[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR11MB52769883FEE25F0BA731220B8CD19@BN9PR11MB5276.namprd11.prod.outlook.com>
Date: Wed, 1 Feb 2023 03:07:32 +0000
From: "Tian, Kevin" <kevin.tian@...el.com>
To: Nicolin Chen <nicolinc@...dia.com>,
"jgg@...dia.com" <jgg@...dia.com>,
"Lu, Baolu" <baolu.lu@...el.com>,
"robin.murphy@....com" <robin.murphy@....com>
CC: "Liu, Yi L" <yi.l.liu@...el.com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2 3/3] iommufd/device: Change
iommufd_hw_pagetable_has_group to device centric
> From: Nicolin Chen <nicolinc@...dia.com>
> Sent: Monday, January 30, 2023 6:22 PM
>
> On Sun, Jan 29, 2023 at 02:38:55AM -0800, Nicolin Chen wrote:
>
> > > > @@ -385,10 +372,8 @@ void iommufd_device_detach(struct
> > > > iommufd_device *idev)
> > > > struct iommufd_hw_pagetable *hwpt = idev->hwpt;
> > > >
> > > > mutex_lock(&hwpt->ioas->mutex);
> > > > - mutex_lock(&hwpt->devices_lock);
> > > > refcount_dec(hwpt->devices_users);
> > > > - list_del(&idev->devices_item);
> > > > - if (!iommufd_hw_pagetable_has_group(hwpt, idev->group)) {
> > > > + if (iommufd_hw_pagetable_has_device(hwpt, idev->dev)) {
> > > > if (refcount_read(hwpt->devices_users) == 1) {
> > > > iopt_table_remove_domain(&hwpt->ioas->iopt,
> > > > hwpt->domain);
> > > > @@ -397,7 +382,6 @@ void iommufd_device_detach(struct
> iommufd_device
> > > > *idev)
> > > > iommu_detach_group(hwpt->domain, idev->group);
> > > > }
> > >
> > > emmm how do we track last device detach in a group? Here the first
> > > device detach already leads to group detach...
> >
> > Oh no. That's a bug. Thanks for catching it.
> >
> > We need an additional refcount somewhere to track the number of
> > attached devices in the iommu_group.
>
> Wondering if we can let iommu_attach/detach_device handle this:
>
that is the desired way to fully remove group awareness in iommufd.
but iirc there were some concerns on changing their semantics. But
I don't remember the detail now. Jason might know. also +Baolu/Robin.
otherwise as long as the group attach/detach continues to be used
then identifying last device in the group always needs some hack
within iommufd itself.
Powered by blists - more mailing lists