From: Alexander Usyskin <alexander.usyskin@intel.com>
To: Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Menachem Adin <menachem.adin@intel.com>,
linux-kernel@vger.kernel.org,
Riana Tauro <riana.tauro@intel.com>,
Alexander Usyskin <alexander.usyskin@intel.com>
Subject: [PATCH char-misc-next] mei: csc: add reset_prepare() and reset_done()
Date: Thu, 12 Nov 2026 15:51:42 +0200 [thread overview]
Message-ID: <20261112-csc_reset_prepare_done-v1-1-843c48cc4530@intel.com> (raw)
Process PCI reset by stopping the flow in reset_prepare() and resuming
it in reset_done().
Consolidate start/stop flow in helper functions and stop polling thread
on suspend/resume by the way.
Reviewed-by: Riana Tauro <riana.tauro@intel.com>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
---
drivers/misc/mei/pci-csc.c | 77 ++++++++++++++++++++++++++++++++--------------
1 file changed, 54 insertions(+), 23 deletions(-)
diff --git a/drivers/misc/mei/pci-csc.c b/drivers/misc/mei/pci-csc.c
index fc09cfb5cdc7..7fbe4c1826bc 100644
--- a/drivers/misc/mei/pci-csc.c
+++ b/drivers/misc/mei/pci-csc.c
@@ -186,38 +186,63 @@ static void mei_csc_remove(struct pci_dev *pdev)
mei_deregister(mdev);
}
-static int mei_csc_pci_prepare(struct device *dev)
+static void mei_csc_stop(struct mei_device *mdev)
{
- pm_runtime_resume(dev);
- return 0;
-}
+ struct mei_me_hw *hw = to_me_hw(mdev);
-static int mei_csc_pci_suspend(struct device *dev)
-{
- struct mei_device *mdev = dev_get_drvdata(dev);
+ scoped_guard(mutex, &mdev->device_lock) {
+ if (mei_me_hw_use_polling(hw))
+ hw->is_active = false;
+ }
mei_stop(mdev);
mei_disable_interrupts(mdev);
-
- return 0;
}
-static int mei_csc_pci_resume(struct device *dev)
+static int mei_csc_restart(struct mei_device *mdev)
{
- struct mei_device *mdev = dev_get_drvdata(dev);
+ struct mei_me_hw *hw = to_me_hw(mdev);
int err;
+ scoped_guard(mutex, &mdev->device_lock) {
+ if (mei_me_hw_use_polling(hw)) {
+ hw->is_active = true;
+ wake_up_interruptible(&hw->wait_active);
+ }
+ }
+
err = mei_restart(mdev);
if (err)
return err;
- /* Start timer if stopped in suspend */
+ /* Start timer if stopped in stop */
schedule_delayed_work(&mdev->timer_work, HZ);
+ return 0;
+}
+static int mei_csc_pci_prepare(struct device *dev)
+{
+ pm_runtime_resume(dev);
return 0;
}
+static int mei_csc_pci_suspend(struct device *dev)
+{
+ struct mei_device *mdev = dev_get_drvdata(dev);
+
+ mei_csc_stop(mdev);
+
+ return 0;
+}
+
+static int mei_csc_pci_resume(struct device *dev)
+{
+ struct mei_device *mdev = dev_get_drvdata(dev);
+
+ return mei_csc_restart(mdev);
+}
+
static void mei_csc_pci_complete(struct device *dev)
{
pm_runtime_suspend(dev);
@@ -316,28 +341,34 @@ static pci_ers_result_t mei_csc_pci_error_slot_reset(struct pci_dev *pdev)
static void mei_csc_pci_error_resume(struct pci_dev *pdev)
{
struct mei_device *mdev = pci_get_drvdata(pdev);
- struct mei_me_hw *hw = to_me_hw(mdev);
dev_info(&pdev->dev, "error recovery: resume\n");
- scoped_guard(mutex, &mdev->device_lock) {
- if (mei_me_hw_use_polling(hw)) {
- hw->is_active = true;
- wake_up_interruptible(&hw->wait_active);
- }
- }
+ mei_csc_restart(mdev);
+}
- if (mei_restart(mdev))
- return;
+static void mei_csc_reset_prepare(struct pci_dev *pdev)
+{
+ struct mei_device *mdev = pci_get_drvdata(pdev);
- /* Start timer if stopped in error */
- schedule_delayed_work(&mdev->timer_work, HZ);
+ mei_csc_stop(mdev);
+}
+
+static void mei_csc_reset_done(struct pci_dev *pdev)
+{
+ struct mei_device *mdev = pci_get_drvdata(pdev);
+
+ pci_set_master(pdev);
+
+ mei_csc_restart(mdev);
}
static const struct pci_error_handlers mei_csc_pci_error_handlers = {
.error_detected = mei_csc_pci_error_detected,
.slot_reset = mei_csc_pci_error_slot_reset,
.resume = mei_csc_pci_error_resume,
+ .reset_prepare = mei_csc_reset_prepare,
+ .reset_done = mei_csc_reset_done,
};
static const struct dev_pm_ops mei_csc_pm_ops = {
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261112-csc_reset_prepare_done-b9310b3fa62c
Best regards,
--
Alexander Usyskin <alexander.usyskin@intel.com>
reply other threads:[~2026-11-12 13:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261112-csc_reset_prepare_done-v1-1-843c48cc4530@intel.com \
--to=alexander.usyskin@intel.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=menachem.adin@intel.com \
--cc=riana.tauro@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
all inboxes | Powered by JetHome®