Skip to contentSkip to conversation

Grab IPA IMEM slice through DT

PATCH Applied Konrad Dybcio 2 participants 5 messages Mar 2 – Mar 4

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v6 cover Grab IPA IMEM slice through DT

This adds the necessary driver change to migrate over from hardcoded-per-IPA-version-but-varying-per-implementation numbers, while unfortunately keeping them in there for backwards compatibility.

The DT changes will be submitted in a separate series, this one is OK to merge independently.

---
Changes in v6:
- Refrain from corrupting the resource representing IPA pdev's
"ipa-shared" reg region
- Rebase on next-20260227 (NOP)
- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- Rebase on next-20260223 (NOP)
- Resend after the merge window formally closed..
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Fix a memmap() leak
- Adjust comment style, take Alex's suggestion about very explicit
DEPRECATION notices
- Pick up tags
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Pick up tags, rebase (effectively a NOP)
- Add actual binding constraints for modem-tables, drop Alex's r-b
- Better describe the purpose of this region, as much as I can anyway
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Actually pass the retrieved data to the target function
- Re-wrap comments to match net/ style
- Mention next-next in the mail subjects
- Pick up tags
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Konrad Dybcio (3):
dt-bindings: sram: qcom,imem: Allow modem-tables subnode
dt-bindings: net: qcom,ipa: Add sram property for describing IMEM slice
net: ipa: Grab IMEM slice base/size from DTS

 .../devicetree/bindings/net/qcom,ipa.yaml          |  7 +++++++
 .../devicetree/bindings/sram/qcom,imem.yaml        | 14 +++++++++++++
 drivers/net/ipa/ipa_data.h                         |  9 ++++++--
 drivers/net/ipa/ipa_mem.c                          | 24 +++++++++++++++++++++-
 4 files changed, 51 insertions(+), 3 deletions(-)

---
base-commit: 3fa5e5702a82d259897bd7e209469bc06368bf31
change-id: 20250523-topic-ipa_imem-def66cca88e5

Best regards,

Signature · 1 line
Konrad Dybcio <[email protected]>
#1 lore raw

PATCH v6 1/3 dt-bindings: sram: qcom,imem: Allow modem-tables subnode

From: Konrad Dybcio <[email protected]>

The IP Accelerator hardware/firmware owns a sizeable region within the IMEM, named 'modem-tables', containing various packet processing configuration data.

It's not actually accessed by the OS, although we have to IOMMU-map it with the IPA device, so that presumably the firmware can act upon it.

Allow it as a subnode of IMEM.

---
 Documentation/devicetree/bindings/sram/qcom,imem.yaml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/sram/qcom,imem.yaml +14 -0
index 6a627c57ae2f..c63026904061 100644
@@ -67,6 +67,20 @@ properties:
     $ref: /schemas/power/reset/syscon-reboot-mode.yaml#
 
 patternProperties:
+  "^modem-tables@[0-9a-f]+$":
+    type: object
+    description:
+      Region containing packet processing configuration for the IP Accelerator.
+
+    properties:
+      reg:
+        maxItems: 1
+
+    required:
+      - reg
+
+    additionalProperties: false
+
   "^pil-reloc@[0-9a-f]+$":
     $ref: /schemas/remoteproc/qcom,pil-info.yaml#
     description: Peripheral image loader relocation region
Signature · 1 line
2.53.0
#2 lore raw

PATCH v6 2/3 dt-bindings: net: qcom,ipa: Add sram property for describing IMEM slice

In reply to Konrad Dybcio

From: Konrad Dybcio <[email protected]>

The IPA driver currently grabs a slice of IMEM through hardcoded addresses. Not only is that ugly and against the principles of DT, but it also creates a situation where two distinct platforms implementing the same version of IPA would need to be hardcoded together and matched at runtime.

Instead, do the sane thing and accept a handle to said region directly.

Don't make it required on purpose, as it's not there on ancient implementations (currently unsupported) and we're not yet done with filling the data across al DTs.

---
 Documentation/devicetree/bindings/net/qcom,ipa.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/net/qcom,ipa.yaml +7 -0
