From nobody Tue Sep 6 08:45:36 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MMJr10Fthz4cWCT; Tue, 6 Sep 2022 08:45:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MMJr06qSSz3fZF; Tue, 6 Sep 2022 08:45:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662453937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7tLiatXvFnXsY9CizcatePR1W5j9r9GHaKb0Q1UUaEo=; b=TfSK369zQ9phMamU1ospEwkCpTJCA5VXskkrXrCNcLHNjkNQkkVo8tb3i5tlXZZimnngnu FnCA0yFifxJ1PV2fn9g03A9LFzrlhdin+Cc5hjhSkzIweNp+1pd3k+jw0OUznNpmMhXP/x 9v8SRAszFFD35LbjGVatd3EXVAJkbUXUdpuCK1wJYOUlapEzTLLkwRfqAyUQAPO1BuFkjf A3Xo9QmwBpwEhiDOhjw+0fGbQo8fvRulPwycVMmfFNm+rTyjPWmGmWIKoxuSfBbjYCyb5U KIrBHzcjNK1NsNDElh996wzLwtUFCn2VepHMkVKynaLsOutxK51bz6R/CWgbDQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MMJr05bgSz16Vf; Tue, 6 Sep 2022 08:45:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2868jaF6038000; Tue, 6 Sep 2022 08:45:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2868jaMK037999; Tue, 6 Sep 2022 08:45:36 GMT (envelope-from git) Date: Tue, 6 Sep 2022 08:45:36 GMT Message-Id: <202209060845.2868jaMK037999@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 7c39928455c5 - stable/12 - umodem(4): Clear stall at every open. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 7c39928455c5cbb22f9c3c92e541faa25d3418d8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662453937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7tLiatXvFnXsY9CizcatePR1W5j9r9GHaKb0Q1UUaEo=; b=Kpfln+vS5CtwMNsNnI8UvnspuJ4HYcfJXhHj8F8fowEsSWe2bvGOGJEyy08uSS78WZ7Q/3 YH2QxsUA7SpvwBsiRhQicnkY+wJxtCvUbRaVUQ6C7Xn+glz7bkmzvtxYEwKGsykv2tZWEJ vulPIAlvRuM02dymF8BpHCSWZxADyRewPM5WytBir9pgLcQnEO3dRPhamY5zvbXCqooOvP Hv3ufr6/6owPL0cOsUN87DOscbPMBsduKTYjVaLfwMiHn5yayZ6StOz3xHL9yvAtPwbVbC D+LgIBvyhZrVmlFCVG+kvQmHtyImedqkKOufMeAbm3OfB2+t4BVnA81hgPD3dg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662453937; a=rsa-sha256; cv=none; b=i/4bFYcC21/MIFbK81kXLgNAnm6U3uTgq0FKJF2eulusuTGIha/XV/W3HKlE0ceMfxhhcP dDCOK1Utb9lht/7B69MxbVmgSWpln64nSXy1cux0MRBMaoiY00CzWfspgAhqqE0ApLiUgl wbIhr65jOnkJxtLs5sxeSiMjELPkPvsFce3Vw0Qq4xDnYknTEUFidZGYD5wjpkqT64cwQ1 ke0R6hpkFWp1WJyt/fbEwHhjDUTsoGh8mkC2YTsEU+9Kn1xp/jU/0BrOz2fMXX/xKl8Uif i17ZSEOhPV3FgUPfqRVlBkpme23IAeoaKvW6/enShP8OR1BTMPVcuR3GmEi7WQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=7c39928455c5cbb22f9c3c92e541faa25d3418d8 commit 7c39928455c5cbb22f9c3c92e541faa25d3418d8 Author: Hans Petter Selasky AuthorDate: 2022-08-30 14:01:43 +0000 Commit: Hans Petter Selasky CommitDate: 2022-09-06 08:45:21 +0000 umodem(4): Clear stall at every open. Some controllers like the XHCI(4) loose track of the data toggle value when USB receive transfers are cancelled at close. This in turn can lead to to data loss after the next open. To avoid data loss, make sure both the receive and transmit data toggles get reset, before trying to read or write any data. Differential Revision: https://reviews.freebsd.org/D36391 Submitted by: Dave Baukus Sponsored by: NVIDIA Networking (cherry picked from commit 40e43b056df9aa2392f673fcacc72725c2201658) --- sys/dev/usb/serial/umodem.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/sys/dev/usb/serial/umodem.c b/sys/dev/usb/serial/umodem.c index 346a6bc45c9a..a31821f63490 100644 --- a/sys/dev/usb/serial/umodem.c +++ b/sys/dev/usb/serial/umodem.c @@ -216,6 +216,7 @@ static void umodem_cfg_get_status(struct ucom_softc *, uint8_t *, uint8_t *); static int umodem_pre_param(struct ucom_softc *, struct termios *); static void umodem_cfg_param(struct ucom_softc *, struct termios *); +static void umodem_cfg_open(struct ucom_softc *); static int umodem_ioctl(struct ucom_softc *, uint32_t, caddr_t, int, struct thread *); static void umodem_cfg_set_dtr(struct ucom_softc *, uint8_t); @@ -282,6 +283,7 @@ static const struct ucom_callback umodem_callback = { .ucom_cfg_set_break = &umodem_cfg_set_break, .ucom_cfg_param = &umodem_cfg_param, .ucom_pre_param = &umodem_pre_param, + .ucom_cfg_open = &umodem_cfg_open, .ucom_ioctl = &umodem_ioctl, .ucom_start_read = &umodem_start_read, .ucom_stop_read = &umodem_stop_read, @@ -451,14 +453,6 @@ umodem_attach(device_t dev) goto detach; } - /* clear stall at first run, if USB host mode */ - if (uaa->usb_mode == USB_MODE_HOST) { - mtx_lock(&sc->sc_mtx); - usbd_xfer_set_stall(sc->sc_xfer[UMODEM_BULK_WR]); - usbd_xfer_set_stall(sc->sc_xfer[UMODEM_BULK_RD]); - mtx_unlock(&sc->sc_mtx); - } - ucom_set_usb_mode(&sc->sc_super_ucom, uaa->usb_mode); error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, @@ -637,6 +631,18 @@ umodem_cfg_param(struct ucom_softc *ucom, struct termios *t) &req, &ls, 0, 1000); } +static void +umodem_cfg_open(struct ucom_softc *ucom) +{ + struct umodem_softc *sc = ucom->sc_parent; + + /* clear stall, if in USB host mode */ + if ((sc->sc_super_ucom.sc_flag & UCOM_FLAG_DEVICE_MODE) == 0) { + usbd_xfer_set_stall(sc->sc_xfer[UMODEM_BULK_WR]); + usbd_xfer_set_stall(sc->sc_xfer[UMODEM_BULK_RD]); + } +} + static int umodem_ioctl(struct ucom_softc *ucom, uint32_t cmd, caddr_t data, int flag, struct thread *td)