From: Jason Gunthorpe <jgg@nvidia.com>
To: Yi Liu <yi.l.liu@intel.com>
Cc: Baolu Lu <baolu.lu@linux.intel.com>,
joro@8bytes.org, kevin.tian@intel.com,
alex.williamson@redhat.com, robin.murphy@arm.com,
eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org,
chao.p.peng@linux.intel.com, iommu@lists.linux.dev,
zhenzhong.duan@intel.com, jacob.jun.pan@intel.com
Subject: Re: [PATCH v2 2/2] iommu: Pass domain to remove_dev_pasid() op
Date: Fri, 5 Apr 2024 15:17:59 -0300 [thread overview]
Message-ID: <20240405181759.GI5383@nvidia.com> (raw)
In-Reply-To: <735f81a8-a605-41c0-8252-15715e4d8884@intel.com>
On Wed, Apr 03, 2024 at 11:25:35AM +0800, Yi Liu wrote:
> On 2024/4/3 11:04, Baolu Lu wrote:
> > On 3/28/24 8:29 PM, Yi Liu wrote:
> > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> > > index 2e925b5eba53..40dd439307e8 100644
> > > --- a/include/linux/iommu.h
> > > +++ b/include/linux/iommu.h
> > > @@ -578,7 +578,8 @@ struct iommu_ops {
> > > struct iommu_page_response *msg);
> > > int (*def_domain_type)(struct device *dev);
> > > - void (*remove_dev_pasid)(struct device *dev, ioasid_t pasid);
> > > + void (*remove_dev_pasid)(struct device *dev, ioasid_t pasid,
> > > + struct iommu_domain *domain);
> >
> > Previously, this callback said "Hey, remove any domain associated with
> > this pasid".
> >
> > Now this callback changes to "Hey, please remove *this* domain from the
> > pasid". What the driver should do if it doesn't match the previously
> > attached domain, or the pasid hasn't been attached to any domain?
>
> I think the caller of this callback should know very well whether
> a pasid has been attached to this domain or not. So the problem
> you described should not happen at all. Otherwise, it is a bug in
> the iommu layer.
>
> Actually, there is similar concern in the iommu_detach_device_pasid().
> The input domain may be different with what iommu layer tracks. If
> so there is a warn. This means the external callers of this API are
> buggy. While, I have more faith on iommu layer. :)
Yeah, the iommu layer should obtain the domain from the pasid xarray
and every driver today also obtains the domain from the pasid
xarray. It is not something different, it is just moving code around.
The core code should guarentee the invariant.
Jason
next prev parent reply other threads:[~2024-04-05 18:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 12:29 [PATCH v2 0/2] Two enhancements to iommu_at[de]tach_device_pasid() Yi Liu
2024-03-28 12:29 ` [PATCH v2 1/2] iommu: Undo pasid attachment only for the devices that have succeeded Yi Liu
2024-04-03 3:08 ` Baolu Lu
2024-03-28 12:29 ` [PATCH v2 2/2] iommu: Pass domain to remove_dev_pasid() op Yi Liu
2024-03-29 3:32 ` Tian, Kevin
2024-04-03 3:04 ` Baolu Lu
2024-04-03 3:25 ` Yi Liu
2024-04-05 18:17 ` Jason Gunthorpe [this message]
2024-03-29 2:12 ` [PATCH v2 0/2] Two enhancements to iommu_at[de]tach_device_pasid() Duan, Zhenzhong
2024-03-29 3:38 ` Yi Liu
2024-03-29 5:31 ` Duan, Zhenzhong
2024-04-03 2:56 ` Baolu Lu
2024-04-03 4:14 ` Duan, Zhenzhong
2024-04-12 10:13 ` Joerg Roedel
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=20240405181759.GI5383@nvidia.com \
--to=jgg@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=baolu.lu@linux.intel.com \
--cc=chao.p.peng@linux.intel.com \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jacob.jun.pan@intel.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=yi.l.liu@intel.com \
--cc=zhenzhong.duan@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.