From nobody Tue Feb 10 21:19:20 2026 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19BF8253B42 for ; Sun, 8 Feb 2026 17:12:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770570780; cv=none; b=BjxdMymuxJHWCtOGGFze8iO5fhSRfNfr4BgohbDJHZQaP+AmqKR6MSak0/NaYZxSPYzypQPaiCCKCP3HgQYN5KzwXaLIXCliVdzYit4CDE2ELADdY9GJLuC+CBgz3TV3S8lc9CLGXQx6d73yuef3GHZEiqkRQcnAjBSMPJzvJYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770570780; c=relaxed/simple; bh=mhdGlb1t/ORpowAdA81B+hfxkL6dR35ohtzKQDqvK14=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=ZVW9RncQWi3+Ak5XS/hx8xBCds23PwbSbneJ2ufRQfmwnZWb1ZmmbH4NaMxhIiAkDcF0EzV4dLZnhSENU8dabsQ/yYIhMYiy1WgxJjpTqz525X0HLppkjCEuMiLJeeqJZHktTnolO4MAnHsn6iU3KarPIDY0Py+mAlbRHziY54E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cX7vjSic; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cX7vjSic" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-436e87589e8so634442f8f.3 for ; Sun, 08 Feb 2026 09:12:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770570778; x=1771175578; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=pvwzpJVVWdrlZd2NDzfr6xh4JKcYdWHSQxCaogW/r78=; b=cX7vjSict1bsD0vMsB+mmRfET8M7H/i5JSv6sBnzz99nfiUSljoB0rivBaEByCgFnM 7gBQrr7NomgUPKUArdh+0Jf1npGyrodNWffxB3vnne0wmNWrQnTkXz/gaVQQP8+qALeu FUfPBz+25gwU5c+5CxjnAlgQOCvLDDwfN695h/3yJosQfcpcMnJ3Oirt2hpyyL+sM0jf FK4feTe3mm1ykHefSMrwR2UbC+ZpzPkzWPEZB1LIMbSxX0jh2YLnAwnpqDDTxMLblP8i 2kYLTdImTBzNX9tdGuUa4SQcyQEKJF4M3RYvJjVpheKc8inN8aYpna6ybzEvOrqmxoUP 6GVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770570778; x=1771175578; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pvwzpJVVWdrlZd2NDzfr6xh4JKcYdWHSQxCaogW/r78=; b=TjeTJpM9wTtoaVpVCIQ0J3leaxOYSo347odg2EfEQ+SdFOyCpvAT88FxHZA4VSwPtx XkIOlMu2MFsJzMD8h9fXLrVHS3/BBm+CwpO5NY5zwG+za84C7K00DCSXAOfOzJPzLqdo YVF8jE70ybZZNCynHF/xvNr0uVrB5hjC8Xp4Spy8sj+jAXsCFiBYDCXkX7sYzwhEIj8B OzEx74JkOHf6lYyHKQHVDfVfMszAou3yEBKi2sAAtTDSm0cOpoF8NJB8UW4QJBs0jbrF FmzWhuYy2/4cWOimmZ0erBOZnY+n01L6PRxQGxXi8tGosCgA4GNwoJRQ/2cYrdkbxwAB 6G6Q== X-Forwarded-Encrypted: i=1; AJvYcCV64h3G2lpuD9eRq//odvMcl1fhHKy5IFo4u+KNAITobMUR88Cv4fzuPSz1EO6MJfr6rTYt21dfZHy8SbM=@vger.kernel.org X-Gm-Message-State: AOJu0YwxxsZNbKwWHS4v7JxfHTFtMPbkXCzOInDxvXVvdlMS+yNL1vfN fDB8pbdc+q/pcXa9L8mJaRNwbH5NoXYVoR8pKueWFcL0sY0MTNGRSSd4 X-Gm-Gg: AZuq6aJ5aTvsR3bmIvGdM39aUieN4oEE5OtF92m8uLMyfr6jGx7zq9rWO1q6Q+igoT9 /kuBOBuSF1CNnQPVoE0NfkhYGaq4uPf3s2hNcNNv8pqyltN5t+6BwzlACw4/s21jN0xArrbomH3 Z+49KlHoYIY6Fw4oFfUuoip00l2uoxQIZINXmuaCcsa/NASx6cpHuW1WLxU55bTiCQ5eVnv0qp/ glASCBpvibxgUTSYzVhNTuwC6iJxMTlwLHGAqqo5fGiBvuF35Y5FByXrWz8iiG1/RakyVgPGhQz H1FS8SlW2yjDhLbPBk4uFsA4Zs0hde3/PnhE18XSl528khfmb6vIkiehDsCZpH8JU+Vs5axbI7b syueGYZFJGTYkmMVA/XZTxpyzfJXNTB3nQEhLbaFYJ+B79L5HfjbajfEHAd6ThXaBMQ5Vb2s11m vLfGFJFHjzxZd2hjDLDuZZIP2dPA== X-Received: by 2002:a5d:5f88:0:b0:431:35a:4a8f with SMTP id ffacd0b85a97d-4362938ffacmr13963638f8f.47.1770570778245; Sun, 08 Feb 2026 09:12:58 -0800 (PST) Received: from [192.168.178.21] ([2001:9e8:fb98:1600:22c9:d0ff:fe7b:79cb]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4376accfc0bsm5451770f8f.32.2026.02.08.09.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Feb 2026 09:12:57 -0800 (PST) From: Liam Mitchell Date: Sun, 08 Feb 2026 18:10:19 +0100 Subject: [PATCH] usbhid: tolerate intermittent errors Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260208-usbhid-eproto-v1-1-5872c10d90bb@gmail.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIzMDIwML3dLipIzMFN3UgqL8knxdQ1OjZPPEpOQkQwtTJaCegqLUtMwKsHn RsbW1AOpKY4hfAAAA X-Change-ID: 20260208-usbhid-eproto-152c7abcb185 To: Jiri Kosina , Benjamin Tissoires Cc: Alan Stern , linux-usb@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Liam Mitchell X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1770570777; l=3087; i=mitchell.liam@gmail.com; s=20260207; h=from:subject:message-id; bh=mhdGlb1t/ORpowAdA81B+hfxkL6dR35ohtzKQDqvK14=; b=Ya3bIaypa9Ewxl1KQHmRS4/NfpBCMUt3ZTOCfdVztCt1pod1ob43r+3jt4L5nUqpATl1H2SpA knKUZSaLzxZB/aMVifGEFE/OxK+fpTZtXWv61BVpxlOX5chism183Z1 X-Developer-Key: i=mitchell.liam@gmail.com; a=ed25519; pk=Y9mPqBk1OuHZ0OaUZ5a8Nc5X7YHs7+SKiNwUfcLfPmg= Modifies the usbhid error handling logic to better handle intermittent errors like EPROTO, which should only need resubmission of URBs and not full device reset. Reduces initial retry delay from 13ms to 1ms. The faster the URB is resubmitted, the lower the chance that user events will be missed. Increases retry delay multiplier from 2 to 5, reaching max delay in a similar number of retries. Adds another check to the reset block, only resetting if retry_delay has reached max, effectively only allowing reset after 4 errors. --- The usbhid driver will reset a device after only two errors 1-1.5s apart. The first error will be handled with a retry after 13ms. Handling of the second error depends on the time since the first: * <1000ms: retry after 26ms * >1000ms & <1500ms: reset USB device, taking maybe hundreds of ms * >1500ms: retry after 13ms It doesn't take into account the type, count or timing of errors. EPROTO errors can occur randomly, sometimes frequently and are often not fixed by a device reset. Retry delays or device resets only raise the chance that input events will be missed and that users see symptoms like missed or sticky keyboard keys. See following thread for more details: https://lore.kernel.org/linux-input/CAOQ1CL6Q+4GNy=3DkgisLzs0UBXFT3b02PG8t-= 0rPuW-Wf6NhQ6g@mail.gmail.com/ The following patch is a minimal change to better tolerate intermittent err= ors. Using existing variables, we reduce initial retry delays and only reset in the 1000-1500ms window if 4+ errors have occurred. This should reduce issues for users with intermittent errors and retain the intended retry-backoff-reset for erroring devices that need a reset. More comprehensive error handling could involve counting errors, time betwe= en errors and/or switching on error type but would be more invasive. Signed-off-by: Liam Mitchell --- drivers/hid/usbhid/hid-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index aac0051a2cf6..b6e956ca781b 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -160,12 +160,12 @@ static void hid_io_error(struct hid_device *hid) =20 /* When an error occurs, retry at increasing intervals */ if (usbhid->retry_delay =3D=3D 0) { - usbhid->retry_delay =3D 13; /* Then 26, 52, 104, 104, ... */ + usbhid->retry_delay =3D 1; /* Then 5, 25, 125, 125, ... */ usbhid->stop_retry =3D jiffies + msecs_to_jiffies(1000); } else if (usbhid->retry_delay < 100) - usbhid->retry_delay *=3D 2; + usbhid->retry_delay *=3D 5; =20 - if (time_after(jiffies, usbhid->stop_retry)) { + if (time_after(jiffies, usbhid->stop_retry) && usbhid->retry_delay >=3D 1= 00) { =20 /* Retries failed, so do a port reset unless we lack bandwidth*/ if (!test_bit(HID_NO_BANDWIDTH, &usbhid->iofl) --- base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449 change-id: 20260208-usbhid-eproto-152c7abcb185 Best regards, --=20 Liam Mitchell