[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [linux-2.6.18-xen] Save/restore PCIe/PCI-X states across S3.
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1236938902 0 # Node ID e8a9f8910a3f113759906e493eaa211e2c43cd85 # Parent 13a42de2f9c53345dae1afa1f0348fc29df65803 Save/restore PCIe/PCI-X states across S3. This patch is backported from upstream Linux kernel. commit b56a5a23bfecd9cac9187164a9d5f22d287c48b9 Author: Michael S. Tsirkin <mst@xxxxxxxxxxxxxx> Date: Mon Aug 21 16:22:22 2006 +0300 PCI: Restore PCI Express capability registers after PM event Restore PCI Express capability registers after PM event. This includes maxumum MTU for PCI express and other vital data. Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx> commit cc692a5f1e9816671b77da77c6d6c463156ba1c7 Author: Stephen Hemminger <shemminger@xxxxxxxx> Date: Wed Nov 8 16:17:15 2006 -0800 PCI: save/restore PCI-X state Shouldn't PCI-X state be saved/restored? No device really needs this right now. qla24xx (fc HBA) and mthca (infiniband) don't do suspend, and sky2 resets its tweaks when links are brought up. Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx> Signed-off-by: Dexuan Cui <dexuan.cui@xxxxxxxxx> --- drivers/pci/pci.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 89 insertions(+) diff -r 13a42de2f9c5 -r e8a9f8910a3f drivers/pci/pci.c --- a/drivers/pci/pci.c Fri Mar 13 08:51:09 2009 +0000 +++ b/drivers/pci/pci.c Fri Mar 13 10:08:22 2009 +0000 @@ -428,6 +428,86 @@ pci_power_t pci_choose_state(struct pci_ EXPORT_SYMBOL(pci_choose_state); +static int pci_save_pcie_state(struct pci_dev *dev) +{ + int pos, i = 0; + struct pci_cap_saved_state *save_state; + u16 *cap; + + pos = pci_find_capability(dev, PCI_CAP_ID_EXP); + if (pos <= 0) + return 0; + + save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); + if (!save_state) { + dev_err(&dev->dev, "buffer not found in %s\n", __FUNCTION__); + return -ENOMEM; + } + cap = (u16 *)&save_state->data[0]; + + pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &cap[i++]); + pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]); + pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]); + pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]); + + return 0; +} + +static void pci_restore_pcie_state(struct pci_dev *dev) +{ + int i = 0, pos; + struct pci_cap_saved_state *save_state; + u16 *cap; + + save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); + pos = pci_find_capability(dev, PCI_CAP_ID_EXP); + if (!save_state || pos <= 0) + return; + cap = (u16 *)&save_state->data[0]; + + pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, cap[i++]); + pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]); + pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]); + pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]); +} + + +static int pci_save_pcix_state(struct pci_dev *dev) +{ + int pos; + struct pci_cap_saved_state *save_state; + + pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); + if (pos <= 0) + return 0; + + save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX); + if (!save_state) { + dev_err(&dev->dev, "buffer not found in %s\n", __FUNCTION__); + return -ENOMEM; + } + + pci_read_config_word(dev, pos + PCI_X_CMD, (u16 *)save_state->data); + + return 0; +} + +static void pci_restore_pcix_state(struct pci_dev *dev) +{ + int i = 0, pos; + struct pci_cap_saved_state *save_state; + u16 *cap; + + save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX); + pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); + if (!save_state || pos <= 0) + return; + cap = (u16 *)&save_state->data[0]; + + pci_write_config_word(dev, pos + PCI_X_CMD, cap[i++]); +} + + /** * pci_save_state - save the PCI configuration space of a device before suspending * @dev: - PCI device that we're dealing with @@ -443,6 +523,11 @@ pci_save_state(struct pci_dev *dev) return i; if ((i = pci_save_msix_state(dev)) != 0) return i; + if ((i = pci_save_pcie_state(dev)) != 0) + return i; + if ((i = pci_save_pcix_state(dev)) != 0) + return i; + return 0; } @@ -455,6 +540,9 @@ pci_restore_state(struct pci_dev *dev) { int i; int val; + + /* PCI Express register must be restored first */ + pci_restore_pcie_state(dev); /* * The Base Address register should be programmed before the command @@ -471,6 +559,7 @@ pci_restore_state(struct pci_dev *dev) dev->saved_config_space[i]); } } + pci_restore_pcix_state(dev); pci_restore_msi_state(dev); pci_restore_msix_state(dev); return 0; _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |