All of lore.kernel.org
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@dabbelt.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: peterz@infradead.org, tglx@linutronix.de, jason@lakedaemon.net,
	marc.zyngier@arm.com, dmitriy@oss-tech.org,
	yamada.masahiro@socionext.com, mmarek@suse.com,
	albert@sifive.com, will.deacon@arm.com, boqun.feng@gmail.com,
	oleg@redhat.com, mingo@redhat.com, daniel.lezcano@linaro.org,
	gregkh@linuxfoundation.org, jslaby@suse.com, davem@davemloft.net,
	mchehab@kernel.org, hverkuil@xs4all.nl, rdunlap@infradead.org,
	viro@zeniv.linux.org.uk, mhiramat@kernel.org, fweisbec@gmail.com,
	mcgrof@kernel.org, dledford@redhat.com,
	bart.vanassche@sandisk.com, sstabellini@kernel.org,
	mpe@ellerman.id.au, rmk+kernel@armlinux.org.uk,
	paul.gortmaker@windriver.com, nicolas.dichtel@6wind.com,
	linux@roeck-us.net, heiko.carstens@de.ibm.com,
	schwidefsky@de.ibm.com, geert@linux-m68k.org,
	akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com,
	jiri@mellanox.com, vgupta@synopsys.com, airlied@redhat.com,
	jk@ozlabs.org, chris@chris-wilson.co.uk, Jason@zx2c4.com,
	paulmck@linux.vnet.ibm.com, ncardwell@google.com,
	linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
	patches@groups.riscv.org
Subject: Re: [PATCH v8 10/18] RISC-V: Init and Halt Code
Date: Wed, 13 Sep 2017 10:01:44 -0700 (PDT)	[thread overview]
Message-ID: <mhng-dd00158c-af84-46d2-a4e3-219e4d9cb1bf@palmer-si-x1c4> (raw)
In-Reply-To: <CAK8P3a3fxTkRjXfHfW=8OoME0DNyU=DKNcaRPWwnaKqF-w1ccg@mail.gmail.com>

On Wed, 13 Sep 2017 08:20:42 PDT (-0700), Arnd Bergmann wrote:
> On Tue, Sep 12, 2017 at 11:57 PM, Palmer Dabbelt <palmer@dabbelt.com> wrote:
>> This contains the various __init C functions, the initial assembly
>> kernel entry point, and the code to reset the system.  When a file was
>> init-related this patch contains the entire file.
>
> One minor comment:
>
>> +       /*
>> +        * This hart didn't win the lottery, so we wait for the winning hart to
>> +        * get far enough along the boot process that it should continue.
>> +        */
>> +.Lwait_for_cpu_up:
>> +       REG_L sp, (a1)
>> +       REG_L tp, (a2)
>> +       beqz sp, .Lwait_for_cpu_up
>> +       beqz tp, .Lwait_for_cpu_up
>> +       fence
>
> We usually discourage having the CPUs spin in a busy-loop while
> waiting to be started up, at least on ARM platforms. It seems that
> you could however just have them wait for an interrupt before checking
> the sp/tp values. Would that guarantee to put the CPUs in a low
> power state?

There's no way to _force_ a core to go into a low power state, but putting a
WFI (Wait For Interrupt) in there would at least allow implementations that
care to save power.  We already have some WFIs elsewhere, so it's the right
thing to do here.

There's a few sticky bits here:
* WFI can be implemented as a noop, so this could race with other IPI handling.
  I think it's safe: our IPI is just a "maybe there's a new message" signal, so
  if there's a spurious one it's ignored.
* Interrupts are disabled at this time, though since there's no trap vector it
  should be safe to enable them with a local trap vector here.

I added a FIXME for now, I'll fix it by the v9.

diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index 1c50fe3765b1..76af908f87c1 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -130,6 +130,7 @@ relocate:
         * get far enough along the boot process that it should continue.
         */
 .Lwait_for_cpu_up:
+       /* FIXME: We should WFI to save some energy here. */
        REG_L sp, (a1)
        REG_L tp, (a2)
        beqz sp, .Lwait_for_cpu_up

       reply	other threads:[~2017-09-13 17:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAK8P3a3fxTkRjXfHfW=8OoME0DNyU=DKNcaRPWwnaKqF-w1ccg@mail.gmail.com>
2017-09-13 17:01 ` Palmer Dabbelt [this message]
2017-09-12 21:56 RISC-V Linux Port v8 Palmer Dabbelt
2017-09-12 21:57 ` [PATCH v8 10/18] RISC-V: Init and Halt Code Palmer Dabbelt
2017-09-13 18:15   ` Daniel Lezcano
2017-09-16  6:23     ` Dmitriy Cherkasov
2017-09-16 13:28       ` Daniel Lezcano
2017-09-16 21:38         ` Dmitriy Cherkasov

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=mhng-dd00158c-af84-46d2-a4e3-219e4d9cb1bf@palmer-si-x1c4 \
    --to=palmer@dabbelt.com \
    --cc=Jason@zx2c4.com \
    --cc=airlied@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=albert@sifive.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=bart.vanassche@sandisk.com \
    --cc=boqun.feng@gmail.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.lezcano@linaro.org \
    --cc=davem@davemloft.net \
    --cc=dledford@redhat.com \
    --cc=dmitriy@oss-tech.org \
    --cc=fweisbec@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jason@lakedaemon.net \
    --cc=jiri@mellanox.com \
    --cc=jk@ozlabs.org \
    --cc=jslaby@suse.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=marc.zyngier@arm.com \
    --cc=mcgrof@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mmarek@suse.com \
    --cc=mpe@ellerman.id.au \
    --cc=ncardwell@google.com \
    --cc=nicolas.dichtel@6wind.com \
    --cc=oleg@redhat.com \
    --cc=patches@groups.riscv.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=schwidefsky@de.ibm.com \
    --cc=sstabellini@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vgupta@synopsys.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will.deacon@arm.com \
    --cc=yamada.masahiro@socionext.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 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.