On 10/5/22 13:55, Axel Rau wrote:
If I do not want to touch th USB stuff, can I get the same effect by close/open 
of the serial device?

The uslcom driver only does this right after attach, in 13-stable and 14-main.

Does the attached patch make any difference for you?

--HPS
From c59ecc6c361f48f08b70d4fed905667b62e21ed6 Mon Sep 17 00:00:00 2001
From: Hans Petter Selasky <hsela...@freebsd.org>
Date: Wed, 5 Oct 2022 16:45:21 +0200
Subject: [PATCH] uslcom(4): Clear stall at every open.

To avoid data loss, make sure both the receive and transmit data toggles
get reset, before trying to read or write any data.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
---
 sys/dev/usb/serial/uslcom.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sys/dev/usb/serial/uslcom.c b/sys/dev/usb/serial/uslcom.c
index e4367d6781a7..868711afef01 100644
--- a/sys/dev/usb/serial/uslcom.c
+++ b/sys/dev/usb/serial/uslcom.c
@@ -439,12 +439,6 @@ uslcom_attach(device_t dev)
 		    "error=%s\n", usbd_errstr(error));
 		goto detach;
 	}
-	/* clear stall at first run */
-	mtx_lock(&sc->sc_mtx);
-	usbd_xfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_WR]);
-	usbd_xfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_RD]);
-	mtx_unlock(&sc->sc_mtx);
-
 	sc->sc_partnum = uslcom_get_partnum(sc);
 
 	error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
@@ -514,6 +508,10 @@ uslcom_cfg_open(struct ucom_softc *ucom)
 		DPRINTF("UART enable failed (ignored)\n");
 	}
 
+	/* clear stall */
+	usbd_xfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_WR]);
+	usbd_xfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_RD]);
+
 	/* start polling status */
 	uslcom_watchdog(sc);
 }
-- 
2.37.3

Reply via email to