Repository navigation
HID: dockchannel-hid: bind afe_reset on PM2 fallback and clear starting on timeout - #3932
Conversation
…lear starting on timeout When an interface does not pin apple,power-method in DT, dchid_get_interface() initializes it with power method 1 and leaves iface->reset NULL. On Macs whose MTP 27.2+ firmware rejects power method 1 with 0xe00002c2 (for example J516s), dchid_start_interface() switches iface->power_method to DCHID_POWER_METHOD_2 at runtime, asserts dchid->afe_reset when adopting a retained MTP session, resends the firmware, and calls dchid_pm2_set_power(iface, DCHID_POWER_STATE_ON). Commit 4e9a796 ("HID: dockchannel-hid: bring up the kiwi (touch screen) interface") refactored dchid_pm2_set_power() to drive iface->reset through dchid_set_own_lines() instead of dchid->afe_reset directly, but the runtime fallback path never assigned iface->reset = dchid->afe_reset. Because gpiod_direction_output(NULL, 0) silently returns 0, AFE reset was never released (and the 50 ms settle was skipped), leaving the multi-touch AFE held in reset until start timed out after 10 s. In addition, when wait_for_completion_timeout(&iface->ready, ...) timed out in dchid_open(), iface->starting remained true permanently, causing every subsequent open of the HID input device to fail with -EINPROGRESS ("Interface multi-touch is already starting"). Bind iface->reset = iface->dchid->afe_reset when falling back to power method 2, reject a NULL iface->reset in dchid_set_own_lines() with -EINVAL instead of silently no-oping, and clear iface->starting when waiting for ready finishes or times out. Add KUnit tests for both cases. Fixes: 4e9a796 ("HID: dockchannel-hid: bring up the kiwi (touch screen) interface") Signed-off-by: Diljit Singh <hey@djdev.me>
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed at 185dc0f. The PM2 fallback binding (dchid_enter_pm2_fallback) and clearing starting on the open() timeout both look right, and the KUnit cases cover them.
One cross-board concern before I approve: the new if (!iface->reset) return -EINVAL; in dchid_set_own_lines(). Before this PR, a NULL iface->reset went to gpiod_direction_output(NULL, ...), which is a no-op returning 0 for an optional GPIO. Now it's a hard -EINVAL. dchid_pm2_set_state() calls set_own_lines for every PM2 interface that isn't firmware_managed_reset (around line 758). So any board with a PM2 interface and no reset line in its DT (keyboard, or kiwi on another SoC) would now fail every PM2 power transition, including on suspend and resume, where it used to succeed.
Could you either:
(a) keep NULL as an explicit no-op in set_own_lines and fail only where a line is actually required (the own_lines power-cycle path in dchid_start_interface already checks that iface->reset is distinct from the AFE reset), or
(b) show that every PM2, non-firmware-managed interface on every board has a reset line, e.g. a DT scan of all apple,dockchannel-hid nodes or a probe-time WARN, plus a boot and s2idle row on one non-T6030 dockchannel Mac (J713/J616s/J700)?
With either of those I'll approve straight away.
satchlj
left a comment
There was a problem hiding this comment.
Audit at 185dc0f3 — code fixes and KUnit tests look clean; awaiting CI + resolution of reset-line check / peer row
Reviewed drivers/hid/dockchannel-hid/dockchannel-hid.c and dockchannel-hid-parser-test.c:
dchid_enter_pm2_fallback()cleanly bindsiface->reset = iface->dchid->afe_resetwhen falling back from PM1 (0xe00002c2) to PM2, anddchid_wait_ready()clearsiface->starting = falseon both timeout and completion so a timed-outopen()no longer wedges subsequent opens with-EINPROGRESS. Both new KUnit cases cover these paths cleanly.- Regarding the
!iface->resetcheck indchid_set_own_lines(): at probe (dockchannel-hid.c:332-349), any interface configured withDCHID_POWER_METHOD_2 && !firmware_managed_resetalready fails probe if!reset, so configured PM2 interfaces cannot reachdchid_set_own_lines()withiface->reset == NULL. The only path that can hit!iface->resetthere is a PM1-to-PM2 fallback on a board withdchid->afe_reset == NULL— in which casedchid_start_interface()line 1036 (gpiod_direction_output(iface->reset, 1)) would still no-op before failing indchid_set_own_lines(). If PM1-to-PM2 fallback requiresafe_reset, checkingdchid->afe_resetat fallback (or keeping the guard aligned with Ryan's comment) makes that invariant explicit. - Holding
APPROVEuntil CI (host-tests,pr-text,readiness) finishes green and the cross-board dockchannel peer row /dchid_set_own_lines()question is resolved.
Returning -EINVAL from dchid_set_own_lines() when iface->reset is NULL turns the old optional-GPIO no-op into a hard failure, including on suspend and resume, for any power-method-2 interface without a DT reset line on other boards. Drop the check and its KUnit assertion. The power-method-2 fallback still binds iface->reset to afe_reset, so the J516s multi-touch fix is unchanged. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Review follow-up at Tested: on main Not yet: J516s boot + 3× s2idle + evdev row at |
RyanTheTide
left a comment
There was a problem hiding this comment.
Re-reviewed at ea8ac57. The NULL reset is a no-op again, so dchid_set_own_lines() matches the base and other boards' PM2 interfaces without a DT reset line are unaffected. The PM2 fallback still binds afe_reset, and open() clears starting on timeout. Both are covered by KUnit. Approve.
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
satchlj
left a comment
There was a problem hiding this comment.
Re-audit at ea8ac57f6efd — reset-line follow-up is clean; awaiting queued CI and exact-head J516s row
Checked:
ea8ac57f6efddrops the-EINVALreturn oniface->reset == NULLindchid_set_own_lines()and its KUnit assertion, keeping PM2 interfaces without a DT reset line as a no-op while preservingdchid_enter_pm2_fallback()(bindingiface->reset = iface->dchid->afe_reseton PM1→PM2 fallback),dchid_wait_ready()(clearingiface->starting = falseon both timeout and completion), and both remaining KUnit tests.
Remaining before merge:
- Queued CI checks (
host-tests,pr-text) atea8ac57f6efd. - Queued J516s boot + 3× s2idle + evdev row at
ea8ac57f6efdnoted in#issuecomment-7346149709.
|
J516s (M3 Pro, T6030) hardware verification at exact PR head
|
|
Local CI passed on pc. Tested main
|
What: Fix two bugs in
drivers/hid/dockchannel-hid/dockchannel-hid.cthat break multi-touch startup on Apple MTP 27.2+ laptops (e.g., J516s / M3 Pro) when the device tree does not forceapple,power-method = <2>:iface->resetasNULL(regression from4e9a79628fc5):dchid_get_interface()only bindsiface->reset = dchid->afe_resetwhenpower_method == DCHID_POWER_METHOD_2at probe time. On boards defaulting to PM1 whose MTP firmware rejects PM1 with0xe00002c2,dchid_start_interface()switchediface->power_methodto PM2, asserteddchid->afe_reset, resent firmware, and calleddchid_pm2_set_power(ON)->dchid_set_own_lines(ON)->gpiod_direction_output(iface->reset, 0). Withiface->reset == NULL,gpiod_direction_output()silently returned0(and skipped the 50 ms settle), leaving AFE reset asserted until the 10 s ready timeout expired. Adddchid_enter_pm2_fallback()to bindiface->reset = dchid->afe_resetwhen switching to PM2, and return-EINVALfromdchid_set_own_lines()ififace->resetisNULL.iface->startingafter ready timeout:dchid_open()leftiface->starting = truewhenwait_for_completion_timeout(&iface->ready, ...)timed out, wedging every subsequent open of/dev/input/event*with-EINPROGRESS(Interface multi-touch is already starting). Adddchid_wait_ready()to cleariface->starting = falseon both timeout and completion.Also add two KUnit tests in
drivers/hid/dockchannel-hid/dockchannel-hid-parser-test.c(dchid_pm2_fallback_binds_afe_reset_testanddchid_wait_ready_timeout_clears_starting_test).Tested:
scripts/checkpatch.pl: 0 errors, 0 warnings.drivers/hid/dockchannel-hid/dockchannel-hid.kunitconfig(dockchannel-hid.o,dockchannel-hid-protocol-test.o): clean, 0 warnings.tools/asahi/j613-mtp-s2idle-tests.py: PASS.185dc0f3991ab61406293b634e205fb7dd82d99f(7.3.0-m3-dchid+, stock cmdline, stockm1n1/boot.bin,boot_id=651dd435-84d2-4094-add9-1c2eafa210fc):dmesg:[ 4.195534] dockchannel-hid 37ab28000.input: output report 0x40 to iface 0 (comm) failed with err 0xe00002c2[ 4.195539] dockchannel-hid 37ab28000.input: multi-touch: power method 1 rejected (0xe00002c2); retrying with power method 2[ 4.499241] dockchannel-hid 37ab28000.input: Interface multi-touch is now readyevent0Force Click,event1keyboard,event2Apple MTP multi-touchABS_MT_X=[-7456..7976] ABS_MT_Y=[-9283..163],event3SMC,event4jack) open and pass ioctl (EVDEV_ALL_OK).s2idlecycles (rtcwake -d rtc0 -m freeze -s 5):suspend_statssuccess 0->3,fail 0->0.EVDEV_ALL_OK; 0start timed out, 0already starting, 0 kernel WARN/BUG/Oops/GPU faults.Risk: Two-way door, scoped to
dockchannel-hidPM1->PM2 fallback and ready-wait error handling. Boards already using PM2 from DT or succeeding on PM1 keep identical behavior.Not yet: Independent review and hosted CI on this branch; peer-board verification on another PM1-fallback MTP laptop (e.g., J414s or J613) if desired.