linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Lixu <lixu.zhang@intel.com>
To: linux-input@vger.kernel.org, srinivas.pandruvada@linux.intel.com,
	jikos@kernel.org, benjamin.tissoires@redhat.com
Cc: lixu.zhang@intel.com
Subject: [PATCH 3/6] HID: intel-ish-ipc: Reset clients state on resume from D3
Date: Fri, 19 Sep 2025 09:05:56 +0800	[thread overview]
Message-ID: <20250919010559.165076-4-lixu.zhang@intel.com> (raw)
In-Reply-To: <20250919010559.165076-1-lixu.zhang@intel.com>

When ISH resumes from D3, the connection between ishtp clients and firmware
is lost. The ish_resume() function schedules resume_work asynchronously to
re-initiate the connection and then returns immediately. This can cause a
race where the upper-layer ishtp client driver's .resume() may execute
before the connection is fully restored, leaving the client in a stale
connected state. If the client sends messages during this window, the
firmware cannot respond.

To avoid this, reset the ishtp clients' state before returning from
ish_resume() if ISH is resuming from D3.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/hid/intel-ish-hid/ipc/pci-ish.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
index 9d150ce234f2..ccd195adbbd6 100644
--- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c
+++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
@@ -147,6 +147,12 @@ static inline bool ish_should_enter_d0i3(struct pci_dev *pdev)
 
 static inline bool ish_should_leave_d0i3(struct pci_dev *pdev)
 {
+	struct ishtp_device *dev = pci_get_drvdata(pdev);
+	u32 fwsts = dev->ops->get_fw_status(dev);
+
+	if (dev->suspend_flag || !IPC_IS_ISH_ILUP(fwsts))
+		return false;
+
 	return !pm_resume_via_firmware() || pdev->device == PCI_DEVICE_ID_INTEL_ISH_CHV;
 }
 
@@ -277,10 +283,8 @@ static void __maybe_unused ish_resume_handler(struct work_struct *work)
 {
 	struct pci_dev *pdev = to_pci_dev(ish_resume_device);
 	struct ishtp_device *dev = pci_get_drvdata(pdev);
-	uint32_t fwsts = dev->ops->get_fw_status(dev);
 
-	if (ish_should_leave_d0i3(pdev) && !dev->suspend_flag
-			&& IPC_IS_ISH_ILUP(fwsts)) {
+	if (ish_should_leave_d0i3(pdev)) {
 		if (device_may_wakeup(&pdev->dev))
 			disable_irq_wake(pdev->irq);
 
@@ -384,6 +388,10 @@ static int __maybe_unused ish_resume(struct device *device)
 	ish_resume_device = device;
 	dev->resume_flag = 1;
 
+	/* If ISH resume from D3, reset ishtp clients before return */
+	if (!ish_should_leave_d0i3(pdev))
+		ishtp_reset_handler(dev);
+
 	schedule_work(&resume_work);
 
 	return 0;
-- 
2.43.0


  parent reply	other threads:[~2025-09-19  1:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19  1:05 [PATCH 0/6] HID: intel-ish-hid: Various power management improvements for hibernation Zhang Lixu
2025-09-19  1:05 ` [PATCH 1/6] HID: intel-ish-hid: Add ishtp_get_connection_state() interface Zhang Lixu
2025-09-19  1:05 ` [PATCH 2/6] HID: intel-ishtp-hid: Clear suspended flag only after connected on resume Zhang Lixu
2025-09-19  1:05 ` Zhang Lixu [this message]
2025-09-19  1:05 ` [PATCH 4/6] HID: intel-ish-hid: ipc: Always schedule FW reset work on RESET_NOTIFY/ACK Zhang Lixu
2025-09-19  1:05 ` [PATCH 5/6] HID: intel-ish-hid: Use IPC RESET instead of void message in ish_wakeup() Zhang Lixu
2025-09-19  1:05 ` [PATCH 6/6] HID: intel-ish-hid: ipc: Separate hibernate callbacks in dev_pm_ops Zhang Lixu
2025-10-14  9:24 ` [PATCH 0/6] HID: intel-ish-hid: Various power management improvements for hibernation Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250919010559.165076-4-lixu.zhang@intel.com \
    --to=lixu.zhang@intel.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).