From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: baolu.lu@linux.intel.com, Kevin Tian <kevin.tian@intel.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Jean-Philippe Brucker <jean-philippe@linaro.org>,
Nicolin Chen <nicolinc@nvidia.com>, Yi Liu <yi.l.liu@intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
Joel Granados <j.granados@samsung.com>,
iommu@lists.linux.dev, virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/9] iommu: Introduce domain attachment handle
Date: Tue, 9 Apr 2024 09:34:12 +0800 [thread overview]
Message-ID: <ff7ed901-fb4d-4bb1-adf1-8c83409b7a80@linux.intel.com> (raw)
In-Reply-To: <20240408140548.GO5383@nvidia.com>
On 4/8/24 10:05 PM, Jason Gunthorpe wrote:
> On Sat, Apr 06, 2024 at 12:34:14PM +0800, Baolu Lu wrote:
>> On 4/3/24 7:58 PM, Jason Gunthorpe wrote:
>>> On Wed, Apr 03, 2024 at 09:15:11AM +0800, Lu Baolu wrote:
>>>> Currently, when attaching a domain to a device or its PASID, domain is
>>>> stored within the iommu group. It could be retrieved for use during the
>>>> window between attachment and detachment.
>>>>
>>>> With new features introduced, there's a need to store more information
>>>> than just a domain pointer. This information essentially represents the
>>>> association between a domain and a device. For example, the SVA code
>>>> already has a custom struct iommu_sva which represents a bond between
>>>> sva domain and a PASID of a device. Looking forward, the IOMMUFD needs
>>>> a place to store the iommufd_device pointer in the core, so that the
>>>> device object ID could be quickly retrieved in the critical fault handling
>>>> path.
>>>>
>>>> Introduce domain attachment handle that explicitly represents the
>>>> attachment relationship between a domain and a device or its PASID.
>>>> A caller-specific data field can be used by the caller to store additional
>>>> information beyond a domain pointer, depending on its specific use case.
>>>>
>>>> Co-developed-by: Jason Gunthorpe<jgg@nvidia.com>
>>>> Signed-off-by: Jason Gunthorpe<jgg@nvidia.com>
>>>> Signed-off-by: Lu Baolu<baolu.lu@linux.intel.com>
>>>> ---
>>>> drivers/iommu/iommu-priv.h | 9 +++
>>>> drivers/iommu/iommu.c | 158 +++++++++++++++++++++++++++++++++----
>>>> 2 files changed, 153 insertions(+), 14 deletions(-)
>>>>
>>>> diff --git a/drivers/iommu/iommu-priv.h b/drivers/iommu/iommu-priv.h
>>>> index 5f731d994803..08c0667cef54 100644
>>>> --- a/drivers/iommu/iommu-priv.h
>>>> +++ b/drivers/iommu/iommu-priv.h
>>>> @@ -28,4 +28,13 @@ void iommu_device_unregister_bus(struct iommu_device *iommu,
>>>> const struct bus_type *bus,
>>>> struct notifier_block *nb);
>>>> +struct iommu_attach_handle {
>>>> + struct iommu_domain *domain;
>>>> + refcount_t users;
>>> I don't understand how the refcounting can be generally useful. There
>>> is no way to free this:
>>>
>>>> + void *priv;
>>> When the refcount goes to zero.
>> This field is set by the caller, so the caller ensures that the pointer
>> can only be freed after iommu domain detachment. For iopf, the caller
>> should automatically respond to all outstanding iopf's in the domain
>> detach path.
>>
>> In the sva case, which uses the workqueue to handle iopf,
>> flush_workqueue() is called in the domain detach path to ensure that all
>> outstanding iopf's are completed before detach completion.
> Which is back to what is the point of the refcount at all?
Yeah, refcount is not generally useful. It's context-specific, so it
needs to move out of the core.
The SVA code needs refcount because it allows multiple attachments
between a SVA domain and a PASID. This is not a common case.
>
>> +static void iommufd_auto_response_handle(struct iommufd_fault *fault,
>> + struct iommu_attach_handle *handle)
>> +{
>> + struct iommufd_device *idev = handle->priv;
> The caller already has the iommufd_device, don't need the handler.
Yes.
Best regards,
baolu
next prev parent reply other threads:[~2024-04-09 1:35 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 1:15 [PATCH v4 0/9] IOMMUFD: Deliver IO page faults to user space Lu Baolu
2024-04-03 1:15 ` [PATCH v4 1/9] iommu: Introduce domain attachment handle Lu Baolu
2024-04-03 11:58 ` Jason Gunthorpe
2024-04-06 4:34 ` Baolu Lu
2024-04-08 14:05 ` Jason Gunthorpe
2024-04-09 1:34 ` Baolu Lu [this message]
2024-04-09 1:53 ` Baolu Lu
2024-04-09 23:37 ` Jason Gunthorpe
2024-04-10 0:25 ` Tian, Kevin
2024-04-03 1:15 ` [PATCH v4 2/9] iommu: Replace sva_iommu with iommu_attach_handle Lu Baolu
2024-04-03 11:59 ` Jason Gunthorpe
2024-04-06 6:09 ` Baolu Lu
2024-04-08 14:19 ` Jason Gunthorpe
2024-04-09 2:11 ` Baolu Lu
2024-04-09 23:48 ` Jason Gunthorpe
2024-04-10 6:12 ` Baolu Lu
2024-04-28 10:22 ` Baolu Lu
2024-04-29 2:39 ` Tian, Kevin
2024-04-29 5:07 ` Baolu Lu
2024-04-29 20:24 ` Jason Gunthorpe
2024-04-06 6:28 ` Baolu Lu
2024-04-03 1:15 ` [PATCH v4 3/9] iommu: Add attachment handle to struct iopf_group Lu Baolu
2024-04-03 1:15 ` [PATCH v4 4/9] iommufd: Fault-capable hw page table attach/detach/replace Lu Baolu
2024-04-03 1:15 ` [PATCH v4 5/9] iommufd: Add fault and response message definitions Lu Baolu
2024-04-03 1:15 ` [PATCH v4 6/9] iommufd: Add iommufd fault object Lu Baolu
2024-04-03 1:15 ` [PATCH v4 7/9] iommufd: Associate fault object with iommufd_hw_pgtable Lu Baolu
2024-04-03 1:15 ` [PATCH v4 8/9] iommufd/selftest: Add IOPF support for mock device Lu Baolu
2024-04-03 1:15 ` [PATCH v4 9/9] iommufd/selftest: Add coverage for IOPF test Lu Baolu
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=ff7ed901-fb4d-4bb1-adf1-8c83409b7a80@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=j.granados@samsung.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.org \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=will@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).