Some systems have a large number of NVMe controllers. Probing all of them requires an excessive amount of memory and with out-of-order probing this also means that the important ones will not be probed, because SeaBIOS runs out of memory.
Add an option to skip probing of NVMe devices, if there is no boot priority for them.
Signed-off-by: Julian Stecklina jsteckli@amazon.de --- src/Kconfig | 8 ++++++++ src/hw/nvme.c | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/Kconfig b/src/Kconfig index 55a87cb..ef8f458 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -233,6 +233,14 @@ menu "Hardware support" default y help Support for NVMe disk code. + config NVME_PROBE_BOOTDEVICES_ONLY + depends on NVME + bool "Only probe NVMe controllers with boot priority" + default n + help + Only enables NVMe controllers that have a boot priority + configured. This saves memory on systems with many non-bootable + NVMe devices.
config PS2PORT depends on KEYBOARD || MOUSE diff --git a/src/hw/nvme.c b/src/hw/nvme.c index e6d739d..5525f68 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -625,6 +625,16 @@ nvme_controller_setup(void *opaque) dprintf(2, "Failed to enable NVMe controller.\n"); }
+ +static int should_setup_controller(struct pci_device *pci) +{ +#ifdef NVME_PROBE_BOOTDEVICES_ONLY + return bootprio_find_pci_device(pci) >= 0; +#else + return 1; +#endif +} + // Locate and init NVMe controllers static void nvme_scan(void) @@ -640,7 +650,9 @@ nvme_scan(void) continue; }
- run_thread(nvme_controller_setup, pci); + if (should_setup_controller(pci)) { + run_thread(nvme_controller_setup, pci); + } } }
The current code is limited to having a single hard drive in the list of devices that are probed for boot. Allow adding multiple hard drives by adding each of them in the list of boot devices and passing along their ID.
Signed-off-by: Julian Stecklina jsteckli@amazon.de --- src/boot.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/boot.c b/src/boot.c index ff705fd..5392457 100644 --- a/src/boot.c +++ b/src/boot.c @@ -537,13 +537,11 @@ struct bev_s { }; static struct bev_s BEV[20]; static int BEVCount; -static int HaveHDBoot, HaveFDBoot; +static int HaveFDBoot;
static void add_bev(int type, u32 vector) { - if (type == IPL_TYPE_HARDDISK && HaveHDBoot++) - return; if (type == IPL_TYPE_FLOPPY && HaveFDBoot++) return; if (BEVCount >= ARRAY_SIZE(BEV)) @@ -578,7 +576,7 @@ bcv_prepboot(void) break; case IPL_TYPE_HARDDISK: map_hd_drive(pos->drive); - add_bev(IPL_TYPE_HARDDISK, 0); + add_bev(IPL_TYPE_HARDDISK, getDriveId(EXTTYPE_HD, pos->drive)); break; case IPL_TYPE_CDROM: map_cd_drive(pos->drive); @@ -737,8 +735,8 @@ do_boot(int seq_nr) boot_disk(0x00, CheckFloppySig); break; case IPL_TYPE_HARDDISK: - printf("Booting from Hard Disk...\n"); - boot_disk(0x80, 1); + printf("Booting from Hard Disk %u...\n", ie->vector); + boot_disk(EXTSTART_HD + ie->vector, 1); break; case IPL_TYPE_CDROM: boot_cdrom((void*)ie->vector);
Dear Julian,
On 07/06/18 11:32, Julian Stecklina wrote:
Some systems have a large number of NVMe controllers. Probing all of them requires an excessive amount of memory and with out-of-order probing this also means that the important ones will not be probed, because SeaBIOS runs out of memory.
Add an option to skip probing of NVMe devices, if there is no boot priority for them.
Signed-off-by: Julian Stecklina jsteckli@amazon.de
src/Kconfig | 8 ++++++++ src/hw/nvme.c | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/Kconfig b/src/Kconfig index 55a87cb..ef8f458 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -233,6 +233,14 @@ menu "Hardware support" default y help Support for NVMe disk code.
config NVME_PROBE_BOOTDEVICES_ONLY
depends on NVME
bool "Only probe NVMe controllers with boot priority"
default n
help
Only enables NVMe controllers that have a boot priority
configured. This saves memory on systems with many non-bootable
NVMe devices.
config PS2PORT depends on KEYBOARD || MOUSE
diff --git a/src/hw/nvme.c b/src/hw/nvme.c index e6d739d..5525f68 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -625,6 +625,16 @@ nvme_controller_setup(void *opaque) dprintf(2, "Failed to enable NVMe controller.\n"); }
+static int should_setup_controller(struct pci_device *pci) +{ +#ifdef NVME_PROBE_BOOTDEVICES_ONLY
return bootprio_find_pci_device(pci) >= 0;
+#else
return 1;
+#endif +}
// Locate and init NVMe controllers static void nvme_scan(void) @@ -640,7 +650,9 @@ nvme_scan(void) continue; }
run_thread(nvme_controller_setup, pci);
if (should_setup_controller(pci)) {
run_thread(nvme_controller_setup, pci);
}}
}
Thank you for the patch. Would it be better to make that a run-time option?
Kind regards,
Paul
On Fri, 2018-07-06 at 11:37 +0200, Paul Menzel wrote:
Thank you for the patch. Would it be better to make that a run-time option?
Can you elaborate? As long as there is a mechanism to limit the number of NVMe controllers probed, I'm happy to take any feedback here.
Regards, Julian Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B
Dear Julian,
On 07/06/18 12:15, Stecklina, Julian wrote:
On Fri, 2018-07-06 at 11:37 +0200, Paul Menzel wrote:
Thank you for the patch. Would it be better to make that a run-time option?
Can you elaborate? As long as there is a mechanism to limit the number of NVMe controllers probed, I'm happy to take any feedback here.
I hope the developer documentation [1] explains it.
SeaBIOS can read several configuration items at runtime. On coreboot the configuration comes from files located in CBFS. When SeaBIOS runs natively on QEMU the files are passed from QEMU via the fw_cfg interface.
Please ask if something is not clear.
Kind regards,
Paul
On Fri, 2018-07-06 at 12:19 +0200, Paul Menzel wrote:
On 07/06/18 12:15, Stecklina, Julian wrote:
On Fri, 2018-07-06 at 11:37 +0200, Paul Menzel wrote:
Thank you for the patch. Would it be better to make that a run-time option?
Can you elaborate? As long as there is a mechanism to limit the number of NVMe controllers probed, I'm happy to take any feedback here.
I hope the developer documentation [1] explains it.
Ah, fw-cfg / romfile_*. Sorry, it's Friday. ;) Sure, why not. I'll update the patch. Any preferences for a name?
Julian Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B
Dear Julian,
On 07/06/18 13:01, Stecklina, Julian wrote:
On Fri, 2018-07-06 at 12:19 +0200, Paul Menzel wrote:
On 07/06/18 12:15, Stecklina, Julian wrote:
On Fri, 2018-07-06 at 11:37 +0200, Paul Menzel wrote:
Thank you for the patch. Would it be better to make that a run-time option?
Can you elaborate? As long as there is a mechanism to limit the number of NVMe controllers probed, I'm happy to take any feedback here.
I hope the developer documentation [1] explains it.
Ah, fw-cfg / romfile_*. Sorry, it's Friday. ;) Sure, why not. I'll update the patch.
Before you put any work into it, maybe wait for Kevin to comment on this.
Any preferences for a name?
I do not have anything against descriptive names, so nvme_probe_bootdevices_only would be fine with me.
Kind regards,
Paul
run_thread(nvme_controller_setup, pci);
if (should_setup_controller(pci)) {
run_thread(nvme_controller_setup, pci);
}}
}
Thank you for the patch. Would it be better to make that a run-time option?
I think so.
You can ask for a strict boot order (qemu -boot strict=on). seabios will not try to boot any default boot entries then and only consider devices which are explicitly specified as boot device. It is implemented by a "HALT" boot order entry.
So, skipping non-boot devices in case a HALT entry is present looks pretty reasonable to me. And there is no reason to restrict that to nvme, a virtio-scsi controller could likewise initialize only the disk(s) which have an boot order entry.
cheers, Gerd