svn commit: r290808 - stable/9/sys/dev/pci

John Baldwin jhb at FreeBSD.org
Sat Nov 14 00:04:43 UTC 2015


Author: jhb
Date: Sat Nov 14 00:04:42 2015
New Revision: 290808
URL: https://svnweb.freebsd.org/changeset/base/290808

Log:
  MFC 232472 (partial):
  Cache the starting location of the PCI-express capability for PCI-express
  devices in PCI device ivars.

Modified:
  stable/9/sys/dev/pci/pci.c
  stable/9/sys/dev/pci/pcivar.h

Modified: stable/9/sys/dev/pci/pci.c
==============================================================================
--- stable/9/sys/dev/pci/pci.c	Fri Nov 13 23:47:41 2015	(r290807)
+++ stable/9/sys/dev/pci/pci.c	Sat Nov 14 00:04:42 2015	(r290808)
@@ -798,6 +798,9 @@ pci_read_cap(device_t pcib, pcicfgregs *
 			 * at least one PCI-express device.
 			 */
 			pcie_chipset = 1;
+			cfg->pcie.pcie_location = ptr;
+			val = REG(ptr + PCIR_EXPRESS_FLAGS, 2);
+			cfg->pcie.pcie_type = val & PCIM_EXP_FLAGS_TYPE;
 			break;
 		default:
 			break;
@@ -1776,10 +1779,12 @@ pci_ht_map_msi(device_t dev, uint64_t ad
 int
 pci_get_max_read_req(device_t dev)
 {
+	struct pci_devinfo *dinfo = device_get_ivars(dev);
 	int cap;
 	uint16_t val;
 
-	if (pci_find_cap(dev, PCIY_EXPRESS, &cap) != 0)
+	cap = dinfo->cfg.pcie.pcie_location;
+	if (cap == 0)
 		return (0);
 	val = pci_read_config(dev, cap + PCIER_DEVICE_CTL, 2);
 	val &= PCIEM_CTL_MAX_READ_REQUEST;
@@ -1790,10 +1795,12 @@ pci_get_max_read_req(device_t dev)
 int
 pci_set_max_read_req(device_t dev, int size)
 {
+	struct pci_devinfo *dinfo = device_get_ivars(dev);
 	int cap;
 	uint16_t val;
 
-	if (pci_find_cap(dev, PCIY_EXPRESS, &cap) != 0)
+	cap = dinfo->cfg.pcie.pcie_location;
+	if (cap == 0)
 		return (0);
 	if (size < 128)
 		size = 128;

Modified: stable/9/sys/dev/pci/pcivar.h
==============================================================================
--- stable/9/sys/dev/pci/pcivar.h	Fri Nov 13 23:47:41 2015	(r290807)
+++ stable/9/sys/dev/pci/pcivar.h	Sat Nov 14 00:04:42 2015	(r290808)
@@ -124,6 +124,12 @@ struct pcicfg_ht {
     uint64_t	ht_msiaddr;	/* MSI mapping base address */
 };
 
+/* Interesting values for PCI-express */
+struct pcicfg_pcie {
+    uint8_t	pcie_location;	/* Offset of PCI-e capability registers. */
+    uint8_t	pcie_type;	/* Device type. */
+};
+
 /* config header information common to all header types */
 typedef struct pcicfg {
     struct device *dev;		/* device which owns this */
@@ -165,6 +171,7 @@ typedef struct pcicfg {
     struct pcicfg_msi msi;	/* PCI MSI */
     struct pcicfg_msix msix;	/* PCI MSI-X */
     struct pcicfg_ht ht;	/* HyperTransport */
+    struct pcicfg_pcie pcie;	/* PCI Express */
 } pcicfgregs;
 
 /* additional type 1 device config header information (PCI to PCI bridge) */


More information about the svn-src-stable-9 mailing list