]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
HID: intel-ish-hid: Use dedicated unbound workqueues to prevent resume blocking
authorZhang Lixu <lixu.zhang@intel.com>
Fri, 10 Oct 2025 05:52:54 +0000 (13:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Jan 2026 10:18:50 +0000 (11:18 +0100)
commit 0d30dae38fe01cd1de358c6039a0b1184689fe51 upstream.

During suspend/resume tests with S2IDLE, some ISH functional failures were
observed because of delay in executing ISH resume handler. Here
schedule_work() is used from resume handler to do actual work.
schedule_work() uses system_wq, which is a per CPU work queue. Although
the queuing is not bound to a CPU, but it prefers local CPU of the caller,
unless prohibited.

Users of this work queue are not supposed to queue long running work.
But in practice, there are scenarios where long running work items are
queued on other unbound workqueues, occupying the CPU. As a result, the
ISH resume handler may not get a chance to execute in a timely manner.

In one scenario, one of the ish_resume_handler() executions was delayed
nearly 1 second because another work item on an unbound workqueue occupied
the same CPU. This delay causes ISH functionality failures.

A similar issue was previously observed where the ISH HID driver timed out
while getting the HID descriptor during S4 resume in the recovery kernel,
likely caused by the same workqueue contention problem.

Create dedicated unbound workqueues for all ISH operations to allow work
items to execute on any available CPU, eliminating CPU-specific bottlenecks
and improving resume reliability under varying system loads. Also ISH has
three different components, a bus driver which implements ISH protocols, a
PCI interface layer and HID interface. Use one dedicated work queue for all
of them.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/intel-ish-hid/ipc/ipc.c
drivers/hid/intel-ish-hid/ipc/pci-ish.c
drivers/hid/intel-ish-hid/ishtp-hid-client.c
drivers/hid/intel-ish-hid/ishtp/bus.c
drivers/hid/intel-ish-hid/ishtp/hbm.c
drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
include/linux/intel-ish-client-if.h

index 4c861119e97aa0dae16b0dae3e23be6bec0e46ef..264f9c07a7f3df900a0201f633749cd8b6103240 100644 (file)
@@ -627,7 +627,7 @@ static void recv_ipc(struct ishtp_device *dev, uint32_t doorbell_val)
                if (!ishtp_dev) {
                        ishtp_dev = dev;
                }
-               schedule_work(&fw_reset_work);
+               queue_work(dev->unbound_wq, &fw_reset_work);
                break;
 
        case MNG_RESET_NOTIFY_ACK:
@@ -932,6 +932,21 @@ static const struct ishtp_hw_ops ish_hw_ops = {
        .dma_no_cache_snooping = _dma_no_cache_snooping
 };
 
+static struct workqueue_struct *devm_ishtp_alloc_workqueue(struct device *dev)
+{
+       struct workqueue_struct *wq;
+
+       wq = alloc_workqueue("ishtp_unbound_%d", WQ_UNBOUND, 0, dev->id);
+       if (!wq)
+               return NULL;
+
+       if (devm_add_action_or_reset(dev, (void (*)(void *))destroy_workqueue,
+                                    wq))
+               return NULL;
+
+       return wq;
+}
+
 /**
  * ish_dev_init() -Initialize ISH devoce
  * @pdev: PCI device
@@ -952,6 +967,10 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
        if (!dev)
                return NULL;
 
+       dev->unbound_wq = devm_ishtp_alloc_workqueue(&pdev->dev);
+       if (!dev->unbound_wq)
+               return NULL;
+
        dev->devc = &pdev->dev;
        ishtp_device_init(dev);
 
index 1894743e8802884696059dd4f17e9f2b9b39d06a..c5df6e190043b2301944c6662740b9513951f18c 100644 (file)
@@ -381,7 +381,7 @@ static int __maybe_unused ish_resume(struct device *device)
        ish_resume_device = device;
        dev->resume_flag = 1;
 
-       schedule_work(&resume_work);
+       queue_work(dev->unbound_wq, &resume_work);
 
        return 0;
 }
index af6a5afc1a93e9efb7603d76563780f580e485f5..89b954a195343b4ddbb22e872e45b74abb8a0091 100644 (file)
@@ -858,7 +858,7 @@ static int hid_ishtp_cl_reset(struct ishtp_cl_device *cl_device)
        hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__,
                        hid_ishtp_cl);
 
-       schedule_work(&client_data->work);
+       queue_work(ishtp_get_workqueue(cl_device), &client_data->work);
 
        return 0;
 }
@@ -900,7 +900,7 @@ static int hid_ishtp_cl_resume(struct device *device)
 
        hid_ishtp_trace(client_data, "%s hid_ishtp_cl %p\n", __func__,
                        hid_ishtp_cl);
-       schedule_work(&client_data->resume_work);
+       queue_work(ishtp_get_workqueue(cl_device), &client_data->resume_work);
        return 0;
 }
 
index 5ac7d70a7c84353c4979bd6892aaba4021d07f68..1ff63fa89fd82faf80dc567abdee9d7ce8e78fb3 100644 (file)
@@ -541,7 +541,7 @@ void ishtp_cl_bus_rx_event(struct ishtp_cl_device *device)
                return;
 
        if (device->event_cb)
-               schedule_work(&device->event_work);
+               queue_work(device->ishtp_dev->unbound_wq, &device->event_work);
 }
 
 /**
@@ -879,6 +879,22 @@ struct device *ishtp_get_pci_device(struct ishtp_cl_device *device)
 }
 EXPORT_SYMBOL(ishtp_get_pci_device);
 
+/**
+ * ishtp_get_workqueue - Retrieve the workqueue associated with an ISHTP device
+ * @cl_device: Pointer to the ISHTP client device structure
+ *
+ * Returns the workqueue_struct pointer (unbound_wq) associated with the given
+ * ISHTP client device. This workqueue is typically used for scheduling work
+ * related to the device.
+ *
+ * Return: Pointer to struct workqueue_struct.
+ */
+struct workqueue_struct *ishtp_get_workqueue(struct ishtp_cl_device *cl_device)
+{
+       return cl_device->ishtp_dev->unbound_wq;
+}
+EXPORT_SYMBOL(ishtp_get_workqueue);
+
 /**
  * ishtp_trace_callback() - Return trace callback
  * @cl_device: ISH-TP client device instance
index 8ee5467127d87294631350ee49350cd718f86e96..97c4fcd9e3c6f2c3ccf696accd7e6196617f637f 100644 (file)
@@ -573,7 +573,7 @@ void ishtp_hbm_dispatch(struct ishtp_device *dev,
 
                /* Start firmware loading process if it has loader capability */
                if (version_res->host_version_supported & ISHTP_SUPPORT_CAP_LOADER)
-                       schedule_work(&dev->work_fw_loader);
+                       queue_work(dev->unbound_wq, &dev->work_fw_loader);
 
                dev->version.major_version = HBM_MAJOR_VERSION;
                dev->version.minor_version = HBM_MINOR_VERSION;
@@ -864,7 +864,7 @@ void        recv_hbm(struct ishtp_device *dev, struct ishtp_msg_hdr *ishtp_hdr)
        dev->rd_msg_fifo_tail = (dev->rd_msg_fifo_tail + IPC_PAYLOAD_SIZE) %
                (RD_INT_FIFO_SIZE * IPC_PAYLOAD_SIZE);
        spin_unlock_irqrestore(&dev->rd_msg_spinlock, flags);
-       schedule_work(&dev->bh_hbm_work);
+       queue_work(dev->unbound_wq, &dev->bh_hbm_work);
 eoi:
        return;
 }
