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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200806135316.GT3634@localhost>
Date:   Thu, 6 Aug 2020 15:53:16 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Manivannan Sadhasivam <mani@...nel.org>
Cc:     Johan Hovold <johan@...nel.org>, gregkh@...uxfoundation.org,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        patong.mxl@...il.com, linus.walleij@...aro.org,
        mchehab+huawei@...nel.org, linux-gpio@...r.kernel.org
Subject: Re: [RESEND PATCH v4 2/3] usb: serial: xr_serial: Add gpiochip
 support

On Sun, Jul 26, 2020 at 09:22:23PM +0530, Manivannan Sadhasivam wrote:
> On Wed, Jul 01, 2020 at 03:02:06PM +0200, Johan Hovold wrote:
> > On Sun, Jun 07, 2020 at 09:53:49PM +0530, Manivannan Sadhasivam wrote:
> > > Add gpiochip support for Maxlinear/Exar USB to serial converter
> > > for controlling the available gpios.
> > > 
> > > Inspired from cp210x usb to serial converter driver.
> > > 
> > > Cc: Linus Walleij <linus.walleij@...aro.org>
> > > Cc: linux-gpio@...r.kernel.org
> > > Reviewed-by: Linus Walleij <linus.walleij@...aro.org>
> > > Signed-off-by: Manivannan Sadhasivam <mani@...nel.org>
> > > ---
> > >  drivers/usb/serial/xr_serial.c | 209 ++++++++++++++++++++++++++++++++-
> > >  1 file changed, 208 insertions(+), 1 deletion(-)

> > > @@ -390,6 +408,13 @@ static void xr_set_flow_mode(struct tty_struct *tty,
> > >  	 */
> > >  	gpio_mode &= ~UART_MODE_GPIO_MASK;
> > >  	if (cflag & CRTSCTS) {
> > > +#ifdef CONFIG_GPIOLIB
> > > +		/* Check if the CTS/RTS pins are occupied */
> > > +		if (port_priv->pin_status[GPIO_RTS] ||
> > > +		    port_priv->pin_status[GPIO_CTS])
> > > +			return;
> > > +#endif
> > 
> > You cannot just bail out as this could leave software flow enabled etc.
> > 
> > You also need to claim these pins once at open or leave them be. We
> > don't want CRTSCTS to suddenly start toggling because a pin is released
> > by gpiolib.
> > 
> > That is, determine who owns each pin at open() and keep it that way till
> > close() (by setting some flags at open).
> > 
> > > +
> > >  		dev_dbg(&port->dev, "Enabling hardware flow ctrl\n");
> > >  		flow = UART_FLOW_MODE_HW;
> > >  		gpio_mode |= UART_MODE_RTS_CTS;
> > > @@ -497,6 +522,17 @@ static int xr_tiocmset_port(struct usb_serial_port *port,
> > >  	u8 gpio_set = 0;
> > >  	u8 gpio_clr = 0;
> > >  
> > > +#ifdef CONFIG_GPIOLIB
> > > +	/* Check if the RTS/DTR pins are occupied */
> > > +	if (set & TIOCM_RTS || clear & TIOCM_RTS)
> > > +		if (port_priv->pin_status[GPIO_RTS])
> > > +			return -EBUSY;
> > > +
> > > +	if (set & TIOCM_DTR || clear & TIOCM_DTR)
> > > +		if (port_priv->pin_status[GPIO_DTR])
> > > +			return -EBUSY;
> > > +#endif
> > 
> > Same here. And perhaps just ignoring the pins managed by gpiolib is
> > better (cf. gpiolib and pinctrl being orthogonal).
> 
> You mean, we can just make TX,RX,CTS,RTS pins controlled only by the serial
> driver and the rest only by gpiolib?

No, I think I just meant that you shouldn't return an error here for
signals whose pins happen to be muxed for a different function (gpio).

Johan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