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]

 



El 2/6/21 a las 09:50, Johan Hovold escribió:
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;
  }

Tests with *both* patches applied:

# echo module cp210x +p > /sys/kernel/debug/dynamic_debug/control
# insmod ./cp210x.ko dyndbg==p

jun 02 10:42:38 karlalex-asus kernel: usbcore: registered new interface driver cp210x jun 02 10:42:38 karlalex-asus kernel: usbserial: USB Serial support registered for cp210x


<device plugged in>

jun 02 10:44:28 karlalex-asus kernel: usb 1-9: new full-speed USB device number 5 using xhci_hcd jun 02 10:44:29 karlalex-asus kernel: usb 1-9: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00 jun 02 10:44:29 karlalex-asus kernel: usb 1-9: New USB device strings: Mfr=1, Product=2, SerialNumber=3 jun 02 10:44:29 karlalex-asus kernel: usb 1-9: Product: CP2102N USB to UART Bridge Controller
jun 02 10:44:29 karlalex-asus kernel: usb 1-9: Manufacturer: Silicon Labs
jun 02 10:44:29 karlalex-asus kernel: usb 1-9: SerialNumber: 283405bafee6e81182024fe64b629a73 jun 02 10:44:29 karlalex-asus kernel: cp210x 1-9:1.0: cp210x converter detected
jun 02 10:44:29 karlalex-asus kernel: cp210x ttyUSB0: wLength = 66
jun 02 10:44:29 karlalex-asus kernel: cp210x ttyUSB0: ulMaxTxQueue = 640
jun 02 10:44:29 karlalex-asus kernel: cp210x ttyUSB0: ulMaxRxQueue = 640
jun 02 10:44:29 karlalex-asus kernel: cp210x ttyUSB0: ulProvSubType = 1
jun 02 10:44:29 karlalex-asus kernel: cp210x ttyUSB0: ulProvCapabilities = 0x13f jun 02 10:44:29 karlalex-asus kernel: cp210x ttyUSB0: ulSettableParams = 0x7f jun 02 10:44:29 karlalex-asus kernel: cp210x ttyUSB0: ulCurrentTx-Queue = 640 jun 02 10:44:29 karlalex-asus kernel: cp210x ttyUSB0: ulCurrentRx-Queue = 640 jun 02 10:44:29 karlalex-asus kernel: usb 1-9: cp210x converter now attached to ttyUSB0 jun 02 10:44:29 karlalex-asus mtp-probe[10146]: checking bus 1, device 5: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-9" jun 02 10:44:29 karlalex-asus mtp-probe[10146]: bus: 1, device: 5 was not an MTP device jun 02 10:44:29 karlalex-asus mtp-probe[10163]: checking bus 1, device 5: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-9" jun 02 10:44:29 karlalex-asus mtp-probe[10163]: bus: 1, device: 5 was not an MTP device jun 02 10:44:31 karlalex-asus ModemManager[725]: <info> [base-manager] couldn't check support for device '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-9': not supported by any plugin


$ stty -F /dev/ttyUSB0 ixon ixoff

jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: cp210x_change_speed - setting baud rate to 9600 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x00, flow = 0x00 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - xon_limit = 0, xoff_limit = 0 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x00, flow = 0x01 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: cp210x_tiocmset_port - control = 0x0303 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: failed set request 0x7 status: -32 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x00, flow = 0x01 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - xon_limit = 128, xoff_limit = 128 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x01, flow = 0x43 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: cp210x_tiocmset_port - control = 0x0300 jun 02 10:45:40 karlalex-asus kernel: cp210x ttyUSB0: failed set request 0x7 status: -32


$ stty -F /dev/ttyUSB0 crtscts -ixon -ixoff

jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: cp210x_change_speed - setting baud rate to 9600 jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x01, flow = 0x43 jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - xon_limit = 128, xoff_limit = 128 jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x00, flow = 0x03 jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: cp210x_tiocmset_port - control = 0x0303 jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: failed set request 0x7 status: -32 jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x00, flow = 0x03 jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - xon_limit = 128, xoff_limit = 128 jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x09, flow = 0x80 jun 02 10:46:41 karlalex-asus kernel: cp210x ttyUSB0: cp210x_tiocmset_port - ctrl = 0x08, flow = 0x00


$ cat /dev/ttyUSB0
<cat now waits for input>
jun 02 10:47:52 karlalex-asus kernel: cp210x ttyUSB0: cp210x_change_speed - setting baud rate to 9600 jun 02 10:47:52 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x08, flow = 0x00 jun 02 10:47:52 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - xon_limit = 128, xoff_limit = 128 jun 02 10:47:52 karlalex-asus kernel: cp210x ttyUSB0: cp210x_set_flow_control - ctrl = 0x08, flow = 0x00 jun 02 10:47:52 karlalex-asus kernel: cp210x ttyUSB0: cp210x_tiocmset_port - ctrl = 0x09, flow = 0x80


<Ctrl-C pressed, returned to shell prompt>
jun 02 10:48:59 karlalex-asus kernel: cp210x ttyUSB0: cp210x_tiocmset_port - ctrl = 0x08, flow = 0x00





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

  Powered by Linux