From: Kenhou Iijima <kenhou@kenhou.net>
To: "Derek J . Clark" <derekjohn.clark@gmail.com>
Cc: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Denis Benato <denis.benato@linux.dev>,
Zhouwang Huang <honjow311@gmail.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Kenhou Iijima <kenhou@kenhou.net>
Subject: [PATCH] HID: hid-msi: Drain orphan MCU ACKs by issuing a query
Date: Sat, 14 Nov 2026 19:10:45 +0900 [thread overview]
Message-ID: <20261114101045.21986-1-kenhou@kenhou.net> (raw)
The Claw MCU re-sends an unhandled ACK roughly every 2 seconds until it
receives another command. When an ACK arrives with waiting_cmd set to
CLAW_COMMAND_TYPE_NONE, such as after a command is written through
hidraw or once orphan_ack_pending has been cleared without a subsequent
command, the driver currently logs "Got unexpected ACK from MCU,
ignoring" on every re-transmission and never clears the MCU's pending
ACK state.
Schedule a work item that issues a harmless READ_GAMEPAD_MODE query when
an unexpected ACK arrives. Receiving any command causes the MCU to stop
re-sending the pending ACK, eliminating the repeated events and log
spam.
Fixes: a9517958e828 ("HID: hid-msi: Add MSI Claw configuration driver")
Signed-off-by: Kenhou Iijima <kenhou@kenhou.net>
---
Tested on an MSI Claw 8 AI+ A2VM (0db0:1901, bcdDevice 2.30).
drivers/hid/hid-msi.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-msi.c b/drivers/hid/hid-msi.c
index 23d731f700..e52923fcc8 100644
--- a/drivers/hid/hid-msi.c
+++ b/drivers/hid/hid-msi.c
@@ -332,6 +332,7 @@ struct claw_drvdata {
enum claw_profile_ack_pending profile_pending;
struct completion orphan_ack_complete;
struct completion send_cmd_complete;
+ struct work_struct orphan_ack_work;
struct delayed_work cfg_resume;
struct delayed_work cfg_setup;
spinlock_t registration_lock; /* Lock for registration read/write */
@@ -532,7 +533,12 @@ static int claw_raw_event(struct claw_drvdata *drvdata, struct hid_report *repor
}
if (drvdata->waiting_cmd == CLAW_COMMAND_TYPE_NONE) {
- dev_warn(&drvdata->hdev->dev, "Got unexpected ACK from MCU, ignoring\n");
+ /*
+ * The MCU re-sends an unhandled ACK roughly every 2 s
+ * until it receives another command. Drain it by
+ * scheduling a harmless query so the ACK storm stops.
+ */
+ schedule_work(&drvdata->orphan_ack_work);
break;
}
@@ -653,6 +659,20 @@ static int claw_hw_output_report(struct hid_device *hdev, u8 index, u8 *data,
return __claw_hw_output_report(hdev, index, data, len, timeout);
}
+static void claw_orphan_ack_drain(struct work_struct *work)
+{
+ struct claw_drvdata *drvdata = container_of(work, struct claw_drvdata,
+ orphan_ack_work);
+
+ /*
+ * A query is enough to make the MCU stop re-sending the pending ACK.
+ * claw_hw_output_report() also waits for any orphan ACK before
+ * sending, so this cannot interleave with a real command sequence.
+ */
+ claw_hw_output_report(drvdata->hdev, CLAW_COMMAND_TYPE_READ_GAMEPAD_MODE,
+ NULL, 0, 25);
+}
+
static int claw_switch_mode(struct hid_device *hdev, enum claw_mode_field field, u8 val)
{
struct claw_drvdata *drvdata = hid_get_drvdata(hdev);
@@ -1868,6 +1888,7 @@ static int claw_probe(struct hid_device *hdev, u8 ep)
spin_lock_init(&drvdata->rumble_lock);
init_completion(&drvdata->orphan_ack_complete);
init_completion(&drvdata->send_cmd_complete);
+ INIT_WORK(&drvdata->orphan_ack_work, &claw_orphan_ack_drain);
INIT_DELAYED_WORK(&drvdata->cfg_resume, &cfg_resume_fn);
INIT_DELAYED_WORK(&drvdata->cfg_setup, &cfg_setup_fn);
INIT_DELAYED_WORK(&drvdata->rgb_queue, &claw_rgb_queue_fn);
@@ -1934,6 +1955,7 @@ static void claw_remove(struct hid_device *hdev)
cancel_delayed_work_sync(&drvdata->cfg_resume);
cancel_delayed_work_sync(&drvdata->cfg_setup);
+ cancel_work_sync(&drvdata->orphan_ack_work);
scoped_guard(spinlock_irqsave, &drvdata->registration_lock) {
/* Pairs with smp_store_release from cfg_setup_fn in system_wq context */
@@ -2014,6 +2036,7 @@ static int claw_suspend(struct hid_device *hdev)
cancel_delayed_work_sync(&drvdata->cfg_resume);
cancel_delayed_work_sync(&drvdata->cfg_setup);
+ cancel_work_sync(&drvdata->orphan_ack_work);
cancel_delayed_work_sync(&drvdata->rgb_queue);
return 0;
--
2.56.0
reply other threads:[~2026-11-14 10:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261114101045.21986-1-kenhou@kenhou.net \
--to=kenhou@kenhou.net \
--cc=bentiss@kernel.org \
--cc=denis.benato@linux.dev \
--cc=derekjohn.clark@gmail.com \
--cc=honjow311@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®