All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aditya Dash <mradityadash@gmail.com>
To: Benjamin Tissoires <bentiss@kernel.org>,
	"Derek J. Clark" <derekjohn.clark@gmail.com>,
	Jiri Kosina <jikos@kernel.org>,
	Mark Pearson <mpearson-lenovo@squebb.ca>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 0/7] HID: hid-lenovo-go: fix controller configuration
Date: Tue,  1 Sep 2026 12:06:01 +0530	[thread overview]
Message-ID: <cover.1788222001.git.mradityadash@gmail.com> (raw)

This series fixes several issues in the controller configuration and
calibration paths in hid-lenovo-go.

1/7 fixes the calibration attributes, where the command and sub-command
are swapped. 2/7 fixes two right-controller attributes: imu_enabled
selects the bypass feature, and reset targets the left controller.

The configuration interface initializes its command completion after the
HID hardware starts and opens. 3/7 moves that initialization before both
hardware operations.

Before 4/7, any decoded configuration reply completes the shared
completion. The driver then ignores the result of the wait, so an
unrelated reply, a firmware error, an interrupted wait, or a timeout can
still be reported as success.

4/7 tracks one pending request in the driver data and matches replies by
command ID, command, sub-command, and device. It initializes the new
completion and spinlock at the pre-hardware point established by 3/7. It
also returns request errors to the caller.

The firmware has no sequence number, so a late reply with the same tuple
can still match a newer request.

The remaining patches fix calibration status handling.

The calibration status table defines 0x00 as unknown, 0x01 as success,
and 0x02 as failure. A Legion Go 1 returned 0x08 after a Stop was sent
while no calibration was active. The driver stores the raw value as a
status-text index, so a later read returns -EINVAL.

5/7 preserves the defined values and maps larger status values to
failure.

6/7 rejects 'unknown' as an action. The action table contains it at index
zero, but the options attribute advertises only 'start' and 'stop'.

A previous result can also hide a new calibration attempt:

failure -> start -> failure

The status appears unchanged for the whole operation. 7/7 clears the
selected status to unknown before submitting a Start. Stop leaves the
status unchanged.

I built every patch against kernel 7.2.1-ogc3.1.fc44.x86_64 with
W=1 and KCFLAGS=-Werror. I tested the exact final module on an Original
Legion Go. The configuration interface bound without a kernel fault.
An idle Stop result of 0x08 was reported as failure. Writing 'unknown'
returned -EINVAL without an output report or status change. A later Start
produced failure -> unknown -> failure; the final report contained result
0x02 and error 0x0007. The five unselected statuses stayed unchanged.

---
Changes in v3:
- Initialize command completion state before hid_hw_start() and
  hid_hw_open().
- Remove the unreachable zero-length calibration action path after
  rejecting 'unknown'.

v2 review:
https://lore.kernel.org/all/CAFqHKTnQiTQc6joz-Y6tmjR=C5giF-MuHeBwu3rw+bmFVMQtqw@mail.gmail.com/

v2:
https://lore.kernel.org/all/cover.1788096666.git.mradityadash@gmail.com/

Changes in v2:
- Drop the FPS DPI patch; the existing request is correct.
- Drop the v1 Boolean calibration-result mapping. Preserve values 0x00
  through 0x02 and map only larger failure values.
- Move the existing pending command state into the driver data and
  initialize it in cfg_probe().
- Use scoped IRQ-save guards and validate the report size and ID together.
- Drop the v1 no-wait calibration path. Correct requests receive their
  matching SET replies within the existing 50 ms timeout.
- Reject 'unknown' and clear only the selected status on Start.

v1:
https://lore.kernel.org/all/20260821214810.87826-1-mradityadash@gmail.com/


Aditya Dash (7):
  HID: hid-lenovo-go: use the correct calibration commands
  HID: hid-lenovo-go: use the right controller selectors
  HID: hid-lenovo-go: initialize command completion before hardware
  HID: hid-lenovo-go: return configuration request errors
  HID: hid-lenovo-go: normalize calibration failure status
  HID: hid-lenovo-go: reject unknown calibration action
  HID: hid-lenovo-go: clear calibration status on start

 drivers/hid/hid-lenovo-go.c | 191 +++++++++++++++++++++++++++---------
 1 file changed, 142 insertions(+), 49 deletions(-)


base-commit: 1292bca0f8d835d2ad96d309595b2e97f3106d3d
-- 
2.55.0


             reply	other threads:[~2026-09-01  6:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  6:36 Aditya Dash [this message]
2026-09-01  6:36 ` [PATCH v3 1/7] HID: hid-lenovo-go: use the correct calibration commands Aditya Dash
2026-09-01  6:50   ` sashiko-bot
2026-09-01  6:36 ` [PATCH v3 2/7] HID: hid-lenovo-go: use the right controller selectors Aditya Dash
2026-09-01  6:46   ` sashiko-bot
2026-09-01  6:36 ` [PATCH v3 3/7] HID: hid-lenovo-go: initialize command completion before hardware Aditya Dash
2026-09-01  6:48   ` sashiko-bot
2026-09-01  6:36 ` [PATCH v3 4/7] HID: hid-lenovo-go: return configuration request errors Aditya Dash
2026-09-01  6:50   ` sashiko-bot
2026-09-01  6:36 ` [PATCH v3 5/7] HID: hid-lenovo-go: normalize calibration failure status Aditya Dash
2026-09-01  6:50   ` sashiko-bot
2026-09-01 15:57   ` Derek John Clark
2026-09-01 17:06     ` Aditya
2026-09-02 12:40       ` Derek J. Clark
2026-09-05  6:10         ` Aditya Dash
2026-09-01  6:36 ` [PATCH v3 6/7] HID: hid-lenovo-go: reject unknown calibration action Aditya Dash
2026-09-01  6:48   ` sashiko-bot
2026-09-01  6:36 ` [PATCH v3 7/7] HID: hid-lenovo-go: clear calibration status on start Aditya Dash
2026-09-01  7:00   ` sashiko-bot

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=cover.1788222001.git.mradityadash@gmail.com \
    --to=mradityadash@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=derekjohn.clark@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpearson-lenovo@squebb.ca \
    /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.