From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5458BC433F5 for ; Thu, 29 Sep 2022 23:56:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 759F984D72; Fri, 30 Sep 2022 01:56:25 +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="euwXA3vE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2531884CD7; Fri, 30 Sep 2022 01:56:09 +0200 (CEST) Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (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 3135A849F0 for ; Fri, 30 Sep 2022 01:56:06 +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@google.com Received: by mail-oi1-x233.google.com with SMTP id v130so3214379oie.2 for ; Thu, 29 Sep 2022 16:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=ta6GvWwBFtsIxPtPqjwNxwwqxVYcUNvGASP9a3VUSgI=; b=euwXA3vEi0eL/UEtnyz0LT/y8ADWkBbd9rfPc5HuoAt6Hyli6UQJwot22L8Yx4Dr83 0n6IANqIcQupCBOJAIJsS1bZUb7gCZQR0nEuSg9hUNWCjdv6WbdYSp/qy8zhVT/rEfi2 knSS5svwro0ukq06OUO7Z8edsx+qItgRP4oes= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=ta6GvWwBFtsIxPtPqjwNxwwqxVYcUNvGASP9a3VUSgI=; b=VbzR+u7MD35NROjQa0eUwgWTeg+N+/pMHPGABPG7E/sOQroLOGTrUcPDP9Z6F1+EVR 0CfSskdvIeDidZeQOFMDz3Bn1w39ot3pTfYR6QqVf8uAmNwWasuQuszXt2tkA7JDeiur /8srDTxtQWb5L4JtAX0+d6ZnD4QuliwqusEguukdK/+4RWYPWebbBYtJ0HBTyQMWOTb9 vR68MQipHxsOnsoZwTDxdI31PwnFyGpeJXMPi0wSkcapozhSH+VEifyqckkJ3VZVRUmJ zi7jQqbyn4heWeSaCzz7RooV1rGR6xSaRt5dXr0TUq1HP4csGsBCi0uu59Jaxtge7VMQ rEww== X-Gm-Message-State: ACrzQf1mttgqLc2AiiHfiSGUCBpkMQfv9DOdf3i6oVgSfN+PZm2ciDJg mtpheEtKL9HUES7dGnS5J8qlUiJUreqL5o8zcKmsew== X-Google-Smtp-Source: AMsMyM4bcPw5G7s3sLP9XIs1zbjt8bYaWe6GxMpYSNry8uguXg0C/4cxhAcLCXl0OBYqeUsbSd4cBUCh+pHA0Qni+jM= X-Received: by 2002:a05:6808:d53:b0:351:1cab:9c29 with SMTP id w19-20020a0568080d5300b003511cab9c29mr2908230oik.64.1664495764511; Thu, 29 Sep 2022 16:56:04 -0700 (PDT) MIME-Version: 1.0 References: <20220929095639.355675-1-mchitale@ventanamicro.com> <20220929095639.355675-4-mchitale@ventanamicro.com> In-Reply-To: <20220929095639.355675-4-mchitale@ventanamicro.com> From: Simon Glass Date: Thu, 29 Sep 2022 17:55:52 -0600 Message-ID: Subject: Re: [RFC PATCH v1 3/3] common: spl: Add spl NVMe boot support To: Mayuresh Chitale Cc: Bin Meng , U-Boot Mailing List , Heinrich Schuchardt , Rick Chen , Leo Content-Type: text/plain; charset="UTF-8" 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.6 at phobos.denx.de X-Virus-Status: Clean Hi Mayuresh, On Thu, 29 Sept 2022 at 03:57, Mayuresh Chitale wrote: > > Add spl_nvme to read a fat partition from a bootable NVMe device. > > Signed-off-by: Mayuresh Chitale > --- > arch/riscv/include/asm/spl.h | 1 + > common/spl/Makefile | 1 + > common/spl/spl_nvme.c | 44 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 46 insertions(+) > create mode 100644 common/spl/spl_nvme.c Reviewed-by: Simon Glass (but see below) > > diff --git a/arch/riscv/include/asm/spl.h b/arch/riscv/include/asm/spl.h > index e8a94fcb1f..5d0ba4b034 100644 > --- a/arch/riscv/include/asm/spl.h > +++ b/arch/riscv/include/asm/spl.h > @@ -20,6 +20,7 @@ enum { > BOOT_DEVICE_SPI, > BOOT_DEVICE_USB, > BOOT_DEVICE_SATA, > + BOOT_DEVICE_NVME, > BOOT_DEVICE_I2C, > BOOT_DEVICE_BOARD, > BOOT_DEVICE_DFU, > diff --git a/common/spl/Makefile b/common/spl/Makefile > index 13db3df993..4bcc3d7e68 100644 > --- a/common/spl/Makefile > +++ b/common/spl/Makefile > @@ -28,6 +28,7 @@ obj-$(CONFIG_$(SPL_TPL_)USB_STORAGE) += spl_usb.o > obj-$(CONFIG_$(SPL_TPL_)FS_FAT) += spl_fat.o > obj-$(CONFIG_$(SPL_TPL_)FS_EXT4) += spl_ext.o > obj-$(CONFIG_$(SPL_TPL_)SATA) += spl_sata.o > +obj-$(CONFIG_$(SPL_TPL_)NVME) += spl_nvme.o > obj-$(CONFIG_$(SPL_TPL_)SEMIHOSTING) += spl_semihosting.o > obj-$(CONFIG_$(SPL_TPL_)DFU) += spl_dfu.o > obj-$(CONFIG_$(SPL_TPL_)SPI_LOAD) += spl_spi.o > diff --git a/common/spl/spl_nvme.c b/common/spl/spl_nvme.c > new file mode 100644 > index 0000000000..d8a9dba845 > --- /dev/null > +++ b/common/spl/spl_nvme.c > @@ -0,0 +1,44 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright (C) 2022 > + * Ventana Micro Systems Inc. > + * > + * Derived work from spl_sata.c > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include Should go above nvme.h > + > +static int spl_nvme_load_image(struct spl_image_info *spl_image, > + struct spl_boot_device *bootdev) > +{ > + int ret; > + struct blk_desc *blk_desc; > + > + ret = pci_init(); > + if (ret < 0) > + goto out; > + > + ret = nvme_scan_namespace(); > + if (ret < 0) > + goto out; > + > + blk_show_device(IF_TYPE_NVME, CONFIG_SPL_NVME_BOOT_DEVICE); > + blk_desc = blk_get_devnum_by_type(IF_TYPE_NVME, > + CONFIG_SPL_NVME_BOOT_DEVICE); I think we need to move this to device tree, but it is OK for now. > + if (IS_ENABLED(CONFIG_SPL_FS_FAT)) > + ret = spl_load_image_fat(spl_image, bootdev, blk_desc, > + CONFIG_SYS_NVME_FAT_BOOT_PARTITION, > + CONFIG_SPL_PAYLOAD); > + else > + ret = -ENOSYS; > + > +out: > + return ret; > +} > + > +SPL_LOAD_IMAGE_METHOD("NVME", 0, BOOT_DEVICE_NVME, spl_nvme_load_image); > -- > 2.25.1 > Regards, Simon