Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci - Define a device call for PCI bus instances to ...



details:   https://anonhg.NetBSD.org/src/rev/db32cb198225
branches:  trunk
changeset: 379124:db32cb198225
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed May 12 23:22:32 2021 +0000

description:
- Define a device call for PCI bus instances to fetch a direct child's
  device handle given the device's device/function #s (extracted from
  a pcitag_t).  Use it to associate the handle with the child device
  at config_found() time.
- Implement this device call for ACPI and OpenFirmware.
- Enable the OpenFirmware variant for evbarm FDT, macppc, ofppc, sparc64.
- Obsolete acpi_device_register(); it is no longer needed.
- Obsolete setting the OpenFirmware handle in PCI devices in the
  sparc64 device_register(); it is no longer needed.

diffstat:

 sys/arch/arm/acpi/acpi_platform.c   |   6 +-
 sys/arch/evbarm/conf/files.fdt      |   3 +-
 sys/arch/macppc/conf/files.macppc   |   3 +-
 sys/arch/ofppc/conf/files.ofppc     |   3 +-
 sys/arch/sparc64/conf/files.sparc64 |   3 +-
 sys/arch/sparc64/sparc64/autoconf.c |  16 +------
 sys/arch/x86/acpi/acpi_machdep.c    |   6 +-
 sys/dev/acpi/acpi.c                 |  41 +----------------
 sys/dev/acpi/acpi_pci.c             |  40 ++++++++++++++++-
 sys/dev/acpi/acpivar.h              |   3 +-
 sys/dev/ofw/files.ofw               |   5 +-
 sys/dev/ofw/ofw_pci_subr.c          |  86 +++++++++++++++++++++++++++++++++++++
 sys/dev/pci/pci.c                   |  28 +++++++++++-
 sys/dev/pci/pcivar.h                |  27 +++++++++++-
 14 files changed, 197 insertions(+), 73 deletions(-)

diffs (truncated from 507 to 300 lines):

