Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] HID: nintendo: relax subcommand limiter until cadence is proven
@ 2026-09-08 22:45 Mike Lothian
  2026-09-08 22:58 ` sashiko-bot
  2026-09-08 23:43 ` [PATCH v2] " Mike Lothian
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Lothian @ 2026-09-08 22:45 UTC (permalink / raw)
  To: Daniel J . Ogorchock
  Cc: Jiri Kosina, Benjamin Tissoires, Silvan Jegen, linux-input,
	linux-kernel, Mike Lothian

joycon_config_rumble() queues a zero-rumble packet during probe. The
rumble worker sends it as soon as ctlr_state becomes READ, and
joycon_handle_rumble_report() retries it a few more times after
that. This is the first subcommand sent on every connection, and it
goes out before any input reports have been seen, so
consecutive_valid_report_deltas is still 0.
joycon_enforce_subcmd_rate_strict() requires 3 consecutive reports
in the 8-17ms window before it releases a subcommand, so this send
exhausts all 25 attempts and warns, on every connection.

Start each connection on the legacy flat-delay throttle instead of
the cadence-gated one, and switch to the strict limiter from
joycon_parse_report() once JC_SUBCMD_VALID_DELTA_REQ consecutive
reports have actually arrived at a valid cadence. Controllers that
already hit the permanent fallback in
joycon_enforce_subcmd_rate_strict() are left alone.

Found and bisected with a btmon capture over Bluetooth (MediaTek
mt7921e): the three JC_SUBCMD_RATE_MAX_ATTEMPTS warnings on connect
line up exactly with three JC_OUTPUT_RUMBLE_ONLY (0x10) frames sent
by the rumble worker's zero-countdown retries, all before the first
JC_OUTPUT_FULL_REPORT (0x30) frame has had a chance to establish
cadence. Tested on real hardware (official Pro Controller): reliable
first-attempt connect across repeated pairing/reconnect cycles,
versus dropping inside the first ~70 seconds of a fresh connection
about half the time before this change.

Fixes: d750d1480362 ("HID: nintendo: fix rumble rate limiter")
Signed-off-by: Mike Lothian <mike@fireburn.co.uk>
Assisted-by: Claude:Sonnet-5 [Claude Code]
---
 drivers/hid/hid-nintendo.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index 43e0f2aaea3b..0a169d0aa719 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -1797,8 +1797,12 @@ static void joycon_parse_report(struct joycon_ctlr *ctlr,
 	 */
 	if (report_delta_ms >= JC_INPUT_REPORT_MIN_DELTA &&
 	    report_delta_ms <= JC_INPUT_REPORT_MAX_DELTA) {
-		if (ctlr->consecutive_valid_report_deltas < JC_SUBCMD_VALID_DELTA_REQ)
+		if (ctlr->consecutive_valid_report_deltas < JC_SUBCMD_VALID_DELTA_REQ) {
 			ctlr->consecutive_valid_report_deltas++;
+			if (ctlr->consecutive_valid_report_deltas == JC_SUBCMD_VALID_DELTA_REQ &&
+			    ctlr->subcmd_rate_exhaustions < JC_SUBCMD_RATE_MAX_FAILURES)
+				ctlr->subcmd_rate_relaxed = false;
+		}
 	} else {
 		ctlr->consecutive_valid_report_deltas = 0;
 	}
@@ -2730,6 +2734,10 @@ static int nintendo_hid_probe(struct hid_device *hdev,
 
 	ctlr->hdev = hdev;
 	ctlr->ctlr_state = JOYCON_CTLR_STATE_INIT;
+	/* Promoted to the strict limiter once cadence is proven, see
+	 * joycon_parse_report().
+	 */
+	ctlr->subcmd_rate_relaxed = true;
 	ctlr->rumble_queue_head = 0;
 	ctlr->rumble_queue_tail = 0;
 	hid_set_drvdata(hdev, ctlr);
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-08 23:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 22:45 [PATCH] HID: nintendo: relax subcommand limiter until cadence is proven Mike Lothian
2026-09-08 22:58 ` sashiko-bot
2026-09-08 23:43 ` [PATCH v2] " Mike Lothian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox