Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] wifi: rtw89: 8852be: add .shutdown callback to quiesce device on reboot
@ 2026-07-28  1:54 yhchen312
  2026-07-28  2:45 ` Ping-Ke Shih
  0 siblings, 1 reply; 4+ messages in thread
From: yhchen312 @ 2026-07-28  1:54 UTC (permalink / raw)
  To: pkshih; +Cc: damon.chen, linux-wireless, linux-kernel, stable, Yuhang.chen

From: "Yuhang.chen" <yhchen312@gmail.com>

Since hardware rfkill polling was introduced, warm reboot on arm64
platforms can panic with an asynchronous SError when the rfkill poll
workqueue reads a register while the PCIe link is being torn down:

  SError Interrupt on CPU8, code 0x00000000be000011 -- SError
  Workqueue: events_power_efficient rfkill_poll [rfkill]
  Call trace:
    rtw89_pci_ops_read8+0x94/0x160 [rtw89_pci]
    rtw89_core_rfkill_poll+0x50/0x1e0 [rtw89_core]
    rtw89_ops_rfkill_poll+0x40/0x68 [rtw89_core]
    ieee80211_rfkill_poll+0x3c/0x70 [mac80211]
    cfg80211_rfkill_poll+0x40/0x2a0 [cfg80211]
    rfkill_poll+0x30/0x88 [rfkill]
  Kernel panic - not syncing: Asynchronous SError Interrupt

During device_shutdown() the 8852BE PCI driver has no .shutdown
callback, so the device is never quiesced and the rfkill polling keeps
running.  Once the platform brings the PCIe link down, the next MMIO
read targets a non-responding device and is reported as an asynchronous
SError, which is fatal on arm64.

Add a .shutdown callback that runs the existing remove path to stop the
rfkill polling, free interrupts and power down the chip before the link
goes away.  A NULL drvdata check guards the case where probe did not
fully complete.

Fixes: 0b38e6277aed ("wifi: rtw89: add support for hardware rfkill")
Cc: stable@vger.kernel.org
Signed-off-by: Yuhang.chen <yhchen312@gmail.com>
---
 drivers/net/wireless/realtek/rtw89/rtw8852be.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852be.c b/drivers/net/wireless/realtek/rtw89/rtw8852be.c
index 5bc0a6a99d1d..9aebecbac067 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852be.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852be.c
@@ -92,11 +92,20 @@ static const struct pci_device_id rtw89_8852be_id_table[] = {
 };
 MODULE_DEVICE_TABLE(pci, rtw89_8852be_id_table);
 
+static void rtw89_8852be_shutdown(struct pci_dev *pdev)
+{
+	if (!pci_get_drvdata(pdev))
+		return;
+
+	rtw89_pci_remove(pdev);
+}
+
 static struct pci_driver rtw89_8852be_driver = {
 	.name		= "rtw89_8852be",
 	.id_table	= rtw89_8852be_id_table,
 	.probe		= rtw89_pci_probe,
 	.remove		= rtw89_pci_remove,
+	.shutdown       = rtw89_8852be_shutdown,
 	.driver.pm	= &rtw89_pm_ops,
 	.err_handler    = &rtw89_pci_err_handler,
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] wifi: rtw89: 8852be: add .shutdown callback to quiesce device on reboot
  2026-07-28  1:54 [PATCH] wifi: rtw89: 8852be: add .shutdown callback to quiesce device on reboot yhchen312
@ 2026-07-28  2:45 ` Ping-Ke Shih
  2026-07-29  1:35   ` yhchen312
  2026-07-29  1:41   ` [PATCH v2] wifi: rtw89: pci: add .shutdown callback to stop rfkill polling " yhchen312
  0 siblings, 2 replies; 4+ messages in thread
From: Ping-Ke Shih @ 2026-07-28  2:45 UTC (permalink / raw)
  To: yhchen312@gmail.com
  Cc: Damon Chen, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org


yhchen312@gmail.com <yhchen312@gmail.com> wrote:
> From: "Yuhang.chen" <yhchen312@gmail.com>
> 
> Since hardware rfkill polling was introduced, warm reboot on arm64
> platforms can panic with an asynchronous SError when the rfkill poll
> workqueue reads a register while the PCIe link is being torn down:

Does it mean the work is running after .shutdown but before .remove?

