linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dave.Martin@arm.com (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 2/3] ARM: mcpm: Implement cpu_kill() to synchronise on powerdown
Date: Mon, 30 Sep 2013 18:20:55 +0100	[thread overview]
Message-ID: <20130930172055.GC3209@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.03.1309301252050.6331@syhkavp.arg>

On Mon, Sep 30, 2013 at 01:00:00PM -0400, Nicolas Pitre wrote:
> On Mon, 30 Sep 2013, Dave Martin wrote:
> 
> > CPU hotplug and kexec rely on smp_ops.cpu_kill(), which is supposed
> > to wait for the CPU to park or power down, and perform the last
> > rites (such as disabling clocks etc., where the platform doesn't do
> > this automatically).
> > 
> > kexec in particular is unsafe without performing this
> > synchronisation to park secondaries.  Without it, the secondaries
> > might not be parked when kexec trashes the kernel.
> > 
> > There is no generic way to do this synchronisation, so a new mcpm
> > platform_ops method power_down_finish() is added by this patch.
> > 
> > The new method is mandatory.  A platform which provides no way to
> > detect when CPUs are parked is likely broken.
> > 
> > Signed-off-by: Dave Martin <Dave.Martin@arm.com>
> > ---
> >  arch/arm/common/mcpm_entry.c   |    5 +++++
> >  arch/arm/common/mcpm_platsmp.c |   10 ++++++++++
> >  arch/arm/include/asm/mcpm.h    |   31 +++++++++++++++++++++++++++++++
> >  3 files changed, 46 insertions(+)
> > 
> > diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c
> > index 370236d..b722027 100644
> > --- a/arch/arm/common/mcpm_entry.c
> > +++ b/arch/arm/common/mcpm_entry.c
> > @@ -89,6 +89,11 @@ void mcpm_cpu_power_down(void)
> >  	BUG();
> >  }
> >  
> > +int mcpm_cpu_power_down_finish(unsigned int cpu, unsigned int cluster)
> > +{
> > +	return platform_ops->power_down_finish(cpu, cluster);
> > +}
> 
> Please make it return an error (non-zero return value) if platform_ops 
> or platform_ops->power_down_finish is NULL.  Otherwise this would oops 
> the kernel.
> 
> There is a patch already handling the other cases in RMK's patch system.

OK -- I didn't pay enough attention as that went past.

I'll grab that patch and rebase onto it.


Do you have concerns about the mandatoriness of the new call?  The
alternative would be to check for it at registration time and set
smp_ops.cpu_kill to NULL if the backend method isn't there.

But I really wouldn't want to encourage that until someone comes
up with a good reason.

[...]

> > diff --git a/arch/arm/include/asm/mcpm.h b/arch/arm/include/asm/mcpm.h
> > index 0f7b762..22cdc6f 100644
> > --- a/arch/arm/include/asm/mcpm.h
> > +++ b/arch/arm/include/asm/mcpm.h
> > @@ -78,10 +78,40 @@ int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster);
> >   *
> >   * This does not return.  Re-entry in the kernel is expected via
> >   * mcpm_entry_point.
> > + *
> > + * The CPU is not necessarily truly halted until
> > + * mcpu_cpu_power_down_finish() subsequently returns non-zero for the
> 
> s/mcpu/mcpm/
> 
> > + * specified cpu.  Until then, other CPUs should make sure they do not
> > + * trash memory the target CPU might be executing/accessing.
> >   */
> >  void mcpm_cpu_power_down(void);
> >  
> >  /**
> > + * mcpm_cpu_power_down_finish - wait for a specified CPU to halt, and
> > + *	make sure it is powered off
> > + *
> > + * @cpu: CPU number within given cluster
> > + * @cluster: cluster number for the CPU
> > + *
> > + * Call this function to ensure that a pending powerdown has taken
> > + * effect and the CPU is safely parked before performing non-mcpm
> > + * operations that may affect the CPU (such as kexec trashing the
> > + * kernel text).
> > + *
> > + * It is *not* necessary to call this function if you only need to
> > + * serialise a pending powerdown with mcpu_cpu_power_up() or a wakeup
> 
> Ditto.
> 
> > + * event.
> > + *
> > + * Do not call this function unless the specified CPU has already
> > + * called mcpu_cpu_power_down() or has committed to doing so.
> 
> Ditto.

Ummm, duh.  Fixed -- thanks.

[...]

Cheers
---Dave

  reply	other threads:[~2013-09-30 17:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-30 15:06 [RFC PATCH 0/3] MCPM/TC2 support for CPU powerdown synchronisation Dave Martin
2013-09-30 15:06 ` [RFC PATCH 1/3] ARM: mcpm: Factor out logical-to-physical CPU translation Dave Martin
2013-09-30 16:51   ` Nicolas Pitre
2013-09-30 15:06 ` [RFC PATCH 2/3] ARM: mcpm: Implement cpu_kill() to synchronise on powerdown Dave Martin
2013-09-30 17:00   ` Nicolas Pitre
2013-09-30 17:20     ` Dave Martin [this message]
2013-09-30 17:32       ` Nicolas Pitre
2013-09-30 15:06 ` [RFC PATCH 3/3] ARM: vexpress/TC2: Implement MCPM power_down_finish() Dave Martin
2013-09-30 17:14   ` Nicolas Pitre
2013-09-30 17:26     ` Dave Martin

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=20130930172055.GC3209@localhost.localdomain \
    --to=dave.martin@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).