From 583d37d192d92c5e92efa68b1d97f8ecdef71c47 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sun, 12 Nov 2023 10:57:21 +0000 Subject: [PATCH] bootstd: efi: Initialize PCI to discover network controllers Boards like Radxa ROCK 5 Model B and NanoPi R5C require PCI to be initialized in order to discover their onboard network controllers. During standard boot, PCI gets initialized after faster boot media have been evaluated. However when an EFI bootflow is run from a fast boot media, PCI initialization may not have happended and as a result no network device is exposed to EFI. Fix this by initializing PCI during EFI bootflow when no ethernet device can be found. This allows chainloading e.g. iPXE on ROCK 5B and NanoPi R5C without having to enable PCI_INIT_R. Enabling of PCI_INIT_R has the side affect of slowing down booting from faster boot media, by adding ~1 second off boot delay for each unocupied M.2 slot. Signed-off-by: Jonas Karlman --- boot/bootmeth_efi.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -307,6 +308,14 @@ static int distro_efi_read_bootflow(stru { int ret; + /* init PCI first since this is often used to provide Ehternet */ + if (IS_ENABLED(CONFIG_NETDEVICES) && IS_ENABLED(CONFIG_PCI) && + !eth_get_dev()) { + ret = pci_init(); + if (ret) + return log_msg_ret("pci", ret); + } + /* * bootmeth_efi doesn't allocate any buffer neither for blk nor net device * set flag to avoid freeing static buffer.