]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
nvme: Provide more useful debugging messages
authorSimon Glass <sjg@chromium.org>
Sun, 16 Jul 2023 03:38:54 +0000 (21:38 -0600)
committerBin Meng <bmeng@tinylab.org>
Mon, 17 Jul 2023 09:12:26 +0000 (17:12 +0800)
When scanning fails it is useful to be able to decode what went wrong. Add
some debugging for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/nvme/nvme.c

index 74e7a5b0110939b4e40a4efd0c650475f47cf26f..a7add66ab4d139640affb394b21c5493eba32811 100644 (file)
@@ -578,17 +578,22 @@ static int nvme_set_queue_count(struct nvme_dev *dev, int count)
        return min(result & 0xffff, result >> 16) + 1;
 }
 
-static void nvme_create_io_queues(struct nvme_dev *dev)
+static int nvme_create_io_queues(struct nvme_dev *dev)
 {
        unsigned int i;
+       int ret;
 
        for (i = dev->queue_count; i <= dev->max_qid; i++)
                if (!nvme_alloc_queue(dev, i, dev->q_depth))
-                       break;
+                       return log_msg_ret("all", -ENOMEM);
 
-       for (i = dev->online_queues; i <= dev->queue_count - 1; i++)
-               if (nvme_create_queue(dev->queues[i], i))
-                       break;
+       for (i = dev->online_queues; i <= dev->queue_count - 1; i++) {
+               ret = nvme_create_queue(dev->queues[i], i);
+               if (ret)
+                       return log_msg_ret("cre", ret);
+       }
+
+       return 0;
 }
 
 static int nvme_setup_io_queues(struct nvme_dev *dev)
@@ -598,14 +603,18 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
 
        nr_io_queues = 1;
        result = nvme_set_queue_count(dev, nr_io_queues);
-       if (result <= 0)
+       if (result <= 0) {
+               log_debug("Cannot set queue count (err=%dE)\n", result);
                return result;
+       }
 
        dev->max_qid = nr_io_queues;
 
        /* Free previously allocated queues */
        nvme_free_queues(dev, nr_io_queues + 1);
-       nvme_create_io_queues(dev);
+       result = nvme_create_io_queues(dev);
+       if (result)
+               return result;
 
        return 0;
 }
@@ -683,8 +692,11 @@ int nvme_scan_namespace(void)
 
        uclass_foreach_dev(dev, uc) {
                ret = device_probe(dev);
-               if (ret)
+               if (ret) {
+                       log_err("Failed to probe '%s': err=%dE\n", dev->name,
+                               ret);
                        return ret;
+               }
        }
 
        return 0;
@@ -842,8 +854,10 @@ int nvme_init(struct udevice *udev)
        ndev->dbs = ((void __iomem *)ndev->bar) + 4096;
 
        ret = nvme_configure_admin_queue(ndev);
-       if (ret)
+       if (ret) {
+               log_debug("Unable to configure admin queue (err=%dE)\n", ret);
                goto free_queue;
+       }
 
        /* Allocate after the page size is known */
        ndev->prp_pool = memalign(ndev->page_size, MAX_PRP_POOL);
@@ -855,8 +869,10 @@ int nvme_init(struct udevice *udev)
        ndev->prp_entry_num = MAX_PRP_POOL >> 3;
 
        ret = nvme_setup_io_queues(ndev);
-       if (ret)
+       if (ret) {
+               log_debug("Unable to setup I/O queues(err=%dE)\n", ret);
                goto free_queue;
+       }
 
        nvme_get_info_from_identify(ndev);