From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756880AbcA2VCs (ORCPT ); Fri, 29 Jan 2016 16:02:48 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:53371 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752780AbcA2VCq convert rfc822-to-8bit (ORCPT ); Fri, 29 Jan 2016 16:02:46 -0500 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: Sergei Shtylyov , Krzysztof =?utf-8?B?SGHFgmFzYQ==?= , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi , Haojian Zhuang , Daniel Mack , Imre Kaloz , Robert Jarzmik Subject: Re: [PATCH 3/7] usb: gadget: pxa25x_udc: use readl/writel for mmio Date: Fri, 29 Jan 2016 22:02:07 +0100 Message-ID: <12329346.gKHqOE6tJJ@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <56ABA97C.1000501@cogentembedded.com> References: <1453997722-3489596-1-git-send-email-arnd@arndb.de> <56ABA97C.1000501@cogentembedded.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="utf-8" X-Provags-ID: V03:K0:ORWyS3ui3CcQmQ+boc1FEQZm8PAOEuC9Zb9QayLmzjkan7ZqWZP Kdk8M97hNB+n7cvE0YSxaZaaFUchpLMbl/lWrGYkBjdHw3jX0bbsuL7MrDrU7b4cm8hkTuo tcFG0UBdEc1XxnqdxHab4N0f08qN3asmUU5Iq4vz9/VomnYHUu9fP99x5wDE6knmf0lw/sU yOlD/m3OvkEiNt1B9RGgA== X-UI-Out-Filterresults: notjunk:1;V01:K0:g5ZIho6JKxo=:WiQvI7iIp2p9Asv0fL3KE8 BuV6ji/4TnXG7WxzJKn0jl4e9Im2w5YNYQoWw2AI1MTl16sP+GIHSFePBY54VefJrjDfNRh4O /4Jiqlm1OmA4ekRkVhfC1PnacEejk1410W4jLQmyAl+kpEjrdlSBJVntpH/qXUX0NFzfwQhEu z0DOhTuHBcxfMR0UKz9lhO+rgyjTp7Vi7u2PhhboMXyr0YOZ0Isg3aJat9mucDGntOgnt/pzf YJm446w4juSh+cpbRnVnnx91uC5H7svyI1XBKmM1kHURl9DWmtiNIi/vEM2SaUuQXXiRLsvDB loozUci9vbv8pbIlrIBjhyQroNj5dl4IukZFpzJrypJZL/hm1PSVDS4efQ0h+q0ph+NveVKHx mTseDPnEj8+aPfWn8ld3Z2/ZLm5K4DzUkgLfgkYu18pRslEJofOEUbci3+EyR2ijBZ3LByJG4 5jNS89mpALRDHjILM2rf1mFSQqVJzx5PBkh7BcefB2qML4iKDHnL0otLSh4t1lNJiZuzsbzvL iejKzyvBTrFV2WHSzlOr4CQOWkVlOVnO0/FXPwZ79HcJbmDc/sox0597OMKRPFU7zkh8OdkSd POivumJYEXdd2gNtCpNxRh6OgdpZGnXu+kLGRRw23EUclLV3ead3Z1Cefy5f1llGb3SL0cKSc 7tb6qDjUXNe2Mh/o+APRzHm98zuIUN6zL2byG/xdVebm/kp8VM+5oG/FIpWpJDEx2OPHEanQn UqSNMFLjmsyUDtak Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 29 January 2016 21:03:40 Sergei Shtylyov wrote: > On 01/29/2016 07:18 PM, Krzysztof HaƂasa wrote: > > >> The unclear part here is for IXP4xx, which supports both big-endian > >> and little-endian configurations. So far, the driver has done > >> no byteswap in either case. I suspect that is wrong and it would > >> actually need to swap in one or the other case, but I don't know > >> which. > > > > If at all, I guess it should swap in LE mode. But it's far from certain. > > > >> It's also possible that there is some magic setting in > >> the chip that makes the endianess of the MMIO register match the > >> CPU, and in that case, the code actually does the right thing > >> for all configurations, both before and after this patch. > > > > This is IMHO most probable. > > > > Actually, the IXP4xx is "natural" in BE mode (except for PCI) and > > normally in LE mode it's order-coherent, meaning 32-bit "integer" > > accesses need no swapping, but 8-bit and (mostly unused) 16-bit > > transfers need swapping. > > > > Anyway, I think readl()/writel() do the right thing: in BE mode they > > swap PCI accesses and don't swap normal registers, > > Alas, readl()/writel() don't know what registers you are calling them for, > they were designed for PCI which is little-endian, so they will swap in BE mode. > In general, that is correct, but as Krzysztof said, ixp4xx is rather special here, and it implements its own readl/writel functions that behave differently for PCI spaces than for on-chip addresses, See arch/arm/mach-ixp4xx/include/mach/io.h. This platform evidently does its own tricks with byte swapping so while a normal big-endian platform has to swap on readl (but not readsl), ixp4xx never does any swaps when CONFIG_IXP4XX_INDIRECT_PCI is set (neither readl nor readsl, neither PCI nor on-chip MMU) However if CONFIG_IXP4XX_INDIRECT_PCI is disabled (which I think is almost always the case), it basically behaves like all the other platforms, and in big-endian configurations performsm swaps for inl/readl/ioread32 but not readsl/ioread32_rep/insl (it swaps twice for the last one). Arnd