Currently the ACS capability is being looked up at a number of places. Read and store it once at enumeration so that it can be used by all later. No functional change intended.
Unified · Split
| @@ -253,7 +253,7 @@ static int pci_bridge_has_acs_redir(struct pci_dev *pdev) · 252 unmodified lines | ||
| 253 | 253 | int pos; |
| 254 | 254 | u16 ctrl; |
| 255 | 255 | |
| 256 | − pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS); | |
| 256 | + pos = pdev->acs_cap; | |
| 257 | 257 | if (!pos) |
| 258 | 258 | return 0; |
| 259 | 259 | |
| @@ -831,7 +831,7 @@ static void pci_disable_acs_redir(struct pci_dev *dev) · 830 unmodified lines | ||
| 831 | 831 | if (!pci_dev_specific_disable_acs_redir(dev)) |
| 832 | 832 | return; |
| 833 | 833 | |
| 834 | − pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); | |
| 834 | + pos = dev->acs_cap; | |
| 835 | 835 | if (!pos) { |
| 836 | 836 | pci_warn(dev, "cannot disable ACS redirect for this hardware as it does not have ACS capabilities\n"); |
| 837 | 837 | return; |
| @@ -857,7 +857,7 @@ static void pci_std_enable_acs(struct pci_dev *dev) · 19 unmodified lines | ||
| 857 | 857 | u16 cap; |
| 858 | 858 | u16 ctrl; |
| 859 | 859 | |
| 860 | − pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); | |
| 860 | + pos = dev->acs_cap; | |
| 861 | 861 | if (!pos) |
| 862 | 862 | return; |
| 863 | 863 | |
| @@ -883,7 +883,7 @@ static void pci_std_enable_acs(struct pci_dev *dev) · 19 unmodified lines | ||
| 883 | 883 | * pci_enable_acs - enable ACS if hardware support it |
| 884 | 884 | * @dev: the PCI device |
| 885 | 885 | */ |
| 886 | −void pci_enable_acs(struct pci_dev *dev) | |
| 886 | +static void pci_enable_acs(struct pci_dev *dev) | |
| 887 | 887 | { |
| 888 | 888 | if (!pci_acs_enable) |
| 889 | 889 | goto disable_acs_redir; |
| @@ -3362,7 +3362,7 @@ static bool pci_acs_flags_enabled(struct pci_dev *pdev, u16 acs_flags) · 2472 unmodified lines | ||
| 3362 | 3362 | int pos; |
| 3363 | 3363 | u16 cap, ctrl; |
| 3364 | 3364 | |
| 3365 | − pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS); | |
| 3365 | + pos = pdev->acs_cap; | |
| 3366 | 3366 | if (!pos) |
| 3367 | 3367 | return false; |
| 3368 | 3368 | |
| @@ -3487,6 +3487,18 @@ bool pci_acs_path_enabled(struct pci_dev *start, · 118 unmodified lines | ||
| 3487 | 3487 | return true; |
| 3488 | 3488 | } |
| 3489 | 3489 | |
| 3490 | +/** | |
| 3491 | + * pci_acs_init - Initialize ACS if hardware supports it | |
| 3492 | + * @dev: the PCI device | |
| 3493 | + */ | |
| 3494 | +void pci_acs_init(struct pci_dev *dev) | |
| 3495 | +{ | |
| 3496 | + dev->acs_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); | |
| 3497 | + | |
| 3498 | + if (dev->acs_cap) | |
| 3499 | + pci_enable_acs(dev); | |
| 3500 | +} | |
| 3501 | + | |
| 3490 | 3502 | /** |
| 3491 | 3503 | * pci_rebar_find_pos - find position of resize ctrl reg for BAR |
| 3492 | 3504 | * @pdev: PCI device |
| @@ -532,7 +532,7 @@ static inline resource_size_t pci_resource_alignment(struct pci_dev *dev, · 531 unmodified lines | ||
| 532 | 532 | return resource_alignment(res); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | −void pci_enable_acs(struct pci_dev *dev); | |
| 535 | +void pci_acs_init(struct pci_dev *dev); | |
| 536 | 536 | #ifdef CONFIG_PCI_QUIRKS |
| 537 | 537 | int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags); |
| 538 | 538 | int pci_dev_specific_enable_acs(struct pci_dev *dev); |
| @@ -2390,7 +2390,7 @@ static void pci_init_capabilities(struct pci_dev *dev) · 2389 unmodified lines | ||
| 2390 | 2390 | pci_ats_init(dev); /* Address Translation Services */ |
| 2391 | 2391 | pci_pri_init(dev); /* Page Request Interface */ |
| 2392 | 2392 | pci_pasid_init(dev); /* Process Address Space ID */ |
| 2393 | − pci_enable_acs(dev); /* Enable ACS P2P upstream forwarding */ | |
| 2393 | + pci_acs_init(dev); /* Access Control Services */ | |
| 2394 | 2394 | pci_ptm_init(dev); /* Precision Time Measurement */ |
| 2395 | 2395 | pci_aer_init(dev); /* Advanced Error Reporting */ |
| 2396 | 2396 | pci_dpc_init(dev); /* Downstream Port Containment */ |
| @@ -4653,7 +4653,7 @@ static int pci_quirk_intel_spt_pch_acs(struct pci_dev *dev, u16 acs_flags) · 4652 unmodified lines | ||
| 4653 | 4653 | if (!pci_quirk_intel_spt_pch_acs_match(dev)) |
| 4654 | 4654 | return -ENOTTY; |
| 4655 | 4655 | |
| 4656 | − pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); | |
| 4656 | + pos = dev->acs_cap; | |
| 4657 | 4657 | if (!pos) |
| 4658 | 4658 | return -ENOTTY; |
| 4659 | 4659 | |
| @@ -4961,7 +4961,7 @@ static int pci_quirk_enable_intel_spt_pch_acs(struct pci_dev *dev) · 301 unmodified lines | ||
| 4961 | 4961 | if (!pci_quirk_intel_spt_pch_acs_match(dev)) |
| 4962 | 4962 | return -ENOTTY; |
| 4963 | 4963 | |
| 4964 | − pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); | |
| 4964 | + pos = dev->acs_cap; | |
| 4965 | 4965 | if (!pos) |
| 4966 | 4966 | return -ENOTTY; |
| 4967 | 4967 | |
| @@ -4988,7 +4988,7 @@ static int pci_quirk_disable_intel_spt_pch_acs_redir(struct pci_dev *dev) · 20 unmodified lines | ||
| 4988 | 4988 | if (!pci_quirk_intel_spt_pch_acs_match(dev)) |
| 4989 | 4989 | return -ENOTTY; |
| 4990 | 4990 | |
| 4991 | − pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); | |
| 4991 | + pos = dev->acs_cap; | |
| 4992 | 4992 | if (!pos) |
| 4993 | 4993 | return -ENOTTY; |
| 4994 | 4994 | |
| @@ -5355,7 +5355,7 @@ int pci_idt_bus_quirk(struct pci_bus *bus, int devfn, u32 *l, int timeout) · 360 unmodified lines | ||
| 5355 | 5355 | bool found; |
| 5356 | 5356 | struct pci_dev *bridge = bus->self; |
| 5357 | 5357 | |
| 5358 | − pos = pci_find_ext_capability(bridge, PCI_EXT_CAP_ID_ACS); | |
| 5358 | + pos = bridge->acs_cap; | |
| 5359 | 5359 | |
| 5360 | 5360 | /* Disable ACS SV before initial config reads */ |
| 5361 | 5361 | if (pos) { |
| @@ -486,6 +486,7 @@ struct pci_dev { · 485 unmodified lines | ||
| 486 | 486 | #ifdef CONFIG_PCI_P2PDMA |
| 487 | 487 | struct pci_p2pdma *p2pdma; |
| 488 | 488 | #endif |
| 489 | + u16 acs_cap; /* ACS Capability offset */ | |
| 489 | 490 | phys_addr_t rom; /* Physical address if not from BAR */ |
| 490 | 491 | size_t romlen; /* Length if not from BAR */ |
| 491 | 492 | char *driver_override; /* Driver name to force a match */ |