> 
>   SError Interrupt on CPU8, code 0x00000000be000011 -- SError
>   Workqueue: events_power_efficient rfkill_poll [rfkill]
>   Call trace:
>     rtw89_pci_ops_read8+0x94/0x160 [rtw89_pci]
>     rtw89_core_rfkill_poll+0x50/0x1e0 [rtw89_core]
>     rtw89_ops_rfkill_poll+0x40/0x68 [rtw89_core]
>     ieee80211_rfkill_poll+0x3c/0x70 [mac80211]
>     cfg80211_rfkill_poll+0x40/0x2a0 [cfg80211]
>     rfkill_poll+0x30/0x88 [rfkill]
>   Kernel panic - not syncing: Asynchronous SError Interrupt
> 
> During device_shutdown() the 8852BE PCI driver has no .shutdown
> callback, so the device is never quiesced and the rfkill polling keeps
> running.  Once the platform brings the PCIe link down, the next MMIO
> read targets a non-responding device and is reported as an asynchronous
> SError, which is fatal on arm64.
> 
> Add a .shutdown callback that runs the existing remove path to stop the
> rfkill polling, free interrupts and power down the chip before the link
> goes away. A NULL drvdata check guards the case where probe did not
> fully complete.
> 
> Fixes: 0b38e6277aed ("wifi: rtw89: add support for hardware rfkill")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuhang.chen <yhchen312@gmail.com>
> ---
>  drivers/net/wireless/realtek/rtw89/rtw8852be.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852be.c
> b/drivers/net/wireless/realtek/rtw89/rtw8852be.c
> index 5bc0a6a99d1d..9aebecbac067 100644
> --- a/drivers/net/wireless/realtek/rtw89/rtw8852be.c
> +++ b/drivers/net/wireless/realtek/rtw89/rtw8852be.c
> @@ -92,11 +92,20 @@ static const struct pci_device_id rtw89_8852be_id_table[] = {
>  };
>  MODULE_DEVICE_TABLE(pci, rtw89_8852be_id_table);
> 
> +static void rtw89_8852be_shutdown(struct pci_dev *pdev)
> +{
> +       if (!pci_get_drvdata(pdev))
> +               return;
> +
> +       rtw89_pci_remove(pdev);

Not prefer calling rtw89_pci_remove() twice.

I think we can add a callback .rtw89_pci_shutdown() to set a flag
RTW89_FLAG_SHUTDOWN. In rtw89_ops_rfkill_poll(), just ignore polling, like:

@@ -2010,7 +2010,8 @@ static void rtw89_ops_rfkill_poll(struct ieee80211_hw *hw)
        lockdep_assert_wiphy(hw->wiphy);

        /* wl_disable GPIO get floating when entering LPS */
-       if (test_bit(RTW89_FLAG_RUNNING, rtwdev->flags))
+       if (test_bit(RTW89_FLAG_RUNNING, rtwdev->flags) ||
+           test_bit(RTW89_FLAG_SHUTDOWN, rtwdev->flags))
                return;

        rtw89_core_rfkill_poll(rtwdev, false);

This flag is very similar to USB RTW89_FLAG_UNPLUGGED flag, but I'd add a
new flag.

> +}
> +
>  static struct pci_driver rtw89_8852be_driver = {
>         .name           = "rtw89_8852be",
>         .id_table       = rtw89_8852be_id_table,
>         .probe          = rtw89_pci_probe,
>         .remove         = rtw89_pci_remove,
> +       .shutdown       = rtw89_8852be_shutdown,

I think this fix can apply to all PCI devices for this driver, right?

>         .driver.pm      = &rtw89_pm_ops,
>         .err_handler    = &rtw89_pci_err_handler,
>  };
> --
> 2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] wifi: rtw89: 8852be: add .shutdown callback to quiesce device on reboot
  2026-07-28  2:45 ` Ping-Ke Shih
@ 2026-07-29  1:35   ` yhchen312
  2026-07-29  1:41   ` [PATCH v2] wifi: rtw89: pci: add .shutdown callback to stop rfkill polling " yhchen312
  1 sibling, 0 replies; 4+ messages in thread
From: yhchen312 @ 2026-07-29  1:35 UTC (permalink / raw)
  To: pkshih; +Cc: damon.chen, linux-wireless, linux-kernel

Hi Ping-Ke,

Thanks for the review.

> Does it mean the work is running after .shutdown but before .remove?

On the reboot/poweroff path the kernel only runs device_shutdown(),
which invokes each driver's .shutdown callback; .remove is *not* called
on this path -- it only runs on driver unbind, module unload or
hot-unplug.  The rfkill polling workqueue, however, keeps being scheduled
by the rfkill core throughout the whole shutdown sequence until the
system finally halts.  During that window the platform starts tearing
the PCIe link down, and the next MMIO read issued by
rtw89_ops_rfkill_poll() then targets a non-responding device, which on
arm64 is reported as a fatal asynchronous SError.  So it is not ".remove
after .shutdown"; .remove never runs on reboot -- the poll work simply
outlives the link, and that is exactly what the new flag stops.

> Not prefer calling rtw89_pci_remove() twice.

Agreed.  In v2 I dropped the rtw89_pci_remove() call from .shutdown and
switched to the flag-based approach you suggested:

  * add rtw89_pci_shutdown() that sets a new RTW89_FLAG_SHUTDOWN flag
    (mirroring the USB RTW89_FLAG_UNPLUGGED pattern);
  * make rtw89_ops_rfkill_poll() bail out early when that flag is set,
    so no MMIO read reaches the chip after shutdown begins.

This keeps the shutdown handler minimal and avoids running the
non-idempotent teardown twice.

> I think this fix can apply to all PCI devices for this driver, right?

Yes, agreed.  v2 wires .shutdown = rtw89_pci_shutdown into all rtw89 PCI
device drivers (8851BE/8852AE/8852BE/8852BTE/8852CE/8922AE/8922DE), so
the subject prefix is now "wifi: rtw89: pci: ...".

v2 is sent as a reply to this thread.

Thanks,
Yuhang

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] wifi: rtw89: pci: add .shutdown callback to stop rfkill polling on reboot
  2026-07-28  2:45 ` Ping-Ke Shih
  2026-07-29  1:35   ` yhchen312
@ 2026-07-29  1:41   ` yhchen312
  1 sibling, 0 replies; 4+ messages in thread
