Re: [PATCH] wifi: rtw88: pci: Power off MAC and disable interrupts on shutdown
From: ꧁Swapnil Shinde꧂
Date: Fri Nov 27 2026 - 02:00:58 EST
Hi Ping-Ke,
Thank you for the review and suggestion.
I tested calling rtw_enter_ips(rtwdev) under rtwdev->mutex in
rtw_pci_shutdown() (with EXPORT_SYMBOL(rtw_enter_ips) added in ps.c,
running alongside the companion btusb shutdown/autosuspend fix) on my
RTL8723DE laptop:
- Cold boot: Wi-Fi and Bluetooth both work.
- Warm reboot #1 (Wi-Fi ON, Bluetooth ON): Both Wi-Fi and Bluetooth work.
- Warm reboot #2 (Bluetooth toggled OFF mid-session, Wi-Fi ON): Both
Wi-Fi and Bluetooth work cleanly (no -16 MAC power-on timeout or -71
USB enumeration error).
Using rtw_enter_ips() is indeed much cleaner than manually clearing the
internal flags and calling rtw_power_off(), and it also notifies BT
coex via COEX_IPS_ENTER before entering PCI_D3hot.
Regarding commits 05202746ed70 and 44492e70adc8:
- 05202746ed70 sets BIT_USB_SUS_DIS in REG_HCI_OPT_CTRL, which does not
power off the Wi-Fi MAC before 44492e70adc8 transitions the device to
PCI_D3hot—leaving REG_APS_FSMCO active across warm reset (-EBUSY).
- Calling rtw_enter_ips() right before pci_set_power_state(pdev, PCI_D3hot)
cleanly resolves that while keeping both commits intact.
Would you like me to send a [PATCH v2] that exports rtw_enter_ips() in
ps.c and calls it from rtw_pci_shutdown() in pci.c?
Best regards,
Swapnil
On Fri, 27 Nov 2026 at 09:17, Ping-Ke Shih <pkshih@xxxxxxxxxxx> wrote:
>
>
> Swapnil Shinde <shindeswapnil028@xxxxxxxxx> wrote:
> > Currently rtw_pci_shutdown() invokes chip->ops->shutdown() and
> > immediately transitions the device to PCI_D3hot without powering off
> > the MAC or disabling PCI interrupts when RTW_FLAG_POWERON is active.
> >
> > On RTL8723DE combo cards, leaving the MAC powered across a warm reset
> > causes REG_APS_FSMCO polling (offset 0x5, mask 0x1) to time out with
> > -EBUSY (-16) on the next boot. Power off the MAC under rtwdev->mutex
> > and disable PCI interrupts before entering PCI_D3hot.
>
> IIRC the commit 05202746ed70 ("rtw88: 8723d: Add shutdown callback to disable BT USB suspend")
> is to fix the problem your encountered.
>
> The later another commit 44492e70adc8 ("rtw88: pci: Power cycle device during shutdown")
> is to let PCI enters PCI_D3hot.
>
> Can you revert both or either one to see if anything different?
>
> >
> > Signed-off-by: Swapnil Shinde <shindeswapnil028@xxxxxxxxx>
> > ---
> > drivers/net/wireless/realtek/rtw88/pci.c | 15 +++++++++++++++
> > 1 file changed, 15 insertions(+)
> >
> > diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c
> > index 66d2e5f51..b0bbb9397 100644
> > --- a/drivers/net/wireless/realtek/rtw88/pci.c
> > +++ b/drivers/net/wireless/realtek/rtw88/pci.c
> > @@ -1949,14 +1949,29 @@ void rtw_pci_shutdown(struct pci_dev *pdev)
> > {
> > struct ieee80211_hw *hw = pci_get_drvdata(pdev);
> > struct rtw_dev *rtwdev;
> > + struct rtw_pci *rtwpci;
> > const struct rtw_chip_info *chip;
> >
> > if (!hw)
> > return;
> >
> > rtwdev = hw->priv;
> > + rtwpci = (struct rtw_pci *)rtwdev->priv;
> > chip = rtwdev->chip;
> >
>
> Can it just call rtw_enter_ips()?
>
> > + mutex_lock(&rtwdev->mutex);
> > + if (test_bit(RTW_FLAG_POWERON, rtwdev->flags)) {
> > + clear_bit(RTW_FLAG_RUNNING, rtwdev->flags);
> > + clear_bit(RTW_FLAG_FW_RUNNING, rtwdev->flags);
> > + rtw_power_off(rtwdev);
> > + clear_bit(RTW_FLAG_POWERON, rtwdev->flags);
> > + } else {
> > + rtw_hci_link_ps(rtwdev, false);
> > + }
> > + mutex_unlock(&rtwdev->mutex);
> > +
> > + rtw_pci_disable_interrupt(rtwdev, rtwpci);
> > +
> > if (chip->ops->shutdown)
> > chip->ops->shutdown(rtwdev);
> >
> > --
> > 2.56.0
>