All of lore.kernel.org
 help / color / mirror / Atom feed
From: Auer, Lukas <lukas.auer@aisec.fraunhofer.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RESEND PATCH v2 15/15] riscv: Move do_reset() to a common place
Date: Mon, 17 Sep 2018 22:01:42 +0000	[thread overview]
Message-ID: <02a5863da86cfcbf2c75aac5af0984c35cb739b7.camel@aisec.fraunhofer.de> (raw)
In-Reply-To: <CAEUhbmVsTsRHW+bS9FG7AbCWYpaMzAcm-CRUuT90m2fxUZaLAg@mail.gmail.com>

Hi Bin,

On Mon, 2018-09-17 at 13:02 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Mon, Sep 17, 2018 at 5:09 AM Auer, Lukas
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > 
> > Hi Bin,
> > 
> > On Mon, 2018-09-10 at 21:54 -0700, Bin Meng wrote:
> > > We don't have a reset method on any RISC-V board yet. Instead of
> > > adding the same 'unsupported' message for each CPU variant it
> > > might
> > > make more sense to add a generic do_reset function for all CPU
> > > variants to lib/, similar to the one for ARM
> > > (arch/arm/lib/reset.c).
> > > 
> > > Suggested-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > > 
> > > ---
> > > 
> > > Changes in v2:
> > > - new patch to move do_reset() to a common place
> > > 
> > >  arch/riscv/cpu/ax25/cpu.c |  9 ---------
> > >  arch/riscv/cpu/qemu/cpu.c |  8 --------
> > >  arch/riscv/lib/Makefile   |  1 +
> > >  arch/riscv/lib/reset.c    | 14 ++++++++++++++
> > >  4 files changed, 15 insertions(+), 17 deletions(-)
> > >  create mode 100644 arch/riscv/lib/reset.c
> > > 
> > > diff --git a/arch/riscv/cpu/ax25/cpu.c
> > > b/arch/riscv/cpu/ax25/cpu.c
> > > index ab05b57..fddcc15 100644
> > > --- a/arch/riscv/cpu/ax25/cpu.c
> > > +++ b/arch/riscv/cpu/ax25/cpu.c
> > > @@ -6,9 +6,6 @@
> > > 
> > >  /* CPU specific code */
> > >  #include <common.h>
> > > -#include <command.h>
> > > -#include <watchdog.h>
> > > -#include <asm/cache.h>
> > > 
> > >  /*
> > >   * cleanup_before_linux() is called just before we call linux
> > > @@ -24,9 +21,3 @@ int cleanup_before_linux(void)
> > > 
> > >       return 0;
> > >  }
> > > -
> > > -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> > > argv[])
> > > -{
> > > -     disable_interrupts();
> > > -     panic("ax25-ae350 wdt not support yet.\n");
> > > -}
> > > diff --git a/arch/riscv/cpu/qemu/cpu.c
> > > b/arch/riscv/cpu/qemu/cpu.c
> > > index a064639..6c7a327 100644
> > > --- a/arch/riscv/cpu/qemu/cpu.c
> > > +++ b/arch/riscv/cpu/qemu/cpu.c
> > > @@ -4,7 +4,6 @@
> > >   */
> > > 
> > >  #include <common.h>
> > > -#include <command.h>
> > > 
> > >  /*
> > >   * cleanup_before_linux() is called just before we call linux
> > > @@ -20,10 +19,3 @@ int cleanup_before_linux(void)
> > > 
> > >       return 0;
> > >  }
> > > -
> > > -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> > > argv[])
> > > -{
> > > -     printf("reset unsupported yet\n");
> > > -
> > > -     return 0;
> > > -}
> > > diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
> > > index cc562f9..b58db89 100644
> > > --- a/arch/riscv/lib/Makefile
> > > +++ b/arch/riscv/lib/Makefile
> > > @@ -10,6 +10,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
> > >  obj-$(CONFIG_CMD_GO) += boot.o
> > >  obj-y        += cache.o
> > >  obj-y        += interrupts.o
> > > +obj-y        += reset.o
> > >  obj-y   += setjmp.o
> > > 
> > >  # For building EFI apps
> > > diff --git a/arch/riscv/lib/reset.c b/arch/riscv/lib/reset.c
> > > new file mode 100644
> > > index 0000000..5d9b99c
> > > --- /dev/null
> > > +++ b/arch/riscv/lib/reset.c
> > > @@ -0,0 +1,14 @@
> > > +// SPDX-License-Identifier: GPL-2.0+
> > > +/*
> > > + * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
> > > + */
> > > +
> > > +#include <common.h>
> > > +#include <command.h>
> > > +
> > > +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> > > argv[])
> > > +{
> > > +     printf("reset unsupported yet\n");
> > > +
> > > +     return 0;
> > > +}
> > 
> > Thanks for adding this patch!
> > I see one possible problem with it. The way you implemented it,
> > arch /
> > board code can't overwrite the function to add a reset method. How
> > about something like this?
> > 
> 
> Thanks for your review and comments. I believe current implementation
> in this patch is an interim approach, for now to save some
> duplicates.
> The problem you mentioned can be resolved by implementing a SYSRESET
> uclass driver for that CPU/board in the future.
> 

