Re: [PATCH] dma-iommu: Introduce API to reserve IOVA regions for dynamically created devices

From: Vishnu Reddy

Date: Mon Jun 15 2026 - 13:57:40 EST



On 6/15/2026 6:22 PM, Jason Gunthorpe wrote:
> On Mon, Jun 15, 2026 at 12:26:25PM +0530, Vikash Garodia wrote:
>
>> To handle such case, we create the device dynamically and associated the
>> distinct IOVA range to them,via the api introduced in this patch.
>> This was prototyped in recent SOC here [1]
>>
>> [1] https://lore.kernel.org/linux-media/20260313-kaanapali-iris-v3-1-9c0d1a67af4b@xxxxxxxxxxxxxxxx/
> Well, I'm not enthused by this:
>
> +static int iris_vpu_bus_dma_configure(struct device *dev)
> +{
> + struct iris_context_bank *cb = dev_get_drvdata(dev);
> +
> + if (!cb)
> + return -ENODEV;
> +
> + return of_dma_configure_id(dev, dev->parent->of_node, true, &cb->f_id);
> +}
>
> A custom bus and then calling configure_id on the parent which would
> have already called of_dma_configure on that same of_node seems very
> hacky to me.

Hi Jason,

Here, the parent node does not have an iommus property — it only has iommu-map,
like example below:

iommu-map = <0x0 &apps_smmu 0x1940 0x0 0x1>,  /* function_id 0 → SID 0x1940 */
            <0x1 &apps_smmu 0x1943 0x0 0x1>,  /* function_id 1 → SID 0x1943 */
            <0x2 &apps_smmu 0x1944 0x0 0x1>;  /* function_id 2 → SID 0x1944 */

When the parent device is probed, of_dma_configure() is called, which
internally invokes of_dma_configure_id() with NULL as the function ID. Since
there is no iommus entry, no stream ID gets mapped to the parent device.

The child devices are created at runtime and have no of_node of their own. The
only place the iommu-map property exists is on the parent's of_node. So when
configuring a child device, we pass the parent's of_node along with the child's
specific function_id — this is how of_dma_configure_id() finds and maps the
correct stream ID to the child device only.

So to be clear — the parent of_node is not being configured again. It is just
being used as a lookup source for the iommu-map property, since the child has
no of_node of its own.

Thanks,
Vishnu Reddy.

> Jason