]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: Support arch-specific DP device allocation
authorRipan Deuri <quic_rdeuri@quicinc.com>
Tue, 30 Sep 2025 13:10:01 +0000 (18:40 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Tue, 30 Sep 2025 16:12:58 +0000 (09:12 -0700)
Add arch_init() and arch_deinit() ops to the PCI and AHB family ops to
support allocation and cleanup of architecture-specific fields in
ath12k_base. Define shared ath12k_wifi7_arch_init() and
ath12k_wifi7_arch_deinit() functions to handle DP device allocation and
cleanup for Wi-Fi 7 across both PCI and AHB. Introduce a new header file
wifi7/core.h to declare functions defined in wifi7/core.c.

Currently, DP device allocation and cleanup are handled via arch_init()
and arch_deinit(), which can be extended to support additional
architecture-specific initialization in the future.

Define common ath12k_wifi7_arch_init() and
ath12k_wifi7_arch_deinit() functions to handle allocation and cleanup
for Wi-Fi 7. Add a new header file wifi7/core.h to declare common Wi-Fi 7
functions.

Add ath12k_wifi7_dp_device_alloc() and ath12k_wifi7_dp_device_free() to
handle allocation and deallocation of the DP device object for Wi-Fi 7.

Add ath12k_dp_cmn_device_init() and ath12k_dp_cmn_device_deinit() to
initialize and deinitialize common DP device fields. Introduce a new header
file dp_cmn.h to declare these functions, which can also be used to expose
new common DP functions that need to be invoked from non-DP code.

Rename existing DP allocation and cleanup functions to ath12k_dp_setup()
and ath12k_dp_cleanup() to better reflect their purpose in the updated
design.

Replicate device-related fields such as device and hw_params in the DP
device object to align with the new design, which limits per packet data
path object usage to DP specific objects.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Ripan Deuri <quic_rdeuri@quicinc.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Reviewed-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Link: https://patch.msgid.link/20250930131005.2884253-3-quic_rdeuri@quicinc.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
14 files changed:
drivers/net/wireless/ath/ath12k/ahb.c
drivers/net/wireless/ath/ath12k/ahb.h
drivers/net/wireless/ath/ath12k/core.c
drivers/net/wireless/ath/ath12k/dp.c
drivers/net/wireless/ath/ath12k/dp.h
drivers/net/wireless/ath/ath12k/dp_cmn.h [new file with mode: 0644]
drivers/net/wireless/ath/ath12k/pci.c
drivers/net/wireless/ath/ath12k/pci.h
drivers/net/wireless/ath/ath12k/wifi7/ahb.c
drivers/net/wireless/ath/ath12k/wifi7/core.c
drivers/net/wireless/ath/ath12k/wifi7/core.h [new file with mode: 0644]
drivers/net/wireless/ath/ath12k/wifi7/dp.c
drivers/net/wireless/ath/ath12k/wifi7/dp.h
drivers/net/wireless/ath/ath12k/wifi7/pci.c

index 168d588604a114675bdd264cc731609875ce2318..c545bea18935c721ec9c39626c3a0d2a1e869488 100644 (file)
@@ -1088,14 +1088,26 @@ static int ath12k_ahb_probe(struct platform_device *pdev)
                goto err_rproc_deconfigure;
        }
 
+       /* Invoke arch_init here so that arch-specific init operations
+        * can utilize already initialized ab fields, such as HAL SRNGs.
+        */
+       ret = ab_ahb->device_family_ops->arch_init(ab);
+       if (ret) {
+               ath12k_err(ab, "AHB arch_init failed %d\n", ret);
+               goto err_rproc_deconfigure;
+       }
+
        ret = ath12k_core_init(ab);
        if (ret) {
                ath12k_err(ab, "failed to init core: %d\n", ret);
-               goto err_rproc_deconfigure;
+               goto err_deinit_arch;
        }
 
        return 0;
 
+err_deinit_arch:
+       ab_ahb->device_family_ops->arch_deinit(ab);
+
 err_rproc_deconfigure:
        ath12k_ahb_deconfigure_rproc(ab);
 
@@ -1134,11 +1146,13 @@ static void ath12k_ahb_remove_prepare(struct ath12k_base *ab)
 static void ath12k_ahb_free_resources(struct ath12k_base *ab)
 {
        struct platform_device *pdev = ab->pdev;
+       struct ath12k_ahb *ab_ahb = ath12k_ab_to_ahb(ab);
 
        ath12k_hal_srng_deinit(ab);
        ath12k_ce_free_pipes(ab);
        ath12k_ahb_resource_deinit(ab);
        ath12k_ahb_deconfigure_rproc(ab);
+       ab_ahb->device_family_ops->arch_deinit(ab);
        ath12k_core_free(ab);
        platform_set_drvdata(pdev, NULL);
 }
