mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
To: Jason Gunthorpe <jgg@ziepe.ca>,
	Vikash Garodia <vikash.garodia@oss.qualcomm.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
	joro@8bytes.org, will@kernel.org, m.szyprowski@samsung.com,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	dikshita.agarwal@oss.qualcomm.com
Subject: Re: [PATCH] dma-iommu: Introduce API to reserve IOVA regions for dynamically created devices
Date: Mon, 15 Jun 2026 23:21:45 +0530	[thread overview]
Message-ID: <dcc0d02e-91fb-ddbe-399a-0191bab94c4f@oss.qualcomm.com> (raw)
In-Reply-To: <20260615125257.GS1066031@ziepe.ca>


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@oss.qualcomm.com/
> 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

  reply	other threads:[~2026-06-15 17:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-19  5:49 Vishnu Reddy
2026-01-19  8:00 ` Christoph Hellwig
2026-01-19 14:13 ` Robin Murphy
2026-06-10 14:27   ` Vishnu Reddy
2026-06-12 17:26     ` Jason Gunthorpe
2026-06-15  6:56       ` Vikash Garodia
2026-06-15 12:52         ` Jason Gunthorpe
2026-06-15 17:51           ` Vishnu Reddy [this message]
2026-06-17 19:40             ` Jason Gunthorpe
2026-06-18 11:57               ` Krzysztof Kozlowski
2026-06-18 15:17                 ` Jason Gunthorpe
2026-06-24 10:16                   ` Krzysztof Kozlowski
2026-07-17 10:44                   ` Konrad Dybcio
2026-07-17 12:21                     ` Robin Murphy
2026-07-17 16:07                     ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dcc0d02e-91fb-ddbe-399a-0191bab94c4f@oss.qualcomm.com \
    --to=busanna.reddy@oss.qualcomm.com \
    --cc=dikshita.agarwal@oss.qualcomm.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.com \
    --cc=vikash.garodia@oss.qualcomm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®