Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Oct 2023 00:41:44 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ec31ca0a48e4 - releng/14.0 - acpi_pcib: Trust decoded bus range from _CRS over _BBN
Message-ID:  <202310250041.39P0fik0005652@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/14.0 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=ec31ca0a48e4f2a6d4c406a1aacc6b44e5cbb7aa

commit ec31ca0a48e4f2a6d4c406a1aacc6b44e5cbb7aa
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-10-16 22:19:07 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-10-24 19:27:31 +0000

    acpi_pcib: Trust decoded bus range from _CRS over _BBN
    
    Currently if _BBN doesn't match the first bus in the decoded bus range
    from _CRS for a Host to PCI bridge, the driver fails to attach as a
    defensive measure.
    
    There is now firmware in the field where these do not match, and the
    _BBN values are clearly wrong, so rather than failing attach, trust
    the range from _CRS over _BBN.
    
    Co-authored-by: Justin Gibbs <gibbs@FreeBSD.org>
    Reported by:    gibbs
    Reviewed by:    imp (earlier version)
    Differential Revision:  https://reviews.freebsd.org/D42231
    
    (cherry picked from commit 22a6678b627b39ceb94f7323be1010e928d92494)
    (cherry picked from commit 76b37faac869aac7e889da3ac291207606a20e51)
    
    Approved by:    re (gjb)
---
 sys/dev/acpica/acpi_pcib_acpi.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c
index 0575b1d83bb1..02e3a0be5956 100644
--- a/sys/dev/acpica/acpi_pcib_acpi.c
+++ b/sys/dev/acpica/acpi_pcib_acpi.c
@@ -289,7 +289,8 @@ acpi_pcib_producer_handler(ACPI_RESOURCE *res, void *context)
 
 #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
 static int
-first_decoded_bus(struct acpi_hpcib_softc *sc, rman_res_t *startp)
+decoded_bus_range(struct acpi_hpcib_softc *sc, rman_res_t *startp,
+    rman_res_t *endp)
 {
 	struct resource_list_entry *rle;
 
@@ -297,6 +298,7 @@ first_decoded_bus(struct acpi_hpcib_softc *sc, rman_res_t *startp)
 	if (rle == NULL)
 		return (ENXIO);
 	*startp = rle->start;
+	*endp = rle->end;
 	return (0);
 }
 #endif
@@ -366,7 +368,7 @@ acpi_pcib_acpi_attach(device_t dev)
     u_int slot, func, busok;
 #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
     struct resource *bus_res;
-    rman_res_t start;
+    rman_res_t end, start;
     int rid;
 #endif
     int error, domain;
@@ -495,7 +497,7 @@ acpi_pcib_acpi_attach(device_t dev)
 	     * If we have a region of bus numbers, use the first
 	     * number for our bus.
 	     */
-	    if (first_decoded_bus(sc, &start) == 0)
+	    if (decoded_bus_range(sc, &start, &end) == 0)
 		    sc->ap_bus = start;
 	    else {
 		    rid = 0;
@@ -512,15 +514,21 @@ acpi_pcib_acpi_attach(device_t dev)
 	    }
     } else {
 	    /*
-	     * Require the bus number from _BBN to match the start of any
-	     * decoded range.
+	     * If there is a decoded bus range, assume the bus number is
+	     * the first value in the range.  Warn if _BBN doesn't match.
 	     */
-	    if (first_decoded_bus(sc, &start) == 0 && sc->ap_bus != start) {
-		    device_printf(dev,
-		"bus number %d does not match start of decoded range %ju\n",
-			sc->ap_bus, (uintmax_t)start);
-		    pcib_host_res_free(dev, &sc->ap_host_res);
-		    return (ENXIO);
+	    if (decoded_bus_range(sc, &start, &end) == 0) {
+		    if (sc->ap_bus != start) {
+			    device_printf(dev,
+				"WARNING: BIOS configured bus number (%d) is "
+				"not within decoded bus number range "
+				"(%ju - %ju).\n",
+				sc->ap_bus, (uintmax_t)start, (uintmax_t)end);
+			    device_printf(dev,
+				"Using range start (%ju) as bus number.\n",
+				(uintmax_t)start);
+			    sc->ap_bus = start;
+		    }
 	    }
     }
 #else



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310250041.39P0fik0005652>