public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: "iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	Joerg Roedel <joro@8bytes.org>,
	"llvm@lists.linux.dev" <llvm@lists.linux.dev>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Miguel Ojeda <ojeda@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>, "Rix, Tom" <trix@redhat.com>,
	Will Deacon <will@kernel.org>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Nicolin Chen <nicolinc@nvidia.com>
Subject: Re: [PATCH v4 06/17] iommu: Replace __iommu_group_dma_first_attach() with set_domain
Date: Thu, 20 Apr 2023 09:59:03 -0300	[thread overview]
Message-ID: <ZEE3F3aAIKrHjhji@nvidia.com> (raw)
In-Reply-To: <BL1PR11MB5271C0E78AF1343E1D6ACA958C639@BL1PR11MB5271.namprd11.prod.outlook.com>

On Thu, Apr 20, 2023 at 07:25:59AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > Sent: Wednesday, April 12, 2023 9:52 PM
> > 
> > @@ -2218,6 +2202,12 @@ static int __iommu_device_set_domain(struct
> > iommu_group *group,
> >  {
> >  	int ret;
> > 
> > +	if (dev->iommu->attach_deferred) {
> > +		if (new_domain == group->default_domain)
> > +			return 0;
> > +		dev->iommu->attach_deferred = 0;
> > +	}
> > +
> 
> This leads to a small semantics change, though I'm not sure whether it's
> important to sustain.
> 
> Before this patch the 1st attach is ignored. Deferred attach is conducted
> when the first DMA map request comes by calling iommu_deferred_attach().
> 
> But if the driver tries to do iommu_attach_group() or iommu_attach_device()
> in between it will succeed. No deferred_attach check in that path.
> 
> Now with this patch the behavior is changed. If the driver tries to attach the
> device to default domain in between it's ignored. Otherwise it will succeed.

Sort of..

If a driver is using the attach APIs then the first successfull attach
to a non-default domain will clear the flag, then any following attach
even back to the default domain will succeed.

The tiny difference is if a driver tries to attach to the already
attached domain the NOP now extends to keeping the defered attach too.

I don't think any drivers do something like this so it seems OK.

v3 didn't have this as the flag kept the different call paths
seperate.

Jason

  reply	other threads:[~2023-04-20 15:00 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 13:51 [PATCH v4 00/17] Consolidate the error handling around device attachment Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 01/17] iommu: Replace iommu_group_device_count() with list_count_nodes() Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 02/17] iommu: Add for_each_group_device() Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 03/17] iommu: Make __iommu_group_set_domain() handle error unwind Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 04/17] iommu: Use __iommu_group_set_domain() for __iommu_attach_group() Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 05/17] iommu: Use __iommu_group_set_domain() in iommu_change_dev_def_domain() Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 06/17] iommu: Replace __iommu_group_dma_first_attach() with set_domain Jason Gunthorpe
2023-04-13  2:35   ` Baolu Lu
2023-04-20  7:25   ` Tian, Kevin
2023-04-20 12:59     ` Jason Gunthorpe [this message]
2023-04-12 13:51 ` [PATCH v4 07/17] iommu: Remove iommu_group_do_dma_first_attach() from iommu_group_add_device() Jason Gunthorpe
2023-04-20  7:26   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 08/17] iommu: Replace iommu_group_do_dma_first_attach with __iommu_device_set_domain Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 09/17] iommu: Fix iommu_probe_device() to attach the right domain Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 10/17] iommu: Do iommu_group_create_direct_mappings() before attach Jason Gunthorpe
2023-04-20  7:29   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 11/17] iommu: Remove the assignment of group->domain during default domain alloc Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 12/17] iommu: Consolidate the code to calculate the target default domain type Jason Gunthorpe
2023-04-20  7:30   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 13/17] iommu: Revise iommu_group_alloc_default_domain() Jason Gunthorpe
2023-04-13  2:47   ` Baolu Lu
2023-04-20  7:54   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 14/17] iommu: Consolidate the default_domain setup to one function Jason Gunthorpe
2023-04-20  7:57   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 15/17] iommu: Allow IOMMU_RESV_DIRECT to work on ARM Jason Gunthorpe
2023-04-20  8:00   ` Tian, Kevin
2023-04-26 13:36     ` Jason Gunthorpe
2023-04-26 23:48       ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 16/17] iommu: Remove __iommu_group_for_each_dev() Jason Gunthorpe
2023-04-20  8:06   ` Tian, Kevin
2023-04-20 13:01     ` Jason Gunthorpe
2023-04-21  3:05       ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 17/17] iommu: Tidy the control flow in iommu_group_store_type() Jason Gunthorpe
2023-04-20  8:07   ` Tian, Kevin
2023-05-01 22:01 ` [PATCH v4 00/17] Consolidate the error handling around device attachment Heiko Stübner

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=ZEE3F3aAIKrHjhji@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolinc@nvidia.com \
    --cc=ojeda@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=trix@redhat.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