Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jun 2021 22:08:17 GMT
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 8696dd92ffb7 - stable/12 - ums(4): Do not stop USB xfers on FIFO close when evdev is still active
Message-ID:  <202106132208.15DM8HtC075423@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=8696dd92ffb776263226114f23715746a9abc296

commit 8696dd92ffb776263226114f23715746a9abc296
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2021-05-23 22:38:53 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2021-06-13 22:05:25 +0000

    ums(4): Do not stop USB xfers on FIFO close when evdev is still active
    
    This fixes lose of evdev events after moused has been killed.
    
    While here use bitwise operations for UMS_EVDEV_OPENED flag.
    
    Reviewed by:    hselasky
    Differential revision:  https://reviews.freebsd.org/D30342
    
    (cherry picked from commit 05ab03a31798d4cc96c22a8f30b1d9a0d7a3dd35)
---
 sys/dev/usb/input/ums.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c
index cd5cc905f1b5..dced48754041 100644
--- a/sys/dev/usb/input/ums.c
+++ b/sys/dev/usb/input/ums.c
@@ -381,7 +381,7 @@ tr_setup:
 		/* check if we can put more data into the FIFO */
 		if (usb_fifo_put_bytes_max(sc->sc_fifo.fp[USB_FIFO_RX]) == 0) {
 #ifdef EVDEV_SUPPORT
-			if (sc->sc_evflags == 0)
+			if ((sc->sc_evflags & UMS_EVDEV_OPENED) == 0)
 				break;
 #else
 			break;
@@ -866,7 +866,10 @@ ums_fifo_stop_read(struct usb_fifo *fifo)
 {
 	struct ums_softc *sc = usb_fifo_softc(fifo);
 
-	ums_stop_rx(sc);
+#ifdef EVDEV_SUPPORT
+	if ((sc->sc_evflags & UMS_EVDEV_OPENED) == 0)
+#endif
+		ums_stop_rx(sc);
 }
 
 
@@ -955,7 +958,7 @@ ums_ev_open(struct evdev_dev *evdev)
 
 	mtx_assert(&sc->sc_mtx, MA_OWNED);
 
-	sc->sc_evflags = UMS_EVDEV_OPENED;
+	sc->sc_evflags |= UMS_EVDEV_OPENED;
 
 	if (sc->sc_fflags == 0) {
 		ums_reset(sc);
@@ -972,7 +975,7 @@ ums_ev_close(struct evdev_dev *evdev)
 
 	mtx_assert(&sc->sc_mtx, MA_OWNED);
 
-	sc->sc_evflags = 0;
+	sc->sc_evflags &= ~UMS_EVDEV_OPENED;
 
 	if (sc->sc_fflags == 0)
 		ums_stop_rx(sc);
@@ -994,7 +997,7 @@ ums_fifo_open(struct usb_fifo *fifo, int fflags)
 
 	/* check for first open */
 #ifdef EVDEV_SUPPORT
-	if (sc->sc_fflags == 0 && sc->sc_evflags == 0)
+	if (sc->sc_fflags == 0 && (sc->sc_evflags & UMS_EVDEV_OPENED) == 0)
 		ums_reset(sc);
 #else
 	if (sc->sc_fflags == 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106132208.15DM8HtC075423>