forked from Minki/linux
PCIe ASPM: use pci_pcie_cap()
Use pci_pcie_cap() instead of pci_find_capability() to get PCIe capability offset in PCIe ASPM driver. This avoids unnecessary search in PCI configuration space. Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
parent
dba90dfe48
commit
db9538a749
@ -122,7 +122,7 @@ static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable)
|
|||||||
struct pci_bus *linkbus = link->pdev->subordinate;
|
struct pci_bus *linkbus = link->pdev->subordinate;
|
||||||
|
|
||||||
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
||||||
pos = pci_find_capability(child, PCI_CAP_ID_EXP);
|
pos = pci_pcie_cap(child);
|
||||||
if (!pos)
|
if (!pos)
|
||||||
return;
|
return;
|
||||||
pci_read_config_word(child, pos + PCI_EXP_LNKCTL, ®16);
|
pci_read_config_word(child, pos + PCI_EXP_LNKCTL, ®16);
|
||||||
@ -156,7 +156,7 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist)
|
|||||||
|
|
||||||
/* All functions should have the same cap and state, take the worst */
|
/* All functions should have the same cap and state, take the worst */
|
||||||
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
||||||
pos = pci_find_capability(child, PCI_CAP_ID_EXP);
|
pos = pci_pcie_cap(child);
|
||||||
if (!pos)
|
if (!pos)
|
||||||
return;
|
return;
|
||||||
pci_read_config_dword(child, pos + PCI_EXP_LNKCAP, ®32);
|
pci_read_config_dword(child, pos + PCI_EXP_LNKCAP, ®32);
|
||||||
@ -194,20 +194,20 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link)
|
|||||||
BUG_ON(!child->is_pcie);
|
BUG_ON(!child->is_pcie);
|
||||||
|
|
||||||
/* Check downstream component if bit Slot Clock Configuration is 1 */
|
/* Check downstream component if bit Slot Clock Configuration is 1 */
|
||||||
cpos = pci_find_capability(child, PCI_CAP_ID_EXP);
|
cpos = pci_pcie_cap(child);
|
||||||
pci_read_config_word(child, cpos + PCI_EXP_LNKSTA, ®16);
|
pci_read_config_word(child, cpos + PCI_EXP_LNKSTA, ®16);
|
||||||
if (!(reg16 & PCI_EXP_LNKSTA_SLC))
|
if (!(reg16 & PCI_EXP_LNKSTA_SLC))
|
||||||
same_clock = 0;
|
same_clock = 0;
|
||||||
|
|
||||||
/* Check upstream component if bit Slot Clock Configuration is 1 */
|
/* Check upstream component if bit Slot Clock Configuration is 1 */
|
||||||
ppos = pci_find_capability(parent, PCI_CAP_ID_EXP);
|
ppos = pci_pcie_cap(parent);
|
||||||
pci_read_config_word(parent, ppos + PCI_EXP_LNKSTA, ®16);
|
pci_read_config_word(parent, ppos + PCI_EXP_LNKSTA, ®16);
|
||||||
if (!(reg16 & PCI_EXP_LNKSTA_SLC))
|
if (!(reg16 & PCI_EXP_LNKSTA_SLC))
|
||||||
same_clock = 0;
|
same_clock = 0;
|
||||||
|
|
||||||
/* Configure downstream component, all functions */
|
/* Configure downstream component, all functions */
|
||||||
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
||||||
cpos = pci_find_capability(child, PCI_CAP_ID_EXP);
|
cpos = pci_pcie_cap(child);
|
||||||
pci_read_config_word(child, cpos + PCI_EXP_LNKCTL, ®16);
|
pci_read_config_word(child, cpos + PCI_EXP_LNKCTL, ®16);
|
||||||
child_reg[PCI_FUNC(child->devfn)] = reg16;
|
child_reg[PCI_FUNC(child->devfn)] = reg16;
|
||||||
if (same_clock)
|
if (same_clock)
|
||||||
@ -247,7 +247,7 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link)
|
|||||||
dev_printk(KERN_ERR, &parent->dev,
|
dev_printk(KERN_ERR, &parent->dev,
|
||||||
"ASPM: Could not configure common clock\n");
|
"ASPM: Could not configure common clock\n");
|
||||||
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
||||||
cpos = pci_find_capability(child, PCI_CAP_ID_EXP);
|
cpos = pci_pcie_cap(child);
|
||||||
pci_write_config_word(child, cpos + PCI_EXP_LNKCTL,
|
pci_write_config_word(child, cpos + PCI_EXP_LNKCTL,
|
||||||
child_reg[PCI_FUNC(child->devfn)]);
|
child_reg[PCI_FUNC(child->devfn)]);
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ static void pcie_get_aspm_reg(struct pci_dev *pdev,
|
|||||||
u16 reg16;
|
u16 reg16;
|
||||||
u32 reg32;
|
u32 reg32;
|
||||||
|
|
||||||
pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
|
pos = pci_pcie_cap(pdev);
|
||||||
pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, ®32);
|
pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, ®32);
|
||||||
info->support = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10;
|
info->support = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10;
|
||||||
info->latency_encoding_l0s = (reg32 & PCI_EXP_LNKCAP_L0SEL) >> 12;
|
info->latency_encoding_l0s = (reg32 & PCI_EXP_LNKCAP_L0SEL) >> 12;
|
||||||
@ -420,7 +420,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
|
|||||||
child->pcie_type != PCI_EXP_TYPE_LEG_END)
|
child->pcie_type != PCI_EXP_TYPE_LEG_END)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pos = pci_find_capability(child, PCI_CAP_ID_EXP);
|
pos = pci_pcie_cap(child);
|
||||||
pci_read_config_dword(child, pos + PCI_EXP_DEVCAP, ®32);
|
pci_read_config_dword(child, pos + PCI_EXP_DEVCAP, ®32);
|
||||||
/* Calculate endpoint L0s acceptable latency */
|
/* Calculate endpoint L0s acceptable latency */
|
||||||
encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6;
|
encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6;
|
||||||
@ -436,7 +436,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
|
|||||||
static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val)
|
static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val)
|
||||||
{
|
{
|
||||||
u16 reg16;
|
u16 reg16;
|
||||||
int pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
|
int pos = pci_pcie_cap(pdev);
|
||||||
|
|
||||||
pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, ®16);
|
pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, ®16);
|
||||||
reg16 &= ~0x3;
|
reg16 &= ~0x3;
|
||||||
@ -503,7 +503,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
|
|||||||
* very strange. Disable ASPM for the whole slot
|
* very strange. Disable ASPM for the whole slot
|
||||||
*/
|
*/
|
||||||
list_for_each_entry(child, &pdev->subordinate->devices, bus_list) {
|
list_for_each_entry(child, &pdev->subordinate->devices, bus_list) {
|
||||||
pos = pci_find_capability(child, PCI_CAP_ID_EXP);
|
pos = pci_pcie_cap(child);
|
||||||
if (!pos)
|
if (!pos)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user