SM8550: defer rsinput haptics playback out of atomic context - #3116
Conversation
8794088 to
4996fdb
Compare
|
Marking as draft while I validate this on device: I will run similar tests on ROCKNIX with Steam and rumble-heavy games, first without the patch to confirm the atomic-context issue occurs there too, then with it to confirm it no longer does. |
|
Glad you found this fix on my branch. |
Planned to reproduce it and test it againts fresh next branch + this PR to see correction. I am currently working on continuation of the suspend, that why I spot this commit as detached from it ;-). |
|
Tested this on my AYN Odin 2. First try was the honest way: installed No Man's Sky on stock 20260801 and So I wrote two small python scripts to do it properly:
(InputPlumber hides the physical gamepad node, so it has to be stopped to On stock 20260801 that changes everything: first First one is the upload taking the driver mutex under the bridge's own With the patch (current Happy to share the scripts if anyone wants to reproduce. |
qcom_spmi_haptics_global_playback() is reached from the rsinput force-feedback callback, which runs below input_event() with the input device event lock held and interrupts disabled. It calls haptics_erase() directly, which takes a mutex and synchronously cancels delayed work, so it can sleep: "BUG: scheduling while atomic" during game rumble. Record the latest request atomically and apply it from a workqueue, serialise upload, playback and gain with a mutex in process context, and drain both the playback work and the delayed stop work before the haptics device suspends. Ported from gh123man/armada-packages#1, where it was found, root-caused and validated on hardware while testing the SM8550 deep-suspend series. Not a suspend fix in itself: the crash is reachable on any device carrying 1003-rsinput-add-ff.patch whenever a game rumbles, no suspend involved.
4996fdb to
6c25748
Compare
Summary
qcom_spmi_haptics_global_playback()is called from the rsinput FF callback, which runs belowinput_event()with the input device event lock held and interrupts disabled. It invokeshaptics_erase()directly, which takes a mutex and synchronously cancels delayed work, so it can sleep: "BUG: scheduling while atomic" during game rumble. Every ingredient (1000/1002 qcom-haptics, 1003-rsinput-add-ff) is already onnext, so any SM8550 device can hit this today in a rumble-heavy game.The fix records the latest playback request atomically and applies it from a workqueue, serialises upload, playback and gain with a mutex in process context, and drains pending playback work before the haptics device suspends.
Credit: this was found, root-caused, fixed and hardware-validated by @gh123man in gh123man/armada-packages#1 while stress-testing the SM8550 deep-suspend series with active haptics. The commit carries his authorship; this PR only ports the patch into ROCKNIX's SM8550 patch set.
Testing
Additional Context
AI Usage
Did you use AI tools to help write this code? PARTIALLY
The fix was authored and hardware-validated by @gh123man in the Armada PR referenced above. AI tools were used to port the patch into ROCKNIX's SM8550 patch layout, verify it applies against 7.1.2, and draft this PR description.