[U-Boot,20/22] x86: pci: Allow conditionally run VGA rom in S3

Message ID 1489674408-17498-21-git-send-email-bmeng.cn@gmail.com
State Accepted
Commit 68769ebcbc892c85e9a1ffff09bbc6e4877f2d1f
Delegated to: Bin Meng
Headers show

Commit Message

Bin Meng March 16, 2017, 2:26 p.m.
Introduce a new CONFIG_S3_VGA_ROM_RUN option so that U-Boot can
bypass executing VGA roms in S3.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 arch/x86/Kconfig      | 12 ++++++++++++
 drivers/pci/pci_rom.c | 14 ++++++++++++++
 2 files changed, 26 insertions(+)

Comments

Simon Glass March 21, 2017, 8:07 p.m. | #1
Hi,

On 16 March 2017 at 08:26, Bin Meng <bmeng.cn@gmail.com> wrote:
> Introduce a new CONFIG_S3_VGA_ROM_RUN option so that U-Boot can
> bypass executing VGA roms in S3.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  arch/x86/Kconfig      | 12 ++++++++++++
>  drivers/pci/pci_rom.c | 14 ++++++++++++++
>  2 files changed, 26 insertions(+)

Can this be handled at run-time, based on whether we have already run the ROM?

At present, at least on ivybridge (non-FSP), the ROM execution happens
when the device comes up. So do we actually need to run the ROM in S3
Or can we do it later by re-probing the driver?

Regards
Simon
Bin Meng April 13, 2017, 10 a.m. | #2
Hi Simon,

On Wed, Mar 22, 2017 at 4:07 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi,
>
> On 16 March 2017 at 08:26, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Introduce a new CONFIG_S3_VGA_ROM_RUN option so that U-Boot can
>> bypass executing VGA roms in S3.
>>
>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>> ---
>>
>>  arch/x86/Kconfig      | 12 ++++++++++++
>>  drivers/pci/pci_rom.c | 14 ++++++++++++++
>>  2 files changed, 26 insertions(+)
>
> Can this be handled at run-time, based on whether we have already run the ROM?
>

I am not sure if this is what you want:

1). If on previous cold boot, VGA ROM has been run. Then on next S3
boot, VGA ROM should also be run.
2). If on previous cold boot, VGA ROM has not been run. Then on next
S3 boot, VGA ROM should not be run.

So this is actually controlled by the CONFIG_VIDEO_VESA driver. But
this new Kconfig option aims to solve: even CONFIG_VIDEO_VESA driver
is used in a normal boot, U-Boot can still bypass the driver probe
(ROM execution) in an S3 boot to save some resume time.

> At present, at least on ivybridge (non-FSP), the ROM execution happens
> when the device comes up. So do we actually need to run the ROM in S3
> Or can we do it later by re-probing the driver?

Regards,
Bin
Simon Glass April 13, 2017, 1:32 p.m. | #3
Hi Bin,

On 13 April 2017 at 04:00, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Wed, Mar 22, 2017 at 4:07 AM, Simon Glass <sjg@chromium.org> wrote:
>> Hi,
>>
>> On 16 March 2017 at 08:26, Bin Meng <bmeng.cn@gmail.com> wrote:
>>> Introduce a new CONFIG_S3_VGA_ROM_RUN option so that U-Boot can
>>> bypass executing VGA roms in S3.
>>>
>>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>> ---
>>>
>>>  arch/x86/Kconfig      | 12 ++++++++++++
>>>  drivers/pci/pci_rom.c | 14 ++++++++++++++
>>>  2 files changed, 26 insertions(+)
>>
>> Can this be handled at run-time, based on whether we have already run the ROM?
>>
>
> I am not sure if this is what you want:
>
> 1). If on previous cold boot, VGA ROM has been run. Then on next S3
> boot, VGA ROM should also be run.
> 2). If on previous cold boot, VGA ROM has not been run. Then on next
> S3 boot, VGA ROM should not be run.
>
> So this is actually controlled by the CONFIG_VIDEO_VESA driver. But
> this new Kconfig option aims to solve: even CONFIG_VIDEO_VESA driver
> is used in a normal boot, U-Boot can still bypass the driver probe
> (ROM execution) in an S3 boot to save some resume time.
>
>> At present, at least on ivybridge (non-FSP), the ROM execution happens
>> when the device comes up. So do we actually need to run the ROM in S3
>> Or can we do it later by re-probing the driver?

With ivybridge the ROM runs when the video driver starts up. If there
is no 'vidconsole' in stdout then this won't happen until someone
does:

setenv stdout vidconsole,serial

or similar. I am not sure if this is possible with FSP machines.

However in practice we are generally returning from sleep to Linux, not U-Boot.

Do we have a way to know whether the ROM needs to be run (i.e. it was
run before)?

Regards,
Simon

Patch

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 95a65ff..29a1634 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -583,6 +583,18 @@  config HAVE_ACPI_RESUME
 	  is done, U-Boot needs to find out the wakeup vector provided by OSes
 	  and jump there.
 
+config S3_VGA_ROM_RUN
+	bool "Re-run VGA option ROMs on S3 resume"
+	depends on HAVE_ACPI_RESUME
+	default y if HAVE_ACPI_RESUME
+	help
+	  Execute VGA option ROMs in U-Boot when resuming from S3. Normally
+	  this is needed when graphics console is being used in the kernel.
+
+	  Turning it off can reduce some resume time, but be aware that your
+	  graphics console won't work without VGA options ROMs. Set it to N
+	  if your kernel is only on a serial console.
+
 config STACK_SIZE
 	hex
 	depends on HAVE_ACPI_RESUME
diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 57204c4..75fb093 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -35,8 +35,22 @@ 
 #include <video_fb.h>
 #include <linux/screen_info.h>
 
+#ifdef CONFIG_X86
+#include <asm/acpi_s3.h>
+DECLARE_GLOBAL_DATA_PTR;
+#endif
+
 __weak bool board_should_run_oprom(struct udevice *dev)
 {
+#if defined(CONFIG_X86) && defined(CONFIG_HAVE_ACPI_RESUME)
+	if (gd->arch.prev_sleep_state == ACPI_S3) {
+		if (IS_ENABLED(CONFIG_S3_VGA_ROM_RUN))
+			return true;
+		else
+			return false;
+	}
+#endif
+
 	return true;
 }