[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <013afe9a-756f-4c85-baa1-977bea6be395@linux.intel.com>
Date: Thu, 13 Jun 2024 12:23:17 +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 v6 03/10] iommu: Add attach handle to struct iopf_group
On 6/12/24 9:37 PM, Jason Gunthorpe wrote:
> On Mon, May 27, 2024 at 12:05:10PM +0800, Lu Baolu wrote:
>> @@ -206,20 +182,49 @@ void iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
>> if (group == &abort_group)
>> goto err_abort;
>>
>> - group->domain = get_domain_for_iopf(dev, fault);
>> - if (!group->domain)
>> + if (fault->prm.flags & IOMMU_FAULT_PAGE_REQUEST_PASID_VALID) {
>> + group->attach_handle = iommu_attach_handle_get(dev->iommu_group,
>> + fault->prm.pasid,
>> + 0);
>> + if (IS_ERR(group->attach_handle)) {
>> + if (!device_iommu_capable(dev, IOMMU_CAP_USER_IOASID_TABLE))
>> + goto err_abort;
>
> I'm not excited about calling a function pointer on every fault. Let's
> just add a constant flag to iommu_ops?
Yes, it's reasonable given this is a critical path. How about below
additional change?
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 16b3a2da91ef..69ea4d0374b9 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -253,12 +253,6 @@ enum iommu_cap {
*/
IOMMU_CAP_DEFERRED_FLUSH,
IOMMU_CAP_DIRTY_TRACKING, /* IOMMU supports dirty tracking */
- /*
- * IOMMU driver supports user-managed IOASID table. There is no
- * user domain for each PASID and the I/O page faults are forwarded
- * through the user domain attached to the device RID.
- */
- IOMMU_CAP_USER_IOASID_TABLE,
};
/* These are the possible reserved region types */
@@ -557,6 +551,10 @@ static inline int __iommu_copy_struct_from_user_array(
* @default_domain: If not NULL this will always be set as the default
domain.
* This should be an IDENTITY/BLOCKED/PLATFORM domain.
* Do not use in new drivers.
+ * @user_pasid_table: IOMMU driver supports user-managed PASID table.
There is
+ * no user domain for each PASID and the I/O page
faults are
+ * forwarded through the user domain attached to the
device
+ * RID.
*/
struct iommu_ops {
bool (*capable)(struct device *dev, enum iommu_cap);
@@ -600,6 +598,7 @@ struct iommu_ops {
struct iommu_domain *blocked_domain;
struct iommu_domain *release_domain;
struct iommu_domain *default_domain;
+ bool user_pasid_table;
};
/**
diff --git a/drivers/iommu/io-pgfault.c b/drivers/iommu/io-pgfault.c
index a629d8a93614..cd679c13752e 100644
--- a/drivers/iommu/io-pgfault.c
+++ b/drivers/iommu/io-pgfault.c
@@ -189,7 +189,9 @@ void iommu_report_device_fault(struct device *dev,
struct iopf_fault *evt)
fault->prm.pasid,
0);
if (IS_ERR(group->attach_handle)) {
- if (!device_iommu_capable(dev,
IOMMU_CAP_USER_IOASID_TABLE))
+ const struct iommu_ops *ops = dev_iommu_ops(dev);
+
+ if (!ops->user_pasid_table)
goto err_abort;
Best regards,
baolu
Powered by blists - more mailing lists