aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUros Bizjak <[email protected]>2024-05-22 10:26:47 +0200
committerJoerg Roedel <[email protected]>2024-06-25 14:20:41 +0200
commit9a448e453151ec4e4b98a914b463539e790dd198 (patch)
tree6b5a4f4360f0613d299b2a8c9f49371e6a6c0188
parent83a7eefedc9b56fe7bfeff13b6c7356688ffa670 (diff)
iommu/amd: Use try_cmpxchg64() in v2_alloc_pte()
Use try_cmpxchg64() instead of cmpxchg64 (*ptr, old, new) != old in v2_alloc_pte(). cmpxchg returns success in ZF flag, so this change saves a compare after cmpxchg (and related move instruction in front of cmpxchg). This is the same improvement as implemented for alloc_pte() in: commit 0d10fe759117 ("iommu/amd: Use try_cmpxchg64 in alloc_pte and free_clear_pte") Signed-off-by: Uros Bizjak <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Suravee Suthikulpanit <[email protected]> Cc: Will Deacon <[email protected]> Cc: Robin Murphy <[email protected]> Reviewed-by: Vasant Hegde <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
-rw-r--r--drivers/iommu/amd/io_pgtable_v2.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iommu/amd/io_pgtable_v2.c b/drivers/iommu/amd/io_pgtable_v2.c
index 78ac37c5ccc1..664e91c88748 100644
--- a/drivers/iommu/amd/io_pgtable_v2.c
+++ b/drivers/iommu/amd/io_pgtable_v2.c
@@ -158,7 +158,7 @@ static u64 *v2_alloc_pte(int nid, u64 *pgd, unsigned long iova,
__npte = set_pgtable_attr(page);
/* pte could have been changed somewhere. */
- if (cmpxchg64(pte, __pte, __npte) != __pte)
+ if (!try_cmpxchg64(pte, &__pte, __npte))
iommu_free_page(page);
else if (IOMMU_PTE_PRESENT(__pte))
*updated = true;