lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220625194951.GA2879@wunner.de>
Date:   Sat, 25 Jun 2022 21:49:51 +0200
From:   Lukas Wunner <lukas@...ner.de>
To:     Lino Sanfilippo <LinoSanfilippo@....de>
Cc:     gregkh@...uxfoundation.org, jirislaby@...nel.org,
        ilpo.jarvinen@...ux.intel.com, robh+dt@...nel.org,
        krzysztof.kozlowski+dt@...aro.org,
        andriy.shevchenko@...ux.intel.com, vz@...ia.com,
        linux-arm-kernel@...ts.infradead.org, devicetree@...r.kernel.org,
        linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org,
        p.rosenberger@...bus.com, Lino Sanfilippo <l.sanfilippo@...bus.com>
Subject: Re: [PATCH 1/8] serial: core: only get RS485 termination gpio if
 supported

On Wed, Jun 22, 2022 at 05:46:52PM +0200, Lino Sanfilippo wrote:
> In uart_get_rs485_mode() only try to get a termination GPIO if RS485 bus
> termination is supported by the driver.
[...]
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -3384,17 +3384,20 @@ int uart_get_rs485_mode(struct uart_port *port)
>  		rs485conf->flags |= SER_RS485_RTS_AFTER_SEND;
>  	}
>  
> -	/*
> -	 * Disabling termination by default is the safe choice:  Else if many
> -	 * bus participants enable it, no communication is possible at all.
> -	 * Works fine for short cables and users may enable for longer cables.
> -	 */
> -	port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term",
> -							GPIOD_OUT_LOW);
> -	if (IS_ERR(port->rs485_term_gpio)) {
> -		ret = PTR_ERR(port->rs485_term_gpio);
> -		port->rs485_term_gpio = NULL;
> -		return dev_err_probe(dev, ret, "Cannot get rs485-term-gpios\n");
> +	if (port->rs485_supported->flags & SER_RS485_TERMINATE_BUS) {

So I think linux-next commit be2e2cb1d281 ("serial: Sanitize rs485_struct")
contains a mistake in that it forces drivers to set SER_RS485_TERMINATE_BUS
in their rs485_supported->flags to allow enabling bus termination.

That's wrong because *every* rs485-capable driver can enable bus
termination if a GPIO has been defined for that in the DT.

In fact, another commit which was applied as part of the same series,
ebe2cf736a04 ("serial: pl011: Fill in rs485_supported") does not set
SER_RS485_TERMINATE_BUS in amba-pl011.c's flags and thus forbids the
driver from enabling bus termination, even though we know there are
products out there which support bus termination on the pl011 through
a GPIO (Revolution Pi RevPi Compact, Revpi Flat).

I think what you want to do is amend uart_get_rs485_mode() to set
SER_RS485_TERMINATE_BUS in port->rs485_supported_flags if a GPIO
was found in the DT.  Instead of the change proposed above.

Thanks,

Lukas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