* [PATCH] wifi: rtw88: pci: Power off MAC and disable interrupts on shutdown
@ 2026-11-27 0:48 Swapnil Shinde
2026-11-27 3:47 ` Ping-Ke Shih
2026-11-27 8:37 ` [PATCH v2] wifi: rtw88: pci: Enter IPS before PCI_D3hot " Swapnil Shinde
0 siblings, 2 replies; 5+ messages in thread
From: Swapnil Shinde @ 2026-11-27 0:48 UTC (permalink / raw)
To: pkshih, kvalo; +Cc: linux-wireless, linux-kernel, Swapnil Shinde
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.
Signed-off-by: Swapnil Shinde <shindeswapnil028@gmail.com>
---
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;
+ 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] wifi: rtw88: pci: Power off MAC and disable interrupts on shutdown
2026-11-27 0:48 [PATCH] wifi: rtw88: pci: Power off MAC and disable interrupts on shutdown Swapnil Shinde
@ 2026-11-27 3:47 ` Ping-Ke Shih
2026-11-27 7:00 ` ꧁Swapnil Shinde꧂
2026-11-27 8:37 ` [PATCH v2] wifi: rtw88: pci: Enter IPS before PCI_D3hot " Swapnil Shinde
1 sibling, 1 reply; 5+ messages in thread
From: Ping-Ke Shih @ 2026-11-27 3:47 UTC (permalink / raw)
To: Swapnil Shinde, kvalo; +Cc: linux-wireless, linux-kernel
Swapnil Shinde <shindeswapnil028@gmail.com> 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@gmail.com>
> ---
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] wifi: rtw88: pci: Power off MAC and disable interrupts on shutdown
2026-11-27 3:47 ` Ping-Ke Shih
@ 2026-11-27 7:00 ` ꧁Swapnil Shinde꧂
2026-11-27 7:11 ` Ping-Ke Shih
0 siblings, 1 reply; 5+ messages in thread
From: ꧁Swapnil Shinde꧂ @ 2026-11-27 7:00 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: kvalo, linux-wireless, linux-kernel
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@realtek.com> wrote:
>
>
> Swapnil Shinde <shindeswapnil028@gmail.com> 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@gmail.com>
> > ---
> > 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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] wifi: rtw88: pci: Power off MAC and disable interrupts on shutdown
2026-11-27 7:00 ` ꧁Swapnil Shinde꧂
@ 2026-11-27 7:11 ` Ping-Ke Shih
0 siblings, 0 replies; 5+ messages in thread
From: Ping-Ke Shih @ 2026-11-27 7:11 UTC (permalink / raw)
To: ꧁Swapnil Shinde꧂; +Cc: kvalo, linux-wireless, linux-kernel
꧁Swapnil Shinde꧂ <shindeswapnil028@gmail.com> wrote:
> 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).
Good to hear that.
>
> 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).
So both or either one commit don't help?
> - 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?
If this is the only way to fix, please.
---
pw-bot: cr
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] wifi: rtw88: pci: Enter IPS before PCI_D3hot on shutdown
2026-11-27 0:48 [PATCH] wifi: rtw88: pci: Power off MAC and disable interrupts on shutdown Swapnil Shinde
2026-11-27 3:47 ` Ping-Ke Shih
@ 2026-11-27 8:37 ` Swapnil Shinde
1 sibling, 0 replies; 5+ messages in thread
From: Swapnil Shinde @ 2026-11-27 8:37 UTC (permalink / raw)
To: pkshih, kvalo; +Cc: linux-wireless, linux-kernel, Swapnil Shinde
Currently rtw_pci_shutdown() invokes chip->ops->shutdown() and
immediately transitions the device to PCI_D3hot without stopping the
firmware/MAC or notifying Bluetooth coexistence when RTW_FLAG_POWERON
is active.
On RTL8723DE combo cards, leaving the MAC active across a warm reset
causes REG_APS_FSMCO polling (offset 0x5, mask 0x1) to time out with
-EBUSY (-16) on the next boot. Export rtw_enter_ips() and invoke it
under rtwdev->mutex before entering PCI_D3hot so the driver notifies
COEX_IPS_ENTER, stops the core/MAC, and enters PCIe link power save.
---
Changes in v2:
- Call rtw_enter_ips() under rtwdev->mutex instead of manually clearing
internal flags and calling rtw_power_off() (suggested by Ping-Ke Shih).
- Export rtw_enter_ips() in ps.c so rtw88_pci can invoke it.
- Note on commits 05202746ed70 and 44492e70adc8: neither alone resolves
the warm-reboot failure on RTL8723DE because 05202746ed70 only sets
BIT_USB_SUS_DIS in REG_HCI_OPT_CTRL without powering down the Wi-Fi
MAC, and 44492e70adc8 puts PCI into PCI_D3hot while the MAC is still
powered on. Calling rtw_enter_ips() before PCI_D3hot fixes the MAC
shutdown cleanly while keeping both commits intact.
Signed-off-by: Swapnil Shinde <shindeswapnil028@gmail.com>
---
drivers/net/wireless/realtek/rtw88/pci.c | 4 ++++
drivers/net/wireless/realtek/rtw88/ps.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c
index 66d2e5f..ecf954d 100644
--- a/drivers/net/wireless/realtek/rtw88/pci.c
+++ b/drivers/net/wireless/realtek/rtw88/pci.c
@@ -1960,6 +1960,10 @@ void rtw_pci_shutdown(struct pci_dev *pdev)
if (chip->ops->shutdown)
chip->ops->shutdown(rtwdev);
+ mutex_lock(&rtwdev->mutex);
+ rtw_enter_ips(rtwdev);
+ mutex_unlock(&rtwdev->mutex);
+
pci_set_power_state(pdev, PCI_D3hot);
}
EXPORT_SYMBOL(rtw_pci_shutdown);
diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c
index add5a20..41a13d9 100644
--- a/drivers/net/wireless/realtek/rtw88/ps.c
+++ b/drivers/net/wireless/realtek/rtw88/ps.c
@@ -36,6 +36,7 @@ int rtw_enter_ips(struct rtw_dev *rtwdev)
return 0;
}
+EXPORT_SYMBOL(rtw_enter_ips);
static void rtw_restore_port_cfg_iter(void *data, struct ieee80211_vif *vif)
{
--
2.56.0
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-27 8:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 0:48 [PATCH] wifi: rtw88: pci: Power off MAC and disable interrupts on shutdown Swapnil Shinde
2026-11-27 3:47 ` Ping-Ke Shih
2026-11-27 7:00 ` ꧁Swapnil Shinde꧂
2026-11-27 7:11 ` Ping-Ke Shih
2026-11-27 8:37 ` [PATCH v2] wifi: rtw88: pci: Enter IPS before PCI_D3hot " Swapnil Shinde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®