All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: Gary Chang <gary.chang@realtek.com>,
	Damon Chen <damon.chen@realtek.com>,
	Zong-Zhe Yang <kevin_yang@realtek.com>
Subject: Re: [PATCH rtw-next 04/12] wifi: rtw89: mac: reset power state before switching to power on
Date: Wed, 17 Dec 2025 20:05:22 +0200	[thread overview]
Message-ID: <b9a20503-b599-4667-96ab-e7d4f058fc19@gmail.com> (raw)
In-Reply-To: <6ed5e59b4aa4498687030244404dc3f6@realtek.com>

On 16/12/2025 11:06, Ping-Ke Shih wrote:
> Hi Bitterblue,
> 
> Ping-Ke Shih wrote:
>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>> On 15/12/2025 04:05, Ping-Ke Shih wrote:
>>>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote;
>>>>> On 12/12/2025 05:12, Ping-Ke Shih wrote:
>>>>>> To run power on function properly, reset power states (off/on/PS) to
>>>>>> initial state. Otherwise, it might be unusable due to fail to power on.
>>>>>>
>>>>>> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
>>>>>> ---
>>>>>>  drivers/net/wireless/realtek/rtw89/mac.c    |  89 ++++++++++++--
>>>>>>  drivers/net/wireless/realtek/rtw89/mac.h    |   1 +
>>>>>>  drivers/net/wireless/realtek/rtw89/mac_be.c | 130 ++++++++++++++++++++
>>>>>>  drivers/net/wireless/realtek/rtw89/reg.h    |  27 ++++
>>>>>>  4 files changed, 240 insertions(+), 7 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c
>>>>>> index d78fbe73e365..ba4344a640f5 100644
>>>>>> --- a/drivers/net/wireless/realtek/rtw89/mac.c
>>>>>> +++ b/drivers/net/wireless/realtek/rtw89/mac.c
>>>>>> @@ -1478,13 +1478,11 @@ static void rtw89_mac_power_switch_boot_mode(struct rtw89_dev *rtwdev)
>>>>>>
>>>>>>  static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)
>>>>>>  {
>>>>>> -#define PWR_ACT 1
>>>>>>       const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def;
>>>>>>       const struct rtw89_chip_info *chip = rtwdev->chip;
>>>>>>       const struct rtw89_pwr_cfg * const *cfg_seq;
>>>>>>       int (*cfg_func)(struct rtw89_dev *rtwdev);
>>>>>>       int ret;
>>>>>> -     u8 val;
>>>>>>
>>>>>>       rtw89_mac_power_switch_boot_mode(rtwdev);
>>>>>>
>>>>>> @@ -1499,10 +1497,10 @@ static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)
>>>>>>       if (test_bit(RTW89_FLAG_FW_RDY, rtwdev->flags))
>>>>>>               __rtw89_leave_ps_mode(rtwdev);
>>>>>>
>>>>>> -     val = rtw89_read32_mask(rtwdev, R_AX_IC_PWR_STATE, B_AX_WLMAC_PWR_STE_MASK);
>>>>>> -     if (on && val == PWR_ACT) {
>>>>>> -             rtw89_err(rtwdev, "MAC has already powered on\n");
>>>>>> -             return -EBUSY;
>>>>>> +     if (on) {
>>>>>> +             ret = mac->reset_pwr_state(rtwdev);
>>>>>> +             if (ret)
>>>>>> +                     return ret;
>>>>>>       }
>>>>>>
>>>>>>       ret = cfg_func ? cfg_func(rtwdev) : rtw89_mac_pwr_seq(rtwdev, cfg_seq);
>>>>>> @@ -1529,7 +1527,6 @@ static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)
>>>>>>       }
>>>>>>
>>>>>>       return 0;
>>>>>> -#undef PWR_ACT
>>>>>>  }
>>>>>>
>>>>>>  int rtw89_mac_pwr_on(struct rtw89_dev *rtwdev)
>>>>>> @@ -3931,6 +3928,83 @@ static int rtw89_mac_feat_init(struct rtw89_dev *rtwdev)
>>>>>>       return 0;
>>>>>>  }
>>>>>>
>>>>>> +static int rtw89_mac_reset_pwr_state_ax(struct rtw89_dev *rtwdev)
>>>>>> +{
>>>>>> +     enum rtw89_core_chip_id chip_id = rtwdev->chip->chip_id;
>>>>>> +     u32 val32;
>>>>>> +     int ret;
>>>>>> +
>>>>>> +     val32 = rtw89_read32(rtwdev, R_AX_SYSON_FSM_MON);
>>>>>> +     val32 &= WLAN_FSM_MASK;
>>>>>> +     val32 |= WLAN_FSM_SET;
>>>>>> +     rtw89_write32(rtwdev, R_AX_SYSON_FSM_MON, val32);
>>>>>> +
>>>>>> +     ret = read_poll_timeout(rtw89_read32_mask, val32, val32 == WLAN_FSM_IDLE,
>>>>>> +                             1000, 2000000, false,
>>>>>> +                             rtwdev, R_AX_SYSON_FSM_MON, WLAN_FSM_STATE_MASK);
>>>>>> +     if (ret) {
>>>>>> +             rtw89_err(rtwdev, "[ERR]Polling WLAN PMC timeout= %X\n", val32);
>>>>>> +             return ret;
>>>>>> +     }
>>>>>
>>>>> I get this error message with every AX chip the first time
>>>>> rtw89_mac_pwr_on() is called:
>>>>>
>>>>> [  +0.007286] rtw89_8852bu 2-4:1.0: loaded firmware rtw89/rtw8852b_fw-1.bin
>>>>> [  +2.001260] rtw89_8852bu 2-4:1.0: [ERR]Polling WLAN PMC timeout= 100
>>>>>
>>>>> They still work, because the second attempt in rtw89_mac_pwr_on()
>>>>> succeeds.
>>>>>
>>>>> Before this patch, the message was "MAC has already powered on".
>>>>> The new message says it's an error, so it will confuse people.
>>>>
>>>> I borrow a 8852AU and a 8852CU that both don't have error messages.
>>>> The "first time" you meant is just to plug the USB adapter?
>>>> If so, I have not idea about the difference between yours and mine.
>>>>
>>>
>>> Yes, the error only appears right after the adapter is plugged in.
>>> I put a message at the top of rtw89_mac_power_switch():
>>>
>>> [  +0.721188] usb 1-4: new high-speed USB device number 8 using xhci_hcd
>>> [  +0.126425] usb 1-4: New USB device found, idVendor=0bda, idProduct=8832, bcdDevice= 0.00
>>> [  +0.000014] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
>>> [  +0.000005] usb 1-4: Product: 802.11ac WLAN Adapter
>>> [  +0.000004] usb 1-4: Manufacturer: Realtek
>>> [  +0.000003] usb 1-4: SerialNumber: 00e04c000001
>>> [  +0.007757] rtw89_8852au 1-4:1.0: loaded firmware rtw89/rtw8852a_fw.bin
>>> [  +0.000338] rtw89_mac_power_switch enter, on 1
>>> [  +2.005000] rtw89_8852au 1-4:1.0: [ERR]Polling WLAN PMC timeout= 100
>>> [  +0.000010] rtw89_mac_power_switch enter, on 0
>>> [  +0.007867] rtw89_mac_power_switch enter, on 1
>>> [  +0.020254] rtw89_8852au 1-4:1.0: Firmware version 0.13.36.2 (52acc807), cmd version 0, type 1
>>> [  +0.000010] rtw89_8852au 1-4:1.0: Firmware version 0.13.36.2 (52acc807), cmd version 0, type 3
>>> [  +0.963868] rtw89_8852au 1-4:1.0: chip rfe_type is 1
>>> [  +0.103131] rtw89_mac_power_switch enter, on 0
>>> [  +0.011027] rtw89_8852au 1-4:1.0: rfkill hardware state changed to enable
>>> [  +0.051507] rtw89_8852au 1-4:1.0 wlp3s0f3u4: renamed from wlan0
>>> [  +0.020062] rtw89_mac_power_switch enter, on 1
>>>
>>>>>
>>>>> Is it possible this code related to R_AX_SYSON_FSM_MON is not
>>>>> applicable to USB? My adapters still work if I delete it.
>>>>
>>>> I'm checking internal experts. Quickly checking vendor driver, I don't see
>>>> it avoids calling this because of USB devices.
>>>>
>>>> If you delete code related to R_AX_SYSON_FSM_MON, will it show below messages
>>>> under the case 'val32 == MAC_AX_MAC_ON'?
>>>>
>>>>    "[ERR]Polling MAC state timeout= %X\n"
>>>>
>>>
>>> No, I never see that error. I checked the value of R_AX_IC_PWR_STATE.
>>> My RTL8832BU with the Windows driver onboard:
>>>
>>> [  +4.566707] usb 1-4: new high-speed USB device number 20 using xhci_hcd
>>> [  +0.125152] usb 1-4: New USB device found, idVendor=0bda, idProduct=1a2b, bcdDevice= 0.00
>>> [  +0.000008] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
>>> [  +0.000002] usb 1-4: Product: DISK
>>> [  +0.000002] usb 1-4: Manufacturer: Realtek
>>> [  +0.000544] usb-storage 1-4:1.0: USB Mass Storage device detected
>>> [  +0.000160] usb-storage 1-4:1.0: device ignored
>>> [  +0.629850] usb 1-4: USB disconnect, device number 20
>>> [  +0.723342] usb 1-4: new high-speed USB device number 21 using xhci_hcd
>>> [  +0.125493] usb 1-4: New USB device found, idVendor=0bda, idProduct=b832, bcdDevice= 0.00
>>> [  +0.000013] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
>>> [  +0.000005] usb 1-4: Product: 802.11ac WLAN Adapter
>>> [  +0.000004] usb 1-4: Manufacturer: Realtek
>>> [  +0.000004] usb 1-4: SerialNumber: 00e04c000001
>>> [  +0.007910] rtw89_8852bu 1-4:1.0: loaded firmware rtw89/rtw8852b_fw-1.bin
>>> [  +0.005682] rtw89_mac_reset_pwr_state_ax R_AX_IC_PWR_STATE=0x2200104
>>> [  +2.000406] rtw89_8852bu 1-4:1.0: [ERR]Polling WLAN PMC timeout= 100
>>> [  +0.017635] rtw89_mac_reset_pwr_state_ax R_AX_IC_PWR_STATE=0x2200004
>>> [  +0.043991] rtw89_8852bu 1-4:1.0: Firmware version 0.29.128.0 (418a672d), cmd version 0, type 5
>>> [  +0.000009] rtw89_8852bu 1-4:1.0: Firmware version 0.29.128.0 (418a672d), cmd version 0, type 3
>>> [  +1.462646] rtw89_8852bu 1-4:1.0: chip rfe_type is 1
>>> [  +0.135147] rtw89_8852bu 1-4:1.0: rfkill hardware state changed to enable
>>> [  +0.045006] rtw89_8852bu 1-4:1.0 wlp3s0f3u4: renamed from wlan0
>>> [  +0.016726] rtw89_mac_reset_pwr_state_ax R_AX_IC_PWR_STATE=0x2200004
>>>
>>> And another RTL8832BU without a Windows driver onboard:
>>>
>>> [Dec15 19:46] usb 1-4: new high-speed USB device number 22 using xhci_hcd
>>> [  +0.125532] usb 1-4: New USB device found, idVendor=0bda, idProduct=b832, bcdDevice= 0.00
>>> [  +0.000010] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
>>> [  +0.000003] usb 1-4: Product: 802.11ax WLAN Adapter
>>> [  +0.000003] usb 1-4: Manufacturer: Realtek
>>> [  +0.000002] usb 1-4: SerialNumber: 00e04c000001
>>> [  +0.007667] rtw89_8852bu 1-4:1.0: loaded firmware rtw89/rtw8852b_fw-1.bin
>>> [  +0.002684] rtw89_mac_reset_pwr_state_ax R_AX_IC_PWR_STATE=0x2200004
>>> [  +0.045258] rtw89_8852bu 1-4:1.0: Firmware version 0.29.128.0 (418a672d), cmd version 0, type 5
>>> [  +0.000015] rtw89_8852bu 1-4:1.0: Firmware version 0.29.128.0 (418a672d), cmd version 0, type 3
>>> [  +1.462130] rtw89_8852bu 1-4:1.0: chip rfe_type is 1
>>> [  +0.133511] rtw89_8852bu 1-4:1.0: rfkill hardware state changed to enable
>>> [  +0.043307] rtw89_8852bu 1-4:1.0 wlp3s0f3u4: renamed from wlan0
>>> [  +0.017936] rtw89_mac_reset_pwr_state_ax R_AX_IC_PWR_STATE=0x2200004
>>>
>>> Maybe your borrowed adapters don't have the Windows drivers onboard either?
>>
>> Yes, the adapters I borrowed are just pure WiFi adapters, no Windows drivers onboard.
>>
>> I will share these information to internal experts to see how I can handle
>> this kind of adapters.
>>
>>>
>>>>>
>>>>> (I don't get the error with RTL8912AU.)
>>>>>
>>>>
>>>> I'm adding this patch for WiFi 7 chips mainly, and this seems to be expected.
>>>>
>>>
>>> My RTL8912AU does have the Windows driver onboard, but no error:
>>>
>>> [  +5.365639] usb 1-4: new high-speed USB device number 25 using xhci_hcd
>>> [  +0.124722] usb 1-4: New USB device found, idVendor=0bda, idProduct=1a2b, bcdDevice= 0.00
>>> [  +0.000007] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
>>> [  +0.000002] usb 1-4: Product: DISK
>>> [  +0.000002] usb 1-4: Manufacturer: Realtek
>>> [  +0.000540] usb-storage 1-4:1.0: USB Mass Storage device detected
>>> [  +0.000143] usb-storage 1-4:1.0: device ignored
>>> [  +0.629713] usb 1-4: USB disconnect, device number 25
>>> [  +0.420492] usb 1-4: new high-speed USB device number 26 using xhci_hcd
>>> [  +0.125490] usb 1-4: New USB device found, idVendor=0bda, idProduct=8912, bcdDevice= 0.00
>>> [  +0.000009] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
>>> [  +0.000002] usb 1-4: Product: 802.11be WLAN Adapter
>>> [  +0.000002] usb 1-4: Manufacturer: Realtek
>>> [  +0.000002] usb 1-4: SerialNumber: 00e04c000001
>>> [  +0.008039] rtw89_8922au 1-4:1.0: loaded firmware rtw89/rtw8922a_fw-4.bin
>>> [  +0.005192] rtw89_mac_reset_pwr_state_be R_AX_IC_PWR_STATE=0x2200104
>>> [  +0.055131] rtw89_8922au 1-4:1.0: Firmware version 0.35.80.3 (8ef4f0cf), cmd version 1, type 1
>>> [  +0.000009] rtw89_8922au 1-4:1.0: Firmware version 0.35.80.3 (8ef4f0cf), cmd version 1, type 3
>>> [  +1.419275] rtw89_8922au 1-4:1.0: chip rfe_type is 1
>>> [  +0.042634] rtw89_8922au 1-4:1.0: Firmware version 0.1.0.0 (7b393818), cmd version 0, type 64
>>> [  +0.000012] rtw89_8922au 1-4:1.0: Firmware element BB version: 00 49 00 00
>>> [  +0.000014] rtw89_8922au 1-4:1.0: Firmware element radio A version: 00 33 00 00
>>> [  +0.000015] rtw89_8922au 1-4:1.0: Firmware element NCTL version: 00 0f 00 00
>>> [  +0.000118] rtw89_8922au 1-4:1.0: Firmware element TXPWR version: 00 40 00 00
>>> [  +0.000005] rtw89_8922au 1-4:1.0: Firmware element PWR_TRK version: 00 33 00 00
>>> [  +0.000010] rtw89_8922au 1-4:1.0: Firmware element REGD version: 00 48 00 06
>>> [  +0.024441] rtw89_8922au 1-4:1.0: rfkill hardware state changed to enable
>>> [  +0.042643] rtw89_8922au 1-4:1.0 wlp3s0f3u4: renamed from wlan0
>>> [  +0.012737] rtw89_mac_reset_pwr_state_be R_AX_IC_PWR_STATE=0x2200004
> 
> Could you apply below to my original patchset to see if it can silence warning?
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c
> index 7ffb039e7d1b..1f9f21040adc 100644
> --- a/drivers/net/wireless/realtek/rtw89/mac.c
> +++ b/drivers/net/wireless/realtek/rtw89/mac.c
> @@ -3950,6 +3950,16 @@ static int rtw89_mac_reset_pwr_state_ax(struct rtw89_dev *rtwdev)
>                                 1000, 2000000, false,
>                                 rtwdev, R_AX_SYSON_FSM_MON, WLAN_FSM_STATE_MASK);
>         if (ret) {
> +               /*
> +                * A USB adapter might play as USB mass storage with driver and
> +                * then switch to WiFi adapter, causing it stays on power-on
> +                * state when doing WiFi USB probe. Return EAGAIN to caller to
> +                * power-off and power-on again to reset the state.
> +                */
> +               if (rtwdev->hci.type == RTW89_HCI_TYPE_USB &&
> +                   !test_bit(RTW89_FLAG_PROBE_DONE, rtwdev->flags))
> +                       return -EAGAIN;
> +
>                 rtw89_err(rtwdev, "[ERR]Polling WLAN PMC timeout= %X\n", val32);
>                 return ret;
>         }
> 

Yes, that silences the warning.

  reply	other threads:[~2025-12-17 18:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-12  3:12 [PATCH rtw-next 00/12] wifi: rtw89: refine MLO, MCC and SER functions Ping-Ke Shih
2025-12-12  3:12 ` [PATCH rtw-next 01/12] wifi: rtw89: 8852b: increase beacon loss to 6 seconds Ping-Ke Shih
2025-12-12  3:12 ` [PATCH rtw-next 02/12] wifi: rtw89: mlo: fix missing TX null-data 1 during link switch Ping-Ke Shih
2025-12-12  3:12 ` [PATCH rtw-next 03/12] wifi: rtw89: mlo: fix incorrect link address in management frames Ping-Ke Shih
2025-12-12  3:12 ` [PATCH rtw-next 04/12] wifi: rtw89: mac: reset power state before switching to power on Ping-Ke Shih
2025-12-14 22:30   ` Bitterblue Smith
2025-12-15  2:05     ` Ping-Ke Shih
2025-12-15 18:06       ` Bitterblue Smith
2025-12-16  0:34         ` Ping-Ke Shih
2025-12-16  9:06           ` Ping-Ke Shih
2025-12-17 18:05             ` Bitterblue Smith [this message]
2025-12-12  3:12 ` [PATCH rtw-next 05/12] wifi: rtw89: ser: enable error IMR after recovering from L1 Ping-Ke Shih
2025-12-12  3:12 ` [PATCH rtw-next 06/12] wifi: rtw89: ser: L1 skip polling status if FW runs event mode Ping-Ke Shih
2025-12-12  3:12 ` [PATCH rtw-next 07/12] wifi: rtw89: debug: add ser_counters dbgfs Ping-Ke Shih
2025-12-12  3:12 ` [PATCH rtw-next 08/12] wifi: rtw89: debug: support SER L0/L1 simulation via halt H2C Ping-Ke Shih
2025-12-12  3:13 ` [PATCH rtw-next 09/12] wifi: rtw89: refine C2H reg event polling timeout for LPS Ping-Ke Shih
2025-12-12  3:13 ` [PATCH rtw-next 10/12] wifi: rtw89: warn unexpected polling value of XTAL SI Ping-Ke Shih
2025-12-14 22:32   ` Bitterblue Smith
2025-12-15  1:24     ` Ping-Ke Shih
2025-12-15 22:13       ` Bitterblue Smith
2025-12-16  0:29         ` Ping-Ke Shih
2025-12-12  3:13 ` [PATCH rtw-next 11/12] wifi: rtw89: setting TBTT AGG number when mac port initialization Ping-Ke Shih
2025-12-12  3:13 ` [PATCH rtw-next 12/12] wifi: rtw89: mcc: reset probe counter when receiving beacon Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9a20503-b599-4667-96ab-e7d4f058fc19@gmail.com \
    --to=rtl8821cerfe2@gmail.com \
    --cc=damon.chen@realtek.com \
    --cc=gary.chang@realtek.com \
    --cc=kevin_yang@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.