From: yhchen312 @ 2026-07-29  1:41 UTC (permalink / raw)
  To: pkshih; +Cc: damon.chen, linux-wireless, linux-kernel, Yuhang.chen, stable

From: "Yuhang.chen" <yhchen312@gmail.com>

Since the hardware rfkill polling was introduced, arm64 platforms can
panic with an asynchronous SError during warm reboot:

  SError Interrupt on CPU8, code 0x00000000be000011 -- SError
  Workqueue: events_power_efficient rfkill_poll [rfkill]
    rtw89_pci_ops_read8+0x94/0x160 [rtw89_pci]
    rtw89_core_rfkill_poll+0x50/0x1e0 [rtw89_core]
    rtw89_ops_rfkill_poll+0x40/0x68 [rtw89_core]
    ieee80211_rfkill_poll+0x3c/0x70 [mac80211]
    cfg80211_rfkill_poll+0x40/0x2a0 [cfg80211]
    rfkill_poll+0x30/0x88 [rfkill]
  Kernel panic - not syncing: Asynchronous SError Interrupt

On the reboot path the kernel only runs device_shutdown(), which calls
each driver's .shutdown callback; .remove is not invoked.  The rtw89 PCI
driver had no .shutdown callback, so nothing stopped the rfkill polling
work while the platform was tearing the PCIe link down.  Once the link
is gone, the next MMIO read from the poll handler targets a
non-responding device and is reported as a fatal asynchronous SError on
arm64.

Add rtw89_pci_shutdown(), wired to all rtw89 PCI device drivers, which
sets a new RTW89_FLAG_SHUTDOWN flag (mirroring the USB
RTW89_FLAG_UNPLUGGED pattern).  When the flag is set,
rtw89_ops_rfkill_poll() returns early, so no MMIO read is issued to the
chip after shutdown begins and the SError no longer occurs.

This does not call the full .remove path from .shutdown, to keep the
shutdown handler minimal and avoid running the non-idempotent teardown
twice.

Fixes: 0b38e6277aed ("wifi: rtw89: add support for hardware rfkill")
Cc: stable@vger.kernel.org
Suggested-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Yuhang.chen <yhchen312@gmail.com>
---
v2: per Ping-Ke Shih's review [1], replace the rtw89_pci_remove() call
    from .shutdown with a flag-based approach (set RTW89_FLAG_SHUTDOWN
    and bail out early in rtw89_ops_rfkill_poll), and extend the fix to
    all rtw89 PCI device drivers instead of 8852BE only.

