@@ -20,6 +20,7 @@
#include <linux/interrupt.h>
#include <linux/io-pgtable.h>
#include <linux/iommu.h>
+#include <linux/iommu-driver.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -32,8 +33,6 @@
#include <linux/swab.h>
#include <linux/types.h>
-#include "dma-iommu.h"
-
#define DART_MAX_STREAMS 256
#define DART_MAX_TTBR 4
#define MAX_DARTS_PER_DEVICE 2
@@ -972,7 +971,7 @@ static void apple_dart_get_resv_regions(struct device *dev,
list_add_tail(®ion->list, head);
}
- iommu_dma_get_resv_regions(dev, head);
+ of_iommu_get_resv_regions(dev, head);
}
static const struct iommu_ops apple_dart_iommu_ops = {
@@ -23,7 +23,7 @@
#include <linux/memremap.h>
#include <linux/mm.h>
#include <linux/mutex.h>
-#include <linux/of_iommu.h>
+#include <linux/iommu-driver.h>
#include <linux/pci.h>
#include <linux/scatterlist.h>
#include <linux/spinlock.h>
@@ -475,8 +475,7 @@ void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
fwspec->ids, fwspec->num_ids);
}
- if (dev->of_node)
- of_iommu_get_resv_regions(dev, list);
+ of_iommu_get_resv_regions(dev, list);
}
EXPORT_SYMBOL(iommu_dma_get_resv_regions);
@@ -217,6 +217,9 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
struct of_phandle_iterator it;
int err;
+ if (!dev->of_node)
+ return;
+
of_for_each_phandle(&it, err, dev->of_node, "memory-region", NULL, 0) {
const __be32 *maps, *end;
struct resource phys;
@@ -12,6 +12,7 @@
#include <linux/freezer.h>
#include <linux/interval_tree.h>
#include <linux/iommu.h>
+#include <linux/iommu-driver.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pci.h>
@@ -22,8 +23,6 @@
#include <uapi/linux/virtio_iommu.h>
-#include "dma-iommu.h"
-
#define MSI_IOVA_BASE 0x8000000
#define MSI_IOVA_LENGTH 0x100000
@@ -969,7 +968,7 @@ static void viommu_get_resv_regions(struct device *dev, struct list_head *head)
list_add_tail(&msi->list, head);
}
- iommu_dma_get_resv_regions(dev, head);
+ of_iommu_get_resv_regions(dev, head);
}
static struct iommu_ops viommu_ops;
@@ -25,4 +25,13 @@ struct iommu_probe_info {
int iommu_probe_device_pinf(struct iommu_probe_info *pinf);
struct iommu_device *iommu_device_from_fwnode(struct fwnode_handle *fwnode);
+#if IS_ENABLED(CONFIG_OF_IOMMU)
+void of_iommu_get_resv_regions(struct device *dev, struct list_head *list);
+#else
+static inline void of_iommu_get_resv_regions(struct device *dev,
+ struct list_head *list)
+{
+}
+#endif
+
#endif
@@ -11,9 +11,6 @@ struct iommu_ops;
extern int of_iommu_configure(struct device *dev, struct device_node *master_np,
const u32 *id);
-extern void of_iommu_get_resv_regions(struct device *dev,
- struct list_head *list);
-
#else
static inline int of_iommu_configure(struct device *dev,
@@ -23,11 +20,6 @@ static inline int of_iommu_configure(struct device *dev,
return -ENODEV;
}
-static inline void of_iommu_get_resv_regions(struct device *dev,
- struct list_head *list)
-{
-}
-
#endif /* CONFIG_OF_IOMMU */
#endif /* __OF_IOMMU_H */
virtio-iommu and dart already parse the ACPI firmware description in their own get_resv_regions() callback. They just need to parse the OF description. The generic iommu_dma_get_resv_regions() really just knows how to parse the IORT ACPI in addition to OF. Directly call of_iommu_get_resv_regions() instead. Move the declaration of of_iommu_get_resv_regions() to iommu-driver.h since it is now intended to be called by drivers. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/iommu/apple-dart.c | 5 ++--- drivers/iommu/dma-iommu.c | 5 ++--- drivers/iommu/of_iommu.c | 3 +++ drivers/iommu/virtio-iommu.c | 5 ++--- include/linux/iommu-driver.h | 9 +++++++++ include/linux/of_iommu.h | 8 -------- 6 files changed, 18 insertions(+), 17 deletions(-)