Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christos Maragkos" <whitetowersoftware@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH] HID: nintendo: Fix imu_timestamp_us double increment per report
Date: Wed, 03 Jun 2026 15:34:32 +0000	[thread overview]
Message-ID: <20260603153432.E4C931F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260603152134.94439-1-whitetowersoftware@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing dropped packet compensation causes cumulative IMU timestamp lag.
--

commit ad128b0e7b6200fd6acd6f6287071433e2058d5a
Author: Christos Maragkos <whitetowersoftware@gmail.com>

HID: nintendo: Fix imu_timestamp_us double increment per report

This commit fixes an issue where the imu_timestamp_us variable was incremented
twice per report. It removes the redundant increment at the start of the
report handling to ensure accurate timing for userspace applications.

> diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
> --- a/drivers/hid/hid-nintendo.c
> +++ b/drivers/hid/hid-nintendo.c
> @@ -1453,7 +1453,6 @@ static void joycon_parse_imu_report(struct joycon_ctlr *ctlr,
>  		dropped_threshold = ctlr->imu_avg_delta_ms * 3 / 2;
>  		dropped_pkts = (delta - min(delta, dropped_threshold)) /
>  				ctlr->imu_avg_delta_ms;
> -		ctlr->imu_timestamp_us += 1000 * ctlr->imu_avg_delta_ms;
>  		if (dropped_pkts > JC_IMU_DROPPED_PKT_WARNING) {
>  			hid_warn_ratelimited(ctlr->hdev,
>  				 "compensating for %u dropped IMU reports\n",
>  				 dropped_pkts);
>  			hid_warn_ratelimited(ctlr->hdev,
>  				 "delta=%u avg_delta=%u\n",
>  				 delta, ctlr->imu_avg_delta_ms);
>  		}

[Severity: High]
This is a pre-existing issue, but while the timestamp logic is being
modified here in joycon_parse_imu_report(), the code calculates dropped_pkts
and logs a warning about compensating for dropped IMU reports, but completely
lacks the logic to actually add the dropped time to imu_timestamp_us.

Because the driver only increments the timestamp for the 15ms window of
the received samples later in the function, dropped intervals are silently
omitted. Over a gaming session, will this cause the controller's timestamp
to accumulate permanent lag relative to real time, breaking sensor fusion
or gyro aiming in userspace?

Additionally, does the existing formula for dropped_pkts undercount by 1,
yielding 0 for a single dropped packet? Would it be better to correct this
formula (for example, (delta + avg / 2) / avg - 1) so it can accurately
perform the missing compensation?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260603152134.94439-1-whitetowersoftware@gmail.com?part=1

      reply	other threads:[~2026-06-03 15:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 15:21 [PATCH] HID: nintendo: Fix imu_timestamp_us double increment per report Christos Maragkos
2026-06-03 15:34 ` sashiko-bot [this message]

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=20260603153432.E4C931F00898@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=whitetowersoftware@gmail.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