]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
iommu: Remove iommu_fwspec ops
authorRobin Murphy <robin.murphy@arm.com>
Tue, 2 Jul 2024 11:40:51 +0000 (12:40 +0100)
committerWill Deacon <will@kernel.org>
Thu, 4 Jul 2024 13:36:04 +0000 (14:36 +0100)
The ops in iommu_fwspec are only needed for the early configuration and
probe process, and by now are easy enough to derive on-demand in those
couple of places which need them, so remove the redundant stored copy.

Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/55c1410b2cd09531eab4f8e2f18f92a0faa0ea75.1719919669.git.robin.murphy@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/iommu-priv.h
drivers/iommu/iommu.c
drivers/iommu/of_iommu.c
include/linux/iommu.h

index 078cafcf49b47e2916b95e48c54b646def7afeca..a34efed2884be69aaaac704f4b9af0e19b9b28a3 100644 (file)
@@ -19,6 +19,11 @@ static inline const struct iommu_ops *dev_iommu_ops(struct device *dev)
 
 const struct iommu_ops *iommu_ops_from_fwnode(const struct fwnode_handle *fwnode);
 
+static inline const struct iommu_ops *iommu_fwspec_ops(struct iommu_fwspec *fwspec)
+{
+       return iommu_ops_from_fwnode(fwspec ? fwspec->iommu_fwnode : NULL);
+}
+
 int iommu_group_replace_domain(struct iommu_group *group,
                               struct iommu_domain *new_domain);
 
index 7618c4285cf9aa6ad1ec1a29b5edcce1dcccd040..e15ae1dd494b912abcd9d128ebf3865f19c04b2f 100644 (file)
@@ -510,7 +510,6 @@ DEFINE_MUTEX(iommu_probe_device_lock);
 static int __iommu_probe_device(struct device *dev, struct list_head *group_list)
 {
        const struct iommu_ops *ops;
-       struct iommu_fwspec *fwspec;
        struct iommu_group *group;
        struct group_device *gdev;
        int ret;
@@ -523,12 +522,7 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list
         * be present, and that any of their registered instances has suitable
         * ops for probing, and thus cheekily co-opt the same mechanism.
         */
-       fwspec = dev_iommu_fwspec_get(dev);
-       if (fwspec && fwspec->ops)
-               ops = fwspec->ops;
-       else
-               ops = iommu_ops_from_fwnode(NULL);
-
+       ops = iommu_fwspec_ops(dev_iommu_fwspec_get(dev));
        if (!ops)
                return -ENODEV;
        /*
@@ -2831,7 +2825,7 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode)
                return -EPROBE_DEFER;
 
        if (fwspec)
-               return ops == fwspec->ops ? 0 : -EINVAL;
+               return ops == iommu_fwspec_ops(fwspec) ? 0 : -EINVAL;
 
        if (!dev_iommu_get(dev))
                return -ENOMEM;
@@ -2843,7 +2837,6 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode)
 
        fwnode_handle_get(iommu_fwnode);
        fwspec->iommu_fwnode = iommu_fwnode;
-       fwspec->ops = ops;
        dev_iommu_fwspec_set(dev, fwspec);
        return 0;
 }
index c946521a5906efd54e416e1b46159969dd84081e..559c5db78edb4865e6fb7d763d281872032bbbc4 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/slab.h>
 #include <linux/fsl/mc.h>
 
+#include "iommu-priv.h"
+
 static int of_iommu_xlate(struct device *dev,
                          struct of_phandle_args *iommu_spec)
 {
@@ -32,7 +34,7 @@ static int of_iommu_xlate(struct device *dev,
        if (ret)
                return ret;
 
-       ops = dev_iommu_fwspec_get(dev)->ops;
+       ops = iommu_ops_from_fwnode(&iommu_spec->np->fwnode);
        if (!ops->of_xlate || !try_module_get(ops->owner))
                return -ENODEV;
 
index 81893aad9ee49536e42600c2c0f9f47c36c245a6..11ae1750cb1d1ed7da16081c631160f6f1a02999 100644 (file)
@@ -968,7 +968,6 @@ extern struct iommu_group *generic_single_device_group(struct device *dev);
 
 /**
  * struct iommu_fwspec - per-device IOMMU instance data
- * @ops: ops for this device's IOMMU
  * @iommu_fwnode: firmware handle for this device's IOMMU
  * @flags: IOMMU_FWSPEC_* flags
  * @num_ids: number of associated device IDs
@@ -979,7 +978,6 @@ extern struct iommu_group *generic_single_device_group(struct device *dev);
  * consumers.
  */
 struct iommu_fwspec {
-       const struct iommu_ops  *ops;
        struct fwnode_handle    *iommu_fwnode;
        u32                     flags;
        unsigned int            num_ids;