Source-Changes-HG archive

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

[src/trunk]: src PCI Extended Configuration stuff written by nonaka@:



details:   https://anonhg.NetBSD.org/src/rev/b64eacb864c2
branches:  trunk
changeset: 340791:b64eacb864c2
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Oct 02 05:22:49 2015 +0000

description:
PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
  if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
  Currently the following extended capabilities are decoded:
   - Advanced Error Reporting
   - Virtual Channel
   - Device Serial Number
   - Power Budgeting
   - Root Complex Link Declaration
   - Root Complex Event Collector Association
   - Access Control Services
   - Alternative Routing-ID Interpretation
   - Address Translation Services
   - Single Root IO Virtualization
   - Page Request
   - TPH Requester
   - Latency Tolerance Reporting
   - Secondary PCI Express
   - Process Address Space ID
   - LN Requester
   - L1 PM Substates
  The following extended capabilities are not decoded yet:
   - Root Complex Internal Link Control
   - Multi-Function Virtual Channel
   - RCRB Header
   - Vendor Unique
   - Configuration Access Correction
   - Multiple Root IO Virtualization
   - Multicast
   - Resizable BAR
   - Dynamic Power Allocation
   - Protocol Multiplexing
   - Downstream Port Containment
   - Precision Time Management
   - M-PCIe
   - Function Reading Status Queueing
   - Readiness Time Reporting
   - Designated Vendor-Specific

