Skip to contentSkip to conversation

powerpc/iommu: Refactor spapr_tce_platform_iommu_attach_dev()

PATCH Applied Shivaprasad G Bhat 2 participants 2 messages Feb 15, 2024 – Apr 22, 2024 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/iommu: Refactor spapr_tce_platform_iommu_attach_dev()

The patch makes the iommu_group_get() call only when using it thereby avoiding the unnecessary get & put for domain already being set case.

---
Changelog:
v2: https://lore.kernel.org/linux-iommu/[email protected]/
- As the v1 itself was merged, the patch was suggested to be reposted as cleanup/refactoring to be applied on top of v1.
- Removed the versioning as this is actually new cleanup/refactoring.
- Retaining the Reviewed-by as the effective new code was actually reviewed.

v1: https://lore.kernel.org/all/[email protected]/
- Minor refactor to call the iommu_get_group only if required.
- Updated the title, description and signature(Closes/Reported-by).

 arch/powerpc/kernel/iommu.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/powerpc/kernel/iommu.c +3 -4
index a9bebfd56b3b..37fae3bd89c6 100644
@@ -1285,15 +1285,14 @@ spapr_tce_platform_iommu_attach_dev(struct iommu_domain *platform_domain,
 				    struct device *dev)
 {
 	struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
-	struct iommu_group *grp = iommu_group_get(dev);
 	struct iommu_table_group *table_group;
+	struct iommu_group *grp;
 
 	/* At first attach the ownership is already set */
-	if (!domain) {
-		iommu_group_put(grp);
+	if (!domain)
 		return 0;
-	}
 
+	grp = iommu_group_get(dev);
 	table_group = iommu_group_get_iommudata(grp);
 	/*
 	 * The domain being set to PLATFORM from earlier