linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 08/13] arm64: kernel: implement debug monitors CPU PM notifiers
Date: Tue, 15 Oct 2013 12:27:15 +0100	[thread overview]
Message-ID: <20131015112715.GC30411@mudshark.cambridge.arm.com> (raw)
In-Reply-To: <1381748590-14279-9-git-send-email-lorenzo.pieralisi@arm.com>

On Mon, Oct 14, 2013 at 12:03:05PM +0100, Lorenzo Pieralisi wrote:
> When a CPU is shutdown either through CPU idle or suspend to RAM, the
> content of debug monitor registers must be reset or restored to proper
> values when CPU resume from low power states. This patch implements a
> CPU PM notifier that allows to restore the content of debug monitor
> registers to allow proper suspend/resume operations.

How do you deal with pstate in this series? In particular, the single-step
state machine is partially driven by bits in the SPSR, so you need to be
careful with preserving that (may even require a dummy exception return...
not sure).

> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> ---
>  arch/arm64/kernel/debug-monitors.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
> index cbfacf7..28ce685 100644
> --- a/arch/arm64/kernel/debug-monitors.c
> +++ b/arch/arm64/kernel/debug-monitors.c
> @@ -19,6 +19,7 @@
>   */
>  
>  #include <linux/cpu.h>
> +#include <linux/cpu_pm.h>
>  #include <linux/debugfs.h>
>  #include <linux/hardirq.h>
>  #include <linux/init.h>
> @@ -154,6 +155,42 @@ static struct notifier_block os_lock_nb = {
>  	.notifier_call = os_lock_notify,
>  };
>  
> +#ifdef CONFIG_CPU_PM
> +static DEFINE_PER_CPU(u32, mdscr);
> +
> +static int dm_cpu_pm_notify(struct notifier_block *self, unsigned long action,
> +			    void *v)
> +{
> +	switch (action) {
> +	case CPU_PM_ENTER:
> +		__get_cpu_var(mdscr) = mdscr_read();

I'm concerned about simply saving/restoring the mdscr. Both the MDE and KDE
bits are ref-counted for each CPU, so we'd need to guarantee no context
switching between the CPU_PM_ENTER and CPU_PM_EXIT invocations of this
notifier. Is that the case?

> +		break;
> +	case CPU_PM_EXIT:
> +		clear_os_lock(NULL);
> +		mdscr_write(__get_cpu_var(mdscr));

I think you should do this the other way round. Also, back to PSTATE, you
need to take care when clearing the D bit, since you definitely want to
either restore or zero the mdscr first.

Will

  reply	other threads:[~2013-10-15 11:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-14 11:02 [PATCH v2 00/13] arm64: suspend/resume implementation Lorenzo Pieralisi
2013-10-14 11:02 ` [PATCH v2 01/13] arm64: kernel: add MPIDR_EL1 accessors macros Lorenzo Pieralisi
2013-10-15 10:11   ` Will Deacon
2013-10-15 11:43     ` Lorenzo Pieralisi
2013-10-14 11:02 ` [PATCH v2 02/13] arm64: kernel: build MPIDR_EL1 hash function data structure Lorenzo Pieralisi
2013-10-14 11:03 ` [PATCH v2 03/13] arm64: kernel: suspend/resume registers save/restore Lorenzo Pieralisi
2013-10-15 10:59   ` Will Deacon
2013-10-16  8:59     ` Lorenzo Pieralisi
2013-10-14 11:03 ` [PATCH v2 04/13] arm64: kernel: cpu_{suspend/resume} implementation Lorenzo Pieralisi
2013-10-14 11:03 ` [PATCH v2 05/13] arm64: add CPU PM infrastructure selection Lorenzo Pieralisi
2013-10-14 11:03 ` [PATCH v2 06/13] arm64: kernel: implement fpsimd CPU PM notifier Lorenzo Pieralisi
2013-10-14 11:03 ` [PATCH v2 07/13] arm: kvm: implement " Lorenzo Pieralisi
2013-10-14 11:03 ` [PATCH v2 08/13] arm64: kernel: implement debug monitors CPU PM notifiers Lorenzo Pieralisi
2013-10-15 11:27   ` Will Deacon [this message]
2013-10-14 11:03 ` [PATCH v2 09/13] arm64: kernel: refactor code to install/uninstall breakpoints Lorenzo Pieralisi
2013-10-14 11:03 ` [PATCH v2 10/13] arm64: kernel: implement HW breakpoints CPU PM notifier Lorenzo Pieralisi
2013-10-14 11:03 ` [PATCH v2 11/13] arm64: enable generic clockevent broadcast Lorenzo Pieralisi
2013-10-17  9:15   ` Daniel Lezcano
2013-10-14 11:03 ` [PATCH v2 12/13] arm64: kernel: add CPU idle call Lorenzo Pieralisi
2013-10-17  9:20   ` Daniel Lezcano
2013-10-14 11:03 ` [PATCH v2 13/13] arm64: add CPU power management menu/entries Lorenzo Pieralisi
2013-10-17  9:21   ` Daniel Lezcano

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=20131015112715.GC30411@mudshark.cambridge.arm.com \
    --to=will.deacon@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).