Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Oct 2022 16:46:21 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Axel Rau <Axel.Rau@chaos1.de>
Cc:        hardware@freebsd.org, freebsd-hackers@freebsd.org
Subject:   Re: Accessing I2C-Bus via ELV USB-I2C
Message-ID:  <c033a26c-10e1-29e6-bc87-a81fe32cfb92@selasky.org>
In-Reply-To: <752FCC61-496D-40C5-8A99-143F15B1EE84@Chaos1.DE>
References:  <996df5c0-ffa7-f1bf-a9e2-6dd47d7b49e6@Chaos1.DE> <35D556D7-56EC-4295-93D6-80A4CFE6DCE9@Chaos1.DE> <37c55124-5cd5-6fd1-ca46-9265ebe47b18@selasky.org> <602324D8-515B-4061-8689-5638E9A82759@Chaos1.DE> <2cb6203f-03da-9a05-24a5-c851f1424503@selasky.org> <F81783C4-F79F-48A1-A5BE-25D997DF29DA@Chaos1.DE> <beafa2e5-17e7-491a-d104-a0ede1b69ce3@selasky.org> <490EBA38-E103-4DC1-8A42-E16A8279980D@Chaos1.DE> <017C6EBE-910E-43E7-AAF7-A3D9ECE85EFF@Chaos1.DE> <84c5bc0b-1c72-d50d-6289-ac91a0878bd1@selasky.org> <752FCC61-496D-40C5-8A99-143F15B1EE84@Chaos1.DE>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
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

[-- Attachment #2 --]
From c59ecc6c361f48f08b70d4fed905667b62e21ed6 Mon Sep 17 00:00:00 2001
From: Hans Petter Selasky <hselasky@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

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?c033a26c-10e1-29e6-bc87-a81fe32cfb92>