[coreboot-gerrit] Patch set updated for coreboot: c591ec7 libpayload: PCI bus scan - Eliminate endless loop

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Wed Mar 18 19:24:48 CET 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8734

-gerrit

commit c591ec7fb88ebc1ea3bd30921c4b86c05228a31e
Author: Lee Leahy <leroy.p.leahy at intel.com>
Date:   Wed Dec 17 13:05:26 2014 -0800

    libpayload: PCI bus scan - Eliminate endless loop
    
    Don't attempt to scan the PCI bus if the bridge is disabled.  When
    the PCI bridge is not setup and enabled, it is possible for the
    secondary bus register to contain the value zero (0).  In this case
    the usb_scan_pci_bus routine gets into an infinite recursive loop
    which ends only when the heap or stack is exhausted.  This patch
    verifies that the PCI bridge is enabled by verifying that it is
    enabled for either memory or I/O operations.  When enabled, the
    secondary bus is scanned.
    
    BRANCH=none
    BUG=None
    TEST=Build and run on Samus
    
    Change-Id: I6826dc1d73b7c24729de5ac7c4d3534922ca73c5
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
    Original-Commit-Id: 63d04b47934761351b54c847a2692bdef81ce54f
    Original-Change-Id: I855240c52fa3eba841e6754816ebbcb824abc4cd
    Original-Signed-off-by: Lee Leahy <Leroy.P.Leahy at intel.com>
    Original-Reviewed-on: https://chromium-review.googlesource.com/236382
    Original-Commit-Queue: Leroy P Leahy <leroy.p.leahy at intel.com>
    Original-Tested-by: Leroy P Leahy <leroy.p.leahy at intel.com>
    Original-Reviewed-by: Giri P Mudusuru <giri.p.mudusuru at intel.com>
    Original-Reviewed-by: Duncan Laurie <dlaurie at chromium.org>
---
 payloads/libpayload/drivers/usb/usbinit.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/payloads/libpayload/drivers/usb/usbinit.c b/payloads/libpayload/drivers/usb/usbinit.c
index 6fb7d4b..4225c3f 100644
--- a/payloads/libpayload/drivers/usb/usbinit.c
+++ b/payloads/libpayload/drivers/usb/usbinit.c
@@ -146,9 +146,13 @@ static void usb_scan_pci_bus(int bus)
 			header_type = pci_read_config8(pci_device, REG_HEADER_TYPE);
 			/* If this is a bridge, scan the other side. */
 			if ((header_type & ~HEADER_TYPE_MULTIFUNCTION) ==
-					HEADER_TYPE_BRIDGE)
-				usb_scan_pci_bus(pci_read_config8(pci_device,
-							REG_SECONDARY_BUS));
+					HEADER_TYPE_BRIDGE) {
+				/* Verify that the bridge is enabled */
+				if ((pci_read_config16(pci_device, REG_COMMAND)
+						& 3) != 0)
+					usb_scan_pci_bus(pci_read_config8(
+						pci_device, REG_SECONDARY_BUS));
+			}
 			else
 				usb_controller_initialize(bus, dev, func);
 		}



More information about the coreboot-gerrit mailing list