mbox series

[v2,00/17] mt76 patches 2018-08-24 v2

Message ID 1535381791-14908-1-git-send-email-sgruszka@redhat.com (mailing list archive)
Headers show
Series mt76 patches 2018-08-24 v2 | expand

Message

Stanislaw Gruszka Aug. 27, 2018, 2:56 p.m. UTC
This is the begin work of integration between mt76x0 and mt76x2.

Further development can be seen here:
https://github.com/sgruszka/wireless-drivers-next/commits/mt76x0-draft-v2

v1 -> v2:
- rename mt76xx to mt76x02 to reflect that common code is for mt76x0
  and mt76x2 only, not for new chips.
- fixup 'stucture typo' in one patch

Stanislaw Gruszka (17):
  mt76: unify wait_for_mac
  mt76: rename mt76x2_regs.h
  mt76: merge mt76x0/regs.h into mt76x02_regs.h
  mt76: create new mt76x02-lib module for common mt76x{0,2} code
  mt76: fix mt76x02-lib module license
  mt76: unify mac_get_key_info
  mt76: add helpers for register access with mt76_dev struct
  mt76: unify mac_shared_key_setup
  mt76: unify mt76x02_mac_wcid_set_key
  mt76: unify mac_wcid_setup
  mt76: use mac_wcid_set_drop in mt76x0
  mt76x0: use mt76_wcid_free in mt76x0
  mt76: unify mt76x02_vif struct
  mt76: unify sta structure part 1
  mt76: unify sta structure part 2
  mt76x0: initalize custom tx queues
  mt76x0: use mt76x02_sta and mt76x02_tx_status

 drivers/net/wireless/mediatek/mt76/Kconfig         |   6 +
 drivers/net/wireless/mediatek/mt76/Makefile        |   3 +
 drivers/net/wireless/mediatek/mt76/mac80211.c      |   1 +
 drivers/net/wireless/mediatek/mt76/mt76.h          |  13 +
 drivers/net/wireless/mediatek/mt76/mt76x0/init.c   |  37 +-
 drivers/net/wireless/mediatek/mt76/mt76x0/mac.c    | 126 +---
 drivers/net/wireless/mediatek/mt76/mt76x0/mac.h    |   8 +-
 drivers/net/wireless/mediatek/mt76/mt76x0/main.c   | 127 ++--
 drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c    |   4 +-
 drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h |  35 +-
 drivers/net/wireless/mediatek/mt76/mt76x0/regs.h   | 651 --------------------
 drivers/net/wireless/mediatek/mt76/mt76x0/trace.h  |   4 +-
 drivers/net/wireless/mediatek/mt76/mt76x0/tx.c     |   8 +-
 drivers/net/wireless/mediatek/mt76/mt76x0/usb.c    |   5 +-
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.c   | 157 +++++
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.h   |  85 +++
 drivers/net/wireless/mediatek/mt76/mt76x02_regs.h  | 685 +++++++++++++++++++++
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c  |  55 ++
 drivers/net/wireless/mediatek/mt76/mt76x02_util.h  |  25 +
 drivers/net/wireless/mediatek/mt76/mt76x2.h        |  50 +-
 drivers/net/wireless/mediatek/mt76/mt76x2_common.c |  99 +--
 drivers/net/wireless/mediatek/mt76/mt76x2_init.c   |  15 +-
 .../wireless/mediatek/mt76/mt76x2_init_common.c    |   4 +-
 drivers/net/wireless/mediatek/mt76/mt76x2_mac.c    |   4 +-
 drivers/net/wireless/mediatek/mt76/mt76x2_mac.h    |  21 +-
 .../net/wireless/mediatek/mt76/mt76x2_mac_common.c | 130 +---
 drivers/net/wireless/mediatek/mt76/mt76x2_main.c   |  47 +-
 .../net/wireless/mediatek/mt76/mt76x2_phy_common.c |   4 +-
 drivers/net/wireless/mediatek/mt76/mt76x2_regs.h   | 619 -------------------
 drivers/net/wireless/mediatek/mt76/mt76x2_trace.h  |   2 +-
 drivers/net/wireless/mediatek/mt76/mt76x2_tx.c     |   8 +-
 .../net/wireless/mediatek/mt76/mt76x2_tx_common.c  |   8 +-
 drivers/net/wireless/mediatek/mt76/mt76x2u_core.c  |   2 +-
 drivers/net/wireless/mediatek/mt76/mt76x2u_init.c  |   8 +-
 drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c   |   2 +-
 drivers/net/wireless/mediatek/mt76/mt76x2u_main.c  |  29 +-
 36 files changed, 1226 insertions(+), 1861 deletions(-)
 delete mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/regs.h
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_util.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_util.h
 delete mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_regs.h