[1] https://lore.kernel.org/all/142c91dfc7334136a5dabc4f91504ec6@realtek.com/
---
 drivers/net/wireless/realtek/rtw89/core.h       |  1 +
 drivers/net/wireless/realtek/rtw89/mac80211.c   |  3 ++-
 drivers/net/wireless/realtek/rtw89/pci.c        | 13 +++++++++++++
 drivers/net/wireless/realtek/rtw89/pci.h        |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8851be.c  |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8852ae.c  |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8852be.c  |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8852bte.c |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8852ce.c  |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8922ae.c  |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8922de.c  |  1 +
 11 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 5547888d7e67..a85b9c39c257 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -5373,6 +5373,7 @@ enum rtw89_flags {
 	RTW89_FLAG_CHANGING_INTERFACE,
 	RTW89_FLAG_HW_RFKILL_STATE,
 	RTW89_FLAG_UNPLUGGED,
+	RTW89_FLAG_SHUTDOWN,
 
 	NUM_OF_RTW89_FLAGS,
 };
diff --git a/drivers/net/wireless/realtek/rtw89/mac80211.c b/drivers/net/wireless/realtek/rtw89/mac80211.c
index aade5c5b79e8..9baedfde7085 100644
--- a/drivers/net/wireless/realtek/rtw89/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw89/mac80211.c
@@ -1979,7 +1979,8 @@ static void rtw89_ops_rfkill_poll(struct ieee80211_hw *hw)
 	lockdep_assert_wiphy(hw->wiphy);
 
 	/* wl_disable GPIO get floating when entering LPS */
-	if (test_bit(RTW89_FLAG_RUNNING, rtwdev->flags))
+	if (test_bit(RTW89_FLAG_RUNNING, rtwdev->flags) ||
+	    test_bit(RTW89_FLAG_SHUTDOWN, rtwdev->flags))
 		return;
 
 	rtw89_core_rfkill_poll(rtwdev, false);
diff --git a/drivers/net/wireless/realtek/rtw89/pci.c b/drivers/net/wireless/realtek/rtw89/pci.c
index 102bae488180..61c54b52be1f 100644
--- a/drivers/net/wireless/realtek/rtw89/pci.c
+++ b/drivers/net/wireless/realtek/rtw89/pci.c
@@ -4874,6 +4874,19 @@ void rtw89_pci_remove(struct pci_dev *pdev)
 }
 EXPORT_SYMBOL(rtw89_pci_remove);
 
+void rtw89_pci_shutdown(struct pci_dev *pdev)
+{
+	struct ieee80211_hw *hw = pci_get_drvdata(pdev);
+	struct rtw89_dev *rtwdev;
+
+	if (!hw)
+		return;
+
+	rtwdev = hw->priv;
+	set_bit(RTW89_FLAG_SHUTDOWN, rtwdev->flags);
+}
+EXPORT_SYMBOL(rtw89_pci_shutdown);
+
 MODULE_AUTHOR("Realtek Corporation");
 MODULE_DESCRIPTION("Realtek PCI 802.11ax wireless driver");
 MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/net/wireless/realtek/rtw89/pci.h b/drivers/net/wireless/realtek/rtw89/pci.h
index c3f2d0df5846..0728120d721f 100644
--- a/drivers/net/wireless/realtek/rtw89/pci.h
+++ b/drivers/net/wireless/realtek/rtw89/pci.h
@@ -1751,6 +1751,7 @@ struct pci_device_id;
 
 int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id);
 void rtw89_pci_remove(struct pci_dev *pdev);
