[coreboot-gerrit] New patch to review for coreboot: 603548f device: provide option to always load PCI option roms

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Sun Apr 27 21:34:50 CEST 2014


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5594

-gerrit

commit 603548f058dcc580e48e32c88d3e8af40ee4443f
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Tue Mar 4 10:21:31 2014 -0600

    device: provide option to always load PCI option roms
    
    Certain kernel drivers require the presence of option rom
    contents because the board's static configuration information
    is located within the blob. Therefore, allow a chipset/board to
    instruct the pci device handling code to always load but not
    necessarily run the option rom.
    
    BUG=chrome-os-partner:25885
    BRANCH=baytrail
    TEST=Both enabling and not enabling this option shows expected behavior.
    
    Change-Id: Ib0f65ffaf1a861b543573a062c291f4ba491ffe0
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
    Reviewed-on: https://chromium-review.googlesource.com/188720
    Reviewed-by: Duncan Laurie <dlaurie at chromium.org>
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/device/Kconfig      | 12 ++++++++++++
 src/device/pci_device.c | 50 +++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/src/device/Kconfig b/src/device/Kconfig
index 932b4de..ab7a577 100644
--- a/src/device/Kconfig
+++ b/src/device/Kconfig
@@ -70,6 +70,18 @@ config S3_VGA_ROM_RUN
 
 	  If unsure, say N when using SeaBIOS as payload, Y otherwise.
 
+config ALWAYS_LOAD_OPROM
+	def_bool n
+	depends on VGA_ROM_RUN
+	help
+	  Always load option roms if any are found. The decision to run
+	  the rom is still determined at runtime, but the distinction
+	  between loading and not running comes into play for CHROMEOS.
+
+	  An example where this is required is that VBT (video bios tables)
+	  are needed for the kernel's display driver to know how a piece of
+	  hardware is configured to be used.
+
 config ON_DEVICE_ROM_RUN
 	bool "Run Option ROMs on PCI devices"
 	default n if PAYLOAD_SEABIOS
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index 24d0552..d5f150c 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -23,6 +23,7 @@
  * Copyright 1997 -- 1999 Martin Mares <mj at atrey.karlin.mff.cuni.cz>
  */
 
+#include <kconfig.h>
 #include <console/console.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -659,15 +660,13 @@ void pci_dev_set_subsystem(struct device *dev, unsigned vendor, unsigned device)
 			   ((device & 0xffff) << 16) | (vendor & 0xffff));
 }
 
-/** Default handler: only runs the relevant PCI BIOS. */
-void pci_dev_init(struct device *dev)
-{
 #if CONFIG_VGA_ROM_RUN
-	struct rom_header *rom, *ram;
+static int should_run_oprom(struct device *dev)
+{
+	static int should_run = -1;
 
-	/* Only execute VGA ROMs. */
-	if (((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA))
-		return;
+	if (should_run >= 0)
+		return should_run;
 
 #if CONFIG_CHROMEOS
 	/* In ChromeOS we want to boot blazingly fast. Therefore
@@ -676,19 +675,47 @@ void pci_dev_init(struct device *dev)
 	 */
 	if (!developer_mode_enabled() && !recovery_mode_enabled() &&
 	    !vboot_wants_oprom()) {
-		printk(BIOS_DEBUG, "Not loading VGA Option ROM\n");
-		return;
+		printk(BIOS_DEBUG, "Not running VGA Option ROM\n");
+		should_run = 0;
+		return should_run;
 	}
 #endif
+	should_run = 1;
+
+	return should_run;
+}
 
+static int should_load_oprom(struct device *dev)
+{
 #if CONFIG_HAVE_ACPI_RESUME && !CONFIG_S3_VGA_ROM_RUN
 	/* If S3_VGA_ROM_RUN is disabled, skip running VGA option
 	 * ROMs when coming out of an S3 resume.
 	 */
 	if ((acpi_slp_type == 3) &&
 		((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA))
-		return;
+		return 0;
 #endif
+	if (IS_ENABLED(CONFIG_ALWAYS_LOAD_OPROM))
+		return 1;
+	if (should_run_oprom(dev))
+		return 1;
+
+	return 0;
+}
+#endif /* CONFIG_VGA_ROM_RUN */
+
+/** Default handler: only runs the relevant PCI BIOS. */
+void pci_dev_init(struct device *dev)
+{
+#if CONFIG_VGA_ROM_RUN
+	struct rom_header *rom, *ram;
+
+	/* Only execute VGA ROMs. */
+	if (((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA))
+		return;
+
+	if (!should_load_oprom(dev))
+		return;
 
 	rom = pci_rom_probe(dev);
 	if (rom == NULL)
@@ -698,6 +725,9 @@ void pci_dev_init(struct device *dev)
 	if (ram == NULL)
 		return;
 
+	if (!should_run_oprom(dev))
+		return;
+
 	run_bios(dev, (unsigned long)ram);
 	dev->oprom_is_loaded = 1;
 	printk(BIOS_DEBUG, "VGA Option ROM has been loaded\n");



More information about the coreboot-gerrit mailing list