diff -r 8753447de245 -r db32cb198225 sys/arch/arm/acpi/acpi_platform.c
--- a/sys/arch/arm/acpi/acpi_platform.c Wed May 12 22:17:40 2021 +0000
+++ b/sys/arch/arm/acpi/acpi_platform.c Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.25 2021/04/24 23:36:25 thorpej Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.26 2021/05/12 23:22:32 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.25 2021/04/24 23:36:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.26 2021/05/12 23:22:32 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -287,8 +287,6 @@ acpi_platform_init_attach_args(struct fd
 static void
 acpi_platform_device_register(device_t self, void *aux)
 {
-       acpi_device_register(self, aux);
-
 #if NCOM > 0
        prop_dictionary_t prop = device_properties(self);
        ACPI_STATUS rv;
diff -r 8753447de245 -r db32cb198225 sys/arch/evbarm/conf/files.fdt
--- a/sys/arch/evbarm/conf/files.fdt    Wed May 12 22:17:40 2021 +0000
+++ b/sys/arch/evbarm/conf/files.fdt    Wed May 12 23:22:32 2021 +0000
@@ -1,9 +1,10 @@
-#      $NetBSD: files.fdt,v 1.7 2020/12/12 09:27:31 skrll Exp $
+#      $NetBSD: files.fdt,v 1.8 2021/05/12 23:22:32 thorpej Exp $
 #
 # FDT-based kernel configuration info
 #
 
 file   arch/evbarm/fdt/fdt_dma_machdep.c       fdt
 file   arch/evbarm/fdt/fdt_machdep.c           fdt
+file   dev/ofw/ofw_pci_subr.c                  fdt & pci
 
 include "arch/arm/fdt/files.fdt"
diff -r 8753447de245 -r db32cb198225 sys/arch/macppc/conf/files.macppc
--- a/sys/arch/macppc/conf/files.macppc Wed May 12 22:17:40 2021 +0000
+++ b/sys/arch/macppc/conf/files.macppc Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.macppc,v 1.117 2021/05/01 15:12:25 thorpej Exp $
+#      $NetBSD: files.macppc,v 1.118 2021/05/12 23:22:33 thorpej Exp $
 #
 # macppc-specific configuration info
 
@@ -93,6 +93,7 @@ include "dev/isa/files.isa"
 include "dev/pci/files.pci"
 include "dev/pci/files.agp"
 file arch/macppc/pci/pci_machdep.c             pci
+file dev/ofw/ofw_pci_subr.c                    pci
 file arch/macppc/pci/agp_machdep.c             agp
 file arch/powerpc/pci/pciconf_indirect.c       pci
 file arch/powerpc/pci/pci_machdep_common.c     pci
diff -r 8753447de245 -r db32cb198225 sys/arch/ofppc/conf/files.ofppc
--- a/sys/arch/ofppc/conf/files.ofppc   Wed May 12 22:17:40 2021 +0000
+++ b/sys/arch/ofppc/conf/files.ofppc   Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.ofppc,v 1.47 2017/12/18 15:53:39 skrll Exp $
+#      $NetBSD: files.ofppc,v 1.48 2021/05/12 23:22:33 thorpej Exp $
 #
 # NetBSD/ofppc configuration info
 #
@@ -77,6 +77,7 @@ file  arch/powerpc/pci/pciconf_ofmethod.c
 file   arch/powerpc/pci/pci_machdep_common.c   pci
 file   arch/powerpc/pci/pci_machdep_ofw.c      pci
 file    arch/powerpc/pci/pci_module.c          pci & modular
+file   dev/ofw/ofw_pci_subr.c                  pci
 
 device ofwpci: pcibus
 attach ofwpci at mainbus
diff -r 8753447de245 -r db32cb198225 sys/arch/sparc64/conf/files.sparc64
--- a/sys/arch/sparc64/conf/files.sparc64       Wed May 12 22:17:40 2021 +0000
+++ b/sys/arch/sparc64/conf/files.sparc64       Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sparc64,v 1.165 2021/04/25 13:22:49 thorpej Exp $
+#      $NetBSD: files.sparc64,v 1.166 2021/05/12 23:22:33 thorpej Exp $
 
 # @(#)files.sparc64    8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -44,6 +44,7 @@ file  arch/sparc64/dev/schizo.c               schizo
 file   arch/sparc64/dev/pyro.c                 pyro
 file   arch/sparc64/dev/vpci.c                 vpci
 file   arch/sparc64/dev/pci_machdep.c          psycho | schizo | pyro | vpci
+file   dev/ofw/ofw_pci_subr.c                  pci
 
 device jbusi2c: i2cexec, i2c_bitbang, i2cbus
 attach jbusi2c at mainbus
diff -r 8753447de245 -r db32cb198225 sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Wed May 12 22:17:40 2021 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.230 2021/05/11 03:43:30 thorpej Exp $ */
+/*     $NetBSD: autoconf.c,v 1.231 2021/05/12 23:22:33 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.230 2021/05/11 03:43:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.231 2021/05/12 23:22:33 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1025,18 +1025,6 @@ device_register(device_t dev, void *aux)
                 * Ignore mainbus0 itself, it certainly is not a boot
                 * device.
                 */
-       } else if (device_is_a(busdev, "pci")) {
-               struct pci_attach_args *pa = aux;
-
-               /*
-                * XXX PCI devices don't currently get their devhandles
-                * set when the PCI layer attaches them, so we need to
-                * do it here.  (It's not just us; ACPI has the same
-                * problem...)
-                */
-               ofnode = (int)PCITAG_NODE(pa->pa_tag);
-               devhandle = devhandle_from_of(ofnode);
-               device_set_handle(dev, devhandle);
        } else if (device_is_a(busdev, "iic")) {
                struct i2c_attach_args *ia = aux;
 
diff -r 8753447de245 -r db32cb198225 sys/arch/x86/acpi/acpi_machdep.c
--- a/sys/arch/x86/acpi/acpi_machdep.c  Wed May 12 22:17:40 2021 +0000
+++ b/sys/arch/x86/acpi/acpi_machdep.c  Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.31 2021/02/04 23:54:48 thorpej Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.32 2021/05/12 23:22:33 thorpej Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.31 2021/02/04 23:54:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.32 2021/05/12 23:22:33 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -603,8 +603,6 @@ device_acpi_register(device_t dev, void 
        if (parent == NULL)
                return;
 
-       acpi_device_register(dev, aux);
-
        device_is_vga = device_is_a(dev, "vga") || device_is_a(dev, "genfb");
        device_is_pci = device_is_a(parent, "pci");
        device_is_isa = device_is_a(parent, "isa");
diff -r 8753447de245 -r db32cb198225 sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Wed May 12 22:17:40 2021 +0000
+++ b/sys/dev/acpi/acpi.c       Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi.c,v 1.291 2021/04/24 23:36:52 thorpej Exp $       */
+/*     $NetBSD: acpi.c,v 1.292 2021/05/12 23:22:33 thorpej Exp $       */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.291 2021/04/24 23:36:52 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.292 2021/05/12 23:22:33 thorpej Exp $");
 
 #include "pci.h"
 #include "opt_acpi.h"
@@ -1146,43 +1146,6 @@ acpi_print(void *aux, const char *pnp)
 }
 
 /*
- * acpi_device_register --
- *     Called by the platform device_register() routine when
- *     attaching devices.
- */
-void
-acpi_device_register(device_t dev, void *v)
-{
-       /* All we do here is set the devhandle in the device_t. */
-       device_t parent = device_parent(dev);
-       ACPI_HANDLE hdl = NULL;
-
-       if (device_is_a(parent, "pci")) {
-               const struct pci_attach_args *pa = v;
-               struct acpi_devnode *ad;
-               u_int segment;
-
-#ifdef __HAVE_PCI_GET_SEGMENT
-               segment = pci_get_segment(pa->pa_pc);
-#else
-               segment = 0;
-#endif /* __HAVE_PCI_GET_SEGMENT */
-
-               ad = acpi_pcidev_find(segment,
-                   pa->pa_bus, pa->pa_device, pa->pa_function);
-               if (ad == NULL || (hdl = ad->ad_handle) == NULL) {
-                       aprint_debug_dev(dev, "no matching ACPI node\n");
-                       return;
-               }
-       } else {
-               return;
-       }
-       KASSERT(hdl != NULL);
-
-       device_set_handle(dev, devhandle_from_acpi(hdl));
-}
-
-/*
  * Notify.
  */
 static void
diff -r 8753447de245 -r db32cb198225 sys/dev/acpi/acpi_pci.c
--- a/sys/dev/acpi/acpi_pci.c   Wed May 12 22:17:40 2021 +0000
+++ b/sys/dev/acpi/acpi_pci.c   Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.30 2021/01/14 14:37:17 thorpej Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.31 2021/05/12 23:22:33 thorpej Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.30 2021/01/14 14:37:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.31 2021/05/12 23:22:33 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -542,3 +542,39 @@ acpi_pci_ignore_boot_config(ACPI_HANDLE 
 
        return ret;
 }
+
+/*
+ * acpi_pci_bus_get_child_devhandle:
+ *
+ *     Implements the "pci-bus-get-child-devhandle" device call for
+ *     ACPI device handles
+ */
+static int
+acpi_pci_bus_get_child_devhandle(device_t dev, devhandle_t call_handle, void *v)
+{
+       struct pci_bus_get_child_devhandle_args *args = v;
+       struct acpi_devnode *ad;
+       ACPI_HANDLE hdl;
+       int b, d, f;
+       u_int segment;
+
+#ifdef __HAVE_PCI_GET_SEGMENT
+       segment = pci_get_segment(args->pc);
+#else
+       segment = 0;
+#endif /* __HAVE_PCI_GET_SEGMENT */
+
+       pci_decompose_tag(args->pc, args->tag, &b, &d, &f);
+
+       ad = acpi_pcidev_find(segment, b, d, f);
+
+       if (ad != NULL && (hdl = ad->ad_handle) != NULL) {
+               /* Found it! */
+               args->devhandle = devhandle_from_acpi(hdl);
+               return 0;
+       }
+
+       return ENODEV;
+}
+ACPI_DEVICE_CALL_REGISTER("pci-bus-get-child-devhandle",
+                         acpi_pci_bus_get_child_devhandle)
diff -r 8753447de245 -r db32cb198225 sys/dev/acpi/acpivar.h
--- a/sys/dev/acpi/acpivar.h    Wed May 12 22:17:40 2021 +0000
+++ b/sys/dev/acpi/acpivar.h    Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpivar.h,v 1.85 2021/02/04 21:39:00 thorpej Exp $     */
+/*     $NetBSD: acpivar.h,v 1.86 2021/05/12 23:22:33 thorpej Exp $     */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -319,7 +319,6 @@ const struct device_compatible_entry *
                    const struct device_compatible_entry *);
 
 bool           acpi_device_present(ACPI_HANDLE);
-void           acpi_device_register(device_t, void *);
 
 int            acpi_reset(void);
 
diff -r 8753447de245 -r db32cb198225 sys/dev/ofw/files.ofw
--- a/sys/dev/ofw/files.ofw     Wed May 12 22:17:40 2021 +0000
+++ b/sys/dev/ofw/files.ofw     Wed May 12 23:22:32 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.ofw,v 1.16 2021/02/04 20:19:09 thorpej Exp $
+#      $NetBSD: files.ofw,v 1.17 2021/05/12 23:22:33 thorpej Exp $



Home | Main Index | Thread Index | Old Index