Skip to content

Commit 8931f7b

Browse files
lixuzhaJiri Kosina
authored andcommitted
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: ae02e5d ("HID: intel-ish-hid: ipc layer") Signed-off-by: Zhang Lixu <lixu.zhang@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 02d6eee commit 8931f7b

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

  • drivers/hid/intel-ish-hid/ipc

drivers/hid/intel-ish-hid/ipc/ipc.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ static int ish_fw_reset_handler(struct ishtp_device *dev)
498498
{
499499
uint32_t reset_id;
500500
unsigned long flags;
501+
int ret;
501502

502503
/* Read reset ID */
503504
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)
510511
/* ISHTP notification in IPC_RESET */
511512
ishtp_reset_handler(dev);
512513

513-
if (!ish_is_input_ready(dev))
514-
timed_wait_for_timeout(dev, WAIT_FOR_INPUT_RDY,
515-
TIME_SLICE_FOR_INPUT_RDY_MS, TIMEOUT_FOR_INPUT_RDY_MS);
516-
514+
ret = timed_wait_for_timeout(dev, WAIT_FOR_INPUT_RDY,
515+
TIME_SLICE_FOR_INPUT_RDY_MS,
516+
TIMEOUT_FOR_INPUT_RDY_MS);
517517
/* ISH FW is dead */
518-
if (!ish_is_input_ready(dev))
518+
if (ret)
519519
return -EPIPE;
520520

521521
/* Send clock sync at once after reset */
@@ -531,9 +531,10 @@ static int ish_fw_reset_handler(struct ishtp_device *dev)
531531
sizeof(uint32_t));
532532

533533
/* Wait for ISH FW'es ILUP and ISHTP_READY */
534-
timed_wait_for_timeout(dev, WAIT_FOR_FW_RDY,
535-
TIME_SLICE_FOR_FW_RDY_MS, TIMEOUT_FOR_FW_RDY_MS);
536-
if (!ishtp_fw_is_ready(dev)) {
534+
ret = timed_wait_for_timeout(dev, WAIT_FOR_FW_RDY,
535+
TIME_SLICE_FOR_FW_RDY_MS,
536+
TIMEOUT_FOR_FW_RDY_MS);
537+
if (ret) {
537538
/* ISH FW is dead */
538539
uint32_t ish_status;
539540

0 commit comments

Comments
 (0)