HID: Intel-ish-hid: Ishtp: Fix sensor reads after ACPI S3 suspend
Subsystems (2)
PATCH 1/1 HID: Intel-ish-hid: Ishtp: Fix sensor reads after ACPI S3 suspend
After legacy suspend/resume via ACPI S3, sensor read operation fails with timeout. Also, it will cause delay in resume operation as there will be retries on failure.
This is caused by commit f645a90e8ff7 ("HID: intel-ish-hid:
ishtp-hid-client: use helper functions for connection"), which used helper functions to simplify connect, reset and disconnect process. Also avoid freeing and allocating client buffers again during reconnect process.
But there is a case, when ISH firmware resets after ACPI S3 suspend, ishtp bus driver frees client buffers. Since there is no realloc again during reconnect, there are no client buffers available to send connection requests to the firmware. Without successful connection to the firmware, subsequent sensor reads will timeout.
To address this issue, ishtp bus driver does not free client buffers on warm reset after S3 resume. Simply add the buffers from the read list to free list of buffers.
--- drivers/hid/intel-ish-hid/ishtp/bus.c | 2 ++ drivers/hid/intel-ish-hid/ishtp/client.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/hid/intel-ish-hid/ishtp/bus.c +2 -0
@@ -722,6 +722,8 @@ void ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev,spin_lock_irqsave (&ishtp_dev->cl_list_lock, flags);list_for_each_entry (cl, &ishtp_dev->cl_list, link) { cl->state =ISHTP_CL_DISCONNECTED ; +if (warm_reset && cl->device->reference_count) +continue ;/* * Wake any pending process. The waiter would check dev->state
drivers/hid/intel-ish-hid/ishtp/client.c +3 -1
@@ -49,7 +49,9 @@ static void ishtp_read_list_flush(struct ishtp_cl *cl)list_for_each_entry_safe (rb, next, &cl->dev->read_list.list, list)if (rb->cl &&ishtp_cl_cmp_id (cl, rb->cl)) {list_del (&rb->list); -ishtp_io_rb_free (rb); +spin_lock (&cl->free_list_spinlock); +list_add_tail (&rb->list, &cl->free_rb_list.list); +spin_unlock (&cl->free_list_spinlock); }spin_unlock_irqrestore (&cl->dev->read_list_spinlock, flags); }
Signature · 1 line
2.43.0
Quoted 25 lines · Even Xu
After legacy suspend/resume via ACPI S3, sensor read operation fails with timeout. Also, it will cause delay in resume operation as there will be retries on failure.
This is caused by commit
f645a90e8ff7("HID: intel-ish-hid:
ishtp-hid-client: use helper functions for connection"), which used helper functions to simplify connect, reset and disconnect process. Also avoid freeing and allocating client buffers again during reconnect
process.But there is a case, when ISH firmware resets after ACPI S3 suspend, ishtp bus driver frees client buffers. Since there is no realloc again
during reconnect, there are no client buffers available to send connection
requests to the firmware. Without successful connection to the firmware,
subsequent sensor reads will timeout.To address this issue, ishtp bus driver does not free client buffers on
warm reset after S3 resume. Simply add the buffers from the read list to free list of buffers.
Quoted 4 lines
Fixes f645a90e8ff7 ("HID: intel-ish-hid: ishtp-hid-client: usehelper functions for connection")
Signed-off-by Even Xu <[email protected]>
Hi Jiri,
This regression is introduced with 6.8-rc1, so need a pull request for this rc cycle.
Thanks,
Srinivas
Quoted 40 lines
---
drivers/hid/intel-ish-hid/ishtp/bus.c | 2 ++drivers/hid/intel-ish-hid/ishtp/client.c| 4 +++-2 files changed, 5 insertions(+), 1 deletion(-)drivers/hid/intel-ish-hid/ishtp/bus.c +2
-0@@ -722,6 +722,8 @@ void ishtp_bus_remove_all_clients(structishtp_device *ishtp_dev, spin_lock_irqsave(&ishtp_dev->cl_list_lock, flags); list_for_each_entry(cl, &ishtp_dev->cl_list, link) { cl->state = ISHTP_CL_DISCONNECTED; + if (warm_reset && cl->device->reference_count) + continue;
/*
* Wake any pending process. The waiter would checkdev->statedrivers/hid/intel-ish-hid/ishtp/client.c +3
-1@@ -49,7 +49,9 @@ static void ishtp_read_list_flush(struct ishtp_cl *cl) list_for_each_entry_safe(rb, next, &cl->dev->read_list.list, list) if (rb->cl && ishtp_cl_cmp_id(cl, rb->cl)) { list_del(&rb->list); - ishtp_io_rb_free(rb); + spin_lock(&cl->free_list_spinlock); + list_add_tail(&rb->list, &cl- >free_rb_list.list); + spin_unlock(&cl->free_list_spinlock);}
spin_unlock_irqrestore(&cl->dev->read_list_spinlock, flags); }
Jiri Kosina
maintainerQuoted 10 lines · srinivas pandruvada
Quoted 4 lines
Fixes f645a90e8ff7 ("HID: intel-ish-hid: ishtp-hid-client: usehelper functions for connection")
Signed-off-by Even Xu <[email protected]>Hi Jiri,
This regression is introduced with 6.8-rc1, so need a pull request for this rc cycle.
Right; now queued in hid.git#for-6.8/upstream-fixes. Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Thanks Jiri and Srinivas!
Best Regards,
Even Xu
-----Original Message-----
From: Jiri Kosina <[email protected]>
Sent: Tuesday, February 13, 2024 6:32 PM
To: srinivas pandruvada <[email protected]>
Cc: Xu, Even <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] HID: Intel-ish-hid: Ishtp: Fix sensor reads after ACPI S3 suspend
Quoted 10 lines · srinivas pandruvada
Quoted 4 lines
Fixes f645a90e8ff7 ("HID: intel-ish-hid: ishtp-hid-client: usehelper functions for connection")
Signed-off-by Even Xu <[email protected]>Hi Jiri,
This regression is introduced with 6.8-rc1, so need a pull request for this rc cycle.
Right; now queued in hid.git#for-6.8/upstream-fixes. Thanks,
--
Jiri Kosina
SUSE Labs