Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=cc692a5f1e9816671b77da77c6d6c463156ba1c7
Commit:     cc692a5f1e9816671b77da77c6d6c463156ba1c7
Parent:     e65e5fb5ceb02aaea7b65bf8b3b0d0c9057718b6
Author:     Stephen Hemminger <[EMAIL PROTECTED]>
AuthorDate: Wed Nov 8 16:17:15 2006 -0800
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Dec 1 14:36:56 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 <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 drivers/pci/pci.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a544997..0eaf381 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -490,6 +490,47 @@ static void pci_restore_pcie_state(struc
        kfree(save_state);
 }
 
+
+static int pci_save_pcix_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_PCIX);
+       if (pos <= 0)
+               return 0;
+
+       save_state = kzalloc(sizeof(*save_state) + sizeof(u16), GFP_KERNEL);
+       if (!save_state) {
+               dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n");
+               return -ENOMEM;
+       }
+       cap = (u16 *)&save_state->data[0];
+
+       pci_read_config_word(dev, pos + PCI_X_CMD, &cap[i++]);
+       pci_add_saved_cap(dev, save_state);
+       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_remove_saved_cap(save_state);
+       kfree(save_state);
+}
+
+
 /**
  * pci_save_state - save the PCI configuration space of a device before 
suspending
  * @dev: - PCI device that we're dealing with
@@ -507,6 +548,8 @@ pci_save_state(struct pci_dev *dev)
                return i;
        if ((i = pci_save_pcie_state(dev)) != 0)
                return i;
+       if ((i = pci_save_pcix_state(dev)) != 0)
+               return i;
        return 0;
 }
 
@@ -538,6 +581,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;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to