Received: by 10.213.65.68 with SMTP id h4csp1242815imn; Mon, 26 Mar 2018 03:55:07 -0700 (PDT) X-Google-Smtp-Source: AG47ELvMxXWhjiKxPACGsE4Miad9MZt6LWwzr5qs/p0Q3OG1NfewZsOuJHotJ9+/kctveqKcPR+i X-Received: by 10.99.64.131 with SMTP id n125mr22064343pga.303.1522061707498; Mon, 26 Mar 2018 03:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522061707; cv=none; d=google.com; s=arc-20160816; b=dChX6i9YL/pH2r6jQuXJyFOqDtsdleJW5xfiq+3BUcGTuSNhs8Ru0PSxkkQhYWf7AN x9oWg0OGX0FQnu7VffiFAK6qhnKPaZ9vYImFVq9VyDgM51Ym9tBGHWbmBfvRpqAqeAIn kPg4Y/jOuVQDUMHGBadeNG6Dcj3V+EqvJsXPO2xpaAHyO2MOWqd1hpcfB1ZdNRrfbzQy 80oGFMOgo6U8SUCBiXUQrrEM0m0hpWcvT8QR91wj/cuOYl1X3TvuY6RNqj+RoxkTlhgA +Zy2lEcm1aWke6CHi6sMPbq8plR59F0hfiG1IzO8Pvc4MYyyi+zaKFPAS1oU2Zn411vL gKmg== 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=Krtu540OU7Ij4sHyVli8AsM1nVWz0Y+HmLGNew6d6m0=; b=NpNb9/7ltdruR6UA/vo2GpBaBqjp6iAnGzxFEdSJJMdlrDAp+kbT4vQ8e3l3SI8Dvz Nq6RnjIwboFnWVDkWUeX601Rh0RTP4fM8OfwutLlST0JYC9aJALzXAWWRFu1geAYc2KT Szf8qat74as+NQlJ/qvybLjV/fqUkliBnPBhbRwhdjfUJfsLZK/6F5y4hpmUsslefhn9 WT4ITNBOY41KEh6gOC4fuLXj6//Fr5gdVMVfjNF+mQedjnHf3Mp/VlW/YyzMkpTqUAyT 77jXDbxSmYsLAOFAPkQBh+haFDllUyaGBR5wuQjIOI76cYA1DuTL0ozl56Pzn1LMdEis a6Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=inq9Vxb0; 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 b35-v6si15003139plh.84.2018.03.26.03.54.40; Mon, 26 Mar 2018 03:55:07 -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=inq9Vxb0; 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 S1751138AbeCZKxJ (ORCPT + 99 others); Mon, 26 Mar 2018 06:53:09 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:33336 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750989AbeCZKxG (ORCPT ); Mon, 26 Mar 2018 06:53:06 -0400 Received: by mail-qk0-f194.google.com with SMTP id d206so7182737qkb.0; Mon, 26 Mar 2018 03:53:05 -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=Krtu540OU7Ij4sHyVli8AsM1nVWz0Y+HmLGNew6d6m0=; b=inq9Vxb0rDyKwSb59ycpOP1+jx6/FSIg4h7aWlIEoe13FXo8AumrbJiVVeLsBWI6bA 1idWu1WvoucyCPOQMFpfYSsVeY1jvKtDzpWXyyfpHt+YktBQczUzjFCc3deVHn+K/UzC QPmVnvhwoZkD6PCaHgBpDfS+0X2bx6NhDk6sGn0Cz8WiJSFvgrQaLwBR5k6DlDAvukiR /RkHyorSTjUTP7Ym83FDdacn6q3nPi5rDmqgzyMoSuYKVWdUzGzC5u5vkRrc5AZgZ7OV 2fqrI3K9jf0jiBa8YwCvifM+bD8RtgFJ0MMB/kagL6EtJ/VZyReWoxP8K11lDqEQf6TU 1Cqw== 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=Krtu540OU7Ij4sHyVli8AsM1nVWz0Y+HmLGNew6d6m0=; b=Zy5BZ/8NpTSXI4Yk1JPKanark+AjEnvQfvq1y+1DIUXCYRlb8BHznYy8hOV4iDGObu ZegxooK2BHCKU/3ay7O4TW06GZPCNiz4IQ0kr+PNw+nl+NTQU11edrPsMc05AmTYytiK 5zNb4eKe1DiWuRcZmZ9xL4LHkyZ+xcWb+MLfRiZ/rY8sSQgpfHfHsbfJYPnOFIphS0tx tsC+DGQnfxT7lEorWQumpwDbkxW1sGaRczMX+dSqlcPHrM9//ewmfQD0B9wSe65i63x8 jKsTH2hRge6mxCa6Wmr2F/hZ3WW4SN2jRYRsz68M+9jnHjDMesCbdLwlHUsTiDOwsxLA pxeA== X-Gm-Message-State: AElRT7GRy+0yhgnkO+QUP+b7IaWZldRjPjV4YHKC7unfZ7Ynpw1fU5ao MgPgHfX/lrGaBAHQXt8/eqHYUtjo8tOXBn4fGDQ= X-Received: by 10.55.158.137 with SMTP id h131mr52630549qke.330.1522061585306; Mon, 26 Mar 2018 03:53:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.185.25 with HTTP; Mon, 26 Mar 2018 03:53:04 -0700 (PDT) In-Reply-To: <20180321163745.12286-2-logang@deltatee.com> References: <20180321163745.12286-1-logang@deltatee.com> <20180321163745.12286-2-logang@deltatee.com> From: Arnd Bergmann Date: Mon, 26 Mar 2018 12:53:04 +0200 X-Google-Sender-Auth: 1lf-MGwxnQGSplaGg0ZEPPguZPc 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 Wed, Mar 21, 2018 at 5:37 PM, Logan Gunthorpe wrote: > The semantics of the iowriteXXbe() functions are to write a > value in CPU endianess to an IO register that is known by the > caller to be in Big Endian. The mmio_writeXXbe() macro, which > is called by iowriteXXbe(), should therefore use cpu_to_beXX() > instead of beXX_to_cpu(). > > Seeing both beXX_to_cpu() and cpu_to_beXX() are both functionally > implemented as either null operations or swabXX operations there > was no noticable bug here. But it is confusing for both developers > and code analysis tools alike. > > Signed-off-by: Logan Gunthorpe Your patch is a clear improvement of what we had before, but I notice that we have a weird asymmetry between big-endian and little-endian accessors before and after this patch: void iowrite32(u32 val, void __iomem *addr) { IO_COND(addr, outl(val,port), writel(val, addr)); } void iowrite32be(u32 val, void __iomem *addr) { IO_COND(addr, pio_write32be(val,port), mmio_write32be(val, addr)); } The little-endian iowrite32() when applied to mmio registers uses a 32-bit wide atomic store to a little-endian register with barriers to order against both spinlocks and DMA. The big-endian iowrite32be() on the same pointer uses a nonatomic store with no barriers whatsoever and the opposite endianess. 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? Arnd