remve dead iommu code
Subsystems (8)
Hi all,
this removes a bit of dead code and methods from the iommu code and the cleans up the arm-smmu-v3 driver a little bit based on that.
Diffstat:
drivers/iommu/amd/iommu.c | 1 drivers/iommu/apple-dart.c | 1 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 60 +++++++--------------------- drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 drivers/iommu/intel/iommu.c | 1 drivers/iommu/iommu.c | 33 --------------- drivers/iommu/mtk_iommu.c | 1 drivers/iommu/virtio-iommu.c | 5 -- include/linux/iommu.h | 17 ------- 9 files changed, 19 insertions(+), 101 deletions(-)
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 1/4 iommu: remove the unused dev_has_feat method
This method is never actually called.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 - include/linux/iommu.h | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +0 -1
@@ -2848,7 +2848,6 @@ static struct iommu_ops arm_smmu_ops = { .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, .put_resv_regions = generic_iommu_put_resv_regions, - .dev_has_feat = arm_smmu_dev_has_feature, .dev_feat_enabled = arm_smmu_dev_feature_enabled, .dev_enable_feat = arm_smmu_dev_enable_feature, .dev_disable_feat = arm_smmu_dev_disable_feature,
include/linux/iommu.h +1 -3
@@ -153,8 +153,7 @@ struct iommu_resv_region {* supported, this feature must be enabled before and * disabled after %IOMMU_DEV_FEAT_SVA. * -* Device drivers query whether a feature is supported using -* iommu_dev_has_feature(), and enable it using iommu_dev_enable_feature(). +* Device drivers enable a feature using iommu_dev_enable_feature(). */ enum iommu_dev_features {IOMMU_DEV_FEAT_SVA ,
@@ -237,7 +236,6 @@ struct iommu_ops {bool (*is_attach_deferred)(struct device *dev);/* Per device IOMMU features */ -bool (*dev_has_feat)(struct device *dev,enum iommu_dev_features f);bool (*dev_feat_enabled)(struct device *dev,enum iommu_dev_features f);int (*dev_enable_feat)(struct device *dev,enum iommu_dev_features f);int (*dev_disable_feat)(struct device *dev,enum iommu_dev_features f);
Signature · 6 lines
2.30.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 2/4 iommu: remove iommu_dev_feature_enabled
In reply to Christoph HellwigRemove the unused iommu_dev_feature_enabled function.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 - drivers/iommu/iommu.c | 13 ------------- include/linux/iommu.h | 9 --------- 3 files changed, 23 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +0 -1
@@ -2848,7 +2848,6 @@ static struct iommu_ops arm_smmu_ops = { .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, .put_resv_regions = generic_iommu_put_resv_regions, - .dev_feat_enabled = arm_smmu_dev_feature_enabled, .dev_enable_feat = arm_smmu_dev_enable_feature, .dev_disable_feat = arm_smmu_dev_disable_feature, .sva_bind = arm_smmu_sva_bind,
drivers/iommu/iommu.c +0 -13
@@ -2758,19 +2758,6 @@ int iommu_dev_disable_feature(struct device *dev, enum iommu_dev_features feat) }EXPORT_SYMBOL_GPL (iommu_dev_disable_feature); -bool iommu_dev_feature_enabled (struct device *dev,enum iommu_dev_features feat) -{ -if (dev->iommu && dev->iommu->iommu_dev) { -const struct iommu_ops *ops = dev->iommu->iommu_dev->ops; - -if (ops->dev_feat_enabled) -return ops->dev_feat_enabled (dev, feat); - } - -return false; -} -EXPORT_SYMBOL_GPL (iommu_dev_feature_enabled); -/** * iommu_sva_bind_device() - Bind a process address space to a device * @dev: the device
include/linux/iommu.h +0 -9
@@ -204,7 +204,6 @@ struct iommu_iotlb_gather {* driver init to device driver init (default no) * @dev_has/enable/disable_feat: per device entries to check/enable/disable * iommu specific features. -* @dev_feat_enabled: check enabled feature * @sva_bind: Bind process address space to device * @sva_unbind: Unbind process address space from device * @sva_get_pasid: Get PASID associated to a SVA handle
@@ -236,7 +235,6 @@ struct iommu_ops {bool (*is_attach_deferred)(struct device *dev);/* Per device IOMMU features */ -bool (*dev_feat_enabled)(struct device *dev,enum iommu_dev_features f);int (*dev_enable_feat)(struct device *dev,enum iommu_dev_features f);int (*dev_disable_feat)(struct device *dev,enum iommu_dev_features f);
@@ -665,7 +663,6 @@ void iommu_release_device(struct device *dev);int iommu_dev_enable_feature (struct device *dev,enum iommu_dev_features f);int iommu_dev_disable_feature (struct device *dev,enum iommu_dev_features f); -bool iommu_dev_feature_enabled (struct device *dev,enum iommu_dev_features f); struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm,
@@ -992,12 +989,6 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)return NULL ; } -static inline bool -iommu_dev_feature_enabled (struct device *dev,enum iommu_dev_features feat) -{ -return false; -} -static inline int iommu_dev_enable_feature (struct device *dev,enum iommu_dev_features feat) {
Signature · 6 lines
2.30.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 3/4 iommu: remove the put_resv_regions method
In reply to Christoph HellwigAll drivers that implement get_resv_regions just use generic_put_resv_regions to implement the put side. Remove the indirections and document the allocations constraints.
--- drivers/iommu/amd/iommu.c | 1 - drivers/iommu/apple-dart.c | 1 - drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 - drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 - drivers/iommu/intel/iommu.c | 1 - drivers/iommu/iommu.c | 20 +------------------- drivers/iommu/mtk_iommu.c | 1 - drivers/iommu/virtio-iommu.c | 5 ++--- include/linux/iommu.h | 4 ---- 9 files changed, 3 insertions(+), 32 deletions(-)
drivers/iommu/amd/iommu.c +0 -1
@@ -2279,7 +2279,6 @@ const struct iommu_ops amd_iommu_ops = { .probe_finalize = amd_iommu_probe_finalize, .device_group = amd_iommu_device_group, .get_resv_regions = amd_iommu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .is_attach_deferred = amd_iommu_is_attach_deferred, .pgsize_bitmap = AMD_IOMMU_PGSIZES, .def_domain_type = amd_iommu_def_domain_type,
drivers/iommu/apple-dart.c +0 -1
@@ -771,7 +771,6 @@ static const struct iommu_ops apple_dart_iommu_ops = { .of_xlate = apple_dart_of_xlate, .def_domain_type = apple_dart_def_domain_type, .get_resv_regions = apple_dart_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .pgsize_bitmap = -1UL, /* Restricted during dart probe */ .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = apple_dart_attach_dev,
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +0 -1
@@ -2847,7 +2847,6 @@ static struct iommu_ops arm_smmu_ops = { .device_group = arm_smmu_device_group, .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .dev_enable_feat = arm_smmu_dev_enable_feature, .dev_disable_feat = arm_smmu_dev_disable_feature, .sva_bind = arm_smmu_sva_bind,
drivers/iommu/arm/arm-smmu/arm-smmu.c +0 -1
@@ -1589,7 +1589,6 @@ static struct iommu_ops arm_smmu_ops = { .device_group = arm_smmu_device_group, .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .def_domain_type = arm_smmu_def_domain_type, .pgsize_bitmap = -1UL, /* Restricted during device attach */ .owner = THIS_MODULE,
drivers/iommu/intel/iommu.c +0 -1
@@ -4875,7 +4875,6 @@ const struct iommu_ops intel_iommu_ops = { .probe_finalize = intel_iommu_probe_finalize, .release_device = intel_iommu_release_device, .get_resv_regions = intel_iommu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .device_group = intel_iommu_device_group, .dev_enable_feat = intel_iommu_dev_enable_feat, .dev_disable_feat = intel_iommu_dev_disable_feat,
drivers/iommu/iommu.c +1 -19
@@ -2584,31 +2584,13 @@ void iommu_get_resv_regions(struct device *dev, struct list_head *list) }void iommu_put_resv_regions (struct device *dev,struct list_head *list) -{ -const struct iommu_ops *ops =dev_iommu_ops (dev); - -if (ops->put_resv_regions) - ops->put_resv_regions (dev, list); -} - -/** -* generic_iommu_put_resv_regions - Reserved region driver helper -* @dev: device for which to free reserved regions -* @list: reserved region list for device -* -* IOMMU drivers can use this to implement their .put_resv_regions() callback -* for simple reservations. Memory allocated for each reserved region will be -* freed. If an IOMMU driver allocates additional resources per region, it is -* going to have to implement a custom callback. -*/ -void generic_iommu_put_resv_regions (struct device *dev,struct list_head *list) {struct iommu_resv_region *entry, *next;list_for_each_entry_safe (entry, next, list, list)kfree (entry); } -EXPORT_SYMBOL (generic_iommu_put_resv_regions); +EXPORT_SYMBOL (iommu_put_resv_regions); struct iommu_resv_region *iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot,
drivers/iommu/mtk_iommu.c +0 -1
@@ -688,7 +688,6 @@ static const struct iommu_ops mtk_iommu_ops = { .device_group = mtk_iommu_device_group, .of_xlate = mtk_iommu_of_xlate, .get_resv_regions = mtk_iommu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) {
drivers/iommu/virtio-iommu.c +2 -3
@@ -964,7 +964,7 @@ static struct iommu_device *viommu_probe_device(struct device *dev)return &viommu->iommu; err_free_dev: -generic_iommu_put_resv_regions (dev, &vdev->resv_regions); +iommu_put_resv_regions (dev, &vdev->resv_regions);kfree (vdev);return ERR_PTR (ret);
@@ -989,7 +989,7 @@ static void viommu_release_device(struct device *dev) vdev =dev_iommu_priv_get (dev); -generic_iommu_put_resv_regions (dev, &vdev->resv_regions); +iommu_put_resv_regions (dev, &vdev->resv_regions);kfree (vdev); }
@@ -1013,7 +1013,6 @@ static struct iommu_ops viommu_ops = { .release_device = viommu_release_device, .device_group = viommu_device_group, .get_resv_regions = viommu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .of_xlate = viommu_of_xlate, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) {
include/linux/iommu.h +0 -4
@@ -198,7 +198,6 @@ struct iommu_iotlb_gather {* group and attached to the groups domain * @device_group: find iommu group for a particular device * @get_resv_regions: Request list of reserved regions for a device -* @put_resv_regions: Free list of reserved regions for a device * @of_xlate: add OF master IDs to iommu grouping * @is_attach_deferred: Check if domain attach should be deferred from iommu * driver init to device driver init (default no)
@@ -229,7 +228,6 @@ struct iommu_ops {/* Request/Free a list of reserved regions for a device */ void (*get_resv_regions)(struct device *dev,struct list_head *list); -void (*put_resv_regions)(struct device *dev,struct list_head *list);int (*of_xlate)(struct device *dev,struct of_phandle_args *args);bool (*is_attach_deferred)(struct device *dev);
@@ -445,8 +443,6 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain,extern void iommu_get_resv_regions (struct device *dev,struct list_head *list);extern void iommu_put_resv_regions (struct device *dev,struct list_head *list); -extern void generic_iommu_put_resv_regions (struct device *dev, -struct list_head *list);extern void iommu_set_default_passthrough (bool cmd_line);extern void iommu_set_default_translated (bool cmd_line);extern bool iommu_default_passthrough (void );
Signature · 6 lines
2.30.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
RE: [PATCH 3/4] iommu: remove the put_resv_regions method
Quoted 7 lines
From: Christoph Hellwig
Sent: Thursday, April 7, 2022 2:26 PMAll drivers that implement
get_resv_regionsjust usegeneric_put_resv_regionsto implement the put side. Remove the indirections and document the allocations constraints.
Looks no document after removal:
Quoted 14 lines
void
iommu_put_resv_regions(struct device *dev, struct list_head *list)drivers/iommu/iommu.c +0
-13-{ -const struct iommu_ops *ops =dev_iommu_ops (dev); - -if (ops->put_resv_regions) - ops->put_resv_regions (dev, list); -} - -/** -* generic_iommu_put_resv_regions - Reserved region driver helper -* @dev: device for which to free reserved regions -* @list: reserved region list for device -* -* IOMMU drivers can use this to implement their .put_resv_regions()
Quoted 8 lines
callback
- * for simple reservations. Memory allocated for each reserved region will be
- * freed. If an IOMMU driver allocates additional resources per region, it is
- * going to have to implement a custom callback.
- */
-voidgeneric_iommu_put_resv_regions(struct device *dev, struct list_head *list)
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Robin Murphy
reviewerRe: [PATCH 3/4] iommu: remove the put_resv_regions method
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
All drivers that implement
get_resv_regionsjust usegeneric_put_resv_regionsto implement the put side. Remove the indirections and document the allocations constraints.
Unfortunately we need to keep this one for now, as the belated IORT RMR support will finally be the first real user[1][2].
Robin.
[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/linux-iommu/[email protected]/
Quoted 173 lines
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/iommu/amd/iommu.c | 1 - drivers/iommu/apple-dart.c | 1 - drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 - drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 - drivers/iommu/intel/iommu.c | 1 - drivers/iommu/iommu.c | 20 +------------------- drivers/iommu/mtk_iommu.c | 1 - drivers/iommu/virtio-iommu.c | 5 ++--- include/linux/iommu.h | 4 ---- 9 files changed, 3 insertions(+), 32 deletions(-)drivers/iommu/amd/iommu.c +0
-1@@ -2279,7 +2279,6 @@ const struct iommu_ops amd_iommu_ops = { .probe_finalize = amd_iommu_probe_finalize, .device_group = amd_iommu_device_group, .get_resv_regions = amd_iommu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .is_attach_deferred = amd_iommu_is_attach_deferred, .pgsize_bitmap = AMD_IOMMU_PGSIZES, .def_domain_type = amd_iommu_def_domain_type,drivers/iommu/apple-dart.c +0
-1@@ -771,7 +771,6 @@ static const struct iommu_ops apple_dart_iommu_ops = { .of_xlate = apple_dart_of_xlate, .def_domain_type = apple_dart_def_domain_type, .get_resv_regions = apple_dart_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .pgsize_bitmap = -1UL, /* Restricted during dart probe */ .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = apple_dart_attach_dev,drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +0
-1@@ -2847,7 +2847,6 @@ static struct iommu_ops arm_smmu_ops = { .device_group = arm_smmu_device_group, .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .dev_enable_feat = arm_smmu_dev_enable_feature, .dev_disable_feat = arm_smmu_dev_disable_feature, .sva_bind = arm_smmu_sva_bind,drivers/iommu/arm/arm-smmu/arm-smmu.c +0
-1@@ -1589,7 +1589,6 @@ static struct iommu_ops arm_smmu_ops = { .device_group = arm_smmu_device_group, .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .def_domain_type = arm_smmu_def_domain_type, .pgsize_bitmap = -1UL, /* Restricted during device attach */ .owner = THIS_MODULE,drivers/iommu/intel/iommu.c +0
-1@@ -4875,7 +4875,6 @@ const struct iommu_ops intel_iommu_ops = { .probe_finalize = intel_iommu_probe_finalize, .release_device = intel_iommu_release_device, .get_resv_regions = intel_iommu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .device_group = intel_iommu_device_group, .dev_enable_feat = intel_iommu_dev_enable_feat, .dev_disable_feat = intel_iommu_dev_disable_feat,drivers/iommu/iommu.c +1
-19@@ -2584,31 +2584,13 @@ void iommu_get_resv_regions(struct device *dev, struct list_head *list) }void iommu_put_resv_regions (struct device *dev,struct list_head *list) -{ -const struct iommu_ops *ops =dev_iommu_ops (dev); - -if (ops->put_resv_regions) - ops->put_resv_regions (dev, list); -} - -/** -* generic_iommu_put_resv_regions - Reserved region driver helper -* @dev: device for which to free reserved regions -* @list: reserved region list for device -* -* IOMMU drivers can use this to implement their .put_resv_regions() callback -* for simple reservations. Memory allocated for each reserved region will be -* freed. If an IOMMU driver allocates additional resources per region, it is -* going to have to implement a custom callback. -*/ -void generic_iommu_put_resv_regions (struct device *dev,struct list_head *list) {struct iommu_resv_region *entry, *next;list_for_each_entry_safe (entry, next, list, list)kfree (entry); } -EXPORT_SYMBOL (generic_iommu_put_resv_regions); +EXPORT_SYMBOL (iommu_put_resv_regions); struct iommu_resv_region *iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot,drivers/iommu/mtk_iommu.c +0
-1@@ -688,7 +688,6 @@ static const struct iommu_ops mtk_iommu_ops = { .device_group = mtk_iommu_device_group, .of_xlate = mtk_iommu_of_xlate, .get_resv_regions = mtk_iommu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) {drivers/iommu/virtio-iommu.c +2
-3@@ -964,7 +964,7 @@ static struct iommu_device *viommu_probe_device(struct device *dev)return &viommu->iommu; err_free_dev: -generic_iommu_put_resv_regions (dev, &vdev->resv_regions); +iommu_put_resv_regions (dev, &vdev->resv_regions);kfree (vdev);return ERR_PTR (ret);@@ -989,7 +989,7 @@ static void viommu_release_device(struct device *dev) vdev =dev_iommu_priv_get (dev); -generic_iommu_put_resv_regions (dev, &vdev->resv_regions); +iommu_put_resv_regions (dev, &vdev->resv_regions);kfree (vdev); }@@ -1013,7 +1013,6 @@ static struct iommu_ops viommu_ops = { .release_device = viommu_release_device, .device_group = viommu_device_group, .get_resv_regions = viommu_get_resv_regions, - .put_resv_regions = generic_iommu_put_resv_regions, .of_xlate = viommu_of_xlate, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) {include/linux/iommu.h +0
-2@@ -198,7 +198,6 @@ struct iommu_iotlb_gather {* group and attached to the groups domain * @device_group: find iommu group for a particular device * @get_resv_regions: Request list of reserved regions for a device -* @put_resv_regions: Free list of reserved regions for a device * @of_xlate: add OF master IDs to iommu grouping * @is_attach_deferred: Check if domain attach should be deferred from iommu * driver init to device driver init (default no) @@ -229,7 +228,6 @@ struct iommu_ops {/* Request/Free a list of reserved regions for a device */ void (*get_resv_regions)(struct device *dev,struct list_head *list); -void (*put_resv_regions)(struct device *dev,struct list_head *list);int (*of_xlate)(struct device *dev,struct of_phandle_args *args);bool (*is_attach_deferred)(struct device *dev);
include/linux/iommu.h extern void iommu_set_fault_handler(struct iommu_domain *domain, · line 448
Quoted 8 lines
include/linux/iommu.h +0
-2@@ -445,8 +443,6 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain,extern void iommu_get_resv_regions (struct device *dev,struct list_head *list);extern void iommu_put_resv_regions (struct device *dev,struct list_head *list); -extern void generic_iommu_put_resv_regions (struct device *dev, -struct list_head *list);extern void iommu_set_default_passthrough (bool cmd_line);extern void iommu_set_default_translated (bool cmd_line);extern bool iommu_default_passthrough (void );
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 3/4] iommu: remove the put_resv_regions method
Quoted 8 lines · Robin Murphy
Quoted 3 lines · Christoph Hellwig
All drivers that implement
get_resv_regionsjust usegeneric_put_resv_regionsto implement the put side. Remove the indirections and document the allocations constraints.Unfortunately we need to keep this one for now, as the belated IORT RMR support will finally be the first real user[1][2].
Quoted 6 lines
Robin.
[1]
https://lore.kernel.org/linux-iommu/[email protected]/
[2]
https://lore.kernel.org/linux-iommu/[email protected]/
What these patches to looks wrong to me. I'll comment there.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 4/4 iommu/arm-smmu-v3: cleanup arm_smmu_dev_{enable, disable}_feature
In reply to Christoph HellwigFold the arm_smmu_dev_has_feature arm_smmu_dev_feature_enabled into the main methods.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 57 ++++++--------------- 1 file changed, 15 insertions(+), 42 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +15 -42
@@ -2760,58 +2760,27 @@ static void arm_smmu_get_resv_regions(struct device *dev,iommu_dma_get_resv_regions (dev, head); } -static bool arm_smmu_dev_has_feature (struct device *dev, -enum iommu_dev_features feat) -{ -struct arm_smmu_master *master =dev_iommu_priv_get (dev); - -if (!master) -return false; - -switch (feat) { -case IOMMU_DEV_FEAT_IOPF : -return arm_smmu_master_iopf_supported (master); -case IOMMU_DEV_FEAT_SVA : -return arm_smmu_master_sva_supported (master); -default : -return false; - } -} - -static bool arm_smmu_dev_feature_enabled (struct device *dev, -enum iommu_dev_features feat) -{ -struct arm_smmu_master *master =dev_iommu_priv_get (dev); - -if (!master) -return false; - -switch (feat) { -case IOMMU_DEV_FEAT_IOPF : -return master->iopf_enabled; -case IOMMU_DEV_FEAT_SVA : -return arm_smmu_master_sva_enabled (master); -default : -return false; - } -} -static int arm_smmu_dev_enable_feature (struct device *dev,enum iommu_dev_features feat) {struct arm_smmu_master *master =dev_iommu_priv_get (dev); -if (!arm_smmu_dev_has_feature (dev, feat)) -return -ENODEV ; - -if (arm_smmu_dev_feature_enabled (dev, feat)) -return -EBUSY ; +if (!master) +return -EINVAL ;switch (feat) {case IOMMU_DEV_FEAT_IOPF : +if (!arm_smmu_master_iopf_supported (master)) +return -EINVAL ; +if (master->iopf_enabled) +return -EBUSY ; master->iopf_enabled = true;return 0 ;case IOMMU_DEV_FEAT_SVA : +if (!arm_smmu_master_sva_supported (master)) +return -EINVAL ; +if (arm_smmu_master_sva_enabled (master)) +return -EBUSY ;return arm_smmu_master_enable_sva (master);default :return -EINVAL ;
@@ -2823,16 +2792,20 @@ static int arm_smmu_dev_disable_feature(struct device *dev, {struct arm_smmu_master *master =dev_iommu_priv_get (dev); -if (!arm_smmu_dev_feature_enabled (dev, feat)) +if (!master)return -EINVAL ;switch (feat) {case IOMMU_DEV_FEAT_IOPF : +if (!master->iopf_enabled) +return -EINVAL ;if (master->sva_enabled)return -EBUSY ; master->iopf_enabled = false;return 0 ;case IOMMU_DEV_FEAT_SVA : +if (!arm_smmu_master_sva_enabled (master)) +return -EINVAL ;return arm_smmu_master_disable_sva (master);default :return -EINVAL ;
Signature · 6 lines
2.30.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
RE: [PATCH 4/4] iommu/arm-smmu-v3: cleanup arm_smmu_dev_{enable, disable}_feature
Quoted 60 lines
From: Christoph Hellwig
Sent: Thursday, April 7, 2022 2:26 PMFold the
arm_smmu_dev_has_featurearm_smmu_dev_feature_enabledinto
the main methods.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 57 ++++++--------------- 1 file changed, 15 insertions(+), 42 deletions(-)drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +0
-36@@ -2760,58 +2760,27 @@ static void arm_smmu_get_resv_regions(structdevice *dev,iommu_dma_get_resv_regions (dev ,head ); } -static bool arm_smmu_dev_has_feature (struct device *dev, -enum iommu_dev_features feat) -{ -struct arm_smmu_master *master =dev_iommu_priv_get (dev); - -if (!master) -return false; - -switch (feat) { -case IOMMU_DEV_FEAT_IOPF : -return arm_smmu_master_iopf_supported (master); -case IOMMU_DEV_FEAT_SVA : -return arm_smmu_master_sva_supported (master); -default : -return false; - } -} - -static bool arm_smmu_dev_feature_enabled (struct device *dev, -enum iommu_dev_features feat) -{ -struct arm_smmu_master *master =dev_iommu_priv_get (dev); - -if (!master) -return false; - -switch (feat) { -case IOMMU_DEV_FEAT_IOPF : -return master->iopf_enabled; -case IOMMU_DEV_FEAT_SVA : -return arm_smmu_master_sva_enabled (master); -default : -return false; - } -} -static int arm_smmu_dev_enable_feature (struct device *dev,enum iommu_dev_features feat)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c static void arm_smmu_get_resv_regions(struct · line 2770
Quoted 10 lines
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +2
-5{struct arm_smmu_master *master =dev_iommu_priv_get (dev); -if (!arm_smmu_dev_has_feature (dev, feat)) -return -ENODEV ; - -if (arm_smmu_dev_feature_enabled (dev, feat)) -return -EBUSY ; +if (!master) +return -EINVAL ;
Old logic returns -ENODEV but it's changed to -EINVAL here. Is it intended? If yes, probably mention it in the patch description though just a small semantics change.
Quoted 43 lines
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +13
-1switch (feat) {case IOMMU_DEV_FEAT_IOPF : +if (!arm_smmu_master_iopf_supported (master)) +return -EINVAL ; +if (master->iopf_enabled) +return -EBUSY ; master->iopf_enabled = true;return 0 ;case IOMMU_DEV_FEAT_SVA : +if (!arm_smmu_master_sva_supported (master)) +return -EINVAL ; +if (arm_smmu_master_sva_enabled (master)) +return -EBUSY ;return arm_smmu_master_enable_sva (master);default :return -EINVAL ;@@ -2823,16 +2792,20 @@ static int arm_smmu_dev_disable_feature(struct device *dev, {struct arm_smmu_master *master =dev_iommu_priv_get (dev); -if (!arm_smmu_dev_feature_enabled (dev, feat)) +if (!master)return -EINVAL ;switch (feat) {case IOMMU_DEV_FEAT_IOPF : +if (!master->iopf_enabled) +return -EINVAL ;if (master->sva_enabled)return -EBUSY ; master->iopf_enabled = false;return 0 ;case IOMMU_DEV_FEAT_SVA : +if (!arm_smmu_master_sva_enabled (master)) +return -EINVAL ;return arm_smmu_master_disable_sva (master);default :return
-EINVAL;
--
2.30.2
Quoted 4 lines
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Joerg Roedel
maintainerQuoted 6 lines · Christoph Hellwig
Hi all,
this removes a bit of dead code and methods from the iommu code and the cleans up the arm-smmu-v3 driver a little bit based on that.
Diffstat:
Quoted 10 lines
drivers/iommu/amd/iommu.c | 1 drivers/iommu/apple-dart.c | 1 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 60 +++++++--------------------- drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 drivers/iommu/intel/iommu.c | 1 drivers/iommu/iommu.c | 33 --------------- drivers/iommu/mtk_iommu.c | 1 drivers/iommu/virtio-iommu.c | 5 -- include/linux/iommu.h | 17 ------- 9 files changed, 19 insertions(+), 101 deletions(-)
This concerns mostly arm-smmu, please also Cc Will Deacon on this one.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu