Skip to contentSkip to conversation

HID: intel-ish-ipc: Remove redundant ready check after timeout function

PATCH Applied Zhang Lixu 2 participants 2 messages Aug 21, 2025 – Sep 12, 2025

Subsystems (2)
lore
Share & tools
lore

Zhang Lixu

author
#0 lore raw

PATCH 1/1 HID: intel-ish-ipc: Remove redundant ready check after timeout function

timed_wait_for_timeout() internally checks for ish_is_input_ready() and ishtp_fw_is_ready() based on the provided parameters. If timed_wait_for_timeout() returns 0, it indicates the status is ready. In rare cases, another thread may send a message immediately after timed_wait_for_timeout() returns, causing a subsequent ish_is_input_ready() check to fail. Since the return value of timed_wait_for_timeout() is sufficient to determine readiness, the additional ready check is unnecessary and may introduce issues.

This patch removes the redundant check and relies solely on the return value of timed_wait_for_timeout().

Fixes ae02e5d40d5f ("HID: intel-ish-hid: ipc layer")
---
 drivers/hid/intel-ish-hid/ipc/ipc.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/hid/intel-ish-hid/ipc/ipc.c +9 -8
index 4c861119e97a..3ddaa2cd39d5 100644
@@ -498,6 +498,7 @@ static int ish_fw_reset_handler(struct ishtp_device *dev)
 {
 	uint32_t	reset_id;
 	unsigned long	flags;
+	int ret;
 
 	/* Read reset ID */
 	reset_id = ish_reg_read(dev, IPC_REG_ISH2HOST_MSG) & 0xFFFF;
@@ -510,12 +511,11 @@ static int ish_fw_reset_handler(struct ishtp_device *dev)
 	/* ISHTP notification in IPC_RESET */
 	ishtp_reset_handler(dev);
 
-	if (!ish_is_input_ready(dev))
-		timed_wait_for_timeout(dev, WAIT_FOR_INPUT_RDY,
-			TIME_SLICE_FOR_INPUT_RDY_MS, TIMEOUT_FOR_INPUT_RDY_MS);
-
+	ret = timed_wait_for_timeout(dev, WAIT_FOR_INPUT_RDY,
+				     TIME_SLICE_FOR_INPUT_RDY_MS,
+				     TIMEOUT_FOR_INPUT_RDY_MS);
 	/* ISH FW is dead */
-	if (!ish_is_input_ready(dev))
+	if (ret)
 		return	-EPIPE;
 
 	/* Send clock sync at once after reset */
@@ -531,9 +531,10 @@ static int ish_fw_reset_handler(struct ishtp_device *dev)
 			 sizeof(uint32_t));
 
 	/* Wait for ISH FW'es ILUP and ISHTP_READY */
-	timed_wait_for_timeout(dev, WAIT_FOR_FW_RDY,
-			TIME_SLICE_FOR_FW_RDY_MS, TIMEOUT_FOR_FW_RDY_MS);
-	if (!ishtp_fw_is_ready(dev)) {
+	ret = timed_wait_for_timeout(dev, WAIT_FOR_FW_RDY,
+				     TIME_SLICE_FOR_FW_RDY_MS,
+				     TIMEOUT_FOR_FW_RDY_MS);
+	if (ret) {
 		/* ISH FW is dead */
 		uint32_t	ish_status;
 

base-commit: 3ac864c2d9bb8608ee236e89bf561811613abfce

Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 9 lines · Zhang Lixu

timed_wait_for_timeout() internally checks for ish_is_input_ready() and ishtp_fw_is_ready() based on the provided parameters. If timed_wait_for_timeout() returns 0, it indicates the status is ready. In rare cases, another thread may send a message immediately after timed_wait_for_timeout() returns, causing a subsequent ish_is_input_ready() check to fail. Since the return value of timed_wait_for_timeout() is sufficient to determine readiness, the additional ready check is unnecessary and may introduce issues.

Quoted 6 lines

This patch removes the redundant check and relies solely on the return value of timed_wait_for_timeout().

Fixes ae02e5d40d5f ("HID: intel-ish-hid: ipc layer")

Applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs