wifi: mt76: mt792x: describe USB WFSYS reset with a descriptor
Subsystems (3)
PATCH 1/2 wifi: mt76: mt792x: describe USB WFSYS reset with a descriptor
From: Sean Wang <[email protected]>
Prepare mt792xu_wfsys_reset() for chips that share the same USB WFSYS reset flow but use different register definitions.
This is a pure refactor of the current mt7921u path and keeps the reset sequence unchanged.
--- .../net/wireless/mediatek/mt76/mt792x_usb.c | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt792x_usb.c +32 -8
@@ -206,6 +206,24 @@ static void mt792xu_epctl_rst_opt(struct mt792x_dev *dev, bool reset)mt792xu_uhw_wr (&dev->mt76,MT_SSUSB_EPCTL_CSR_EP_RST_OPT , val); } +struct mt792xu_wfsys_desc { +u32 rst_reg; +u32 done_reg; +u32 done_mask; +u32 done_val; +u32 delay_ms; +bool need_status_sel; +}; + +static const struct mt792xu_wfsys_desc mt7921_wfsys_desc = { + .rst_reg =MT_CBTOP_RGU_WF_SUBSYS_RST , + .done_reg =MT_UDMA_CONN_INFRA_STATUS , + .done_mask =MT_UDMA_CONN_WFSYS_INIT_DONE , + .done_val =MT_UDMA_CONN_WFSYS_INIT_DONE , + .delay_ms =0 , + .need_status_sel = true, +}; +int mt792xu_dma_init (struct mt792x_dev *dev,bool resume) {int err;
@@ -236,25 +254,31 @@ EXPORT_SYMBOL_GPL(mt792xu_dma_init);int mt792xu_wfsys_reset (struct mt792x_dev *dev) { +const struct mt792xu_wfsys_desc *desc = &mt7921_wfsys_desc;u32 val;int i;mt792xu_epctl_rst_opt (dev, false); - val =mt792xu_uhw_rr (&dev->mt76,MT_CBTOP_RGU_WF_SUBSYS_RST ); + val =mt792xu_uhw_rr (&dev->mt76, desc->rst_reg); val |=MT_CBTOP_RGU_WF_SUBSYS_RST_WF_WHOLE_PATH ; -mt792xu_uhw_wr (&dev->mt76,MT_CBTOP_RGU_WF_SUBSYS_RST , val); +mt792xu_uhw_wr (&dev->mt76, desc->rst_reg, val); -usleep_range (10 ,20 ); +if (desc->delay_ms) +msleep (desc->delay_ms); +else +usleep_range (10 ,20 ); - val =mt792xu_uhw_rr (&dev->mt76,MT_CBTOP_RGU_WF_SUBSYS_RST ); + val =mt792xu_uhw_rr (&dev->mt76, desc->rst_reg); val &= ~MT_CBTOP_RGU_WF_SUBSYS_RST_WF_WHOLE_PATH ; -mt792xu_uhw_wr (&dev->mt76,MT_CBTOP_RGU_WF_SUBSYS_RST , val); +mt792xu_uhw_wr (&dev->mt76, desc->rst_reg, val); + +if (desc->need_status_sel) +mt792xu_uhw_wr (&dev->mt76,MT_UDMA_CONN_INFRA_STATUS_SEL ,0 ); -mt792xu_uhw_wr (&dev->mt76,MT_UDMA_CONN_INFRA_STATUS_SEL ,0 );for (i =0 ; i < MT792x_WFSYS_INIT_RETRY_COUNT; i++) { - val =mt792xu_uhw_rr (&dev->mt76,MT_UDMA_CONN_INFRA_STATUS ); -if (val &MT_UDMA_CONN_WFSYS_INIT_DONE ) + val =mt792xu_uhw_rr (&dev->mt76, desc->done_reg); +if ((val & desc->done_mask) == desc->done_val)break ;msleep (100 );
Signature · 1 line
2.43.0
PATCH 2/2 wifi: mt76: mt792x: fix mt7925u USB WFSYS reset handling
From: Sean Wang <[email protected]>
mt7925u uses different reset/status registers from mt7921u. Reusing the mt7921u register set causes the WFSYS reset to fail.
Add a chip-specific descriptor in mt792xu_wfsys_reset() to select the correct registers and fix mt7925u failing to initialize after a warm reboot.
--- drivers/net/wireless/mediatek/mt76/mt792x_regs.h | 4 ++++ drivers/net/wireless/mediatek/mt76/mt792x_usb.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt792x_regs.h +4 -0
@@ -392,6 +392,10 @@#define MT_CBTOP_RGU_WF_SUBSYS_RST MT_CBTOP_RGU(0x600)#define MT_CBTOP_RGU_WF_SUBSYS_RST_WF_WHOLE_PATH BIT(0) +#define MT7925_CBTOP_RGU_WF_SUBSYS_RST 0x70028600 +#define MT7925_WFSYS_INIT_DONE_ADDR 0x184c1604 +#define MT7925_WFSYS_INIT_DONE 0x00001d1e +#define MT_HW_BOUND 0x70010020#define MT_HW_CHIPID 0x70010200#define MT_HW_REV 0x70010204
drivers/net/wireless/mediatek/mt76/mt792x_usb.c +12 -1
@@ -224,6 +224,15 @@ static const struct mt792xu_wfsys_desc mt7921_wfsys_desc = { .need_status_sel = true, }; +static const struct mt792xu_wfsys_desc mt7925_wfsys_desc = { + .rst_reg =MT7925_CBTOP_RGU_WF_SUBSYS_RST , + .done_reg =MT7925_WFSYS_INIT_DONE_ADDR , + .done_mask =U32_MAX , + .done_val =MT7925_WFSYS_INIT_DONE , + .delay_ms =20 , + .need_status_sel = false, +}; +int mt792xu_dma_init (struct mt792x_dev *dev,bool resume) {int err;
@@ -254,7 +263,9 @@ EXPORT_SYMBOL_GPL(mt792xu_dma_init);int mt792xu_wfsys_reset (struct mt792x_dev *dev) { -const struct mt792xu_wfsys_desc *desc = &mt7921_wfsys_desc; +const struct mt792xu_wfsys_desc *desc =is_mt7925 (&dev->mt76) ? + &mt7925_wfsys_desc : + &mt7921_wfsys_desc;u32 val;int i;
Signature · 1 line
2.43.0
Re: [PATCH 2/2] wifi: mt76: mt792x: fix mt7925u USB WFSYS reset handling
Quoted 64 lines
From: Sean Wang <[email protected]>
mt7925u uses different reset/status registers from mt7921u. Reusing the mt7921u register set causes the WFSYS reset to fail.
Add a chip-specific descriptor in
mt792xu_wfsys_reset()to select the correct registers and fix mt7925u failing to initialize after a warm reboot.Fixes d28e1a48952e ("wifi: mt76: mt792x: introduce mt792x-usb module")Signed-off-by Sean Wang <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt792x_regs.h | 4 ++++ drivers/net/wireless/mediatek/mt76/mt792x_usb.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/mt792x_regs.h +4
-0@@ -392,6 +392,10 @@#define MT_CBTOP_RGU_WF_SUBSYS_RST MT_CBTOP_RGU(0x600)#define MT_CBTOP_RGU_WF_SUBSYS_RST_WF_WHOLE_PATH BIT(0) +#define MT7925_CBTOP_RGU_WF_SUBSYS_RST 0x70028600 +#define MT7925_WFSYS_INIT_DONE_ADDR 0x184c1604 +#define MT7925_WFSYS_INIT_DONE 0x00001d1e +#define MT_HW_BOUND 0x70010020#define MT_HW_CHIPID 0x70010200#define MT_HW_REV 0x70010204drivers/net/wireless/mediatek/mt76/mt792x_usb.c +12
-2@@ -224,6 +224,15 @@ static const struct mt792xu_wfsys_desc mt7921_wfsys_desc = { .need_status_sel = true, }; +static const struct mt792xu_wfsys_desc mt7925_wfsys_desc = { + .rst_reg =MT7925_CBTOP_RGU_WF_SUBSYS_RST , + .done_reg =MT7925_WFSYS_INIT_DONE_ADDR , + .done_mask =U32_MAX , + .done_val =MT7925_WFSYS_INIT_DONE , + .delay_ms =20 , + .need_status_sel = false, +}; +int mt792xu_dma_init (struct mt792x_dev *dev,bool resume) {int err;@@ -254,7 +263,9 @@ EXPORT_SYMBOL_GPL(mt792xu_dma_init);int mt792xu_wfsys_reset (struct mt792x_dev *dev) { -const struct mt792xu_wfsys_desc *desc = &mt7921_wfsys_desc; +const struct mt792xu_wfsys_desc *desc =is_mt7925 (&dev->mt76) ? + &mt7925_wfsys_desc : + &mt7921_wfsys_desc;u32 val;int i; --
Quoted 2 lines
2.43.0
Sean, testing results from: Satadru Pramanik <[email protected]>
"The updated patches from
https://patchwork.kernel.org/project/linux-wireless/list/?series=1064695
do NOT work. I get the -110 error with them on a warm reboot. Reverting to the kernel with the older patch restores my adapter connection on a warm reboot."
You are welcome to stop by the Github issue where this issue is being discussed:
https://github.com/morrownr/USB-WiFi/issues/688#
Nick
A message that is not in the archive (sent off-list or not yet received): CAFrh3J-PsVQ1u_hGFxTVKK0uOs6KxT=euK+jbGvWCueqvynAgw@mail.gmail.com
Re: [PATCH 2/2] wifi: mt76: mt792x: fix mt7925u USB WFSYS reset handling
After rebuilding the kernel with 7.0-rc3 and the two patches at
https://patchwork.kernel.org/project/linux-wireless/list/?series=1064695,
I can confirm that after a warm reboot booted from that kernel, the mt7925u-based adapter is once again visible.
Thanks!
Regards,
Satadru Pramanik
Quoted 89 lines · Satadru Pramanik
Hello all, I'm rebuilding this kernel one more time in case I mispatched, and will let you know shortly if a new kernel build works.
Regards,
Satadru
Quoted 81 lines · Nick
Quoted 65 lines
From: Sean Wang <[email protected]>
mt7925u uses different reset/status registers from mt7921u. Reusing the mt7921u register set causes the WFSYS reset to fail.
Add a chip-specific descriptor in
mt792xu_wfsys_reset()to select the correct registers and fix mt7925u failing to initialize after a warm reboot.Fixes d28e1a48952e ("wifi: mt76: mt792x: introduce mt792x-usb module")Signed-off-by Sean Wang <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt792x_regs.h | 4 ++++ drivers/net/wireless/mediatek/mt76/mt792x_usb.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/mt792x_regs.h +4
-0@@ -392,6 +392,10 @@#define MT_CBTOP_RGU_WF_SUBSYS_RST MT_CBTOP_RGU(0x600)#define MT_CBTOP_RGU_WF_SUBSYS_RST_WF_WHOLE_PATH BIT(0) +#define MT7925_CBTOP_RGU_WF_SUBSYS_RST 0x70028600 +#define MT7925_WFSYS_INIT_DONE_ADDR 0x184c1604 +#define MT7925_WFSYS_INIT_DONE 0x00001d1e +#define MT_HW_BOUND 0x70010020#define MT_HW_CHIPID 0x70010200#define MT_HW_REV 0x70010204drivers/net/wireless/mediatek/mt76/mt792x_usb.c +12
-2@@ -224,6 +224,15 @@ static const struct mt792xu_wfsys_desc mt7921_wfsys_desc = { .need_status_sel = true, }; +static const struct mt792xu_wfsys_desc mt7925_wfsys_desc = { + .rst_reg =MT7925_CBTOP_RGU_WF_SUBSYS_RST , + .done_reg =MT7925_WFSYS_INIT_DONE_ADDR , + .done_mask =U32_MAX , + .done_val =MT7925_WFSYS_INIT_DONE , + .delay_ms =20 , + .need_status_sel = false, +}; +int mt792xu_dma_init (struct mt792x_dev *dev,bool resume) {int err;@@ -254,7 +263,9 @@ EXPORT_SYMBOL_GPL(mt792xu_dma_init);int mt792xu_wfsys_reset (struct mt792x_dev *dev) { -const struct mt792xu_wfsys_desc *desc = &mt7921_wfsys_desc; +const struct mt792xu_wfsys_desc *desc =is_mt7925 (&dev->mt76) ? + &mt7925_wfsys_desc : + &mt7921_wfsys_desc;u32 val;int i; --Quoted 2 lines
2.43.0
Sean, testing results from: Satadru Pramanik <[email protected]>
"The updated patches from
https://patchwork.kernel.org/project/linux-wireless/list/?series=1064695
do NOT work. I get the -110 error with them on a warm reboot. Reverting to the kernel with the older patch restores my adapter connection on a warm reboot."You are welcome to stop by the Github issue where this issue is being discussed:
https://github.com/morrownr/USB-WiFi/issues/688#
Nick
Nick
Tested-byRe: [PATCH 2/2] wifi: mt76: mt792x: fix mt7925u USB WFSYS reset handling
Quoted 63 lines
Quoted 63 lines
Quoted 63 lines
Quoted 63 lines
From: Sean Wang <[email protected]>
mt7925u uses different reset/status registers from mt7921u. Reusing the mt7921u register set causes the WFSYS reset to fail.
Add a chip-specific descriptor in
mt792xu_wfsys_reset()to select the correct registers and fix mt7925u failing to initialize after a warm reboot.Fixes d28e1a48952e ("wifi: mt76: mt792x: introduce mt792x-usb module")Signed-off-by Sean Wang <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt792x_regs.h | 4 ++++ drivers/net/wireless/mediatek/mt76/mt792x_usb.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/mt792x_regs.h +4
-0@@ -392,6 +392,10 @@#define MT_CBTOP_RGU_WF_SUBSYS_RST MT_CBTOP_RGU(0x600)#define MT_CBTOP_RGU_WF_SUBSYS_RST_WF_WHOLE_PATH BIT(0) +#define MT7925_CBTOP_RGU_WF_SUBSYS_RST 0x70028600 +#define MT7925_WFSYS_INIT_DONE_ADDR 0x184c1604 +#define MT7925_WFSYS_INIT_DONE 0x00001d1e +#define MT_HW_BOUND 0x70010020#define MT_HW_CHIPID 0x70010200#define MT_HW_REV 0x70010204drivers/net/wireless/mediatek/mt76/mt792x_usb.c +12
-1@@ -224,6 +224,15 @@ static const struct mt792xu_wfsys_desc mt7921_wfsys_desc = { .need_status_sel = true, }; +static const struct mt792xu_wfsys_desc mt7925_wfsys_desc = { + .rst_reg =MT7925_CBTOP_RGU_WF_SUBSYS_RST , + .done_reg =MT7925_WFSYS_INIT_DONE_ADDR , + .done_mask =U32_MAX , + .done_val =MT7925_WFSYS_INIT_DONE , + .delay_ms =20 , + .need_status_sel = false, +}; +int mt792xu_dma_init (struct mt792x_dev *dev,bool resume) {int err;@@ -254,7 +263,9 @@ EXPORT_SYMBOL_GPL(mt792xu_dma_init);int mt792xu_wfsys_reset (struct mt792x_dev *dev) { -const struct mt792xu_wfsys_desc *desc = &mt7921_wfsys_desc; +const struct mt792xu_wfsys_desc *desc =is_mt7925 (&dev->mt76) ? + &mt7925_wfsys_desc : + &mt7921_wfsys_desc;u32 val;int i;
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
--
2.43.0
Sean, I have been testing this series of 2 patches for the last two days. I am no longer seeing problems with warm boot so:
Thanks.