aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iommu.h
diff options
context:
space:
mode:
authorRobin Murphy <robin.murphy@arm.com>2016-09-13 05:54:14 -0400
committerWill Deacon <will.deacon@arm.com>2016-09-16 04:34:15 -0400
commit57f98d2f61e191ef9d06863c9ce3f8621f3671ef (patch)
treefd6d52282bcada86b0893b9972eaa5b8a5f219e1 /include/linux/iommu.h
parentb996444cf35e736621855e73f9d0762bd49f41f2 (diff)
iommu: Introduce iommu_fwspec
Introduce a common structure to hold the per-device firmware data that most IOMMU drivers need to keep track of. This enables us to configure much of that data from common firmware code, and consolidate a lot of the equivalent implementations, device look-up tables, etc. which are currently strewn across IOMMU drivers. This will also be enable us to address the outstanding "multiple IOMMUs on the platform bus" problem by tweaking IOMMU API calls to prefer dev->fwspec->ops before falling back to dev->bus->iommu_ops, and thus gracefully handle those troublesome systems which we currently cannot. As the first user, hook up the OF IOMMU configuration mechanism. The driver-defined nature of DT cells means that we still need the drivers to translate and add the IDs themselves, but future users such as the much less free-form ACPI IORT will be much simpler and self-contained. CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Suggested-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'include/linux/iommu.h')
-rw-r--r--include/linux/iommu.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index a35fb8b42e1a..436dc21318af 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -331,10 +331,32 @@ extern struct iommu_group *pci_device_group(struct device *dev);
331/* Generic device grouping function */ 331/* Generic device grouping function */
332extern struct iommu_group *generic_device_group(struct device *dev); 332extern struct iommu_group *generic_device_group(struct device *dev);
333 333
334/**
335 * struct iommu_fwspec - per-device IOMMU instance data
336 * @ops: ops for this device's IOMMU
337 * @iommu_fwnode: firmware handle for this device's IOMMU
338 * @iommu_priv: IOMMU driver private data for this device
339 * @num_ids: number of associated device IDs
340 * @ids: IDs which this device may present to the IOMMU
341 */
342struct iommu_fwspec {
343 const struct iommu_ops *ops;
344 struct fwnode_handle *iommu_fwnode;
345 void *iommu_priv;
346 unsigned int num_ids;
347 u32 ids[1];
348};
349
350int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode,
351 const struct iommu_ops *ops);
352void iommu_fwspec_free(struct device *dev);
353int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids);
354
334#else /* CONFIG_IOMMU_API */ 355#else /* CONFIG_IOMMU_API */
335 356
336struct iommu_ops {}; 357struct iommu_ops {};
337struct iommu_group {}; 358struct iommu_group {};
359struct iommu_fwspec {};
338 360
339static inline bool iommu_present(struct bus_type *bus) 361static inline bool iommu_present(struct bus_type *bus)
340{ 362{
@@ -541,6 +563,23 @@ static inline void iommu_device_unlink(struct device *dev, struct device *link)
541{ 563{
542} 564}
543 565
566static inline int iommu_fwspec_init(struct device *dev,
567 struct fwnode_handle *iommu_fwnode,
568 const struct iommu_ops *ops)
569{
570 return -ENODEV;
571}
572
573static inline void iommu_fwspec_free(struct device *dev)
574{
575}
576
577static inline int iommu_fwspec_add_ids(struct device *dev, u32 *ids,
578 int num_ids)
579{
580 return -ENODEV;
581}
582
544#endif /* CONFIG_IOMMU_API */ 583#endif /* CONFIG_IOMMU_API */
545 584
546#endif /* __LINUX_IOMMU_H */ 585#endif /* __LINUX_IOMMU_H */