Re: [PATCH v4 11/16] HID: ft260: workaround for TN_189 errata endpoint STALL after enumeration

From
sashiko-bot@kernel.org
Date
2026-11-17 20:50:52
Also in
linux-gpio, linux-serial
Reply to
Michael Zaidman, 2026-11-17
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: ft260: race between ft260_reset_and_rebind() and
  ft260_probe()
--

commit 4f2501f4550a54da3c0f10a72785d9919d317381
Author: Michael Zaidman [off-list ref]

HID: ft260: workaround for TN_189 errata endpoint STALL after enumeration

This commit adds a workaround for the FT260 TN_189 silicon errata by
checking interrupt IN endpoint health and device responsiveness during
probe, and scheduling a deferred USB device reset and interface rebind
when either check fails.

Link: https://ftdichip.com/wp-content/uploads/2026/05/TN_189-FT260-Errata-Technical-Note.pdf
quoted hunk ↗ jump to hunk
diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c
index e708b1be734c7..096e46836d743 100644
--- a/drivers/hid/hid-ft260.c
+++ b/drivers/hid/hid-ft260.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -2504,15 +2566,276 @@ static int ft260_uart_probe(struct ft260_device *dev,
[ ... ]
+static void ft260_reset_and_rebind(struct work_struct *ws)
+{
[ ... ]
quoted hunk ↗ jump to hunk
+	/*
+	 * usb_reset_device() keeps usbhid bound (its pre_reset/post_reset
+	 * both return 0) and does not re-trigger HID-level driver probing.
+	 * Unbind all USB interfaces, reset, and bind them again to force
+	 * usbhid to destroy stale HID devices and create new ones, which
+	 * triggers fresh ft260_probe() calls. Unbind before the reset: it
+	 * waits for a probe still running on either interface, so the
+	 * reset does not run while that probe stops usbhid.
+	 */
+	actconfig = usbdev->actconfig;
+	for (i = 0; actconfig && i < actconfig->desc.bNumInterfaces; i++) {
+		struct usb_interface *intf = actconfig->interface[i];
+
+		if (intf && intf->dev.driver)
+			device_release_driver(&intf->dev);
+	}
[ ... ]
+static int ft260_check_intr_ep_health(struct hid_device *hdev)
+{
[ ... ]
quoted hunk ↗ jump to hunk
+	pipe = usb_rcvintpipe(usbdev, ep->bEndpointAddress);
+	ret = usb_interrupt_msg(usbdev, pipe, buf, FT260_REPORT_MAX_LEN,
+				&actual_length, 100);
+	kfree(buf);
+
+	if (ret == -EPIPE) {
+		hid_warn(hdev,
+			 "interrupt IN ep %#x halted (TN_189 errata), scheduling USB reset and rebind\n",
+			 ep->bEndpointAddress);
+		return -ENODEV;
+	}
+
+	return 0;
+}
[ ... ]
quoted hunk ↗ jump to hunk
@@ -2540,6 +2869,27 @@ static int ft260_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		goto hid_fail;
 	}
 
+	/*
+	 * TN_189 errata workaround: bail out fast on a broken device so
+	 * that hub_event releases the device lock quickly, allowing the
+	 * scheduled reset work to acquire it and recover the device.
+	 */
+	ret = ft260_check_intr_ep_health(hdev);
+	if (ret == -ENODEV) {
+		ft260_schedule_reset(usbif);
+		goto err_hid_stop;
+	}
[Severity: Medium]
Can ft260_reset_and_rebind() race with an active ft260_probe() when the
driver is bound outside USB enumeration?

Unlike usb_bus_type, hid_bus_type does not set need_parent_lock.  When
hid-ft260 is loaded after hid-generic has already bound during USB
enumeration (or when reprobed via sysfs), hid_register_driver() probes the
two HID interfaces holding only device_lock(&hdev->dev), without holding
usb_lock_device(usbdev) or device_lock(&intf->dev).

When the first interface (hid0) detects a stalled endpoint and schedules
the reset work, ft260_reset_and_rebind() immediately acquires
usb_lock_device_for_reset() and calls device_release_driver(&intf->dev).
That enters usb_unbind_interface() and usbhid_disconnect() before
device_del(&hdev->dev) waits on device_lock(&hdev->dev):

CPU0 (modprobe hid-ft260)           CPU1 (ft260_reset_wq)
ft260_probe(hid0)
  ft260_check_intr_ep_health(hid0)
  ft260_schedule_reset()
  hid_hw_stop(hid0)
ft260_probe(hid1)
                                    ft260_reset_and_rebind()
                                      usb_lock_device_for_reset(usbdev)
                                      device_release_driver(&intf1->dev)
                                        usb_unbind_interface(intf1)
                                          usb_disable_interface(intf1)
                                          usbhid_disconnect(intf1)
                                            set_bit(HID_DISCONNECTED, ...)
                                            ...
                                            device_del(&hid1->dev)
                                              /* blocks on hid1 lock */
  hid_hw_start(hid1, 0)
    usbhid_start(hid1)
      clear_bit(HID_DISCONNECTED)
  ft260_check_intr_ep_health(hid1)
    usb_interrupt_msg() -> -ENOENT
    returns 0
  ft260_check_dev_responsive(hid1)
    usb_control_msg(ep0) -> 0
  hid_hw_open(hid1)                 <-- arms io_retry on disconnecting hid1

Because usb_disable_interface() has already disabled the interrupt IN
endpoint on intf1, usb_interrupt_msg() fails with -ENOENT, which
ft260_check_intr_ep_health() ignores because it only checks for -EPIPE.
When only the interrupt endpoints are halted under TN_189, ep0 still
answers USB_REQ_GET_STATUS, so ft260_probe(hid1) continues through
hid_hw_open() (with HID_DISCONNECTED cleared by usbhid_start()) and
registers the subdevices on a half-disconnected hid_device.  On hid0,
usb_disable_interface() and hid_bpf_destroy_device() can also run
concurrently with hid_hw_stop(hid0) if the work starts before hid0 finishes
unwinding.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117200423.19561-1-michael.zaidman@gmail.com?part=11
Thread (27 messages) 27 messages, 4 authors, last reply 1d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help