]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: add panic handler
authorBaochen Qiang <quic_bqiang@quicinc.com>
Thu, 30 May 2024 15:56:52 +0000 (18:56 +0300)
committerKalle Valo <quic_kvalo@quicinc.com>
Mon, 3 Jun 2024 13:11:38 +0000 (16:11 +0300)
Currently for ath12k PCI devices, firmware could be running in one of
several execution environments, e.g., PBL, SBL and mission mode etc. Among
which PBL is the only stage where PCIe link negotiation could happen. So
normally firmware runs in PBL in order to be enumerated during system reboot.

However it might not work in kernel crash scenario: ath12k target is not
found after warm reboot from kernel crash. This is because when kernel crashes,
ath12k host does nothing to firmware. And during warm reboot, WLAN power
is sustained. So firmware is likely to keep running in mission mode throughout
the bootup process. As a result PCIe link is not established and thus target
not enumerated.

So add a handler in panic notification list for ath12k. When kernel crashes,
this handler gets called and tries to reset target to PBL state. Then PCIe
link negotiation could happen and target gets enumerated.

This change applies to all PCI devices including WCN7850 and QCN9274.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4

Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20240529021533.10861-1-quic_bqiang@quicinc.com
drivers/net/wireless/ath/ath12k/core.c
drivers/net/wireless/ath/ath12k/core.h
drivers/net/wireless/ath/ath12k/hif.h
drivers/net/wireless/ath/ath12k/pci.c

index e7f628e935e4a56782dcebf09bcf2e8113340f81..4c3eab4686c240df874e9ba824c7fdd635a938ff 100644 (file)
@@ -1188,6 +1188,29 @@ int ath12k_core_pre_init(struct ath12k_base *ab)
        return 0;
 }
 
+static int ath12k_core_panic_handler(struct notifier_block *nb,
+                                    unsigned long action, void *data)
+{
+       struct ath12k_base *ab = container_of(nb, struct ath12k_base,
+                                             panic_nb);
+
+       return ath12k_hif_panic_handler(ab);
+}
+
+static int ath12k_core_panic_notifier_register(struct ath12k_base *ab)
+{
+       ab->panic_nb.notifier_call = ath12k_core_panic_handler;
+
+       return atomic_notifier_chain_register(&panic_notifier_list,
+                                             &ab->panic_nb);
+}
+
+static void ath12k_core_panic_notifier_unregister(struct ath12k_base *ab)
+{
+       atomic_notifier_chain_unregister(&panic_notifier_list,
+                                        &ab->panic_nb);
+}
+
 int ath12k_core_init(struct ath12k_base *ab)
 {
        int ret;
@@ -1198,11 +1221,17 @@ int ath12k_core_init(struct ath12k_base *ab)
                return ret;
        }
 
+       ret = ath12k_core_panic_notifier_register(ab);
+       if (ret)
+               ath12k_warn(ab, "failed to register panic handler: %d\n", ret);
+
        return 0;
 }
 
 void ath12k_core_deinit(struct ath12k_base *ab)
 {
+       ath12k_core_panic_notifier_unregister(ab);
+
        mutex_lock(&ab->core_lock);
 
        ath12k_core_pdev_destroy(ab);
index 7d20b09c52e6658a4c1a8a79d309968a691176f6..44ca30b67fa2e506ab9e757a2f5b42cbfdaa25b7 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/dmi.h>
 #include <linux/ctype.h>
 #include <linux/firmware.h>
+#include <linux/panic_notifier.h>
 #include "qmi.h"
 #include "htc.h"
 #include "wmi.h"
@@ -924,6 +925,8 @@ struct ath12k_base {
 
 #endif /* CONFIG_ACPI */
 
+       struct notifier_block panic_nb;
+
        /* must be last */
        u8 drv_priv[] __aligned(sizeof(void *));
 };
index 7f0926fe751d20f6c6fb65250bc01b41cbc58a8f..0e53ec269fa4f2a9d1290b09a9bdf23f3ec294a9 100644 (file)
@@ -30,6 +30,7 @@ struct ath12k_hif_ops {
        void (*ce_irq_enable)(struct ath12k_base *ab);
        void (*ce_irq_disable)(struct ath12k_base *ab);
        void (*get_ce_msi_idx)(struct ath12k_base *ab, u32 ce_id, u32 *msi_idx);
+       int (*panic_handler)(struct ath12k_base *ab);
 };
 
 static inline int ath12k_hif_map_service_to_pipe(struct ath12k_base *ab, u16 service_id,
@@ -147,4 +148,12 @@ static inline void ath12k_hif_power_down(struct ath12k_base *ab, bool is_suspend
        ab->hif.ops->power_down(ab, is_suspend);
 }
 
+static inline int ath12k_hif_panic_handler(struct ath12k_base *ab)
+{
+       if (!ab->hif.ops->panic_handler)
+               return NOTIFY_DONE;
+
+       return ab->hif.ops->panic_handler(ab);
+}
+
 #endif /* ATH12K_HIF_H */
index 11b95d037051806c50253a7d1657491eb470dfa5..876c029f58f62c3d9644dc44c80eabae8b084739 100644 (file)
@@ -1302,6 +1302,13 @@ void ath12k_pci_power_down(struct ath12k_base *ab, bool is_suspend)
        ath12k_pci_sw_reset(ab_pci->ab, false);
 }
 
+static int ath12k_pci_panic_handler(struct ath12k_base *ab)
+{
+       ath12k_pci_sw_reset(ab, false);
+
+       return NOTIFY_OK;
+}
+
 static const struct ath12k_hif_ops ath12k_pci_hif_ops = {
        .start = ath12k_pci_start,
        .stop = ath12k_pci_stop,
@@ -1319,6 +1326,7 @@ static const struct ath12k_hif_ops ath12k_pci_hif_ops = {
        .ce_irq_enable = ath12k_pci_hif_ce_irq_enable,
        .ce_irq_disable = ath12k_pci_hif_ce_irq_disable,
        .get_ce_msi_idx = ath12k_pci_get_ce_msi_idx,
+       .panic_handler = ath12k_pci_panic_handler,
 };
 
 static