Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A374DC2B9F4 for ; Tue, 22 Jun 2021 13:16:43 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D3AF6113E for ; Tue, 22 Jun 2021 13:16:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D3AF6113E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 07D17828EB; Tue, 22 Jun 2021 15:16:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ItWGzMe/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 14B02829A6; Tue, 22 Jun 2021 15:16:38 +0200 (CEST) Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (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 E5B4E80F32 for ; Tue, 22 Jun 2021 15:16:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-pj1-x1033.google.com with SMTP id t19-20020a17090ae513b029016f66a73701so1716763pjy.3 for ; Tue, 22 Jun 2021 06:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EDA1JqJT7F/a2MUq/6cWJNXGDp5vuDnCfyk8LD4quy0=; b=ItWGzMe/1l2UPyAEgaz8h+CWlb9v5bFv7QTlX0adJP9FzJJMivLLZIj+vs82GHSoU/ pVIwTDjzUNBQzOc+bcRF19MYoo+l+G5gkb/QG6W26bHJ1n/z+jRQ4aJpAgUnoeveLSKI rGv4YXFQRzHtL37X0vhuKlShLLj+UZHdUskfTFNHAnO/3kbPutVrQPSXHn7XI+oubWZG u1HfF5nxOOAqXp/oDL1fqnH7LpV8a/7NCp0V9KwL0LN8UmsUO/lDlwbFdg9SmpU3dX4k jCF/WBNLv0nT/xwX4rEdZJT3J39LFzfm7WWpsmf3HQMn/n/eQ95eSzC6mth618HxKeaI OJBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EDA1JqJT7F/a2MUq/6cWJNXGDp5vuDnCfyk8LD4quy0=; b=GK1uLcBItdA1ydNTR6yfAE7wWlTvi4fuCo+1HHhM4xnyRVjJ0H5QUh3cRC+ZKhdlvJ z+u6Ml2/hPJca2BZgZlOAh4HOgFU3zu/0eNXoDxfjOwWsC4SEZ8z1qvu+Y/jNKww1EA1 UsEdcxEFAQPBXfiFvnEVUPrtjIobv+LpyAgsaQjn2bl8Po33b5umK7iMNhx9Mjc5F9sC 3Y2czqPdBDfa7dDNFV90FcvoQANfOJK6gXoVieyM5W+hbBa+2rN9O1kQNZy2+heOC3Da hJ0WM1qy+kS3bpkWMJtaK30S3dacymb+GLA8orIfNq9dUR4MoFm0MuMWbfLQuB+vPutX u9zQ== X-Gm-Message-State: AOAM530H9nUAaxsefw2nh4xKNb1Q3YtSi2OK6N6xiS2SXvSu3ow4T6cw KGfTMe8DEkTJ8feDVby6QM0= X-Google-Smtp-Source: ABdhPJw4W5yOIEBCbisPDeDAuARHUfQp0b2nfIrrWJccTRJydjqKMQO7jC498+8S16qAEyUj2Ffmmg== X-Received: by 2002:a17:902:eac2:b029:107:b14c:423d with SMTP id p2-20020a170902eac2b0290107b14c423dmr7766532pld.77.1624367791071; Tue, 22 Jun 2021 06:16:31 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id j24sm18456482pfe.58.2021.06.22.06.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Jun 2021 06:16:30 -0700 (PDT) From: Bin Meng To: Tom Rini , u-boot@lists.denx.de Cc: Bin Meng Subject: [PATCH v2 1/7] nvme: Move block dev creation from uclass post_probe() to driver probe() Date: Tue, 22 Jun 2021 21:16:17 +0800 Message-Id: <20210622131623.21265-1-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean At present the block device creation happens in the NVMe uclass driver post_probe() phase. In preparation to support multiple namespaces, we should issue namespace identify before creating block devices but that touches the underlying hardware hence it is not appropriate to do such in the uclass driver post_probe(). Let's move it to driver probe() phase instead. Signed-off-by: Bin Meng --- Changes in v2: - drop the nvme per-child platdata change drivers/nvme/nvme-uclass.c | 30 ------------------------------ drivers/nvme/nvme.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/drivers/nvme/nvme-uclass.c b/drivers/nvme/nvme-uclass.c index 277e31e1f3..610166d76e 100644 --- a/drivers/nvme/nvme-uclass.c +++ b/drivers/nvme/nvme-uclass.c @@ -5,39 +5,9 @@ */ #include -#include -#include #include -#include -#include "nvme.h" - -static int nvme_uclass_post_probe(struct udevice *udev) -{ - char name[20]; - struct udevice *ns_udev; - int i, ret; - struct nvme_dev *ndev = dev_get_priv(udev); - - /* Create a blk device for each namespace */ - for (i = 0; i < ndev->nn; i++) { - /* - * Encode the namespace id to the device name so that - * we can extract it when doing the probe. - */ - sprintf(name, "blk#%d", i); - - /* The real blksz and size will be set by nvme_blk_probe() */ - ret = blk_create_devicef(udev, "nvme-blk", name, IF_TYPE_NVME, - -1, 512, 0, &ns_udev); - if (ret) - return ret; - } - - return 0; -} UCLASS_DRIVER(nvme) = { .name = "nvme", .id = UCLASS_NVME, - .post_probe = nvme_uclass_post_probe, }; diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index c61dab20c5..29735a6ad8 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -879,6 +879,24 @@ static int nvme_probe(struct udevice *udev) nvme_get_info_from_identify(ndev); + /* Create a blk device for each namespace */ + for (int i = 0; i < ndev->nn; i++) { + struct udevice *ns_udev; + char name[20]; + + /* + * Encode the namespace id to the device name so that + * we can extract it when doing the probe. + */ + sprintf(name, "blk#%d", i); + + /* The real blksz and size will be set by nvme_blk_probe() */ + ret = blk_create_devicef(udev, "nvme-blk", name, IF_TYPE_NVME, + -1, 512, 0, &ns_udev); + if (ret) + goto free_queue; + } + return 0; free_queue: -- 2.25.1