From nobody Tue Sep 6 08:43:56 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 4MMJp44hyFz4cVsg; Tue, 6 Sep 2022 08:43:56 +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 4MMJp444nsz3fCc; Tue, 6 Sep 2022 08:43:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662453836; 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=uBeC0POpG1ZK6IkcXWPEGXZarTBNnMOdoskfNZpOqcM=; b=LM9fdi/aDDIHQPzgsIUWi7cBjh+NPCH6LcNTDcBl6W1uI2KB+TIHmqa2/qtzDLaCIfWqsQ k90NZExLTQEz1qSh3+rGbPGa9VuMkEJyW4Bn/QPj+284npZDtjSGa7fx7WhhTvhMgj1Lln RKAr8sf0W3V0NttZs1nn1L7Fpvrl82ljy8HqvEtIOuwQx+/Q6fp2yoH6ob/ZwE7vwjNETY uKnU5n1yTBkOEpUf6Ne0fxM/KHbTyMuYIBnAE+g4eEgpdW1XNf2A+nwpIsE3Znoy6dJ58x ZrK4KNAQOCYAsObSeOcSM0JLKrBGm3igS6+jyBZYnzWHtfs5vn/BhH1LqogEVw== 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 4MMJp438LJz16h2; Tue, 6 Sep 2022 08:43:56 +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 2868hu3U037628; Tue, 6 Sep 2022 08:43:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2868hu5v037627; Tue, 6 Sep 2022 08:43:56 GMT (envelope-from git) Date: Tue, 6 Sep 2022 08:43:56 GMT Message-Id: <202209060843.2868hu5v037627@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: 56caa9e82b46 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 56caa9e82b46eeea3c7c21b44e7170d77a61b492 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662453836; 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=uBeC0POpG1ZK6IkcXWPEGXZarTBNnMOdoskfNZpOqcM=; b=uI1OHwinSZ4ReC5BdSgNkUzdab7BpnTpx9RYd8fSNhiA1Z5ZgYcYB27dPB5C+arGyvOkOk SlfVK0wd5CPKTRfQ/HwLNRmkxmqZsyt9gdtlMcJmBBHOywsQvfkjzXvILNDCpPznFkYyrj jbs9pzkdXCIyh9FvxGjoyIrBKtDYleVuwgjj3R8IniQJzkpmb+qy82v8QZ4eBxuEEdzlGY VHW2nwlshvlWnp2bvgw2Ju2GsFMyOMtyIinjhM5uoihez7jm29LHcDPWuopB8Fa01hLZ1Z RKzfh7HbP0CZutbjjVRtBeClTIDmhhn3fjsddT2s3UcUoTCUI6Dmd7E4/+cesg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662453836; a=rsa-sha256; cv=none; b=TkaqmtDMhNHmfFP6Q1zIlh1V4WCtVEwgT/IN465tdaIXTU+0WtwNjpQvbGSYr74LvJrAEX /M8ECFlEtdTu8ugxSkkzdKFQiGvY85karKN5yyltDotPaG9KrJyv5RG+JVsbwI0nLDxYhB rqMgBE+GDw4PH4XMLe2tX3S8sRHiHwWF96NhddqIrx+up7NQEtoI1Jb1GTIwh9jYgs10AM Q8941clVCRSJ/W6Io6izftdLrlJ+DcJLsy5LEyTyRcwYn7+KuNT+EO9VXM7zxamG0wqHWE goErt68Qa7KBh9RJ9y1zxOkTyUaa2+bLp4Vzz45MHej4X7PJuXtS+OyavLsvAg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=56caa9e82b46eeea3c7c21b44e7170d77a61b492 commit 56caa9e82b46eeea3c7c21b44e7170d77a61b492 Author: Hans Petter Selasky AuthorDate: 2022-08-30 14:01:43 +0000 Commit: Hans Petter Selasky CommitDate: 2022-09-06 08:43:17 +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 4fa108e962f2..c4aba1bdd3e2 100644 --- a/sys/dev/usb/serial/umodem.c +++ b/sys/dev/usb/serial/umodem.c @@ -218,6 +218,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); @@ -283,6 +284,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, @@ -449,14 +451,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, @@ -635,6 +629,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)