patch "bus: mhi: pci-generic: Fix hibernation" added to char-misc-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
bus: mhi: pci-generic: Fix hibernation
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 5f0c2ee1fe8de700dd0d1cdc63e1a7338e2d3a3d Mon Sep 17 00:00:00 2001
From: Loic Poulain <[email protected]>
Date: Sun, 6 Jun 2021 21:07:41 +0530
Subject: bus: mhi: pci-generic: Fix hibernation
This patch fixes crash after resuming from hibernation. The issue occurs when mhi stack is builtin and so part of the 'restore-kernel', causing the device to be resumed from 'restored kernel' with a no more valid context (memory mappings etc...) and leading to spurious crashes.
This patch fixes the issue by implementing proper freeze/restore callbacks.
--- drivers/bus/mhi/pci_generic.c | 36 ++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
drivers/bus/mhi/pci_generic.c +35 -1
@@ -935,9 +935,43 @@ static int __maybe_unused mhi_pci_resume(struct device *dev)return ret; } +static int __maybe_unused mhi_pci_freeze (struct device *dev) +{ +struct mhi_pci_device *mhi_pdev =dev_get_drvdata (dev); +struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl; + +/* We want to stop all operations, hibernation does not guarantee that +* device will be in the same state as before freezing, especially if +* the intermediate restore kernel reinitializes MHI device with new +* context. +*/ +if (test_and_clear_bit (MHI_PCI_DEV_STARTED , &mhi_pdev->status)) { +mhi_power_down (mhi_cntrl, false); +mhi_unprepare_after_power_down (mhi_cntrl); + } + +return 0 ; +} + +static int __maybe_unused mhi_pci_restore (struct device *dev) +{ +struct mhi_pci_device *mhi_pdev =dev_get_drvdata (dev); + +/* Reinitialize the device */ +queue_work (system_long_wq, &mhi_pdev->recovery_work); + +return 0 ; +} +static const struct dev_pm_ops mhi_pci_pm_ops = {SET_RUNTIME_PM_OPS (mhi_pci_runtime_suspend, mhi_pci_runtime_resume,NULL ) -SET_SYSTEM_SLEEP_PM_OPS (mhi_pci_suspend, mhi_pci_resume) +#ifdef CONFIG_PM_SLEEP + .suspend = mhi_pci_suspend, + .resume = mhi_pci_resume, + .freeze = mhi_pci_freeze, + .thaw = mhi_pci_restore, + .restore = mhi_pci_restore, +#endif };static struct pci_driver mhi_pci_driver = {
Signature · 1 line
2.32.0