mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Charan Teja Kalla <charan.kalla@oss.qualcomm.com>
To: Robin Murphy <robin.murphy@arm.com>,
	will@kernel.org, joro@8bytes.org, robh@kernel.org,
	dmitry.baryshkov@oss.qualcomm.com,
	konrad.dybcio@oss.qualcomm.com, bjorn.andersson@oss.qualcomm.com,
	bod@kernel.org, conor+dt@kernel.org, krzk+dt@kernel.org,
	saravanak@google.com, prakash.gupta@oss.qualcomm.com,
	vikash.garodia@oss.qualcomm.com
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH 0/6] of: iommu-map parsing for multi-cell IOMMU
Date: Tue, 11 Nov 2025 23:57:44 +0530	[thread overview]
Message-ID: <351373ed-c699-4945-a978-cb35412918bc@oss.qualcomm.com> (raw)
In-Reply-To: <0319bdf5-0a46-40fc-93f8-30d74cf6475a@arm.com>



On 11/5/2025 10:58 PM, Robin Murphy wrote:
>> The other motivation for this patchset is the below usecase.
>> USECASE [1]:
>> ------------
>> Video IP, 32bit, have 2 hardware sub blocks(or can be called as
>> functions) called as pixel and nonpixel blocks, that does decode and
>> encode of the video stream. These logical blocks are configured to
>> generate different stream IDs.
>>
>> With the classical approach of representing all sids with iommus= end up
>> in using a single translation context limited to the 4GB. There are
>> video usecases which needs larger IOVA space, like higher concurrent
>> video sessions(eg: 32 session and 192MB per session) where 4GB of IOVA
>> is not sufficient.
>>
>> For this case, each functionality is represented in the firmware(device
>> tree) by the 'rid' field of the iommu-map property and the video driver
>> creates sub platform devices for each of this functionality and call
>> into IOMMU configuration. Each rid(function id) in the dt property
>> indicates the bit that can be associated by the driver passed input id.
>>
>> Example:
>> iommu {
>>     #iommu-cells = 2;
>> };
>>
>> video-codec@foobar {
>>     compatible = "qcom,video";
>>     iommus = <&apps_smmu 0x1234 0xca>;
>>     iommu-map= <0x1 &iommu 0x1940 0x0 0x1>,
>>                 <0x1 &iommu 0x1941 0x0 0x1>,
>>                 <0x2 &iommu 0x1942 0x0 0x1>,
>>                 <0x4 &iommu 0x1943 0x0 0x1>,
>>                 <0x4 &iommu 0x1944 0x0 0x1>;
>> };
>>
>> video-driver:
>> #define PIXEL_FUNC       (1)
>> #define NON_PIXEL_FUNC       (2)
>> #define SECURE_FUNC       (4)
>>
>> case1: All these functionalities requires individual contexts.
>> Create 3 subdevices for each of this function and call
>> of_dma_configure_id(..,id), id = 0x1, 0x2, 0x4.
>>
>> Case2: Secure and non-secure functionalities require individual
>> contexts. Create 2 subdevices and call of_dma_configure_id(..,id), id =
>> 0x3(bitmap of pixel and non-pixel), 0x4 (secure).
>>
>> Credits: to Dmitry for thorough discussions on the RFC patch and major
>> help in getting the consenus on this approach, to Konrad & Bjorn for
>> offline discussions and reviews, to Robin for his inputs on IOMMU front,
>> to Bod, Rob and Krzysztof for all valuable inputs.
>>
>> [1] https://lore.kernel.org/all/20250627-video_cb-
>> v3-0-51e18c0ffbce@quicinc.com/
>> [2] https://lore.kernel.org/all/20250928171718.436440-1-
>> charan.kalla@oss.qualcomm.com/#r
>>
>> Charan Teja Kalla (6):
>>    of: create a wrapper for of_map_id()
>>    of: introduce wrapper function to query the cell count
>>    of: parse #<name>-cells property to get the cell count
>>    of: detect and handle legacy iommu-map parsing
>>    of: add infra to parse iommu-map per IOMMU cell count
>>    of: use correct iommu-map parsing logic from of_iommu layer
>>
>>   drivers/iommu/of_iommu.c |  59 +++++++--
>>   drivers/of/base.c        | 269 +++++++++++++++++++++++++++++++++++----
>>   include/linux/of.h       |  19 +++
>>   3 files changed, 314 insertions(+), 33 deletions(-)
> 
> Hmm, I did actually have a quick go at this the other week too, and
> while I though it was a bit clunky, it was still significantly simpler
> than this seems to be...
> 
> FWIW: https://gitlab.arm.com/linux-arm/linux-rm/-/commits/iommu-map - I