@@ -1167,7 +1181,8 @@ int ath12k_ahb_register_driver(const enum ath12k_device_family device_id,
        if (device_id >= ATH12K_DEVICE_FAMILY_MAX)
                return -EINVAL;
 
-       if (!driver || !driver->ops.probe)
+       if (!driver || !driver->ops.probe ||
+           !driver->ops.arch_init || !driver->ops.arch_deinit)
                return -EINVAL;
 
        if (ath12k_ahb_family_drivers[device_id]) {
index fce02e3af5fb406a732eb52d6854a551f6d80012..8a040d03d27a3c520a8e7779448162bb8436c388 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
 /*
  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
- * Copyright (c) 2022-2025, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
  */
 #ifndef ATH12K_AHB_H
 #define ATH12K_AHB_H
@@ -46,6 +46,8 @@ struct ath12k_base;
 
 struct ath12k_ahb_device_family_ops {
        int (*probe)(struct platform_device *pdev);
+       int (*arch_init)(struct ath12k_base *ab);
+       void (*arch_deinit)(struct ath12k_base *ab);
 };
 
 struct ath12k_ahb {
index 1534efe358870d6c31c0e8c851d044e450755cd1..e5b358f5e7034d580687e87fe0231c275b1d82e8 100644 (file)
@@ -22,6 +22,7 @@
 #include "hif.h"
 #include "pci.h"
 #include "wow.h"
+#include "dp_cmn.h"
 
 unsigned int ath12k_debug_mask;
 module_param_named(debug_mask, ath12k_debug_mask, uint, 0644);
@@ -711,7 +712,7 @@ static void ath12k_core_stop(struct ath12k_base *ab)
        ath12k_dp_rx_pdev_reo_cleanup(ab);
        ath12k_hif_stop(ab);
        ath12k_wmi_detach(ab);
-       ath12k_dp_free(ab);
+       ath12k_dp_cmn_device_deinit(ath12k_ab_to_dp(ab));
 
        /* De-Init of components as needed */
 }
@@ -1290,7 +1291,7 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab)
                goto err_firmware_stop;
        }
 
-       ret = ath12k_dp_alloc(ab);
+       ret = ath12k_dp_cmn_device_init(ath12k_ab_to_dp(ab));
        if (ret) {
                ath12k_err(ab, "failed to init DP: %d\n", ret);
                goto err_firmware_stop;
@@ -1302,7 +1303,7 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab)
        ret = ath12k_core_start(ab);
        if (ret) {
                ath12k_err(ab, "failed to start core: %d\n", ret);
-               goto err_dp_free;
+               goto err_deinit;
        }
 
        mutex_unlock(&ab->core_lock);
@@ -1335,8 +1336,8 @@ err_core_stop:
        mutex_unlock(&ag->mutex);
        goto exit;
 
-err_dp_free:
-       ath12k_dp_free(ab);
+err_deinit:
+       ath12k_dp_cmn_device_deinit(ath12k_ab_to_dp(ab));
        mutex_unlock(&ab->core_lock);
        mutex_unlock(&ag->mutex);
 
@@ -1358,7 +1359,7 @@ static int ath12k_core_reconfigure_on_crash(struct ath12k_base *ab)
        ath12k_dp_rx_pdev_reo_cleanup(ab);
        mutex_unlock(&ab->core_lock);
 
-       ath12k_dp_free(ab);
+       ath12k_dp_cmn_device_deinit(ath12k_ab_to_dp(ab));
        ath12k_hal_srng_deinit(ab);
        total_vdev = ab->num_radios * TARGET_NUM_VDEVS(ab);
        ab->free_vdev_map = (1LL << total_vdev) - 1;
index 9a97eb8685423fefe264528741a7ef3f094c6bb7..f8d38562fc7ffa3ded030bd7107d04d519edfffa 100644 (file)
@@ -13,6 +13,7 @@
 #include "wifi7/dp_rx.h"
 #include "peer.h"
 #include "dp_mon.h"
+#include "dp_cmn.h"
 
 enum ath12k_dp_desc_type {
        ATH12K_DP_TX_DESC,
@@ -1130,7 +1131,7 @@ static void ath12k_dp_reoq_lut_cleanup(struct ath12k_base *ab)
        }
 }
 
