Skip to contentSkip to conversation

wifi: rtw89: fix wrong pci_get_drvdata type in AER handlers

PATCH In review Christos Longros 2 participants 4 messages Mar 29 – Apr 29 Realtek wireless driver (rtw89)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: rtw89: fix wrong pci_get_drvdata type in AER handlers

rtw89 stores an ieee80211_hw pointer via pci_set_drvdata() at probe time, but io_error_detected() and io_resume() retrieve it as a net_device pointer. This causes netif_device_detach/attach to operate on an ieee80211_hw struct, reading and writing at wrong offsets. The adjacent io_slot_reset() already does it correctly.

Use ieee80211_stop_queues/wake_queues instead, consistent with every other queue stop/start path in the driver.

Tested on RTL8852CE by calling the handlers from a test module before and after the fix.

---
 drivers/net/wireless/realtek/rtw89/pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtw89/pci.c +4 -4
index 43c61b3dc..64554eb35 100644
@@ -4624,9 +4624,9 @@ EXPORT_SYMBOL(rtw89_pm_ops);
 static pci_ers_result_t rtw89_pci_io_error_detected(struct pci_dev *pdev,
 						    pci_channel_state_t state)
 {
-	struct net_device *netdev = pci_get_drvdata(pdev);
+	struct ieee80211_hw *hw = pci_get_drvdata(pdev);
 
-	netif_device_detach(netdev);
+	ieee80211_stop_queues(hw);
 
 	return PCI_ERS_RESULT_NEED_RESET;
 }
@@ -4643,12 +4643,12 @@ static pci_ers_result_t rtw89_pci_io_slot_reset(struct pci_dev *pdev)
 
 static void rtw89_pci_io_resume(struct pci_dev *pdev)
 {
-	struct net_device *netdev = pci_get_drvdata(pdev);
+	struct ieee80211_hw *hw = pci_get_drvdata(pdev);
 
 	/* ack any pending wake events, disable PME */
 	pci_enable_wake(pdev, PCI_D0, 0);
 
-	netif_device_attach(netdev);
+	ieee80211_wake_queues(hw);
 }
 
 const struct pci_error_handlers rtw89_pci_err_handler = {
Signature · 1 line
2.53.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Christos Longros

rtw89 stores an ieee80211_hw pointer via pci_set_drvdata() at probe time, but io_error_detected() and io_resume() retrieve it as a net_device pointer. This causes netif_device_detach/attach to operate on an ieee80211_hw struct, reading and writing at wrong offsets. The adjacent io_slot_reset() already does it correctly.

Use ieee80211_stop_queues/wake_queues instead, consistent with every other queue stop/start path in the driver.

Tested on RTL8852CE by calling the handlers from a test module before and after the fix.

Could you share the "test module" you did? I'd like to know how to test (simulate) the io error.

Quoted 2 lines
maintainer
#2 lore raw
Quoted 7 lines · Ping-Ke Shih
Quoted 6 lines · Christos Longros

rtw89 stores an ieee80211_hw pointer via pci_set_drvdata() at probe time, but io_error_detected() and io_resume() retrieve it as a net_device pointer. This causes netif_device_detach/attach to operate on an ieee80211_hw struct, reading and writing at wrong offsets. The adjacent io_slot_reset() already does it correctly.

Quoted 10 lines
Quoted 5 lines

Use ieee80211_stop_queues/wake_queues instead, consistent with every other queue stop/start path in the driver.

Tested on RTL8852CE by calling the handlers from a test module before and after the fix.

Could you share the "test module" you did? I'd like to know how to test (simulate) the io error.

Quoted 1 line

I'd add a Fixes tag

Fixes 16e3d93c6183 ("wifi: rtw89: pci: add PCI Express error handling")
Quoted 4 lines
Quoted 1 line
maintainer
#3 lore raw
In reply to Christos Longros
Quoted 6 lines · Christos Longros

rtw89 stores an ieee80211_hw pointer via pci_set_drvdata() at probe time, but io_error_detected() and io_resume() retrieve it as a net_device pointer. This causes netif_device_detach/attach to operate on an ieee80211_hw struct, reading and writing at wrong offsets. The adjacent io_slot_reset() already does it correctly.

Quoted 8 lines

Use ieee80211_stop_queues/wake_queues instead, consistent with every other queue stop/start path in the driver.

Tested on RTL8852CE by calling the handlers from a test module before and after the fix.

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

7068c379cf9a wifi: rtw89: fix wrong pci_get_drvdata type in AER handlers

---
https://github.com/pkshih/rtw.git