Skip to content

Commit

Permalink
[efi] Standardise PCI debug messages
Browse files Browse the repository at this point in the history
Use the PCI bus:dev.fn address in debug messages, falling back to the
EFI handle name only if we do not yet have enough information to
determine the bus:dev.fn address.

Include the vendor and device IDs in debug messages when no suitable
driver is found, to match the diagnostics available in a BIOS
environment.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed May 1, 2017
1 parent b91cc98 commit 17887f8
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions src/interface/efi/efi_pci.c
Expand Up @@ -87,8 +87,8 @@ static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
&efi_pci_root_bridge_io_protocol_guid,
NULL, &num_handles, &handles ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( pci, "EFIPCI cannot locate root bridges: %s\n",
strerror ( rc ) );
DBGC ( pci, "EFIPCI " PCI_FMT " cannot locate root bridges: "
"%s\n", PCI_ARGS ( pci ), strerror ( rc ) );
goto err_locate;
}

Expand All @@ -100,8 +100,9 @@ static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
&u.interface, efi_image_handle, *handle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( pci, "EFIPCI cannot open %s: %s\n",
efi_handle_name ( *handle ), strerror ( rc ) );
DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n",
PCI_ARGS ( pci ), efi_handle_name ( *handle ),
strerror ( rc ) );
continue;
}
if ( u.root->SegmentNumber == PCI_SEG ( pci->busdevfn ) ) {
Expand All @@ -113,7 +114,7 @@ static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
&efi_pci_root_bridge_io_protocol_guid,
efi_image_handle, *handle );
}
DBGC ( pci, "EFIPCI found no root bridge for " PCI_FMT "\n",
DBGC ( pci, "EFIPCI " PCI_FMT " found no root bridge\n",
PCI_ARGS ( pci ) );
rc = -ENOENT;

Expand Down Expand Up @@ -163,9 +164,9 @@ int efipci_read ( struct pci_device *pci, unsigned long location,
efipci_address ( pci, location ), 1,
value ) ) != 0 ) {
rc = -EEFI ( efirc );
DBG ( "EFIPCI config read from " PCI_FMT " offset %02lx "
"failed: %s\n", PCI_ARGS ( pci ),
EFIPCI_OFFSET ( location ), strerror ( rc ) );
DBGC ( pci, "EFIPCI " PCI_FMT " config read from offset %02lx "
"failed: %s\n", PCI_ARGS ( pci ),
EFIPCI_OFFSET ( location ), strerror ( rc ) );
goto err_read;
}

Expand Down Expand Up @@ -201,9 +202,9 @@ int efipci_write ( struct pci_device *pci, unsigned long location,
efipci_address ( pci, location ), 1,
&value ) ) != 0 ) {
rc = -EEFI ( efirc );
DBG ( "EFIPCI config write to " PCI_FMT " offset %02lx "
"failed: %s\n", PCI_ARGS ( pci ),
EFIPCI_OFFSET ( location ), strerror ( rc ) );
DBGC ( pci, "EFIPCI " PCI_FMT " config write to offset %02lx "
"failed: %s\n", PCI_ARGS ( pci ),
EFIPCI_OFFSET ( location ), strerror ( rc ) );
goto err_write;
}

Expand Down Expand Up @@ -268,10 +269,10 @@ int efipci_open ( EFI_HANDLE device, UINT32 attributes,
efi_handle_name ( device ), strerror ( rc ) );
goto err_get_location;
}
DBGC2 ( device, "EFIPCI %s is PCI %04lx:%02lx:%02lx.%lx\n",
efi_handle_name ( device ), ( ( unsigned long ) pci_segment ),
( ( unsigned long ) pci_bus ), ( ( unsigned long ) pci_dev ),
( ( unsigned long ) pci_fn ) );
busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn );
pci_init ( pci, busdevfn );
DBGCP ( device, "EFIPCI " PCI_FMT " is %s\n",
PCI_ARGS ( pci ), efi_handle_name ( device ) );

/* Try to enable I/O cycles, memory cycles, and bus mastering.
* Some platforms will 'helpfully' report errors if these bits
Expand All @@ -290,11 +291,10 @@ int efipci_open ( EFI_HANDLE device, UINT32 attributes,
EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, NULL );

/* Populate PCI device */
busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn );
pci_init ( pci, busdevfn );
if ( ( rc = pci_read_config ( pci ) ) != 0 ) {
DBGC ( device, "EFIPCI %s cannot read PCI configuration: %s\n",
efi_handle_name ( device ), strerror ( rc ) );
DBGC ( device, "EFIPCI " PCI_FMT " cannot read PCI "
"configuration: %s\n",
PCI_ARGS ( pci ), strerror ( rc ) );
goto err_pci_read_config;
}

Expand Down Expand Up @@ -364,12 +364,14 @@ static int efipci_supported ( EFI_HANDLE device ) {

/* Look for a driver */
if ( ( rc = pci_find_driver ( &pci ) ) != 0 ) {
DBGCP ( device, "EFIPCI %s has no driver\n",
efi_handle_name ( device ) );
DBGC ( device, "EFIPCI " PCI_FMT " (%04x:%04x class %06x) "
"has no driver\n", PCI_ARGS ( &pci ), pci.vendor,
pci.device, pci.class );
return rc;
}
DBGC ( device, "EFIPCI %s has driver \"%s\"\n",
efi_handle_name ( device ), pci.id->name );
DBGC ( device, "EFIPCI " PCI_FMT " (%04x:%04x class %06x) has driver "
"\"%s\"\n", PCI_ARGS ( &pci ), pci.vendor, pci.device,
pci.class, pci.id->name );

return 0;
}
Expand Down Expand Up @@ -404,8 +406,8 @@ static int efipci_start ( struct efi_device *efidev ) {

/* Find driver */
if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
DBGC ( device, "EFIPCI %s has no driver\n",
efi_handle_name ( device ) );
DBGC ( device, "EFIPCI " PCI_FMT " has no driver\n",
PCI_ARGS ( pci ) );
goto err_find_driver;
}

Expand All @@ -415,13 +417,13 @@ static int efipci_start ( struct efi_device *efidev ) {

/* Probe driver */
if ( ( rc = pci_probe ( pci ) ) != 0 ) {
DBGC ( device, "EFIPCI %s could not probe driver \"%s\": %s\n",
efi_handle_name ( device ), pci->id->name,
DBGC ( device, "EFIPCI " PCI_FMT " could not probe driver "
"\"%s\": %s\n", PCI_ARGS ( pci ), pci->id->name,
strerror ( rc ) );
goto err_probe;
}
DBGC ( device, "EFIPCI %s using driver \"%s\"\n",
efi_handle_name ( device ), pci->id->name );
DBGC ( device, "EFIPCI " PCI_FMT " using driver \"%s\"\n",
PCI_ARGS ( pci ), pci->id->name );

efidev_set_drvdata ( efidev, pci );
return 0;
Expand Down

0 comments on commit 17887f8

Please sign in to comment.