Received: by 10.213.65.68 with SMTP id h4csp1700061imn; Mon, 26 Mar 2018 12:51:32 -0700 (PDT) X-Google-Smtp-Source: AG47ELt9xxNKpFVvveitluptbrGUMdiPqMSepu+GIAdc6hYWuHd9GmTMP0aTgUKD74YFyp/UX4AB X-Received: by 10.98.226.23 with SMTP id a23mr21210468pfi.157.1522093892838; Mon, 26 Mar 2018 12:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522093892; cv=none; d=google.com; s=arc-20160816; b=byIuJ6DHcBMfe8kHpRkcTJHXQ9eSc0v5j11qutlUYBbyv2kpwlA3TCxzaelEYdR6lI rZsyqlPFUru2/VAlsZzL5EWTS+0cSQsGjRzSHm9og0ADbFnSnRet/69wlF5z8Tu6QtrA xM75JoyJpjQlMwJfE6y9FnIbS9FOr01cxbCAXiahezbSqGA1N+FdGj4MORxcdOnEGhe5 1gjM88jazuorBzyvHRm9JzTDbewFZHGbxcxT1o9LM3JFXJD6XKDUS/eBwVyY1yybtDrG ubQp/7dJtPTwdd/smfVtaVDDmCkaLRXVT1E8JR/5h90auxcZjtVHxl3qyHvTrw6SDxyU WkWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=XsSLFwJG1fVG+jba5n3iz3v3KXe5QpW8Wg3QAhdaZx4=; b=wbwL71L0J/WvX2cfJkBGgLOJsYczq+f0z/Hv/W3hy1HlyBn7BTXh7UAH2q/YKzIm7a lyjo8S8jzZta1oU8WdVHQcdl99f3kEXzYft/gl5+ZMIIFvSO9fI6NmkUZCUX97AJUe9h +lFUuVKYhir25cX7SBnp0Z86oOSZGufG4xPcFyHGvJMC1sZovSj3nnnYCxaHq92gwJJG 9LUI8aBiO6NZy0lqsQ3dkInUJpPSHqCrtN09tA+1XhrpQvlERuVNrn8by81H73GpLY1+ wtNOsb4ZNNpnbF2TUEFNxYEykZHl5+pJ7VMZWO45kMtMiYOrobAEJGitEbnMzATB+QLo 8V7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pTr1KuMm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e93-v6si8353049plk.521.2018.03.26.12.51.17; Mon, 26 Mar 2018 12:51:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pTr1KuMm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751859AbeCZTu0 (ORCPT + 99 others); Mon, 26 Mar 2018 15:50:26 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:37455 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751076AbeCZTuY (ORCPT ); Mon, 26 Mar 2018 15:50:24 -0400 Received: by mail-qt0-f196.google.com with SMTP id w12so13303212qti.4; Mon, 26 Mar 2018 12:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=XsSLFwJG1fVG+jba5n3iz3v3KXe5QpW8Wg3QAhdaZx4=; b=pTr1KuMmOXXeWC4UEyQtnq8umZBUdxuKA0BGG/mhX7u0VvZieQPC/07HgECyXgjXB9 o/V3AZh4gQ4JnzDypHhk0+Mvmq+bcVAeQcrpDJQugB0XEeT49xQdPyrokDzuoowjEqi0 BdeSBdw+jr5ysNA4CTSFYma7lLG90NSrJmXKCaX03magyHpuoQOVzNFf/Z6w9GCQzh6Y NHrESbX1a8nXfq31yYcXDxJ+9oNfFtoJNjQh7ZqbIgWj0xlAWndATWWPDaIAdZhaRd3I zIm1SesACVPXHsNr1tmxvVvu8ij/LxI9RVv14mMGS2vzOiZoqi3sk6Bhhxx1+5rxzZEy Ysjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=XsSLFwJG1fVG+jba5n3iz3v3KXe5QpW8Wg3QAhdaZx4=; b=Ao8saIPRLZUh0PdotH1YQI8LiDnhxbnIajZmpOoVhSl15EaugvQxLLoo4a5gfFx8vt l5WJhWBHisshyY0gFgU/Unh3GEeevWKF18gbyUK2WyiRgkl/CUgZbZc3Lc9es5fYer9/ d8ErihnHdVmq18gYJ7bM1ZClCr9I1/rRfjIv0L/PCnUIEMKHuUdfmZoxirDc7nCjW4FB er7gx6/FoYkQgKGJsCQ/WjRxPns4AO5Q7LbtUYK8Cu5AxcWa9vfFUXe+6/XgXU0IWxUM f18sW1ApAyYK82yOhjL+zRMwf6zOlkEPE2q7W8ltLljAYElPrZUE+7pWTlLb2MzY7hCl Joig== X-Gm-Message-State: AElRT7F40z/UHW/XngXHEAhWJqoHDcy1Niu/Eig3OofGLFk2EN6tRLVY kY24Iy5A4klU5zu1XwD2kOhQ9nTjZmiGwv9LXus= X-Received: by 10.200.68.7 with SMTP id j7mr15980515qtn.132.1522093823664; Mon, 26 Mar 2018 12:50:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.185.25 with HTTP; Mon, 26 Mar 2018 12:50:23 -0700 (PDT) In-Reply-To: <726eb143-2cca-b221-b569-e193a962e357@deltatee.com> References: <20180321163745.12286-1-logang@deltatee.com> <20180321163745.12286-2-logang@deltatee.com> <726eb143-2cca-b221-b569-e193a962e357@deltatee.com> From: Arnd Bergmann Date: Mon, 26 Mar 2018 21:50:23 +0200 X-Google-Sender-Auth: KZFn-GKMyHRRa3lrYATZvaf0S98 Message-ID: Subject: Re: [PATCH v13 01/10] iomap: Use correct endian conversion function in mmio_writeXXbe To: Logan Gunthorpe Cc: Linux Kernel Mailing List , linux-arch , linux-ntb@googlegroups.com, "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Greg Kroah-Hartman , Andy Shevchenko , =?UTF-8?Q?Horia_Geant=C4=83?= , Philippe Ombredanne , Thomas Gleixner , Kate Stewart , Luc Van Oostenryck Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 26, 2018 at 6:21 PM, Logan Gunthorpe wrote: > > > On 26/03/18 04:53 AM, Arnd Bergmann wrote: >> On most architectures, this is not important: >> - For x86, the stores are aways atomic and no additional barriers >> are needed, so the two are the same >> - For ARM (both 32 and 64-bit), powerpc and many others, we don't >> use the generic iowrite() and just fall back to writel() or >> writel(swab32()). >> >> However, shouldn't we just use the writel(swab32()) logic here as well >> for the common case rather than risking missing barriers? > > Hmm, I don't know... it's complicated? > > Doing a bit of digging shows that the existing code was written during a > time when writel() did not include extra barriers over __raw_writel() in > any of the common arches. > > The commit logs don't seem to provide any guidance as to why this it was > done this way, but I'd assume it was done to avoid a double swab() call > on BE arches. Seeing writel() is typically implemented as: > > __raw_writel(__cpu_to_le32(value), addr); > > Then on BE arches, writel(swab32()) would become: > > __raw_writel(swab32(swab32(value)), addr) > > Which seems undesirable. I wouldn't expect it to matter: the byte swap is almost always much cheaper compared to the actual bus access for the MMIO, and I would also guess that modern compilers can eliminate the double byte swap on architectures where writel() is an inline function. Most of the important architectures use ARCH_USE_BUILTIN_BSWAP, which guarantees that. Arnd