From patchwork Thu May 4 22:58:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1777172 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=NZedVawR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QC8Wy29Xpz214G for ; Fri, 5 May 2023 09:04:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 292FC86116; Fri, 5 May 2023 00:59:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="NZedVawR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D704786044; Fri, 5 May 2023 00:59:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C5EE585FBD for ; Fri, 5 May 2023 00:59:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-76983b8a1f5so77248139f.0 for ; Thu, 04 May 2023 15:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683241142; x=1685833142; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KTsQMZ9vOwnQ6v/708vlGOTcPu1tNvVWca8ekXcbLSY=; b=NZedVawRdMRbl6RROgLTF3xTU2qk0oey44HZlHKTz2tGeKii7LMKQs+v9TVsy94FaH KPgUSHj2gnnK6x2pIz9urIw9Qdlz26yWwwWRGmOGRjFGKqE+qlQYTVebFvPNAX5kx29c PNGl/pwpuZzCRaxhHlLnCSfDGq63l0cMPiDFo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683241142; x=1685833142; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KTsQMZ9vOwnQ6v/708vlGOTcPu1tNvVWca8ekXcbLSY=; b=d2xs+FwOZfAX+PTDlZdjkb9hgFat1RlrzP2XnGAPx+5XUjyF8x7UuoErbgIj+4rSf0 HVYpBKFkBLFZLSxvQLxOksibRi45qoSYyeiiUbJS6Kajy6C/iY2474W3mrmEcoy0fyJw Alnrv4ZMiqaNXbjxuQ7FLtq3eOAJyAqVt8R2mI1TQpAo0bqiSxfpf62zdrVUaZ3g4hwx +EyZfjGnLVH37hpZUGcUeA2ZdFfO4t1ab3xa7woyIEmyWoFtBTBkRPcElD0awSu6O4QD HRx5pjipltm53n3Qdfh2rzLqF9LJWwRGsZeBQhbSV/YbHgCYfPtwfGEhLPBquS3oPxyn gt8g== X-Gm-Message-State: AC+VfDyK+9NDH/uJPpNRqWXQsVHcAMWB06sOCTUCdoiJQ/PPG0RA5aq1 CDEy2uzqiaRr8dTFXAmHj91+yqigK+CMkaTA/Eg= X-Google-Smtp-Source: ACHHUZ5ZsY47Ni+Dn7AWff9X7pCzVQX+rOr3p8no4MW6Evhd90qLAZLRjlq4MEN7dMka1SGKKaGUTg== X-Received: by 2002:a5e:840f:0:b0:768:d817:3692 with SMTP id h15-20020a5e840f000000b00768d8173692mr230239ioj.20.1683241141910; Thu, 04 May 2023 15:59:01 -0700 (PDT) Received: from kea.bld.corp.google.com ([2620:15c:183:200:b5a:9fa0:3da:54ec]) by smtp.gmail.com with ESMTPSA id e11-20020a5ede0b000000b007608af6dfb4sm39506iok.31.2023.05.04.15.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:59:01 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Nikhil M Jain , Bin Meng , Simon Glass Subject: [PATCH v3 20/43] nvme: Provide more useful debugging messages Date: Thu, 4 May 2023 16:58:06 -0600 Message-ID: <20230504165823.v3.20.I60cf14612aa3596f3c00761d66055794f9208995@changeid> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog In-Reply-To: <20230504225829.2537050-1-sjg@chromium.org> References: <20230504225829.2537050-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean When scanning fails it is useful to be able to decode what went wrong. Add some debugging for this. Signed-off-by: Simon Glass --- (no changes since v1) drivers/nvme/nvme.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index 74e7a5b0110..a7add66ab4d 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -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);