+void rtw89_pci_shutdown(struct pci_dev *pdev);
 void rtw89_pci_basic_cfg(struct rtw89_dev *rtwdev, bool resume);
 void rtw89_pci_ops_reset(struct rtw89_dev *rtwdev);
 int rtw89_pci_ltr_set(struct rtw89_dev *rtwdev, bool en);
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8851be.c b/drivers/net/wireless/realtek/rtw89/rtw8851be.c
index 640672eb0d26..61e6c997b206 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8851be.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8851be.c
@@ -93,6 +93,7 @@ static struct pci_driver rtw89_8851be_driver = {
 	.id_table	= rtw89_8851be_id_table,
 	.probe		= rtw89_pci_probe,
 	.remove		= rtw89_pci_remove,
+	.shutdown	= rtw89_pci_shutdown,
 	.driver.pm	= &rtw89_pm_ops,
 	.err_handler    = &rtw89_pci_err_handler,
 };
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852ae.c b/drivers/net/wireless/realtek/rtw89/rtw8852ae.c
index 64306cdc1ee4..e6fbcf75f1ad 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852ae.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852ae.c
@@ -95,6 +95,7 @@ static struct pci_driver rtw89_8852ae_driver = {
 	.id_table	= rtw89_8852ae_id_table,
 	.probe		= rtw89_pci_probe,
 	.remove		= rtw89_pci_remove,
+	.shutdown	= rtw89_pci_shutdown,
 	.driver.pm	= &rtw89_pm_ops,
 	.err_handler    = &rtw89_pci_err_handler,
 };
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852be.c b/drivers/net/wireless/realtek/rtw89/rtw8852be.c
index 5bc0a6a99d1d..25463342ac89 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852be.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852be.c
@@ -97,6 +97,7 @@ static struct pci_driver rtw89_8852be_driver = {
 	.id_table	= rtw89_8852be_id_table,
 	.probe		= rtw89_pci_probe,
 	.remove		= rtw89_pci_remove,
+	.shutdown	= rtw89_pci_shutdown,
 	.driver.pm	= &rtw89_pm_ops,
 	.err_handler    = &rtw89_pci_err_handler,
 };
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852bte.c b/drivers/net/wireless/realtek/rtw89/rtw8852bte.c
index 49a72ca835ac..bf22be739f39 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852bte.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852bte.c
@@ -99,6 +99,7 @@ static struct pci_driver rtw89_8852bte_driver = {
 	.id_table	= rtw89_8852bte_id_table,
 	.probe		= rtw89_pci_probe,
 	.remove		= rtw89_pci_remove,
+	.shutdown	= rtw89_pci_shutdown,
 	.driver.pm	= &rtw89_pm_ops,
 	.err_handler    = &rtw89_pci_err_handler,
 };
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852ce.c b/drivers/net/wireless/realtek/rtw89/rtw8852ce.c
index 3c64c0539205..b8d4d9f02686 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852ce.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852ce.c
@@ -122,6 +122,7 @@ static struct pci_driver rtw89_8852ce_driver = {
 	.id_table	= rtw89_8852ce_id_table,
 	.probe		= rtw89_pci_probe,
 	.remove		= rtw89_pci_remove,
+	.shutdown	= rtw89_pci_shutdown,
 	.driver.pm	= &rtw89_pm_ops,
 	.err_handler    = &rtw89_pci_err_handler,
 };
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8922ae.c b/drivers/net/wireless/realtek/rtw89/rtw8922ae.c
index 5527a8db393b..54bcd3f3d008 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8922ae.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8922ae.c
@@ -111,6 +111,7 @@ static struct pci_driver rtw89_8922ae_driver = {
 	.id_table	= rtw89_8922ae_id_table,
 	.probe		= rtw89_pci_probe,
 	.remove		= rtw89_pci_remove,
+	.shutdown	= rtw89_pci_shutdown,
 	.driver.pm	= &rtw89_pm_ops_be,
 	.err_handler    = &rtw89_pci_err_handler,
 };
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8922de.c b/drivers/net/wireless/realtek/rtw89/rtw8922de.c
index a1a81c338be3..65476a35a323 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8922de.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8922de.c
@@ -111,6 +111,7 @@ static struct pci_driver rtw89_8922de_driver = {
 	.id_table	= rtw89_8922de_id_table,
 	.probe		= rtw89_pci_probe,
 	.remove		= rtw89_pci_remove,
+	.shutdown	= rtw89_pci_shutdown,
 	.driver.pm	= &rtw89_pm_ops_be,
 	.err_handler    = &rtw89_pci_err_handler,
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-29  1:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28  1:54 [PATCH] wifi: rtw89: 8852be: add .shutdown callback to quiesce device on reboot yhchen312
2026-07-28  2:45 ` Ping-Ke Shih
2026-07-29  1:35   ` yhchen312
2026-07-29  1:41   ` [PATCH v2] wifi: rtw89: pci: add .shutdown callback to stop rfkill polling " yhchen312

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox