Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752278AbaFFKzk (ORCPT ); Fri, 6 Jun 2014 06:55:40 -0400 Received: from mailout32.mail01.mtsvc.net ([216.70.64.70]:33087 "EHLO n23.mail01.mtsvc.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751541AbaFFKzj (ORCPT ); Fri, 6 Jun 2014 06:55:39 -0400 Message-ID: <53919E24.3010206@hurleysoftware.com> Date: Fri, 06 Jun 2014 06:55:32 -0400 From: Peter Hurley User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Pranith Kumar , Pranith Kumar , dwmw2@infradead.org, joro@8bytes.org CC: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] use documented cmpxchg api References: <5390ED07.2070009@gatech.edu> <53910C95.7000808@hurleysoftware.com> <5391136C.3010809@gmail.com> In-Reply-To: <5391136C.3010809@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-User: 990527 peter@hurleysoftware.com X-MT-ID: 8FA290C2A27252AACF65DBC4A42F3CE3735FB2A4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/05/2014 09:03 PM, Pranith Kumar wrote: > 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 >>> --- >>> 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. This won't work either, and should generate a compile or link error on CONFIG_X86_32. The auto-sizing done by __cmpxchg() does not substitute the cmpxchg8b instruction for the cmpxchg instruction. __X86_CASE_Q is defined as -1 for CONFIG_X86_32 so the 8-byte size variant is dead-code, and calls __cmpxchg_wrong_size() instead. > 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 > --- > 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 > } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/