Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add support for multiple PCI segments.
details: https://anonhg.NetBSD.org/src/rev/28b3deab1abb
branches: trunk
changeset: 445557:28b3deab1abb
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Nov 02 15:01:18 2018 +0000
description:
Add support for multiple PCI segments.
diffstat:
share/man/man9/pci.9 | 14 ++++++++++++--
sys/arch/arm/acpi/acpi_pci_machdep.c | 14 ++++++++++++--
sys/arch/arm/include/pci_machdep.h | 7 ++++++-
sys/dev/acpi/acpi_mcfg.c | 26 +++++++++++++++++---------
4 files changed, 47 insertions(+), 14 deletions(-)
diffs (221 lines):
diff -r 69490ad496d5 -r 28b3deab1abb share/man/man9/pci.9
--- a/share/man/man9/pci.9 Fri Nov 02 13:46:24 2018 +0000
+++ b/share/man/man9/pci.9 Fri Nov 02 15:01:18 2018 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pci.9,v 1.48 2018/09/20 07:08:00 rin Exp $
+.\" $NetBSD: pci.9,v 1.49 2018/11/02 15:01:18 jmcneill Exp $
.\"
.\" Copyright (c) 2001, 2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd September 20, 2018
+.Dd November 2, 2018
.Dt PCI 9
.Os
.Sh NAME
@@ -45,6 +45,7 @@
.Nm pci_get_capability ,
.Nm pci_get_ht_capability ,
.Nm pci_get_ext_capability ,
+.Nm pci_get_segment ,
.Nm pci_mapreg_type ,
.Nm pci_mapreg_map ,
.Nm pci_mapreg_info ,
@@ -110,6 +111,8 @@
.Ft int
.Fn pci_get_ext_capability "pci_chipset_tag_t pc" "pcitag_t tag" \
"int capid" "int *offsetp" "pcireg_t *valuep"
+.Ft u_int
+.Fn pci_get_segment "pci_chipset_tag_t pc"
.Ft pcireg_t
.Fn pci_mapreg_type "pci_chipset_tag_t pc" "pcitag_t tag" "int reg"
.Ft int
@@ -536,6 +539,13 @@
and
.Fa valuep
remain unchanged.
+.It Fn pci_get_segment "pc"
+Return the PCI segment number for PCI chipset
+.Fa pc .
+This machine-dependent function is only available if
+.Dv __HAVE_PCI_GET_SEGMENT
+is defined in the header
+.In machine/pci_machdep.h .
.It Fn pci_mapreg_type "pc" "tag" "reg"
Interrogates the Base Address Register (BAR) in configuration space
specified by
diff -r 69490ad496d5 -r 28b3deab1abb sys/arch/arm/acpi/acpi_pci_machdep.c
--- a/sys/arch/arm/acpi/acpi_pci_machdep.c Fri Nov 02 13:46:24 2018 +0000
+++ b/sys/arch/arm/acpi/acpi_pci_machdep.c Fri Nov 02 15:01:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.5 2018/10/31 15:42:36 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.6 2018/11/02 15:01:18 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.5 2018/10/31 15:42:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.6 2018/11/02 15:01:18 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -73,6 +73,7 @@
static int acpi_pci_md_bus_maxdevs(void *, int);
static pcitag_t acpi_pci_md_make_tag(void *, int, int, int);
static void acpi_pci_md_decompose_tag(void *, pcitag_t, int *, int *, int *);
+static u_int acpi_pci_md_get_segment(void *);
static pcireg_t acpi_pci_md_conf_read(void *, pcitag_t, int);
static void acpi_pci_md_conf_write(void *, pcitag_t, int, pcireg_t);
static int acpi_pci_md_conf_hook(void *, int, int, int, pcireg_t);
@@ -94,6 +95,7 @@
.pc_bus_maxdevs = acpi_pci_md_bus_maxdevs,
.pc_make_tag = acpi_pci_md_make_tag,
.pc_decompose_tag = acpi_pci_md_decompose_tag,
+ .pc_get_segment = acpi_pci_md_get_segment,
.pc_conf_read = acpi_pci_md_conf_read,
.pc_conf_write = acpi_pci_md_conf_write,
.pc_conf_hook = acpi_pci_md_conf_hook,
@@ -227,6 +229,14 @@
*fp = (tag >> 8) & 0x7;
}
+static u_int
+acpi_pci_md_get_segment(void *v)
+{
+ struct acpi_pci_context * const ap = v;
+
+ return ap->ap_seg;
+}
+
static pcireg_t
acpi_pci_md_conf_read(void *v, pcitag_t tag, int offset)
{
diff -r 69490ad496d5 -r 28b3deab1abb sys/arch/arm/include/pci_machdep.h
--- a/sys/arch/arm/include/pci_machdep.h Fri Nov 02 13:46:24 2018 +0000
+++ b/sys/arch/arm/include/pci_machdep.h Fri Nov 02 15:01:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.14 2018/10/21 00:42:06 jmcneill Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.15 2018/11/02 15:01:18 jmcneill Exp $ */
/*
* Modified for arm32 by Mark Brinicombe
@@ -41,6 +41,8 @@
#define _PCI_HAVE_DMA64
#endif
+#define __HAVE_PCI_GET_SEGMENT
+
#include <sys/errno.h>
/*
@@ -89,6 +91,7 @@
pcitag_t (*pc_make_tag)(void *, int, int, int);
void (*pc_decompose_tag)(void *, pcitag_t, int *,
int *, int *);
+ u_int (*pc_get_segment)(void *);
pcireg_t (*pc_conf_read)(void *, pcitag_t, int);
void (*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
@@ -143,6 +146,8 @@
(*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
#define pci_decompose_tag(c, t, bp, dp, fp) \
(*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
+#define pci_get_segment(c) \
+ ((c)->pc_get_segment ? (*(c)->pc_get_segment)((c)->pc_conf_v) : 0)
#define pci_conf_read(c, t, r) \
(*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
#define pci_conf_write(c, t, r, v) \
diff -r 69490ad496d5 -r 28b3deab1abb sys/dev/acpi/acpi_mcfg.c
--- a/sys/dev/acpi/acpi_mcfg.c Fri Nov 02 13:46:24 2018 +0000
+++ b/sys/dev/acpi/acpi_mcfg.c Fri Nov 02 15:01:18 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_mcfg.c,v 1.11 2018/10/19 14:06:13 jmcneill Exp $ */
+/* $NetBSD: acpi_mcfg.c,v 1.12 2018/11/02 15:01:18 jmcneill Exp $ */
/*-
* Copyright (C) 2015 NONAKA Kimihiro <nonaka%NetBSD.org@localhost>
@@ -28,7 +28,7 @@
#include "opt_pci.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.11 2018/10/19 14:06:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.12 2018/11/02 15:01:18 jmcneill Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -448,14 +448,22 @@
}
static struct mcfg_segment *
-acpimcfg_get_segment(int bus)
+acpimcfg_get_segment(pci_chipset_tag_t pc, int bus)
{
struct mcfg_segment *seg;
+ u_int segment;
int i;
+#ifdef __HAVE_PCI_GET_SEGMENT
+ segment = pci_get_segment(pc);
+#else
+ segment = 0;
+#endif
+
for (i = 0; i < mcfg_nsegs; i++) {
seg = &mcfg_segs[i];
- if (bus >= seg->ms_bus_start && bus <= seg->ms_bus_end)
+ if (segment == seg->ms_segment &&
+ bus >= seg->ms_bus_start && bus <= seg->ms_bus_end)
return seg;
}
return NULL;
@@ -479,7 +487,7 @@
bool force_noextcnf = false;
int i, j;
- seg = acpimcfg_get_segment(bus);
+ seg = acpimcfg_get_segment(pc, bus);
if (seg == NULL)
return 0;
@@ -561,7 +569,7 @@
if (!mcfg_inited)
return ENXIO;
- seg = acpimcfg_get_segment(bus);
+ seg = acpimcfg_get_segment(pc, bus);
if (seg == NULL)
return ENOENT;
@@ -813,7 +821,7 @@
bus_addr_t baddr;
ACPI_STATUS rv;
- seg = acpimcfg_get_segment(bus);
+ seg = acpimcfg_get_segment(pc, bus);
if (seg == NULL)
return ENOENT;
@@ -908,7 +916,7 @@
pci_decompose_tag(pc, tag, &bus, &dev, &func);
- seg = acpimcfg_get_segment(bus);
+ seg = acpimcfg_get_segment(pc, bus);
if (seg == NULL) {
*data = -1;
return ERANGE;
@@ -943,7 +951,7 @@
pci_decompose_tag(pc, tag, &bus, &dev, &func);
- seg = acpimcfg_get_segment(bus);
+ seg = acpimcfg_get_segment(pc, bus);
if (seg == NULL)
return ERANGE;
Home |
Main Index |
Thread Index |
Old Index