Thanks a lot Robin for taking a look and sorry for the delayed reply as
I was on vacation.

stripped code_snippet from your patch:
	offset = 0;
	out_base = map + offset + 2;
	id_off = masked_id - id_base;
	if (masked_id < id_base || id_off >= id_len)
		continue;
	for (int i = 0; id_out && i < cells; i++)
		id_out[i] = id_off + be32_to_cpu(out_base[i]);


seems way cleaner than mine...

Actually, we also have a case of a device emitting 2 distinct
identifiers, eg: a device is emitting 0x1940, 0x1944 and 0x1A20 sids and
attached to a single context bank. If I use mask to cover all these sids
in a single iommu-map entry, it does overlap with other device SID.

I don't think that patch you shared can be used to cover the above, or
it is?

Hence I resorted to the approach where RID used as the bitmap of indices
to cover such cases for platform devices, which it seems you clearly
didn't like....otherwise, any otherway we can handle such cases?


> can give it some polish and testing to post properly if you like.
Sure, I am fine with it ...
or If you are busy please let me know so that i can take it forward as
_you are the only author of the patch._
[1]
https://gitlab.arm.com/linux-arm/linux-rm/-/commit/3e1bd87ce1a7b6f567ab17a0931e4294d8982ed2






  reply	other threads:[~2025-11-11 18:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04  8:50 Charan Teja Kalla
2025-11-04  8:51 ` [PATCH 1/6] of: create a wrapper for of_map_id() Charan Teja Kalla
2025-11-04  8:51 ` [PATCH 2/6] of: introduce wrapper function to query the cell count Charan Teja Kalla
2025-11-05 17:35   ` Robin Murphy
2025-11-04  8:51 ` [PATCH 3/6] of: parse #<name>-cells property to get " Charan Teja Kalla
2025-11-04  8:51 ` [PATCH 4/6] of: detect and handle legacy iommu-map parsing Charan Teja Kalla
2025-11-04  8:51 ` [PATCH 5/6] of: add infra to parse iommu-map per IOMMU cell count Charan Teja Kalla
2025-11-04 10:46   ` kernel test robot
2025-11-04 10:57     ` Charan Teja Kalla
2025-11-04 13:02   ` kernel test robot
2025-11-06 15:03   ` Dan Carpenter
2025-11-04  8:51 ` [PATCH 6/6] of: use correct iommu-map parsing logic from of_iommu layer Charan Teja Kalla
2025-11-05 18:20   ` Robin Murphy
2025-11-05 17:28 ` [PATCH 0/6] of: iommu-map parsing for multi-cell IOMMU Robin Murphy
2025-11-11 18:27   ` Charan Teja Kalla [this message]
2025-11-12 14:42     ` Charan Teja Kalla
2025-11-21  5:54       ` Charan Teja Kalla
2025-11-24 16:42         ` Robin Murphy
2025-11-24 16:51       ` Robin Murphy
2025-11-26 17:30         ` Charan Teja Kalla
2025-11-07  8:07 ` Krzysztof Kozlowski
2025-11-11 18:45   ` Charan Teja Kalla
2025-11-11 20:39     ` Rob Herring

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=351373ed-c699-4945-a978-cb35412918bc@oss.qualcomm.com \
    --to=charan.kalla@oss.qualcomm.com \
    --cc=bjorn.andersson@oss.qualcomm.com \
    --cc=bod@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prakash.gupta@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=saravanak@google.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®