Skip to content

Commit 29c6e1c

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu: Unexport iommu_fwspec_free()
The drivers doing their own fwspec parsing have no need to call iommu_fwspec_free() since fwspecs were moved into dev_iommu, as returning an error from .probe_device will tear down the whole lot anyway. Move it into the private interface now that it only serves for of_iommu to clean up in an error case. I have no idea what mtk_v1 was doing in effectively guaranteeing a NULL fwspec would be dereferenced if no "iommus" DT property was found, so add a check for that to at least make the code look sane. Signed-off-by: Robin Murphy <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/36e245489361de2d13db22a510fa5c79e7126278.1740667667.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent 032d7e4 commit 29c6e1c

File tree

6 files changed

+6
-18
lines changed

6 files changed

+6
-18
lines changed

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,6 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
14861486
out_cfg_free:
14871487
kfree(cfg);
14881488
out_free:
1489-
iommu_fwspec_free(dev);
14901489
return ERR_PTR(ret);
14911490
}
14921491

drivers/iommu/iommu-priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ static inline const struct iommu_ops *iommu_fwspec_ops(struct iommu_fwspec *fwsp
2424
return iommu_ops_from_fwnode(fwspec ? fwspec->iommu_fwnode : NULL);
2525
}
2626

27+
void iommu_fwspec_free(struct device *dev);
28+
2729
int iommu_device_register_bus(struct iommu_device *iommu,
2830
const struct iommu_ops *ops,
2931
const struct bus_type *bus,

drivers/iommu/iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2837,7 +2837,6 @@ void iommu_fwspec_free(struct device *dev)
28372837
dev_iommu_fwspec_set(dev, NULL);
28382838
}
28392839
}
2840-
EXPORT_SYMBOL_GPL(iommu_fwspec_free);
28412840

28422841
int iommu_fwspec_add_ids(struct device *dev, const u32 *ids, int num_ids)
28432842
{

drivers/iommu/mtk_iommu_v1.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -446,22 +446,13 @@ static int mtk_iommu_v1_create_mapping(struct device *dev,
446446

447447
static struct iommu_device *mtk_iommu_v1_probe_device(struct device *dev)
448448
{
449-
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
449+
struct iommu_fwspec *fwspec = NULL;
450450
struct of_phandle_args iommu_spec;
451451
struct mtk_iommu_v1_data *data;
452452
int err, idx = 0, larbid, larbidx;
453453
struct device_link *link;
454454
struct device *larbdev;
455455

456-
/*
457-
* In the deferred case, free the existed fwspec.
458-
* Always initialize the fwspec internally.
459-
*/
460-
if (fwspec) {
461-
iommu_fwspec_free(dev);
462-
fwspec = dev_iommu_fwspec_get(dev);
463-
}
464-
465456
while (!of_parse_phandle_with_args(dev->of_node, "iommus",
466457
"#iommu-cells",
467458
idx, &iommu_spec)) {
@@ -476,6 +467,9 @@ static struct iommu_device *mtk_iommu_v1_probe_device(struct device *dev)
476467
idx++;
477468
}
478469

470+
if (!fwspec)
471+
return ERR_PTR(-ENODEV);
472+
479473
data = dev_iommu_priv_get(dev);
480474

481475
/* Link the consumer device with the smi-larb device(supplier) */

drivers/iommu/tegra-smmu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,6 @@ static int tegra_smmu_configure(struct tegra_smmu *smmu, struct device *dev,
846846
err = ops->of_xlate(dev, args);
847847
if (err < 0) {
848848
dev_err(dev, "failed to parse SW group ID: %d\n", err);
849-
iommu_fwspec_free(dev);
850849
return err;
851850
}
852851

include/linux/iommu.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,6 @@ struct iommu_mm_data {
10991099
};
11001100

11011101
int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode);
1102-
void iommu_fwspec_free(struct device *dev);
11031102
int iommu_fwspec_add_ids(struct device *dev, const u32 *ids, int num_ids);
11041103

11051104
static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
@@ -1410,10 +1409,6 @@ static inline int iommu_fwspec_init(struct device *dev,
14101409
return -ENODEV;
14111410
}
14121411

1413-
static inline void iommu_fwspec_free(struct device *dev)
1414-
{
1415-
}
1416-
14171412
static inline int iommu_fwspec_add_ids(struct device *dev, u32 *ids,
14181413
int num_ids)
14191414
{

0 commit comments

Comments
 (0)