diff mbox series

[U-Boot,09/19] riscv: qemu: Probe cpus during boot

Message ID 1542097327-6629-10-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Andes
Headers show
Series riscv: Adding RISC-V CPU and timer driver | expand

Commit Message

Bin Meng Nov. 13, 2018, 8:21 a.m. UTC
This calls cpu_probe_all() to probe all available cpus.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 arch/riscv/cpu/qemu/Kconfig |  1 +
 arch/riscv/cpu/qemu/cpu.c   | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

Comments

Lukas Auer Nov. 14, 2018, 10:21 p.m. UTC | #1
Hi Bin,

On Tue, 2018-11-13 at 00:21 -0800, Bin Meng wrote:
> This calls cpu_probe_all() to probe all available cpus.
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
> 
>  arch/riscv/cpu/qemu/Kconfig |  1 +
>  arch/riscv/cpu/qemu/cpu.c   | 14 ++++++++++++++
>  2 files changed, 15 insertions(+)
> 

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

This could also go into the generic cpu/cpu.c, what do you think?

> diff --git a/arch/riscv/cpu/qemu/Kconfig
> b/arch/riscv/cpu/qemu/Kconfig
> index ec5d934..e91cff5 100644
> --- a/arch/riscv/cpu/qemu/Kconfig
> +++ b/arch/riscv/cpu/qemu/Kconfig
> @@ -4,6 +4,7 @@
>  
>  config QEMU_RISCV
>  	bool
> +	select ARCH_EARLY_INIT_R
>  	imply CPU
>  	imply CPU_RISCV
>  	imply RISCV_TIMER
> diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/qemu/cpu.c
> index 221f3a8..e98f624 100644
> --- a/arch/riscv/cpu/qemu/cpu.c
> +++ b/arch/riscv/cpu/qemu/cpu.c
> @@ -4,7 +4,9 @@
>   */
>  
>  #include <common.h>
> +#include <cpu.h>
>  #include <dm.h>
> +#include <log.h>
>  
>  /*
>   * cleanup_before_linux() is called just before we call linux
> @@ -21,6 +23,18 @@ int cleanup_before_linux(void)
>  	return 0;
>  }
>  
> +int arch_early_init_r(void)
> +{
> +	int ret;
> +
> +	/* probe cpus so that risc-v timer can be bound */
> +	ret = cpu_probe_all();
> +	if (ret)
> +		return log_msg_ret("risc-v cpus probe fails\n", ret);

nit: RISC-V (here and in the comment above), failed instead of fails

Thanks,
Lukas

> +
> +	return 0;
> +}
> +
>  /* To enumerate devices on the /soc/ node, create a "simple-bus"
> driver */
>  static const struct udevice_id riscv_virtio_soc_ids[] = {
>  	{ .compatible = "riscv-virtio-soc" },
Bin Meng Nov. 30, 2018, 9:48 a.m. UTC | #2
Hi Lukas,

On Thu, Nov 15, 2018 at 6:22 AM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Tue, 2018-11-13 at 00:21 -0800, Bin Meng wrote:
> > This calls cpu_probe_all() to probe all available cpus.
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >
> >  arch/riscv/cpu/qemu/Kconfig |  1 +
> >  arch/riscv/cpu/qemu/cpu.c   | 14 ++++++++++++++
> >  2 files changed, 15 insertions(+)
> >
>
> Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
>
> This could also go into the generic cpu/cpu.c, what do you think?
>

Yes, I think so. Let's do this in v2.

> > diff --git a/arch/riscv/cpu/qemu/Kconfig
> > b/arch/riscv/cpu/qemu/Kconfig
> > index ec5d934..e91cff5 100644
> > --- a/arch/riscv/cpu/qemu/Kconfig
> > +++ b/arch/riscv/cpu/qemu/Kconfig
> > @@ -4,6 +4,7 @@
> >
> >  config QEMU_RISCV
> >       bool
> > +     select ARCH_EARLY_INIT_R
> >       imply CPU
> >       imply CPU_RISCV
> >       imply RISCV_TIMER
> > diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/qemu/cpu.c
> > index 221f3a8..e98f624 100644
> > --- a/arch/riscv/cpu/qemu/cpu.c
> > +++ b/arch/riscv/cpu/qemu/cpu.c
> > @@ -4,7 +4,9 @@
> >   */
> >
> >  #include <common.h>
> > +#include <cpu.h>
> >  #include <dm.h>
> > +#include <log.h>
> >
> >  /*
> >   * cleanup_before_linux() is called just before we call linux
> > @@ -21,6 +23,18 @@ int cleanup_before_linux(void)
> >       return 0;
> >  }
> >
> > +int arch_early_init_r(void)
> > +{
> > +     int ret;
> > +
> > +     /* probe cpus so that risc-v timer can be bound */
> > +     ret = cpu_probe_all();
> > +     if (ret)
> > +             return log_msg_ret("risc-v cpus probe fails\n", ret);
>
> nit: RISC-V (here and in the comment above), failed instead of fails
>

Will fix in v2.

Regards,
Bin
diff mbox series

Patch

diff --git a/arch/riscv/cpu/qemu/Kconfig b/arch/riscv/cpu/qemu/Kconfig
index ec5d934..e91cff5 100644
--- a/arch/riscv/cpu/qemu/Kconfig
+++ b/arch/riscv/cpu/qemu/Kconfig
@@ -4,6 +4,7 @@ 
 
 config QEMU_RISCV
 	bool
+	select ARCH_EARLY_INIT_R
 	imply CPU
 	imply CPU_RISCV
 	imply RISCV_TIMER
diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/qemu/cpu.c
index 221f3a8..e98f624 100644
--- a/arch/riscv/cpu/qemu/cpu.c
+++ b/arch/riscv/cpu/qemu/cpu.c
@@ -4,7 +4,9 @@ 
  */
 
 #include <common.h>
+#include <cpu.h>
 #include <dm.h>
+#include <log.h>
 
 /*
  * cleanup_before_linux() is called just before we call linux
@@ -21,6 +23,18 @@  int cleanup_before_linux(void)
 	return 0;
 }
 
+int arch_early_init_r(void)
+{
+	int ret;
+
+	/* probe cpus so that risc-v timer can be bound */
+	ret = cpu_probe_all();
+	if (ret)
+		return log_msg_ret("risc-v cpus probe fails\n", ret);
+
+	return 0;
+}
+
 /* To enumerate devices on the /soc/ node, create a "simple-bus" driver */
 static const struct udevice_id riscv_virtio_soc_ids[] = {
 	{ .compatible = "riscv-virtio-soc" },