* [PATCH 0/3] Cleanup around iommu_set_fault_handler()
@ 2025-10-22 17:12 Jason Gunthorpe
2025-10-22 17:12 ` [PATCH 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Jason Gunthorpe @ 2025-10-22 17:12 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner,
iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky,
linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma,
linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar,
Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit,
Chen-Yu Tsai, Will Deacon, Yong Wu
Cc: patches
report_iommu_fault() is an older API that has been superseded by
iommu_report_device_fault() which is capable to support PRI.
Only three external drivers consume this via iommu_set_fault_handler()
drivers/remoteproc
drivers/gpu/drm/msm
drivers/infiniband/hw/usnic
Remove the use in usnic as the iommu driver logging is good enough these
days.
Remove generation support from the AMD iommu driver since msm and
remoteproc are not used on AMD x86 CPUs.
Fail iommu_set_fault_handler() if the underlying iommu driver does not
support it.
Jason Gunthorpe (3):
RDMA/usnic: Remove iommu_set_fault_handler()
iommu/amd: Don't call report_iommu_fault()
iommu: Allow drivers to say if they use report_iommu_fault()
drivers/infiniband/hw/usnic/usnic_uiom.c | 13 -------------
drivers/iommu/amd/iommu.c | 24 ------------------------
drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 +
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 1 +
drivers/iommu/iommu.c | 6 +++++-
drivers/iommu/ipmmu-vmsa.c | 1 +
drivers/iommu/mtk_iommu.c | 1 +
drivers/iommu/mtk_iommu_v1.c | 1 +
drivers/iommu/omap-iommu.c | 1 +
drivers/iommu/rockchip-iommu.c | 1 +
drivers/iommu/sun50i-iommu.c | 1 +
include/linux/iommu.h | 3 +++
12 files changed, 16 insertions(+), 38 deletions(-)
base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
--
2.43.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] RDMA/usnic: Remove iommu_set_fault_handler()
2025-10-22 17:12 [PATCH 0/3] Cleanup around iommu_set_fault_handler() Jason Gunthorpe
@ 2025-10-22 17:12 ` Jason Gunthorpe
2025-10-23 5:02 ` Baolu Lu
2025-10-22 17:12 ` [PATCH 2/3] iommu/amd: Don't call report_iommu_fault() Jason Gunthorpe
2025-10-22 17:12 ` [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe
2 siblings, 1 reply; 12+ messages in thread
From: Jason Gunthorpe @ 2025-10-22 17:12 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner,
iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky,
linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma,
linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar,
Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit,
Chen-Yu Tsai, Will Deacon, Yong Wu
Cc: patches
The handler in usnic just prints a fault report message, the iommu drivers
all do a better job of that these days. Just remove the use of this old
API.
Acked-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/infiniband/hw/usnic/usnic_uiom.c | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c
index 3fbf99757b1148..f7fb6246c83aba 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom.c
+++ b/drivers/infiniband/hw/usnic/usnic_uiom.c
@@ -51,17 +51,6 @@
((void *) &((struct usnic_uiom_chunk *) 0)->page_list[1] - \
(void *) &((struct usnic_uiom_chunk *) 0)->page_list[0]))
-static int usnic_uiom_dma_fault(struct iommu_domain *domain,
- struct device *dev,
- unsigned long iova, int flags,
- void *token)
-{
- usnic_err("Device %s iommu fault domain 0x%p va 0x%lx flags 0x%x\n",
- dev_name(dev),
- domain, iova, flags);
- return -ENOSYS;
-}
-
static void usnic_uiom_put_pages(struct list_head *chunk_list, int dirty)
{
struct usnic_uiom_chunk *chunk, *tmp;
@@ -450,8 +439,6 @@ struct usnic_uiom_pd *usnic_uiom_alloc_pd(struct device *dev)
return ERR_CAST(domain);
}
- iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL);
-
spin_lock_init(&pd->lock);
INIT_LIST_HEAD(&pd->devs);
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] iommu/amd: Don't call report_iommu_fault()
2025-10-22 17:12 [PATCH 0/3] Cleanup around iommu_set_fault_handler() Jason Gunthorpe
2025-10-22 17:12 ` [PATCH 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe
@ 2025-10-22 17:12 ` Jason Gunthorpe
2025-10-23 12:34 ` Robin Murphy
2025-10-22 17:12 ` [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe
2 siblings, 1 reply; 12+ messages in thread
From: Jason Gunthorpe @ 2025-10-22 17:12 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner,
iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky,
linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma,
linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar,
Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit,
Chen-Yu Tsai, Will Deacon, Yong Wu
Cc: patches
This old style API is only used by drivers/gpu/drm/msm and
drivers/remoteproc, neither are used on x86 HW. Remove the dead code to
discourage new users.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/amd/iommu.c | 24 ------------------------
1 file changed, 24 deletions(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 2e1865daa1cee8..072c80bb2c2b3a 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -840,29 +840,6 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu,
dev_data = dev_iommu_priv_get(&pdev->dev);
if (dev_data) {
- /*
- * If this is a DMA fault (for which the I(nterrupt)
- * bit will be unset), allow report_iommu_fault() to
- * prevent logging it.
- */
- if (IS_IOMMU_MEM_TRANSACTION(flags)) {
- /* Device not attached to domain properly */
- if (dev_data->domain == NULL) {
- pr_err_ratelimited("Event logged [Device not attached to domain properly]\n");
- pr_err_ratelimited(" device=%04x:%02x:%02x.%x domain=0x%04x\n",
- iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid),
- PCI_FUNC(devid), domain_id);
- goto out;
- }
-
- if (!report_iommu_fault(&dev_data->domain->domain,
- &pdev->dev, address,
- IS_WRITE_REQUEST(flags) ?
- IOMMU_FAULT_WRITE :
- IOMMU_FAULT_READ))
- goto out;
- }
-
if (__ratelimit(&dev_data->rs)) {
pci_err(pdev, "Event logged [IO_PAGE_FAULT domain=0x%04x address=0x%llx flags=0x%04x]\n",
domain_id, address, flags);
@@ -873,7 +850,6 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu,
domain_id, address, flags);
}
-out:
if (pdev)
pci_dev_put(pdev);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault()
2025-10-22 17:12 [PATCH 0/3] Cleanup around iommu_set_fault_handler() Jason Gunthorpe
2025-10-22 17:12 ` [PATCH 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe
2025-10-22 17:12 ` [PATCH 2/3] iommu/amd: Don't call report_iommu_fault() Jason Gunthorpe
@ 2025-10-22 17:12 ` Jason Gunthorpe
2025-10-23 5:06 ` Baolu Lu
2025-10-23 11:24 ` Robin Murphy
2 siblings, 2 replies; 12+ messages in thread
From: Jason Gunthorpe @ 2025-10-22 17:12 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner,
iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky,
linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma,
linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar,
Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit,
Chen-Yu Tsai, Will Deacon, Yong Wu
Cc: patches
report_iommu_fault() is an older API that has been superseded by
iommu_report_device_fault() which is capable to support PRI.
Only two external drivers consume this, drivers/remoteproc and
drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for
now protect against accidentally mix and matching the wrong components.
The iommu drivers support either the old iommu_set_fault_handler() via the
driver calling report_iommu_fault(), or they are newer server focused
drivers that call iommu_report_device_fault().
Include a flag in the domain_ops if it calls report_iommu_fault() and
block iommu_set_fault_handler() on iommu's that can't support it.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 +
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 1 +
drivers/iommu/iommu.c | 6 +++++-
drivers/iommu/ipmmu-vmsa.c | 1 +
drivers/iommu/mtk_iommu.c | 1 +
drivers/iommu/mtk_iommu_v1.c | 1 +
drivers/iommu/omap-iommu.c | 1 +
drivers/iommu/rockchip-iommu.c | 1 +
drivers/iommu/sun50i-iommu.c | 1 +
include/linux/iommu.h | 3 +++
10 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 4ced4b5bee4df3..5ce8f82ddb534b 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -1644,6 +1644,7 @@ static const struct iommu_ops arm_smmu_ops = {
.def_domain_type = arm_smmu_def_domain_type,
.owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = arm_smmu_attach_dev,
.map_pages = arm_smmu_map_pages,
.unmap_pages = arm_smmu_unmap_pages,
diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
index c5be95e560317e..3163a23fcbaa4f 100644
--- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
+++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
@@ -598,6 +598,7 @@ static const struct iommu_ops qcom_iommu_ops = {
.device_group = generic_device_group,
.of_xlate = qcom_iommu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = qcom_iommu_attach_dev,
.map_pages = qcom_iommu_map,
.unmap_pages = qcom_iommu_unmap,
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 59244c744eabd2..34546a70fb5279 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2005,6 +2005,9 @@ EXPORT_SYMBOL_GPL(iommu_group_has_isolated_msi);
* This function should be used by IOMMU users which want to be notified
* whenever an IOMMU fault happens.
*
+ * This is a legacy API not supported by all drivers. New users should look
+ * to using domain->iopf_handler for the modern API.
+ *
* The fault handler itself should return 0 on success, and an appropriate
* error code otherwise.
*/
@@ -2012,7 +2015,8 @@ void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler,
void *token)
{
- if (WARN_ON(!domain || domain->cookie_type != IOMMU_COOKIE_NONE))
+ if (WARN_ON(!domain || domain->cookie_type != IOMMU_COOKIE_NONE ||
+ !domain->ops->report_iommu_fault_supported))
return;
domain->cookie_type = IOMMU_COOKIE_FAULT_HANDLER;
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index ffa892f6571406..770fa248e30477 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -885,6 +885,7 @@ static const struct iommu_ops ipmmu_ops = {
? generic_device_group : generic_single_device_group,
.of_xlate = ipmmu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = ipmmu_attach_device,
.map_pages = ipmmu_map,
.unmap_pages = ipmmu_unmap,
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 0e0285348d2b8e..0f44993eaadce3 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -1019,6 +1019,7 @@ static const struct iommu_ops mtk_iommu_ops = {
.get_resv_regions = mtk_iommu_get_resv_regions,
.owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = mtk_iommu_attach_device,
.map_pages = mtk_iommu_map,
.unmap_pages = mtk_iommu_unmap,
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index 10cc0b1197e801..279e7acfd5c6d3 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -582,6 +582,7 @@ static const struct iommu_ops mtk_iommu_v1_ops = {
.device_group = generic_device_group,
.owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = mtk_iommu_v1_attach_device,
.map_pages = mtk_iommu_v1_map,
.unmap_pages = mtk_iommu_v1_unmap,
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index 5c6f5943f44b1f..3f3193de3ecd86 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -1724,6 +1724,7 @@ static const struct iommu_ops omap_iommu_ops = {
.device_group = generic_single_device_group,
.of_xlate = omap_iommu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = omap_iommu_attach_dev,
.map_pages = omap_iommu_map,
.unmap_pages = omap_iommu_unmap,
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 0861dd469bd866..0053f5aa2cb781 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -1174,6 +1174,7 @@ static const struct iommu_ops rk_iommu_ops = {
.device_group = generic_single_device_group,
.of_xlate = rk_iommu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = rk_iommu_attach_device,
.map_pages = rk_iommu_map,
.unmap_pages = rk_iommu_unmap,
diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c
index de10b569d9a940..29b230050906a2 100644
--- a/drivers/iommu/sun50i-iommu.c
+++ b/drivers/iommu/sun50i-iommu.c
@@ -849,6 +849,7 @@ static const struct iommu_ops sun50i_iommu_ops = {
.of_xlate = sun50i_iommu_of_xlate,
.probe_device = sun50i_iommu_probe_device,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = sun50i_iommu_attach_device,
.flush_iotlb_all = sun50i_iommu_flush_iotlb_all,
.iotlb_sync_map = sun50i_iommu_iotlb_sync_map,
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index c30d12e16473df..e2bf7885287fac 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -714,6 +714,8 @@ struct iommu_ops {
/**
* struct iommu_domain_ops - domain specific operations
+ * @report_iommu_fault_supported: True if the domain supports
+ * iommu_set_fault_handler()
* @attach_dev: attach an iommu domain to a device
* Return:
* * 0 - success
@@ -751,6 +753,7 @@ struct iommu_ops {
* @free: Release the domain after use.
*/
struct iommu_domain_ops {
+ bool report_iommu_fault_supported : 1;
int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
int (*set_dev_pasid)(struct iommu_domain *domain, struct device *dev,
ioasid_t pasid, struct iommu_domain *old);
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] RDMA/usnic: Remove iommu_set_fault_handler()
2025-10-22 17:12 ` [PATCH 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe
@ 2025-10-23 5:02 ` Baolu Lu
0 siblings, 0 replies; 12+ messages in thread
From: Baolu Lu @ 2025-10-23 5:02 UTC (permalink / raw)
To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti,
Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel,
Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek,
linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger,
Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland,
Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu
Cc: patches
On 10/23/25 01:12, Jason Gunthorpe wrote:
> The handler in usnic just prints a fault report message, the iommu drivers
> all do a better job of that these days. Just remove the use of this old
> API.
>
> Acked-by: Jason Gunthorpe<jgg@nvidia.com>
> Signed-off-by: Jason Gunthorpe<jgg@nvidia.com>
> ---
> drivers/infiniband/hw/usnic/usnic_uiom.c | 13 -------------
> 1 file changed, 13 deletions(-)
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault()
2025-10-22 17:12 ` [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe
@ 2025-10-23 5:06 ` Baolu Lu
2025-10-23 11:24 ` Robin Murphy
1 sibling, 0 replies; 12+ messages in thread
From: Baolu Lu @ 2025-10-23 5:06 UTC (permalink / raw)
To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti,
Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel,
Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek,
linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger,
Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland,
Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu
Cc: patches
On 10/23/25 01:12, Jason Gunthorpe wrote:
> report_iommu_fault() is an older API that has been superseded by
> iommu_report_device_fault() which is capable to support PRI.
>
> Only two external drivers consume this, drivers/remoteproc and
> drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for
> now protect against accidentally mix and matching the wrong components.
>
> The iommu drivers support either the old iommu_set_fault_handler() via the
> driver calling report_iommu_fault(), or they are newer server focused
> drivers that call iommu_report_device_fault().
>
> Include a flag in the domain_ops if it calls report_iommu_fault() and
> block iommu_set_fault_handler() on iommu's that can't support it.
>
> Signed-off-by: Jason Gunthorpe<jgg@nvidia.com>
> ---
> drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 +
> drivers/iommu/arm/arm-smmu/qcom_iommu.c | 1 +
> drivers/iommu/iommu.c | 6 +++++-
> drivers/iommu/ipmmu-vmsa.c | 1 +
> drivers/iommu/mtk_iommu.c | 1 +
> drivers/iommu/mtk_iommu_v1.c | 1 +
> drivers/iommu/omap-iommu.c | 1 +
> drivers/iommu/rockchip-iommu.c | 1 +
> drivers/iommu/sun50i-iommu.c | 1 +
> include/linux/iommu.h | 3 +++
> 10 files changed, 16 insertions(+), 1 deletion(-)
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault()
2025-10-22 17:12 ` [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe
2025-10-23 5:06 ` Baolu Lu
@ 2025-10-23 11:24 ` Robin Murphy
2025-10-23 14:54 ` Jason Gunthorpe
1 sibling, 1 reply; 12+ messages in thread
From: Robin Murphy @ 2025-10-23 11:24 UTC (permalink / raw)
To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti,
Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel,
Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek,
linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger,
Nelson Escobar, Rob Clark, Samuel Holland, Suravee Suthikulpanit,
Chen-Yu Tsai, Will Deacon, Yong Wu
Cc: patches
On 2025-10-22 6:12 pm, Jason Gunthorpe wrote:
> report_iommu_fault() is an older API that has been superseded by
> iommu_report_device_fault() which is capable to support PRI.
>
> Only two external drivers consume this, drivers/remoteproc and
> drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for
> now protect against accidentally mix and matching the wrong components.
>
> The iommu drivers support either the old iommu_set_fault_handler() via the
> driver calling report_iommu_fault(), or they are newer server focused
> drivers that call iommu_report_device_fault().
>
> Include a flag in the domain_ops if it calls report_iommu_fault() and
> block iommu_set_fault_handler() on iommu's that can't support it.
This isn't a domain operation though; depending on how you look at it,
supporting a legacy fault_handler is either a capability of the IOMMU
driver (that would be reachable via domain->owner->capable) or a
property of the iommu_domain itself that the drivers can set at
allocation time (basically this same patch just with the lines in
slightly different places).
Thanks,
Robin.
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 +
> drivers/iommu/arm/arm-smmu/qcom_iommu.c | 1 +
> drivers/iommu/iommu.c | 6 +++++-
> drivers/iommu/ipmmu-vmsa.c | 1 +
> drivers/iommu/mtk_iommu.c | 1 +
> drivers/iommu/mtk_iommu_v1.c | 1 +
> drivers/iommu/omap-iommu.c | 1 +
> drivers/iommu/rockchip-iommu.c | 1 +
> drivers/iommu/sun50i-iommu.c | 1 +
> include/linux/iommu.h | 3 +++
> 10 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 4ced4b5bee4df3..5ce8f82ddb534b 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -1644,6 +1644,7 @@ static const struct iommu_ops arm_smmu_ops = {
> .def_domain_type = arm_smmu_def_domain_type,
> .owner = THIS_MODULE,
> .default_domain_ops = &(const struct iommu_domain_ops) {
> + .report_iommu_fault_supported = true,
> .attach_dev = arm_smmu_attach_dev,
> .map_pages = arm_smmu_map_pages,
> .unmap_pages = arm_smmu_unmap_pages,
> diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> index c5be95e560317e..3163a23fcbaa4f 100644
> --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> @@ -598,6 +598,7 @@ static const struct iommu_ops qcom_iommu_ops = {
> .device_group = generic_device_group,
> .of_xlate = qcom_iommu_of_xlate,
> .default_domain_ops = &(const struct iommu_domain_ops) {
> + .report_iommu_fault_supported = true,
> .attach_dev = qcom_iommu_attach_dev,
> .map_pages = qcom_iommu_map,
> .unmap_pages = qcom_iommu_unmap,
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 59244c744eabd2..34546a70fb5279 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -2005,6 +2005,9 @@ EXPORT_SYMBOL_GPL(iommu_group_has_isolated_msi);
> * This function should be used by IOMMU users which want to be notified
> * whenever an IOMMU fault happens.
> *
> + * This is a legacy API not supported by all drivers. New users should look
> + * to using domain->iopf_handler for the modern API.
> + *
> * The fault handler itself should return 0 on success, and an appropriate
> * error code otherwise.
> */
> @@ -2012,7 +2015,8 @@ void iommu_set_fault_handler(struct iommu_domain *domain,
> iommu_fault_handler_t handler,
> void *token)
> {
> - if (WARN_ON(!domain || domain->cookie_type != IOMMU_COOKIE_NONE))
> + if (WARN_ON(!domain || domain->cookie_type != IOMMU_COOKIE_NONE ||
> + !domain->ops->report_iommu_fault_supported))
> return;
>
> domain->cookie_type = IOMMU_COOKIE_FAULT_HANDLER;
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index ffa892f6571406..770fa248e30477 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -885,6 +885,7 @@ static const struct iommu_ops ipmmu_ops = {
> ? generic_device_group : generic_single_device_group,
> .of_xlate = ipmmu_of_xlate,
> .default_domain_ops = &(const struct iommu_domain_ops) {
> + .report_iommu_fault_supported = true,
> .attach_dev = ipmmu_attach_device,
> .map_pages = ipmmu_map,
> .unmap_pages = ipmmu_unmap,
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 0e0285348d2b8e..0f44993eaadce3 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -1019,6 +1019,7 @@ static const struct iommu_ops mtk_iommu_ops = {
> .get_resv_regions = mtk_iommu_get_resv_regions,
> .owner = THIS_MODULE,
> .default_domain_ops = &(const struct iommu_domain_ops) {
> + .report_iommu_fault_supported = true,
> .attach_dev = mtk_iommu_attach_device,
> .map_pages = mtk_iommu_map,
> .unmap_pages = mtk_iommu_unmap,
> diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
> index 10cc0b1197e801..279e7acfd5c6d3 100644
> --- a/drivers/iommu/mtk_iommu_v1.c
> +++ b/drivers/iommu/mtk_iommu_v1.c
> @@ -582,6 +582,7 @@ static const struct iommu_ops mtk_iommu_v1_ops = {
> .device_group = generic_device_group,
> .owner = THIS_MODULE,
> .default_domain_ops = &(const struct iommu_domain_ops) {
> + .report_iommu_fault_supported = true,
> .attach_dev = mtk_iommu_v1_attach_device,
> .map_pages = mtk_iommu_v1_map,
> .unmap_pages = mtk_iommu_v1_unmap,
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index 5c6f5943f44b1f..3f3193de3ecd86 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -1724,6 +1724,7 @@ static const struct iommu_ops omap_iommu_ops = {
> .device_group = generic_single_device_group,
> .of_xlate = omap_iommu_of_xlate,
> .default_domain_ops = &(const struct iommu_domain_ops) {
> + .report_iommu_fault_supported = true,
> .attach_dev = omap_iommu_attach_dev,
> .map_pages = omap_iommu_map,
> .unmap_pages = omap_iommu_unmap,
> diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
> index 0861dd469bd866..0053f5aa2cb781 100644
> --- a/drivers/iommu/rockchip-iommu.c
> +++ b/drivers/iommu/rockchip-iommu.c
> @@ -1174,6 +1174,7 @@ static const struct iommu_ops rk_iommu_ops = {
> .device_group = generic_single_device_group,
> .of_xlate = rk_iommu_of_xlate,
> .default_domain_ops = &(const struct iommu_domain_ops) {
> + .report_iommu_fault_supported = true,
> .attach_dev = rk_iommu_attach_device,
> .map_pages = rk_iommu_map,
> .unmap_pages = rk_iommu_unmap,
> diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c
> index de10b569d9a940..29b230050906a2 100644
> --- a/drivers/iommu/sun50i-iommu.c
> +++ b/drivers/iommu/sun50i-iommu.c
> @@ -849,6 +849,7 @@ static const struct iommu_ops sun50i_iommu_ops = {
> .of_xlate = sun50i_iommu_of_xlate,
> .probe_device = sun50i_iommu_probe_device,
> .default_domain_ops = &(const struct iommu_domain_ops) {
> + .report_iommu_fault_supported = true,
> .attach_dev = sun50i_iommu_attach_device,
> .flush_iotlb_all = sun50i_iommu_flush_iotlb_all,
> .iotlb_sync_map = sun50i_iommu_iotlb_sync_map,
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index c30d12e16473df..e2bf7885287fac 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -714,6 +714,8 @@ struct iommu_ops {
>
> /**
> * struct iommu_domain_ops - domain specific operations
> + * @report_iommu_fault_supported: True if the domain supports
> + * iommu_set_fault_handler()
> * @attach_dev: attach an iommu domain to a device
> * Return:
> * * 0 - success
> @@ -751,6 +753,7 @@ struct iommu_ops {
> * @free: Release the domain after use.
> */
> struct iommu_domain_ops {
> + bool report_iommu_fault_supported : 1;
> int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
> int (*set_dev_pasid)(struct iommu_domain *domain, struct device *dev,
> ioasid_t pasid, struct iommu_domain *old);
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] iommu/amd: Don't call report_iommu_fault()
2025-10-22 17:12 ` [PATCH 2/3] iommu/amd: Don't call report_iommu_fault() Jason Gunthorpe
@ 2025-10-23 12:34 ` Robin Murphy
2025-10-23 14:26 ` Jason Gunthorpe
0 siblings, 1 reply; 12+ messages in thread
From: Robin Murphy @ 2025-10-23 12:34 UTC (permalink / raw)
To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti,
Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel,
Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek,
linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger,
Nelson Escobar, Rob Clark, Samuel Holland, Suravee Suthikulpanit,
Chen-Yu Tsai, Will Deacon, Yong Wu
Cc: patches
On 2025-10-22 6:12 pm, Jason Gunthorpe wrote:
> This old style API is only used by drivers/gpu/drm/msm and
> drivers/remoteproc, neither are used on x86 HW. Remove the dead code to
> discourage new users.
I'd be almost certain there's somebody somewhere using remoteproc on x86
with some FPGA/bespoke PCI device/on-board MCU/etc. - whether they're
doing it on AMD *and* care about its fault reporting mechanism is really
the question.
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/amd/iommu.c | 24 ------------------------
> 1 file changed, 24 deletions(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 2e1865daa1cee8..072c80bb2c2b3a 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -840,29 +840,6 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu,
> dev_data = dev_iommu_priv_get(&pdev->dev);
>
> if (dev_data) {
> - /*
> - * If this is a DMA fault (for which the I(nterrupt)
> - * bit will be unset), allow report_iommu_fault() to
> - * prevent logging it.
> - */
> - if (IS_IOMMU_MEM_TRANSACTION(flags)) {
> - /* Device not attached to domain properly */
> - if (dev_data->domain == NULL) {
> - pr_err_ratelimited("Event logged [Device not attached to domain properly]\n");
> - pr_err_ratelimited(" device=%04x:%02x:%02x.%x domain=0x%04x\n",
> - iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid),
> - PCI_FUNC(devid), domain_id);
> - goto out;
> - }
This part is unrelated to the report_iommu_fault() call - in fact it was
specifically added even more recently.
Thanks,
Robin.
> -
> - if (!report_iommu_fault(&dev_data->domain->domain,
> - &pdev->dev, address,
> - IS_WRITE_REQUEST(flags) ?
> - IOMMU_FAULT_WRITE :
> - IOMMU_FAULT_READ))
> - goto out;
> - }
> -
> if (__ratelimit(&dev_data->rs)) {
> pci_err(pdev, "Event logged [IO_PAGE_FAULT domain=0x%04x address=0x%llx flags=0x%04x]\n",
> domain_id, address, flags);
> @@ -873,7 +850,6 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu,
> domain_id, address, flags);
> }
>
> -out:
> if (pdev)
> pci_dev_put(pdev);
> }
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] iommu/amd: Don't call report_iommu_fault()
2025-10-23 12:34 ` Robin Murphy
@ 2025-10-23 14:26 ` Jason Gunthorpe
2025-11-20 19:26 ` Jason Gunthorpe
0 siblings, 1 reply; 12+ messages in thread
From: Jason Gunthorpe @ 2025-10-23 14:26 UTC (permalink / raw)
To: Robin Murphy
Cc: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner,
iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky,
linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma,
linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar,
Rob Clark, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai,
Will Deacon, Yong Wu, patches
On Thu, Oct 23, 2025 at 01:34:21PM +0100, Robin Murphy wrote:
> On 2025-10-22 6:12 pm, Jason Gunthorpe wrote:
> > This old style API is only used by drivers/gpu/drm/msm and
> > drivers/remoteproc, neither are used on x86 HW. Remove the dead code to
> > discourage new users.
>
> I'd be almost certain there's somebody somewhere using remoteproc on x86
> with some FPGA/bespoke PCI device/on-board MCU/etc. - whether they're doing
> it on AMD *and* care about its fault reporting mechanism is really the
> question.
Hmm!
Looking more closely
static int rproc_enable_iommu(struct rproc *rproc)
{
struct iommu_domain *domain;
struct device *dev = rproc->dev.parent;
int ret;
if (!rproc->has_iommu) {
^^^^^^^^^^^^^
dev_dbg(dev, "iommu not present\n");
return 0;
}
iommu_set_fault_handler(domain, rproc_iommu_fault, rproc);
And then:
drivers/remoteproc/omap_remoteproc.c: rproc->has_iommu = true;
drivers/remoteproc/qcom_q6v5_adsp.c: .has_iommu = true,
config OMAP_REMOTEPROC
tristate "OMAP remoteproc support"
depends on ARCH_OMAP4 || SOC_OMAP5 || SOC_DRA7XX
depends on OMAP_IOMMU
config QCOM_Q6V5_ADSP
tristate "Qualcomm Technology Inc ADSP Peripheral Image Loader"
depends on OF && ARCH_QCOM
depends on QCOM_SMEM
So, I think it is safe. I will revise the commit message.
Seems like these drivers are definately used:
drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 +
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 1 +
drivers/iommu/omap-iommu.c | 1 +
But I wonder if these are all dead code too? Any thoughts?
drivers/iommu/ipmmu-vmsa.c | 1 +
drivers/iommu/mtk_iommu.c | 1 +
drivers/iommu/mtk_iommu_v1.c | 1 +
drivers/iommu/rockchip-iommu.c | 1 +
drivers/iommu/sun50i-iommu.c | 1 +
> > if (dev_data) {
> > - /*
> > - * If this is a DMA fault (for which the I(nterrupt)
> > - * bit will be unset), allow report_iommu_fault() to
> > - * prevent logging it.
> > - */
> > - if (IS_IOMMU_MEM_TRANSACTION(flags)) {
> > - /* Device not attached to domain properly */
> > - if (dev_data->domain == NULL) {
> > - pr_err_ratelimited("Event logged [Device not attached to domain properly]\n");
> > - pr_err_ratelimited(" device=%04x:%02x:%02x.%x domain=0x%04x\n",
> > - iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid),
> > - PCI_FUNC(devid), domain_id);
> > - goto out;
> > - }
> This part is unrelated to the report_iommu_fault() call - in fact it was
> specifically added even more recently.
Yeah, I'll fix it
Thanks,
Jason
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault()
2025-10-23 11:24 ` Robin Murphy
@ 2025-10-23 14:54 ` Jason Gunthorpe
2025-10-23 16:58 ` Jason Gunthorpe
0 siblings, 1 reply; 12+ messages in thread
From: Jason Gunthorpe @ 2025-10-23 14:54 UTC (permalink / raw)
To: Robin Murphy
Cc: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner,
iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky,
linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma,
linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar,
Rob Clark, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai,
Will Deacon, Yong Wu, patches
On Thu, Oct 23, 2025 at 12:24:01PM +0100, Robin Murphy wrote:
> On 2025-10-22 6:12 pm, Jason Gunthorpe wrote:
> > report_iommu_fault() is an older API that has been superseded by
> > iommu_report_device_fault() which is capable to support PRI.
> >
> > Only two external drivers consume this, drivers/remoteproc and
> > drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for
> > now protect against accidentally mix and matching the wrong components.
> >
> > The iommu drivers support either the old iommu_set_fault_handler() via the
> > driver calling report_iommu_fault(), or they are newer server focused
> > drivers that call iommu_report_device_fault().
> >
> > Include a flag in the domain_ops if it calls report_iommu_fault() and
> > block iommu_set_fault_handler() on iommu's that can't support it.
>
> This isn't a domain operation though; depending on how you look at it,
> supporting a legacy fault_handler is either a capability of the IOMMU driver
> (that would be reachable via domain->owner->capable) or a property of the
> iommu_domain itself that the drivers can set at allocation time (basically
> this same patch just with the lines in slightly different places).
That's right, the issue is:
void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler,
void *token)
We can't get to the iommu instance starting from a domain pointer
Do you think we should change the above signature to include a
struct device *?
Jason
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault()
2025-10-23 14:54 ` Jason Gunthorpe
@ 2025-10-23 16:58 ` Jason Gunthorpe
0 siblings, 0 replies; 12+ messages in thread
From: Jason Gunthorpe @ 2025-10-23 16:58 UTC (permalink / raw)
To: Robin Murphy
Cc: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner,
iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky,
linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma,
linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar,
Rob Clark, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai,
Will Deacon, Yong Wu, patches
On Thu, Oct 23, 2025 at 11:54:34AM -0300, Jason Gunthorpe wrote:
> On Thu, Oct 23, 2025 at 12:24:01PM +0100, Robin Murphy wrote:
> > On 2025-10-22 6:12 pm, Jason Gunthorpe wrote:
> > > report_iommu_fault() is an older API that has been superseded by
> > > iommu_report_device_fault() which is capable to support PRI.
> > >
> > > Only two external drivers consume this, drivers/remoteproc and
> > > drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for
> > > now protect against accidentally mix and matching the wrong components.
> > >
> > > The iommu drivers support either the old iommu_set_fault_handler() via the
> > > driver calling report_iommu_fault(), or they are newer server focused
> > > drivers that call iommu_report_device_fault().
> > >
> > > Include a flag in the domain_ops if it calls report_iommu_fault() and
> > > block iommu_set_fault_handler() on iommu's that can't support it.
> >
> > This isn't a domain operation though; depending on how you look at it,
> > supporting a legacy fault_handler is either a capability of the IOMMU driver
> > (that would be reachable via domain->owner->capable) or a property of the
> > iommu_domain itself that the drivers can set at allocation time (basically
> > this same patch just with the lines in slightly different places).
>
> That's right, the issue is:
>
> void iommu_set_fault_handler(struct iommu_domain *domain,
> iommu_fault_handler_t handler,
> void *token)
>
> We can't get to the iommu instance starting from a domain pointer
>
> Do you think we should change the above signature to include a
> struct device *?
Reading this again, it is easy to move it to the domain->owner, which
is an *ops* pointer. It would still be driver global and not
per-instance. Lets try that then
I like adding a iommu_paging_domain_alloc_flags() option too..
Jason
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] iommu/amd: Don't call report_iommu_fault()
2025-10-23 14:26 ` Jason Gunthorpe
@ 2025-11-20 19:26 ` Jason Gunthorpe
0 siblings, 0 replies; 12+ messages in thread
From: Jason Gunthorpe @ 2025-11-20 19:26 UTC (permalink / raw)
To: Robin Murphy
Cc: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner,
iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky,
linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma,
linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar,
Rob Clark, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai,
Will Deacon, Yong Wu, patches
On Thu, Oct 23, 2025 at 11:26:57AM -0300, Jason Gunthorpe wrote:
> > > if (dev_data) {
> > > - /*
> > > - * If this is a DMA fault (for which the I(nterrupt)
> > > - * bit will be unset), allow report_iommu_fault() to
> > > - * prevent logging it.
> > > - */
> > > - if (IS_IOMMU_MEM_TRANSACTION(flags)) {
> > > - /* Device not attached to domain properly */
> > > - if (dev_data->domain == NULL) {
> > > - pr_err_ratelimited("Event logged [Device not attached to domain properly]\n");
> > > - pr_err_ratelimited(" device=%04x:%02x:%02x.%x domain=0x%04x\n",
> > > - iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid),
> > > - PCI_FUNC(devid), domain_id);
> > > - goto out;
> > > - }
> > This part is unrelated to the report_iommu_fault() call - in fact it was
> > specifically added even more recently.
>
> Yeah, I'll fix it
Coming back to this, it was right in the v1, it should be deleted.
The (dev_data->domain == NULL) test was added because calling
report_iommu_fault() will crash if the domain is NULL. This removed
that call it so we can't crash anymore.
Instead we fall through to this:
if (__ratelimit(&dev_data->rs)) {
pci_err(pdev, "Event logged [IO_PAGE_FAULT domain=0x%04x address=0x%llx flags=0x%04x]\n",
domain_id, address, flags);
}
Which prints the same information, the "domain is null" is not
especially useful. Further this only happens when dev_data is set it
so is very unlikely to be NULL anyhow, there is only a short period
after probe before the default domain is attached.
I will add some remarks to the commit message since I forgot why I did
it when you asked :\
Jason
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-11-20 19:33 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 17:12 [PATCH 0/3] Cleanup around iommu_set_fault_handler() Jason Gunthorpe
2025-10-22 17:12 ` [PATCH 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe
2025-10-23 5:02 ` Baolu Lu
2025-10-22 17:12 ` [PATCH 2/3] iommu/amd: Don't call report_iommu_fault() Jason Gunthorpe
2025-10-23 12:34 ` Robin Murphy
2025-10-23 14:26 ` Jason Gunthorpe
2025-11-20 19:26 ` Jason Gunthorpe
2025-10-22 17:12 ` [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe
2025-10-23 5:06 ` Baolu Lu
2025-10-23 11:24 ` Robin Murphy
2025-10-23 14:54 ` Jason Gunthorpe
2025-10-23 16:58 ` Jason Gunthorpe
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).