Module Name:    src
Committed By:   jmcneill
Date:           Fri May  8 14:44:24 UTC 2020

Modified Files:
        src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Try to get the starting bus number from _CRS before falling back to _BBN.
There are apparently cases where the first bus in _CRS does not match the
value of _BBN, and the consensus is that _CRS should take precedence.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/acpi/acpipchb.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/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.17 src/sys/arch/arm/acpi/acpipchb.c:1.18
--- src/sys/arch/arm/acpi/acpipchb.c:1.17	Tue Jan 21 11:24:47 2020
+++ src/sys/arch/arm/acpi/acpipchb.c	Fri May  8 14:44:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.17 2020/01/21 11:24:47 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.18 2020/05/08 14:44:23 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.17 2020/01/21 11:24:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.18 2020/05/08 14:44:23 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -123,13 +123,22 @@ acpipchb_attach(device_t parent, device_
 	struct acpi_attach_args *aa = aux;
 	struct pcibus_attach_args pba;
 	ACPI_INTEGER seg;
+	uint16_t bus_start;
 
 	sc->sc_dev = self;
 	sc->sc_memt = aa->aa_memt;
 	sc->sc_handle = aa->aa_node->ad_handle;
 
-	if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_BBN", &sc->sc_bus)))
-		sc->sc_bus = 0;
+	/*
+	 * First try to derive the base bus number from _CRS. If that fails,
+	 * try _BBN. If that fails too, assume bus 0.
+	 */
+	if (ACPI_SUCCESS(acpi_pcidev_pciroot_bus(sc->sc_handle, &bus_start))) {
+		sc->sc_bus = bus_start;
+	} else {
+		if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_BBN", &sc->sc_bus)))
+			sc->sc_bus = 0;
+	}
 
 	if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", &seg)))
 		seg = 0;

Reply via email to