linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Lukas Wunner <lukas@wunner.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-serial@vger.kernel.org,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Ulrich Teichert <krypton@ulrich-teichert.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>,
	linux-alpha@vger.kernel.org,
	Lino Sanfilippo <LinoSanfilippo@gmx.de>,
	Philipp Rosenberger <p.rosenberger@kunbus.com>,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Subject: Re: [PATCH v2] serial: 8250: Move Alpha-specific quirk out of the core
Date: Tue, 4 Jan 2022 08:17:55 +0100	[thread overview]
Message-ID: <50ceeac0-adb1-30c1-ecc7-ddd4fb94a99c@kernel.org> (raw)
In-Reply-To: <b83d069cb516549b8a5420e097bb6bdd806f36fc.1640695609.git.lukas@wunner.de>

On 28. 12. 21, 18:22, Lukas Wunner wrote:
> struct uart_8250_port contains mcr_mask and mcr_force members whose
> sole purpose is to work around an Alpha-specific quirk.  This code
> doesn't belong in the core where it is executed by everyone else,
> so move it to a proper ->set_mctrl callback which is used on the
> affected Alpha machine only.
> 
> The quirk was introduced in January 1995:
> https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/diff/drivers/char/serial.c?h=1.1.83
> 
> The members in struct uart_8250_port were added in 2002:
> https://git.kernel.org/history/history/c/4524aad27854
> 
> The quirk applies to non-PCI Alphas and arch/alpha/Kconfig specifies
> "select FORCE_PCI if !ALPHA_JENSEN".  So apparently the only affected
> machine is the EISA-based Jensen that Linus was working on back then:
> https://lore.kernel.org/all/CAHk-=wj1JWZ3sCrGz16nxEj7=0O+srMg6Ah3iPTDXSPKEws_SA@mail.gmail.com/
> 
> Up until now the quirk is not applied unless CONFIG_PCI is disabled.
> If users forget to do that or run a generic Alpha kernel, the serial
> ports aren't usable on Jensen.  Avoid by confining the quirk to
> CONFIG_ALPHA_JENSEN instead of !CONFIG_PCI.  On generic Alpha kernels,
> auto-detect at runtime whether the quirk needs to be applied.
> 
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Cc: Russell King <rmk+kernel@armlinux.org.uk>
> Cc: Ulrich Teichert <krypton@ulrich-teichert.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> ---
> Changes in v2:
> * Also apply quirk when running a generic Alpha kernel on a Jensen.
> * Fix outdated reference to the quirk in sunsu.c.
> 
>   drivers/tty/serial/8250/8250.h       | 12 ++----------
>   drivers/tty/serial/8250/8250_alpha.c | 21 +++++++++++++++++++++
>   drivers/tty/serial/8250/8250_core.c  |  9 ++++-----
>   drivers/tty/serial/8250/8250_port.c  |  2 +-
>   drivers/tty/serial/8250/Makefile     |  2 ++
>   drivers/tty/serial/sunsu.c           |  3 ++-
>   include/linux/serial_8250.h          |  2 --
>   7 files changed, 32 insertions(+), 19 deletions(-)
>   create mode 100644 drivers/tty/serial/8250/8250_alpha.c
> 
> diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
> index 6473361525d1..db784ace25d8 100644
> --- a/drivers/tty/serial/8250/8250.h
> +++ b/drivers/tty/serial/8250/8250.h
> @@ -241,16 +241,8 @@ static inline int serial8250_in_MCR(struct uart_8250_port *up)
>   	return mctrl;
>   }
>   
> -#if defined(__alpha__) && !defined(CONFIG_PCI)
> -/*
> - * Digital did something really horribly wrong with the OUT1 and OUT2
> - * lines on at least some ALPHA's.  The failure mode is that if either
> - * is cleared, the machine locks up with endless interrupts.
> - */
> -#define ALPHA_KLUDGE_MCR  (UART_MCR_OUT2 | UART_MCR_OUT1)
> -#else
> -#define ALPHA_KLUDGE_MCR 0
> -#endif
> +bool alpha_jensen(void);
> +void alpha_jensen_set_mctrl(struct uart_port *port, unsigned int mctrl);
>   
>   #ifdef CONFIG_SERIAL_8250_PNP
>   int serial8250_pnp_init(void);
> diff --git a/drivers/tty/serial/8250/8250_alpha.c b/drivers/tty/serial/8250/8250_alpha.c
> new file mode 100644
> index 000000000000..58e70328aa4d
> --- /dev/null
> +++ b/drivers/tty/serial/8250/8250_alpha.c
> @@ -0,0 +1,21 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +#include <asm/machvec.h>
> +#include "8250.h"
> +
> +bool alpha_jensen(void)
> +{
> +	return !strcmp(alpha_mv.vector_name, "Jensen");
> +}
> +
> +void alpha_jensen_set_mctrl(struct uart_port *port, unsigned int mctrl)
> +{
> +	/*
> +	 * Digital did something really horribly wrong with the OUT1 and OUT2
> +	 * lines on Alpha Jensen.  The failure mode is that if either is
> +	 * cleared, the machine locks up with endless interrupts.
> +	 */
> +	mctrl |= TIOCM_OUT1 | TIOCM_OUT2;
> +
> +	serial8250_do_set_mctrl(port, mctrl);
> +}
> diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> index 1ce193daea7f..01d30f6ed8fb 100644
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -509,11 +509,10 @@ static void __init serial8250_isa_init_ports(void)
>   
>   		up->ops = &univ8250_driver_ops;
>   
> -		/*
> -		 * ALPHA_KLUDGE_MCR needs to be killed.
> -		 */
> -		up->mcr_mask = ~ALPHA_KLUDGE_MCR;
> -		up->mcr_force = ALPHA_KLUDGE_MCR;
> +		if (IS_ENABLED(CONFIG_ALPHA_JENSEN) ||
> +		    (IS_ENABLED(CONFIG_ALPHA_GENERIC) && alpha_jensen()))

It'd be definitely nicer, if here was only "if (alpha_jensen())". The 
rest would be done in the header or in 8250_alpha.c.

Or even create an empty __weak arch_serial8250_set_defaults() and also 
one non-empty in arch/alpha/?

thanks,
-- 
js
suse labs

      reply	other threads:[~2022-01-04  7:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28 17:22 [PATCH v2] serial: 8250: Move Alpha-specific quirk out of the core Lukas Wunner
2022-01-04  7:17 ` Jiri Slaby [this message]

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=50ceeac0-adb1-30c1-ecc7-ddd4fb94a99c@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=LinoSanfilippo@gmx.de \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=ink@jurassic.park.msu.ru \
    --cc=krypton@ulrich-teichert.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mattst88@gmail.com \
    --cc=p.rosenberger@kunbus.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=rth@twiddle.net \
    --cc=torvalds@linux-foundation.org \
    /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).