From: Sebastian Ott <sebott@linux.vnet.ibm.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
Subject: [PATCH] PCI: add hibernation hooks
Date: Tue, 20 Aug 2013 16:41:02 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.03.1308201637390.1566@linux.vnet.ibm.com> (raw)
Hello Bjorn,
I'm currently trying to implement hibernate support for pci on s390. To access
the config space of a pci function on s390 the function has to be enabled first.
So I need some kind of callback to achieve this before the pci core or the device
driver tries to access the function after a resume from hibernate.
Would you be OK with the following patch?
Regards,
Sebastian
---
PCI: add hibernation hooks
Platforms may want to provide architecture-specific functionality when
a PCI device is doing a hibernate transition. Add a weak symbol
pcibios_pm_ops that architectures can override to do so.
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
---
drivers/pci/pci-driver.c | 30 ++++++++++++++++++++++++++++++
include/linux/pci.h | 4 ++++
2 files changed, 34 insertions(+)
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -763,6 +763,13 @@ static int pci_pm_resume(struct device *
#ifdef CONFIG_HIBERNATE_CALLBACKS
+
+/*
+ * pcibios_pm_ops - provide arch specific hooks when a pci device is doing
+ * a hibernate transition
+ */
+struct dev_pm_ops __weak pcibios_pm_ops;
+
static int pci_pm_freeze(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
@@ -786,6 +793,9 @@ static int pci_pm_freeze(struct device *
return error;
}
+ if (pcibios_pm_ops.freeze)
+ pcibios_pm_ops.freeze(dev);
+
return 0;
}
@@ -811,6 +821,9 @@ static int pci_pm_freeze_noirq(struct de
pci_pm_set_unknown_state(pci_dev);
+ if (pcibios_pm_ops.freeze_noirq)
+ pcibios_pm_ops.freeze_noirq(dev);
+
return 0;
}
@@ -820,6 +833,9 @@ static int pci_pm_thaw_noirq(struct devi
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pcibios_pm_ops.thaw_noirq)
+ pcibios_pm_ops.thaw_noirq(dev);
+
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume_early(dev);
@@ -837,6 +853,9 @@ static int pci_pm_thaw(struct device *de
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int error = 0;
+ if (pcibios_pm_ops.thaw)
+ pcibios_pm_ops.thaw(dev);
+
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume(dev);
@@ -878,6 +897,9 @@ static int pci_pm_poweroff(struct device
Fixup:
pci_fixup_device(pci_fixup_suspend, pci_dev);
+ if (pcibios_pm_ops.poweroff)
+ pcibios_pm_ops.poweroff(dev);
+
return 0;
}
@@ -911,6 +933,9 @@ static int pci_pm_poweroff_noirq(struct
if (pci_dev->class == PCI_CLASS_SERIAL_USB_EHCI)
pci_write_config_word(pci_dev, PCI_COMMAND, 0);
+ if (pcibios_pm_ops.poweroff_noirq)
+ pcibios_pm_ops.poweroff_noirq(dev);
+
return 0;
}
@@ -920,6 +945,9 @@ static int pci_pm_restore_noirq(struct d
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pcibios_pm_ops.restore_noirq)
+ pcibios_pm_ops.restore_noirq(dev);
+
pci_pm_default_resume_early(pci_dev);
if (pci_has_legacy_pm_support(pci_dev))
@@ -937,6 +965,8 @@ static int pci_pm_restore(struct device
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int error = 0;
+ if (pcibios_pm_ops.restore)
+ pcibios_pm_ops.restore(dev);
/*
* This is necessary for the hibernation error path in which restore is
* called without restoring the standard config registers of the device.
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1648,6 +1648,10 @@ int pcibios_set_pcie_reset_state(struct
int pcibios_add_device(struct pci_dev *dev);
void pcibios_release_device(struct pci_dev *dev);
+#ifdef CONFIG_HIBERNATE_CALLBACKS
+extern struct dev_pm_ops pcibios_pm_ops;
+#endif
+
#ifdef CONFIG_PCI_MMCONFIG
void __init pci_mmcfg_early_init(void);
void __init pci_mmcfg_late_init(void);
next reply other threads:[~2013-08-20 14:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 14:41 Sebastian Ott [this message]
2013-08-20 17:08 ` [PATCH] PCI: add hibernation hooks Bjorn Helgaas
2013-08-20 18:24 ` Sebastian Ott
2013-08-20 21:33 ` Rafael J. Wysocki
2013-08-21 16:23 ` Bjorn Helgaas
2013-08-21 22:06 ` Rafael J. Wysocki
2013-08-22 20:22 ` Bjorn Helgaas
2013-08-22 21:21 ` Sebastian Ott
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=alpine.LFD.2.03.1308201637390.1566@linux.vnet.ibm.com \
--to=sebott@linux.vnet.ibm.com \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.