That's true, still, two minor things I would consider to change.

- A simple wording changes to make it clear that the reset is not only
not available, but u-boot actually tried to reset the system. So
something like this: "Resetting... reset not supported yet".

- I don't know how much of an issue it is that u-boot keeps running
after a reset. I would tend to use panic() together with PANIC_HANG, to
make sure u-boot halts. You know u-boot better than me, what do you
think?

Thanks,
Lukas


Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>

> > - do_reset() only prints "resetting..." and then calls cpu_reset()
> > - reset.c includes a weak cpu_reset() function that prints the
> > warning
> > you currently have in this patch (by the way, it should say "reset
> > not
> > supported yet"). It might also make sense to print the warning with
> > the
> > panic() function and define PANIC_HANG, so that u-boot is halted on
> > resets. cpu_reset() can then be defined by boards that have an
> > actual
> > reset method.
> 
> Regards,
> Bin

  reply	other threads:[~2018-09-17 22:01 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11  4:54 [U-Boot] [RESEND PATCH v2 00/15] riscv: Add QEMU virt board support Bin Meng
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 01/15] riscv: kconfig: Normalize architecture name spelling Bin Meng
2018-09-16 20:43   ` Auer, Lukas
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA2F93D39@ATCPCS16.andestech.com>
2018-09-20  3:15     ` Rick Chen
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 02/15] riscv: Remove setup.h Bin Meng
2018-09-16 20:44   ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 03/15] riscv: bootm: Correct the 1st kernel argument to hart id Bin Meng
2018-09-16 20:45   ` Auer, Lukas
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA2F93D4E@ATCPCS16.andestech.com>
2018-09-20  3:17     ` Rick Chen
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 04/15] riscv: Remove mach type Bin Meng
2018-09-16 20:46   ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 05/15] riscv: Move the linker script to the CPU root directory Bin Meng
2018-09-16 20:47   ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 06/15] riscv: Fix coding style issues in the linker script Bin Meng
2018-09-16 20:49   ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 07/15] riscv: Explicitly pass -march and -mabi to the compiler Bin Meng
2018-09-16 20:51   ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 08/15] riscv: Add a helper routine to print CPU information Bin Meng
2018-09-16 20:54   ` Auer, Lukas
2018-09-17  4:55     ` Bin Meng
2018-09-17 21:59       ` Auer, Lukas
2018-09-18  8:53         ` Bin Meng
2018-09-18 10:53           ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 09/15] riscv: Remove CSR read/write defines in encoding.h Bin Meng
2018-09-16 20:55   ` Auer, Lukas
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA2F93D8B@ATCPCS16.andestech.com>
2018-09-20  3:20     ` Rick Chen
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 10/15] riscv: bootm: Pass mhartid CSR value to kernel Bin Meng
2018-09-16 20:55   ` Auer, Lukas
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA2F93D92@ATCPCS16.andestech.com>
2018-09-20  3:22     ` Rick Chen
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 11/15] riscv: Make start.S available for all targets Bin Meng
2018-09-16 20:56   ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 12/15] riscv: ae350: Clean up mixed tabs and spaces in the dts Bin Meng
2018-09-16 20:57   ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 13/15] riscv: kconfig: Select DM and OF_CONTROL Bin Meng
2018-09-16 20:58   ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 14/15] riscv: Add QEMU virt board support Bin Meng
2018-09-16 21:02   ` Auer, Lukas
2018-09-17  5:18     ` Bin Meng
2018-09-17 21:54       ` Auer, Lukas
2018-09-11  4:54 ` [U-Boot] [RESEND PATCH v2 15/15] riscv: Move do_reset() to a common place Bin Meng
2018-09-16 21:09   ` Auer, Lukas
2018-09-17  5:02     ` Bin Meng
2018-09-17 22:01       ` Auer, Lukas [this message]
2018-09-18  8:50         ` Bin Meng
2018-09-18 10:54           ` Auer, Lukas
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA2F93DD7@ATCPCS16.andestech.com>
2018-09-20  3:26     ` Rick Chen
2018-09-16 10:57 ` [U-Boot] [RESEND PATCH v2 00/15] riscv: Add QEMU virt board support Bin Meng
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA2F93D22@ATCPCS16.andestech.com>
2018-09-20  3:00     ` Rick Chen
2018-09-20  3:21       ` Bin Meng

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=02a5863da86cfcbf2c75aac5af0984c35cb739b7.camel@aisec.fraunhofer.de \
    --to=lukas.auer@aisec.fraunhofer.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.