[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8b71bd41-dc1a-4a28-a380-8f470264f8da@linux.intel.com>
Date: Sat, 6 Apr 2024 14:28:42 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Jason Gunthorpe <jgg@...pe.ca>
Cc: baolu.lu@...ux.intel.com, Kevin Tian <kevin.tian@...el.com>,
Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>,
Jean-Philippe Brucker <jean-philippe@...aro.org>,
Nicolin Chen <nicolinc@...dia.com>, Yi Liu <yi.l.liu@...el.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>,
Joel Granados <j.granados@...sung.com>, iommu@...ts.linux.dev,
virtualization@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/9] iommu: Replace sva_iommu with iommu_attach_handle
On 4/3/24 7:59 PM, Jason Gunthorpe wrote:
>> - iommu_detach_device_pasid(domain, dev, iommu_mm->pasid);
>> - if (--domain->users == 0) {
>> - list_del(&domain->next);
>> - iommu_domain_free(domain);
>> + iommu_attach_handle_put(handle);
>> + if (refcount_read(&handle->users) == 1) {
>> + iommu_detach_device_pasid(domain, dev, iommu_mm->pasid);
>> + if (--domain->users == 0) {
>> + list_del(&domain->next);
>> + iommu_domain_free(domain);
>> + }
>> }
> Though I'm not convinced the refcount should be elevated into the core
> structure. The prior patch I showed you where the caller can provide
> the memory for the handle and we don't have a priv would make it easy
> to put the refcount in a SVA dervied handle struct without more
> allocation. Then we don't need this weirdness.
It's fine to move the refcount out of the core and allow the caller to
specify and manage its own attach handler. The refcount would then be
managed by the SVA code.
For the IOMMUFD case, we've discussed that all outstanding iopf's
should be automatically responded in the detach process. This ensures
the attach handle won't be used once the detach process completes.
Therefore, if this is true, there appears to be no need for a refcount
for IOMMUFD.
>
>> mutex_unlock(&iommu_sva_lock);
>> - kfree(handle);
> Also do we need iommu_sva_lock here anymore? I wonder if the group
> mutex would be sufficient..
The iommu_sva_lock protects the whole process of a mm binding, from
pasid allocation to domain attachment. While the group mutex only
protects the data within it structure. I don't think we could replace
iommu_sva_lock with group mutex in this patch. Or any misunderstanding?
Best regards,
baolu
Powered by blists - more mailing lists