-void ath12k_dp_free(struct ath12k_base *ab)
+static void ath12k_dp_cleanup(struct ath12k_base *ab)
 {
        struct ath12k_dp *dp = ath12k_ab_to_dp(ab);
        int i;
@@ -1155,8 +1156,6 @@ void ath12k_dp_free(struct ath12k_base *ab)
 
        ath12k_dp_rx_free(ab);
        /* Deinit any SOC level resource */
-       kfree(ab->dp);
-       ab->dp = NULL;
 }
 
 void ath12k_dp_cc_config(struct ath12k_base *ab)
@@ -1564,7 +1563,7 @@ ath12k_dp_get_idle_link_rbm(struct ath12k_base *ab)
        }
 }
 
-int ath12k_dp_alloc(struct ath12k_base *ab)
+static int ath12k_dp_setup(struct ath12k_base *ab)
 {
        struct ath12k_dp *dp;
        struct hal_srng *srng = NULL;
@@ -1573,12 +1572,7 @@ int ath12k_dp_alloc(struct ath12k_base *ab)
        int ret;
        int i;
 
-       /* TODO: align dp later if cache alignment becomes a bottleneck */
-       dp = kzalloc(sizeof(*dp), GFP_KERNEL);
-       if (!dp)
-               return -ENOMEM;
-
-       ab->dp = dp;
+       dp = ath12k_ab_to_dp(ab);
        dp->ab = ab;
 
        INIT_LIST_HEAD(&dp->reo_cmd_list);
@@ -1591,7 +1585,7 @@ int ath12k_dp_alloc(struct ath12k_base *ab)
        ret = ath12k_wbm_idle_ring_setup(ab, &n_link_desc);
        if (ret) {
                ath12k_warn(ab, "failed to setup wbm_idle_ring: %d\n", ret);
-               goto fail_dp_free;
+               return ret;
        }
 
        srng = &ab->hal.srng_list[dp->wbm_idle_ring.ring_id];
@@ -1600,7 +1594,7 @@ int ath12k_dp_alloc(struct ath12k_base *ab)
                                        HAL_WBM_IDLE_LINK, srng, n_link_desc);
        if (ret) {
                ath12k_warn(ab, "failed to setup link desc: %d\n", ret);
-               goto fail_dp_free;
+               return ret;
        }
 
        ret = ath12k_dp_cc_init(ab);
@@ -1673,9 +1667,21 @@ fail_link_desc_cleanup:
        ath12k_dp_link_desc_cleanup(ab, dp->link_desc_banks,
                                    HAL_WBM_IDLE_LINK, &dp->wbm_idle_ring);
 
-fail_dp_free:
-       kfree(ab->dp);
-       ab->dp = NULL;
-
        return ret;
 }
+
+void ath12k_dp_cmn_device_deinit(struct ath12k_dp *dp)
+{
+       ath12k_dp_cleanup(dp->ab);
+}
+
+int ath12k_dp_cmn_device_init(struct ath12k_dp *dp)
+{
+       int ret;
+
+       ret = ath12k_dp_setup(dp->ab);
+       if (ret)
+               return ret;
+
+       return 0;
+}
index 71f7c4858176e3f8aa710dac9cb6633ad5f796ae..8b3973e0e676e85ce18a8985ebbff64f135bd75c 100644 (file)
@@ -424,6 +424,8 @@ struct ath12k_dp {
        struct dp_rxdma_mon_ring rx_mon_status_refill_ring[MAX_RXDMA_PER_PDEV];
        struct ath12k_reo_q_addr_lut reoq_lut;
        struct ath12k_reo_q_addr_lut ml_reoq_lut;
+       const struct ath12k_hw_params *hw_params;
+       struct device *dev;
 };
 
 static inline void ath12k_dp_get_mac_addr(u32 addr_l32, u16 addr_h16, u8 *addr)
@@ -433,8 +435,6 @@ static inline void ath12k_dp_get_mac_addr(u32 addr_l32, u16 addr_h16, u8 *addr)
 }
 
 void ath12k_dp_vdev_tx_attach(struct ath12k *ar, struct ath12k_link_vif *arvif);
-void ath12k_dp_free(struct ath12k_base *ab);
-int ath12k_dp_alloc(struct ath12k_base *ab);
 void ath12k_dp_cc_config(struct ath12k_base *ab);
 void ath12k_dp_partner_cc_init(struct ath12k_base *ab);
 int ath12k_dp_pdev_alloc(struct ath12k_base *ab);
