All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
	llvm@lists.linux.dev, Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Miguel Ojeda <ojeda@kernel.org>, Tom Rix <trix@redhat.com>,
	Will Deacon <will@kernel.org>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Kevin Tian <kevin.tian@intel.com>,
	Nicolin Chen <nicolinc@nvidia.com>
Subject: Re: [PATCH v3 07/17] iommu: Make iommu_group_do_dma_first_attach() simpler
Date: Thu, 6 Apr 2023 13:09:26 -0300	[thread overview]
Message-ID: <ZC7utpUloineTYaV@nvidia.com> (raw)
In-Reply-To: <51111b86-97af-b3d2-d3e8-5cebc350f37f@arm.com>

On Thu, Apr 06, 2023 at 04:44:57PM +0100, Robin Murphy wrote:
> On 06/04/2023 12:38 am, Jason Gunthorpe wrote:
> > It should always attach to the current group->domain, so don't take in a
> > domain parameter. Use the __iommu_device_set_domain() common code to
> > handle the attach.
> 
> Hmm, why do we still end up with this in two places, and potentially called
> twice in the same path?
> 
> iommu_probe_device()
>   __iommu_probe_device()
>     iommu_group_get_for_dev()
>       iommu_group_add_device()
>         iommu_group_do_dma_first_attach()
>   iommu_create_device_direct_mappings()
>   iommu_group_do_dma_first_attach()
> 
> Seems off to me... at best it's confusing, but at worst it's plain wrong
> (it's the one in iommu_group_add_device() that I'm most suspicious of)

Lu and Kevin pointed to this as well, it started out that way.

I made a whole other series tidying the probe related flows just based
on this observation.. 

I can pull one patch into here since this seems to catch everyone.

AFIACT it is harmless at this point since we can safely call
first_attach twice?

> Not to mention the slightly different open-coded variant we still seem to
> have in iommu_setup_default_domain() via the "else if
> (!group->default_domain)" path :/

Yes.. Humm. More parts could be moved into a function but I think it
would obfuscates what iommu_setup_default_domain() does.

Oh, I see another mistake:

	if (group->domain) {
		iommu_create_device_direct_mappings(group->domain, dev);
                                                  ^^^^^^^^^^^^^^^

iommu_create_device_direct_mappings should only be called on the
default domain.

> (BTW if any comments seem misplaced, it's because I'm really looking at the
> end result at the cover-letter commit in your branch, rather than trying to
> review each patch independently)

That is probably best. The patches are OK but it is hard to see the
final arrangment

Thanks,
Jason

  reply	other threads:[~2023-04-06 16:09 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-05 23:38 [PATCH v3 00/17] Consolidate the error handling around device attachment Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 01/17] iommu: Replace iommu_group_device_count() with list_count_nodes() Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 02/17] iommu: Add for_each_group_device() Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 03/17] iommu: Make __iommu_group_set_domain() handle error unwind Jason Gunthorpe
2023-04-06 18:08   ` Robin Murphy
2023-04-06 19:09     ` Jason Gunthorpe
2023-04-13 16:47       ` Robin Murphy
2023-04-13 18:39         ` Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 04/17] iommu: Use __iommu_group_set_domain() for __iommu_attach_group() Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 05/17] iommu: Use __iommu_group_set_domain() in iommu_change_dev_def_domain() Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 06/17] iommu: Replace __iommu_group_dma_first_attach() with set_domain Jason Gunthorpe
2023-04-06 15:58   ` Robin Murphy
2023-04-06 19:17     ` Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 07/17] iommu: Make iommu_group_do_dma_first_attach() simpler Jason Gunthorpe
2023-04-06  3:28   ` Baolu Lu
2023-04-06 15:44   ` Robin Murphy
2023-04-06 16:09     ` Jason Gunthorpe [this message]
2023-04-06 19:05       ` Robin Murphy
2023-04-05 23:38 ` [PATCH v3 08/17] iommu: Make iommu_group_do_dma_first_attach() work with owned groups Jason Gunthorpe
2023-04-06 16:37   ` Robin Murphy
2023-04-06 19:34     ` Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 09/17] iommu: Fix iommu_probe_device() to attach the right domain Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 10/17] iommu: Do iommu_group_create_direct_mappings() before attach Jason Gunthorpe
2023-04-06  3:14   ` Baolu Lu
2023-04-05 23:38 ` [PATCH v3 11/17] iommu: Remove the assignment of group->domain during default domain alloc Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 12/17] iommu: Consolidate the code to calculate the target default domain type Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 13/17] iommu: Revise iommu_group_alloc_default_domain() Jason Gunthorpe
2023-04-06  3:40   ` Baolu Lu
2023-04-06 11:34     ` Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 14/17] iommu: Consolidate the default_domain setup to one function Jason Gunthorpe
2023-04-06  4:43   ` Baolu Lu
2023-04-05 23:38 ` [PATCH v3 15/17] iommu: Allow IOMMU_RESV_DIRECT to work on ARM Jason Gunthorpe
2023-04-06  3:53   ` Baolu Lu
2023-04-05 23:38 ` [PATCH v3 16/17] iommu: Remove __iommu_group_for_each_dev() Jason Gunthorpe
2023-04-05 23:38 ` [PATCH v3 17/17] iommu: Tidy the control flow in iommu_group_store_type() Jason Gunthorpe
2023-04-07 11:02 ` [PATCH v3 00/17] Consolidate the error handling around device attachment Naresh Kamboju

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=ZC7utpUloineTYaV@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.