Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ipa: Grab IMEM slice base/size from DTS

This is a detail that differ per chip, and not per IPA version (and
there are cases of the same IPA versions being implemented across very
very very different SoCs).

This region isn't actually used by the driver, but we most definitely
want to iommu-map it, so that IPA can poke at the data within.

Reviewed-by: Alex Elder <elder@riscstar.com>
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20260302-topic-ipa_imem-v6-3-c0ebbf3eae9f@oss.qualcomm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Konrad Dybcio and committed by
Jakub Kicinski
6f82cb4e f5a598ab

+30 -3
+7 -2
drivers/net/ipa/ipa_data.h
··· 185 185 struct ipa_mem_data { 186 186 u32 local_count; 187 187 const struct ipa_mem *local; 188 - u32 imem_addr; 189 - u32 imem_size; 188 + 189 + /* These values are now passed via DT, but to support 190 + * older systems we must allow this to be specified here. 191 + */ 192 + u32 imem_addr; /* DEPRECATED */ 193 + u32 imem_size; /* DEPRECATED */ 194 + 190 195 u32 smem_size; 191 196 }; 192 197
+23 -1
drivers/net/ipa/ipa_mem.c
··· 7 7 #include <linux/dma-mapping.h> 8 8 #include <linux/io.h> 9 9 #include <linux/iommu.h> 10 + #include <linux/of_address.h> 10 11 #include <linux/platform_device.h> 11 12 #include <linux/types.h> 12 13 ··· 618 617 int ipa_mem_init(struct ipa *ipa, struct platform_device *pdev, 619 618 const struct ipa_mem_data *mem_data) 620 619 { 620 + struct device_node *ipa_slice_np; 621 621 struct device *dev = &pdev->dev; 622 + u32 imem_base, imem_size; 622 623 struct resource *res; 623 624 int ret; 624 625 ··· 659 656 ipa->mem_addr = res->start; 660 657 ipa->mem_size = resource_size(res); 661 658 662 - ret = ipa_imem_init(ipa, mem_data->imem_addr, mem_data->imem_size); 659 + ipa_slice_np = of_parse_phandle(dev->of_node, "sram", 0); 660 + if (ipa_slice_np) { 661 + struct resource sram_res; 662 + 663 + ret = of_address_to_resource(ipa_slice_np, 0, &sram_res); 664 + of_node_put(ipa_slice_np); 665 + if (ret) 666 + goto err_unmap; 667 + 668 + imem_base = sram_res.start; 669 + imem_size = resource_size(&sram_res); 670 + } else { 671 + /* Backwards compatibility for DTs lacking 672 + * an explicit reference 673 + */ 674 + imem_base = mem_data->imem_addr; 675 + imem_size = mem_data->imem_size; 676 + } 677 + 678 + ret = ipa_imem_init(ipa, imem_base, imem_size); 663 679 if (ret) 664 680 goto err_unmap; 665 681