[PATCH 1/2] 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") Signed-off-by: Moritz Fischer moritzf@google.com --- drivers/nvme/nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index c39cd41aa3..ec45f831a3 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; }

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") Signed-off-by: Moritz Fischer moritzf@google.com --- drivers/nvme/nvme.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index ec45f831a3..59a139baa0 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; } }

On Wed, 22 Nov 2023 at 16:53, Moritz Fischer moritzf@google.com wrote:
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") Signed-off-by: Moritz Fischer moritzf@google.com
drivers/nvme/nvme.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Wed, 22 Nov 2023 at 16:52, Moritz Fischer moritzf@google.com wrote:
Return -EBUSY if controller is found busy rather than -ENOMEM
-ENODEV ?
and update the error message accordingly.
Fixes: 982388eaa991 ("nvme: Add NVM Express driver support") Signed-off-by: Moritz Fischer moritzf@google.com
drivers/nvme/nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index c39cd41aa3..ec45f831a3 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; }
-- 2.43.0.rc1.413.gea7ed67945-goog
participants (2)
-
Moritz Fischer
-
Simon Glass