aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorMyron Stowe <myron.stowe@redhat.com>2012-06-01 17:16:43 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-06-11 22:41:28 -0400
commit9cb604ed45a31419bab3877472691a5da15a3c47 (patch)
tree6a9c237f2af76b3ac257fb6ee477cc8fb7b89980 /drivers/pci/pci.c
parentc463b8cb9350cf1230cefe467a1cf279140a5437 (diff)
PCI: remove redundant capabilities checking in pci_{save, restore}_pcie_state
Unlike PCI Express v1's Capabilities Structure, v2's requires the entire structure to be implemented. In v2 structures, register fields that are not implemented are present but hardwired to 0x0. These may include: Link Capabilities, Status, and Control; Slot Capabilities, Status, and Control; Root Capabilities, Status, and Control; and all of the '2' (Device, Link, and Slot) Capabilities, Status, and Control registers. This patch removes the redundant capability checks corresponding to the Link 2's and Slot 2's, Capabilities, Status, and Control registers as they will be present if Device Capabilities 2's registers are (which explains why the macros for each of the three are identical). Signed-off-by: Myron Stowe <myron.stowe@redhat.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 985df63aa59..fe26df7cf5c 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -854,12 +854,6 @@ EXPORT_SYMBOL(pci_choose_state);
854 ((flags & PCI_EXP_FLAGS_VERS) > 1 || \ 854 ((flags & PCI_EXP_FLAGS_VERS) > 1 || \
855 (type == PCI_EXP_TYPE_ROOT_PORT || \ 855 (type == PCI_EXP_TYPE_ROOT_PORT || \
856 type == PCI_EXP_TYPE_RC_EC)) 856 type == PCI_EXP_TYPE_RC_EC))
857#define pcie_cap_has_devctl2(type, flags) \
858 ((flags & PCI_EXP_FLAGS_VERS) > 1)
859#define pcie_cap_has_lnkctl2(type, flags) \
860 ((flags & PCI_EXP_FLAGS_VERS) > 1)
861#define pcie_cap_has_sltctl2(type, flags) \
862 ((flags & PCI_EXP_FLAGS_VERS) > 1)
863 857
864static struct pci_cap_saved_state *pci_find_saved_cap( 858static struct pci_cap_saved_state *pci_find_saved_cap(
865 struct pci_dev *pci_dev, char cap) 859 struct pci_dev *pci_dev, char cap)
@@ -902,13 +896,14 @@ static int pci_save_pcie_state(struct pci_dev *dev)
902 pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]); 896 pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]);
903 if (pcie_cap_has_rtctl(dev->pcie_type, flags)) 897 if (pcie_cap_has_rtctl(dev->pcie_type, flags))
904 pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]); 898 pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]);
905 if (pcie_cap_has_devctl2(dev->pcie_type, flags))
906 pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &cap[i++]);
907 if (pcie_cap_has_lnkctl2(dev->pcie_type, flags))
908 pci_read_config_word(dev, pos + PCI_EXP_LNKCTL2, &cap[i++]);
909 if (pcie_cap_has_sltctl2(dev->pcie_type, flags))
910 pci_read_config_word(dev, pos + PCI_EXP_SLTCTL2, &cap[i++]);
911 899
900 pos = pci_pcie_cap2(dev);
901 if (!pos)
902 return 0;
903
904 pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &cap[i++]);
905 pci_read_config_word(dev, pos + PCI_EXP_LNKCTL2, &cap[i++]);
906 pci_read_config_word(dev, pos + PCI_EXP_SLTCTL2, &cap[i++]);
912 return 0; 907 return 0;
913} 908}
914 909
@@ -935,12 +930,14 @@ static void pci_restore_pcie_state(struct pci_dev *dev)
935 pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]); 930 pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]);
936 if (pcie_cap_has_rtctl(dev->pcie_type, flags)) 931 if (pcie_cap_has_rtctl(dev->pcie_type, flags))
937 pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]); 932 pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]);
938 if (pcie_cap_has_devctl2(dev->pcie_type, flags)) 933
939 pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, cap[i++]); 934 pos = pci_pcie_cap2(dev);
940 if (pcie_cap_has_lnkctl2(dev->pcie_type, flags)) 935 if (!pos)
941 pci_write_config_word(dev, pos + PCI_EXP_LNKCTL2, cap[i++]); 936 return;
942 if (pcie_cap_has_sltctl2(dev->pcie_type, flags)) 937
943 pci_write_config_word(dev, pos + PCI_EXP_SLTCTL2, cap[i++]); 938 pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, cap[i++]);
939 pci_write_config_word(dev, pos + PCI_EXP_LNKCTL2, cap[i++]);
940 pci_write_config_word(dev, pos + PCI_EXP_SLTCTL2, cap[i++]);
944} 941}
945 942
946 943