From: Will Deacon <will.deacon@arm.com>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH/RFC v2 1/4] ARM: hw_breakpoint: Add arm_dbg_regs_available flag
Date: Tue, 30 Sep 2014 16:03:31 +0000 [thread overview]
Message-ID: <20140930160331.GN2548@arm.com> (raw)
In-Reply-To: <1412079987-1827-2-git-send-email-geert+renesas@glider.be>
Hi Geert,
On Tue, Sep 30, 2014 at 01:26:24PM +0100, Geert Uytterhoeven wrote:
> If power area D4, which contains the Coresight-ETM hardware block, is
> powered down on R-Mobile A1 (r8a7740), the kernel crashes when
> suspending from s2ram with:
>
> Internal error: Oops - undefined instruction: 0 [#1] ARM
>
> This happens because dbg_cpu_pm_notify() calls reset_ctrl_regs(), which
> can't access the debug registers as the debug module is powered down.
>
> As suggested by Russell King, track whether the ETM block is powered down
> to fix this.
>
> The availability of the debug registers depends on the platform and its
> state. Hence provide a mechanism for platform code to indicate that the
> debug registers are available or not, using a boolean flag that defaults
> to true.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2:
> - New
>
> arch/arm/include/asm/hw_breakpoint.h | 2 ++
> arch/arm/kernel/hw_breakpoint.c | 7 +++++++
> 2 files changed, 9 insertions(+)
>
> diff --git a/arch/arm/include/asm/hw_breakpoint.h b/arch/arm/include/asm/hw_breakpoint.h
> index 8e427c7b44257d2d..51ffdae41bfe3754 100644
> --- a/arch/arm/include/asm/hw_breakpoint.h
> +++ b/arch/arm/include/asm/hw_breakpoint.h
> @@ -110,6 +110,8 @@ static inline void decode_ctrl_reg(u32 reg,
> asm volatile("mcr p14, 0, %0, " #N "," #M ", " #OP2 : : "r" (VAL));\
> } while (0)
>
> +extern bool arm_dbg_regs_available;
> +
> struct notifier_block;
> struct perf_event;
> struct pmu;
> diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
> index b5b452f90f761bd2..96193c0165fbe5ca 100644
> --- a/arch/arm/kernel/hw_breakpoint.c
> +++ b/arch/arm/kernel/hw_breakpoint.c
> @@ -38,6 +38,8 @@
> #include <asm/traps.h>
> #include <asm/hardware/coresight.h>
>
> +bool arm_dbg_regs_available = true;
> +
> /* Breakpoint currently in use for each BRP. */
> static DEFINE_PER_CPU(struct perf_event *, bp_on_reg[ARM_MAX_BRP]);
>
> @@ -931,6 +933,11 @@ static void reset_ctrl_regs(void *unused)
> int i, raw_num_brps, err = 0, cpu = smp_processor_id();
> u32 val;
>
> + if (!arm_dbg_regs_available) {
> + pr_warn_once("Debug registers are not available\n");
> + return;
> + }
Whilst I guess this solves your problem, it doesn't feel like a scalable fix
for something that can/will assumedly happen elsewhere in an SoC (e.g. PMU
registers in perf). I'd much rather have a generic abstraction for power
domains, which subsystems such as hw_breakpoint can attempt to take a
reference on when they want to access registers in that domain.
Will
WARNING: multiple messages have this Message-ID (diff)
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH/RFC v2 1/4] ARM: hw_breakpoint: Add arm_dbg_regs_available flag
Date: Tue, 30 Sep 2014 17:03:31 +0100 [thread overview]
Message-ID: <20140930160331.GN2548@arm.com> (raw)
In-Reply-To: <1412079987-1827-2-git-send-email-geert+renesas@glider.be>
Hi Geert,
On Tue, Sep 30, 2014 at 01:26:24PM +0100, Geert Uytterhoeven wrote:
> If power area D4, which contains the Coresight-ETM hardware block, is
> powered down on R-Mobile A1 (r8a7740), the kernel crashes when
> suspending from s2ram with:
>
> Internal error: Oops - undefined instruction: 0 [#1] ARM
>
> This happens because dbg_cpu_pm_notify() calls reset_ctrl_regs(), which
> can't access the debug registers as the debug module is powered down.
>
> As suggested by Russell King, track whether the ETM block is powered down
> to fix this.
>
> The availability of the debug registers depends on the platform and its
> state. Hence provide a mechanism for platform code to indicate that the
> debug registers are available or not, using a boolean flag that defaults
> to true.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2:
> - New
>
> arch/arm/include/asm/hw_breakpoint.h | 2 ++
> arch/arm/kernel/hw_breakpoint.c | 7 +++++++
> 2 files changed, 9 insertions(+)
>
> diff --git a/arch/arm/include/asm/hw_breakpoint.h b/arch/arm/include/asm/hw_breakpoint.h
> index 8e427c7b44257d2d..51ffdae41bfe3754 100644
> --- a/arch/arm/include/asm/hw_breakpoint.h
> +++ b/arch/arm/include/asm/hw_breakpoint.h
> @@ -110,6 +110,8 @@ static inline void decode_ctrl_reg(u32 reg,
> asm volatile("mcr p14, 0, %0, " #N "," #M ", " #OP2 : : "r" (VAL));\
> } while (0)
>
> +extern bool arm_dbg_regs_available;
> +
> struct notifier_block;
> struct perf_event;
> struct pmu;
> diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
> index b5b452f90f761bd2..96193c0165fbe5ca 100644
> --- a/arch/arm/kernel/hw_breakpoint.c
> +++ b/arch/arm/kernel/hw_breakpoint.c
> @@ -38,6 +38,8 @@
> #include <asm/traps.h>
> #include <asm/hardware/coresight.h>
>
> +bool arm_dbg_regs_available = true;
> +
> /* Breakpoint currently in use for each BRP. */
> static DEFINE_PER_CPU(struct perf_event *, bp_on_reg[ARM_MAX_BRP]);
>
> @@ -931,6 +933,11 @@ static void reset_ctrl_regs(void *unused)
> int i, raw_num_brps, err = 0, cpu = smp_processor_id();
> u32 val;
>
> + if (!arm_dbg_regs_available) {
> + pr_warn_once("Debug registers are not available\n");
> + return;
> + }
Whilst I guess this solves your problem, it doesn't feel like a scalable fix
for something that can/will assumedly happen elsewhere in an SoC (e.g. PMU
registers in perf). I'd much rather have a generic abstraction for power
domains, which subsystems such as hw_breakpoint can attempt to take a
reference on when they want to access registers in that domain.
Will
WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Russell King <linux@arm.linux.org.uk>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Simon Horman <horms@verge.net.au>,
Magnus Damm <magnus.damm@gmail.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-sh@vger.kernel.org" <linux-sh@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH/RFC v2 1/4] ARM: hw_breakpoint: Add arm_dbg_regs_available flag
Date: Tue, 30 Sep 2014 17:03:31 +0100 [thread overview]
Message-ID: <20140930160331.GN2548@arm.com> (raw)
In-Reply-To: <1412079987-1827-2-git-send-email-geert+renesas@glider.be>
Hi Geert,
On Tue, Sep 30, 2014 at 01:26:24PM +0100, Geert Uytterhoeven wrote:
> If power area D4, which contains the Coresight-ETM hardware block, is
> powered down on R-Mobile A1 (r8a7740), the kernel crashes when
> suspending from s2ram with:
>
> Internal error: Oops - undefined instruction: 0 [#1] ARM
>
> This happens because dbg_cpu_pm_notify() calls reset_ctrl_regs(), which
> can't access the debug registers as the debug module is powered down.
>
> As suggested by Russell King, track whether the ETM block is powered down
> to fix this.
>
> The availability of the debug registers depends on the platform and its
> state. Hence provide a mechanism for platform code to indicate that the
> debug registers are available or not, using a boolean flag that defaults
> to true.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2:
> - New
>
> arch/arm/include/asm/hw_breakpoint.h | 2 ++
> arch/arm/kernel/hw_breakpoint.c | 7 +++++++
> 2 files changed, 9 insertions(+)
>
> diff --git a/arch/arm/include/asm/hw_breakpoint.h b/arch/arm/include/asm/hw_breakpoint.h
> index 8e427c7b44257d2d..51ffdae41bfe3754 100644
> --- a/arch/arm/include/asm/hw_breakpoint.h
> +++ b/arch/arm/include/asm/hw_breakpoint.h
> @@ -110,6 +110,8 @@ static inline void decode_ctrl_reg(u32 reg,
> asm volatile("mcr p14, 0, %0, " #N "," #M ", " #OP2 : : "r" (VAL));\
> } while (0)
>
> +extern bool arm_dbg_regs_available;
> +
> struct notifier_block;
> struct perf_event;
> struct pmu;
> diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
> index b5b452f90f761bd2..96193c0165fbe5ca 100644
> --- a/arch/arm/kernel/hw_breakpoint.c
> +++ b/arch/arm/kernel/hw_breakpoint.c
> @@ -38,6 +38,8 @@
> #include <asm/traps.h>
> #include <asm/hardware/coresight.h>
>
> +bool arm_dbg_regs_available = true;
> +
> /* Breakpoint currently in use for each BRP. */
> static DEFINE_PER_CPU(struct perf_event *, bp_on_reg[ARM_MAX_BRP]);
>
> @@ -931,6 +933,11 @@ static void reset_ctrl_regs(void *unused)
> int i, raw_num_brps, err = 0, cpu = smp_processor_id();
> u32 val;
>
> + if (!arm_dbg_regs_available) {
> + pr_warn_once("Debug registers are not available\n");
> + return;
> + }
Whilst I guess this solves your problem, it doesn't feel like a scalable fix
for something that can/will assumedly happen elsewhere in an SoC (e.g. PMU
registers in perf). I'd much rather have a generic abstraction for power
domains, which subsystems such as hw_breakpoint can attempt to take a
reference on when they want to access registers in that domain.
Will
next prev parent reply other threads:[~2014-09-30 16:03 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-30 12:26 [PATCH/RFC v2 0/4] ARM: hw_breakpoint: Avoid undef instruction exceptions on wake-up Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` [PATCH/RFC v2 1/4] ARM: hw_breakpoint: Add arm_dbg_regs_available flag Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 16:03 ` Will Deacon [this message]
2014-09-30 16:03 ` Will Deacon
2014-09-30 16:03 ` Will Deacon
2014-10-01 7:41 ` Geert Uytterhoeven
2014-10-01 7:41 ` Geert Uytterhoeven
2014-10-01 7:41 ` Geert Uytterhoeven
2014-10-01 14:38 ` Mathieu Poirier
2014-10-01 14:38 ` Mathieu Poirier
2014-10-01 14:38 ` Mathieu Poirier
2014-10-01 20:26 ` Geert Uytterhoeven
2014-10-01 20:26 ` Geert Uytterhoeven
2014-10-01 20:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` [PATCH/RFC v2 2/4] ARM: shmobile: r8a7740 legacy: Sync arm_dbg_regs_available with D4 PM domain Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` [PATCH/RFC v2 3/4] ARM: shmobile: R-Mobile: " Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` [PATCH/RFC v2 4/4] ARM: shmobile: r8a7740 dtsi: Add minimal device node for Coresight-ETM Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
2014-09-30 12:26 ` Geert Uytterhoeven
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=20140930160331.GN2548@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 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.