index b35afefd036d402bb364f2393a093fbb79f40300..47773b161da13fd586068dd3973d145331de296e 100644 (file)
@@ -166,6 +166,9 @@ struct ishtp_device {
        struct hbm_version version;
        int transfer_path; /* Choice of transfer path: IPC or DMA */
 
+       /* Alloc a dedicated unbound workqueue for ishtp device */
+       struct workqueue_struct *unbound_wq;
+
        /* work structure for scheduling firmware loading tasks */
        struct work_struct work_fw_loader;
        /* waitq for waiting for command response from the firmware loader */
index 771622650247a7d4257f984fb0538844206faf5e..d87cf772708436f2936f2e31ea4b26fe482a9842 100644 (file)
@@ -87,6 +87,8 @@ bool ishtp_wait_resume(struct ishtp_device *dev);
 ishtp_print_log ishtp_trace_callback(struct ishtp_cl_device *cl_device);
 /* Get device pointer of PCI device for DMA acces */
 struct device *ishtp_get_pci_device(struct ishtp_cl_device *cl_device);
+/* Get the ISHTP workqueue */
+struct workqueue_struct *ishtp_get_workqueue(struct ishtp_cl_device *cl_device);
 
 struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device);
 void ishtp_cl_free(struct ishtp_cl *cl);