Comments

Sid Hayn Aug. 29, 2018, 2:26 a.m. UTC | #1
Stanislaw et al,

Thanks for working on this, I have a small stack of different devices
covered by this driver which I'm excited to test with.

I'm running wireless-testing which may or may not be fully up to date
on the patches you have sent (head is at
c9cd161770dd1866207b70d41ec03c9a26eea94f from Aug 13th), so please
tell me if this has already been fixed.  I have a script that attempts
to connect to 16 differently configured SSIDs using 33 different (yet
compatible) wpa_supplicant.conf files and reports failures to me.
It's hardly perfect, but it gives me an idea if something is obviously
broken and needs a deeper dive.  When I run this script against a
device supported by mt76x2 or mt76x0 I get an unusual error.
Everything goes fine, connect, dhcp, disconnect, connect, dhcp,
disconnect, but after about 5 or 6 connections I start getting errors
like this during wpa_supplicant:

Could not set interface t2uh flags (UP): No space left on device
nl80211: Could not set interface 't2uh' UP
nl80211: deinit ifname=t2uh disabled_11b_rates=0
t2uh: Failed to initialize driver interface

and then this with dhcpcd:

dhcpcd_prestartinterface: t2uh: No space left on device
t2uh: waiting for carrier

the same happens with just ifconfig up:

SIOCSIFFLAGS: No space left on device

I see nothing useful in dmesg, and this happens after multiple
successful connections.  I've used this test setup before, and never
seen anything like this.  I will be happy to provide more detail if
requested, but for now here is a list of the tested device which
exhibit this behavior (named for my convenience to the model):