diffstat:

 distrib/sets/lists/comp/mi                |     5 +-
 share/man/man9/Makefile                   |     3 +-
 share/man/man9/pci.9                      |    32 +-
 sys/arch/algor/pci/vtpbc.c                |     7 +-
 sys/arch/alpha/pci/apecs_pci.c            |    10 +-
 sys/arch/alpha/pci/cia_pci.c              |    10 +-
 sys/arch/alpha/pci/dwlpx_pci.c            |    10 +-
 sys/arch/alpha/pci/irongate_pci.c         |    13 +-
 sys/arch/alpha/pci/lca_pci.c              |    10 +-
 sys/arch/alpha/pci/mcpcia_pci.c           |    10 +-
 sys/arch/alpha/pci/tsp_pci.c              |    10 +-
 sys/arch/alpha/pci/ttwoga_pci.c           |    10 +-
 sys/arch/amiga/pci/cv3dpb.c               |     8 +-
 sys/arch/amiga/pci/em4k.c                 |     8 +-
 sys/arch/amiga/pci/empb.c                 |     8 +-
 sys/arch/amiga/pci/mppb.c                 |     8 +-
 sys/arch/amiga/pci/p5pb.c                 |     8 +-
 sys/arch/arc/pci/necpb.c                  |    10 +-
 sys/arch/arm/broadcom/bcm53xx_pax.c       |     8 +-
 sys/arch/arm/footbridge/footbridge_pci.c  |    10 +-
 sys/arch/arm/gemini/gemini_pci.c          |     8 +-
 sys/arch/arm/ixp12x0/ixp12x0_pci.c        |     7 +-
 sys/arch/arm/marvell/pci_machdep.c        |    13 +-
 sys/arch/arm/nvidia/tegra_pcie.c          |    10 +-
 sys/arch/arm/s3c2xx0/s3c2800_pci.c        |     8 +-
 sys/arch/arm/xscale/becc_pci.c            |     7 +-
 sys/arch/arm/xscale/i80312_pci.c          |     7 +-
 sys/arch/arm/xscale/i80321_pci.c          |     7 +-
 sys/arch/arm/xscale/ixp425_pci.c          |    10 +-
 sys/arch/atari/pci/pci_hades.c            |    11 +-
 sys/arch/atari/pci/pci_milan.c            |    11 +-
 sys/arch/cobalt/pci/pci_machdep.c         |    10 +-
 sys/arch/dreamcast/dev/g2/gapspci_pci.c   |    10 +-
 sys/arch/evbarm/ifpga/ifpga_pci.c         |    10 +-
 sys/arch/evbmips/loongson/dev/glx.c       |    10 +-
 sys/arch/evbmips/malta/dev/gt.c           |    10 +-
 sys/arch/hpcmips/dev/plum.c               |    10 +-
 sys/arch/hpcmips/vr/vrc4172pci.c          |    10 +-
 sys/arch/hpcmips/vr/vrpciu.c              |    11 +-
 sys/arch/hppa/dev/dino.c                  |    10 +-
 sys/arch/hppa/dev/elroy.c                 |    10 +-
 sys/arch/ia64/pci/pci_machdep.c           |    10 +-
 sys/arch/macppc/pci/bandit.c              |    10 +-
 sys/arch/macppc/pci/grackle.c             |    10 +-
 sys/arch/macppc/pci/u3.c                  |     8 +-
 sys/arch/macppc/pci/uninorth.c            |    16 +-
 sys/arch/mips/adm5120/dev/admpci.c        |     8 +-
 sys/arch/mips/alchemy/dev/aupci.c         |     7 +-
 sys/arch/mips/atheros/dev/arpci.c         |    10 +-
 sys/arch/mips/bonito/bonito_pci.c         |     7 +-
 sys/arch/mips/rmi/rmixl_pcie.c            |     8 +-
 sys/arch/mips/rmi/rmixl_pcix.c            |     7 +-
 sys/arch/mips/sibyte/pci/sbbrz_pci.c      |    10 +-
 sys/arch/powerpc/booke/pci/pq3pci.c       |    16 +-
 sys/arch/powerpc/ibm4xx/pci/pci_machdep.c |    10 +-
 sys/arch/powerpc/pci/pciconf_indirect.c   |    10 +-
 sys/arch/powerpc/pci/pciconf_ofmethod.c   |    10 +-
 sys/arch/prep/pci/prep_pciconf_direct.c   |    10 +-
 sys/arch/sandpoint/pci/pci_machdep.c      |    10 +-
 sys/arch/sgimips/gio/pci_gio.c            |    10 +-
 sys/arch/sgimips/mace/pci_mace.c          |    10 +-
 sys/arch/sh3/dev/shpcic.c                 |    10 +-
 sys/arch/sparc/sparc/pci_machdep.c        |    14 +-
 sys/arch/sparc64/dev/psycho.c             |    11 +-
 sys/arch/sparc64/dev/pyro.c               |     9 +-
 sys/arch/sparc64/dev/schizo.c             |     9 +-
 sys/arch/x86/acpi/acpi_machdep.c          |    96 ++-
 sys/arch/x86/pci/pci_machdep.c            |    47 +-
 sys/dev/acpi/acpi.c                       |    10 +-
 sys/dev/acpi/acpi_mcfg.c                  |   697 ++++++++++++++++
 sys/dev/acpi/acpi_mcfg.h                  |    58 +
 sys/dev/acpi/files.acpi                   |     3 +-
 sys/dev/marvell/gtpci.c                   |    10 +-
 sys/dev/marvell/mvpex.c                   |    10 +-
 sys/dev/pci/pci.c                         |    44 +-
 sys/dev/pci/pci_subr.c                    |  1225 ++++++++++++++++++++++++++++-
 sys/dev/pci/pcireg.h                      |   500 +++++++++++-
 sys/dev/pci/pcivar.h                      |    14 +-
 78 files changed, 3190 insertions(+), 172 deletions(-)

diffs (truncated from 5441 to 300 lines):

