Skip to content

Commit 7616c12

Browse files
saschahauer981213
authored andcommitted
wifi: rtw88: Drop rf_lock
The rtwdev->rf_lock spinlock protects the rf register accesses in rtw_read_rf() and rtw_write_rf(). Most callers of these functions hold rtwdev->mutex already with the exception of the callsites in the debugfs code. The debugfs code doesn't justify an extra lock, so acquire the mutex there as well before calling rf register accessors and drop the now unnecessary spinlock. Signed-off-by: Sascha Hauer <[email protected]> Reviewed-by: Ping-Ke Shih <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent dd0cfc5 commit 7616c12

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

debug.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ static int rtw_debugfs_get_rf_read(struct seq_file *m, void *v)
144144
addr = debugfs_priv->rf_addr;
145145
mask = debugfs_priv->rf_mask;
146146

147+
mutex_lock(&rtwdev->mutex);
147148
val = rtw_read_rf(rtwdev, path, addr, mask);
149+
mutex_unlock(&rtwdev->mutex);
148150

149151
seq_printf(m, "rf_read path:%d addr:0x%08x mask:0x%08x val=0x%08x\n",
150152
path, addr, mask, val);
@@ -414,7 +416,9 @@ static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
414416
return count;
415417
}
416418

419+
mutex_lock(&rtwdev->mutex);
417420
rtw_write_rf(rtwdev, path, addr, mask, val);
421+
mutex_unlock(&rtwdev->mutex);
418422
rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
419423
"write_rf path:%d addr:0x%08x mask:0x%08x, val:0x%08x\n",
420424
path, addr, mask, val);
@@ -519,6 +523,8 @@ static int rtw_debug_get_rf_dump(struct seq_file *m, void *v)
519523
u32 addr, offset, data;
520524
u8 path;
521525

526+
mutex_lock(&rtwdev->mutex);
527+
522528
for (path = 0; path < rtwdev->hal.rf_path_num; path++) {
523529
seq_printf(m, "RF path:%d\n", path);
524530
for (addr = 0; addr < 0x100; addr += 4) {
@@ -533,6 +539,8 @@ static int rtw_debug_get_rf_dump(struct seq_file *m, void *v)
533539
seq_puts(m, "\n");
534540
}
535541

542+
mutex_unlock(&rtwdev->mutex);
543+
536544
return 0;
537545
}
538546

@@ -1026,6 +1034,8 @@ static void dump_gapk_status(struct rtw_dev *rtwdev, struct seq_file *m)
10261034
dm_info->dm_flags & BIT(RTW_DM_CAP_TXGAPK) ? '-' : '+',
10271035
rtw_dm_cap_strs[RTW_DM_CAP_TXGAPK]);
10281036

1037+
mutex_lock(&rtwdev->mutex);
1038+
10291039
for (path = 0; path < rtwdev->hal.rf_path_num; path++) {
10301040
val = rtw_read_rf(rtwdev, path, RF_GAINTX, RFREG_MASK);
10311041
seq_printf(m, "path %d:\n0x%x = 0x%x\n", path, RF_GAINTX, val);
@@ -1035,6 +1045,7 @@ static void dump_gapk_status(struct rtw_dev *rtwdev, struct seq_file *m)
10351045
txgapk->rf3f_fs[path][i], i);
10361046
seq_puts(m, "\n");
10371047
}
1048+
mutex_unlock(&rtwdev->mutex);
10381049
}
10391050

10401051
static int rtw_debugfs_get_dm_cap(struct seq_file *m, void *v)

hci.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,11 @@ static inline u32
166166
rtw_read_rf(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
167167
u32 addr, u32 mask)
168168
{
169-
unsigned long flags;
170169
u32 val;
171170

172-
spin_lock_irqsave(&rtwdev->rf_lock, flags);
171+
lockdep_assert_held(&rtwdev->mutex);
172+
173173
val = rtwdev->chip->ops->read_rf(rtwdev, rf_path, addr, mask);
174-
spin_unlock_irqrestore(&rtwdev->rf_lock, flags);
175174

176175
return val;
177176
}
@@ -180,11 +179,9 @@ static inline void
180179
rtw_write_rf(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
181180
u32 addr, u32 mask, u32 data)
182181
{
183-
unsigned long flags;
182+
lockdep_assert_held(&rtwdev->mutex);
184183

185-
spin_lock_irqsave(&rtwdev->rf_lock, flags);
186184
rtwdev->chip->ops->write_rf(rtwdev, rf_path, addr, mask, data);
187-
spin_unlock_irqrestore(&rtwdev->rf_lock, flags);
188185
}
189186

190187
static inline u32

main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,6 @@ int rtw_core_init(struct rtw_dev *rtwdev)
21832183
skb_queue_head_init(&rtwdev->coex.queue);
21842184
skb_queue_head_init(&rtwdev->tx_report.queue);
21852185

2186-
spin_lock_init(&rtwdev->rf_lock);
21872186
spin_lock_init(&rtwdev->h2c.lock);
21882187
spin_lock_init(&rtwdev->txq_lock);
21892188
spin_lock_init(&rtwdev->tx_report.q_lock);

main.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,9 +2092,6 @@ struct rtw_dev {
20922092
/* ensures exclusive access from mac80211 callbacks */
20932093
struct mutex mutex;
20942094

2095-
/* read/write rf register */
2096-
spinlock_t rf_lock;
2097-
20982095
/* watch dog every 2 sec */
20992096
struct delayed_work watch_dog_work;
21002097
u32 watch_dog_cnt;

0 commit comments

Comments
 (0)