Module Name: src Committed By: thorpej Date: Wed May 12 22:17:40 UTC 2021
Modified Files: src/sys/arch/x86/x86: mpacpi.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/sys/arch/x86/x86/mpacpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/x86/mpacpi.c diff -u src/sys/arch/x86/x86/mpacpi.c:1.105 src/sys/arch/x86/x86/mpacpi.c:1.106 --- src/sys/arch/x86/x86/mpacpi.c:1.105 Sat Apr 24 23:36:51 2021 +++ src/sys/arch/x86/x86/mpacpi.c Wed May 12 22:17:40 2021 @@ -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;