public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Siarhei Vishniakou <svv@google.com>,
	Benjamin Tissoires <bentiss@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	roderick.colenbrander@sony.com, jikos@kernel.org,
	linux-input@vger.kernel.org
Subject: [PATCH AUTOSEL 6.18-5.15] HID: playstation: Center initial joystick axes to prevent spurious events
Date: Mon, 12 Jan 2026 09:58:18 -0500	[thread overview]
Message-ID: <20260112145840.724774-17-sashal@kernel.org> (raw)
In-Reply-To: <20260112145840.724774-1-sashal@kernel.org>

From: Siarhei Vishniakou <svv@google.com>

[ Upstream commit e9143268d259d98e111a649affa061acb8e13c5b ]

When a new PlayStation gamepad (DualShock 4 or DualSense) is initialized,
the input subsystem sets the default value for its absolute axes (e.g.,
ABS_X, ABS_Y) to 0.

However, the hardware's actual neutral/resting state for these joysticks
is 128 (0x80). This creates a mismatch.

When the first HID report arrives from the device, the driver sees the
resting value of 128. The kernel compares this to its initial state of 0
and incorrectly interprets this as a delta (0 -> 128). Consequently, it
generates EV_ABS events for this initial, non-existent movement.

This behavior can fail userspace 'sanity check' tests (e.g., in
Android CTS) that correctly assert no motion events should be generated
from a device that is already at rest.

This patch fixes the issue by explicitly setting the initial value of the
main joystick axes (e.g., ABS_X, ABS_Y, ABS_RX, ABS_RY) to 128 (0x80)
in the common ps_gamepad_create() function.

This aligns the kernel's initial state with the hardware's expected
neutral state, ensuring that the first report (at 128) produces no
delta and thus, no spurious event.

Signed-off-by: Siarhei Vishniakou <svv@google.com>
Reviewed-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

## Analysis of Commit: "HID: playstation: Center initial joystick axes
to prevent spurious events"

### 1. COMMIT MESSAGE ANALYSIS

The commit describes a clear, specific bug:
- PlayStation gamepads (DualShock 4, DualSense) have joysticks that rest
  at value 128 (0x80)
- The kernel initializes the axis value to 0 by default
- When the first HID report arrives with the resting value of 128, the
  kernel interprets this as actual movement
- This generates spurious EV_ABS events for non-existent movement
- The problem causes Android CTS test failures and potentially confuses
  userspace applications

The bug has user-visible impact ("Reported-by" pattern implied through
CTS test context).

### 2. CODE CHANGE ANALYSIS

**The fix is minimal and surgical:**
```c
gamepad->absinfo[ABS_X].value = 128;
gamepad->absinfo[ABS_Y].value = 128;
gamepad->absinfo[ABS_RX].value = 128;
gamepad->absinfo[ABS_RY].value = 128;
```

- 5 lines added (1 comment + 4 value assignments)
- Single file: `drivers/hid/hid-playstation.c`
- Single function: `ps_gamepad_create()`
- Only affects joystick axes (ABS_X, ABS_Y, ABS_RX, ABS_RY), correctly
  leaves triggers (ABS_Z, ABS_RZ) at 0

**Technical correctness:** The fix is obviously correct. After
`input_set_abs_params()` sets up the axis with range 0-255, manually
setting `.value = 128` aligns the kernel's initial state with the
hardware's physical resting position at center (128).

### 3. CLASSIFICATION

- **Type:** Bug fix (not a feature)
- **Category:** Input device initialization fix
- **No new API or behavior change:** Just corrects initial state values
- **No new features:** Purely corrects existing incorrect behavior

### 4. SCOPE AND RISK ASSESSMENT

| Factor | Assessment |
|--------|------------|
| Lines changed | 5 (very small) |
| Files changed | 1 |
| Complexity | Trivial |
| Subsystem | HID - PlayStation driver (mature) |
| Risk of regression | Very low |

The change is confined to initialization code and cannot affect any
existing logic paths. Setting an initial value cannot break anything
because:
1. The value 128 is within the valid range (0-255)
2. The hardware reports 128 at rest anyway
3. This aligns kernel state with reality

### 5. USER IMPACT

**Who is affected:**
- All users of DualShock 4 and DualSense controllers
- Android users (CTS compliance)
- Applications that validate initial input state

**Severity:** Medium - Not a crash or data corruption, but:
- Causes spurious input events at device connect
- Breaks CTS conformance tests
- May confuse input-sensitive applications

### 6. STABILITY INDICATORS

- **Reviewed-by:** Benjamin Tissoires (HID maintainer) ✓
- **Signed-off-by:** Maintainer sign-off ✓
- The fix is simple enough to verify correctness by inspection

### 7. DEPENDENCY CHECK

- No dependencies on other commits
- `ps_gamepad_create()` has existed since the driver was introduced
- Uses standard input subsystem patterns (`absinfo[].value`)
- Should apply cleanly to any stable tree containing this driver

### STABLE KERNEL CRITERIA EVALUATION

| Criterion | Status |
|-----------|--------|
| Obviously correct and tested | ✓ Reviewed by maintainer |
| Fixes a real bug | ✓ Spurious input events |
| Important issue | ✓ Breaks CTS, affects popular hardware |
| Small and contained | ✓ 5 lines, 1 file |
| No new features | ✓ Pure correctness fix |
| No new APIs | ✓ |

