From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933080AbcAYWZF (ORCPT ); Mon, 25 Jan 2016 17:25:05 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:49950 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932935AbcAYWY6 (ORCPT ); Mon, 25 Jan 2016 17:24:58 -0500 From: Arnd Bergmann To: Johannes Berg Cc: Mark Brown , Simon Arlott , linux-kernel@vger.kernel.org Subject: Re: [PATCH] Revert "regmap-mmio: Use native endianness for read/write" Date: Mon, 25 Jan 2016 23:24:44 +0100 Message-ID: <6166456.VMAx8CBNIX@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1453759675-28461-1-git-send-email-johannes@sipsolutions.net> References: <1453759675-28461-1-git-send-email-johannes@sipsolutions.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:+Pfoum4hlm7b9XZ6Y0Sq7ebwLr8/yrCFSRmdu71Y2FsXjEqDq0N TklxHjtQaFmoQ8j2xWj1IcJLV2L1m/OKOymODewFD4DFwmRda6qcdFSU8shldM29XtIseHr hkOh3vfzlzAPnImQWn3tWM1sP0YWT6ASX8HSqDrUDj5OgcrWTaqizr4yWUhK2aEayTj9rI7 /MWQ0BfpaHp6JI3oDMY6A== X-UI-Out-Filterresults: notjunk:1;V01:K0:EI2akBm5I8A=:xQyR2JiuOmy8PSW51U9Epc lEHbW1GdKIO1xWyVK6x3NGOB0UCAIk79haZKV5o0mX6cuRCZyfKvccyucyW7Ve1Ev2MP8oGRt nHa0YnrTQ9kMNwR3zm5ZxiumpEE2k2oAzhdFFfqHeEnPEFhNy9BcJhCJdXEHjgKrl6VCX4oP8 zIjj98CWMbkQ75q3MD1ip+so1SFn482gIrbL+9KBcI6CPli+QHLG4U/d/Nm1XlbdSrJG7f3CL qJXmC63gQIMeLt/jVBasHnn20jps4A+bncFyZ+kPEBsKmlfikwUk+xrT4dNyXnk5LsYbyYL4q XM9jMDEPLgzzY9TGzw8Uf6TczzDSTNvdiz8eSFepSQzAFvlnuhcvj7NvA8azXwSWSOuAgIV3U 3FoevGOlHS4IMUz81fSlx//loC7h4SwQzl06QonCZcjmEuQPV6IM3cV6aCX4Y4qeHREuZbiFY us3IoE5PKDhnvAbbAyrAhO/X6kVT7J+8/gRgtT+bSdeR2HQ/kMyrf4pcHVl/Jwtm9xx26E4gP 08TM6Tn9FbTucm+DMJRcqgM5iCwycpsev768H2tCnl2h/O/I7c2qGBunu1gAmQW02mvqGo7nt oE7mKD2koXKxpMkZehKFag1lg83yY/MTuJyY2r7dceSM18o8QmdmnyeP3DnjvvWkpBLKi0dD0 vB85Mgg26KFK9dML3PYRyfEGMtuz0vltIKFT4/nF0xZLYWWjDjWWh8a1vwh5zn8rCQZXt0czO 1RVoTkbrkWmNXAkw Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 25 January 2016 23:07:55 Johannes Berg wrote: > This reverts commit 29bb45f25ff3051354ed330c0d0f10418a2b8c7c. > > Clearly, using "native" endianness is a terrible idea when > devices are involved, since those devices are different hw > from the CPU, won't change, and the CPU might be able to > run in both big and little endian, like ARM and PowerPC can. > Therefore, "native" endian doesn't really exist. > > Consequently, this commit broke my HummingBoard i.MX6 in big > endian mode since it would now try to talk to the little > endian hardware with a big endian CPU without conversion. > > What the patch really would have to do is introduce some kind > of "device-endian" readl/writel, that takes the endianness of > the device as an argument. That seems a bit overkill though, > and would likely not generate any better code than the double > byte-swaps that MIPS is getting now. > > Therefore, simply revert the commit to fix the breakage. > > Fixes: 29bb45f25ff3 ("regmap-mmio: Use native endianness for read/write") > Signed-off-by: Johannes Berg I think it's more complicated than this unfortunately: Most architectures behave the same way you explain: all I/O registers are fixed-endian, and the CPU may also be fixed-endian or may support both using a runtime switch, which we abstract using the readl/writel etc helpers in Linux. On MIPS, the CPU endianess is set at through an input signal on the CPU core, and this cannot change during runtime but can change between SoCs or can be configurable with a hardware jumper. Some SoC vendors (notably Broadcom) decided to use the same signal to control whether there is a byteswap on the device bus or not, so the on-chip MMIO registers are always the same endianess as the CPU itself. This means that the devices are in fact CPU-endian, and we need some way for Linux to represent this. The patch to drivers/base/regmap/regmap-mmio.c is clearly wrong, as we must never use __raw_*() accessors in an architecture independent driver (for a number of reasons), but we still need a fix for MIPS so it can specify a way to do the double-swap without faking the endianess of the registers. Also, defaulting syscon to "native-endian" when nothing else is specified sounds like a bad idea, but we may already be stuck there with the precedent in existing bindings after 6a55244e897d ("regmap: mmio: request native endian formatting"), we'll have to think about that some more. Arnd