linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty/serial: atmel: use proper accessors
@ 2015-07-20 13:56 Alexandre Belloni
  2015-07-20 19:05 ` Peter Hurley
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2015-07-20 13:56 UTC (permalink / raw)
  To: Nicolas Ferre, Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-arm-kernel, linux-kernel,
	Cyrille Pitchen, Alexandre Belloni

On ARM, it is necessary to use the _relaxed versions of read[bl] and
write[bl] to ensure we do the correct endianness conversion when running in
big endian.
Keep using avr32 __raw version on avr32 to avoid breakage.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---

This patch applies after [PATCH v4 0/5] tty/serial: at91: add support to FIFOs
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/353704.html

 drivers/tty/serial/atmel_serial.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index e91b3b2f0590..451acf054281 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -194,6 +194,7 @@ to_atmel_uart_port(struct uart_port *uart)
 	return container_of(uart, struct atmel_uart_port, uart);
 }
 
+#ifdef CONFIG_AVR32
 static inline u32 atmel_uart_readl(struct uart_port *port, u32 reg)
 {
 	return __raw_readl(port->membase + reg);
@@ -213,6 +214,27 @@ static inline void atmel_uart_writeb(struct uart_port *port, u32 reg, u8 value)
 {
 	__raw_writeb(value, port->membase + reg);
 }
+#else
+static inline u32 atmel_uart_readl(struct uart_port *port, u32 reg)
+{
+	return readl_relaxed(port->membase + reg);
+}
+
+static inline void atmel_uart_writel(struct uart_port *port, u32 reg, u32 value)
+{
+	writel_relaxed(value, port->membase + reg);
+}
+
+static inline u8 atmel_uart_readb(struct uart_port *port, u32 reg)
+{
+	return readb_relaxed(port->membase + reg);
+}
+
+static inline void atmel_uart_writeb(struct uart_port *port, u32 reg, u8 value)
+{
+	writeb_relaxed(value, port->membase + reg);
+}
+#endif
 
 #ifdef CONFIG_SERIAL_ATMEL_PDC
 static bool atmel_use_pdc_rx(struct uart_port *port)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty/serial: atmel: use proper accessors
  2015-07-20 13:56 [PATCH] tty/serial: atmel: use proper accessors Alexandre Belloni
@ 2015-07-20 19:05 ` Peter Hurley
  2015-07-20 20:02   ` Alexandre Belloni
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Hurley @ 2015-07-20 19:05 UTC (permalink / raw)
  To: Alexandre Belloni, Nicolas Ferre, Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-arm-kernel, linux-kernel,
	Cyrille Pitchen

Hi Alexandre,

On 07/20/2015 09:56 AM, Alexandre Belloni wrote:
> On ARM, it is necessary to use the _relaxed versions of read[bl] and
> write[bl] to ensure we do the correct endianness conversion when running in
> big endian.
> Keep using avr32 __raw version on avr32 to avoid breakage.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> 
> This patch applies after [PATCH v4 0/5] tty/serial: at91: add support to FIFOs
> http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/353704.html
> 
>  drivers/tty/serial/atmel_serial.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index e91b3b2f0590..451acf054281 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -194,6 +194,7 @@ to_atmel_uart_port(struct uart_port *uart)
>  	return container_of(uart, struct atmel_uart_port, uart);
>  }
>  
> +#ifdef CONFIG_AVR32

The whole point of i/o accessors is to encapsulate arch-specific
differences, so one of these arches isn't doing it right, or the wrong
i/o accessors are being used.

In any event, serial drivers can't start taking on per-arch conditional
compilation.

Regards,
Peter Hurley

PS - The $subject doesn't really match the patch; this is basically adding
big-endian support on little-endian arches.

>  static inline u32 atmel_uart_readl(struct uart_port *port, u32 reg)
>  {
>  	return __raw_readl(port->membase + reg);
> @@ -213,6 +214,27 @@ static inline void atmel_uart_writeb(struct uart_port *port, u32 reg, u8 value)
>  {
>  	__raw_writeb(value, port->membase + reg);
>  }
> +#else
> +static inline u32 atmel_uart_readl(struct uart_port *port, u32 reg)
> +{
> +	return readl_relaxed(port->membase + reg);
> +}
> +
> +static inline void atmel_uart_writel(struct uart_port *port, u32 reg, u32 value)
> +{
> +	writel_relaxed(value, port->membase + reg);
> +}
> +
> +static inline u8 atmel_uart_readb(struct uart_port *port, u32 reg)
> +{
> +	return readb_relaxed(port->membase + reg);
> +}
> +
> +static inline void atmel_uart_writeb(struct uart_port *port, u32 reg, u8 value)
> +{
> +	writeb_relaxed(value, port->membase + reg);
> +}
> +#endif
>  
>  #ifdef CONFIG_SERIAL_ATMEL_PDC
>  static bool atmel_use_pdc_rx(struct uart_port *port)
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty/serial: atmel: use proper accessors
  2015-07-20 19:05 ` Peter Hurley
@ 2015-07-20 20:02   ` Alexandre Belloni
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2015-07-20 20:02 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Hans Ulli Kroll, Nicolas Ferre, Greg Kroah-Hartman, Jiri Slaby,
	linux-serial, linux-arm-kernel, linux-kernel, Cyrille Pitchen

Hi,

(adding Hans in Cc)

On 20/07/2015 at 15:05:39 -0400, Peter Hurley wrote :
> Hi Alexandre,
> 
> On 07/20/2015 09:56 AM, Alexandre Belloni wrote:
> > On ARM, it is necessary to use the _relaxed versions of read[bl] and
> > write[bl] to ensure we do the correct endianness conversion when running in
> > big endian.
> > Keep using avr32 __raw version on avr32 to avoid breakage.
> > 
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > ---
> > 
> > This patch applies after [PATCH v4 0/5] tty/serial: at91: add support to FIFOs
> > http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/353704.html
> > 
> >  drivers/tty/serial/atmel_serial.c | 22 ++++++++++++++++++++++
> >  1 file changed, 22 insertions(+)
> > 
> > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> > index e91b3b2f0590..451acf054281 100644
> > --- a/drivers/tty/serial/atmel_serial.c
> > +++ b/drivers/tty/serial/atmel_serial.c
> > @@ -194,6 +194,7 @@ to_atmel_uart_port(struct uart_port *uart)
> >  	return container_of(uart, struct atmel_uart_port, uart);
> >  }
> >  
> > +#ifdef CONFIG_AVR32
> 
> The whole point of i/o accessors is to encapsulate arch-specific
> differences, so one of these arches isn't doing it right, or the wrong
> i/o accessors are being used.
> 

I'm not an avr32 specialist but I think __raw accessors are doing big
endian accesses but _relaxed accessors are doing litlle endian accesses.

Maybe Hans can clarify what's needed here.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-20 20:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-20 13:56 [PATCH] tty/serial: atmel: use proper accessors Alexandre Belloni
2015-07-20 19:05 ` Peter Hurley
2015-07-20 20:02   ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).