Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v14 2/4] HID: nintendo: Add rumble support for Switch 2 controllers
Date: Tue, 29 Sep 2026 05:15:04 +0000	[thread overview]
Message-ID: <20260929051505.05FC31F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929045607.2106149-3-vi@endrift.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hid: timer catch-up storm in switch2_rumble_work() floods USB bus
--

commit d6948b1b7d2b1cb761599f94b49e78c667724675
Author: Vicki Pfau <vi@endrift.com>

HID: nintendo: Add rumble support for Switch 2 controllers

This commit adds rumble support for Switch 2 controllers, handling both the
HD Rumble linear resonant actuator type and the GameCube eccentric rotating
mass type. It implements a basic simulation of these rumble effects using
delayed work.

> diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
> index 3a7c35375be60..e965076b10345 100644
> --- a/drivers/hid/hid-nintendo.c
> +++ b/drivers/hid/hid-nintendo.c
[ ... ]
> @@ -3251,6 +3305,128 @@ static void switch2_kref_put(struct kref *refcount)
[ ... ]
> +static void switch2_rumble_work(struct work_struct *work)
> +{
[ ... ]
> +	if (active) {
> +		unsigned long interval = msecs_to_jiffies(4);
> +		uint64_t current_jiffies = get_jiffies_64();
> +
> +		if (!ns2->last_rumble_work)
> +			ns2->last_rumble_work = current_jiffies;
> +		else
> +			ns2->last_rumble_work += interval;
> +
> +		/* Reschedule a little early to make sure the buffer never underruns */
> +		interval -= msecs_to_jiffies(2);
> +		if (ns2->last_rumble_work + interval >= current_jiffies)
> +			schedule_delayed_work(&ns2->rumble_work,
> +				ns2->last_rumble_work + interval - current_jiffies);
> +		else
> +			schedule_delayed_work(&ns2->rumble_work, 0);

[Severity: Medium]
Could this logic lead to a timer catch-up storm?

If the worker execution is delayed (for example, due to CPU load, workqueue
starvation, or a suspend/resume cycle), the target time is only advanced by
4ms on each execution, while the system time may be much further ahead.

When this happens, the work immediately reschedules itself with a 0 delay.
Because it might take many executions to catch up to the current time 4ms
at a time, this could loop rapidly. Is there a risk that this will hog the
workqueue and flood the USB subsystem with back-to-back synchronous
hid_hw_output_report calls, which might also distort the intended 4ms haptic
cadence?

> +	} else {
> +		ns2->last_rumble_work = 0;
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260929045607.2106149-1-vi@endrift.com?part=2

  reply	other threads:[~2026-09-29  5:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29  4:56 [PATCH v14 0/4] HID: nintendo: Add preliminary Switch 2 controller driver Vicki Pfau
2026-09-29  4:56 ` [PATCH v14 1/4] " Vicki Pfau
2026-09-29  5:11   ` sashiko-bot
2026-09-29  4:56 ` [PATCH v14 2/4] HID: nintendo: Add rumble support for Switch 2 controllers Vicki Pfau
2026-09-29  5:15   ` sashiko-bot [this message]
2026-09-29  4:56 ` [PATCH v14 3/4] HID: nintendo: Add unified report format support Vicki Pfau
2026-09-29  4:56 ` [PATCH v14 4/4] HID: nintendo: Patch NYXI Hyperion 3 descriptor Vicki Pfau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260929051505.05FC31F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vi@endrift.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox