From b18561801164492f63f6a87f6e77e6ebe5529dff Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Thu, 4 Jan 2024 17:12:22 +0000 Subject: iommu: dont fail silently When attempting to probe a device which has an associated IOMMU, if the IOMMU device can't be found (no driver, disabled driver, driver failed to probe, etc) then we currently fail to probe the device with no discernable error. If we fail to hook the device up to its IOMMU, we should make sure that the user knows about it. Write some better error messages for dev_iommu_enable() to facilitate this. Signed-off-by: Caleb Connolly --- drivers/iommu/iommu-uclass.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/iommu/iommu-uclass.c b/drivers/iommu/iommu-uclass.c index 6babc0e3a67..dff3239cccb 100644 --- a/drivers/iommu/iommu-uclass.c +++ b/drivers/iommu/iommu-uclass.c @@ -86,16 +86,16 @@ int dev_iommu_enable(struct udevice *dev) ret = dev_read_phandle_with_args(dev, "iommus", "#iommu-cells", 0, i, &args); if (ret) { - debug("%s: dev_read_phandle_with_args failed: %d\n", - __func__, ret); + log_err("%s: Failed to parse 'iommus' property for '%s': %d\n", + __func__, dev->name, ret); return ret; } ret = uclass_get_device_by_ofnode(UCLASS_IOMMU, args.node, &dev_iommu); if (ret) { - debug("%s: uclass_get_device_by_ofnode failed: %d\n", - __func__, ret); + log_err("%s: Failed to find IOMMU device for '%s': %d\n", + __func__, dev->name, ret); return ret; } dev->iommu = dev_iommu; @@ -106,8 +106,11 @@ int dev_iommu_enable(struct udevice *dev) ops = device_get_ops(dev->iommu); if (ops && ops->connect) { ret = ops->connect(dev); - if (ret) + if (ret) { + log_err("%s: Failed to connect '%s' to IOMMU '%s': %d\n", + __func__, dev->name, dev->iommu->name, ret); return ret; + } } } -- cgit v1.3.1 From 040834703497bafb81fce88a92d8e54c8837fcaa Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Wed, 10 Jan 2024 04:59:02 +0000 Subject: drivers: pci: Fix dm_pci_map_bar() to support 64b BARs This enables 64b BARs if CONFIG_SYS_PCI_64BIT is enabled. Reviewed-by: Philip Oberfichtner Reviewed-by: Simon Glass Signed-off-by: Moritz Fischer --- drivers/pci/pci-uclass.c | 11 +++++++++++ include/pci.h | 1 + 2 files changed, 12 insertions(+) (limited to 'drivers') diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index e0d01f6a85d..1a48256de03 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1611,6 +1611,17 @@ void *dm_pci_map_bar(struct udevice *dev, int bar, size_t offset, size_t len, dm_pci_read_config32(udev, bar, &bar_response); pci_bus_addr = (pci_addr_t)(bar_response & ~0xf); + /* This has a lot of baked in assumptions, but essentially tries + * to mirror the behavior of BAR assignment for 64 Bit enabled + * hosts and 64 bit placeable BARs in the auto assign code. + */ +#if defined(CONFIG_SYS_PCI_64BIT) + if (bar_response & PCI_BASE_ADDRESS_MEM_TYPE_64) { + dm_pci_read_config32(udev, bar + 4, &bar_response); + pci_bus_addr |= (pci_addr_t)bar_response << 32; + } +#endif /* CONFIG_SYS_PCI_64BIT */ + if (~((pci_addr_t)0) - pci_bus_addr < offset) return NULL; diff --git a/include/pci.h b/include/pci.h index 2f5eb30b83c..aad233769a3 100644 --- a/include/pci.h +++ b/include/pci.h @@ -1354,6 +1354,7 @@ pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t addr, size_t len, * type 1 functions. * Can also be used on type 0 functions that support Enhanced Allocation for * 32b/64b BARs. Note that duplicate BEI entries are not supported. + * Can also be used on 64b bars on type 0 functions. * * @dev: Device to check * @bar: Bar register offset (PCI_BASE_ADDRESS_...) -- cgit v1.3.1 From 5775b0f78774ceb352ca73c4a070d99d1c6dc52b Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Wed, 10 Jan 2024 05:04:47 +0000 Subject: nvme: Fix error code and log to indicate busy Return -EBUSY if controller is found busy rather than -ENOMEM and update the error message accordingly. Fixes: 982388eaa991 ("nvme: Add NVM Express driver support") Reviewed-by: Simon Glass Signed-off-by: Moritz Fischer --- drivers/nvme/nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index c39cd41aa38..ec45f831a36 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -835,8 +835,8 @@ int nvme_init(struct udevice *udev) ndev->udev = udev; INIT_LIST_HEAD(&ndev->namespaces); if (readl(&ndev->bar->csts) == -1) { - ret = -ENODEV; - printf("Error: %s: Out of memory!\n", udev->name); + ret = -EBUSY; + printf("Error: %s: Controller not ready!\n", udev->name); goto free_nvme; } -- cgit v1.3.1 From 85946d69d6f5a309564e7e89386cfcaff75d0b86 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Wed, 10 Jan 2024 05:04:48 +0000 Subject: nvme: Update nvme_scan_namespace to keep trying on busy A busy controller shouldn't be game-over for all controllers, so keep trying on hitting -EBUSY. This change brings the actual behavior of the routine in line with what the descriptions says. Fixes: 982388eaa991 ("nvme: Add NVM Express driver support") Reviewed-by: Simon Glass Signed-off-by: Moritz Fischer --- drivers/nvme/nvme.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index ec45f831a36..59a139baa0b 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -695,7 +695,9 @@ int nvme_scan_namespace(void) if (ret) { log_err("Failed to probe '%s': err=%dE\n", dev->name, ret); - return ret; + /* Bail if we ran out of memory, else keep trying */ + if (ret != -EBUSY) + return ret; } } -- cgit v1.3.1