Re: [PATCH 1/1] use documented cmpxchg api
From: Pranith Kumar
Date: Thu Jun 05 2014 - 21:03:48 EST
On 06/05/2014 08:34 PM, Peter Hurley wrote:
> On 06/05/2014 06:19 PM, Pranith Kumar wrote:
>> use the documented atomic_cmpxchg instead of __cmpxchg64
>>
>> This kills the last user of said API in drivers code.
>>
>>
>> Signed-off-by: Pranith Kumar <bobby.prani@xxxxxxxxx>
>> ---
>> drivers/iommu/intel-iommu.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
>> index 6bb3277..270113f 100644
>> --- a/drivers/iommu/intel-iommu.c
>> +++ b/drivers/iommu/intel-iommu.c
>> @@ -293,7 +293,7 @@ static inline u64 dma_pte_addr(struct dma_pte *pte)
>> return pte->val & VTD_PAGE_MASK;
>> #else
>> /* Must have a full atomic 64-bit read */
>> - return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK;
>> + return atomic_cmpxchg(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK;
>
> This is not equivalent.
>
> The __cmpxchg64() is specifically being used in this case
> when !CONFIG_64BIT for a full 64-bit RMW, whereas atomic_cmpxchg()
> uses ints which would be 32-bit RMW.
>
You are right! The previous patch is wrong in that atomic_cmpxchg needs an atomic_t argument.
cmpxchg() handles the size internally using typeof() to figure out the width of RMW.
There is also an explicit cmpxchg64() which does the same thing.
Fixed with the following v2:
use the documented cmpxchg instead of __cmpxchg64
This kills the last user of said API in drivers code.
Signed-off-by: Pranith Kumar <bobby.prani@xxxxxxxxx>
---
drivers/iommu/intel-iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 6bb3277..270113f 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -293,7 +293,7 @@ static inline u64 dma_pte_addr(struct dma_pte *pte)
return pte->val & VTD_PAGE_MASK;
#else
/* Must have a full atomic 64-bit read */
- return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK;
+ return cmpxchg(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK;
#endif
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/