aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a32db0628157..d3eab057b2d3 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -551,7 +551,9 @@ static int pci_save_pcie_state(struct pci_dev *dev)
551 if (pos <= 0) 551 if (pos <= 0)
552 return 0; 552 return 0;
553 553
554 save_state = kzalloc(sizeof(*save_state) + sizeof(u16) * 4, GFP_KERNEL); 554 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP);
555 if (!save_state)
556 save_state = kzalloc(sizeof(*save_state) + sizeof(u16) * 4, GFP_KERNEL);
555 if (!save_state) { 557 if (!save_state) {
556 dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n"); 558 dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n");
557 return -ENOMEM; 559 return -ENOMEM;
@@ -582,8 +584,6 @@ static void pci_restore_pcie_state(struct pci_dev *dev)
582 pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]); 584 pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]);
583 pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]); 585 pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]);
584 pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]); 586 pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]);
585 pci_remove_saved_cap(save_state);
586 kfree(save_state);
587} 587}
588 588
589 589
@@ -597,7 +597,9 @@ static int pci_save_pcix_state(struct pci_dev *dev)
597 if (pos <= 0) 597 if (pos <= 0)
598 return 0; 598 return 0;
599 599
600 save_state = kzalloc(sizeof(*save_state) + sizeof(u16), GFP_KERNEL); 600 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP);
601 if (!save_state)
602 save_state = kzalloc(sizeof(*save_state) + sizeof(u16), GFP_KERNEL);
601 if (!save_state) { 603 if (!save_state) {
602 dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n"); 604 dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n");
603 return -ENOMEM; 605 return -ENOMEM;
@@ -622,8 +624,6 @@ static void pci_restore_pcix_state(struct pci_dev *dev)
622 cap = (u16 *)&save_state->data[0]; 624 cap = (u16 *)&save_state->data[0];
623 625
624 pci_write_config_word(dev, pos + PCI_X_CMD, cap[i++]); 626 pci_write_config_word(dev, pos + PCI_X_CMD, cap[i++]);
625 pci_remove_saved_cap(save_state);
626 kfree(save_state);
627} 627}
628 628
629 629
@@ -638,8 +638,6 @@ pci_save_state(struct pci_dev *dev)
638 /* XXX: 100% dword access ok here? */ 638 /* XXX: 100% dword access ok here? */
639 for (i = 0; i < 16; i++) 639 for (i = 0; i < 16; i++)
640 pci_read_config_dword(dev, i * 4,&dev->saved_config_space[i]); 640 pci_read_config_dword(dev, i * 4,&dev->saved_config_space[i]);
641 if ((i = pci_save_msi_state(dev)) != 0)
642 return i;
643 if ((i = pci_save_pcie_state(dev)) != 0) 641 if ((i = pci_save_pcie_state(dev)) != 0)
644 return i; 642 return i;
645 if ((i = pci_save_pcix_state(dev)) != 0) 643 if ((i = pci_save_pcix_state(dev)) != 0)