### RISK VS BENEFIT

**Benefits:**
- Fixes spurious input events on popular consumer hardware
- Fixes Android CTS test failures
- Aligns kernel state with hardware reality
- Affects millions of PlayStation controller users

**Risks:**
- Essentially zero - the change is trivially correct
- No logic changes, just initialization values

### CONCLUSION

This commit is an excellent candidate for stable backporting:

1. **Fixes a real bug** that causes spurious input events and test
   failures
2. **Small and surgical** - only 5 lines in one function
3. **Obviously correct** - aligns initial value with hardware's physical
   state
4. **Low risk** - cannot introduce regressions
5. **Well-reviewed** - HID maintainer reviewed and signed off
6. **Widely applicable** - affects popular consumer hardware
   (PlayStation controllers)
7. **No dependencies** - self-contained fix

The fix meets all stable kernel criteria: it's obviously correct, fixes
a real bug, is small in scope, and introduces no new features. The fact
that it fixes CTS compliance issues makes it particularly valuable for
Android device manufacturers using stable kernels.

**YES**

 drivers/hid/hid-playstation.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
index 128aa6abd10be..e4dfcf26b04e7 100644
--- a/drivers/hid/hid-playstation.c
+++ b/drivers/hid/hid-playstation.c
@@ -753,11 +753,16 @@ ps_gamepad_create(struct hid_device *hdev,
 	if (IS_ERR(gamepad))
 		return ERR_CAST(gamepad);
 
+	/* Set initial resting state for joysticks to 128 (center) */
 	input_set_abs_params(gamepad, ABS_X, 0, 255, 0, 0);
+	gamepad->absinfo[ABS_X].value = 128;
 	input_set_abs_params(gamepad, ABS_Y, 0, 255, 0, 0);
+	gamepad->absinfo[ABS_Y].value = 128;
 	input_set_abs_params(gamepad, ABS_Z, 0, 255, 0, 0);
 	input_set_abs_params(gamepad, ABS_RX, 0, 255, 0, 0);
+	gamepad->absinfo[ABS_RX].value = 128;
 	input_set_abs_params(gamepad, ABS_RY, 0, 255, 0, 0);
+	gamepad->absinfo[ABS_RY].value = 128;
 	input_set_abs_params(gamepad, ABS_RZ, 0, 255, 0, 0);
 
 	input_set_abs_params(gamepad, ABS_HAT0X, -1, 1, 0, 0);
-- 
2.51.0


  parent reply	other threads:[~2026-01-12 14:59 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 14:58 [PATCH AUTOSEL 6.18] HID: Elecom: Add support for ELECOM M-XT3DRBK (018C) Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18] x86/sev: Disable GCOV on noinstr object Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.10] wifi: mac80211: collect station statistics earlier when disconnect Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18] btrfs: do not free data reservation in fallback from inline due to -ENOSPC Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.10] btrfs: fix deadlock in wait_current_trans() due to ignored transaction type Sasha Levin
2026-01-19 11:46   ` Motiejus Jakštys
2026-01-20 11:03     ` Greg KH
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.10] HID: quirks: Add another Chicony HP 5MP Cameras to hid_ignore_list Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-6.1] HID: intel-ish-hid: Update ishtp bus match to support device ID table Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.10] HID: multitouch: add MT_QUIRK_STICKY_FINGERS to MT_CLS_VTL Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-6.1] HID: i2c-hid: fix potential buffer overflow in i2c_hid_get_report() Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18] riscv: trace: fix snapshot deadlock with sbi ecall Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-6.12] drm/amd/pm: Disable MMIO access during SMU Mode 1 reset Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-6.12] riscv: Sanitize syscall table indexing under speculation Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.15] netfilter: replace -EEXIST with -EBUSY Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-6.12] PCI: qcom: Remove ASPM L0s support for MSM8996 SoC Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.10] ALSA: hda/realtek: add HP Laptop 15s-eq1xxx mute LED quirk Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.10] ring-buffer: Avoid softlockup in ring_buffer_resize() during memory free Sasha Levin
2026-01-12 14:58 ` Sasha Levin [this message]
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.10] HID: intel-ish-hid: Reset enum_devices_done before enumeration Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18] drm/amd/display: Reduce number of arguments of dcn30's CalculatePrefetchSchedule() Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.10] HID: Apply quirk HID_QUIRK_ALWAYS_POLL to Edifier QR30 (2d99:a101) Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-6.1] btrfs: fix reservation leak in some error paths when inserting inline extent Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-6.12] ALSA: hda/realtek: Add quirk for Acer Nitro AN517-55 Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-6.12] HID: logitech: add HID++ support for Logitech MX Anywhere 3S Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18] HID: Intel-thc-hid: Intel-thc: Add safety check for reading DMA buffer Sasha Levin
2026-01-12 14:58 ` [PATCH AUTOSEL 6.18-5.10] HID: usbhid: paper over wrong bNumDescriptor field Sasha Levin

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=20260112145840.724774-17-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=roderick.colenbrander@sony.com \
    --cc=stable@vger.kernel.org \
    --cc=svv@google.com \
    /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