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: Zhang Lixu <lixu.zhang@intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Benjamin Tissoires <bentiss@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	jikos@kernel.org, linux-input@vger.kernel.org
Subject: [PATCH AUTOSEL 6.18-5.10] HID: intel-ish-hid: Reset enum_devices_done before enumeration
Date: Mon, 12 Jan 2026 09:58:19 -0500	[thread overview]
Message-ID: <20260112145840.724774-18-sashal@kernel.org> (raw)
In-Reply-To: <20260112145840.724774-1-sashal@kernel.org>

From: Zhang Lixu <lixu.zhang@intel.com>

[ Upstream commit 56e230723e3a818373bd62331bccb1c6d2b3881b ]

Some systems have enabled ISH without any sensors. In this case sending
HOSTIF_DM_ENUM_DEVICES results in 0 sensors. This triggers ISH hardware
reset on subsequent enumeration after S3/S4 resume.

The enum_devices_done flag was not reset before sending the
HOSTIF_DM_ENUM_DEVICES command. On subsequent enumeration calls (such as
after S3/S4 resume), this flag retains its previous true value, causing the
wait loop to be skipped and returning prematurely to hid_ishtp_cl_init().
If 0 HID devices are found, hid_ishtp_cl_init() skips getting HID device
descriptors and sets init_done to true. When the delayed enumeration
response arrives with init_done already true, the driver treats it as a bad
packet and triggers an ISH hardware reset.

Set enum_devices_done to false before sending the enumeration command,
consistent with similar functions like ishtp_get_hid_descriptor() and
ishtp_get_report_descriptor() which reset their respective flags.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
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: intel-ish-hid: Reset enum_devices_done
before enumeration

### 1. COMMIT MESSAGE ANALYSIS

The commit message clearly describes a **bug in suspend/resume (S3/S4)
handling**:
- Systems with ISH enabled but no sensors return 0 devices from
  HOSTIF_DM_ENUM_DEVICES
- The `enum_devices_done` flag wasn't reset before sending enumeration
  commands
- On subsequent enumerations (after resume), the stale `true` value
  causes the wait loop to be skipped
- This leads to a race where delayed responses are treated as bad
  packets
- Result: **ISH hardware reset** during resume

Key indicators:
- "S3/S4 resume" - power management bug affecting real user workflows
- Clear explanation of the timing/race condition
- Acked-by Srinivas Pandruvada (Intel ISH maintainer)

### 2. CODE CHANGE ANALYSIS

The diff shows a **single line addition**:
```c
+       client_data->enum_devices_done = false;
```

Added immediately before the `HOSTIF_DM_ENUM_DEVICES` command is sent.
The logic:
- The function sends an enumeration request and waits for
  `enum_devices_done` to become true
- Without resetting it first, a stale `true` value from a previous call
  causes immediate exit from the wait loop
- This creates a race: the response arrives after `init_done` is already
  set, triggering a hardware reset

The fix follows the **established pattern** in the same driver - the
commit message notes that `ishtp_get_hid_descriptor()` and
`ishtp_get_report_descriptor()` already reset their respective flags
similarly.

### 3. CLASSIFICATION

- **Bug fix**: Yes - fixes incorrect state handling causing hardware
  reset
- **Feature addition**: No
- **API change**: No
- **Hardware quirk**: No - this is a driver logic bug, not a hardware
  workaround

### 4. SCOPE AND RISK ASSESSMENT

| Metric | Value |
|--------|-------|
| Lines changed | 1 |
| Files touched | 1 |
| Complexity | Very low |
| Risk | Minimal |

The change:
- Sets a boolean flag to false before an operation that expects it to
  transition to true
- Follows identical patterns elsewhere in the same file
- Cannot break any existing functionality that works correctly
- Isolated to Intel ISH subsystem

### 5. USER IMPACT

**Affected users:** Laptop users with Intel Sensor Hub hardware (common
in modern Intel laptops)

**Symptom:** ISH hardware reset during S3/S4 resume, which can cause:
- Delays in resume
- Sensor hub functionality issues after resume
- System instability during power transitions

**Severity:** Moderate-High - affects common laptop power management
workflows

### 6. STABILITY INDICATORS

- **Acked-by:** Srinivas Pandruvada (Intel ISH maintainer) - domain
  expert approval
- **Signed-off-by:** Benjamin Tissoires (HID maintainer)
- Pattern-following fix consistent with other similar functions in the
  driver

### 7. DEPENDENCY CHECK

This commit:
- Is self-contained with no dependencies
- Modifies code that has existed in stable trees for years
- The `enum_devices_done` flag, `client_data` structure, and
  `ishtp_enum_enum_devices()` function are all well-established

---

## Summary

**What it fixes:** Race condition during S3/S4 resume where stale
boolean flag causes ISH hardware reset

**Why it matters:** Users with Intel Sensor Hub hardware experience
hardware reset/instability on resume from suspend/hibernate - a common
laptop workflow

**Stable criteria met:**
- ✅ Obviously correct (follows existing pattern in same driver)
- ✅ Fixes real bug (hardware reset during resume)
- ✅ Small and contained (1 line, 1 file)
- ✅ No new features
- ✅ No API changes
- ✅ Has maintainer acknowledgment

**Risk assessment:** Very low - single boolean assignment following
established pattern

**Benefit:** Fixes real user-facing bug affecting laptop power
management

This is an ideal stable candidate: a minimal, surgical fix for a real
bug affecting common hardware in a common usage scenario, with
maintainer review and following established driver patterns.

**YES**

 drivers/hid/intel-ish-hid/ishtp-hid-client.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c
index d8c3c54a8c0f2..537145ec50586 100644
--- a/drivers/hid/intel-ish-hid/ishtp-hid-client.c
+++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c
@@ -495,6 +495,7 @@ static int ishtp_enum_enum_devices(struct ishtp_cl *hid_ishtp_cl)
 	int rv;
 
 	/* Send HOSTIF_DM_ENUM_DEVICES */
+	client_data->enum_devices_done = false;
 	memset(&msg, 0, sizeof(struct hostif_msg));
 	msg.hdr.command = HOSTIF_DM_ENUM_DEVICES;
 	rv = ishtp_cl_send(hid_ishtp_cl, (unsigned char *)&msg,
-- 
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 ` [PATCH AUTOSEL 6.18-5.15] HID: playstation: Center initial joystick axes to prevent spurious events Sasha Levin
2026-01-12 14:58 ` Sasha Levin [this message]
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-18-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=lixu.zhang@intel.com \
    --cc=patches@lists.linux.dev \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=stable@vger.kernel.org \
    /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