[PATCH 1/4] iommu/amd: clean up the cmpxchg64 invocation

2016-09-15 Thread Baoquan He
Change it as it's designed for and keep it consistent with other
places.

Signed-off-by: Baoquan He 
---
 drivers/iommu/amd_iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 96de97a..160fc6a 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1274,7 +1274,8 @@ static u64 *alloc_pte(struct protection_domain *domain,
 
__npte = PM_LEVEL_PDE(level, virt_to_phys(page));
 
-   if (cmpxchg64(pte, __pte, __npte)) {
+   /* pte could have been changed somewhere. */
+   if (cmpxchg64(pte, __pte, __npte) != __pte) {
free_page((unsigned long)page);
continue;
}
-- 
2.5.5



[PATCH 1/4] iommu/amd: clean up the cmpxchg64 invocation

2016-09-15 Thread Baoquan He
Change it as it's designed for and keep it consistent with other
places.

Signed-off-by: Baoquan He 
---
 drivers/iommu/amd_iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 96de97a..160fc6a 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1274,7 +1274,8 @@ static u64 *alloc_pte(struct protection_domain *domain,
 
__npte = PM_LEVEL_PDE(level, virt_to_phys(page));
 
-   if (cmpxchg64(pte, __pte, __npte)) {
+   /* pte could have been changed somewhere. */
+   if (cmpxchg64(pte, __pte, __npte) != __pte) {
free_page((unsigned long)page);
continue;
}
-- 
2.5.5