Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci IF PCIe's Alternative Routing-ID Interpretation ...



details:   https://anonhg.NetBSD.org/src/rev/7722bee166d6
branches:  trunk
changeset: 352497:7722bee166d6
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Apr 05 04:04:54 2017 +0000

description:
IF PCIe's Alternative Routing-ID Interpretation (ARI) is enabled in a bridge,
all area under the bus should be checked in pci_enumerate_bus() to enumerate
all existing devices.

 The similar code also be required for "pcictl pciN list". (not yet)

diffstat:

 sys/dev/pci/pci.c |  27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diffs (62 lines):

diff -r 32a4eb8b73b9 -r 7722bee166d6 sys/dev/pci/pci.c
--- a/sys/dev/pci/pci.c Wed Apr 05 03:51:36 2017 +0000
+++ b/sys/dev/pci/pci.c Wed Apr 05 04:04:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci.c,v 1.151 2016/01/23 17:09:51 macallan Exp $       */
+/*     $NetBSD: pci.c,v 1.152 2017/04/05 04:04:54 msaitoh Exp $        */
 
 /*
  * Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.151 2016/01/23 17:09:51 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.152 2017/04/05 04:04:54 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -51,6 +51,7 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcidevs.h>
+#include <dev/pci/ppbvar.h>
 
 #include <net/if.h>
 
@@ -692,6 +693,26 @@
        uint8_t devs[32];
        int i, n;
 
+       device_t bridgedev;
+       bool arien = false;
+
+       /* Check PCIe ARI */
+       bridgedev = device_parent(sc->sc_dev);
+       if (device_is_a(bridgedev, "ppb")) {
+               struct ppb_softc *ppbsc = device_private(bridgedev);
+               pci_chipset_tag_t ppbpc = ppbsc->sc_pc;
+               pcitag_t ppbtag = ppbsc->sc_tag;
+               pcireg_t pciecap, reg;
+
+               if (pci_get_capability(ppbpc, ppbtag, PCI_CAP_PCIEXPRESS,
+                   &pciecap, NULL) != 0) {
+                       reg = pci_conf_read(ppbpc, ppbtag, pciecap
+                           + PCIE_DCSR2);
+                       if ((reg & PCIE_DCSR2_ARI_FWD) != 0)
+                               arien = true;
+               }
+       }
+
        n = pci_bus_devorder(sc->sc_pc, sc->sc_bus, devs, __arraycount(devs));
        for (i = 0; i < n; i++) {
                device = devs[i];
@@ -723,6 +744,8 @@
                else if (qd != NULL &&
                      (qd->quirks & PCI_QUIRK_MONOFUNCTION) != 0)
                        nfunctions = 1;
+               else if (arien)
+                       nfunctions = 8; /* Scan all if ARI is enabled */
                else
                        nfunctions = PCI_HDRTYPE_MULTIFN(bhlcr) ? 8 : 1;
 



Home | Main Index | Thread Index | Old Index