phy1    036acm          mt76x2u         MediaTek Inc.
phy0    pau0a           mt76x0          MediaTek Inc.
phy2    t1u             mt76x0
phy3    t2u             mt76x0          Ralink Technology, Corp.
MT7610U ("Archer T2U" 2.4G+5G WLAN Adapter
phy4    t2uh            mt76x0          Ralink Technology, Corp.
MT7610U ("Archer T2U" 2.4G+5G WLAN Adapter

Last thing I can think of, the tests were not conducted
simultaneously, meaning they didn't all start or fail at once.  I had
multiple successful connections with each one before they
independently failed.

Hope that helps.

Thanks,
Zero_Chaos

(apologies if you got this twice, original bounced from ML)

On Mon, Aug 27, 2018 at 2:58 PM Stanislaw Gruszka <sgruszka@redhat.com> wrote:
>
> This is the begin work of integration between mt76x0 and mt76x2.
>
> Further development can be seen here:
> https://github.com/sgruszka/wireless-drivers-next/commits/mt76x0-draft-v2
>
> v1 -> v2:
> - rename mt76xx to mt76x02 to reflect that common code is for mt76x0
>   and mt76x2 only, not for new chips.
> - fixup 'stucture typo' in one patch
>
> Stanislaw Gruszka (17):
>   mt76: unify wait_for_mac
>   mt76: rename mt76x2_regs.h
>   mt76: merge mt76x0/regs.h into mt76x02_regs.h
>   mt76: create new mt76x02-lib module for common mt76x{0,2} code
>   mt76: fix mt76x02-lib module license
>   mt76: unify mac_get_key_info
>   mt76: add helpers for register access with mt76_dev struct
>   mt76: unify mac_shared_key_setup
>   mt76: unify mt76x02_mac_wcid_set_key
>   mt76: unify mac_wcid_setup
>   mt76: use mac_wcid_set_drop in mt76x0
>   mt76x0: use mt76_wcid_free in mt76x0
>   mt76: unify mt76x02_vif struct
>   mt76: unify sta structure part 1
>   mt76: unify sta structure part 2
>   mt76x0: initalize custom tx queues
>   mt76x0: use mt76x02_sta and mt76x02_tx_status
>
>  drivers/net/wireless/mediatek/mt76/Kconfig         |   6 +
>  drivers/net/wireless/mediatek/mt76/Makefile        |   3 +
>  drivers/net/wireless/mediatek/mt76/mac80211.c      |   1 +
>  drivers/net/wireless/mediatek/mt76/mt76.h          |  13 +
>  drivers/net/wireless/mediatek/mt76/mt76x0/init.c   |  37 +-
>  drivers/net/wireless/mediatek/mt76/mt76x0/mac.c    | 126 +---
>  drivers/net/wireless/mediatek/mt76/mt76x0/mac.h    |   8 +-
>  drivers/net/wireless/mediatek/mt76/mt76x0/main.c   | 127 ++--
>  drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c    |   4 +-
>  drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h |  35 +-
>  drivers/net/wireless/mediatek/mt76/mt76x0/regs.h   | 651 --------------------
>  drivers/net/wireless/mediatek/mt76/mt76x0/trace.h  |   4 +-
>  drivers/net/wireless/mediatek/mt76/mt76x0/tx.c     |   8 +-
>  drivers/net/wireless/mediatek/mt76/mt76x0/usb.c    |   5 +-
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c   | 157 +++++
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.h   |  85 +++
>  drivers/net/wireless/mediatek/mt76/mt76x02_regs.h  | 685 +++++++++++++++++++++
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c  |  55 ++
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.h  |  25 +
>  drivers/net/wireless/mediatek/mt76/mt76x2.h        |  50 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2_common.c |  99 +--
>  drivers/net/wireless/mediatek/mt76/mt76x2_init.c   |  15 +-
>  .../wireless/mediatek/mt76/mt76x2_init_common.c    |   4 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2_mac.c    |   4 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2_mac.h    |  21 +-
>  .../net/wireless/mediatek/mt76/mt76x2_mac_common.c | 130 +---
>  drivers/net/wireless/mediatek/mt76/mt76x2_main.c   |  47 +-
>  .../net/wireless/mediatek/mt76/mt76x2_phy_common.c |   4 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2_regs.h   | 619 -------------------
>  drivers/net/wireless/mediatek/mt76/mt76x2_trace.h  |   2 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2_tx.c     |   8 +-
>  .../net/wireless/mediatek/mt76/mt76x2_tx_common.c  |   8 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2u_core.c  |   2 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2u_init.c  |   8 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c   |   2 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2u_main.c  |  29 +-
>  36 files changed, 1226 insertions(+), 1861 deletions(-)
>  delete mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/regs.h
>  create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
>  create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
>  create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
>  create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_util.c
>  create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_util.h
>  delete mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_regs.h
>
> --
> 2.7.5
>
Stanislaw Gruszka Aug. 29, 2018, 10:27 a.m. UTC | #2
Hi Sid

On Wed, Aug 29, 2018 at 02:26:44AM +0000, Sid Hayn wrote:
> Thanks for working on this, I have a small stack of different devices
> covered by this driver which I'm excited to test with.
> 
> I'm running wireless-testing which may or may not be fully up to date
> on the patches you have sent (head is at
> c9cd161770dd1866207b70d41ec03c9a26eea94f from Aug 13th), so please
> tell me if this has already been fixed.  I have a script that attempts
> to connect to 16 differently configured SSIDs using 33 different (yet
> compatible) wpa_supplicant.conf files and reports failures to me.
> It's hardly perfect, but it gives me an idea if something is obviously
> broken and needs a deeper dive.  When I run this script against a
> device supported by mt76x2 or mt76x0 I get an unusual error.
> Everything goes fine, connect, dhcp, disconnect, connect, dhcp,
> disconnect, but after about 5 or 6 connections I start getting errors
> like this during wpa_supplicant:
> 
> Could not set interface t2uh flags (UP): No space left on device
> nl80211: Could not set interface 't2uh' UP
> nl80211: deinit ifname=t2uh disabled_11b_rates=0
> t2uh: Failed to initialize driver interface
> 
> and then this with dhcpcd:
> 
> dhcpcd_prestartinterface: t2uh: No space left on device
> t2uh: waiting for carrier
> 
> the same happens with just ifconfig up:
> 
> SIOCSIFFLAGS: No space left on device

This looks like some memory leak, not sure where, but it quite probable
that is in the m76x{0,2} driver. You can check periodically using 'free'
command (or in more details by 'cat /proc/meminfo') if memory is
leaking. Then compile kernel with CONFIG_DEBUG_KMEMLEAK to see where
the leak happen.

Regards
Stanislaw
Sid Hayn Aug. 29, 2018, 6:10 p.m. UTC | #3
I rebuilt wireless-testing (which updated today)  with
CONFIG_DEBUG_KMEMLEAK=y.  I am still able to replicate the issue, and
presently have 4 devices in the "No space left on device" state.

This is from /sys/kernel/debug/kmemleak:

unreferenced object 0xffff9183f9a4d000 (size 2048):
  comm "iwconfig", pid 14872, jiffies 4295540797 (age 1233.338s)
  hex dump (first 32 bytes):
    46 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00  F...............
    12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<000000003ec4c8c4>] sta_set_sinfo+0x5d2/0x890 [mac80211]
    [<000000008bbf0699>] ieee80211_get_station+0x4b/0x70 [mac80211]
    [<0000000030cbddbc>] cfg80211_wext_giwrate+0xdb/0x140 [cfg80211]
    [<000000001e9277be>] ioctl_standard_call+0x49/0xd0
    [<00000000a0eeae49>] wext_handle_ioctl+0xbe/0x120
    [<00000000832bf9a4>] sock_ioctl+0x164/0x360
    [<00000000d3578d89>] do_vfs_ioctl+0xa3/0x6c0
    [<0000000036a4185e>] ksys_ioctl+0x6b/0x80
    [<00000000e8443423>] __x64_sys_ioctl+0x11/0x20
    [<00000000e2ddce89>] do_syscall_64+0x50/0xf0
    [<000000005d6a8051>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [<00000000e724c32b>] 0xffffffffffffffff

None of my scripts directly use iwconfig, but it is possible that
wpa_supplicant or dhcpcd invoke it (although a grep of their source
code indicates they do not). In case it matters, this is what my
wpa_supplicant invokation looks like:

wpa_supplicant -Dnl80211 -i ${interface} -c test_config/${conffile}

I am leaving the system in this state for now, I can resume from
broken or reboot to working for whatever testing you suggest next.
This is a test rig, so it takes a few but I'm happy to rebuild
whatever you want however you want it to debug this.

Thanks,
Zero
On Wed, Aug 29, 2018 at 10:27 AM Stanislaw Gruszka <sgruszka@redhat.com> wrote:
>
> Hi Sid
>
> On Wed, Aug 29, 2018 at 02:26:44AM +0000, Sid Hayn wrote:
> > Thanks for working on this, I have a small stack of different devices
> > covered by this driver which I'm excited to test with.
> >
> > I'm running wireless-testing which may or may not be fully up to date
> > on the patches you have sent (head is at
> > c9cd161770dd1866207b70d41ec03c9a26eea94f from Aug 13th), so please
> > tell me if this has already been fixed.  I have a script that attempts
> > to connect to 16 differently configured SSIDs using 33 different (yet
> > compatible) wpa_supplicant.conf files and reports failures to me.
> > It's hardly perfect, but it gives me an idea if something is obviously
> > broken and needs a deeper dive.  When I run this script against a
> > device supported by mt76x2 or mt76x0 I get an unusual error.
> > Everything goes fine, connect, dhcp, disconnect, connect, dhcp,
> > disconnect, but after about 5 or 6 connections I start getting errors
> > like this during wpa_supplicant:
> >
> > Could not set interface t2uh flags (UP): No space left on device
> > nl80211: Could not set interface 't2uh' UP
> > nl80211: deinit ifname=t2uh disabled_11b_rates=0
> > t2uh: Failed to initialize driver interface
> >
> > and then this with dhcpcd:
> >
> > dhcpcd_prestartinterface: t2uh: No space left on device
> > t2uh: waiting for carrier
> >
> > the same happens with just ifconfig up:
> >
> > SIOCSIFFLAGS: No space left on device
>
> This looks like some memory leak, not sure where, but it quite probable
> that is in the m76x{0,2} driver. You can check periodically using 'free'
> command (or in more details by 'cat /proc/meminfo') if memory is
> leaking. Then compile kernel with CONFIG_DEBUG_KMEMLEAK to see where
> the leak happen.
>
> Regards
> Stanislaw
>
Stanislaw Gruszka Aug. 30, 2018, 10:08 a.m. UTC | #4
On Wed, Aug 29, 2018 at 06:10:01PM +0000, Sid Hayn wrote:
> I rebuilt wireless-testing (which updated today)  with
> CONFIG_DEBUG_KMEMLEAK=y.  I am still able to replicate the issue, and
> presently have 4 devices in the "No space left on device" state.
> 
> This is from /sys/kernel/debug/kmemleak:
> 
> unreferenced object 0xffff9183f9a4d000 (size 2048):
>   comm "iwconfig", pid 14872, jiffies 4295540797 (age 1233.338s)
>   hex dump (first 32 bytes):
>     46 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00  F...............
>     12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>   backtrace:
>     [<000000003ec4c8c4>] sta_set_sinfo+0x5d2/0x890 [mac80211]
>     [<000000008bbf0699>] ieee80211_get_station+0x4b/0x70 [mac80211]
>     [<0000000030cbddbc>] cfg80211_wext_giwrate+0xdb/0x140 [cfg80211]
>     [<000000001e9277be>] ioctl_standard_call+0x49/0xd0
>     [<00000000a0eeae49>] wext_handle_ioctl+0xbe/0x120
>     [<00000000832bf9a4>] sock_ioctl+0x164/0x360
>     [<00000000d3578d89>] do_vfs_ioctl+0xa3/0x6c0
>     [<0000000036a4185e>] ksys_ioctl+0x6b/0x80
>     [<00000000e8443423>] __x64_sys_ioctl+0x11/0x20
>     [<00000000e2ddce89>] do_syscall_64+0x50/0xf0
>     [<000000005d6a8051>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
>     [<00000000e724c32b>] 0xffffffffffffffff

I do not see what can leak here. Did you run clear and scan commands,
i.e:

echo clear > /sys/kernel/debug/kmemleak
Run test
echo scan > /sys/kernel/debug/kmemleak
cat /sys/kernel/debug/kmemleak

to get results ? I forgot that this is required (full docs can
be found here: 
https://www.kernel.org/doc/html/v4.16/dev-tools/kmemleak.html).

> None of my scripts directly use iwconfig, but it is possible that
> wpa_supplicant or dhcpcd invoke it (although a grep of their source
> code indicates they do not). In case it matters, this is what my
> wpa_supplicant invokation looks like:
> 
> wpa_supplicant -Dnl80211 -i ${interface} -c test_config/${conffile}
> 
> I am leaving the system in this state for now, I can resume from
> broken or reboot to working for whatever testing you suggest next.
> This is a test rig, so it takes a few but I'm happy to rebuild
> whatever you want however you want it to debug this.

You can move /usr/sbin/iwconfig somewhere and see what will fail,
or remove WEXT support from kernel, perhaps that itself will solve
the problem ;-)

Regards
Stanislaw
Stanislaw Gruszka Sept. 1, 2018, 7:47 a.m. UTC | #5
On Wed, Aug 29, 2018 at 02:26:44AM +0000, Sid Hayn wrote:
> dhcpcd_prestartinterface: t2uh: No space left on device
> t2uh: waiting for carrier
> 
> the same happens with just ifconfig up:
> 
> SIOCSIFFLAGS: No space left on device

I think I found bug that could result in this. Please test
below patch:

https://github.com/sgruszka/wireless-drivers-next/commit/be446879afd6b0e315691e379a2aa4412f05884e.patch

Thanks
Stanislaw
Sid Hayn Sept. 3, 2018, 2:45 a.m. UTC | #6
YES.  That fixed the issue for me.  Confirmed across 4 affected
devices and 1 unaffected device (mt76x2u driver).  After this patch
the issue is resolved.  Thanks for working with me.

I haven't completed all my testing, but the only other thing I've
noticed so far is that firmware version isn't available in ethtool,
while the majority of devices it is.  If you can please squeeze that
in before 4.19 drops it would be great to help with tracking and
debugging when needed.

Thanks,
Zero
On Sat, Sep 1, 2018 at 7:48 AM Stanislaw Gruszka <sgruszka@redhat.com> wrote:
>
> On Wed, Aug 29, 2018 at 02:26:44AM +0000, Sid Hayn wrote:
> > dhcpcd_prestartinterface: t2uh: No space left on device
> > t2uh: waiting for carrier
> >
> > the same happens with just ifconfig up:
> >
> > SIOCSIFFLAGS: No space left on device
>
> I think I found bug that could result in this. Please test
> below patch:
>
> https://github.com/sgruszka/wireless-drivers-next/commit/be446879afd6b0e315691e379a2aa4412f05884e.patch
>
> Thanks
> Stanislaw