All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Qemu-devel] [PATCH] PC Chipset: Improve serial divisor calculation
@ 2018-08-31 23:37 Guenter Roeck
  2018-09-11 13:21 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2018-08-31 23:37 UTC (permalink / raw)
  To: Calvin Lee; +Cc: Michael S. Tsirkin, Paolo Bonzini, qemu-devel

Hi,

On Fri, May 11, 2018 at 06:05:44PM -0600, Calvin Lee wrote:
> This fixes several problems I found in the UART serial implementation.
> Now all divisor values are allowed, while before divisor values of zero
> and below the base baud rate were rejected. All changes are in reference
> to http://www.sci.muni.cz/docs/pc/serport.txt
> 

This patch is causing tracebacks in all Linux kernels running the PXA serial
driver. Here is an example:

[    1.907584] ------------[ cut here ]------------
[    1.907805] WARNING: CPU: 0 PID: 1 at drivers/tty/serial/pxa.c:544 serial_pxa_set_termios+0x254/0x268
[    1.907865] Modules linked in:
[    1.908130] CPU: 0 PID: 1 Comm: swapper Not tainted 4.9.125-rc1-00067-g7236e21 #1
[    1.908155] Hardware name: Zipit Z2
[    1.908783] [<c0011f54>] (unwind_backtrace) from [<c000e9ac>] (show_stack+0x20/0x24)
[    1.908846] [<c000e9ac>] (show_stack) from [<c029aa80>] (dump_stack+0x20/0x28)
[    1.908877] [<c029aa80>] (dump_stack) from [<c002befc>] (__warn+0xec/0x114)
[    1.908905] [<c002befc>] (__warn) from [<c002bff4>] (warn_slowpath_null+0x30/0x38)
[    1.908931] [<c002bff4>] (warn_slowpath_null) from [<c033eeb4>] (serial_pxa_set_termios+0x254/0x268)
[    1.908958] [<c033eeb4>] (serial_pxa_set_termios) from [<c0339b00>] (uart_set_options+0xc8/0xf0)
[    1.908987] [<c0339b00>] (uart_set_options) from [<c0712200>] (serial_pxa_console_setup+0xb4/0xc4)
...

The patch results in an unexpected DLL register value. Here is the
surrounding code from drivers/tty/serial/pxa.c:

	serial_out(up, UART_DLL, quot & 0xff);		/* LS of divisor */

	/*
	 * work around Errata #75 according to Intel(R) PXA27x
	 * Processor Family Specification Update (Nov 2005)
	 */
	dll = serial_in(up, UART_DLL);
	WARN_ON(dll != (quot & 0xff));	// <-- warning

Reverting the patch fixes the problem.

Guenter

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

* Re: [Qemu-devel] [PATCH] PC Chipset: Improve serial divisor calculation
  2018-08-31 23:37 [Qemu-devel] [PATCH] PC Chipset: Improve serial divisor calculation Guenter Roeck
@ 2018-09-11 13:21 ` Paolo Bonzini
  2018-09-11 21:59   ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2018-09-11 13:21 UTC (permalink / raw)
  To: Guenter Roeck, Calvin Lee; +Cc: Michael S. Tsirkin, qemu-devel

On 01/09/2018 01:37, Guenter Roeck wrote:
> The patch results in an unexpected DLL register value. Here is the
> surrounding code from drivers/tty/serial/pxa.c:
> 
> 	serial_out(up, UART_DLL, quot & 0xff);		/* LS of divisor */
> 
> 	/*
> 	 * work around Errata #75 according to Intel(R) PXA27x
> 	 * Processor Family Specification Update (Nov 2005)
> 	 */
> 	dll = serial_in(up, UART_DLL);
> 	WARN_ON(dll != (quot & 0xff));	// <-- warning
> 
> Reverting the patch fixes the problem.

I think it's a typo.  Can you try this:

diff --git a/hw/char/serial.c b/hw/char/serial.c
index 251f40fdac..02463e3388 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -345,9 +345,9 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
     default:
     case 0:
         if (s->lcr & UART_LCR_DLAB) {
-            if (size == 2) {
+            if (size == 1) {
                 s->divider = (s->divider & 0xff00) | val;
-            } else if (size == 4) {
+            } else {
                 s->divider = val;
             }
             serial_update_parameters(s);

Thanks,

Paolo

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

* Re: [Qemu-devel] [PATCH] PC Chipset: Improve serial divisor calculation
  2018-09-11 13:21 ` Paolo Bonzini
@ 2018-09-11 21:59   ` Guenter Roeck
  0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2018-09-11 21:59 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Calvin Lee, Michael S. Tsirkin, qemu-devel

On Tue, Sep 11, 2018 at 03:21:34PM +0200, Paolo Bonzini wrote:
> On 01/09/2018 01:37, Guenter Roeck wrote:
> > The patch results in an unexpected DLL register value. Here is the
> > surrounding code from drivers/tty/serial/pxa.c:
> > 
> > 	serial_out(up, UART_DLL, quot & 0xff);		/* LS of divisor */
> > 
> > 	/*
> > 	 * work around Errata #75 according to Intel(R) PXA27x
> > 	 * Processor Family Specification Update (Nov 2005)
> > 	 */
> > 	dll = serial_in(up, UART_DLL);
> > 	WARN_ON(dll != (quot & 0xff));	// <-- warning
> > 
> > Reverting the patch fixes the problem.
> 
> I think it's a typo.  Can you try this:
> 

You are correct, the patch below fixes the problem.

Tested-by: Guenter Roeck <linux@roeck-us.net>

Thanks!
Guenter

> diff --git a/hw/char/serial.c b/hw/char/serial.c
> index 251f40fdac..02463e3388 100644
> --- a/hw/char/serial.c
> +++ b/hw/char/serial.c
> @@ -345,9 +345,9 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
>      default:
>      case 0:
>          if (s->lcr & UART_LCR_DLAB) {
> -            if (size == 2) {
> +            if (size == 1) {
>                  s->divider = (s->divider & 0xff00) | val;
> -            } else if (size == 4) {
> +            } else {
>                  s->divider = val;
>              }
>              serial_update_parameters(s);
> 
> Thanks,
> 
> Paolo

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

end of thread, other threads:[~2018-09-11 22:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31 23:37 [Qemu-devel] [PATCH] PC Chipset: Improve serial divisor calculation Guenter Roeck
2018-09-11 13:21 ` Paolo Bonzini
2018-09-11 21:59   ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.