Re: cp210x module broken in 5.12.5 and 5.12.6, works in 5.11.21 (with bisection)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 01, 2021 at 12:18:27PM -0500, Alex Villacís Lasso wrote:
> El 1/6/21 a las 10:40, Johan Hovold escribió:

> > Could you try applying the below patch, and with debugging enabled
> >
> > 	1. plug the device in
> > 	2. start the terminal program
> >
> > and then send me the logs?
> >
> > This should show the current device settings which appear to have flow
> > control enabled (which the driver fails to disable).

Thanks again for the log.

> $ miniterm.py /dev/ttyUSB0 115200
> Traceback (most recent call last):
>    File "/usr/bin/miniterm.py", line 976, in <module>
>      main()
>    File "/usr/bin/miniterm.py", line 932, in main
>      serial_instance.open()
>    File "/usr/lib/python3.9/site-packages/serial/serialposix.py", line 
> 288, in open
>      self._update_rts_state()
>    File "/usr/lib/python3.9/site-packages/serial/serialposix.py", line 
> 627, in _update_rts_state
>      fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_RTS_str)
> BrokenPipeError: [Errno 32] Broken pipe
> 
> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_change_speed - setting baud rate to 9600
> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_set_flow_control - ctrl = 0x00, flow = 0x00

So the default device settings are the same as for my device and
hardware flow control is disabled.

> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_set_flow_control - xon_limit = 0, xoff_limit = 0

Defaults to zero here too.

> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_set_flow_control - ctrl = 0x00, flow = 0x01

Here IXON is enabled (default termios), but the IXOFF limits are also
updated to 128/128.

> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_tiocmset_port - control = 0x0303
> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: failed set request 
> 0x7 status: -32

And the next SET_MHS (modem handshaking) request fails (for RTS, as can
be seen below).

> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_change_speed - setting baud rate to 115384
> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_set_flow_control - ctrl = 0x00, flow = 0x01

The requested settings appear to have taken effect.

> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_set_flow_control - xon_limit = 128, xoff_limit = 128

And the limits have been updated.

> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_set_flow_control - ctrl = 0x01, flow = 0x40

Here DTR and RTS are asserted, and flow control disabled.

> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_tiocmset_port - control = 0x0101

DTR can still be changed.

> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: 
> cp210x_tiocmset_port - control = 0x0202
> jun 01 12:12:13 karlalex-asus kernel: cp210x ttyUSB0: failed set request 
> 0x7 status: -32

But RTS cannot be changed, just as if auto-RTS is enabled (even if it is
not reported back).

This may be a little far-fetched but can you send me the logs (debugging
again enabled) from when:

	1. plugging the device in
	2. stty -F /dev/ttyUSB0 ixon ixoff
	3. stty -F /dev/ttyUSB0 crtscts -ixon -ixoff
	4. cat /dev/ttyUSB0	# + CTRL-C

No need to run the terminal program.

If you could also apply the below debugging patch (on top of the
previous one) which will dump some device settings during probe before
doing the above that would be great.

Hopefully this will gives some more clues but otherwise I'll probably
just leave the default IXOFF limits for CP2102N to fix the regression.

Johan


>From 65b53f408b5d6b6408420ed9d1c827f80401796e Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan@xxxxxxxxxx>
Date: Wed, 2 Jun 2021 16:23:21 +0200
Subject: [PATCH] USB: serial: cp210x: dump communication properties

---
 drivers/usb/serial/cp210x.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 89da00de9739..f5c9e21538f8 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1843,6 +1843,37 @@ static void cp210x_gpio_remove(struct usb_serial *serial)
 
 #endif
 
+static void cp210x_dump_props(struct usb_serial_port *port)
+{
+	struct usb_device *udev = port->serial->dev;
+	void *buf;
+	int ret;
+
+	buf = kzalloc(256, GFP_KERNEL);
+	if (!buf)
+		return;
+
+	ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+			CP210X_GET_PROPS, REQTYPE_INTERFACE_TO_HOST, 0,
+			cp210x_interface_num(port->serial), buf, 256,
+			USB_CTRL_GET_TIMEOUT);
+	if (ret < 52) {
+		dev_err(&port->dev, "failed to get props: %d\n", ret);
+		goto out;
+	}
+
+	dev_dbg(&port->dev, "wLength = %u\n", le16_to_cpup(buf));
+	dev_dbg(&port->dev, "ulMaxTxQueue = %u\n", le32_to_cpup(buf + 12));
+	dev_dbg(&port->dev, "ulMaxRxQueue = %u\n", le32_to_cpup(buf + 16));
+	dev_dbg(&port->dev, "ulProvSubType = %u\n", le32_to_cpup(buf + 24));
+	dev_dbg(&port->dev, "ulProvCapabilities = 0x%02x\n", le32_to_cpup(buf + 28));
+	dev_dbg(&port->dev, "ulSettableParams = 0x%02x\n", le32_to_cpup(buf + 32));
+	dev_dbg(&port->dev, "ulCurrentTx-Queue = %u\n", le32_to_cpup(buf + 44));
+	dev_dbg(&port->dev, "ulCurrentRx-Queue = %u\n", le32_to_cpup(buf + 48));
+out:
+	kfree(buf);
+}
+
 static int cp210x_port_probe(struct usb_serial_port *port)
 {
 	struct usb_serial *serial = port->serial;
@@ -1857,6 +1888,8 @@ static int cp210x_port_probe(struct usb_serial_port *port)
 
 	usb_set_serial_port_data(port, port_priv);
 
+	cp210x_dump_props(port);
+
 	return 0;
 }
 
-- 
2.31.1




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux