From: Aaron Ma <mapengyu@gmail.com>
To: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Nikolas Koesling <nikolas@koesling.info>,
linux-input@vger.kernel.org
Subject: [PATCH v2 2/3] HID: pulsar: resume device for raw command execution
Date: Tue, 24 Nov 2026 22:13:14 +0800 [thread overview]
Message-ID: <20261124141315.6745-2-mapengyu@gmail.com> (raw)
In-Reply-To: <20261124141315.6745-1-mapengyu@gmail.com>
usbhid drops its runtime PM reference after open, allowing the USB
device to autosuspend while idle. When suspended, hid_hw_raw_request()
fails with -EHOSTUNREACH (-113), causing battery status reads to fail.
Hold PM_HINT_FULLON across exec_cmd() so the device resumes and stays
active during command execution. Log a failure to acquire the power
reference before returning the error.
Fixes: e55cf379e822 ("HID: pulsar: add driver for Pulsar gaming mice")
Tested-by: Nikolas Koesling <nikolas@koesling.info>
Reviewed-by: Nikolas Koesling <nikolas@koesling.info>
Signed-off-by: Aaron Ma <mapengyu@gmail.com>
---
Changes in v2:
- Log an error with hid_err() when hid_hw_power(PM_HINT_FULLON) fails.
Suggested by Nikolas.
v1: https://lore.kernel.org/all/20261123141542.8128-2-mapengyu@gmail.com/
drivers/hid/hid-pulsar.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-pulsar.c b/drivers/hid/hid-pulsar.c
index 86b1050230e9..b3f15ddeb39f 100644
--- a/drivers/hid/hid-pulsar.c
+++ b/drivers/hid/hid-pulsar.c
@@ -148,7 +148,14 @@ static int exec_cmd(struct pulsar_data *drvdata, const u8 *payload,
if (atomic_read(&drvdata->stopping)) {
ret = -ENODEV;
- goto out;
+ goto out_unlock;
+ }
+
+ ret = hid_hw_power(hdev, PM_HINT_FULLON);
+ if (ret < 0) {
+ hid_err(hdev, "failed to power device for command 0x%02x: %d\n",
+ payload[1], ret);
+ goto out_unlock;
}
spin_lock_irqsave(&drvdata->raw_event_lock, flags);
@@ -164,7 +171,7 @@ static int exec_cmd(struct pulsar_data *drvdata, const u8 *payload,
spin_unlock_irqrestore(&drvdata->raw_event_lock, flags);
hid_err(hdev, "failed to send command 0x%02x: %d\n",
payload[1], ret);
- goto out;
+ goto out_power;
}
timeout = wait_for_completion_timeout(&drvdata->response_ready,
@@ -175,7 +182,7 @@ static int exec_cmd(struct pulsar_data *drvdata, const u8 *payload,
drvdata->pending_event = CMD_NONE;
spin_unlock_irqrestore(&drvdata->raw_event_lock, flags);
ret = -ETIMEDOUT;
- goto out;
+ goto out_power;
}
spin_lock_irqsave(&drvdata->raw_event_lock, flags);
@@ -190,11 +197,13 @@ static int exec_cmd(struct pulsar_data *drvdata, const u8 *payload,
"invalid checksum in response: 0x%02x (expected 0x%02x)\n",
response[USB_PAYLOAD_LEN - 1], checksum);
ret = -EIO;
- goto out;
+ goto out_power;
}
ret = 0;
-out:
+out_power:
+ hid_hw_power(hdev, PM_HINT_NORMAL);
+out_unlock:
mutex_unlock(&drvdata->lock_cmd);
return ret;
}
--
2.55.0
next prev parent reply other threads:[~2026-11-24 14:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 14:13 [PATCH v2 1/3] HID: pulsar: keep battery online across RF standby Aaron Ma
2026-11-24 14:13 ` Aaron Ma [this message]
2026-11-24 19:04 ` [PATCH v2 2/3] HID: pulsar: resume device for raw command execution Nikolas Koesling
2026-11-24 14:13 ` [PATCH v2 3/3] HID: pulsar: add support for Akko Gaming Mouse Aaron Ma
2026-11-24 19:11 ` Nikolas Koesling
2026-11-25 1:03 ` Pengyu Ma
2026-11-24 19:02 ` [PATCH v2 1/3] HID: pulsar: keep battery online across RF standby Nikolas Koesling
2026-12-01 12:41 ` Jiri Kosina
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=20261124141315.6745-2-mapengyu@gmail.com \
--to=mapengyu@gmail.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=nikolas@koesling.info \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.