[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <bf052fb0301eabe8c2831c6d53b9de2bbe000ac6.1674753627.git.robin.murphy@arm.com>
Date: Thu, 26 Jan 2023 18:26:16 +0000
From: Robin Murphy <robin.murphy@....com>
To: joro@...tes.org, will@...nel.org
Cc: iommu@...ts.linux.dev, linux-kernel@...r.kernel.org, hch@....de,
jgg@...dia.com, baolu.lu@...ux.intel.com
Subject: [PATCH v2 1/8] iommu: Decouple iommu_present() from bus ops
Much as I'd like to remove iommu_present(), the final remaining users
are proving stubbornly difficult to clean up, so kick that can down
the road and just rework it to preserve the current behaviour without
depending on bus ops.
Signed-off-by: Robin Murphy <robin.murphy@....com>
---
v2: No change
drivers/iommu/iommu.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 42591766266d..b27f5d3453bb 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1871,9 +1871,24 @@ int bus_iommu_probe(struct bus_type *bus)
return ret;
}
+static int __iommu_present(struct device *dev, void *unused)
+{
+ return device_iommu_mapped(dev);
+}
+
+/**
+ * iommu_present() - make platform-specific assumptions about an IOMMU
+ * @bus: bus to check
+ *
+ * Do not use this function. You want device_iommu_mapped() instead.
+ *
+ * Return: true if some IOMMU is present for some device on the given bus. In
+ * general it may not be the only IOMMU, and it may not be for the device you
+ * are ultimately interested in.
+ */
bool iommu_present(struct bus_type *bus)
{
- return bus->iommu_ops != NULL;
+ return bus_for_each_dev(bus, NULL, NULL, __iommu_present) > 0;
}
EXPORT_SYMBOL_GPL(iommu_present);
--
2.36.1.dirty
Powered by blists - more mailing lists