u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Mayuresh Chitale <mchitale@ventanamicro.com>
To: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>,
	u-boot@lists.denx.de,  Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Rick Chen <rick@andestech.com>, Leo <ycliang@andestech.com>
Subject: Re: [PATCH v2 4/4] common: spl: Add spl NVMe boot support
Date: Thu, 4 May 2023 13:58:46 +0530	[thread overview]
Message-ID: <CAN37VV4GcFRzrjri6wt7-Op9q+hj1GTJ++JukqrmVzywYBhqHw@mail.gmail.com> (raw)
In-Reply-To: <CAPnjgZ0bXcaC4jsgQ6UWcFhko8o0zDgsf3sU97TFJY0rpTCmfg@mail.gmail.com>

Hi Simon,

On Wed, May 3, 2023 at 6:58 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Mayuresh,
>
> On Tue, 2 May 2023 at 10:19, Mayuresh Chitale <mchitale@ventanamicro.com> wrote:
> >
> > Add support to load the next stage image from an NVMe disk which may
> > be formatted as an EXT or FAT filesystem.
> >
> > Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> > ---
> >  arch/riscv/include/asm/spl.h |  1 +
> >  common/spl/Kconfig           | 10 +++++++
> >  common/spl/Makefile          |  1 +
> >  common/spl/spl_nvme.c        | 52 ++++++++++++++++++++++++++++++++++++
> >  4 files changed, 64 insertions(+)
> >  create mode 100644 common/spl/spl_nvme.c
> >
> > diff --git a/arch/riscv/include/asm/spl.h b/arch/riscv/include/asm/spl.h
> > index 2898a770ee..9c0bf9755c 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/Kconfig b/common/spl/Kconfig
> > index a42774c76d..021c4997a7 100644
> > --- a/common/spl/Kconfig
> > +++ b/common/spl/Kconfig
> > @@ -1283,6 +1283,16 @@ config SPL_NVME_BOOT_DEVICE
> >         depends on SPL_NVME
> >         default 0x0
> >
> > +config SYS_NVME_EXT_BOOT_PARTITION
> > +       hex "NVMe ext boot partition number"
> > +       depends on SPL_NVME
> > +       default 0x2
> > +
> > +config SYS_NVME_FAT_BOOT_PARTITION
> > +       hex "NVMe boot partition number"
> > +       depends on SPL_NVME
> > +       default 0x1
> > +
> >  config SPL_SERIAL
> >         bool "Support serial"
> >         select SPL_PRINTF
> > 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..c99e0aefc7
> > --- /dev/null
> > +++ b/common/spl/spl_nvme.c
> > @@ -0,0 +1,52 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright (C) 2023
> > + * Ventana Micro Systems Inc.
> > + *
> > + * Derived work from spl_sata.c
> > + */
> > +
> > +#include <common.h>
> > +#include <spl.h>
> > +#include <errno.h>
> > +#include <fat.h>
> > +#include <init.h>
> > +#include <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(UCLASS_NVME, CONFIG_SPL_NVME_BOOT_DEVICE);
> > +       blk_desc = blk_get_devnum_by_uclass_id(UCLASS_NVME,
> > +                                              CONFIG_SPL_NVME_BOOT_DEVICE);
> > +       if (IS_ENABLED(CONFIG_SPL_FS_EXT4)) {
> > +               ret = spl_load_image_ext(spl_image, bootdev, blk_desc,
> > +                                        CONFIG_SYS_NVME_EXT_BOOT_PARTITION,
> > +                                        CONFIG_SPL_PAYLOAD);
> > +               if (!ret)
> > +                       return ret;
> > +       }
> > +
> > +       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.34.1
> >
>
> All of this code looks generic except:
>
> UCLASS_NVME
> CONFIG_SPL_NVME_BOOT_DEVICE
> CONFIG_SYS_NVME_EXT_BOOT_PARTITION
> so please move the code inside your new function into a generic file
> like spl_blk_fs.c or similar and pass these parameters to it. Then we
> can use the same function for other device types.
>

Ok. WIll do it in the next version.

> Regards,
> SImon


Thanks,
Mayuresh.

      reply	other threads:[~2023-05-04  8:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 16:18 [PATCH v2 0/4] SPL NVme support Mayuresh Chitale
2023-05-02 16:18 ` [PATCH v2 1/4] spl: Add Kconfig options for NVME Mayuresh Chitale
2023-05-02 16:19 ` [PATCH v2 2/4] nvme: pci: Enable for SPL Mayuresh Chitale
2023-05-03  1:28   ` Simon Glass
2023-05-04  8:27     ` Mayuresh Chitale
2023-05-02 16:19 ` [PATCH v2 3/4] spl: Support loading a FIT from ext FS Mayuresh Chitale
2023-05-02 16:19 ` [PATCH v2 4/4] common: spl: Add spl NVMe boot support Mayuresh Chitale
2023-05-03  1:28   ` Simon Glass
2023-05-04  8:28     ` Mayuresh Chitale [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAN37VV4GcFRzrjri6wt7-Op9q+hj1GTJ++JukqrmVzywYBhqHw@mail.gmail.com \
    --to=mchitale@ventanamicro.com \
    --cc=bmeng.cn@gmail.com \
    --cc=rick@andestech.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=ycliang@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).