virtio/pci: print PCI addr on init failure

This gives user an information of which
device caused an error.

Change-Id: I47eb1c1b6c9adc36a9c26b4c36b6f6bc1e467ca7
Suggested-by: Daniel Verkamp <daniel.verkamp@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/388195
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-11-20 15:51:31 +01:00 committed by Jim Harris
parent e7885a9a05
commit 48245f4bb8

View File

@ -428,10 +428,19 @@ virtio_pci_dev_probe(struct spdk_pci_device *pci_dev, virtio_pci_create_cb enum_
uint64_t bar_paddr, bar_len;
int rc;
unsigned i;
char bdf[32];
struct spdk_pci_addr addr;
addr = spdk_pci_device_get_addr(pci_dev);
rc = spdk_pci_addr_fmt(bdf, sizeof(bdf), &addr);
if (rc != 0) {
SPDK_ERRLOG("Ignoring a device with non-parseable PCI address\n");
return -1;
}
hw = calloc(1, sizeof(*hw));
if (hw == NULL) {
SPDK_ERRLOG("calloc failed\n");
SPDK_ERRLOG("%s: calloc failed\n", bdf);
return -1;
}
@ -441,7 +450,7 @@ virtio_pci_dev_probe(struct spdk_pci_device *pci_dev, virtio_pci_create_cb enum_
rc = spdk_pci_device_map_bar(pci_dev, i, (void *) &bar_vaddr, &bar_paddr,
&bar_len);
if (rc != 0) {
SPDK_ERRLOG("failed to memmap PCI BAR %u\n", i);
SPDK_ERRLOG("%s: failed to memmap PCI BAR %u\n", bdf, i);
free_virtio_hw(hw);
return -1;
}
@ -454,7 +463,7 @@ virtio_pci_dev_probe(struct spdk_pci_device *pci_dev, virtio_pci_create_cb enum_
* Legacy devices are not supported.
*/
if (virtio_read_caps(hw) != 0) {
SPDK_NOTICELOG("Ignoring legacy PCI device.\n");
SPDK_NOTICELOG("Ignoring legacy PCI device at %s\n", bdf);
free_virtio_hw(hw);
return -1;
}