[PATCH ath-next 09/17] wifi: ath12k: add support for unified data-region memory allocation

From: Aaradhana Sahu

Date: Thu Oct 08 2026 - 06:31:09 EST


Add support for devices such as QCN6432 that provide the M3 and
calibration memory through a unified data-region reserved-memory
node. The QCN6432 device tree continues to provide separate
q6-region and mlo-global-mem regions, while the memory types
mapped to M3 and calibration memory are allocated sequentially from
data-region.

Track the allocated space using an offset and allocate each required
memory chunk from the unified region.

If the data-region lookup does not return a reserved-memory region,
fall back to the existing per-memory-type allocation scheme using the
named memory regions such as q6-region, m3-dump, and q6-caldb.

Introduce a helper ath12k_qmi_map_target_mem() to initialize and map QMI
target memory chunks.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
Tested-on: IPQ5332 hw1.0 AHB WLAN.WBE.1.6-01322-QCAHKSWPL_SILICONZ-1
Tested-on: QCN6432 hw1.0 AHB WLAN.WBE.1.6-01322-QCAHKSWPL_SILICONZ-1

Signed-off-by: Aaradhana Sahu <aaradhana.sahu@xxxxxxxxxxxxxxxx>
---
drivers/net/wireless/ath/ath12k/qmi.c | 83 +++++++++++++++++++++++++++++------
1 file changed, 70 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c
index 817bd820623d..cc488cfe2b2f 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.c
+++ b/drivers/net/wireless/ath/ath12k/qmi.c
@@ -2842,6 +2842,26 @@ static const char *ath12k_qmi_get_mem_reg_name(int mem_type)
}
}

+static int ath12k_qmi_map_target_mem(struct ath12k_base *ab, int idx,
+ phys_addr_t paddr, u32 size, u32 type)
+{
+ ab->qmi.target_mem[idx].paddr = paddr;
+
+ if (paddr) {
+ ab->qmi.target_mem[idx].v.ioaddr =
+ ioremap(ab->qmi.target_mem[idx].paddr, size);
+ if (!ab->qmi.target_mem[idx].v.ioaddr)
+ return -EIO;
+ } else {
+ ab->qmi.target_mem[idx].v.ioaddr = NULL;
+ }
+
+ ab->qmi.target_mem[idx].size = size;
+ ab->qmi.target_mem[idx].type = type;
+
+ return 0;
+}
+
static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab)
{
struct device_node *np = ab->dev->of_node;
@@ -2851,6 +2871,48 @@ static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab)
const char *rname;
int i, idx, ret;

+ ret = of_reserved_mem_region_to_resource_byname(np, "data-region", &res);
+ if (ret && ret != -ENODATA)
+ return ret;
+
+ if (!ret) {
+ avail_rmem_size = resource_size(&res);
+ for (i = 0, idx = 0; i < ab->qmi.mem_seg_count; i++) {
+ chunk = &ab->qmi.target_mem[i];
+
+ if (chunk->type == CALDB_MEM_REGION_TYPE) {
+ ret = ath12k_qmi_map_target_mem(ab, idx, 0, chunk->size,
+ chunk->type);
+ if (ret)
+ goto out;
+
+ idx++;
+ continue;
+ }
+
+ if (offset > avail_rmem_size ||
+ avail_rmem_size - offset < chunk->size) {
+ ath12k_err(ab, "failed to assign mem type %u req size %u avail size %zu\n",
+ chunk->type, chunk->size,
+ offset > avail_rmem_size ? 0 :
+ avail_rmem_size - offset);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = ath12k_qmi_map_target_mem(ab, idx, res.start + offset,
+ chunk->size, chunk->type);
+ if (ret)
+ goto out;
+
+ offset += chunk->size;
+ idx++;
+ }
+
+ ab->qmi.mem_seg_count = idx;
+ return 0;
+ }
+
for (i = 0, idx = 0; i < ab->qmi.mem_seg_count; i++) {
chunk = &ab->qmi.target_mem[i];
if (chunk->type == CALDB_MEM_REGION_TYPE) {
@@ -2860,10 +2922,11 @@ static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab)
* Once cold boot calibration is enabled add support to
* assign reserved memory from DT.
*/
- ab->qmi.target_mem[idx].paddr = 0;
- ab->qmi.target_mem[idx].v.ioaddr = NULL;
- ab->qmi.target_mem[idx].size = chunk->size;
- ab->qmi.target_mem[idx].type = chunk->type;
+ ret = ath12k_qmi_map_target_mem(ab, idx, 0, chunk->size,
+ chunk->type);
+ if (ret)
+ goto out;
+
idx++;
continue;
}
@@ -2904,16 +2967,10 @@ static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab)
goto out;
}

- ab->qmi.target_mem[idx].paddr = res.start;
- ab->qmi.target_mem[idx].v.ioaddr = ioremap(ab->qmi.target_mem[idx].paddr,
- chunk->size);
- if (!ab->qmi.target_mem[idx].v.ioaddr) {
- ret = -EIO;
+ ret = ath12k_qmi_map_target_mem(ab, idx, res.start, chunk->size,
+ chunk->type);
+ if (ret)
goto out;
- }
-
- ab->qmi.target_mem[idx].size = chunk->size;
- ab->qmi.target_mem[idx].type = chunk->type;
idx++;
}
ab->qmi.mem_seg_count = idx;

--
2.34.1