wifi: rtw88: 8821cu: Fix firmware upload fail
Subsystems (2)
PATCH v2 1/4 wifi: rtw88: 8821cu: Fix firmware upload fail
RTL8822CU, RTL8822BU, and RTL8821CU need an extra register write after reading and writing certain addresses.
Without this, the firmware upload fails approximately more than 50% of the time.
Tested with RTL8811CU (Tenda U9 V2.0) which is the same as RTL8821CU but without Bluetooth.
---
v2:
- Simplify the code and add comments, as suggested.
--- drivers/net/wireless/realtek/rtw88/usb.c | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/net/wireless/realtek/rtw88/usb.c +40 -0
@@ -33,6 +33,36 @@ static void rtw_usb_fill_tx_checksum(struct rtw_usb *rtwusb,rtw_tx_fill_txdesc_checksum (rtwdev, &pkt_info, skb->data); } +static void rtw_usb_reg_sec (struct rtw_dev *rtwdev,u32 addr,__le32 *data) +{ +struct rtw_usb *rtwusb =rtw_get_usb_priv (rtwdev); +struct usb_device *udev = rtwusb->udev; +bool reg_on_section = false; +u16 t_reg =0x4e0 ; +u8 t_len =1 ; +int status; + +/* There are three sections: +* 1. on (0x00~0xFF; 0x1000~0x10FF): this section is always powered on +* 2. off (< 0xFE00, excluding "on" section): this section could be +* powered off +* 3. local (>= 0xFE00): usb specific registers section +*/ +if (addr <=0xff || (addr >=0x1000 && addr <=0x10ff )) + reg_on_section = true; + +if (!reg_on_section) +return ; + + status =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ), +RTW_USB_CMD_REQ ,RTW_USB_CMD_WRITE , + t_reg,0 , data, t_len,500 ); + +if (status != t_len && status != -ENODEV ) +rtw_err (rtwdev,"%s: reg 0x%x, usb write %u fail, status: %d\n" , + __func__, t_reg, t_len, status); +} +static u32 rtw_usb_read (struct rtw_dev *rtwdev,u32 addr,u16 len) {struct rtw_usb *rtwusb =rtw_get_usb_priv (rtwdev);
@@ -58,6 +88,11 @@ static u32 rtw_usb_read(struct rtw_dev *rtwdev, u32 addr, u16 len)rtw_err (rtwdev,"read register 0x%x failed with %d\n" , addr, ret); +if (rtwdev->chip->id ==RTW_CHIP_TYPE_8822C || + rtwdev->chip->id ==RTW_CHIP_TYPE_8822B || + rtwdev->chip->id ==RTW_CHIP_TYPE_8821C ) +rtw_usb_reg_sec (rtwdev, addr, data); +return le32_to_cpu (*data); }
@@ -111,6 +146,11 @@ static void rtw_usb_write(struct rtw_dev *rtwdev, u32 addr, u32 val, int len)if (ret <0 && ret != -ENODEV && count++ <4 )rtw_err (rtwdev,"write register 0x%x failed with %d\n" , addr, ret); + +if (rtwdev->chip->id ==RTW_CHIP_TYPE_8822C || + rtwdev->chip->id ==RTW_CHIP_TYPE_8822B || + rtwdev->chip->id ==RTW_CHIP_TYPE_8821C ) +rtw_usb_reg_sec (rtwdev, addr, data); }static void rtw_usb_write8 (struct rtw_dev *rtwdev,u32 addr,u8 val)
Signature · 1 line
2.43.2
PATCH v2 2/4 wifi: rtw88: 8821cu: Fix connection failure
Clear bit 8 of REG_SYS_STATUS1 after MAC power on.
Without this, some RTL8821CU and RTL8811CU cannot connect to any network:
Feb 19 13:33:11 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 1/3) Feb 19 13:33:13 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 2/3) Feb 19 13:33:14 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 3/3) Feb 19 13:33:15 ideapad2 kernel: wlp3s0f3u2: authentication with 90:55:de:__:__:__ timed out
The RTL8822CU and RTL8822BU out-of-tree drivers do this as well, so do it for all three types of chips.
Tested with RTL8811CU (Tenda U9 V2.0).
---
v2:
- Check for pwr_on instead of pwr_seq == chip->pwr_on_seq.
--- drivers/net/wireless/realtek/rtw88/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/realtek/rtw88/mac.c +7 -0
@@ -309,6 +309,13 @@ static int rtw_mac_power_switch(struct rtw_dev *rtwdev, bool pwr_on) pwr_seq = pwr_on ? chip->pwr_on_seq : chip->pwr_off_seq; ret =rtw_pwr_seq_parser (rtwdev, pwr_seq); +if (pwr_on &&rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_USB ) { +if (chip->id ==RTW_CHIP_TYPE_8822C || + chip->id ==RTW_CHIP_TYPE_8822B || + chip->id ==RTW_CHIP_TYPE_8821C ) +rtw_write8_clr (rtwdev,REG_SYS_STATUS1 +1 ,BIT (0 )); + } +if (rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_SDIO )rtw_write32 (rtwdev,REG_SDIO_HIMR , imr);
Signature · 1 line
2.43.2
RE: [PATCH v2 2/4] wifi: rtw88: 8821cu: Fix connection failure
Quoted 23 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Friday, March 1, 2024 6:34 AM
To: [email protected]
Cc: Ping-Ke Shih <[email protected]>; Sascha Hauer <[email protected]>
Subject: [PATCH v2 2/4] wifi: rtw88: 8821cu: Fix connection failureClear bit 8 of
REG_SYS_STATUS1after MAC power on.Without this, some RTL8821CU and RTL8811CU cannot connect to any network:
Feb 19 13:33:11 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 1/3) Feb 19 13:33:13 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 2/3) Feb 19 13:33:14 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 3/3) Feb 19 13:33:15 ideapad2 kernel: wlp3s0f3u2: authentication with 90:55:de:__:__:__ timed out
Quoted 6 lines
The RTL8822CU and RTL8822BU out-of-tree drivers do this as well, so do it for all three types of chips.
Tested with RTL8811CU (Tenda U9 V2.0).
Signed-off-by Bitterblue Smith <[email protected]>
PATCH v2 3/4 wifi: rtw88: 8821c: Fix beacon loss and disconnect
In reply to Bitterblue SmithTenda U9 V2.0, which contains RTL8811CU, is practically unusable because of frequent disconnections:
Feb 23 14:46:45 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-BEACON-LOSS Feb 23 14:46:46 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-DISCONNECTED bssid=90:55:de:__:__:__ reason=4 locally_generated=1
Feb 23 14:46:52 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-CONNECTED - Connection to 90:55:de:__:__:__ completed [id=0 id_str=] Feb 23 14:46:54 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-BEACON-LOSS Feb 23 14:46:55 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-DISCONNECTED bssid=90:55:de:__:__:__ reason=4 locally_generated=1
Feb 23 14:47:01 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-CONNECTED - Connection to 90:55:de:__:__:__ completed [id=0 id_str=] Feb 23 14:47:04 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-BEACON-LOSS Feb 23 14:47:05 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-DISCONNECTED bssid=90:55:de:__:__:__ reason=4 locally_generated=1
This is caused by a mistake in the chip initialisation. This version of the chip requires loading an extra AGC table right after the main one, but the extra table is being loaded at the wrong time, in rtw_chip_board_info_setup().
Move the extra AGC table loading to the right place, in rtw_phy_load_tables().
The rtw_chip_board_info_setup() can only do "software" things, and rtw_phy_load_tables() can really do IO.
---
v2:
- Add more information in the commit message.
--- drivers/net/wireless/realtek/rtw88/main.c | 2 -- drivers/net/wireless/realtek/rtw88/phy.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/main.c +0 -2
@@ -2032,8 +2032,6 @@ static int rtw_chip_board_info_setup(struct rtw_dev *rtwdev)rtw_phy_setup_phy_cond (rtwdev, hal->pkg_type);rtw_phy_init_tx_power (rtwdev); -if (rfe_def->agc_btg_tbl) -rtw_load_table (rtwdev, rfe_def->agc_btg_tbl);rtw_load_table (rtwdev, rfe_def->phy_pg_tbl);rtw_load_table (rtwdev, rfe_def->txpwr_lmt_tbl);rtw_phy_tx_power_by_rate_config (hal);
drivers/net/wireless/realtek/rtw88/phy.c +3 -0
@@ -1761,12 +1761,15 @@ static void rtw_load_rfk_table(struct rtw_dev *rtwdev)void rtw_phy_load_tables (struct rtw_dev *rtwdev) { +const struct rtw_rfe_def *rfe_def =rtw_get_rfe_def (rtwdev);const struct rtw_chip_info *chip = rtwdev->chip;u8 rf_path;rtw_load_table (rtwdev, chip->mac_tbl);rtw_load_table (rtwdev, chip->bb_tbl);rtw_load_table (rtwdev, chip->agc_tbl); +if (rfe_def->agc_btg_tbl) +rtw_load_table (rtwdev, rfe_def->agc_btg_tbl);rtw_load_rfk_table (rtwdev);for (rf_path =0 ; rf_path < rtwdev->hal.rf_path_num; rf_path++) {
Signature · 1 line
2.43.2
RE: [PATCH v2 3/4] wifi: rtw88: 8821c: Fix beacon loss and disconnect
Quoted 33 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Friday, March 1, 2024 6:35 AM
To: [email protected]
Cc: Ping-Ke Shih <[email protected]>; Sascha Hauer <[email protected]>
Subject: [PATCH v2 3/4] wifi: rtw88: 8821c: Fix beacon loss and disconnectTenda U9 V2.0, which contains RTL8811CU, is practically unusable because of frequent disconnections:
Feb 23 14:46:45 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-BEACON-LOSS Feb 23 14:46:46 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-DISCONNECTED bssid=90:55:de:__:__:__ reason=4 locally_generated=1Feb 23 14:46:52 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-CONNECTED - Connection to 90:55:de:__:__:__ completed [id=0 id_str=] Feb 23 14:46:54 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-BEACON-LOSS Feb 23 14:46:55 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-DISCONNECTED bssid=90:55:de:__:__:__ reason=4 locally_generated=1Feb 23 14:47:01 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-CONNECTED - Connection to 90:55:de:__:__:__ completed [id=0 id_str=] Feb 23 14:47:04 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-BEACON-LOSS Feb 23 14:47:05 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-DISCONNECTED bssid=90:55:de:__:__:__ reason=4 locally_generated=1This is caused by a mistake in the chip initialisation. This version of the chip requires loading an extra AGC table right after the main one, but the extra table is being loaded at the wrong time, in
rtw_chip_board_info_setup().
Quoted 8 lines
Move the extra AGC table loading to the right place, in
rtw_phy_load_tables().The
rtw_chip_board_info_setup()can only do "software" things, andrtw_phy_load_tables()can really do IO.Fixes 5d6651fe8583 ("rtw88: 8821c: support RFE type2 wifi NIC")Signed-off-by Bitterblue Smith <[email protected]>
PATCH v2 4/4 wifi: rtw88: 8821c: Fix false alarm count
In reply to Bitterblue Smithtotal_fa_cnt is supposed to include cck_fa_cnt and ofdm_fa_cnt, not just ofdm_fa_cnt.
---
v2:
- No change.
--- drivers/net/wireless/realtek/rtw88/rtw8821c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/rtw8821c.c +1 -1
@@ -773,9 +773,9 @@ static void rtw8821c_false_alarm_statistics(struct rtw_dev *rtwdev) dm_info->cck_fa_cnt = cck_fa_cnt; dm_info->ofdm_fa_cnt = ofdm_fa_cnt; + dm_info->total_fa_cnt = ofdm_fa_cnt;if (cck_enable) dm_info->total_fa_cnt += cck_fa_cnt; - dm_info->total_fa_cnt = ofdm_fa_cnt; crc32_cnt =rtw_read32 (rtwdev,REG_CRC_CCK ); dm_info->cck_ok_cnt =FIELD_GET (GENMASK (15 ,0 ), crc32_cnt);
Signature · 1 line
2.43.2
RE: [PATCH v2 4/4] wifi: rtw88: 8821c: Fix false alarm count
Quoted 9 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Friday, March 1, 2024 6:36 AM
To: [email protected]
Cc: Ping-Ke Shih <[email protected]>; Sascha Hauer <[email protected]>
Subject: [PATCH v2 4/4] wifi: rtw88: 8821c: Fix false alarm count
Quoted 5 lines
total_fa_cntis supposed to includecck_fa_cntandofdm_fa_cnt, not justofdm_fa_cnt.Fixes 960361238b86 ("rtw88: 8821c: add false alarm statistics")Signed-off-by Bitterblue Smith <[email protected]>
Thanks for your great work!
Quoted 12 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Friday, March 1, 2024 6:33 AM
To: [email protected]
Cc: Ping-Ke Shih <[email protected]>; Sascha Hauer <[email protected]>; Sean Mollet <[email protected]>
Subject: [PATCH v2 1/4] wifi: rtw88: 8821cu: Fix firmware upload failRTL8822CU, RTL8822BU, and RTL8821CU need an extra register write after reading and writing certain addresses.
Quoted 8 lines
Without this, the firmware upload fails approximately more than 50% of the time.
Tested with RTL8811CU (Tenda U9 V2.0) which is the same as RTL8821CU but without Bluetooth.
Fixes a82dfd33d123 ("wifi: rtw88: Add common USB chip support")Signed-off-by Bitterblue Smith <[email protected]>
Quoted 6 lines · Bitterblue Smith
RTL8822CU, RTL8822BU, and RTL8821CU need an extra register write after reading and writing certain addresses.
Without this, the firmware upload fails approximately more than 50% of the time.
Quoted 6 lines
Tested with RTL8811CU (Tenda U9 V2.0) which is the same as RTL8821CU but without Bluetooth.
Fixes a82dfd33d123 ("wifi: rtw88: Add common USB chip support")Signed-off-by Bitterblue Smith <[email protected]>Acked-by Ping-Ke Shih <[email protected]>
4 patches applied to wireless-next.git, thanks.
41a7acb7dde8 wifi: rtw88: 8821cu: Fix firmware upload fail 605d7c0b05ee wifi: rtw88: 8821cu: Fix connection failure e1dfa21427ba wifi: rtw88: 8821c: Fix beacon loss and disconnect c238adbc578e wifi: rtw88: 8821c: Fix false alarm count
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 1/1 wifi: rtw88: 8821cu: Fix connection failure
In reply to Bitterblue SmithFrom: Bitterblue Smith <[email protected]>
[ Upstream commit 605d7c0b05eecb985273b1647070497142c470d3 ]
Clear bit 8 of REG_SYS_STATUS1 after MAC power on.
Without this, some RTL8821CU and RTL8811CU cannot connect to any network:
Feb 19 13:33:11 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 1/3) Feb 19 13:33:13 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 2/3) Feb 19 13:33:14 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 3/3) Feb 19 13:33:15 ideapad2 kernel: wlp3s0f3u2: authentication with 90:55:de:__:__:__ timed out
The RTL8822CU and RTL8822BU out-of-tree drivers do this as well, so do it for all three types of chips.
Tested with RTL8811CU (Tenda U9 V2.0).
--- drivers/net/wireless/realtek/rtw88/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/realtek/rtw88/mac.c +7 -0
@@ -309,6 +309,13 @@ static int rtw_mac_power_switch(struct rtw_dev *rtwdev, bool pwr_on) pwr_seq = pwr_on ? chip->pwr_on_seq : chip->pwr_off_seq; ret =rtw_pwr_seq_parser (rtwdev, pwr_seq); +if (pwr_on &&rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_USB ) { +if (chip->id ==RTW_CHIP_TYPE_8822C || + chip->id ==RTW_CHIP_TYPE_8822B || + chip->id ==RTW_CHIP_TYPE_8821C ) +rtw_write8_clr (rtwdev,REG_SYS_STATUS1 +1 ,BIT (0 )); + } +if (rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_SDIO )rtw_write32 (rtwdev,REG_SDIO_HIMR , imr);
Signature · 1 line
2.43.2
Greg KH
maintainerRe: [PATCH] wifi: rtw88: 8821cu: Fix connection failure
Quoted 23 lines · Bitterblue Smith
From: Bitterblue Smith <[email protected]>
[ Upstream commit
605d7c0b05eecb985273b1647070497142c470d3]Clear bit 8 of
REG_SYS_STATUS1after MAC power on.Without this, some RTL8821CU and RTL8811CU cannot connect to any network:
Feb 19 13:33:11 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 1/3) Feb 19 13:33:13 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 2/3) Feb 19 13:33:14 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 3/3) Feb 19 13:33:15 ideapad2 kernel: wlp3s0f3u2: authentication with 90:55:de:__:__:__ timed outThe RTL8822CU and RTL8822BU out-of-tree drivers do this as well, so do it for all three types of chips.
Tested with RTL8811CU (Tenda U9 V2.0).
Quoted 7 lines
Signed-off-by Bitterblue Smith <[email protected]>Acked-by Ping-Ke Shih <[email protected]>Signed-off-by Kalle Valo <[email protected]>--- drivers/net/wireless/realtek/rtw88/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)
What stable kernel(s) is this to be applied to?
thanks,
greg k-h
Re: [PATCH] wifi: rtw88: 8821cu: Fix connection failure
Quoted 32 lines · Greg KH
Quoted 23 lines · Bitterblue Smith
From: Bitterblue Smith <[email protected]>
[ Upstream commit
605d7c0b05eecb985273b1647070497142c470d3]Clear bit 8 of
REG_SYS_STATUS1after MAC power on.Without this, some RTL8821CU and RTL8811CU cannot connect to any network:
Feb 19 13:33:11 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 1/3) Feb 19 13:33:13 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 2/3) Feb 19 13:33:14 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 3/3) Feb 19 13:33:15 ideapad2 kernel: wlp3s0f3u2: authentication with 90:55:de:__:__:__ timed outThe RTL8822CU and RTL8822BU out-of-tree drivers do this as well, so do it for all three types of chips.
Tested with RTL8811CU (Tenda U9 V2.0).
Quoted 7 lines
Signed-off-by Bitterblue Smith <[email protected]>Acked-by Ping-Ke Shih <[email protected]>Signed-off-by Kalle Valo <[email protected]>--- drivers/net/wireless/realtek/rtw88/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)
Quoted 5 lines
What stable kernel(s) is this to be applied to?
thanks,
greg k-h
6.6, 6.7, and 6.8, please. The older ones don't have USB support in rtw88.
Thank you.
Greg KH
maintainerRe: [PATCH] wifi: rtw88: 8821cu: Fix connection failure
Quoted 33 lines · Bitterblue Smith
Quoted 32 lines · Greg KH
Quoted 30 lines · Bitterblue Smith
From: Bitterblue Smith <[email protected]>
[ Upstream commit
605d7c0b05eecb985273b1647070497142c470d3]Clear bit 8 of
REG_SYS_STATUS1after MAC power on.Without this, some RTL8821CU and RTL8811CU cannot connect to any network:
Feb 19 13:33:11 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 1/3) Feb 19 13:33:13 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 2/3) Feb 19 13:33:14 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 3/3) Feb 19 13:33:15 ideapad2 kernel: wlp3s0f3u2: authentication with 90:55:de:__:__:__ timed outThe RTL8822CU and RTL8822BU out-of-tree drivers do this as well, so do it for all three types of chips.
Tested with RTL8811CU (Tenda U9 V2.0).
Signed-off-by Bitterblue Smith <[email protected]>Acked-by Ping-Ke Shih <[email protected]>Signed-off-by Kalle Valo <[email protected]>--- drivers/net/wireless/realtek/rtw88/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)
Quoted 8 lines
Quoted 5 lines
What stable kernel(s) is this to be applied to?
thanks,
greg k-h
6.6, 6.7, and 6.8, please. The older ones don't have USB support in rtw88.
Now queued up, thanks.
greg k-h