diff -r d07f589d822a -r b64eacb864c2 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Fri Oct 02 03:08:26 2015 +0000
+++ b/distrib/sets/lists/comp/mi        Fri Oct 02 05:22:49 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.1995 2015/09/26 01:46:14 christos Exp $
+#      $NetBSD: mi,v 1.1996 2015/10/02 05:22:49 msaitoh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -10213,6 +10213,7 @@
 ./usr/share/man/cat9/pci_find_device.0         comp-sys-catman         .cat
 ./usr/share/man/cat9/pci_findvendor.0          comp-sys-catman         .cat
 ./usr/share/man/cat9/pci_get_capability.0      comp-sys-catman         .cat
+./usr/share/man/cat9/pci_get_ext_capability.0  comp-sys-catman         .cat
 ./usr/share/man/cat9/pci_get_ht_capability.0   comp-sys-catman         .cat
 ./usr/share/man/cat9/pci_get_powerstate.0      comp-sys-catman         .cat
 ./usr/share/man/cat9/pci_intr.0                        comp-sys-catman         .cat
@@ -17030,6 +17031,7 @@
 ./usr/share/man/html9/pci_find_device.html     comp-sys-htmlman        html
 ./usr/share/man/html9/pci_findvendor.html      comp-sys-htmlman        html
 ./usr/share/man/html9/pci_get_capability.html  comp-sys-htmlman        html
+./usr/share/man/html9/pci_get_ext_capability.html      comp-sys-htmlman        html
 ./usr/share/man/html9/pci_get_ht_capability.html       comp-sys-htmlman        html
 ./usr/share/man/html9/pci_get_powerstate.html  comp-sys-htmlman        html
 ./usr/share/man/html9/pci_intr.html            comp-sys-htmlman        html
@@ -24009,6 +24011,7 @@
 ./usr/share/man/man9/pci_find_device.9         comp-sys-man            .man
 ./usr/share/man/man9/pci_findvendor.9          comp-sys-man            .man
 ./usr/share/man/man9/pci_get_capability.9      comp-sys-man            .man
+./usr/share/man/man9/pci_get_ext_capability.9  comp-sys-man            .man
 ./usr/share/man/man9/pci_get_ht_capability.9   comp-sys-man            .man
 ./usr/share/man/man9/pci_get_powerstate.9      comp-sys-man            .man
 ./usr/share/man/man9/pci_intr.9                        comp-sys-man            .man
diff -r d07f589d822a -r b64eacb864c2 share/man/man9/Makefile
--- a/share/man/man9/Makefile   Fri Oct 02 03:08:26 2015 +0000
+++ b/share/man/man9/Makefile   Fri Oct 02 05:22:49 2015 +0000
@@ -1,4 +1,4 @@
-#       $NetBSD: Makefile,v 1.391 2015/08/17 06:28:11 knakahara Exp $
+#       $NetBSD: Makefile,v 1.392 2015/10/02 05:22:49 msaitoh Exp $
 
 #      Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -559,6 +559,7 @@
        pci.9 pci_find_device.9 \
        pci.9 pci_get_capability.9 \
        pci.9 pci_get_ht_capability.9 \
+       pci.9 pci_get_ext_capability.9 \
        pci.9 pci_mapreg_type.9 \
        pci.9 pci_mapreg_map.9 \
        pci.9 pci_mapreg_info.9 \
diff -r d07f589d822a -r b64eacb864c2 share/man/man9/pci.9
--- a/share/man/man9/pci.9      Fri Oct 02 03:08:26 2015 +0000
+++ b/share/man/man9/pci.9      Fri Oct 02 05:22:49 2015 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: pci.9,v 1.41 2015/08/15 16:39:58 wiz Exp $
+.\"     $NetBSD: pci.9,v 1.42 2015/10/02 05:22:49 msaitoh Exp $
 .\"
 .\" Copyright (c) 2001, 2003 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -44,6 +44,7 @@
 .Nm pci_find_device ,
 .Nm pci_get_capability ,
 .Nm pci_get_ht_capability ,
+.Nm pci_get_ext_capability ,
 .Nm pci_mapreg_type ,
 .Nm pci_mapreg_map ,
 .Nm pci_mapreg_info ,
