[PATCH v3 11/12] wifi: ath12k: implement QRTR endpoint ID fetching for PCI
From: Juha-Matti Tilli <hidden>
Date: 2026-09-08 09:35:38
Also in:
ath11k, ath12k, linux-arm-msm, lkml, netdev
Subsystem:
atheros ath generic utilities, qualcomm ath12k wireless driver, the rest · Maintainers:
Jeff Johnson, Linus Torvalds
QRTR endpoint ID fetching for PCIe devices will use MHI. Originally-by: Mihai Moldovan [off-list ref] Signed-off-by: Mihai Moldovan <redacted> Signed-off-by: Juha-Matti Tilli <redacted> --- drivers/net/wireless/ath/ath12k/mhi.c | 46 +++++++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/mhi.h | 3 ++ drivers/net/wireless/ath/ath12k/pci.c | 1 + 3 files changed, 50 insertions(+)
diff --git a/drivers/net/wireless/ath/ath12k/mhi.c b/drivers/net/wireless/ath/ath12k/mhi.c
index ee87f00bc5de9..3d0884e65939d 100644
--- a/drivers/net/wireless/ath/ath12k/mhi.c
+++ b/drivers/net/wireless/ath/ath12k/mhi.c@@ -8,6 +8,8 @@ #include <linux/pci.h> #include <linux/firmware.h> +#include <net/qrtr.h> + #include "core.h" #include "debug.h" #include "mhi.h"
@@ -527,3 +529,47 @@ void ath12k_mhi_coredump(struct mhi_controller *mhi_ctrl, bool in_panic) { mhi_download_rddm_image(mhi_ctrl, in_panic); } + +static void ath12k_mhi_qrtr_free_mhi_id(void *mhi_cntrl_void) +{ + struct mhi_controller *mhi_cntrl = mhi_cntrl_void; + u32 id = mhi_cntrl->qrtr_endpoint_id; + + if (id != 0) + qrtr_endpoint_free_data_id(id); + mhi_cntrl->qrtr_endpoint_id = 0; + mhi_cntrl->free_qrtr_endpoint_id = NULL; +} + +int ath12k_mhi_set_qrtr_endpoint_id(struct ath12k_base *ab) +{ + struct ath12k_pci *ab_pci = ath12k_pci_priv(ab); + struct ath12k_qmi *qmi = &ab->qmi; + int ret; + + spin_lock(&ab_pci->mhi_ctrl->qrtr_endpoint_lock); + + if (ab_pci->mhi_ctrl->qrtr_endpoint_id) { + qmi->handle.endpoint_id = ab_pci->mhi_ctrl->qrtr_endpoint_id; + } else { + ret = qrtr_endpoint_get_data_id(&qmi->handle.endpoint_id); + if (!ret) { + ab_pci->mhi_ctrl->qrtr_endpoint_id = + qmi->handle.endpoint_id; + ab_pci->mhi_ctrl->free_qrtr_endpoint_id = + ath12k_mhi_qrtr_free_mhi_id; + } + } + + spin_unlock(&ab_pci->mhi_ctrl->qrtr_endpoint_lock); + + ath12k_dbg(ab, ATH12K_DBG_PCI, + "queried mhi_ctrl QRTR endpoint ID: %u\n", + qmi->handle.endpoint_id); + if (ret) { + ath12k_warn(ab, "failed to query QRTR endpoint ID: %d\n", ret); + return ret; + } + + return 0; +}
diff --git a/drivers/net/wireless/ath/ath12k/mhi.h b/drivers/net/wireless/ath/ath12k/mhi.h
index 3674326763858..3e692ce0b5108 100644
--- a/drivers/net/wireless/ath/ath12k/mhi.h
+++ b/drivers/net/wireless/ath/ath12k/mhi.h@@ -41,4 +41,7 @@ void ath12k_mhi_clear_vector(struct ath12k_base *ab); void ath12k_mhi_suspend(struct ath12k_pci *ar_pci); void ath12k_mhi_resume(struct ath12k_pci *ar_pci); void ath12k_mhi_coredump(struct mhi_controller *mhi_ctrl, bool in_panic); + +int ath12k_mhi_set_qrtr_endpoint_id(struct ath12k_base *ab); + #endif
diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c
index 6441927b53822..7b73672e5e8e4 100644
--- a/drivers/net/wireless/ath/ath12k/pci.c
+++ b/drivers/net/wireless/ath/ath12k/pci.c@@ -1508,6 +1508,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, + .set_qrtr_endpoint_id = ath12k_mhi_set_qrtr_endpoint_id, .panic_handler = ath12k_pci_panic_handler, #ifdef CONFIG_ATH12K_COREDUMP .coredump_download = ath12k_pci_coredump_download,
--
2.34.1