History

PCI: Cache ACS capability offset in device

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.

Rajat Jain committed 6 years ago

Commit 52fbf5b1 parent cbe42036 files · +24 −11Browse files

Unified · Split

6 files
  1. drivers/pci/p2pdma.c +1 −1
  2. drivers/pci/pci.c +16 −4
  3. drivers/pci/pci.h +1 −1
  4. drivers/pci/probe.c +1 −1
  5. drivers/pci/quirks.c +4 −4
  6. include/linux/pci.h +1 −0
drivers/pci/p2pdma.c+1−1
@@ -253,7 +253,7 @@ static int pci_bridge_has_acs_redir(struct pci_dev *pdev) · 252 unmodified lines
253253 int pos;
254254 u16 ctrl;
255255
256− pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);
256+ pos = pdev->acs_cap;
257257 if (!pos)
258258 return 0;
259259
drivers/pci/pci.c+16−4
@@ -831,7 +831,7 @@ static void pci_disable_acs_redir(struct pci_dev *dev) · 830 unmodified lines
831831 if (!pci_dev_specific_disable_acs_redir(dev))
832832 return;
833833
834− pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);
834+ pos = dev->acs_cap;
835835 if (!pos) {
836836 pci_warn(dev, "cannot disable ACS redirect for this hardware as it does not have ACS capabilities\n");
837837 return;
@@ -857,7 +857,7 @@ static void pci_std_enable_acs(struct pci_dev *dev) · 19 unmodified lines
857857 u16 cap;
858858 u16 ctrl;
859859
860− pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);
860+ pos = dev->acs_cap;
861861 if (!pos)
862862 return;
863863
@@ -883,7 +883,7 @@ static void pci_std_enable_acs(struct pci_dev *dev) · 19 unmodified lines
883883 * pci_enable_acs - enable ACS if hardware support it
884884 * @dev: the PCI device
885885 */
886−void pci_enable_acs(struct pci_dev *dev)
886+static void pci_enable_acs(struct pci_dev *dev)
887887 {
888888 if (!pci_acs_enable)
889889 goto disable_acs_redir;
@@ -3362,7 +3362,7 @@ static bool pci_acs_flags_enabled(struct pci_dev *pdev, u16 acs_flags) · 2472 unmodified lines
33623362 int pos;
33633363 u16 cap, ctrl;
33643364
3365− pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);
3365+ pos = pdev->acs_cap;
33663366 if (!pos)
33673367 return false;
33683368
@@ -3487,6 +3487,18 @@ bool pci_acs_path_enabled(struct pci_dev *start, · 118 unmodified lines
34873487 return true;
34883488 }
34893489
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+
34903502 /**
34913503 * pci_rebar_find_pos - find position of resize ctrl reg for BAR
34923504 * @pdev: PCI device
drivers/pci/pci.h+1−1
@@ -532,7 +532,7 @@ static inline resource_size_t pci_resource_alignment(struct pci_dev *dev, · 531 unmodified lines
532532 return resource_alignment(res);
533533 }
534534
535−void pci_enable_acs(struct pci_dev *dev);
535+void pci_acs_init(struct pci_dev *dev);
536536 #ifdef CONFIG_PCI_QUIRKS
537537 int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags);
538538 int pci_dev_specific_enable_acs(struct pci_dev *dev);
drivers/pci/probe.c+1−1
@@ -2390,7 +2390,7 @@ static void pci_init_capabilities(struct pci_dev *dev) · 2389 unmodified lines
23902390 pci_ats_init(dev); /* Address Translation Services */
23912391 pci_pri_init(dev); /* Page Request Interface */
23922392 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 */
23942394 pci_ptm_init(dev); /* Precision Time Measurement */
23952395 pci_aer_init(dev); /* Advanced Error Reporting */
23962396 pci_dpc_init(dev); /* Downstream Port Containment */
drivers/pci/quirks.c+4−4
@@ -4653,7 +4653,7 @@ static int pci_quirk_intel_spt_pch_acs(struct pci_dev *dev, u16 acs_flags) · 4652 unmodified lines
46534653 if (!pci_quirk_intel_spt_pch_acs_match(dev))
46544654 return -ENOTTY;
46554655
4656− pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);
4656+ pos = dev->acs_cap;
46574657 if (!pos)
46584658 return -ENOTTY;
46594659
@@ -4961,7 +4961,7 @@ static int pci_quirk_enable_intel_spt_pch_acs(struct pci_dev *dev) · 301 unmodified lines
49614961 if (!pci_quirk_intel_spt_pch_acs_match(dev))
49624962 return -ENOTTY;
49634963
4964− pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);
4964+ pos = dev->acs_cap;
49654965 if (!pos)
49664966 return -ENOTTY;
49674967
@@ -4988,7 +4988,7 @@ static int pci_quirk_disable_intel_spt_pch_acs_redir(struct pci_dev *dev) · 20 unmodified lines
49884988 if (!pci_quirk_intel_spt_pch_acs_match(dev))
49894989 return -ENOTTY;
49904990
4991− pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);
4991+ pos = dev->acs_cap;
49924992 if (!pos)
49934993 return -ENOTTY;
49944994
@@ -5355,7 +5355,7 @@ int pci_idt_bus_quirk(struct pci_bus *bus, int devfn, u32 *l, int timeout) · 360 unmodified lines
53555355 bool found;
53565356 struct pci_dev *bridge = bus->self;
53575357
5358− pos = pci_find_ext_capability(bridge, PCI_EXT_CAP_ID_ACS);
5358+ pos = bridge->acs_cap;
53595359
53605360 /* Disable ACS SV before initial config reads */
53615361 if (pos) {
include/linux/pci.h+1−0
@@ -486,6 +486,7 @@ struct pci_dev { · 485 unmodified lines
486486 #ifdef CONFIG_PCI_P2PDMA
487487 struct pci_p2pdma *p2pdma;
488488 #endif
489+ u16 acs_cap; /* ACS Capability offset */
489490 phys_addr_t rom; /* Physical address if not from BAR */
490491 size_t romlen; /* Length if not from BAR */
491492 char *driver_override; /* Driver name to force a match */