From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752266AbdJMU2r (ORCPT ); Fri, 13 Oct 2017 16:28:47 -0400 Received: from smtp3-g21.free.fr ([212.27.42.3]:19062 "EHLO smtp3-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbdJMU2q (ORCPT ); Fri, 13 Oct 2017 16:28:46 -0400 Subject: Re: [PATCH] [RFC] mtd: atmel-quadspi: fix build issues To: Arnd Bergmann Cc: Marek Vasut , David Woodhouse , Brian Norris , Boris Brezillon , Richard Weinberger , Joel Stanley , =?UTF-8?Q?C=c3=a9dric_Le_Goater?= , Ludovic Barre , Mika Westerberg , linux-mtd , Linux Kernel Mailing List , Nicolas Ferre References: <20170721222204.3402340-1-arnd@arndb.de> From: Cyrille Pitchen Message-ID: <63b33705-6e03-08b3-5d1e-6d07e73d32cf@wedev4u.fr> Date: Fri, 13 Oct 2017 22:28:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, + Nicolas Ferre Le 01/08/2017 à 22:10, Arnd Bergmann a écrit : > On Tue, Aug 1, 2017 at 9:41 PM, Cyrille Pitchen > wrote: >> Le 22/07/2017 à 00:21, Arnd Bergmann a écrit : > >>> --- a/drivers/mtd/spi-nor/atmel-quadspi.c >>> +++ b/drivers/mtd/spi-nor/atmel-quadspi.c >>> @@ -208,9 +208,9 @@ static int atmel_qspi_run_transfer(struct atmel_qspi *aq, >>> if (cmd->enable.bits.address) >>> ahb_mem += cmd->address; >>> if (cmd->tx_buf) >>> - _memcpy_toio(ahb_mem, cmd->tx_buf, cmd->buf_len); >>> + memcpy_toio(ahb_mem, cmd->tx_buf, cmd->buf_len); >>> else >>> - _memcpy_fromio(cmd->rx_buf, ahb_mem, cmd->buf_len); >>> + memcpy_fromio(cmd->rx_buf, ahb_mem, cmd->buf_len); >>> >> >> At least on AT91 platforms and likely on most ARM boards, >> memcpy_fromio == memcpy_toio == memcpy. > > Just to give more background, it's a bit more complicated than this: > > On big-endian kernels, memcpy_fromio/memcpy_toio are > always defined as _memcpy_fromio/_memcpy_toio so we > do byte load/store operations in the correct order, while > little-endian kernels have the optimized mmiocpy() that redirects > to memcpy(). This is true for all ARM platforms other than EBSA110 > IIRC. > > Also, mmiocpy is an exported symbol that aliases to the external > memcpy definition, but we can't call memcpy directly, because gcc > knows how to inline calls to memcpy() and replace them by direct > load/store instructions that might be unaligned and trap on uncached > mmio areas. > >> I got some sama5d2 hardware last week, so I'll try to test your patch >> within few days because as you said maybe memcpy() was broken when I >> developed this driver at first but now memcpy() is likely to have been >> fixed so it might be interesting to get rid of _memcpy_fromio() and >> _memcpy_toio() because this is not the first time those 2 functions have >> created issues when building the Atmel Quad SPI driver on other platforms. >> >> So thanks for you're patch, I'll give it a try :) > Bad news: I've just tested this patch, applied onto the spi-nor/next branch of l2-mtd (based on 4.14.0-rc4), with a sama5d2 xplained board + Macronix MX25L25673G Quad SPI memory but it fails on the very first SPI command, Read JEDEC ID (9Fh): atmel_qspi f0020000.spi: unrecognized JEDEC id bytes: c2, 20, 20 atmel_qspi: probe of f0020000.spi failed with error -2 Best regards, Cyrille > Ok, thanks. > > Arnd >