mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jochen Mades <jochen@mades.net>
To: Lukas Wunner <lukas@wunner.de>, Lino Sanfilippo <LinoSanfilippo@gmx.de>
Cc: gregkh@linuxfoundation.org, Russell King <linux@armlinux.org.uk>,
	Jiri Slaby <jirislaby@kernel.org>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Philipp Rosenberger <p.rosenberger@kunbus.com>
Subject: Re: [PATCH] Bugfix RTS line config in RS485 mode is overwritten in pl011_set_mctrl() function.
Date: Tue, 11 Jan 2022 11:00:32 +0100 (CET)	[thread overview]
Message-ID: <27017560.2684465.1641895232612@webmail.strato.com> (raw)
In-Reply-To: <20220102182801.GA22268@wunner.de>

Hi Lukas, Lino,

please let me know when I could test again with an "official" linux kernel, instead of using my local patch.

Bests
Jochen

> On 02/01/2022 19:28 Lukas Wunner <lukas@wunner.de> wrote:
> 
>  
> On Sun, Jan 02, 2022 at 04:06:53PM +0100, Lino Sanfilippo wrote:
> > On 02.01.22 at 11:07, Lukas Wunner wrote:
> > > On Fri, Dec 31, 2021 at 05:15:14PM +0000, jmades wrote:
> > > > --- a/drivers/tty/serial/amba-pl011.c
> > > > +++ b/drivers/tty/serial/amba-pl011.c
> > > > @@ -1646,8 +1646,12 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl)
> > > >  	    container_of(port, struct uart_amba_port, port);
> > > >  	unsigned int cr;
> > > >
> > > > -	if (port->rs485.flags & SER_RS485_ENABLED)
> > > > -		mctrl &= ~TIOCM_RTS;
> > > > +	if (port->rs485.flags & SER_RS485_ENABLED) {
> > > > +		if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND)
> > > > +			mctrl &= ~TIOCM_RTS;
> > > > +		else
> > > > +			mctrl |= TIOCM_RTS;
> > > > +	}
> > > >
> > > >  	cr = pl011_read(uap, REG_CR);
> > 
> > Does this logic really have to be implemented in the driver?
> 
> No, it doesn't have to be and indeed I'm working towards consolidating
> it in the serial core with this collection of patches:
> 
> https://git.kernel.org/gregkh/tty/c/d3b3404df318
> https://lore.kernel.org/all/f49f945375f5ccb979893c49f1129f51651ac738.1641129062.git.lukas@wunner.de
> https://lore.kernel.org/all/e22089ab49e6e78822c50c8c4db46bf3ee885623.1641129328.git.lukas@wunner.de
> https://lore.kernel.org/all/bceeaba030b028ed810272d55d5fc6f3656ddddb.1641129752.git.lukas@wunner.de
> https://github.com/l1k/linux/commit/532ef2ad757f
> 
> The last of these removes the rs485 logic from pl011_set_mctrl().
> I'll post it once the others (and Jochen Mades' patch) have landed.
> 
> Even though the logic is eventually removed from pl011_set_mctrl(),
> Jochen's patch makes sense as a backportable fix for v5.15.
> 
> 
> > It looks as if the serial core already takes RS485 into account before
> > calling set_mctrls(). At least I get the impression when looking
> > at uart_tiocmset() and uart_port_dtr_rts(). Also other drivers like imx
> > simply seem to ignore RTS in case of RS485.
> 
> The logic in uart_port_dtr_rts() is broken.  That's fixed by d3b3404df318,
> which is queued up in tty-next for v5.17.
> 
> The pl011 driver papered over it with its own rs485-specific logic in
> pl011_set_mctrl().  But as Jochen Mades correctly pointed out, that
> only worked correctly if RTS is driven high on idle.
> 
> 
> The logic in uart_tiocmset() is correct, but not sufficient because
> uart_throttle(), uart_unthrottle and uart_set_termios() need to become
> rs485-aware as well.  That's also addressed by the above-linked
> GitHub commit.
> 
> Thanks,
> 
> Lukas

  parent reply	other threads:[~2022-01-11 10:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31 17:15 jmades
2022-01-02 10:07 ` Lukas Wunner
2022-01-02 15:06   ` Lino Sanfilippo
2022-01-02 18:28     ` Lukas Wunner
2022-01-03 13:44       ` Lino Sanfilippo
2022-01-11 10:00       ` Jochen Mades [this message]
2022-01-12  1:41         ` Lino Sanfilippo
2022-01-13 10:12   ` Jochen Mades
2022-01-13 10:20     ` Greg KH
2022-01-23  4:32     ` Lukas Wunner

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=27017560.2684465.1641895232612@webmail.strato.com \
    --to=jochen@mades.net \
    --cc=LinoSanfilippo@gmx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lukas@wunner.de \
    --cc=p.rosenberger@kunbus.com \
    /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

Powered by JetHome