[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250710134215.97840-3-sergey.temerkhanov@intel.com>
Date: Thu, 10 Jul 2025 13:42:13 +0000
From: Sergey Temerkhanov <sergey.temerkhanov@...el.com>
To: iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org
Cc: David Woodhouse <dwmw2@...radead.org>,
Lu Baolu <baolu.lu@...ux.intel.com>,
Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>,
Sergey Temerkhanov <sergey.temerkhanov@...el.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v1 2/4] iommu: Add rid_notifier array to the dev_iommu structure
Add rid_notifier array to struct dev_iommu to facilitate
requester notification of IOMMU faults.
Signed-off-by: Sergey Temerkhanov <sergey.temerkhanov@...el.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/iommu/iommu.c | 9 +++++++++
include/linux/iommu.h | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index a4b606c591da..3789c16806a1 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -354,6 +354,7 @@ static struct dev_iommu *dev_iommu_get(struct device *dev)
return NULL;
mutex_init(¶m->lock);
+ xa_init(¶m->rid_notifiers);
dev->iommu = param;
return param;
}
@@ -361,8 +362,16 @@ static struct dev_iommu *dev_iommu_get(struct device *dev)
void dev_iommu_free(struct device *dev)
{
struct dev_iommu *param = dev->iommu;
+ struct rid_notifier *notifier;
+ unsigned long rid;
dev->iommu = NULL;
+
+ xa_for_each(¶m->rid_notifiers, rid, notifier)
+ kfree(notifier);
+
+ xa_destroy(¶m->rid_notifiers);
+
if (param->fwspec) {
fwnode_handle_put(param->fwspec->iommu_fwnode);
kfree(param->fwspec);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 4ddb63a3f2cf..2062623fdf32 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -795,6 +795,8 @@ struct iommu_fault_param {
* @pci_32bit_workaround: Limit DMA allocations to 32-bit IOVAs
* @require_direct: device requires IOMMU_RESV_DIRECT regions
* @shadow_on_flush: IOTLB flushes are used to sync shadow tables
+ * @rid_notifiers: holds pointers and data to the notifier functions for
+ * specific RIDs
*
* TODO: migrate other per device data pointers under iommu_dev_data, e.g.
* struct iommu_group *iommu_group;
@@ -810,6 +812,8 @@ struct dev_iommu {
u32 pci_32bit_workaround:1;
u32 require_direct:1;
u32 shadow_on_flush:1;
+
+ struct xarray rid_notifiers;
};
int iommu_device_register(struct iommu_device *iommu,
--
2.43.0
Powered by blists - more mailing lists