Re: [PATCH] wifi: rtw89: 8852be: add .shutdown callback to quiesce device on reboot

From: yhchen312

Date: Tue Jul 28 2026 - 21:36:47 EST


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