From nobody Mon Nov 23 04:18:02 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.dev Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793203697067770.9442000234956; Wed, 28 Oct 2026 09:08:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xM6By-0001Bx-DE; Wed, 28 Oct 2026 12:07:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xM6Bp-00017Q-TT for qemu-devel@nongnu.org; Wed, 28 Oct 2026 12:07:50 -0400 Received: from out-185.mta1.migadu.com ([95.215.58.185] helo=mta1.migadu.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xM6Bl-00059V-DB for qemu-devel@nongnu.org; Wed, 28 Oct 2026 12:07:48 -0400 Received: by smtp.migadu.com with ESMTPS id b1889528c61227af; Wed, 28 Oct 2026 16:07:41 +0000 X-Envelope-To: qemu-devel@nongnu.org DKIM-Signature: a=rsa-sha256; bh=CC+n9M+e/BqssdwLRIy9oa/TvpyF3v8MjmdKwGPjIAA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793203661; v=1; x=1793808461; b=m1NrmLs15iMTkYaqr/Vw+QYHnL1TDN60XK6ijlh3V2/fzipbzDGwqffzhl6fmE/HDJTBZZyg bsOorfInTJ+sLzKEYCd6GWyn5aVfpSrzSaGtN7RTGvW7w3Abl6A2CYVMdlYfSp4gy4zRmz+Xha8 RZFZsdjQRF8qqtEcxH9GxT+A= X-Envelope-To: qemu-devel@nongnu.org X-Mizu-Trace-ID: b1889528c61227af X-Migadu-Flow: FLOW_OUT From: Junjie Cao To: qemu-devel@nongnu.org Cc: thuth@redhat.com, marcandre.lureau@redhat.com, sundayjiang@tencent.com, kraxel@redhat.com, fa1rid@live.com, qemu-stable@nongnu.org, junjie.cao@linux.dev Subject: [PATCH] usb-host: reset the open retry count after a successful open Date: Wed, 28 Oct 2026 11:07:27 -0500 Message-ID: <20261028160727.780978-1-junjie.cao@linux.dev> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=95.215.58.185; envelope-from=junjie.cao@linux.dev; helo=mta1.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1793203703860158500 Content-Type: text/plain; charset="utf-8" usb_host_auto_check() gives up on a matching device once three opens have failed, and clears the failure count only when a scan finds no matching device at all. A device that re-enumerates, e.g. after a firmware reboot, is closed on NO_DEVICE and usb_host_close() rescans at once, while libusb still lists the old address: that open fails and counts, the next 2 s scan opens the new address, and nothing clears the count. After the third such cycle the device is skipped until a scan finds it absent or the usb-host device is re-added. Clear the count once an open succeeds. A device that cannot be opened at all still stops after three attempts. The source-level fixture attached to #4673 reproduces the same sequence; its remaining cases expect a failure budget per enumerated device, which this change does not add. Fixes: 3ee886c5ba77 ("usb-host: limit open retries") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4631 Buglink: https://gitlab.com/qemu-project/qemu/-/issues/4673 Cc: qemu-stable@nongnu.org Reported-by: Farid Reported-by: Prateek Rungta Suggested-by: Farid Signed-off-by: Junjie Cao --- The source-level fixture attached to #4673: 15 tests, 7 failures on master d29412cca5, 5 with this change. The two reconnect scenarios pass (repeated-reconnects, success-resets-own-budget). Of the other five, four expect a failure budget per enumerated device and one expects a libusb_get_device_list() error not to reset the count; both are outside this change. Farid's attached patch resets the count inside usb_host_open(); this one keeps it next to the failure count in usb_host_auto_check(). hw/usb/host-libusb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 8f7ced95cf..5a369e2ebf 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1924,6 +1924,7 @@ static void usb_host_auto_check(void *unused) s->errcount++; continue; } + s->errcount =3D 0; break; } } --=20 2.43.0