* [PATCH 0/6] misc: fastrpc: Add extended IOVA mapping support
@ 2026-08-26 13:45 Vinayak Katoch
2026-08-26 13:45 ` [PATCH 1/6] dt-bindings: misc: fastrpc: Add memory-region property for context bank Vinayak Katoch
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Vinayak Katoch @ 2026-08-26 13:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio
Cc: Bharath Kumar, Chenna Kesava Raju, linux-arm-msm, dri-devel,
devicetree, linux-kernel, Vinayak Katoch
FastRPC context banks on kaanapali and glymur are limited to a 34-bit
IOVA window. Large compute workloads such as LLM inference on the
CDSP require mapping buffers that exceed this range. Dedicated extended
context banks exist in hardware but were unused by the driver.
This series wires up end-to-end support for extended IOVA mapping:
- The DT binding gains a memory-region property for context bank nodes.
It points to a reserved-memory node whose iommu-addresses blocks the
lower IOVA range, pushing allocations into the extended address space.
The driver uses the presence of this property to identify the context
bank as an extended mapping bank. The binding also relaxes
#address-cells and #size-cells constraints to accommodate the 64-bit
values required by iommu-addresses.
- The driver is extended to read the correct SID from multi-cell reg
properties, which are needed on platforms that use #address-cells = <2>
on the fastrpc node.
- kaanapali and glymur are updated to add a fastrpc_far_region node
blocking the lower 16 GB IOVA range and link the dedicated CDSP
compute context bank to it via memory-region.
- Extended context banks are shared across all open sessions and carry
a 40-bit DMA mask. They are kept in a separate cctx->ext_cb[] array
rather than the normal session[] pool to avoid mixing exclusively-owned
and shared resources.
- Two new UAPI flags (FASTRPC_MAP_FD_EXTENDED and
FASTRPC_MAP_FD_DELAYED_EXTENDED) allow userspace to request extended
mapping. When set, fastrpc_map_attach() iterates cctx->ext_cb[] and
retries on -ENOMEM, falling over to the next extended CB if one
exhausts its IOVA space. The SID offset is corrected per-CB so the
IOVA forwarded to the DSP is valid.
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
---
Vinayak Katoch (6):
dt-bindings: misc: fastrpc: Add memory-region property for context bank
misc: fastrpc: Handle multi-cell reg in context bank probe
arm64: dts: qcom: kaanapali: Add CDSP FastRPC extended context bank
arm64: dts: qcom: glymur: Add CDSP FastRPC extended context bank
misc: fastrpc: Add extended context bank support
misc: fastrpc: Add UAPI flags for extended IOVA mapping
.../devicetree/bindings/misc/qcom,fastrpc.yaml | 12 ++-
arch/arm64/boot/dts/qcom/glymur.dtsi | 37 ++++---
arch/arm64/boot/dts/qcom/kaanapali.dtsi | 35 ++++---
drivers/misc/fastrpc.c | 114 ++++++++++++++++++---
include/uapi/misc/fastrpc.h | 7 ++
5 files changed, 159 insertions(+), 46 deletions(-)
---
base-commit: a8406e6c0b793ce0788019683837c40855b55995
change-id: 20260826-extended-mapping-9b08b0c3108d
prerequisite-change-id: 20260609-dup-sessions-ea2acaac1994:v4
prerequisite-patch-id: 15f76eb917232e683ce9271fb3f0f465a4d60abe
prerequisite-patch-id: f225961fa033cae9dce14a906752e1232b052290
prerequisite-patch-id: da0a3d55397a522ea4b77769e387df9faea8e024
Best regards,
--
Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/6] dt-bindings: misc: fastrpc: Add memory-region property for context bank
2026-08-26 13:45 [PATCH 0/6] misc: fastrpc: Add extended IOVA mapping support Vinayak Katoch
@ 2026-08-26 13:45 ` Vinayak Katoch
2026-08-26 13:45 ` [PATCH 2/6] misc: fastrpc: Handle multi-cell reg in context bank probe Vinayak Katoch
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Vinayak Katoch @ 2026-08-26 13:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio
Cc: Bharath Kumar, Chenna Kesava Raju, linux-arm-msm, dri-devel,
devicetree, linux-kernel, Vinayak Katoch
Add an optional memory-region property to the context bank node schema.
The driver uses its presence to identify a context bank as dedicated for
extended IOVA mapping and programs the SMMU with an iommu-addresses
range to push allocations into the wider address space.
Relax #address-cells to enum: [1, 2] and #size-cells to enum: [0, 2] to
allow platforms that require 64-bit values in iommu-addresses to pass
binding validation.
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
---
Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
index e945c8ba75e3..f9830ef37814 100644
--- a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
+++ b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
@@ -73,10 +73,10 @@ properties:
$ref: /schemas/types.yaml#/definitions/uint32-array
"#address-cells":
- const: 1
+ enum: [1, 2]
"#size-cells":
- const: 0
+ enum: [0, 2]
patternProperties:
"(compute-)?cb@[0-9]*$":
@@ -98,6 +98,14 @@ patternProperties:
minItems: 1
maxItems: 10
+ memory-region:
+ maxItems: 1
+ description:
+ Phandle to a reserved-memory node whose iommu-addresses property
+ blocks the lower IOVA range, forcing allocations into the extended
+ address space. Its presence marks this context bank as an extended
+ mapping bank.
+
qcom,nsessions:
$ref: /schemas/types.yaml#/definitions/uint32
default: 1
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] misc: fastrpc: Handle multi-cell reg in context bank probe
2026-08-26 13:45 [PATCH 0/6] misc: fastrpc: Add extended IOVA mapping support Vinayak Katoch
2026-08-26 13:45 ` [PATCH 1/6] dt-bindings: misc: fastrpc: Add memory-region property for context bank Vinayak Katoch
@ 2026-08-26 13:45 ` Vinayak Katoch
2026-08-26 13:45 ` [PATCH 3/6] arm64: dts: qcom: kaanapali: Add CDSP FastRPC extended context bank Vinayak Katoch
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Vinayak Katoch @ 2026-08-26 13:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio
Cc: Bharath Kumar, Chenna Kesava Raju, linux-arm-msm, dri-devel,
devicetree, linux-kernel, Vinayak Katoch
Platforms that use #address-cells = <2> on the fastrpc node encode the
context bank number in cell[1] of the reg property rather than cell[0].
Reading cell[0] on such platforms yields 0 for every context bank,
causing all sessions to share SID 0 and corrupting IOVA address
construction.
Use of_property_read_u32_index() with of_n_addr_cells() - 1 as the
index so the correct cell is read regardless of the parent address cell
width.
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 98a61b8b9013..07a0f2b229b4 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -2378,7 +2378,8 @@ static int fastrpc_cb_init(struct platform_device *pdev)
if (!cctx)
return -EINVAL;
- if (of_property_read_u32(dev->of_node, "reg", &sid))
+ if (of_property_read_u32_index(dev->of_node, "reg",
+ of_n_addr_cells(dev->of_node) - 1, &sid))
dev_info(dev, "FastRPC Session ID not specified in DT\n");
spin_lock_irqsave(&cctx->lock, flags);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] arm64: dts: qcom: kaanapali: Add CDSP FastRPC extended context bank
2026-08-26 13:45 [PATCH 0/6] misc: fastrpc: Add extended IOVA mapping support Vinayak Katoch
2026-08-26 13:45 ` [PATCH 1/6] dt-bindings: misc: fastrpc: Add memory-region property for context bank Vinayak Katoch
2026-08-26 13:45 ` [PATCH 2/6] misc: fastrpc: Handle multi-cell reg in context bank probe Vinayak Katoch
@ 2026-08-26 13:45 ` Vinayak Katoch
2026-08-26 13:45 ` [PATCH 4/6] arm64: dts: qcom: glymur: " Vinayak Katoch
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Vinayak Katoch @ 2026-08-26 13:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio
Cc: Bharath Kumar, Chenna Kesava Raju, linux-arm-msm, dri-devel,
devicetree, linux-kernel, Vinayak Katoch
Add a fastrpc_far_region reserved-memory node and link compute-cb@13 to
it via memory-region so the driver detects it as the extended mapping
bank. Bump #address-cells and #size-cells to <2> on the fastrpc ancestor
nodes and update all compute-cb reg values to the 4-cell format to
accommodate the 64-bit iommu-addresses values.
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
---
arch/arm64/boot/dts/qcom/kaanapali.dtsi | 35 +++++++++++++++++++++------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/arch/arm64/boot/dts/qcom/kaanapali.dtsi b/arch/arm64/boot/dts/qcom/kaanapali.dtsi
index 131fd2a16c54..0f258eb2a7a9 100644
--- a/arch/arm64/boot/dts/qcom/kaanapali.dtsi
+++ b/arch/arm64/boot/dts/qcom/kaanapali.dtsi
@@ -451,6 +451,10 @@ rmtfs_mem: rmtfs@d7c00000 {
qcom,client-id = <1>;
qcom,vmid = <QCOM_SCM_VMID_MSS_MSA>;
};
+
+ fastrpc_far_region: fastrpc_far_region {
+ iommu-addresses = <&fastrpc_far_cb 0x0 0x0 0x4 0x0>;
+ };
};
smp2p-adsp {
@@ -6011,6 +6015,8 @@ remoteproc_cdsp: remoteproc@26300000 {
qcom,qmp = <&aoss_qmp>;
qcom,smem-states = <&smp2p_cdsp_out 0>;
qcom,smem-state-names = "stop";
+ #address-cells = <2>;
+ #size-cells = <2>;
status = "disabled";
@@ -6022,17 +6028,19 @@ IPCC_MPROC_SIGNAL_GLINK_QMP
IPCC_MPROC_SIGNAL_GLINK_QMP>;
qcom,remote-pid = <5>;
label = "cdsp";
+ #address-cells = <2>;
+ #size-cells = <2>;
fastrpc {
compatible = "qcom,kaanapali-fastrpc";
qcom,glink-channels = "fastrpcglink-apps-dsp";
label = "cdsp";
- #address-cells = <1>;
- #size-cells = <0>;
+ #address-cells = <2>;
+ #size-cells = <2>;
compute-cb@1 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <1>;
+ reg = <0x0 0x1 0x0 0x0>;
iommus = <&apps_smmu 0x19c1 0x0>,
<&apps_smmu 0x1961 0x0>,
<&apps_smmu 0x0c21 0x0>,
@@ -6042,7 +6050,7 @@ compute-cb@1 {
compute-cb@2 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <2>;
+ reg = <0x0 0x2 0x0 0x0>;
iommus = <&apps_smmu 0x1962 0x0>,
<&apps_smmu 0x0c02 0x20>,
<&apps_smmu 0x0c42 0x0>,
@@ -6052,7 +6060,7 @@ compute-cb@2 {
compute-cb@3 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <3>;
+ reg = <0x0 0x3 0x0 0x0>;
iommus = <&apps_smmu 0x1963 0x0>,
<&apps_smmu 0x0c23 0x0>,
<&apps_smmu 0x0c03 0x40>,
@@ -6062,7 +6070,7 @@ compute-cb@3 {
compute-cb@4 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <4>;
+ reg = <0x0 0x4 0x0 0x0>;
iommus = <&apps_smmu 0x1964 0x0>,
<&apps_smmu 0x0c44 0x0>,
<&apps_smmu 0x0c04 0x20>,
@@ -6072,7 +6080,7 @@ compute-cb@4 {
compute-cb@5 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <5>;
+ reg = <0x0 0x5 0x0 0x0>;
iommus = <&apps_smmu 0x1965 0x0>,
<&apps_smmu 0x0c45 0x0>,
<&apps_smmu 0x0c05 0x20>,
@@ -6082,7 +6090,7 @@ compute-cb@5 {
compute-cb@6 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <6>;
+ reg = <0x0 0x6 0x0 0x0>;
iommus = <&apps_smmu 0x1966 0x0>,
<&apps_smmu 0x0c06 0x20>,
<&apps_smmu 0x0c46 0x0>,
@@ -6092,7 +6100,7 @@ compute-cb@6 {
compute-cb@7 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <7>;
+ reg = <0x0 0x7 0x0 0x0>;
iommus = <&apps_smmu 0x1967 0x0>,
<&apps_smmu 0x0c27 0x0>,
<&apps_smmu 0x0c07 0x40>,
@@ -6102,7 +6110,7 @@ compute-cb@7 {
compute-cb@8 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <8>;
+ reg = <0x0 0x8 0x0 0x0>;
iommus = <&apps_smmu 0x1968 0x0>,
<&apps_smmu 0x0c08 0x20>,
<&apps_smmu 0x0c48 0x0>,
@@ -6112,7 +6120,7 @@ compute-cb@8 {
compute-cb@12 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <12>;
+ reg = <0x0 0xc 0x0 0x0>;
iommus = <&apps_smmu 0x196c 0x0>,
<&apps_smmu 0x0c2c 0x00>,
<&apps_smmu 0x0c0c 0x40>,
@@ -6120,14 +6128,15 @@ compute-cb@12 {
dma-coherent;
};
- compute-cb@13 {
+ fastrpc_far_cb: compute-cb@13 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <13>;
+ reg = <0x0 0xd 0x0 0x0>;
iommus = <&apps_smmu 0x196d 0x0>,
<&apps_smmu 0x0c0d 0x40>,
<&apps_smmu 0x0c2e 0x0>,
<&apps_smmu 0x0c2d 0x0>,
<&apps_smmu 0x19cd 0x0>;
+ memory-region = <&fastrpc_far_region>;
dma-coherent;
};
};
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] arm64: dts: qcom: glymur: Add CDSP FastRPC extended context bank
2026-08-26 13:45 [PATCH 0/6] misc: fastrpc: Add extended IOVA mapping support Vinayak Katoch
` (2 preceding siblings ...)
2026-08-26 13:45 ` [PATCH 3/6] arm64: dts: qcom: kaanapali: Add CDSP FastRPC extended context bank Vinayak Katoch
@ 2026-08-26 13:45 ` Vinayak Katoch
2026-08-26 13:45 ` [PATCH 5/6] misc: fastrpc: Add extended context bank support Vinayak Katoch
2026-08-26 13:45 ` [PATCH 6/6] misc: fastrpc: Add UAPI flags for extended IOVA mapping Vinayak Katoch
5 siblings, 0 replies; 7+ messages in thread
From: Vinayak Katoch @ 2026-08-26 13:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio
Cc: Bharath Kumar, Chenna Kesava Raju, linux-arm-msm, dri-devel,
devicetree, linux-kernel, Vinayak Katoch
Add a fastrpc_far_region reserved-memory node and link compute-cb@12 to
it via memory-region so the driver detects it as the extended mapping
bank. Bump #address-cells and #size-cells to <2> on the fastrpc ancestor
nodes and update all compute-cb reg values to the 4-cell format to
accommodate the 64-bit iommu-addresses values.
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
---
arch/arm64/boot/dts/qcom/glymur.dtsi | 37 ++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/arch/arm64/boot/dts/qcom/glymur.dtsi b/arch/arm64/boot/dts/qcom/glymur.dtsi
index f04058d2e089..2aff2a8a39ae 100644
--- a/arch/arm64/boot/dts/qcom/glymur.dtsi
+++ b/arch/arm64/boot/dts/qcom/glymur.dtsi
@@ -695,6 +695,10 @@ adsp_rpc_remote_heap_mem: adsp-rpc-remote-heap {
alignment = <0x0 0x400000>;
size = <0x0 0x800000>;
};
+
+ fastrpc_far_region: fastrpc_far_region {
+ iommu-addresses = <&fastrpc_far_cb 0x0 0x0 0x4 0x0>;
+ };
};
smp2p-adsp {
@@ -7980,6 +7984,8 @@ remoteproc_cdsp: remoteproc@32300000 {
qcom,qmp = <&aoss_qmp>;
qcom,smem-states = <&smp2p_cdsp_out 0>;
qcom,smem-state-names = "stop";
+ #address-cells = <2>;
+ #size-cells = <2>;
status = "disabled";
@@ -7991,17 +7997,19 @@ IPCC_MPROC_SIGNAL_GLINK_QMP
IPCC_MPROC_SIGNAL_GLINK_QMP>;
qcom,remote-pid = <5>;
label = "cdsp";
+ #address-cells = <2>;
+ #size-cells = <2>;
fastrpc {
compatible = "qcom,glymur-fastrpc", "qcom,kaanapali-fastrpc";
qcom,glink-channels = "fastrpcglink-apps-dsp";
label = "cdsp";
- #address-cells = <1>;
- #size-cells = <0>;
+ #address-cells = <2>;
+ #size-cells = <2>;
compute-cb@1 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <1>;
+ reg = <0x0 0x1 0x0 0x0>;
iommus = <&apps_smmu 0x2401 0x440>,
<&apps_smmu 0x1961 0x0>,
@@ -8011,7 +8019,7 @@ compute-cb@1 {
compute-cb@2 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <2>;
+ reg = <0x0 0x2 0x0 0x0>;
iommus = <&apps_smmu 0x2402 0x440>,
<&apps_smmu 0x1962 0x0>,
@@ -8021,7 +8029,7 @@ compute-cb@2 {
compute-cb@3 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <3>;
+ reg = <0x0 0x3 0x0 0x0>;
iommus = <&apps_smmu 0x2403 0x440>,
<&apps_smmu 0x1963 0x0>,
@@ -8031,7 +8039,7 @@ compute-cb@3 {
compute-cb@4 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <4>;
+ reg = <0x0 0x4 0x0 0x0>;
iommus = <&apps_smmu 0x2404 0x440>,
<&apps_smmu 0x1964 0x0>,
@@ -8041,7 +8049,7 @@ compute-cb@4 {
compute-cb@5 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <5>;
+ reg = <0x0 0x5 0x0 0x0>;
iommus = <&apps_smmu 0x2405 0x440>,
<&apps_smmu 0x1965 0x0>,
@@ -8051,7 +8059,7 @@ compute-cb@5 {
compute-cb@6 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <6>;
+ reg = <0x0 0x6 0x0 0x0>;
iommus = <&apps_smmu 0x2406 0x440>,
<&apps_smmu 0x1966 0x0>,
@@ -8061,7 +8069,7 @@ compute-cb@6 {
compute-cb@7 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <7>;
+ reg = <0x0 0x7 0x0 0x0>;
iommus = <&apps_smmu 0x2407 0x440>,
<&apps_smmu 0x1967 0x0>,
@@ -8071,7 +8079,7 @@ compute-cb@7 {
compute-cb@8 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <8>;
+ reg = <0x0 0x8 0x0 0x0>;
iommus = <&apps_smmu 0x2408 0x440>,
<&apps_smmu 0x1968 0x0>,
@@ -8083,7 +8091,7 @@ compute-cb@8 {
compute-cb@10 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <10>;
+ reg = <0x0 0xa 0x0 0x0>;
iommus = <&apps_smmu 0x240c 0x440>,
<&apps_smmu 0x196c 0x0>,
@@ -8093,7 +8101,7 @@ compute-cb@10 {
compute-cb@11 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <11>;
+ reg = <0x0 0xb 0x0 0x0>;
iommus = <&apps_smmu 0x240d 0x440>,
<&apps_smmu 0x196d 0x0>,
@@ -8101,13 +8109,14 @@ compute-cb@11 {
dma-coherent;
};
- compute-cb@12 {
+ fastrpc_far_cb: compute-cb@12 {
compatible = "qcom,fastrpc-compute-cb";
- reg = <12>;
+ reg = <0x0 0xc 0x0 0x0>;
iommus = <&apps_smmu 0x240e 0x440>,
<&apps_smmu 0x196e 0x0>,
<&apps_smmu 0x19ce 0x0>;
+ memory-region = <&fastrpc_far_region>;
dma-coherent;
};
};
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] misc: fastrpc: Add extended context bank support
2026-08-26 13:45 [PATCH 0/6] misc: fastrpc: Add extended IOVA mapping support Vinayak Katoch
` (3 preceding siblings ...)
2026-08-26 13:45 ` [PATCH 4/6] arm64: dts: qcom: glymur: " Vinayak Katoch
@ 2026-08-26 13:45 ` Vinayak Katoch
2026-08-26 13:45 ` [PATCH 6/6] misc: fastrpc: Add UAPI flags for extended IOVA mapping Vinayak Katoch
5 siblings, 0 replies; 7+ messages in thread
From: Vinayak Katoch @ 2026-08-26 13:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio
Cc: Bharath Kumar, Chenna Kesava Raju, linux-arm-msm, dri-devel,
devicetree, linux-kernel, Vinayak Katoch
Extended context banks carry a 40-bit DMA mask and are shared across all
open sessions rather than exclusively owned by one. They are a
fundamentally different resource from normal CBs and do not belong in
the session[] pool.
Maintain a separate dynamically allocated cctx->ext_cb[] array instead.
Extended CBs are detected at probe time by the presence of a
memory-region phandle and routed there, leaving session[] and the normal
allocation path unchanged.
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 07a0f2b229b4..28d89fd9cbbc 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -309,6 +309,8 @@ struct fastrpc_channel_ctx {
struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS];
struct rpmsg_device *rpdev;
struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS];
+ struct fastrpc_session_ctx **ext_cb;
+ int ext_cb_count;
spinlock_t lock;
struct idr ctx_idr;
struct list_head users;
@@ -536,9 +538,13 @@ static int fastrpc_remote_heap_alloc(struct fastrpc_user *fl, struct device *dev
static void fastrpc_channel_ctx_free(struct kref *ref)
{
struct fastrpc_channel_ctx *cctx;
+ int i;
cctx = container_of(ref, struct fastrpc_channel_ctx, refcount);
+ for (i = 0; i < cctx->ext_cb_count; i++)
+ kfree(cctx->ext_cb[i]);
+ kfree(cctx->ext_cb);
idr_destroy(&cctx->ctx_idr);
kfree(cctx);
}
@@ -2373,6 +2379,8 @@ static int fastrpc_cb_init(struct platform_device *pdev)
u32 dma_bits;
u32 sid = 0;
int rc;
+ bool is_extended_cb = false;
+ struct device_node *mem_np;
cctx = dev_get_drvdata(dev->parent);
if (!cctx)
@@ -2382,6 +2390,45 @@ static int fastrpc_cb_init(struct platform_device *pdev)
of_n_addr_cells(dev->of_node) - 1, &sid))
dev_info(dev, "FastRPC Session ID not specified in DT\n");
+ mem_np = of_parse_phandle(dev->of_node, "memory-region", 0);
+ if (mem_np) {
+ is_extended_cb = true;
+ of_node_put(mem_np);
+ }
+
+ if (is_extended_cb) {
+ struct fastrpc_session_ctx **new_ext;
+
+ sess = kzalloc_obj(*sess);
+ if (!sess)
+ return -ENOMEM;
+
+ spin_lock_irqsave(&cctx->lock, flags);
+ new_ext = krealloc(cctx->ext_cb,
+ (cctx->ext_cb_count + 1) * sizeof(*cctx->ext_cb),
+ GFP_KERNEL);
+ if (!new_ext) {
+ spin_unlock_irqrestore(&cctx->lock, flags);
+ kfree(sess);
+ return -ENOMEM;
+ }
+ cctx->ext_cb = new_ext;
+ sess->valid = true;
+ sess->dev = dev;
+ sess->sid = sid;
+ dev_set_drvdata(dev, sess);
+ cctx->ext_cb[cctx->ext_cb_count++] = sess;
+ spin_unlock_irqrestore(&cctx->lock, flags);
+
+ rc = dma_set_mask(dev, DMA_BIT_MASK(40));
+ if (rc) {
+ dev_err(dev, "40-bit DMA enable failed\n");
+ return rc;
+ }
+
+ return 0;
+ }
+
spin_lock_irqsave(&cctx->lock, flags);
if (cctx->sesscount >= FASTRPC_MAX_SESSIONS) {
spin_unlock_irqrestore(&cctx->lock, flags);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] misc: fastrpc: Add UAPI flags for extended IOVA mapping
2026-08-26 13:45 [PATCH 0/6] misc: fastrpc: Add extended IOVA mapping support Vinayak Katoch
` (4 preceding siblings ...)
2026-08-26 13:45 ` [PATCH 5/6] misc: fastrpc: Add extended context bank support Vinayak Katoch
@ 2026-08-26 13:45 ` Vinayak Katoch
5 siblings, 0 replies; 7+ messages in thread
From: Vinayak Katoch @ 2026-08-26 13:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio
Cc: Bharath Kumar, Chenna Kesava Raju, linux-arm-msm, dri-devel,
devicetree, linux-kernel, Vinayak Katoch
Userspace has no way to request that a buffer be mapped through the
extended context bank, so large buffers cannot be placed in the wider
IOVA window even when one is available.
Add two UAPI flags:
FASTRPC_MAP_FD_EXTENDED - map immediately via the extended CB
FASTRPC_MAP_FD_DELAYED_EXTENDED - map on demand via the extended CB
When either flag is set, fastrpc_map_attach() iterates cctx->ext_cb[]
and retries on -ENOMEM, falling over to the next extended CB when one
exhausts its IOVA space. The SID offset passed to the DSP must reflect
the actual CB used, so fastrpc_compute_dma_addr() takes an explicit
session rather than always using fl->sctx — without this the DSP would
fault on access. All existing call sites pass flags=0 and are unaffected.
Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 64 +++++++++++++++++++++++++++++++++------------
include/uapi/misc/fastrpc.h | 7 +++++
2 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 28d89fd9cbbc..2f248667e734 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -83,6 +83,11 @@
#define FASTRPC_MAX_DSP_ATTRIBUTES (256)
#define FASTRPC_MAX_DSP_ATTRIBUTES_LEN (sizeof(u32) * FASTRPC_MAX_DSP_ATTRIBUTES)
+/* Check if the given flag is used for extended UDMA mapping */
+#define IS_EXTENDED_MAP_FLAG(flag) \
+ ((flag) == FASTRPC_MAP_FD_EXTENDED || \
+ (flag) == FASTRPC_MAP_FD_DELAYED_EXTENDED)
+
/* Retrives number of input buffers from the scalars parameter */
#define REMOTE_SCALARS_INBUFS(sc) (((sc) >> 16) & 0x0ff)
@@ -880,16 +885,19 @@ static const struct dma_buf_ops fastrpc_dma_buf_ops = {
.release = fastrpc_release,
};
-static dma_addr_t fastrpc_compute_dma_addr(struct fastrpc_user *fl, dma_addr_t sg_dma_addr)
+static dma_addr_t fastrpc_compute_dma_addr(struct fastrpc_user *fl, dma_addr_t sg_dma_addr,
+ struct fastrpc_session_ctx *sess)
{
- return sg_dma_addr + fastrpc_sid_offset(fl->cctx, fl->sctx);
+ return sg_dma_addr + fastrpc_sid_offset(fl->cctx, sess);
}
-static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
- u64 len, u32 attr, struct fastrpc_map **ppmap)
+static int fastrpc_map_attach_to_dev(struct fastrpc_user *fl, int fd,
+ u64 len, u32 attr,
+ struct fastrpc_session_ctx *sess,
+ struct fastrpc_map **ppmap)
{
- struct fastrpc_session_ctx *sess = fl->sctx;
struct fastrpc_map *map = NULL;
+ struct device *dev = sess->dev;
struct sg_table *table;
struct scatterlist *sgl = NULL;
int err = 0, sgl_index = 0;
@@ -909,9 +917,9 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
goto get_err;
}
- map->attach = dma_buf_attach(map->buf, sess->dev);
+ map->attach = dma_buf_attach(map->buf, dev);
if (IS_ERR(map->attach)) {
- dev_err(sess->dev, "Failed to attach dmabuf\n");
+ dev_err(dev, "Failed to attach dmabuf\n");
err = PTR_ERR(map->attach);
goto attach_err;
}
@@ -926,12 +934,13 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
if (attr & FASTRPC_ATTR_SECUREMAP)
map->dma_addr = sg_phys(map->table->sgl);
else
- map->dma_addr = fastrpc_compute_dma_addr(fl, sg_dma_address(map->table->sgl));
+ map->dma_addr = fastrpc_compute_dma_addr(fl, sg_dma_address(map->table->sgl), sess);
for_each_sg(map->table->sgl, sgl, map->table->nents,
sgl_index)
map->size += sg_dma_len(sgl);
+
if (len > map->size) {
- dev_dbg(sess->dev, "Bad size passed len 0x%llx map size 0x%llx\n",
+ dev_dbg(dev, "Bad size passed len 0x%llx map size 0x%llx\n",
len, map->size);
err = -EINVAL;
goto map_err;
@@ -954,7 +963,7 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
map->attr = attr;
err = qcom_scm_assign_mem(map->dma_addr, (u64)map->len, &src_perms, dst_perms, 2);
if (err) {
- dev_err(sess->dev,
+ dev_err(dev,
"Failed to assign memory with dma_addr %pad size 0x%llx err %d\n",
&map->dma_addr, map->len, err);
goto map_err;
@@ -977,13 +986,36 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
return err;
}
+static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
+ u64 len, u32 attr, u32 flags, struct fastrpc_map **ppmap)
+{
+ if (IS_EXTENDED_MAP_FLAG(flags)) {
+ int i, err = -ENODEV;
+
+ if (!fl->cctx->ext_cb_count) {
+ dev_err(fl->sctx->dev, "no extended context bank found\n");
+ return -ENODEV;
+ }
+
+ for (i = 0; i < fl->cctx->ext_cb_count; i++) {
+ err = fastrpc_map_attach_to_dev(fl, fd, len, attr,
+ fl->cctx->ext_cb[i], ppmap);
+ if (err != -ENOMEM)
+ break;
+ }
+ return err;
+ }
+
+ return fastrpc_map_attach_to_dev(fl, fd, len, attr, fl->sctx, ppmap);
+}
+
static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
- u64 len, u32 attr, struct fastrpc_map **ppmap)
+ u64 len, u32 attr, u32 flags, struct fastrpc_map **ppmap)
{
if (!fastrpc_map_lookup(fl, fd, ppmap, true))
return 0;
- return fastrpc_map_attach(fl, fd, len, attr, ppmap);
+ return fastrpc_map_attach(fl, fd, len, attr, flags, ppmap);
}
/*
@@ -1061,10 +1093,10 @@ static int fastrpc_create_maps(struct fastrpc_invoke_ctx *ctx)
if (i < ctx->nbufs)
err = fastrpc_map_create(ctx->fl, ctx->args[i].fd,
- ctx->args[i].length, ctx->args[i].attr, &ctx->maps[i]);
+ ctx->args[i].length, ctx->args[i].attr, 0, &ctx->maps[i]);
else
err = fastrpc_map_attach(ctx->fl, ctx->args[i].fd,
- ctx->args[i].length, ctx->args[i].attr, &ctx->maps[i]);
+ ctx->args[i].length, ctx->args[i].attr, 0, &ctx->maps[i]);
if (err) {
dev_err(dev, "Error Creating map %d\n", err);
return -EINVAL;
@@ -1628,7 +1660,7 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
fl->pd = USER_PD;
if (init.filelen && init.filefd) {
- err = fastrpc_map_create(fl, init.filefd, init.filelen, 0, &map);
+ err = fastrpc_map_create(fl, init.filefd, init.filelen, 0, 0, &map);
if (err)
goto err;
}
@@ -2251,7 +2283,7 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
return -EFAULT;
/* create SMMU mapping */
- err = fastrpc_map_create(fl, req.fd, req.length, 0, &map);
+ err = fastrpc_map_create(fl, req.fd, req.length, 0, req.flags, &map);
if (err) {
dev_err(dev, "failed to map buffer, fd = %d\n", req.fd);
return err;
diff --git a/include/uapi/misc/fastrpc.h b/include/uapi/misc/fastrpc.h
index ba1ea5ed426c..b39c0e197a45 100644
--- a/include/uapi/misc/fastrpc.h
+++ b/include/uapi/misc/fastrpc.h
@@ -36,6 +36,11 @@
* cache maintenance for the buffer.
* @FASTRPC_MAP_FD_NOMAP: This flag is used to skip CPU mapping,
* otherwise behaves similar to FASTRPC_MAP_FD_DELAYED flag.
+ * @FASTRPC_MAP_FD_EXTENDED: Map buffer in extended SMMU IOVA space (16GB - 1TB)
+ * and DSP VA space (4GB - 512GB). Can be accessed only through uDMA.
+ * @FASTRPC_MAP_FD_DELAYED_EXTENDED: Map buffer in extended SMMU IOVA space
+ * (16GB - 1TB) but skip DSP mapping. DSP mapping will be done later by
+ * the user. Can be accessed only through uDMA.
* @FASTRPC_MAP_MAX: max count for flags
*
*/
@@ -45,6 +50,8 @@ enum fastrpc_map_flags {
FASTRPC_MAP_FD = 2,
FASTRPC_MAP_FD_DELAYED,
FASTRPC_MAP_FD_NOMAP = 16,
+ FASTRPC_MAP_FD_EXTENDED,
+ FASTRPC_MAP_FD_DELAYED_EXTENDED,
FASTRPC_MAP_MAX,
};
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-26 13:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-26 13:45 [PATCH 0/6] misc: fastrpc: Add extended IOVA mapping support Vinayak Katoch
2026-08-26 13:45 ` [PATCH 1/6] dt-bindings: misc: fastrpc: Add memory-region property for context bank Vinayak Katoch
2026-08-26 13:45 ` [PATCH 2/6] misc: fastrpc: Handle multi-cell reg in context bank probe Vinayak Katoch
2026-08-26 13:45 ` [PATCH 3/6] arm64: dts: qcom: kaanapali: Add CDSP FastRPC extended context bank Vinayak Katoch
2026-08-26 13:45 ` [PATCH 4/6] arm64: dts: qcom: glymur: " Vinayak Katoch
2026-08-26 13:45 ` [PATCH 5/6] misc: fastrpc: Add extended context bank support Vinayak Katoch
2026-08-26 13:45 ` [PATCH 6/6] misc: fastrpc: Add UAPI flags for extended IOVA mapping Vinayak Katoch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox