From nobody Mon Nov 14 20:09:41 2022 X-Original-To: dev-commits-src-main@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 4NB0lT55zdz4dDKW; Mon, 14 Nov 2022 20:09:41 +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 4NB0lT4Ll2z3Lk6; Mon, 14 Nov 2022 20:09:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668456581; 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=eRAnmM4K23zbSqYph59S2tE8KXvNxx8bbNI8kRICszw=; b=o6AJTW7c8R9P77cWw4Lb/JD12FBhWtLgjEV9oKcDKdal499WoxoW+sAUpkQPyBtpRajlT/ F2Tr/HSW/Eod791X+RYLveFH2bo0LnRkfk1AEjZrJT29k140Y6YS16R2amBEkTaxtedeLM GQzUFdyvi7fEvhRBl60A3c6KSjkefAkHyEHkg8EK7dCi14mTkliFB/GXUhiTJvseVgdtFb 4cLa6P0XFlupHFxyBvRVffLE2LnGT+71R6R+/q4gwYPTkUWYt14P0IxZe4QGmNZitYdWuW UWeiDMjfmu/cE8JnihpNfArfQWGvZAFhddygw0nqVlm2f/hKdBQoesMyABvtZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668456581; 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=eRAnmM4K23zbSqYph59S2tE8KXvNxx8bbNI8kRICszw=; b=wMJZ98M973SCFd/XDSmlPkoZ4hSUSlyxhMfsaSY91UZvbBT5K79c5eilzpZNagDpJZlVv1 3164UP+A58+Es4eNyvzB+kMacWXqDnHynwV5vvfVWag9mJMQECo8M/Y4eb7HGov5gCupe6 OTj2XJC4lB5/WE33JXdkbT7BRoMp4FNIO4aLdVB/9oc8Y/Z3TJP6g1lgzjd8yIpqcEGpbZ c20eFX1P409SkVyVge04ZR5fR1y1Wj3HPuq00mYS6VAj3iZxqStB5z9pBj7n92DHQk6xZQ LYsT82ikh2yJ9TnvV3gIuSBwdl/QC2LbhEg1hDT0TS3wzTOxStXXgH7dcOgegA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668456581; a=rsa-sha256; cv=none; b=aFUPzGo4TrpCwOtbPc1h05GzbvmMcH3dmVNwDntP35wZm5t3o0Xygdya2j++SBpNDkxK7e HcacYZztNgjFWKLQ1HjBd4yxeNSugRUSUvwVwyAcyiA6bIhuyWmR2K3vF0umG2CjpH/D7/ PBIKXB02DfJHhW/7F99SEfVr0vl3VzOAsywfZSi6j5nc0R//VjRnfDWlo+uTwkt+nVV4Zu D5AFsQohsu5tQbZVhIC5rnB/SFrmvIuy77vZ820XSFMqNBiJIDh1+OnYta2Jf4Bnr97t/p PuBiM82jxjCFvqYA6Jb9Gscx0AvtyEV1oQskBJ65egDEstih1kcRFLHbuqUmxw== 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 4NB0lT3FLrzvcc; Mon, 14 Nov 2022 20:09:41 +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 2AEK9foJ081475; Mon, 14 Nov 2022 20:09:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AEK9fuH081474; Mon, 14 Nov 2022 20:09:41 GMT (envelope-from git) Date: Mon, 14 Nov 2022 20:09:41 GMT Message-Id: <202211142009.2AEK9fuH081474@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c4c368fb3ecc - main - bhyve: Simplify control flow in the xhci device model List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c4c368fb3ecc426660f79b1c25f18d0401ff96fc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c4c368fb3ecc426660f79b1c25f18d0401ff96fc commit c4c368fb3ecc426660f79b1c25f18d0401ff96fc Author: Mark Johnston AuthorDate: 2022-11-14 20:08:45 +0000 Commit: Mark Johnston CommitDate: 2022-11-14 20:08:45 +0000 bhyve: Simplify control flow in the xhci device model We only need to call pci_xhci_xfer_complete() when handling a transfer to the control endpoint, so move that code into the epid == 1 block and eliminate a goto. Also remove an unneeded reinitialization of setup_trb. No functional change intended. MFC after: 1 week Reviewed by: corvink, jhb Differential Revision: https://reviews.freebsd.org/D37287 --- usr.sbin/bhyve/pci_xhci.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/usr.sbin/bhyve/pci_xhci.c b/usr.sbin/bhyve/pci_xhci.c index 8eff332099df..0d8122ee8c90 100644 --- a/usr.sbin/bhyve/pci_xhci.c +++ b/usr.sbin/bhyve/pci_xhci.c @@ -1725,7 +1725,7 @@ pci_xhci_handle_transfer(struct pci_xhci_softc *sc, DPRINTF(("pci_xhci handle_transfer slot %u", slot)); retry: - err = 0; + err = XHCI_TRB_ERROR_INVALID; do_retry = 0; do_intr = 0; setup_trb = NULL; @@ -1849,24 +1849,26 @@ retry: goto errout; if (epid == 1) { - err = USB_ERR_NOT_STARTED; + int usberr; + if (dev->dev_ue->ue_request != NULL) - err = dev->dev_ue->ue_request(dev->dev_sc, xfer); - setup_trb = NULL; + usberr = dev->dev_ue->ue_request(dev->dev_sc, xfer); + else + usberr = USB_ERR_NOT_STARTED; + err = USB_TO_XHCI_ERR(usberr); + if (err == XHCI_TRB_ERROR_SUCCESS || + err == XHCI_TRB_ERROR_STALL || + err == XHCI_TRB_ERROR_SHORT_PKT) { + err = pci_xhci_xfer_complete(sc, xfer, slot, epid, + &do_intr); + if (err != XHCI_TRB_ERROR_SUCCESS) + do_retry = 0; + } + } else { /* handle data transfer */ pci_xhci_try_usb_xfer(sc, dev, devep, ep_ctx, slot, epid); err = XHCI_TRB_ERROR_SUCCESS; - goto errout; - } - - err = USB_TO_XHCI_ERR(err); - if ((err == XHCI_TRB_ERROR_SUCCESS) || - (err == XHCI_TRB_ERROR_STALL) || - (err == XHCI_TRB_ERROR_SHORT_PKT)) { - err = pci_xhci_xfer_complete(sc, xfer, slot, epid, &do_intr); - if (err != XHCI_TRB_ERROR_SUCCESS) - do_retry = 0; } errout: