From: "Derek J. Clark" <derekjohn.clark@gmail.com>
To: jikos@kernel.org, bentiss@kernel.org
Cc: linux-input@vger.kernel.org,
kernel@lists.opengamingcollective.org,
gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
pgriffais@valvesoftware.com, derekjohn.clark@gmail.com,
stable@vger.kernel.org
Subject: [PATCH 4/8] HID: hid-msi: Re-init on reset during resume
Date: Thu, 3 Dec 2026 16:18:42 -0800 [thread overview]
Message-ID: <20261204001846.3801336-5-derekjohn.clark@gmail.com> (raw)
In-Reply-To: <20261204001846.3801336-1-derekjohn.clark@gmail.com>
A resume that resets the device goes to .reset_resume, which hid-msi
does not currently implement. The driver keeps its pre-suspend view of
the MCU, so gamepad_mode reports a mode the MCU is not in and the next
write pushes the stale mkeys_function back to it.
Register msi_reset_resume and mark that resume as a resync so cfg_setup
re-reads the gamepad mode and the RGB profile. The flag clears only once
both reads complete, so a re-read cut short by another suspend is
retried.
The RGB re-read also makes claw_profile_event() a runtime writer of
rgb_speed and led_cdev.brightness. Before it, that handler reached those
fields only during probe.
Fixes: a9517958e828 ("HID: hid-msi: Add MSI Claw configuration driver")
Cc: stable@vger.kernel.org
Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
---
drivers/hid/hid-msi.c | 44 +++++++++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 8 deletions(-)
diff --git a/drivers/hid/hid-msi.c b/drivers/hid/hid-msi.c
index c7b7399ef930..606ff7d65276 100644
--- a/drivers/hid/hid-msi.c
+++ b/drivers/hid/hid-msi.c
@@ -345,6 +345,7 @@ struct claw_drvdata {
u8 waiting_cmd;
int cmd_status;
u16 bcd_device;
+ bool resync; /* Re-read MCU state, set on resume after a device reset */
u8 ep;
/* Gamepad Variables */
@@ -1753,6 +1754,10 @@ static void cfg_setup_fn(struct work_struct *work)
/* Add sysfs attributes after we get the device state */
try_gamepad:
+ if (gamepad_ready && (rgb_ready || !drvdata->rgb_addr))
+ /* Pairs with smp_load_acquire from cfg_resume_fn in system_percpu_wq context */
+ smp_store_release(&drvdata->resync, false);
+
scoped_guard(spinlock_irqsave, &drvdata->registration_lock)
/* Pairs with smp_store_release from below */
gp_registered = smp_load_acquire(&drvdata->gp_registered);
@@ -1811,12 +1816,19 @@ static void cfg_resume_fn(struct work_struct *work)
{
struct delayed_work *dwork = container_of(work, struct delayed_work, work);
struct claw_drvdata *drvdata = container_of(dwork, struct claw_drvdata, cfg_resume);
+ bool gp_registered, rgb_registered, resync;
+
+ /* Pairs with smp_store_release from claw_resume in process context */
+ resync = smp_load_acquire(&drvdata->resync);
+
+ scoped_guard(spinlock_irqsave, &drvdata->registration_lock) {
+ /* Pairs with smp_store_release from cfg_setup_fn in system_percpu_wq context */
+ gp_registered = smp_load_acquire(&drvdata->gp_registered);
+ /* Pairs with smp_store_release from cfg_setup_fn in system_percpu_wq context */
+ rgb_registered = smp_load_acquire(&drvdata->rgb_registered);
+ }
- guard(spinlock_irqsave)(&drvdata->registration_lock);
- /* Pairs with smp_store_release from cfg_setup_fn in system_percpu_wq context */
- if (!smp_load_acquire(&drvdata->gp_registered) ||
- /* Pairs with smp_store_release from cfg_setup_fn in system_percpu_wq context */
- !smp_load_acquire(&drvdata->rgb_registered))
+ if (resync || !gp_registered || !rgb_registered)
schedule_delayed_work(&drvdata->cfg_setup, msecs_to_jiffies(500));
}
@@ -2003,19 +2015,24 @@ static void msi_remove(struct hid_device *hdev)
hid_hw_stop(hdev);
}
-static int claw_resume(struct hid_device *hdev)
+static int claw_resume(struct hid_device *hdev, bool resync)
{
struct claw_drvdata *drvdata = hid_get_drvdata(hdev);
if (!drvdata)
return -ENODEV;
+ if (resync) {
+ /* Pairs with smp_load_acquire from cfg_resume_fn in system_percpu_wq context */
+ smp_store_release(&drvdata->resync, true);
+ }
+
/* MCU can take up to 500ms to be ready after resume */
schedule_delayed_work(&drvdata->cfg_resume, msecs_to_jiffies(500));
return 0;
}
-static int msi_resume(struct hid_device *hdev)
+static int msi_resume_common(struct hid_device *hdev, bool resync)
{
int ret;
u8 ep;
@@ -2027,11 +2044,21 @@ static int msi_resume(struct hid_device *hdev)
ep = ret;
if (ep == CLAW_XINPUT_CFG_INTF_IN || ep == CLAW_DINPUT_CFG_INTF_IN)
- return claw_resume(hdev);
+ return claw_resume(hdev, resync);
return 0;
}
+static int msi_resume(struct hid_device *hdev)
+{
+ return msi_resume_common(hdev, false);
+}
+
+static int msi_reset_resume(struct hid_device *hdev)
+{
+ return msi_resume_common(hdev, true);
+}
+
static int claw_suspend(struct hid_device *hdev)
{
struct claw_drvdata *drvdata = hid_get_drvdata(hdev);
@@ -2079,6 +2106,7 @@ static struct hid_driver msi_driver = {
.probe = msi_probe,
.remove = msi_remove,
.resume = pm_ptr(msi_resume),
+ .reset_resume = pm_ptr(msi_reset_resume),
.suspend = pm_ptr(msi_suspend),
};
module_hid_driver(msi_driver);
--
2.56.0
next prev parent reply other threads:[~2026-12-04 0:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 0:18 [PATCH 0/8] MSI Claw suspend, resume and ROM commit fixes Derek J. Clark
2026-12-04 0:18 ` [PATCH 1/8] HID: hid-msi: Queue the RGB work item on system_dfl_wq Derek J. Clark
2026-12-04 0:18 ` [PATCH 2/8] HID: hid-msi: Move the ROM commit to an explicit apply attribute Derek J. Clark
2026-12-04 0:35 ` sashiko-bot
2026-12-04 0:18 ` [PATCH 3/8] HID: hid-msi: Protect the RGB state with frame_lock Derek J. Clark
2026-12-04 0:18 ` Derek J. Clark [this message]
2026-12-04 0:37 ` [PATCH 4/8] HID: hid-msi: Re-init on reset during resume sashiko-bot
2026-12-04 0:18 ` [PATCH 5/8] HID: hid-msi: Drain in-flight MCU traffic before suspend Derek J. Clark
2026-12-04 0:38 ` sashiko-bot
2026-12-04 0:18 ` [PATCH 6/8] HID: hid-msi: Defer RGB updates while the MCU is suspended Derek J. Clark
2026-12-04 0:32 ` sashiko-bot
2026-12-04 0:18 ` [PATCH 7/8] HID: hid-msi: Switch the RGB LED to brightness_set_blocking Derek J. Clark
2026-12-04 0:39 ` sashiko-bot
2026-12-04 0:18 ` [PATCH 8/8] USB: core: quirks: Add RESET_RESUME quirk for MSI Claw Derek J. Clark
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=20261204001846.3801336-5-derekjohn.clark@gmail.com \
--to=derekjohn.clark@gmail.com \
--cc=bentiss@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jikos@kernel.org \
--cc=kernel@lists.opengamingcollective.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pgriffais@valvesoftware.com \
--cc=stable@vger.kernel.org \
/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