From nobody Thu Jun 25 23:04:41 2026 X-Original-To: dev-commits-src-all@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 4gmZBf011fz6jWc9 for ; Thu, 25 Jun 2026 23:04:42 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gmZBd6T3Nz3rN6 for ; Thu, 25 Jun 2026 23:04:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782428681; 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=Avy9Wcp+iukgLyHJy+srNYQT+KPPsStqvBSgHRKVI/o=; b=PnjHMCeTykykmqbX94dMvHJozpJSZlsUq14+mkEiizYQ2EMB2H0EocIAJJCND0RmjwUEyL TRpHqGFlnB8H8Gu7sMhEt69yz9A6dos8w5JQkdnGKTHuS7kHH44fhxFf1dAwnfQx0vEfnt 6ybEeLUZZZX7et6wXj8K0mSxVOVbZ8zegWwP3uzjiu1ldceNSZCBa2Fmf8gfoqPlB32/3f i7G+fT32qiljeqFqcgAaK9Err1cRh2xfEfK/pLQAPq3BaoYdlTg8qLZSg6FlYMHsD8cH0T Gbyqu1t2mtuu8QPP3eY/vpVsETalnyPySzkpzNLhb6HxqD0xzF5IZZasEUWCvQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782428681; a=rsa-sha256; cv=none; b=TM6cQnMmYNniyEEZNxsImifPqikTfBTpr9pNU1S/3Qu1At3R0SZ7hOk/OgenM+CYvKtXkG do0SU1dB5pxmmeIrUe7ExHJERHSXNkIVFzNMjnq423jy+3yAhKDHk+hXfbXCZ+1GT4kYiR jyXA2s4arRLErg45gLi2aRsQIec3BfWT8P0WwO9w9lKBiqJstoGaNWJdFs0ZUhBajPWk2d nYtxeTD9qCqsOqPn8/LrRwsQmJb/WIgbWbziX4qcxI/Pct5ZQNVtUcLWKu2s+Bb42j6LJB /r5g05xhs/6Dmcd+s/409PH3OvDaOyVJV88F4UpBYuuR9JkqXkvmTMd4sisfPw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782428681; 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=Avy9Wcp+iukgLyHJy+srNYQT+KPPsStqvBSgHRKVI/o=; b=aeJeD9Fi9t06/IdIXG6BZGE/dn8N1Mmhu73cng8Aszfz3CguSPOcbCf+1yrp6GdCgii6IO wKgrF9ZrlB5Bqi8gshOgLfc5UuQHujA0X0bglTaRf/dPintRYIUDHZ45nwrOpI8QNoAqzE OwkADou7FrdTvYefuHVhQqyjxgaYRd5ockm2KckhCxYODlfFvL/TpUnWH/0W/jOXUS3Spl aDGpLpX297bxb+tLEkaKwEDRht2ovGTvWAQy+i8nFgiHHlaLc03qztnu6rqFrSFiPJbHNz U0CoZGygauhVUR77zRPYRqeKoKD2T25KCwe6rjtRYSBo7oHzY9ACf4NgfPrVBA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gmZBd5B44z1QLF for ; Thu, 25 Jun 2026 23:04:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 32d11 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 25 Jun 2026 23:04:41 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: 240330a85e5f - main - libusb: don't treat EINVAL from USB_FS_COMPLETE as device detach List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: aokblast X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 240330a85e5f7f5d448123902ebee4136ef221fd Auto-Submitted: auto-generated Date: Thu, 25 Jun 2026 23:04:41 +0000 Message-Id: <6a3db409.32d11.15fc5b49@gitrepo.freebsd.org> The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=240330a85e5f7f5d448123902ebee4136ef221fd commit 240330a85e5f7f5d448123902ebee4136ef221fd Author: ShengYi Hung AuthorDate: 2026-06-25 22:38:17 +0000 Commit: ShengYi Hung CommitDate: 2026-06-25 22:58:23 +0000 libusb: don't treat EINVAL from USB_FS_COMPLETE as device detach ugen20_process() treats any non-EBUSY errno returned by USB_FS_COMPLETE as device detach and returns LIBUSB20_ERROR_OTHER. This causes libusb10 to set device_is_gone and fail all subsequent transfer with LIBUSB_ERROR_NO_DEVICE. However, USB_FS_COMPLETE can also return EINVAL when a completion references an endpoint that no longer exists, for example after SET_INTERFACE or SET_CONFIG removes and recreates endpoints. This is a transient condition and does not indicate device detach. Treat EINVAL the same as EBUSY and stop draining completions. This prevents a guest selecting an isochronous streaming altsetting from permanently breaking the passed-through device. Reviewed by: bapt Event: Halifax Hackathon 202606 Location: Peggy's Cove Rock Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57542 --- lib/libusb/libusb20_ugen20.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c index 6c838814a45d..32c8d53cd611 100644 --- a/lib/libusb/libusb20_ugen20.c +++ b/lib/libusb/libusb20_ugen20.c @@ -765,7 +765,16 @@ ugen20_process(struct libusb20_device *pdev) while (1) { if (ioctl(pdev->file, IOUSB(USB_FS_COMPLETE), &temp)) { - if (errno == EBUSY) { + if (errno == EBUSY || errno == EINVAL) { + /* + * EBUSY: no completion is pending. + * EINVAL: a dequeued completion referenced an + * endpoint that no longer exists, e.g. a stale + * completion left over after a SET_INTERFACE / + * SET_CONFIG tore the endpoints down. This is not + * a device detach, so stop draining rather than + * declaring the device gone. + */ break; } else { /* device detached */