diff --git a/drivers/net/wireless/ath/ath12k/dp_cmn.h b/drivers/net/wireless/ath/ath12k/dp_cmn.h
new file mode 100644 (file)
index 0000000..acc0782
--- /dev/null
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: BSD-3-Clause-Clear */
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef ATH12K_DP_CMN_H
+#define ATH12K_DP_CMN_H
+
+void ath12k_dp_cmn_device_deinit(struct ath12k_dp *dp);
+int ath12k_dp_cmn_device_init(struct ath12k_dp *dp);
+
+#endif
index 53f564ff5afa9ff478c38f9591c96b4c587e290f..672cf2899681adf011b8e54c83310344c3f162aa 100644 (file)
@@ -1620,13 +1620,25 @@ static int ath12k_pci_probe(struct pci_dev *pdev,
                goto err_free_irq;
        }
 
+       /* Invoke arch_init here so that arch-specific init operations
+        * can utilize already initialized ab fields, such as HAL SRNGs.
+        */
+       ret = ab_pci->device_family_ops->arch_init(ab);
+       if (ret) {
+               ath12k_err(ab, "PCI arch_init failed %d\n", ret);
+               goto err_pci_msi_free;
+       }
+
        ret = ath12k_core_init(ab);
        if (ret) {
                ath12k_err(ab, "failed to init core: %d\n", ret);
-               goto err_free_irq;
+               goto err_deinit_arch;
        }
        return 0;
 
+err_deinit_arch:
+       ab_pci->device_family_ops->arch_deinit(ab);
+
 err_free_irq:
        /* __free_irq() expects the caller to have cleared the affinity hint */
        ath12k_pci_set_irq_affinity_hint(ab_pci, NULL);
@@ -1685,6 +1697,9 @@ qmi_fail:
 
        ath12k_hal_srng_deinit(ab);
        ath12k_ce_free_pipes(ab);
+
+       ab_pci->device_family_ops->arch_deinit(ab);
+
        ath12k_core_free(ab);
 }
 
