Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Martin Oberleiter" <martin.oberleiter@netixx.it>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2] HID: steelseries: Fix Arctis 7 battery reading 3% on overlapping requests
Date: Thu, 03 Dec 2026 18:53:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-248434@kernel.org> (raw)
In-Reply-To: <20261203-arctis7-battery-v2-1-5ea29f516329@netixx.it>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: steelseries: unlocked reinit_completion() races with
  complete()
--

commit 237c0ec6e1bd62a83cc766060cfd1c8607a35320
Author: Martin Oberleiter <martin.oberleiter@netixx.it>

HID: steelseries: Fix Arctis 7 battery reading 3% on overlapping requests

This commit makes the Arctis 7 (2018) status poll wait on a completion for
the 0x14 connection status reply before sending the 0x18 battery request,
and skips the battery request if the headset is not connected or the reply
times out.

> diff --git a/drivers/hid/hid-steelseries-arctis.c b/drivers/hid/hid-steelseries-arctis.c
> index df61fa33d4c68..7b83ff8a361bd 100644
> --- a/drivers/hid/hid-steelseries-arctis.c
> +++ b/drivers/hid/hid-steelseries-arctis.c

[ ... ]

> @@ -101,16 +103,44 @@ static int steelseries_arctis_1_request_status(struct hid_device *hdev)
>  	return steelseries_send_output_report(hdev, data, sizeof(data));
>  }
>  
> +#define STEELSERIES_ARCTIS_7_REPLY_TIMEOUT_MS	100
> +
>  static int steelseries_arctis_7_2018_request_status(struct hid_device *hdev)
>  {
> +	struct steelseries_device *sd = hid_get_drvdata(hdev);
>  	const u8 connection[] = { 0x06, 0x14 };
>  	const u8 battery[] = { 0x06, 0x18 };
> +	unsigned long flags;
> +	bool connected;
>  	int ret;
>  
> +	reinit_completion(&sd->connection_reply);

[Severity: Medium]
Can reinit_completion(&sd->connection_reply) race with complete() in
steelseries_arctis_7_2018_parse_status()?

reinit_completion() performs an unlocked plain store (x->done = 0), while
steelseries_arctis_raw_event() holds sd->lock and calls complete() on every
incoming 0x06 0x14 report (for instance, a delayed reply arriving after a
previous 100 ms timeout).  complete() does a non-atomic read-modify-write on
x->done under x->wait.lock:

CPU0 (kworker)                CPU1 (<softirq>)
steelseries_arctis_7_2018_request_status()
                              steelseries_arctis_raw_event()
                                spin_lock_irqsave(&sd->lock, ...)
                                ... -> parse_status()
                                  complete(&sd->connection_reply)
                                    load x->done
  reinit_completion(...)
    x->done = 0  <-- data race
                                    store x->done + 1

If complete() overwrites the zero reset with a stale non-zero count,
wait_for_completion_timeout() returns immediately and sends the 0x18 battery
request back-to-back with the 0x14 request, re-triggering the overlapping
request issue.

Wrapping reinit_completion(&sd->connection_reply) in sd->lock serializes it
with complete() in steelseries_arctis_raw_event().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-arctis7-battery-v2-1-5ea29f516329@netixx.it?part=1

      reply	other threads:[~2026-12-03 18:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 18:23 [PATCH v2] HID: steelseries: Fix Arctis 7 battery reading 3% on overlapping requests Martin Oberleiter via B4 Relay
2026-12-03 18:53 ` 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=sashiko-outbox-248434@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=martin.oberleiter@netixx.it \
    --cc=sashiko-reviews@lists.linux.dev \
    /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