linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>,
	linux-alpha@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	linux-serial@vger.kernel.org, linux-rtc@vger.kernel.org
Subject: Re: [PATCH 2/2 v5] alpha: add a delay before serial port read
Date: Thu, 7 May 2020 10:03:53 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LRH.2.02.2005071003040.1718@file01.intranet.prod.int.rdu2.redhat.com> (raw)
In-Reply-To: <20200507135839.GA1803635@kroah.com>



On Thu, 7 May 2020, Greg Kroah-Hartman wrote:

> On Thu, May 07, 2020 at 08:57:09AM -0400, Mikulas Patocka wrote:
> > The patch 92d7223a74235054f2aa7227d207d9c57f84dca0 ("alpha: io: reorder
> > barriers to guarantee writeX() and iowriteX() ordering #2") broke boot on
> > the Alpha Avanti platform.
> > 
> > The patch changes timing between accesses to the ISA bus, in particular,
> > it reduces the time between "write" access and a subsequent "read" access.
> > 
> > This causes lock-up when accessing the real time clock and serial ports.
> > 
> > This patch fixes the serial ports by adding a small delay before the "inb"
> > instruction.
> > 
> > We introduce a global variable
> > alpha_has_broken_serial_ports_and_needs_delay - it is defined on Alpha and
> > it is set to 1 if we have the specific PCI-ISA bridge where this bug
> > occurs. We also introduce a new per-port flag UPQ_DELAY_BEFORE_READ, the
> > flag is set if alpha_has_broken_serial_ports_and_needs_delay is set and if
> > the serial port is an ISA port.
> > 
> > Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> > Fixes: 92d7223a7423 ("alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2")
> > Cc: stable@vger.kernel.org	# v4.17+
> > 
> > ---
> >  arch/alpha/include/asm/serial.h     |    5 +++++
> >  arch/alpha/kernel/pci.c             |    5 +++++
> >  drivers/tty/serial/8250/8250_core.c |   17 +++++++++++------
> >  drivers/tty/serial/8250/8250_port.c |    3 +++
> >  include/linux/serial_core.h         |    1 +
> >  5 files changed, 25 insertions(+), 6 deletions(-)
> > 
> > Index: linux-stable/arch/alpha/kernel/pci.c
> > ===================================================================
> > --- linux-stable.orig/arch/alpha/kernel/pci.c	2020-05-07 09:57:02.000000000 +0200
> > +++ linux-stable/arch/alpha/kernel/pci.c	2020-05-07 14:30:07.000000000 +0200
> > @@ -24,6 +24,7 @@
> >  #include <linux/slab.h>
> >  #include <linux/syscalls.h>
> >  #include <asm/machvec.h>
> > +#include <asm/serial.h>
> >  
> >  #include "proto.h"
> >  #include "pci_impl.h"
> > @@ -61,9 +62,13 @@ struct pci_controller *pci_isa_hose;
> >   * Quirks.
> >   */
> >  
> > +int alpha_has_broken_serial_ports_and_needs_delay = 0;
> > +EXPORT_SYMBOL(alpha_has_broken_serial_ports_and_needs_delay);
> > +
> >  static void quirk_isa_bridge(struct pci_dev *dev)
> >  {
> >  	dev->class = PCI_CLASS_BRIDGE_ISA << 8;
> > +	alpha_has_broken_serial_ports_and_needs_delay = 1;
> >  }
> >  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82378, quirk_isa_bridge);
> >  
> > Index: linux-stable/drivers/tty/serial/8250/8250_port.c
> > ===================================================================
> > --- linux-stable.orig/drivers/tty/serial/8250/8250_port.c	2020-05-07 09:57:02.000000000 +0200
> > +++ linux-stable/drivers/tty/serial/8250/8250_port.c	2020-05-07 09:57:02.000000000 +0200
> > @@ -442,6 +442,9 @@ static unsigned int mem32be_serial_in(st
> >  
> >  static unsigned int io_serial_in(struct uart_port *p, int offset)
> >  {
> > +	if (unlikely(p->quirks & UPQ_DELAY_BEFORE_READ))
> > +		ndelay(300);
> > +
> >  	offset = offset << p->regshift;
> >  	return inb(p->iobase + offset);
> >  }
> > Index: linux-stable/drivers/tty/serial/8250/8250_core.c
> > ===================================================================
> > --- linux-stable.orig/drivers/tty/serial/8250/8250_core.c	2020-05-07 09:57:02.000000000 +0200
> > +++ linux-stable/drivers/tty/serial/8250/8250_core.c	2020-05-07 14:34:16.000000000 +0200
> > @@ -487,9 +487,20 @@ static void univ8250_rsa_support(struct
> >  #define univ8250_rsa_support(x)		do { } while (0)
> >  #endif /* CONFIG_SERIAL_8250_RSA */
> >  
> > +/*
> > + * This "device" covers _all_ ISA 8250-compatible serial devices listed
> > + * in the table in include/asm/serial.h
> > + */
> > +static struct platform_device *serial8250_isa_devs;
> > +
> >  static inline void serial8250_apply_quirks(struct uart_8250_port *up)
> >  {
> >  	up->port.quirks |= skip_txen_test ? UPQ_NO_TXEN_TEST : 0;
> > +#ifdef alpha_has_broken_serial_ports_and_needs_delay
> 
> That is a symbol, not a define, how does that work?
> 
> greg k-h

That's both the symbol and a define - see this part of the patch:

Mikulas

Index: linux-stable/arch/alpha/include/asm/serial.h
===================================================================
--- linux-stable.orig/arch/alpha/include/asm/serial.h   2020-02-07 11:52:16.000000000 +0100
+++ linux-stable/arch/alpha/include/asm/serial.h        2020-05-07 14:48:21.000000000 +0200
@@ -28,3 +28,8 @@
        { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS },      /* ttyS1 */     \
        { 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS },      /* ttyS2 */     \
        { 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS },     /* ttyS3 */
+
+#ifdef CONFIG_PCI
+extern int alpha_has_broken_serial_ports_and_needs_delay;
+#define alpha_has_broken_serial_ports_and_needs_delay  alpha_has_broken_serial_ports_and_needs_delay
+#endif


  reply	other threads:[~2020-05-07 14:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 11:23 [PATCH 2/2] alpha: add a delay before serial port read Mikulas Patocka
2020-05-06 11:47 ` Greg Kroah-Hartman
2020-05-06 15:29   ` [PATCH 2/2 v2] " Mikulas Patocka
2020-05-06 15:49     ` Greg Kroah-Hartman
2020-05-06 15:57       ` Mikulas Patocka
2020-05-06 16:08         ` Greg Kroah-Hartman
2020-05-06 17:04           ` [PATCH 2/2 v3] " Mikulas Patocka
2020-05-06 17:45             ` Greg Kroah-Hartman
2020-05-07  8:18               ` [PATCH 2/2 v4] " Mikulas Patocka
2020-05-07  8:52                 ` Greg Kroah-Hartman
2020-05-07 10:53                   ` Mikulas Patocka
2020-05-07 11:10                     ` Greg Kroah-Hartman
2020-05-07 12:53                       ` Mikulas Patocka
2020-05-07 12:57                       ` [PATCH 2/2 v5] " Mikulas Patocka
2020-05-07 13:58                         ` Greg Kroah-Hartman
2020-05-07 14:03                           ` Mikulas Patocka [this message]
2020-05-10  0:13                 ` [PATCH 2/2 v4] " Maciej W. Rozycki
2020-05-23 10:37                   ` Mikulas Patocka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LRH.2.02.2005071003040.1718@file01.intranet.prod.int.rdu2.redhat.com \
    --to=mpatocka@redhat.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=ink@jurassic.park.msu.ru \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).