From: Robin Murphy <robin.murphy@arm.com>
To: Baolu Lu <baolu.lu@linux.intel.com>, Jason Gunthorpe <jgg@nvidia.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
Ashok Raj <ashok.raj@intel.com>, Will Deacon <will@kernel.org>,
linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
iommu@lists.linux-foundation.org,
Jacob jun Pan <jacob.jun.pan@intel.com>,
Jean-Philippe Brucker <jean-philippe@linaro.com>
Subject: Re: [PATCH 2/5] iommu: Add blocking_domain_ops field in iommu_ops
Date: Tue, 17 May 2022 13:43:03 +0100 [thread overview]
Message-ID: <f971aea9-8ae1-95f8-b10a-cd77e9704dc0@arm.com> (raw)
In-Reply-To: <c8492b29-bc27-ae12-d5c4-9fbbc797e310@linux.intel.com>
On 2022-05-17 03:37, Baolu Lu wrote:
> Hi Jason,
>
> On 2022/5/16 21:57, Jason Gunthorpe wrote:
>> On Mon, May 16, 2022 at 12:22:08PM +0100, Robin Murphy wrote:
>>> On 2022-05-16 02:57, Lu Baolu wrote:
>>>> Each IOMMU driver must provide a blocking domain ops. If the hardware
>>>> supports detaching domain from device, setting blocking domain equals
>>>> detaching the existing domain from the deivce. Otherwise, an UNMANAGED
>>>> domain without any mapping will be used instead.
>>> Unfortunately that's backwards - most of the implementations of
>>> .detach_dev
>>> are disabling translation entirely, meaning the device ends up
>>> effectively
>>> in passthrough rather than blocked.
>> Ideally we'd convert the detach_dev of every driver into either
>> a blocking or identity domain. The trick is knowing which is which..
>
> I am still a bit puzzled about how the blocking_domain should be used
> when it is extended to support ->set_dev_pasid.
>
> If it's a blocking domain, the IOMMU driver knows that setting the
> blocking domain to device pasid means detaching the existing one.
>
> But if it's an identity domain, how could the IOMMU driver choose
> between:
>
> - setting the input domain to the pasid on device; or,
> - detaching the existing domain.
>
> I've ever thought about below solutions:
>
> - Checking the domain types and dispatching them to different
> operations.
> - Using different blocking domains for different types of domains.
>
> But both look rough.
>
>>
>> Guessing going down the list:
>> apple dart - blocking, detach_dev calls apple_dart_hw_disable_dma()
>> same as
>> IOMMU_DOMAIN_BLOCKED
>> [I wonder if this drive ris wrong in other ways though because
>> I dont see a remove_streams in attach_dev]
>> exynos - this seems to disable the 'sysmmu' so I'm guessing this is
>> identity
>> iommu-vmsa - Comment says 'disable mmu translaction' so I'm guessing
>> this is idenity
>> mkt_v1 - Code looks similar to mkt, which is probably identity.
>> rkt - No idea
>> sprd - No idea
>> sun50i - This driver confusingly treats identity the same as
>> unmanaged, seems wrong, no idea.
>> amd - Not sure, clear_dte_entry() seems to set translation on but
>> points
>> the PTE to 0 ? Based on the spec table 8 I would have expected
>> TV to be clear which would be blocking. Maybe a bug??
>> arm smmu qcomm - not sure
>> intel - blocking
>>
>> These doesn't support default domains, so detach_dev should return
>> back to DMA API ownership, which is either identity or something weird:
>> fsl_pamu - identity due to the PPC use of dma direct
>> msm
>> mkt
>> omap
>> s390 - platform DMA ops
>> terga-gart - Usually something called a GART would be 0 length once
>> disabled, guessing blocking?
>> tegra-smmu
>>
>> So, the approach here should be to go driver by driver and convert
>> detach_dev to either identity, blocking or just delete it entirely,
>> excluding the above 7 that don't support default domains. And get acks
>> from the driver owners.
>>
>
> Agreed. There seems to be a long way to go. I am wondering if we could
> decouple this refactoring from my new SVA API work? We can easily switch
> .detach_dev_pasid to using blocking domain later.
FWIW from my point of view I'm happy with having a .detach_dev_pasid op
meaning implicitly-blocked access for now. On SMMUv3, PASIDs don't mix
with our current notion of IOMMU_DOMAIN_IDENTITY (nor the potential one
for IOMMU_DOMAIN_BLOCKED), so giving PASIDs functional symmetry with
devices would need significantly more work anyway.
Thanks,
Robin.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-05-17 12:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 1:57 [PATCH 0/5] iommu: Make blocking domain static for group Lu Baolu
2022-05-16 1:57 ` [PATCH 1/5] iommu: Rename attach_dev to set_dev in domain ops Lu Baolu
2022-05-16 1:57 ` [PATCH 2/5] iommu: Add blocking_domain_ops field in iommu_ops Lu Baolu
2022-05-16 7:27 ` Christoph Hellwig
2022-05-16 13:05 ` Jason Gunthorpe via iommu
2022-05-16 11:22 ` Robin Murphy
2022-05-16 13:43 ` Baolu Lu
2022-05-16 13:57 ` Jason Gunthorpe via iommu
2022-05-17 2:37 ` Baolu Lu
2022-05-17 12:43 ` Robin Murphy [this message]
2022-05-17 13:13 ` Jason Gunthorpe via iommu
2022-05-18 6:43 ` Baolu Lu
2022-05-17 13:08 ` Jason Gunthorpe via iommu
2022-05-20 8:45 ` Joerg Roedel
2022-05-20 11:03 ` Baolu Lu
2022-05-16 1:57 ` [PATCH 3/5] iommu: Make blocking domain static for iommu group Lu Baolu
2022-05-16 1:57 ` [PATCH 4/5] iommu: Use blocking domain for empty domain attaching Lu Baolu
2022-05-16 1:57 ` [PATCH 5/5] iommu: Remove .detach_dev from iommu domain ops Lu Baolu
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=f971aea9-8ae1-95f8-b10a-cd77e9704dc0@arm.com \
--to=robin.murphy@arm.com \
--cc=ashok.raj@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@intel.com \
--cc=jean-philippe@linaro.com \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).