Skip to content

Commit 3e36c15

Browse files
rmurphy-armwilldeacon
authored andcommitted
iommu: Remove iommu_fwspec ops
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 <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/55c1410b2cd09531eab4f8e2f18f92a0faa0ea75.1719919669.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent 5f937bc commit 3e36c15

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

drivers/iommu/iommu-priv.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ static inline const struct iommu_ops *dev_iommu_ops(struct device *dev)
1919

2020
const struct iommu_ops *iommu_ops_from_fwnode(const struct fwnode_handle *fwnode);
2121

22+
static inline const struct iommu_ops *iommu_fwspec_ops(struct iommu_fwspec *fwspec)
23+
{
24+
return iommu_ops_from_fwnode(fwspec ? fwspec->iommu_fwnode : NULL);
25+
}
26+
2227
int iommu_group_replace_domain(struct iommu_group *group,
2328
struct iommu_domain *new_domain);
2429

drivers/iommu/iommu.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ DEFINE_MUTEX(iommu_probe_device_lock);
510510
static int __iommu_probe_device(struct device *dev, struct list_head *group_list)
511511
{
512512
const struct iommu_ops *ops;
513-
struct iommu_fwspec *fwspec;
514513
struct iommu_group *group;
515514
struct group_device *gdev;
516515
int ret;
@@ -523,12 +522,7 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list
523522
* be present, and that any of their registered instances has suitable
524523
* ops for probing, and thus cheekily co-opt the same mechanism.
525524
*/
526-
fwspec = dev_iommu_fwspec_get(dev);
527-
if (fwspec && fwspec->ops)
528-
ops = fwspec->ops;
529-
else
530-
ops = iommu_ops_from_fwnode(NULL);
531-
525+
ops = iommu_fwspec_ops(dev_iommu_fwspec_get(dev));
532526
if (!ops)
533527
return -ENODEV;
534528
/*
@@ -2831,7 +2825,7 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode)
28312825
return -EPROBE_DEFER;
28322826

28332827
if (fwspec)
2834-
return ops == fwspec->ops ? 0 : -EINVAL;
2828+
return ops == iommu_fwspec_ops(fwspec) ? 0 : -EINVAL;
28352829

28362830
if (!dev_iommu_get(dev))
28372831
return -ENOMEM;
@@ -2843,7 +2837,6 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode)
28432837

28442838
fwnode_handle_get(iommu_fwnode);
28452839
fwspec->iommu_fwnode = iommu_fwnode;
2846-
fwspec->ops = ops;
28472840
dev_iommu_fwspec_set(dev, fwspec);
28482841
return 0;
28492842
}

drivers/iommu/of_iommu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <linux/slab.h>
1818
#include <linux/fsl/mc.h>
1919

20+
#include "iommu-priv.h"
21+
2022
static int of_iommu_xlate(struct device *dev,
2123
struct of_phandle_args *iommu_spec)
2224
{
@@ -32,7 +34,7 @@ static int of_iommu_xlate(struct device *dev,
3234
if (ret)
3335
return ret;
3436

35-
ops = dev_iommu_fwspec_get(dev)->ops;
37+
ops = iommu_ops_from_fwnode(&iommu_spec->np->fwnode);
3638
if (!ops->of_xlate || !try_module_get(ops->owner))
3739
return -ENODEV;
3840

include/linux/iommu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,6 @@ extern struct iommu_group *generic_single_device_group(struct device *dev);
968968

969969
/**
970970
* struct iommu_fwspec - per-device IOMMU instance data
971-
* @ops: ops for this device's IOMMU
972971
* @iommu_fwnode: firmware handle for this device's IOMMU
973972
* @flags: IOMMU_FWSPEC_* flags
974973
* @num_ids: number of associated device IDs
@@ -979,7 +978,6 @@ extern struct iommu_group *generic_single_device_group(struct device *dev);
979978
* consumers.
980979
*/
981980
struct iommu_fwspec {
982-
const struct iommu_ops *ops;
983981
struct fwnode_handle *iommu_fwnode;
984982
u32 flags;
985983
unsigned int num_ids;

0 commit comments

Comments
 (0)