From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 408zQK6q61zF22B for ; Tue, 27 Mar 2018 03:00:56 +1100 (AEDT) Subject: Re: RFC on writel and writel_relaxed To: Arnd Bergmann Cc: Oliver , "linux-rdma@vger.kernel.org" , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" References: <3611eabe-2999-1482-b2b4-6d216bbe4762@codeaurora.org> <4e5c745a-8b9b-959e-8893-d99cd6032484@codeaurora.org> <2d2a744a-57b2-ca42-db40-4705df0375db@codeaurora.org> From: Sinan Kaya Message-ID: <4b1004a8-2d8b-681f-3050-a1365cfb8321@codeaurora.org> Date: Mon, 26 Mar 2018 12:00:52 -0400 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On 3/26/2018 9:43 AM, Arnd Bergmann wrote: > On Wed, Mar 21, 2018 at 2:58 PM, Sinan Kaya wrote: >> On 3/21/2018 8:53 AM, Sinan Kaya wrote: >>> BTW, I have no idea what compiler barrier does on PPC and if >>> >>> wrltel() == compiler barrier() + wrltel_relaxed() >>> >>> can be said. >> >> this should have been >> >> writel_relaxed() == compiler barrier() + __raw_writel() > > I don't think anyone clarified this so far, but there are additional differences > between the two, writel_relaxed() assumes we are talking to a 32-bit > little-endian > MMIO register, while __raw_writel() is primarily used for writing into > memory-type > regions with no particular byte order. This means: > > - writel_relaxed() must perform a byte swap when running on big-endian kernels > - when used with __packed MMIO pointers, __raw_writel() may turn into a series > of byte writes, while writel_relaxed() must result in a single 32-bit access. > - A set if consecutive writel_relaxed() on the same device is issued in program > order, while __raw_writel() is not ordered. This typically requires > only a compiler > barrier, but may also need a CPU barrier (in addition to the > barriers we use to > serialize with spinlocks and DMA in writel() but not writel_relaxed()). Thanks for the great summary. I didn't know that __raw_writel() could get converted to byte writes. > > Arnd > -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.