Commit 80905562 authored by Baochen Qiang's avatar Baochen Qiang Committed by Kalle Valo
Browse files

wifi: ath12k: add panic handler



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: default avatarBaochen Qiang <quic_bqiang@quicinc.com>
Acked-by: default avatarJeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20240529021533.10861-1-quic_bqiang@quicinc.com
parent 8233d271
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -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);
+3 −0
Original line number Diff line number Diff line
@@ -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 *));
};
+9 −0
Original line number Diff line number Diff line
@@ -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 */
+8 −0
Original line number Diff line number Diff line
@@ -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