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

From: s.hauer@xxxxxxxxxxxxxx
Date: Fri May 20 2022 - 02:54:54 EST


On Fri, May 20, 2022 at 03:49:06AM +0000, Pkshih wrote:
> 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...

I just did a ping and iperf test while doing a:

while true; do cat /sys/kernel/debug/ieee80211/phy0/rtw88/rf_dump ; done

The register dumping has no influence on neither the throughput or the
latency.

Adding some debugging to the mutex_lock also tells why: rtwdev->mutex
isn't acquired for normal rx/tx. It is only acquired every two seconds
or so.

So I would say adding the mutex_lock around the register dump is not a
problem. If latency is a concern we could still move the mutex_lock()
into the loop.

Sascha

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |