]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: intel-ish-hid: Use IPC RESET instead of void message in ish_wakeup()
authorZhang Lixu <lixu.zhang@intel.com>
Fri, 17 Oct 2025 02:22:17 +0000 (10:22 +0800)
committerJiri Kosina <jkosina@suse.com>
Fri, 17 Oct 2025 15:47:54 +0000 (17:47 +0200)
On ISH power-up, the bootloader enters sleep after preparing to load the
main firmware, waiting for the driver to be ready. When the driver is
ready, it sends a void message to wake up the bootloader and load the main
firmware. The main firmware then sends MNG_RESET_NOTIFY to the driver for
handshake.

This void message-based IPC handshake only works if the main firmware has
not been loaded. During hibernation resume, if the restore kernel has the
ISH driver, the driver wakes up the bootloader to load the main firmware
and perform IPC handshake. However, when switching to the image kernel,
since the main firmware is already loaded, sending a void message in the
.restore() callback does not trigger IPC handshake.

By sending MNG_RESET_NOTIFY (IPC RESET message) in ish_wakeup() instead of
a void message, we can explicitly wake up the bootloader and perform IPC
handshake, regardless of the firmware state. Additionally, since
ish_ipc_reset() already waits for recvd_hw_ready, the redundant wait for
recvd_hw_ready in ish_hw_start() is removed.

The timeout for waiting for HW ready is set to 10 seconds, matching the
original timeout value used in ish_wakeup(), to ensure reliable wakeup on
hardware that requires more time, such as the Lenovo ThinkPad X1 Titanium
Gen 1.

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>
drivers/hid/intel-ish-hid/ipc/ipc.c

index 01a139e17cb524443702e238c538abd9a426c761..59355e4a61f829949f7b2f2ef885bf1414823156 100644 (file)
@@ -728,22 +728,28 @@ int ish_disable_dma(struct ishtp_device *dev)
  * ish_wakeup() - wakeup ishfw from waiting-for-host state
  * @dev: ishtp device pointer
  *
- * Set the dma enable bit and send a void message to FW,
+ * Set the dma enable bit and send a IPC RESET message to FW,
  * it wil wakeup FW from waiting-for-host state.
+ *
+ * Return: 0 for success else error code.
  */
-static void ish_wakeup(struct ishtp_device *dev)
+static int ish_wakeup(struct ishtp_device *dev)
 {
+       int ret;
+
        /* Set dma enable bit */
        ish_reg_write(dev, IPC_REG_ISH_RMP2, IPC_RMP2_DMA_ENABLED);
 
        /*
-        * Send 0 IPC message so that ISH FW wakes up if it was already
+        * Send IPC RESET message so that ISH FW wakes up if it was already
         * asleep.
         */
-       ish_reg_write(dev, IPC_REG_HOST2ISH_DRBL, IPC_DRBL_BUSY_BIT);
+       ret = ish_ipc_reset(dev);
 
        /* Flush writes to doorbell and REMAP2 */
        ish_reg_read(dev, IPC_REG_ISH_HOST_FWSTS);
+
+       return ret;
 }
 
 /**
@@ -792,11 +798,11 @@ static int _ish_hw_reset(struct ishtp_device *dev)
        pci_write_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, csr);
 
        /* Now we can enable ISH DMA operation and wakeup ISHFW */
-       ish_wakeup(dev);
-
-       return  0;
+       return ish_wakeup(dev);
 }
 
+#define RECVD_HW_READY_TIMEOUT (10 * HZ)
+
 /**
  * _ish_ipc_reset() - IPC reset
  * @dev: ishtp device pointer
@@ -831,7 +837,8 @@ static int _ish_ipc_reset(struct ishtp_device *dev)
        }
 
        wait_event_interruptible_timeout(dev->wait_hw_ready,
-                                        dev->recvd_hw_ready, 2 * HZ);
+                                        dev->recvd_hw_ready,
+                                        RECVD_HW_READY_TIMEOUT);
        if (!dev->recvd_hw_ready) {
                dev_err(dev->devc, "Timed out waiting for HW ready\n");
                rv = -ENODEV;
@@ -855,21 +862,7 @@ int ish_hw_start(struct ishtp_device *dev)
        set_host_ready(dev);
 
        /* After that we can enable ISH DMA operation and wakeup ISHFW */
-       ish_wakeup(dev);
-
-       /* wait for FW-initiated reset flow */
-       if (!dev->recvd_hw_ready)
-               wait_event_interruptible_timeout(dev->wait_hw_ready,
-                                                dev->recvd_hw_ready,
-                                                10 * HZ);
-
-       if (!dev->recvd_hw_ready) {
-               dev_err(dev->devc,
-                       "[ishtp-ish]: Timed out waiting for FW-initiated reset\n");
-               return  -ENODEV;
-       }
-
-       return 0;
+       return ish_wakeup(dev);
 }
 
 /**