index c7f5f2ef7452..4237e74041ef 100644
@@ -165,6 +165,13 @@ properties:
       initializing IPA hardware.  Optional, and only used when
       Trust Zone performs early initialization.
 
+  sram:
+    maxItems: 1
+    description:
+      A reference to an additional region residing in IMEM (special
+      on-chip SRAM), which is accessed by the IPA firmware and needs
+      to be IOMMU-mapped from the OS.
+
 required:
   - compatible
   - iommus
Signature · 1 line
2.53.0
#3 lore raw

PATCH v6 3/3 net: ipa: Grab IMEM slice base/size from DTS

In reply to Konrad Dybcio

From: Konrad Dybcio <[email protected]>

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.

---
 drivers/net/ipa/ipa_data.h |  9 +++++++--
 drivers/net/ipa/ipa_mem.c  | 24 +++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)
drivers/net/ipa/ipa_data.h +7 -2
index 2fd03f0799b2..f3bdc64cef05 100644
@@ -185,8 +185,13 @@ struct ipa_resource_data {
 struct ipa_mem_data {
 	u32 local_count;
 	const struct ipa_mem *local;
-	u32 imem_addr;
-	u32 imem_size;
+
+	/* These values are now passed via DT, but to support
+	 * older systems we must allow this to be specified here.
+	 */
+	u32 imem_addr; /* DEPRECATED */
+	u32 imem_size; /* DEPRECATED */
+
 	u32 smem_size;
 };
 
drivers/net/ipa/ipa_mem.c +23 -1
index 835a3c9c1fd4..078d32a18dbf 100644
@@ -7,6 +7,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/iommu.h>
+#include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
 
@@ -617,7 +618,9 @@ static void ipa_smem_exit(struct ipa *ipa)
 int ipa_mem_init(struct ipa *ipa, struct platform_device *pdev,
 		 const struct ipa_mem_data *mem_data)
 {
+	struct device_node *ipa_slice_np;
 	struct device *dev = &pdev->dev;
+	u32 imem_base, imem_size;
 	struct resource *res;
 	int ret;
 
@@ -656,7 +659,26 @@ int ipa_mem_init(struct ipa *ipa, struct platform_device *pdev,
 	ipa->mem_addr = res->start;
 	ipa->mem_size = resource_size(res);
 
-	ret = ipa_imem_init(ipa, mem_data->imem_addr, mem_data->imem_size);
+	ipa_slice_np = of_parse_phandle(dev->of_node, "sram", 0);
+	if (ipa_slice_np) {
+		struct resource sram_res;
+
+		ret = of_address_to_resource(ipa_slice_np, 0, &sram_res);
+		of_node_put(ipa_slice_np);
+		if (ret)
+			goto err_unmap;
+
+		imem_base = sram_res.start;
+		imem_size = resource_size(&sram_res);
+	} else {
+		/* Backwards compatibility for DTs lacking
+		 * an explicit reference
+		 */
+		imem_base = mem_data->imem_addr;
+		imem_size = mem_data->imem_size;
+	}
+
+	ret = ipa_imem_init(ipa, imem_base, imem_size);
 	if (ret)
 		goto err_unmap;
 
Signature · 1 line
2.53.0
#4 lore raw
In reply to Konrad Dybcio
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 02 Mar 2026 16:58:42 +0100 you wrote:

This adds the necessary driver change to migrate over from hardcoded-per-IPA-version-but-varying-per-implementation numbers, while unfortunately keeping them in there for backwards compatibility.

The DT changes will be submitted in a separate series, this one is OK to merge independently.

[...]

Here is the summary with links:
- [net-next,v6,1/3] dt-bindings: sram: qcom,imem: Allow modem-tables subnode

    https://git.kernel.org/netdev/net-next/c/ca4c7771a059
  - [net-next,v6,2/3] dt-bindings: net: qcom,ipa: Add sram property for describing IMEM slice
    https://git.kernel.org/netdev/net-next/c/f5a598abfdd9
  - [net-next,v6,3/3] net: ipa: Grab IMEM slice base/size from DTS
    https://git.kernel.org/netdev/net-next/c/6f82cb4ecdb4

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html