[efi] Cache identified PCI root bridge I/O protocol handle

Reduce the overhead of PCI configuration space accesses (and the
verbosity of debug messages) by caching the identified PCI root bridge
I/O protocol handle for the most recently accessed PCI device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2026-02-04 13:42:21 +00:00
parent 30d162ddd1
commit c18d895704
+10 -4
View File
@@ -255,12 +255,18 @@ static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) {
*/ */
static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle,
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) { EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) {
struct pci_range tmp; static struct {
struct pci_range range;
EFI_HANDLE handle;
} cache;
int rc; int rc;
/* Find matching root bridge I/O protocol handle */ /* Find and cache matching root bridge I/O protocol handle, if any */
if ( ( rc = efipci_discover_any ( pci, &tmp, handle ) ) != 0 ) if ( ( pci->busdevfn - cache.range.start ) >= cache.range.count )
return rc; efipci_discover_any ( pci, &cache.range, &cache.handle );
if ( ! cache.handle )
return -ENOENT;
*handle = cache.handle;
/* Open PCI root bridge I/O protocol */ /* Open PCI root bridge I/O protocol */
if ( ( rc = efi_open ( *handle, &efi_pci_root_bridge_io_protocol_guid, if ( ( rc = efi_open ( *handle, &efi_pci_root_bridge_io_protocol_guid,