@@ -103,6 +104,9 @@
 .Ft int
 .Fn pci_get_ht_capability "pci_chipset_tag_t pc" "pcitag_t tag" \
 "int capid" "int *offsetp" "pcireg_t *valuep"
+.Ft int
+.Fn pci_get_ext_capability "pci_chipset_tag_t pc" "pcitag_t tag" \
+"int capid" "int *offsetp" "pcireg_t *valuep"
 .Ft pcireg_t
 .Fn pci_mapreg_type "pci_chipset_tag_t pc" "pcitag_t tag" "int reg"
 .Ft int
@@ -496,6 +500,32 @@
 and
 .Fa valuep
 remain unchanged.
+.It Fn pci_get_ext_capability "pc" "tag" "capid" "offsetp" "valuep"
+Parse the device capability list in extended configuration space looking for
+capability
+.Fa capid .
+If
+.Fa offsetp
+is not
+.Dv NULL ,
+the register offset in extended configuration space is returned in
+.Fa offsetp .
+If
+.Fa valuep
+is not
+.Dv NULL ,
+the value of the capability is returned in
+.Fa valuep .
+The argument
+.Fa tag
+is the PCI tag for the current device attached to PCI chipset
+.Fa pc .
+This function returns 1 if the capability was found.
+If the capability was not found, it returns zero, and
+.Fa offsetp
+and
+.Fa valuep
+remain unchanged.
 .It Fn pci_mapreg_type "pc" "tag" "reg"
 Interrogates the Base Address Register (BAR) in configuration space
 specified by
