From: Sebastian Ott <sebott@linux.vnet.ibm.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: Re: [PATCH] PCI: add hibernation hooks
Date: Tue, 20 Aug 2013 20:24:24 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.03.1308202016210.1620@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAErSpo4qnDyQQt+sZi=1tj0PP+HUmLfMp4zQ2hdqjJ+mOcAzYA@mail.gmail.com>
On Tue, 20 Aug 2013, Bjorn Helgaas wrote:
> On Tue, Aug 20, 2013 at 8:41 AM, Sebastian Ott
> <sebott@linux.vnet.ibm.com> wrote:
> > 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?
>
> I think doing something like this is fine.
>
> What would it look like if we provided empty weak definitions of the
> eight functions you need to hook: pcibios_pm_freeze(),
> pcibios_pm_freeze_noirq(), etc.? Then the callers wouldn't have to do
> a test before making the call. Not sure which would be better, but it
> might be more obvious that this is a build-time binding rather than a
> dynamic binding.
>
> Should we check return values from the arch code?
OK. I did one additional change - since we are not dependant on dev_pm_ops
we can call these functions with a pci_dev *.
Regards,
Sebastian
---
PCI: add hibernation hooks
Platforms may want to provide architecture-specific functionality when
a PCI device is doing a hibernate transition. Add weak symbols
pcibios_pm_* that architectures can override to do so.
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
---
drivers/pci/pci-driver.c | 46 ++++++++++++++++++++++++++++++++++++++--------
include/linux/pci.h | 11 +++++++++++
2 files changed, 49 insertions(+), 8 deletions(-)
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -763,6 +763,20 @@ static int pci_pm_resume(struct device *
#ifdef CONFIG_HIBERNATE_CALLBACKS
+
+/*
+ * provide arch specific hooks when a pci device is doing
+ * a hibernate transition
+ */
+int __weak pcibios_pm_freeze(struct pci_dev *pdev) { return 0; }
+int __weak pcibios_pm_freeze_noirq(struct pci_dev *pdev) { return 0; }
+int __weak pcibios_pm_thaw(struct pci_dev *pdev) { return 0; }
+int __weak pcibios_pm_thaw_noirq(struct pci_dev *pdev) { return 0; }
+int __weak pcibios_pm_poweroff(struct pci_dev *pdev) { return 0; }
+int __weak pcibios_pm_poweroff_noirq(struct pci_dev *pdev) { return 0; }
+int __weak pcibios_pm_restore(struct pci_dev *pdev) { return 0; }
+int __weak pcibios_pm_restore_noirq(struct pci_dev *pdev) { return 0; }
+
static int pci_pm_freeze(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
@@ -786,7 +800,7 @@ static int pci_pm_freeze(struct device *
return error;
}
- return 0;
+ return pcibios_pm_freeze(pci_dev);
}
static int pci_pm_freeze_noirq(struct device *dev)
@@ -811,14 +825,18 @@ static int pci_pm_freeze_noirq(struct de
pci_pm_set_unknown_state(pci_dev);
- return 0;
+ return pcibios_pm_freeze_noirq(pci_dev);
}
static int pci_pm_thaw_noirq(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
struct device_driver *drv = dev->driver;
- int error = 0;
+ int error;
+
+ error = pcibios_pm_thaw_noirq(pci_dev);
+ if (error)
+ return error;
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume_early(dev);
@@ -835,7 +853,11 @@ static int pci_pm_thaw(struct device *de
{
struct pci_dev *pci_dev = to_pci_dev(dev);
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- int error = 0;
+ int error;
+
+ error = pcibios_pm_thaw(pci_dev);
+ if (error)
+ return error;
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume(dev);
@@ -878,7 +900,7 @@ static int pci_pm_poweroff(struct device
Fixup:
pci_fixup_device(pci_fixup_suspend, pci_dev);
- return 0;
+ return pcibios_pm_poweroff(pci_dev);
}
static int pci_pm_poweroff_noirq(struct device *dev)
@@ -911,14 +933,18 @@ 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);
- return 0;
+ return pcibios_pm_poweroff_noirq(pci_dev);
}
static int pci_pm_restore_noirq(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
struct device_driver *drv = dev->driver;
- int error = 0;
+ int error;
+
+ error = pcibios_pm_restore_noirq(pci_dev);
+ if (error)
+ return error;
pci_pm_default_resume_early(pci_dev);
@@ -935,7 +961,11 @@ static int pci_pm_restore(struct device
{
struct pci_dev *pci_dev = to_pci_dev(dev);
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- int error = 0;
+ int error;
+
+ error = pcibios_pm_restore(pci_dev);
+ if (error)
+ return error;
/*
* This is necessary for the hibernation error path in which restore is
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1648,6 +1648,17 @@ 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
+int pcibios_pm_freeze(struct pci_dev *pdev);
+int pcibios_pm_freeze_noirq(struct pci_dev *pdev);
+int pcibios_pm_thaw(struct pci_dev *pdev);
+int pcibios_pm_thaw_noirq(struct pci_dev *pdev);
+int pcibios_pm_poweroff(struct pci_dev *pdev);
+int pcibios_pm_poweroff_noirq(struct pci_dev *pdev);
+int pcibios_pm_restore(struct pci_dev *pdev);
+int pcibios_pm_restore_noirq(struct pci_dev *pdev);
+#endif
+
#ifdef CONFIG_PCI_MMCONFIG
void __init pci_mmcfg_early_init(void);
void __init pci_mmcfg_late_init(void);
next prev parent reply other threads:[~2013-08-20 18:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 14:41 [PATCH] PCI: add hibernation hooks Sebastian Ott
2013-08-20 17:08 ` Bjorn Helgaas
2013-08-20 18:24 ` Sebastian Ott [this message]
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.1308202016210.1620@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 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).