1: 7fa8fad0490b ! 1: c3d9922e2b51 wifi: ath11k: initialise the CE descriptor waitqueue once per device @@ Commit message  Initialise the queues once in ath11k_core_alloc().  - Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1 + Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1  Fixes: f951380a6022 ("ath11k: Disabling credit flow for WMI path") Reviewed-by: Baochen Qiang  - Assisted-by: Claude:claude-opus-5-5 + Tested-by: Florian Maurer # IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146 (backport to 6.18) Signed-off-by: Julius Bairaktaris   ## drivers/net/wireless/ath/ath11k/core.c ##  2: 1c8fafc1ae06 ! 2: 7e66afa95b6a wifi: ath11k: keep the radios when a firmware recovery fails @@ Commit message Destroy the radios only when ATH11K_FLAG_REGISTERED is clear, as ath11k_mac_allocate() does.  - Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1 + ath11k_core_pdev_create() has the same problem with the registration. + During a recovery ath11k_mac_register() and ath11k_debugfs_pdev_create() + return early, but when a later step such as ath11k_spectral_init() or + ath11k_cfr_init() fails, the error path calls ath11k_mac_unregister() + and ath11k_debugfs_pdev_destroy(). The first unregisters the radios + from mac80211 while ATH11K_FLAG_REGISTERED stays set, so driver removal + unregisters them a second time. The second removes the debugfs tree of + the device with the macN directories, while ar->debug.debugfs_pdev + keeps pointing to the removed directory; the next recovery's + ath11k_spectral_init() and ath11k_cfr_init() create their files under + it. Undo both there only when ATH11K_FLAG_REGISTERED is clear as well, + which is when this call did them. + + Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1  Fixes: 0366f42640a4 ("ath11k: Move mac80211 hw allocation before wmi_init command") - Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julius Bairaktaris   ## drivers/net/wireless/ath/ath11k/core.c ## +@@ drivers/net/wireless/ath/ath11k/core.c: static int ath11k_core_pdev_create(struct ath11k_base *ab) + err_thermal_unregister: + ath11k_thermal_unregister(ab); + err_mac_unregister: +- ath11k_mac_unregister(ab); ++ if (!test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) ++ ath11k_mac_unregister(ab); + err_dp_pdev_free: + ath11k_dp_pdev_free(ab); + err_pdev_debug: +- ath11k_debugfs_pdev_destroy(ab); ++ if (!test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) ++ ath11k_debugfs_pdev_destroy(ab); +  + return ret; + }  @@ drivers/net/wireless/ath/ath11k/core.c: static int ath11k_core_start(struct ath11k_base *ab) err_reo_cleanup: ath11k_dp_pdev_reo_cleanup(ab);  3: 493ec38c5e50 ! 3: f1316658f548 wifi: ath11k: keep the srng allocations when a firmware recovery fails @@ Commit message Return the error and keep the allocations for ath11k_ahb_remove() and ath11k_pci_remove() to free.  - Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1 + A recovery that fails before ath11k_ce_init_pipes() rebuilds the rings + leaves them as ath11k_hal_srng_clear() zeroed them, lock included, and + the same walk then reads the NULL tail pointer in + ath11k_ce_completed_send_next(), at removal or in the next recovery. + Nothing in dev_flags tells such a recovery from one that failed after + the rings were rebuilt. Set ATH11K_FLAG_CE_RINGS_SETUP once + ath11k_ce_init_pipes() has set the rings up, clear it where + ath11k_hal_srng_clear() zeroes them, and let ath11k_ce_cleanup_pipes(), + which every copy engine teardown goes through, return while it is clear. + + The rx_replenish_retry timer posts buffers to the copy engine rings and + ath11k_core_reconfigure_on_crash() does not stop it, so it can fire on + the zeroed rings too. Stop it before the copy engine cleanup, as + ath11k_ahb_stop() does. Also test ATH11K_FLAG_CRASH_FLUSH in + ath11k_ce_send() before it reaps a ring rather than after. + + Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1  Fixes: 32be3ca4cf78 ("wifi: ath11k: HAL SRNG: don't deinitialize and re-initialize again") - Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julius Bairaktaris   + ## drivers/net/wireless/ath/ath11k/ce.c ## +@@ drivers/net/wireless/ath/ath11k/ce.c: int ath11k_ce_send(struct ath11k_base *ab, struct sk_buff *skb, u8 pipe_id, + u8 byte_swap_data = 0; + int num_used; +  ++ if (test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags)) ++ return -ESHUTDOWN; ++ + /* Check if some entries could be regained by handling tx completion if + * the CE has interrupts disabled and the used entries is more than the + * defined usage threshold. +@@ drivers/net/wireless/ath/ath11k/ce.c: int ath11k_ce_send(struct ath11k_base *ab, struct sk_buff *skb, u8 pipe_id, + ath11k_ce_poll_send_completed(ab, pipe->pipe_num); + } +  +- if (test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags)) +- return -ESHUTDOWN; +- + spin_lock_bh(&ab->ce.ce_lock); +  + write_index = pipe->src_ring->write_index; +@@ drivers/net/wireless/ath/ath11k/ce.c: void ath11k_ce_cleanup_pipes(struct ath11k_base *ab) + struct ath11k_ce_pipe *pipe; + int pipe_num; +  ++ if (!test_bit(ATH11K_FLAG_CE_RINGS_SETUP, &ab->dev_flags)) ++ return; ++ + ath11k_ce_stop_shadow_timers(ab); +  + for (pipe_num = 0; pipe_num < ab->hw_params.ce_count; pipe_num++) { + ## drivers/net/wireless/ath/ath11k/core.c ## +@@ drivers/net/wireless/ath/ath11k/core.c: int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab) + goto err_firmware_stop; + } +  ++ set_bit(ATH11K_FLAG_CE_RINGS_SETUP, &ab->dev_flags); ++ + ret = ath11k_dp_alloc(ab); + if (ret) { + ath11k_err(ab, "failed to init DP: %d\n", ret); +@@ drivers/net/wireless/ath/ath11k/core.c: static int ath11k_core_reconfigure_on_crash(struct ath11k_base *ab) + ath11k_dp_pdev_free(ab); + ath11k_cfr_deinit(ab); + ath11k_spectral_deinit(ab); ++ timer_delete_sync(&ab->rx_replenish_retry); + ath11k_ce_cleanup_pipes(ab); + ath11k_wmi_detach(ab); + ath11k_dp_pdev_reo_cleanup(ab); + mutex_unlock(&ab->core_lock); +  + ath11k_dp_free(ab); ++ clear_bit(ATH11K_FLAG_CE_RINGS_SETUP, &ab->dev_flags); + ath11k_hal_srng_clear(ab); +  + ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS(ab))) - 1;  @@ drivers/net/wireless/ath/ath11k/core.c: static int ath11k_core_reconfigure_on_crash(struct ath11k_base *ab)  ret = ath11k_core_qmi_firmware_ready(ab); @@ drivers/net/wireless/ath/ath11k/core.c: static int ath11k_core_reconfigure_on_cr }  void ath11k_core_halt(struct ath11k *ar) + + ## drivers/net/wireless/ath/ath11k/core.h ## +@@ drivers/net/wireless/ath/ath11k/core.h: enum ath11k_dev_flags { + ATH11K_FLAG_DEVICE_INIT_DONE, + ATH11K_FLAG_MULTI_MSI_VECTORS, + ATH11K_FLAG_FTM_SEGMENTED, ++ ATH11K_FLAG_CE_RINGS_SETUP, + }; +  + enum ath11k_monitor_flags {  4: 83d6bf345a5f ! 4: b6b70f4bc82d wifi: ath11k: clear CRASH_FLUSH only after recovery rebuilds the rings @@ Commit message Clear the flag once the rings are rebuilt, before ath11k_core_start() sends the first HTC message.  - Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1 + If ath11k_core_start() or ath11k_core_pdev_create() then fails, the error + path frees the data path rings with the flag clear. The stations stay in + ab->peers, so removing one later, or removing the driver, makes + ath11k_dp_tx_send_reo_cmd() write a REO command into the freed REO + command ring. Set the flag again before ath11k_dp_free(). + + On targets that do not restart the firmware after the cold boot + calibration, the QMI FW_READY handler clears the flag as well, also + during a recovery. FW_READY follows the firmware start, so it arrives + while the restart work is still rebuilding the rings. Clear the flag + there only on the first boot, before that handler starts the firmware + itself. + + Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1  Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") - Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julius Bairaktaris   ## drivers/net/wireless/ath/ath11k/core.c ## @@ drivers/net/wireless/ath/ath11k/core.c: int ath11k_core_qmi_firmware_ready(struc if (ath11k_frame_mode == ATH11K_HW_TXRX_RAW) set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);  +@@ drivers/net/wireless/ath/ath11k/core.c: int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab) + if (!test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) + ath11k_mac_destroy(ab); + err_dp_free: ++ set_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags); + ath11k_dp_free(ab); + mutex_unlock(&ab->core_lock); + err_firmware_stop:  @@ drivers/net/wireless/ath/ath11k/core.c: static int ath11k_core_reconfigure_on_crash(struct ath11k_base *ab)  ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS(ab))) - 1; @@ drivers/net/wireless/ath/ath11k/core.c: static int ath11k_core_reconfigure_on_cr ret = ath11k_core_qmi_firmware_ready(ab); if (ret) return ret; + + ## drivers/net/wireless/ath/ath11k/qmi.c ## +@@ drivers/net/wireless/ath/ath11k/qmi.c: static void ath11k_qmi_driver_event_work(struct work_struct *work) + if (ab->hw_params.cbcal_restart_fw) + break; +  +- clear_bit(ATH11K_FLAG_CRASH_FLUSH, +- &ab->dev_flags); + clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); + if (!test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) { ++ clear_bit(ATH11K_FLAG_CRASH_FLUSH, ++ &ab->dev_flags); + ret = ath11k_core_qmi_firmware_ready(ab); + if (ret) { + set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags);  5: a8c6caec4c5c < -: ------------ wifi: ath11k: hold back WMI commands while the firmware restarts  -: ------------ > 5: 5b436868945f wifi: ath11k: hold back WMI commands while the firmware restarts  -: ------------ > 6: 025157e12701 wifi: ath11k: don't disable ext IRQs twice  -: ------------ > 7: 184494d2117a wifi: ath11k: depend on RPMSG instead of selecting it  -: ------------ > 8: 04029e155251 wifi: ath11k: ahb: stop TX before WCSS is reset on a firmware crash  -: ------------ > 9: edf82d94fce4 wifi: ath11k: release the QMI handle when the QMI service init fails  -: ------------ > 10: a79cc0d1c4e9 wifi: ath11k: ahb: configure the IRQs before the firmware is booted  -: ------------ > 11: 3a41ba5a6e31 wifi: ath11k: free the queued QMI events when the QMI service is torn down  -: ------------ > 12: 78a27500a2b8 wifi: ath11k: stop the restart work before WCSS goes down  -: ------------ > 13: d6417170b6af wifi: ath11k: keep the cooling device across a firmware recovery