From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753289AbcCJTYo (ORCPT ); Thu, 10 Mar 2016 14:24:44 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:56323 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752217AbcCJTYe (ORCPT ); Thu, 10 Mar 2016 14:24:34 -0500 From: Arnd Bergmann To: Lada Trimasova Subject: Re: [PATCH] arc: use little endian accesses Date: Thu, 10 Mar 2016 20:23:59 +0100 User-Agent: KMail/1.12.2 (Linux/3.19.0-54-generic; KDE/4.3.2; x86_64; ; ) Cc: Vineet Gupta , "linux-kernel@vger.kernel.org" , "linux-arch@vger.kernel.org" , "noamc@ezchip.com" , Alexey Brodkin , "linux-snps-arc@lists.infradead.org" References: <1457544064-16167-1-git-send-email-ltrimas@synopsys.com> <1457636268.457.34.camel@synopsys.com> In-Reply-To: <1457636268.457.34.camel@synopsys.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201603102023.59425.arnd@arndb.de> X-Provags-ID: V03:K0:ZSPZ7iJGEIcSbnJqzygDUaafPRrRhAoTR+NV1bbb3aK+dWwdm1l 5ZIZqmn+6XQGWwEIg/8ZRxaCjSHpuocK70RLUgHYrJ7kpOaJrTzk59GrvCjJknzpvTiNsXf l0Q1pr21VCadrf00fWQBNZtmL3bIlVXdFsCBFJd5flWGH8VuDSA288pz2XUVOZTCDaplnHe dFRvqlz0PJjYnyNInZtlg== X-UI-Out-Filterresults: notjunk:1;V01:K0:q45q+2PAnl8=:R9QkbCSy9ZUVjpv+qOhDSR lmHksQqk0YuNLuyMmTgqipUzEQeOCLhmtPiykUIEPOo4sMVvpx8iZlLyZD6bxCLKYz0OP4uK3 JvmJY642XwPnMi7C9Iow3S4kj6i00TVBS53ngzjJmBIGau2ydMsFobnWO5mASzXnRByz/8WoB XH4kvfrJiyoxgEjuWY9WRpsJs0SmEMWtaingpxzPQKhGKaQBAA4vsAdMpKtCk4aRN/kc3DNmt b2L6rV5RgPlUp/VI9sArRz2LO5SjlxSUbzilT+HZehGG3rfe7V/q3GWsg/1CSFFUZP/MMeRGY n356/6IPiup271AgQ6gYcA2+qTzF2ggjFwHVjpUZKVnm5bFkzSyoiZvpx6y1mN9hR7dUUq26v P0u+E+dRi3GUFKkRT+jHQuuGgk9xB92OpwBkNYPzX2SA2Scejv/x/GKg6k9+UXlFbluFkaB4V qFdz6mX+CRKNbmUPZRw1oiVTxCutlz3iQY+QrnWgyvgetxv1cp0tXnzl0Wsd44lXwrfhgRQUm KptJ+kHZkKpAZPcdDvCYJZkOY+6H36/0ahw2WUegMZ+Kx94ZDKMtfqOPvj4UlJecSrRQfzpT1 Ttddn7Od5jLMR2drdXq3LRit1Dx9ruVfCfEXIbRET09gz3/0d9GQNRu8AIzBh9Kfb3EnztWKD XMhIvMLZ176DzrdzfSSq/uysDZBjNJrcqJUUMTVaXx+F0RDZzTLCuRAqFyLHxKdrINe7FW4SL rKkAxbrQQM471Eqp Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 10 March 2016, Lada Trimasova wrote: > Driver is 8250, kernel is built for BE arc, nsim option in model "nsim_isa_big_endian = 1". > > With current "readl" and "writel" implementation for ARC we read word from memory without any endianess manipulation. So in case of little endian architecture we get what we want: the first memory byte is the low byte in the word. But in case of big endian architecture the word endianess is swapped: the first memory byte is the high word byte. > > And for example, let's see what happens when we use "readl" in function "serial8250_early_in" in driver/tty/serial/8250. > > Take a look to one line from memory dump: > 0xf0000010: 0x0b 0x00 0x00 0x00 0x60 0x00 0x00 0x00 > > When kernel is built for little endian architecture, we read this data in status register in function "serial_putc" using "readl" function in driver/tty/serial/8250 as: > r0: 0x0000006 > The low byte is 0x0b, so the condition "if ((status & BOTH_EMPTY) == BOTH_EMPTY)" is true, as BOTH_EMPTY is some mask with low bytes set. > > When kernel is built with "CPU_BIG_ENDIAN" and model nsim option is "nsim_isa_big_endian=1", we read this data as: > r0: 0x6000000 > So as you can see the low byte is 0x00 and above mentioned condition never becomes true, we can't continue initialization. > Ok, this sounds like a completely normal architecture implementation then, and your patch looks correct. If some other driver breaks because of this change, you should investigate what went wrong there, and treat it as a driver specific problem. Arnd