Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Overhaul the interface to pci_configure_bus():
details: https://anonhg.NetBSD.org/src/rev/8b3a4020d587
branches: trunk
changeset: 1011716:8b3a4020d587
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Jul 07 03:38:45 2020 +0000
description:
Overhaul the interface to pci_configure_bus():
- Don't expose how PCI bus configuration resource management is implemented.
Provide a new resource provider API:
==> pciconf_resource_init() -- Initialize a PCI configuration resources
container.
==> pciconf_resource_add() -- Add a PCI configuration resource to the
container (I/O, MEM, or prefetchable MEM). Multiple resources of
each type may be added.
==> pciconf_resource_fini() -- Tear down the PCI configurtation resources
container once the bus has been configured.
This is much easier to use than the previous method of providing an
extent map for each kind of resource, and works better for e.g. ACPI
platforms that provide potentially multiple PCI resources in tables
provided by firmware.
- Re-implement PCI configuration resource management using vmem arenas,
rather than extent maps.
diffstat:
sys/arch/algor/dev/mainbus.c | 100 ++++-----
sys/arch/amiga/pci/em4k.c | 20 +-
sys/arch/amiga/pci/empb.c | 20 +-
sys/arch/amiga/pci/empbreg.h | 7 +-
sys/arch/amiga/pci/mppb.c | 21 +-
sys/arch/amiga/pci/p5pb.c | 20 +-
sys/arch/arc/include/pci_machdep.h | 5 +-
sys/arch/arc/pci/necpb.c | 25 +-
sys/arch/arm/broadcom/bcm53xx_pax.c | 16 +-
sys/arch/arm/fdt/pcihost_fdt.c | 67 ++---
sys/arch/arm/gemini/gemini_pci.c | 27 +-
sys/arch/arm/imx/fdt/imx6_pcie.c | 24 +-
sys/arch/arm/imx/imx6_pcie.c | 24 +-
sys/arch/arm/ixp12x0/ixp12x0_pci.c | 25 +-
sys/arch/arm/nvidia/tegra_pcie.c | 30 +-
sys/arch/arm/s3c2xx0/s3c2800_pci.c | 22 +-
sys/arch/arm/xscale/becc_pci.c | 24 +-
sys/arch/arm/xscale/i80312_pci.c | 24 +-
sys/arch/arm/xscale/i80321_pci.c | 30 +-
sys/arch/arm/xscale/ixp425_pci.c | 26 +-
sys/arch/bebox/bebox/mainbus.c | 32 +-
sys/arch/cobalt/dev/gt.c | 26 +-
sys/arch/cobalt/include/pci_machdep.h | 5 +-
sys/arch/evbarm/ifpga/ifpga.c | 30 +-
sys/arch/evbmips/gdium/mainbus.c | 28 +-
sys/arch/evbmips/loongson/mainbus.c | 28 +-
sys/arch/evbmips/malta/dev/mainbus.c | 35 +-
sys/arch/evbppc/walnut/pci/pchb.c | 28 +-
sys/arch/ibmnws/ibmnws/mainbus.c | 31 +-
sys/arch/mips/adm5120/dev/admpci.c | 53 ++--
sys/arch/mips/alchemy/dev/aupci.c | 33 +-
sys/arch/mips/rmi/rmixl_pcie.c | 29 +-
sys/arch/mips/rmi/rmixl_pcix.c | 26 +-
sys/arch/mvmeppc/mvmeppc/mainbus.c | 31 +-
sys/arch/ofppc/pci/ofwpci.c | 27 +-
sys/arch/powerpc/booke/pci/pq3pci.c | 19 +-
sys/arch/powerpc/ibm4xx/pci/pchb.c | 24 +-
sys/arch/prep/prep/mainbus.c | 31 +-
sys/arch/sandpoint/sandpoint/mainbus.c | 31 +-
sys/arch/sgimips/gio/pci_gio.c | 16 +-
sys/arch/sgimips/include/pci_machdep.h | 5 +-
sys/arch/sgimips/mace/pci_mace.c | 44 ++-
sys/arch/sh3/dev/shpcic.c | 25 +-
sys/dev/acpi/acpi_mcfg.c | 99 ++------
sys/dev/ic/cpc700.c | 27 +-
sys/dev/marvell/gtpci.c | 21 +-
sys/dev/marvell/mvpex.c | 21 +-
sys/dev/pci/pciconf.c | 351 ++++++++++++++++++++++----------
sys/dev/pci/pciconf.h | 31 ++-
49 files changed, 913 insertions(+), 831 deletions(-)
diffs (truncated from 3749 to 300 lines):
diff -r b859fa28b658 -r 8b3a4020d587 sys/arch/algor/dev/mainbus.c
--- a/sys/arch/algor/dev/mainbus.c Tue Jul 07 03:23:33 2020 +0000
+++ b/sys/arch/algor/dev/mainbus.c Tue Jul 07 03:38:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.27 2020/06/14 01:40:02 chs Exp $ */
+/* $NetBSD: mainbus.c,v 1.28 2020/07/07 03:38:45 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.27 2020/06/14 01:40:02 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.28 2020/07/07 03:38:45 thorpej Exp $");
#include "opt_algor_p4032.h"
#include "opt_algor_p5064.h"
@@ -42,7 +42,6 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/device.h>
-#include <sys/extent.h>
#include <sys/malloc.h>
#include <sys/reboot.h>
#include <sys/systm.h>
@@ -98,6 +97,13 @@
{ NULL, 0, 0 },
};
+
+/* Reserve the bottom 64K of the I/O space for ISA devices. */
+#define PCI_IO_START 0x00010000
+#define PCI_IO_END 0x000effff
+#define PCI_MEM_START 0x01000000
+#define PCI_MEM_END 0x07ffffff
+#define PCI_CHIPSET &p4032_configuration.ac_pc
#endif /* ALGOR_P4032 */
#if defined(ALGOR_P5064)
@@ -110,6 +116,19 @@
{ NULL, 0, 0 },
};
+
+/*
+ * Reserve the bottom 512K of the I/O space for ISA devices.
+ * According to the PMON sources, this is a work-around for
+ * a bug in the ISA bridge.
+ */
+#define PCI_IO_START 0x00080000
+#define PCI_IO_END 0x00ffffff
+#define PCI_MEM_START 0x01000000
+#define PCI_MEM_END 0x07ffffff
+#define PCI_IDE_DEV 2
+#define PCI_IDE_FUNC 1
+#define PCI_CHIPSET &p5064_configuration.ac_pc
#endif /* ALGOR_P5064 */
#if defined(ALGOR_P6032)
@@ -122,8 +141,20 @@
{ NULL, 0, 0 },
};
+
+/* Reserve the bottom 64K of the I/O space for ISA devices. */
+#define PCI_IO_START 0x00010000
+#define PCI_IO_END 0x000effff
+#define PCI_MEM_START 0x01000000
+#define PCI_MEM_END 0x0affffff
+#define PCI_IDE_DEV 17
+#define PCI_IDE_FUNC 1
+#define PCI_CHIPSET &p6032_configuration.ac_pc
#endif /* ALGOR_P6032 */
+#define PCI_IO_SIZE ((PCI_IO_END - PCI_IO_START) + 1)
+#define PCI_MEM_SIZE ((PCI_MEM_END - PCI_MEM_START) + 1)
+
int
mainbus_match(device_t parent, cfdata_t cf, void *aux)
{
@@ -140,63 +171,22 @@
struct mainbus_attach_args ma;
struct mainbusdev *md;
bus_space_tag_t st;
-#if defined(PCI_NETBSD_CONFIGURE)
- struct extent *ioext, *memext;
- pci_chipset_tag_t pc;
-#if defined(PCI_NETBSD_ENABLE_IDE)
- pcitag_t idetag;
- pcireg_t idetim;
-#endif
-#endif
mainbus_found = 1;
printf("\n");
#if NPCI > 0 && defined(PCI_NETBSD_CONFIGURE)
-#if defined(ALGOR_P4032)
- /*
- * Reserve the bottom 64K of the I/O space for ISA devices.
- */
- ioext = extent_create("pciio", 0x00010000, 0x000effff,
- NULL, 0, EX_WAITOK);
- memext = extent_create("pcimem", 0x01000000, 0x07ffffff,
- NULL, 0, EX_WAITOK);
-
- pc = &p4032_configuration.ac_pc;
-#elif defined(ALGOR_P5064)
- /*
- * Reserve the bottom 512K of the I/O space for ISA devices.
- * According to the PMON sources, this is a work-around for
- * a bug in the ISA bridge.
- */
- ioext = extent_create("pciio", 0x00080000, 0x00ffffff,
- NULL, 0, EX_WAITOK);
- memext = extent_create("pcimem", 0x01000000, 0x07ffffff,
- NULL, 0, EX_WAITOK);
+ struct pciconf_resources *pcires = pciconf_resource_init();
- pc = &p5064_configuration.ac_pc;
-#if defined(PCI_NETBSD_ENABLE_IDE)
- idetag = pci_make_tag(pc, 0, 2, 1);
-#endif
-#elif defined(ALGOR_P6032)
- /*
- * Reserve the bottom 64K of the I/O space for ISA devices.
- */
- ioext = extent_create("pciio", 0x00010000, 0x000effff,
- NULL, 0, EX_WAITOK);
- memext = extent_create("pcimem", 0x01000000, 0x0affffff,
- NULL, 0, EX_WAITOK);
+ pciconf_resource_add(pcires, PCICONF_RESOURCE_IO,
+ PCI_IO_START, PCI_IO_SIZE);
+ pciconf_resource_add(pcires, PCICONF_RESOURCE_MEM,
+ PCI_MEM_START, PCI_MEM_SIZE);
- pc = &p6032_configuration.ac_pc;
-#if defined(PCI_NETBSD_ENABLE_IDE)
- idetag = pci_make_tag(pc, 0, 17, 1);
-#endif
-#endif /* ALGOR_P4032 || ALGOR_P5064 || ALGOR_P6032 */
-
- pci_configure_bus(pc, ioext, memext, NULL, 0, mips_cache_info.mci_dcache_align);
- extent_destroy(ioext);
- extent_destroy(memext);
+ pci_configure_bus(PCI_CHIPSET, pcires, 0,
+ mips_cache_info.mci_dcache_align);
+ pciconf_resource_fini(pcires);
#if defined(PCI_NETBSD_ENABLE_IDE)
/*
@@ -206,12 +196,14 @@
* except for the ENABLE bits -- the `pciide' driver will
* properly configure it later.
*/
- idetim = 0;
+ pcitag_t idetag = pci_make_tag(PCI_CHIPSET, 0, PCI_IDE_DEV,
+ PCI_IDE_FUNC);
+ pcireg_t idetim = 0;
if (PCI_NETBSD_ENABLE_IDE & 0x01)
idetim = PIIX_IDETIM_SET(idetim, PIIX_IDETIM_IDE, 0);
if (PCI_NETBSD_ENABLE_IDE & 0x02)
idetim = PIIX_IDETIM_SET(idetim, PIIX_IDETIM_IDE, 1);
- pci_conf_write(pc, idetag, PIIX_IDETIM, idetim);
+ pci_conf_write(PCI_CHIPSET, idetag, PIIX_IDETIM, idetim);
#endif
#endif /* NPCI > 0 && defined(PCI_NETBSD_CONFIGURE) */
diff -r b859fa28b658 -r 8b3a4020d587 sys/arch/amiga/pci/em4k.c
--- a/sys/arch/amiga/pci/em4k.c Tue Jul 07 03:23:33 2020 +0000
+++ b/sys/arch/amiga/pci/em4k.c Tue Jul 07 03:38:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: em4k.c,v 1.5 2020/06/14 01:40:02 chs Exp $ */
+/* $NetBSD: em4k.c,v 1.6 2020/07/07 03:38:45 thorpej Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,6 @@
#include <sys/errno.h>
#include <sys/device.h>
#include <sys/malloc.h>
-#include <sys/extent.h>
#include <sys/kmem.h>
#include <uvm/uvm_extern.h>
@@ -243,24 +242,23 @@
static void
em4k_pci_configure(struct em4k_softc *sc)
{
- struct extent *ioext, *memext;
+ struct pciconf_resources *pcires;
+
+ pcires = pciconf_resource_init();
/* I/O addresses are relative to I/O space address. */
- ioext = extent_create("em4kio", 0, EM4K_IO_SIZE,
- NULL, 0, EX_WAITOK);
+ pciconf_resource_add(pcires, PCICONF_RESOURCE_IO, 0, EM4K_IO_SIZE);
/*
* Memory space addresses are absolute (and keep in mind that
* they are in a separate address space.
*/
- memext = extent_create("em4kmem", kvtop((void*) sc->pci_mem_win.base),
- kvtop((void*) sc->pci_mem_win.base) + sc->pci_mem_win_size,
- NULL, 0, EX_WAITOK);
+ pciconf_resource_add(pcires, PCICONF_RESOURCE_MEM,
+ kvtop((void*) sc->pci_mem_win.base), sc->pci_mem_win_size);
- pci_configure_bus(&sc->apc, ioext, memext, NULL, 0, CACHELINE_SIZE);
+ pci_configure_bus(&sc->apc, pcires, 0, CACHELINE_SIZE);
- extent_destroy(ioext);
- extent_destroy(memext);
+ pciconf_resource_fini(pcires);
}
#endif /* PCI_NETBSD_CONFIGURE */
diff -r b859fa28b658 -r 8b3a4020d587 sys/arch/amiga/pci/empb.c
--- a/sys/arch/amiga/pci/empb.c Tue Jul 07 03:23:33 2020 +0000
+++ b/sys/arch/amiga/pci/empb.c Tue Jul 07 03:38:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: empb.c,v 1.12 2020/06/14 01:40:02 chs Exp $ */
+/* $NetBSD: empb.c,v 1.13 2020/07/07 03:38:45 thorpej Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -38,7 +38,6 @@
#include <sys/errno.h>
#include <sys/device.h>
#include <sys/malloc.h>
-#include <sys/extent.h>
#include <sys/kmem.h>
#include <uvm/uvm_extern.h>
@@ -173,9 +172,6 @@
struct empb_softc *sc;
pci_chipset_tag_t pc;
struct pcibus_attach_args pba;
-#ifdef PCI_NETBSD_CONFIGURE
- struct extent *ioext, *memext;
-#endif /* PCI_NETBSD_CONFIGURE */
sc = device_private(self);
pc = &sc->apc;
@@ -233,16 +229,16 @@
sc->apc.cookie = sc;
#ifdef PCI_NETBSD_CONFIGURE
- ioext = extent_create("empbio", 0, EMPB_BRIDGE_SIZE,
- NULL, 0, EX_WAITOK);
+ struct pciconf_resources *pcires = pciconf_resource_init();
- memext = extent_create("empbmem", EMPB_MEM_BASE, EMPB_MEM_END,
- NULL, 0, EX_WAITOK);
+ pciconf_resource_add(pcires, PCICONF_RESOURCE_IO,
+ 0, EMPB_BRIDGE_SIZE);
+ pciconf_resource_add(pcires, PCICONF_RESOURCE_MEM,
+ EMPB_MEM_BASE, EMPB_MEM_SIZE);
- pci_configure_bus(pc, ioext, memext, NULL, 0, CACHELINE_SIZE);
+ pci_configure_bus(pc, pcires, 0, CACHELINE_SIZE);
- extent_destroy(ioext);
- extent_destroy(memext);
+ pciconf_resource_fini(pcires);
#endif /* PCI_NETBSD_CONFIGURE */
diff -r b859fa28b658 -r 8b3a4020d587 sys/arch/amiga/pci/empbreg.h
--- a/sys/arch/amiga/pci/empbreg.h Tue Jul 07 03:23:33 2020 +0000
+++ b/sys/arch/amiga/pci/empbreg.h Tue Jul 07 03:38:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: empbreg.h,v 1.6 2013/01/29 00:49:43 rkujawa Exp $ */
+/* $NetBSD: empbreg.h,v 1.7 2020/07/07 03:38:45 thorpej Exp $ */
/*-
* Copyright (c) 2012, 2013 The NetBSD Foundation, Inc.
@@ -85,8 +85,9 @@
#define EMPB_WINDOW_MASK_8M 0xFF80
#define EMPB_WINDOW_MASK_4M 0xFFC0
-#define EMPB_MEM_BASE 0x80000000
-#define EMPB_MEM_END 0xA0000000
+#define EMPB_MEM_BASE 0x80000000U
+#define EMPB_MEM_END 0x9FFFFFFFU
+#define EMPB_MEM_SIZE ((EMPB_MEM_END - EMPB_MEM_BASE) + 1)
#define EMPB_PM_OFF 0x40 /* power management register */
#define EMPB_PM_PSU_SHUTDOWN 0x0
diff -r b859fa28b658 -r 8b3a4020d587 sys/arch/amiga/pci/mppb.c
--- a/sys/arch/amiga/pci/mppb.c Tue Jul 07 03:23:33 2020 +0000
+++ b/sys/arch/amiga/pci/mppb.c Tue Jul 07 03:38:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mppb.c,v 1.9 2020/06/14 01:40:02 chs Exp $ */
+/* $NetBSD: mppb.c,v 1.10 2020/07/07 03:38:45 thorpej Exp $ */
/*-
Home |
Main Index |
Thread Index |
Old Index