Skip to content

Commit 96bff7e

Browse files
ubizjakgregkh
authored andcommitted
iommu/amd: Use atomic64_inc_return() in iommu.c
commit 5ce73c5 upstream. Use atomic64_inc_return(&ref) instead of atomic64_add_return(1, &ref) to use optimized implementation and ease register pressure around the primitive for targets that implement optimized variant. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Cc: Will Deacon <will@kernel.org> Cc: Robin Murphy <robin.murphy@arm.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20241007084356.47799-1-ubizjak@gmail.com Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Salvatore Bonaccorso <carnil@debian.org> Stable-dep-of: 9e249c4 ("iommu/amd: serialize sequence allocation under concurrent TLB invalidations") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 06c19c9 commit 96bff7e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/iommu/amd/iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
12661266
if (!iommu->need_sync)
12671267
return 0;
12681268

1269-
data = atomic64_add_return(1, &iommu->cmd_sem_val);
1269+
data = atomic64_inc_return(&iommu->cmd_sem_val);
12701270
build_completion_wait(&cmd, iommu, data);
12711271

12721272
raw_spin_lock_irqsave(&iommu->lock, flags);
@@ -2929,7 +2929,7 @@ static void iommu_flush_irt_and_complete(struct amd_iommu *iommu, u16 devid)
29292929
return;
29302930

29312931
build_inv_irt(&cmd, devid);
2932-
data = atomic64_add_return(1, &iommu->cmd_sem_val);
2932+
data = atomic64_inc_return(&iommu->cmd_sem_val);
29332933
build_completion_wait(&cmd2, iommu, data);
29342934

29352935
raw_spin_lock_irqsave(&iommu->lock, flags);

0 commit comments

Comments
 (0)