* [PATCH] mtd: pxa3xx_nand: make the driver work on big-endian systems
@ 2014-05-22 12:56 Thomas Petazzoni
2014-05-28 22:03 ` Brian Norris
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Petazzoni @ 2014-05-22 12:56 UTC (permalink / raw)
To: Brian Norris, David Woodhouse, Artem Bityutskiy
Cc: Thomas Petazzoni, Andrew Lunn, Jason Cooper, stable, linux-mtd,
Ezequiel Garcia, Gregory Clement, Sebastian Hesselbarth
The pxa3xx_nand driver currently uses __raw_writel() and __raw_readl()
to access I/O registers. However, those functions do not do any
endianness swapping, which means that they won't work when the CPU
runs in big-endian but the I/O registers are little endian, which is
the common situation for ARM systems running big endian.
Since __raw_writel() and __raw_readl() do not include any memory
barriers and the pxa3xx_nand driver can only be compiled for ARM
platforms, the closest I/o accessors functions that do endianess
swapping are writel_relaxed() and readl_relaxed().
This patch has been verified to work on Armada XP GP: without the
patch, the NAND is not detected when the kernel runs big endian while
it is properly detected when the kernel runs little endian. With the
patch applied, the NAND is properly detected in both situations
(little and big endian).
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: <stable@vger.kernel.org> # v3.13+
---
This patch does not fix a regression introduced by a previous commit,
but is still necessary for stable to allow NAND to work properly on
ARM big endian platforms. The 3.13 starting point was chosen because
the support for big endian on modern ARM systems was added in this
kernel release.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/mtd/nand/pxa3xx_nand.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 7588fe2..3003611 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -127,10 +127,10 @@
/* macros for registers read/write */
#define nand_writel(info, off, val) \
- __raw_writel((val), (info)->mmio_base + (off))
+ writel_relaxed((val), (info)->mmio_base + (off))
#define nand_readl(info, off) \
- __raw_readl((info)->mmio_base + (off))
+ readl_relaxed((info)->mmio_base + (off))
/* error code and state */
enum {
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: pxa3xx_nand: make the driver work on big-endian systems
2014-05-22 12:56 [PATCH] mtd: pxa3xx_nand: make the driver work on big-endian systems Thomas Petazzoni
@ 2014-05-28 22:03 ` Brian Norris
0 siblings, 0 replies; 2+ messages in thread
From: Brian Norris @ 2014-05-28 22:03 UTC (permalink / raw)
To: Thomas Petazzoni
Cc: Andrew Lunn, Jason Cooper, Artem Bityutskiy, stable, linux-mtd,
Ezequiel Garcia, Gregory Clement, David Woodhouse,
Sebastian Hesselbarth
On Thu, May 22, 2014 at 02:56:52PM +0200, Thomas Petazzoni wrote:
> The pxa3xx_nand driver currently uses __raw_writel() and __raw_readl()
> to access I/O registers. However, those functions do not do any
> endianness swapping, which means that they won't work when the CPU
> runs in big-endian but the I/O registers are little endian, which is
> the common situation for ARM systems running big endian.
>
> Since __raw_writel() and __raw_readl() do not include any memory
> barriers and the pxa3xx_nand driver can only be compiled for ARM
> platforms, the closest I/o accessors functions that do endianess
> swapping are writel_relaxed() and readl_relaxed().
With any luck, the *_relaxed() accessors will be implemented uniformly
on all architectures soon. I believe there's an outstanding patch series
for this out on LKML.
> This patch has been verified to work on Armada XP GP: without the
> patch, the NAND is not detected when the kernel runs big endian while
> it is properly detected when the kernel runs little endian. With the
> patch applied, the NAND is properly detected in both situations
> (little and big endian).
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: <stable@vger.kernel.org> # v3.13+
> ---
> This patch does not fix a regression introduced by a previous commit,
> but is still necessary for stable to allow NAND to work properly on
> ARM big endian platforms. The 3.13 starting point was chosen because
> the support for big endian on modern ARM systems was added in this
> kernel release.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Two sign-offs for the price of one! ;)
Pushed to l2-mtd.git. Thanks!
Brian
> ---
> drivers/mtd/nand/pxa3xx_nand.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> index 7588fe2..3003611 100644
> --- a/drivers/mtd/nand/pxa3xx_nand.c
> +++ b/drivers/mtd/nand/pxa3xx_nand.c
> @@ -127,10 +127,10 @@
>
> /* macros for registers read/write */
> #define nand_writel(info, off, val) \
> - __raw_writel((val), (info)->mmio_base + (off))
> + writel_relaxed((val), (info)->mmio_base + (off))
>
> #define nand_readl(info, off) \
> - __raw_readl((info)->mmio_base + (off))
> + readl_relaxed((info)->mmio_base + (off))
>
> /* error code and state */
> enum {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-28 22:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-22 12:56 [PATCH] mtd: pxa3xx_nand: make the driver work on big-endian systems Thomas Petazzoni
2014-05-28 22:03 ` Brian Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox