Re: [PATCH 02/10] rtw88: Drop rf_lock

From: Pkshih
Date: Thu May 19 2022 - 23:50:00 EST


On Wed, 2022-05-18 at 10:23 +0200, Sascha Hauer wrote:
> 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 <s.hauer@xxxxxxxxxxxxxx>
> ---
> drivers/net/wireless/realtek/rtw88/debug.c | 11 +++++++++++
> drivers/net/wireless/realtek/rtw88/hci.h | 9 +++------
> drivers/net/wireless/realtek/rtw88/main.c | 1 -
> drivers/net/wireless/realtek/rtw88/main.h | 3 ---
> 4 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw88/debug.c
> b/drivers/net/wireless/realtek/rtw88/debug.c
> index 1a52ff585fbc7..ba5ba852efb8c 100644
> --- a/drivers/net/wireless/realtek/rtw88/debug.c
> +++ b/drivers/net/wireless/realtek/rtw88/debug.c
>

[...]

> @@ -523,6 +527,8 @@ static int rtw_debug_get_rf_dump(struct seq_file *m, void *v)
> u32 addr, offset, data;
> u8 path;
>
> + mutex_lock(&rtwdev->mutex);
> +
> for (path = 0; path < rtwdev->hal.rf_path_num; path++) {
> seq_printf(m, "RF path:%d\n", path);
> for (addr = 0; addr < 0x100; addr += 4) {
> @@ -537,6 +543,8 @@ static int rtw_debug_get_rf_dump(struct seq_file *m, void *v)
> seq_puts(m, "\n");
> }
>
> + mutex_unlock(&rtwdev->mutex);
> +
> return 0;
> }
>

This will take time to dump all RF registers for debugging
purpose. For PCI interface, I think this would be okay.
Could you try to dump registers via debufs while you are
using a USB WiFi device, such as play Youtube or download files...

If it doesn't work very well, I suggest to use rf_mutex to
replace rf_lock inplace, but not just remove rf_lock.

--
Ping-Ke