All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: <kevin.tian@intel.com>, <yi.l.liu@intel.com>,
	<iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/3] iommufd: Add devices_users to track the hw_pagetable usage by device
Date: Wed, 1 Feb 2023 23:28:05 -0800	[thread overview]
Message-ID: <Y9tmBW/wnZJ0JyBk@Asurada-Nvidia> (raw)
In-Reply-To: <Y9rW01eROepZuMt3@Asurada-Nvidia>

On Wed, Feb 01, 2023 at 01:18:08PM -0800, Nicolin Chen wrote:
> On Wed, Feb 01, 2023 at 04:00:40PM -0400, Jason Gunthorpe wrote:
> > On Wed, Feb 01, 2023 at 11:25:10AM -0800, Nicolin Chen wrote:
> > 
> > > The "finalise" is one of the very first lines of the attach_dev()
> > > callback function in SMMU driver, though it might still undesirably
> > > fail the replace().
> > 
> > It won't get that far.
> > 
> > Remember how this all works - only autodomains have the special path
> > that allocates a domain, attaches the empty domain, and then populates
> > it with the ioas. We made this special path specifically to accomodate
> > the current ARM drivers, otherwise they wouldn't work at all.
> 
> Yes.
> 
> > replace can't do this - replace must always start out with a
> > pre-existing hwpt that was allocated with a dedicated hwpt allocation
> > ioctl.
> > 
> > Wwhen the hwpt was allocated it must be linked to the IOAS at that
> > time, because we definately don't do defered IOAS linkage.
> >
> > So on ARM when you create an unfinalizes iommu_domain it cannot be
> > added to the IOAS (because it has an empty aperture) and creation will
> > fail, or worse, it will get added to an empty IOAS and make the IOAS
> > permanently unusable.
> 
> IIUIC, user space might add some IOVA mappings to the hwpt/iopt,
> before doing a replace(). If we do a deferred IOAS linkage to
> this hwpt/iopt, it will cause a problem because we are adding
> the reserved region for the MSI window later than IOMMU_IOAS_MAP
> calls. Thus, "we definately don't do defered IOAS linkage".
> 
> With this justification, I think I should include my patch of
> moving iopt_table_add/remove_domain(), in the replace series.

I just posted the replace series. But I found that the base
line (without the nesting series) allocates iommu_domains
always with the ->domain_alloc() op. So, we cannot actually
move the iopt_table_add_domain() in the replace series, as I
intended to.

Yet, a great news is that our nesting series replaces the
domain_alloc() op entirely with ->domain_alloc_user() for all
the iommu_domain allocations, including for auto_domains. So,
we can completely move iopt_table_add_domain() to the hwpt
allocation function. And we don't really need a big change
in the SMMU driver nor Robin's patch that passes in dev ptr
to domain_alloc() op. And even this device_users refcount in
this patch is no longer needed. It also simplifies the shared
device locking situation, if I am not missing anything.

So, in short, we'll have to wait for ->domain_alloc_user()
patch (in the nesting series) to unblock the problem that we
discussed above regarding the iopt_table_add_domain().

Thanks
Nic

  reply	other threads:[~2023-02-02  7:28 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-28 21:18 [PATCH v2 0/3] iommufd: Remove iommufd_hw_pagetable_has_group Nicolin Chen
2023-01-28 21:18 ` [PATCH v2 1/3] iommufd: Add devices_users to track the hw_pagetable usage by device Nicolin Chen
2023-01-29  9:23   ` Tian, Kevin
2023-01-29  9:30     ` Nicolin Chen
2023-01-29  9:39       ` Tian, Kevin
2023-01-30  2:22     ` Liu, Yi L
2023-01-30 15:02   ` Jason Gunthorpe
2023-01-30 19:27     ` Nicolin Chen
2023-01-30 19:50       ` Jason Gunthorpe
2023-01-30 20:04         ` Nicolin Chen
2023-01-30 20:35           ` Jason Gunthorpe
2023-01-30 20:53             ` Nicolin Chen
2023-02-01  7:48               ` Nicolin Chen
2023-02-02  9:12                 ` Nicolin Chen
2023-02-07  4:19                   ` Liu, Yi L
2023-02-01  6:57             ` Nicolin Chen
2023-02-01  7:56               ` Nicolin Chen
2023-02-01 15:53               ` Jason Gunthorpe
2023-02-01 17:46                 ` Nicolin Chen
2023-02-01 18:37                   ` Jason Gunthorpe
2023-02-01 19:25                     ` Nicolin Chen
2023-02-01 20:00                       ` Jason Gunthorpe
2023-02-01 21:18                         ` Nicolin Chen
2023-02-02  7:28                           ` Nicolin Chen [this message]
2023-02-02 15:03                             ` Jason Gunthorpe
2023-02-07  4:27                       ` Liu, Yi L
2023-01-28 21:18 ` [PATCH v2 2/3] iommufd/device: Make hwpt_list list_add/del symmetric Nicolin Chen
2023-01-29  9:24   ` Tian, Kevin
2023-01-29  9:31     ` Nicolin Chen
2023-01-30 14:59   ` Jason Gunthorpe
2023-01-30 19:03     ` Nicolin Chen
2023-01-30 19:07       ` Jason Gunthorpe
2023-01-30 19:38         ` Nicolin Chen
2023-01-28 21:18 ` [PATCH v2 3/3] iommufd/device: Change iommufd_hw_pagetable_has_group to device centric Nicolin Chen
2023-01-29  9:37   ` Tian, Kevin
2023-01-29 10:38     ` Nicolin Chen
2023-01-30  0:44       ` Tian, Kevin
2023-01-30 10:22       ` Nicolin Chen
2023-02-01  3:07         ` Tian, Kevin
2023-02-01  6:49           ` Baolu Lu
2023-02-01  6:59             ` Tian, Kevin
2023-02-01  7:20               ` Nicolin Chen
2023-02-02  6:32                 ` Tian, Kevin
2023-02-02  6:36                   ` Nicolin Chen

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=Y9tmBW/wnZJ0JyBk@Asurada-Nvidia \
    --to=nicolinc@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yi.l.liu@intel.com \
    /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.