Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 In mpacpi_pci_attach_hook(), set the device...
details: https://anonhg.NetBSD.org/src/rev/8753447de245
branches: trunk
changeset: 379123:8753447de245
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed May 12 22:17:40 2021 +0000
description:
In mpacpi_pci_attach_hook(), set the device handle of the PCI bus instance
to the associated ACPI handle if a device handle is not already set.
XXX This is a mess. Sure would be nice if it looked / worked more like
XXX the ARM code.
diffstat:
sys/arch/x86/x86/mpacpi.c | 36 +++++++++++++++++++++++++++++++-----
1 files changed, 31 insertions(+), 5 deletions(-)
diffs (84 lines):
diff -r 03ff6190b257 -r 8753447de245 sys/arch/x86/x86/mpacpi.c
--- a/sys/arch/x86/x86/mpacpi.c Wed May 12 21:56:13 2021 +0000
+++ b/sys/arch/x86/x86/mpacpi.c Wed May 12 22:17:40 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpacpi.c,v 1.105 2021/04/24 23:36:51 thorpej Exp $ */
+/* $NetBSD: mpacpi.c,v 1.106 2021/05/12 22:17:40 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.105 2021/04/24 23:36:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.106 2021/05/12 22:17:40 thorpej Exp $");
#include "acpica.h"
#include "opt_acpi.h"
@@ -90,7 +90,7 @@ ACPI_MODULE_NAME ("mpacpi")
#if NPCI > 0
struct mpacpi_pcibus {
TAILQ_ENTRY(mpacpi_pcibus) mpr_list;
- ACPI_HANDLE mpr_handle; /* Same thing really, but.. */
+ devhandle_t mpr_devhandle;
ACPI_BUFFER mpr_buf; /* preserve _PRT */
int mpr_seg; /* PCI segment number */
int mpr_bus; /* PCI bus number */
@@ -509,7 +509,7 @@ mpacpi_pci_foundbus(struct acpi_devnode
}
mpr = kmem_zalloc(sizeof(struct mpacpi_pcibus), KM_SLEEP);
- mpr->mpr_handle = ad->ad_handle;
+ mpr->mpr_devhandle = devhandle_from_acpi(ad->ad_handle);
mpr->mpr_buf = buf;
mpr->mpr_seg = ad->ad_pciinfo->ap_segment;
mpr->mpr_bus = ad->ad_pciinfo->ap_downbus;
@@ -953,6 +953,29 @@ mpacpi_find_interrupts(void *self)
#if NPCI > 0
+static void
+mpacpi_set_devhandle(device_t self, struct pcibus_attach_args *pba)
+{
+ devhandle_t devhandle = device_handle(self);
+ struct mpacpi_pcibus *mpr;
+
+ /* If we already have a valid handle, eject now. */
+ if (devhandle_type(devhandle) != DEVHANDLE_TYPE_INVALID) {
+ return;
+ }
+
+ TAILQ_FOREACH(mpr, &mpacpi_pcibusses, mpr_list) {
+ /* XXX Assuming always segment 0 on x86. */
+ if (mpr->mpr_seg != 0) {
+ continue;
+ }
+ if (mpr->mpr_bus == pba->pba_bus) {
+ device_set_handle(self, mpr->mpr_devhandle);
+ return;
+ }
+ }
+}
+
int
mpacpi_pci_attach_hook(device_t parent, device_t self,
struct pcibus_attach_args *pba)
@@ -984,13 +1007,16 @@ mpacpi_pci_attach_hook(device_t parent,
if (mpb->mb_name != NULL) {
if (strcmp(mpb->mb_name, "pci"))
return EINVAL;
- } else
+ } else {
/*
* As we cannot find all PCI-to-PCI bridge in
* mpacpi_find_pcibusses, some of the MP_busses may remain
* uninitialized.
*/
mpb->mb_name = "pci";
+ }
+
+ mpacpi_set_devhandle(self, pba);
mpb->mb_dev = self;
mpb->mb_pci_bridge_tag = pba->pba_bridgetag;
Home |
Main Index |
Thread Index |
Old Index