Commit 5ce73c52 authored by Uros Bizjak's avatar Uros Bizjak Committed by Joerg Roedel
Browse files

iommu/amd: Use atomic64_inc_return() in iommu.c



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: default avatarUros 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: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20241007084356.47799-1-ubizjak@gmail.com


Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 8e929cb5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1230,7 +1230,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
	if (!iommu->need_sync)
		return 0;

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

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

	build_inv_irt(&cmd, devid);
	data = atomic64_add_return(1, &iommu->cmd_sem_val);
	data = atomic64_inc_return(&iommu->cmd_sem_val);
	build_completion_wait(&cmd2, iommu, data);

	raw_spin_lock_irqsave(&iommu->lock, flags);