@@ -1781,7 +1796,8 @@ int ath12k_pci_register_driver(const enum ath12k_device_family device_id,
        if (device_id >= ATH12K_DEVICE_FAMILY_MAX)
                return -EINVAL;
 
-       if (!driver || !driver->ops.probe)
+       if (!driver || !driver->ops.probe ||
+           !driver->ops.arch_init || !driver->ops.arch_deinit)
                return -EINVAL;
 
        if (ath12k_pci_family_drivers[device_id]) {
index 5af33e5deacfd8acfc62afc17cb9e63d74df23d5..2c19bb42f0f70182f198156d71729d9cb07e7b20 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
 /*
  * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
  */
 #ifndef ATH12K_PCI_H
 #define ATH12K_PCI_H
@@ -97,6 +97,8 @@ struct ath12k_pci_ops {
 
 struct ath12k_pci_device_family_ops {
        int (*probe)(struct pci_dev *pdev, const struct pci_device_id *pci_dev);
+       int (*arch_init)(struct ath12k_base *ab);
+       void (*arch_deinit)(struct ath12k_base *ab);
 };
 
 struct ath12k_pci_reg_base {
index 803e13207bc067889fb4c36fff109f78a0ed66bb..a6c5f7689edd1a90d0f10651cf74885ee699355d 100644 (file)
@@ -12,6 +12,8 @@
 #include "../debug.h"
 #include "../hif.h"
 #include "hw.h"
+#include "dp.h"
+#include "core.h"
 
 static const struct of_device_id ath12k_wifi7_ahb_of_match[] = {
        { .compatible = "qcom,ipq5332-wifi",
@@ -57,6 +59,8 @@ static struct ath12k_ahb_driver ath12k_wifi7_ahb_driver = {
        .name = "ath12k_wifi7_ahb",
        .id_table = ath12k_wifi7_ahb_of_match,
        .ops.probe = ath12k_wifi7_ahb_probe,
+       .ops.arch_init = ath12k_wifi7_arch_init,
+       .ops.arch_deinit = ath12k_wifi7_arch_deinit,
 };
 
 int ath12k_wifi7_ahb_init(void)
index eb882e56e5ec2865a910d8936cb892f71541d2e9..a02c57acf1374ada2ee8b1afb93a6cacfa5d2983 100644 (file)
@@ -9,9 +9,33 @@
 #include "../pci.h"
 #include "pci.h"
 #include "ahb.h"
+#include "core.h"
+#include "dp.h"
+#include "../debug.h"
 
 static int ahb_err, pci_err;
 
+int ath12k_wifi7_arch_init(struct ath12k_base *ab)
+{
+       struct ath12k_dp *dp;
+
+       dp = ath12k_wifi7_dp_device_alloc(ab);
+       if (!dp) {
+               ath12k_err(ab, "dp alloc failed");
+               return -EINVAL;
+       }
+
+       ab->dp = dp;
+
+       return 0;
+}
+
+void ath12k_wifi7_arch_deinit(struct ath12k_base *ab)
+{
+       ath12k_wifi7_dp_device_free(ab->dp);
+       ab->dp = NULL;
+}
+
 static int ath12k_wifi7_init(void)
 {
        ahb_err = ath12k_wifi7_ahb_init();
diff --git a/drivers/net/wireless/ath/ath12k/wifi7/core.h b/drivers/net/wireless/ath/ath12k/wifi7/core.h
new file mode 100644 (file)
index 0000000..7e9689d
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause-Clear */
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+#ifndef ATH12K_CORE_WIFI7_H
+#define ATH12K_CORE_WIFI7_H
+
+int ath12k_wifi7_arch_init(struct ath12k_base *ab);
+void ath12k_wifi7_arch_deinit(struct ath12k_base *ab);
+
+#endif
index 4310f06163c931ab1d35d27e989d8fc4e68a422c..adc3480b282b3ae8845a0d5dba226654a72cd5f7 100644 (file)
@@ -8,6 +8,7 @@
 #include "../dp_rx.h"
 #include "../dp_tx.h"
 #include "../dp_mon.h"
+#include "../dp_cmn.h"
 #include "dp_rx.h"
 #include "dp.h"
 #include "dp_tx.h"
@@ -132,3 +133,27 @@ int ath12k_wifi7_dp_service_srng(struct ath12k_base *ab,
 done:
        return tot_work_done;
 }
+
+/* TODO: remove export once this file is built with wifi7 ko */
+struct ath12k_dp *ath12k_wifi7_dp_device_alloc(struct ath12k_base *ab)
+{
+       struct ath12k_dp *dp;
+
+       /* TODO: align dp later if cache alignment becomes a bottleneck */
+       dp = kzalloc(sizeof(*dp), GFP_KERNEL);
+       if (!dp)
+               return NULL;
+
+       dp->ab = ab;
+       dp->dev = ab->dev;
+       dp->hw_params = ab->hw_params;
+
+       return dp;
+}
+EXPORT_SYMBOL(ath12k_wifi7_dp_device_alloc);
+
+void ath12k_wifi7_dp_device_free(struct ath12k_dp *dp)
+{
+       kfree(dp);
+}
+EXPORT_SYMBOL(ath12k_wifi7_dp_device_free);
index 9332b9401bbf765b149fd68b1e1611a7dc9c8c36..2300fda657865ffbaf6a0da45c992d84ebdfa95f 100644 (file)
@@ -7,8 +7,15 @@
 #ifndef ATH12K_DP_WIFI7_H
 #define ATH12K_DP_WIFI7_H
 
+#include "../dp_cmn.h"
 #include "hw.h"
 
+struct ath12k_base;
+struct ath12k_dp;
+
 int ath12k_wifi7_dp_service_srng(struct ath12k_base *ab,
                                 struct ath12k_ext_irq_grp *irq_grp, int budget);
+struct ath12k_dp *ath12k_wifi7_dp_device_alloc(struct ath12k_base *ab);
+void ath12k_wifi7_dp_device_free(struct ath12k_dp *dp);
+
 #endif
index ba8c19c24ae6a8b47df88aa98c84299307a09fe8..f6dfdcf95025aac2a91460c50d0bbf31accc98c4 100644 (file)
@@ -13,6 +13,8 @@
 #include "../mhi.h"
 #include "hw.h"
 #include "../hal.h"
+#include "dp.h"
+#include "core.h"
 
 #define QCN9274_DEVICE_ID              0x1109
 #define WCN7850_DEVICE_ID              0x1107
@@ -163,6 +165,8 @@ static struct ath12k_pci_driver ath12k_wifi7_pci_driver = {
        .id_table = ath12k_wifi7_pci_id_table,
        .ops.probe = ath12k_wifi7_pci_probe,
        .reg_base = &ath12k_wifi7_reg_base,
+       .ops.arch_init = ath12k_wifi7_arch_init,
+       .ops.arch_deinit = ath12k_wifi7_arch_deinit,
 };
 
 int ath12k_wifi7_pci_init(void)