diff -r d07f589d822a -r b64eacb864c2 sys/arch/algor/pci/vtpbc.c
--- a/sys/arch/algor/pci/vtpbc.c        Fri Oct 02 03:08:26 2015 +0000
+++ b/sys/arch/algor/pci/vtpbc.c        Fri Oct 02 05:22:49 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vtpbc.c,v 1.9 2012/10/27 17:17:25 chs Exp $    */
+/*     $NetBSD: vtpbc.c,v 1.10 2015/10/02 05:22:49 msaitoh Exp $       */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vtpbc.c,v 1.9 2012/10/27 17:17:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vtpbc.c,v 1.10 2015/10/02 05:22:49 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -165,6 +165,9 @@
 {
        int b, d, f;
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return (1);
+
        vtpbc_decompose_tag(vt, tag, &b, &d, &f);
 
        if (b == 0) {
diff -r d07f589d822a -r b64eacb864c2 sys/arch/alpha/pci/apecs_pci.c
--- a/sys/arch/alpha/pci/apecs_pci.c    Fri Oct 02 03:08:26 2015 +0000
+++ b/sys/arch/alpha/pci/apecs_pci.c    Fri Oct 02 05:22:49 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: apecs_pci.c,v 1.25 2012/02/06 02:14:14 matt Exp $ */
+/* $NetBSD: apecs_pci.c,v 1.26 2015/10/02 05:22:49 msaitoh Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: apecs_pci.c,v 1.25 2012/02/06 02:14:14 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apecs_pci.c,v 1.26 2015/10/02 05:22:49 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -101,6 +101,9 @@
        int s, secondary, ba;
        int32_t old_haxr2;                                      /* XXX */
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return (pcireg_t) -1;
+
        s = 0;                                  /* XXX gcc -Wuninitialized */
        old_haxr2 = 0;                          /* XXX gcc -Wuninitialized */
 
@@ -146,6 +149,9 @@
        int s, secondary;
        int32_t old_haxr2;                                      /* XXX */
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return;
+
        s = 0;                                  /* XXX gcc -Wuninitialized */
        old_haxr2 = 0;                          /* XXX gcc -Wuninitialized */
 
diff -r d07f589d822a -r b64eacb864c2 sys/arch/alpha/pci/cia_pci.c
--- a/sys/arch/alpha/pci/cia_pci.c      Fri Oct 02 03:08:26 2015 +0000
+++ b/sys/arch/alpha/pci/cia_pci.c      Fri Oct 02 05:22:49 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cia_pci.c,v 1.32 2012/02/06 02:14:14 matt Exp $ */
+/* $NetBSD: cia_pci.c,v 1.33 2015/10/02 05:22:49 msaitoh Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cia_pci.c,v 1.32 2012/02/06 02:14:14 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cia_pci.c,v 1.33 2015/10/02 05:22:49 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -101,6 +101,9 @@
        int s, secondary, ba;
        uint32_t old_cfg, errbits;
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return (pcireg_t) -1;
+
 #ifdef __GNUC__
        s = 0;                                  /* XXX gcc -Wuninitialized */
        old_cfg = 0;                            /* XXX gcc -Wuninitialized */
@@ -196,6 +199,9 @@
        int s, secondary;
        uint32_t old_cfg;
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return;
+
 #ifdef __GNUC__
        s = 0;                                  /* XXX gcc -Wuninitialized */
        old_cfg = 0;                            /* XXX gcc -Wuninitialized */
diff -r d07f589d822a -r b64eacb864c2 sys/arch/alpha/pci/dwlpx_pci.c
--- a/sys/arch/alpha/pci/dwlpx_pci.c    Fri Oct 02 03:08:26 2015 +0000
+++ b/sys/arch/alpha/pci/dwlpx_pci.c    Fri Oct 02 05:22:49 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwlpx_pci.c,v 1.18 2012/02/06 02:14:14 matt Exp $ */
+/* $NetBSD: dwlpx_pci.c,v 1.19 2015/10/02 05:22:49 msaitoh Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dwlpx_pci.c,v 1.18 2012/02/06 02:14:14 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwlpx_pci.c,v 1.19 2015/10/02 05:22:49 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -125,6 +125,9 @@
        int secondary, i, s = 0;
        uint32_t rvp;
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return (data);
+
        if (ccp == NULL) {
                panic("NULL ccp in dwlpx_conf_read");
        }
@@ -191,6 +194,9 @@
        int secondary, i, s = 0;
        uint32_t rvp;
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return;
+
        if (ccp == NULL) {
                panic("NULL ccp in dwlpx_conf_write");
        }
diff -r d07f589d822a -r b64eacb864c2 sys/arch/alpha/pci/irongate_pci.c
--- a/sys/arch/alpha/pci/irongate_pci.c Fri Oct 02 03:08:26 2015 +0000
+++ b/sys/arch/alpha/pci/irongate_pci.c Fri Oct 02 05:22:49 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irongate_pci.c,v 1.9 2012/02/06 02:14:14 matt Exp $ */
+/* $NetBSD: irongate_pci.c,v 1.10 2015/10/02 05:22:49 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: irongate_pci.c,v 1.9 2012/02/06 02:14:14 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irongate_pci.c,v 1.10 2015/10/02 05:22:49 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -116,6 +116,9 @@
 {
        int d;
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return (pcireg_t) -1;
+
        /*
         * The AMD 751 appears in PCI configuration space, but
         * that is ... counter-intuitive to the way we normally
@@ -136,6 +139,9 @@
        pcireg_t data;
        int s;
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return (pcireg_t) -1;
+
        PCI_CONF_LOCK(s);
        REGVAL(PCI_CONF_ADDR) = (CONFADDR_ENABLE | tag | (offset & 0xff));
        alpha_mb();
@@ -152,6 +158,9 @@
 {
        int s;
 
+       if ((unsigned int)offset >= PCI_CONF_SIZE)
+               return;
+
        PCI_CONF_LOCK(s);
        REGVAL(PCI_CONF_ADDR) = (CONFADDR_ENABLE | tag | (offset & 0xff));
        alpha_mb();



Home | Main Index | Thread Index | Old Index