Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1052367ybi; Fri, 14 Jun 2019 07:51:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjBuQK81GMvsPog6kWtCtNS/msZz7i3UOWSw8nxFycgGZq3ABXadXVX3wdEdCJBZjzrVVg X-Received: by 2002:a17:90a:37c8:: with SMTP id v66mr11761568pjb.33.1560523906429; Fri, 14 Jun 2019 07:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560523906; cv=none; d=google.com; s=arc-20160816; b=krrhrYpyae99foAc4E6Jyy4/Kiw4wj8lVur4LEP3qzt2JmnHb//CDLhLZv7P3Phg3u mY6/JDfEUMeaLRfTPvm2HwjBYulphuYqw1RbE718Jfnponkqv+WR2E6794xb92/i6jVC IaGFh4NHdV9L1TjfRqPxTV8ki+pD6jHU0S0K3bTW4gqMXInwFg6rZMaVPXXm8hKrC+je hNpa2fb5kOL4eAc1pW45nyEOKMWL1zRdmMU5vV7+0n4Gq3VzDapUAp8YmIxvl3b3OSm3 x+gEqsfiF3pUiOpFxVveZj6F/wzUC6FuqEiHCyIALKP8WXGAouNx5fYsJp4n763knBG8 Qr4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=oIeNUvhjliK6KIzL7q8nMj2q8m3xcZzir0zvDwcAknQ=; b=Fq2yhXl5Th3c+tV5vdE5cWnLv3UZOpdmRQQfEkvfIZ59d2ZgCpwpO2D+mWZozvTqa/ 41QcMHgsWiZ51ez0NiFk8N/0jxqkZAfX2vl14r58JzbpuhT4/aNrp3OcDtFAs+GXxgqe pdO5O676eeXtFNpMkj9MzZjdTtpG8s2+ONPXSUuZDEkrRHNMR1duxPxI6OyUFlttFWnh 6IoKyXTr3FdAQ2AmPBwIyx7pETTtOqU4A2gsLcBHhB3IUnrUGzsLjONYHqCYzLg3OyW/ pKZRgEZ+7OwMyDL0/+LlHC6NDLg+vxL8re5i2RqH0ajdfTRy8ePZc+/+nr/UKCEZHY53 gEcg== ARC-Authentication-Results: i=1; mx.google.com; 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 12si2500650pfi.213.2019.06.14.07.51.30; Fri, 14 Jun 2019 07:51:46 -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; 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 S1728591AbfFNOuC convert rfc822-to-8bit (ORCPT + 99 others); Fri, 14 Jun 2019 10:50:02 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:42662 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727560AbfFNOuB (ORCPT ); Fri, 14 Jun 2019 10:50:01 -0400 Received: by mail-lf1-f67.google.com with SMTP id y13so1923597lfh.9 for ; Fri, 14 Jun 2019 07:50:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/tv53bBPYd1hXH+pjJtxE0GfwGIVE/QTSAJ64xVQ4QY=; b=KNpIxesmCSfDQa66v8UarsZ49zhV3vV5Dh3W7vs1luGHUBm/SoEH1T09Ih7Mr6iCHS 4t/ffNN5XS16jGoy+o5i9duj01JWe6hDvd/BWsGKVdCtHcYfO7u05iUpBF/rk8f/aKFB MhFdiBW6+OAcellbgPLg4jc26mIxRLs5hS9VT56jfACjy0CjEjvIFlUbU010zfybcpny Av/7pcXZqhwViB+McGTVf/sdptZ6N3JydQ0+mXMw16j2yWOqugR383+I/HRrYdR6PWRv z3AYgxs3PMa4X0xqLcgQG4IDfM4lyqKp23cN1rm3kTQfERtpaJz82xeLpqr6vv3PaiN9 9xHg== X-Gm-Message-State: APjAAAWqFNuVH8J/3Z6zWM47QMGwJA1xODxEtqnCLj99g4HLDtSdp64q DkowOSgzPufSxb6rFUpmGLGOtbsjL+gsdsfL8lL/+6t5 X-Received: by 2002:a19:6e41:: with SMTP id q1mr40659179lfk.20.1560523799309; Fri, 14 Jun 2019 07:49:59 -0700 (PDT) MIME-Version: 1.0 References: <20190429081937.7544-1-geert@linux-m68k.org> In-Reply-To: From: Geert Uytterhoeven Date: Fri, 14 Jun 2019 16:49:45 +0200 Message-ID: Subject: Re: [PATCH] m68k: io: Fix io{read,write}{16,32}be() for Coldfire peripherals To: Arnd Bergmann Cc: Greg Ungerer , Angelo Dureghello , Logan Gunthorpe , linux-m68k , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, On Mon, Apr 29, 2019 at 2:40 PM Arnd Bergmann wrote: > On Mon, Apr 29, 2019 at 10:19 AM Geert Uytterhoeven > wrote: > > The generic definitions of mmio_{read,write}{16,32}be() in lib/iomap.c > > assume that the {read,write}[wl]() I/O accessors always use little > > endian accesses, and swap the result. > > > > However, the Coldfire versions of the {read,write}[wl]() I/O accessors are > > special, in that they use native big endian instead of little endian for > > accesses to the on-SoC peripheral block, thus violating the assumption. > > > > Fix this by providing our own variants, using the raw accessors, > > reinstating the old behavior. This is fine on m68k, as no special > > barriers are needed, and also avoids swapping data twice. > > > > Reported-by: Angelo Dureghello > > Fixes: aecc787c06f4300f ("iomap: Use non-raw io functions for io{read|write}XXbe") > > Signed-off-by: Geert Uytterhoeven > > --- > > This can be reverted later, after this oddity of the Coldfire I/O > > support has been fixed, and drivers have been updated. > > --- > > arch/m68k/include/asm/io.h | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/arch/m68k/include/asm/io.h b/arch/m68k/include/asm/io.h > > index aabe6420ead2a599..d47e7384681ab1cd 100644 > > --- a/arch/m68k/include/asm/io.h > > +++ b/arch/m68k/include/asm/io.h > > @@ -8,6 +8,12 @@ > > #include > > #endif > > > > +#define mmio_read16be(addr) __raw_readw(addr) > > +#define mmio_read32be(addr) __raw_readl(addr) > > + > > +#define mmio_write16be(val, port) __raw_writew((val), (port)) > > +#define mmio_write32be(val, port) __raw_writel((val), (port)) > > + > > #include > > This looks correct to me, but there are two points that stick out to me: > > - why do you only do this for mmio and not for pio? Because no one had a need for it? ;-) Now seriously, m68k only has MMIO, no PIO. Any PIO, if used, is for ISA or PCMCIA I/O accesses, which are little endian. > - why do you even use the generic_iomap wrappers rather than > the trivial asm-generic versions of those functions? Looking at git history, that was done to fix some link errors, which no longer seem to happen with the more mature asm-generic infrastructure we have now. So probably we can drop the selection of GENERIC_IOMAP and inclusion of , after fixing a few compiler warnings like: include/asm-generic/io.h: In function ‘ioread8_rep’ arch/m68k/include/asm/io_mm.h:371:44: warning: passing argument 1 of ‘raw_insb’ discard ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] #define readsb(port, buf, nr) raw_insb((port), (u8 *)(buf), (nr)) arch/m68k/include/asm/raw_io.h:101:50: note: expected ‘volatile u8 *’ {aka ‘volatile unsigned char *’} but argument is of type ‘const volatile void *’ static inline void raw_insb(volatile u8 __iomem *port, u8 *buf, unsigned int len) and some regression testing, of course. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds