wifi: ath12k: fix crash on unbind when board data is not found
PATCH 1/1 wifi: ath12k: fix crash on unbind when board data is not found
When QCN9274 boots without the required board data in board-2.bin (e.g. board ID not supported in the default linux-firmware package), the QMI firmware initialization fails during board data loading:
ath12k_wifi7_pci 0000:07:00.0: failed to fetch board data for
bus=pci,qmi-chip-id=0,qmi-board-id=4102 from
ath12k/QCN9274/hw2.0/board-2.binWithout this fix, unbinding the device crashes with a page fault in mhi_queue and duplicate sysfs entries, and the only recovery is a reboot:
sysfs: cannot create duplicate filename '/bus/mhi/devices/mhi0_IPCR'
Workqueue: mhi_hiprio_wq mhi_pm_st_worker [mhi] Call Trace: sysfs_warn_dup.cold+0x17/0x23 sysfs_do_create_link_sd+0xe3/0xf0 bus_add_device+0x9a/0x200 device_add+0x3d4/0x750 mhi_create_devices+0x15f/0x270 [mhi] mhi_pm_mission_mode_transition.isra.0+0x20f/0x2b0 [mhi] mhi_pm_st_worker+0x26a/0x2d0 [mhi]
Fix by:
- Setting ATH12K_FLAG_QMI_FAIL when firmware_ready() fails in the FW_READY event handler.
- Using ATH12K_MHI_FORCE_POWER_OFF when QMI_FAIL is set, to skip the MHI_STATE_RESET that triggers QCN9274 firmware auto-restart.
- Replacing ath12k_pci_power_down() in the QMI_FAIL cleanup path with a direct ath12k_mhi_stop() (guarded by MHI_POWER_ON state) followed by ath12k_pci_sw_reset() for clean firmware state on re-bind.
With this fix, the user can install the correct board-2.bin from the manufacturer, unbind and bind the device, and it initializes successfully without rebooting.
Tested on QCN9274 hw2.0 with unsupported board ID (0x1006) in default board-2.bin.
--- drivers/net/wireless/ath/ath12k/mhi.c | 2 ++ drivers/net/wireless/ath/ath12k/pci.c | 4 +++- drivers/net/wireless/ath/ath12k/qmi.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/mhi.c +2 -0
@@ -507,6 +507,8 @@ void ath12k_mhi_stop(struct ath12k_pci *ab_pci, bool is_suspend)*/ if (is_suspend)ath12k_mhi_set_state (ab_pci,ATH12K_MHI_POWER_OFF_KEEP_DEV ); +else if (test_bit (ATH12K_FLAG_QMI_FAIL , &ab_pci->ab->dev_flags)) +ath12k_mhi_set_state (ab_pci,ATH12K_MHI_FORCE_POWER_OFF );else ath12k_mhi_set_state (ab_pci,ATH12K_MHI_POWER_OFF );
drivers/net/wireless/ath/ath12k/pci.c +3 -1
@@ -1741,7 +1741,9 @@ static void ath12k_pci_remove(struct pci_dev *pdev)ath12k_pci_set_irq_affinity_hint (ab_pci,NULL );if (test_bit (ATH12K_FLAG_QMI_FAIL , &ab->dev_flags)) { -ath12k_pci_power_down (ab, false); +if (test_bit (ATH12K_MHI_POWER_ON , &ab_pci->mhi_state)) +ath12k_mhi_stop (ab_pci, false); +ath12k_pci_sw_reset (ab_pci->ab, false); goto qmi_fail; }
drivers/net/wireless/ath/ath12k/qmi.c +3 -0
@@ -4095,6 +4095,9 @@ static void ath12k_qmi_driver_event_work(struct work_struct *work)if (!ret)set_bit (ATH12K_FLAG_QMI_FW_READY_COMPLETE , &ab->dev_flags); +else +set_bit (ATH12K_FLAG_QMI_FAIL , + &ab->dev_flags);break ;case ATH12K_QMI_EVENT_HOST_CAP :
Signature · 1 line
2.56.0