All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Bitterblue Smith <rtl8821cerfe2@gmail.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: Mon, 15 Dec 2025 02:05:54 +0000	[thread overview]
Message-ID: <05f1a2bbc0d344ea8c37481f9e1d26d4@realtek.com> (raw)
In-Reply-To: <efc58c87-d391-4970-b9af-abdef9861342@gmail.com>

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.

> 
> 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"

> 
> (I don't get the error with RTL8912AU.)
> 

I'm adding this patch for WiFi 7 chips mainly, and this seems to be expected.


  reply	other threads:[~2025-12-15  2: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 [this message]
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
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=05f1a2bbc0d344ea8c37481f9e1d26d4@realtek.com \
    --to=pkshih@realtek.com \
    --cc=damon.chen@realtek.com \
    --cc=gary.chang@realtek.com \
    --cc=kevin_yang@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=rtl8821cerfe2@gmail.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.