All of lore.kernel.org
 help / color / mirror / Atom feed
From: Swapnil Shinde <shindeswapnil028@gmail.com>
To: pkshih@realtek.com, kvalo@kernel.org
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	Swapnil Shinde <shindeswapnil028@gmail.com>
Subject: [PATCH v2] wifi: rtw88: pci: Enter IPS before PCI_D3hot on shutdown
Date: Fri, 27 Nov 2026 14:07:29 +0530	[thread overview]
Message-ID: <20261127083729.7030-1-shindeswapnil028@gmail.com> (raw)
In-Reply-To: <20261127004822.8536-1-shindeswapnil028@gmail.com>

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


  parent reply	other threads:[~2026-11-27  8:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Swapnil Shinde [this message]
2026-12-01  8:17   ` [PATCH v2] wifi: rtw88: pci: Enter IPS before PCI_D3hot " Ping-Ke Shih
2026-12-01 10:10     ` ꧁Swapnil Shinde꧂
2026-12-02  0:32       ` Ping-Ke Shih
2026-12-02  8:04         ` ꧁Swapnil Shinde꧂

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=20261127083729.7030-1-shindeswapnil028@gmail.com \
    --to=shindeswapnil028@gmail.com \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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.