Re: [PATCH v4] serial: 8250_dw: fix wrong logic in dw8250_check_lcr()

From: Andy Shevchenko
Date: Tue Apr 05 2016 - 06:49:16 EST


On Tue, 2016-04-05 at 13:53 +0800, Kefeng Wang wrote:
> Commit cdcea058e510 ("serial: 8250_dw: Avoid serial_outx code
> duplicate
> with new dw8250_check_lcr()") introduce a wrong logic when write val
> to
> LCR reg. When CONFIG_64BIT enabled, __raw_writeq is used
> unconditionally.
>
> The __raw_readq/__raw_writeq is introduced by commit bca2092d7897
> ("serial:
> 8250_dw: Use 64-bit access for OCTEON.") for OCTEON, so for
> !PORT_OCTEON,
> we better to use coincident write func.
>
> Fixes: cdcea058e510("serial: 8250_dw: Avoid serial_outx code
> duplicate with new dw8250_check_lcr()")
> Signed-off-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
> ---
>
> Changes since v3:
> - Add patch change log, suggested by Greg Kroah-Hartman.
> Changes since v2:
> - Add #ifdef CONFIG_64BIT back, ensure it can be built under

Oh, true. Since it's a native IO we can't use writeq() helper from io-
64-nonatomic-*.Â

> configuration lacking readq/writeq.
> Changes since v1:
> - Repace '#ifdef CONFIG_64BIT' with IS_ENABLED(CONFIG_64BIT).
> - Enrich patch log, and add Fixes tag.
> ÂÂ
>
> Âdrivers/tty/serial/8250/8250_dw.c | 7 ++++---
> Â1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_dw.c
> b/drivers/tty/serial/8250/8250_dw.c
> index a3fb95d..47d1f3e 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -104,15 +104,16 @@ static void dw8250_check_lcr(struct uart_port
> *p, int value)
> Â dw8250_force_idle(p);
> Â
> Â#ifdef CONFIG_64BIT
> - __raw_writeq(value & 0xff, offset);
> -#else
> + if (p->type == PORT_OCTEON)
> + __raw_writeq(value & 0xff, offset);
> + else
> +#endif
> Â if (p->iotype == UPIO_MEM32)
> Â writel(value, offset);
> Â else if (p->iotype == UPIO_MEM32BE)
> Â iowrite32be(value, offset);
> Â else
> Â writeb(value, offset);
> -#endif

So, this changes logic to write the value on any 64 platform, using
different (non-64-bit) accessors, so, the case to fix is
actually "64BIT && !PORT_OCTEON". Perhaps commit message should be
amended to point that clearly.

> Â }
> Â /*
> Â Â* FIXME: this deadlocks if port->lock is already held

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy