All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks
@ 2017-01-17 12:46 Geert Uytterhoeven
  2017-01-17 12:46 ` [PATCH 1/2] clk: renesas: cpg-mssr: Migrate to CLK_IS_CRITICAL Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-01-17 12:46 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-clk, linux-renesas-soc, Geert Uytterhoeven

	Hi Mike, Stephen,

This patch series adds support for the CLK_IS_CRITICAL flag to drivers
for module clocks on Renesas ARM SoCs.  For now, this is used to prevent
disabling of the ARM GIC module clock, which would lead to a system
lock-up when accessing the GIC's registers.

  1. The first patch migrates the Renesas CPG/MSSR driver from the
     never merged CLK_ENABLE_HAND_OFF flag to the CLK_IS_CRITICAL flag.
     Note that as the driver already handled critical clocks (i.e. it
     ignored them :-), this is not a prerequisite for linking the GIC to
     its module clock in DT.

  2. The second patch makes sure the CLK_IS_CRITICAL flag is set for the
     INTC-SYS clock on SoCs not (yet) using the Renesas CPG/MSSR driver.
     Note that this is a hard dependency for describing the INTC-SYS
     clock in DT on R-Mobile APE6 and R-Car Gen2.

I plan to queue these patches in my clk-renesas-for-v4.11 branch, if
you agree.

Thanks!
        
Geert Uytterhoeven (2):
  clk: renesas: cpg-mssr: Migrate to CLK_IS_CRITICAL
  clk: renesas: mstp: Make INTC-SYS a critical clock

 drivers/clk/renesas/clk-mstp.c         |  5 +++++
 drivers/clk/renesas/renesas-cpg-mssr.c | 11 ++---------
 2 files changed, 7 insertions(+), 9 deletions(-)

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] clk: renesas: cpg-mssr: Migrate to CLK_IS_CRITICAL
  2017-01-17 12:46 [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks Geert Uytterhoeven
@ 2017-01-17 12:46 ` Geert Uytterhoeven
  2017-01-20 23:00   ` Stephen Boyd
  2017-01-17 12:46 ` [PATCH 2/2] clk: renesas: mstp: Make INTC-SYS a critical clock Geert Uytterhoeven
  2017-01-20 23:00 ` [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks Stephen Boyd
  2 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-01-17 12:46 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-clk, linux-renesas-soc, Geert Uytterhoeven

When the Renesas CPG/MSSR driver was introduced, it was anticipated that
critical clocks would be handled through a new CLK_ENABLE_HAND_OFF flag
soon.  However, CLK_ENABLE_HAND_OFF never made it upstream.

Instead, commit 32b9b10961860860 ("clk: Allow clocks to be marked as
CRITICAL") introduced CLK_IS_CRITICAL, a flag with slightly differing
semantics.  Still, it can be used to prevent e.g. the GIC module clock
from being turned off, until the GIC-400 driver has full support for
Runtime PM.

Hence migrate the Renesas CPG/MSSR driver from CLK_ENABLE_HAND_OFF to
CLK_IS_CRITICAL.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Should this have a Fixes tag? ;-)

Fixes: 32b9b10961860860 ("clk: Allow clocks to be marked as CRITICAL")
---
 drivers/clk/renesas/renesas-cpg-mssr.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c
index 8359ce75db7aa4fb..6947482d48a55094 100644
--- a/drivers/clk/renesas/renesas-cpg-mssr.c
+++ b/drivers/clk/renesas/renesas-cpg-mssr.c
@@ -346,17 +346,10 @@ static void __init cpg_mssr_register_mod_clk(const struct mssr_mod_clk *mod,
 	init.flags = CLK_IS_BASIC | CLK_SET_RATE_PARENT;
 	for (i = 0; i < info->num_crit_mod_clks; i++)
 		if (id == info->crit_mod_clks[i]) {
-#ifdef CLK_ENABLE_HAND_OFF
-			dev_dbg(dev, "MSTP %s setting CLK_ENABLE_HAND_OFF\n",
+			dev_dbg(dev, "MSTP %s setting CLK_IS_CRITICAL\n",
 				mod->name);
-			init.flags |= CLK_ENABLE_HAND_OFF;
+			init.flags |= CLK_IS_CRITICAL;
 			break;
-#else
-			dev_dbg(dev, "Ignoring MSTP %s to prevent disabling\n",
-				mod->name);
-			kfree(clock);
-			return;
-#endif
 		}
 
 	parent_name = __clk_get_name(parent);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] clk: renesas: mstp: Make INTC-SYS a critical clock
  2017-01-17 12:46 [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks Geert Uytterhoeven
  2017-01-17 12:46 ` [PATCH 1/2] clk: renesas: cpg-mssr: Migrate to CLK_IS_CRITICAL Geert Uytterhoeven
@ 2017-01-17 12:46 ` Geert Uytterhoeven
  2017-01-20 23:12   ` Stephen Boyd
  2017-01-20 23:00 ` [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks Stephen Boyd
  2 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-01-17 12:46 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-clk, linux-renesas-soc, Geert Uytterhoeven

INTC-SYS is the module clock for the GIC.  Accessing the GIC while it is
disabled causes:

    Unhandled fault: asynchronous external abort (0x1211) at 0x00000000

Currently, the GIC-400 driver cannot enable its module clock for several
reasons:
  - It does not use a platform device, so Runtime PM is not an option,
  - gic_of_init() runs before any clocks are registered, so it cannot
    enable the clock explicitly,
  - gic_of_init() cannot return -EPROBE_DEFER, as IRQCHIP_DECLARE()
    doesn't support deferred probing.

Hence we have to keep on relying on the boot loader for enabling the
module clock.

To prevent the module clock from being disabled when the CCF core thinks
it is unused, and thus causing a system lock-up, add a check to the MSTP
clock driver and enable CLK_IS_CRITICAL. This will make sure the module
clock is never disabled.

This is a hard dependency for describing the INTC-SYS clock in DT on
R-Mobile APE6 and R-Car Gen2.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
This is v2 of "[PATCH/RFC 1/5] clk: renesas: mstp: Never disable
INTC-SYS".

v2:
  - Use the new CLK_ENABLE_HAND_OFF flag instead of adding a quirk to
    cpg_mstp_clock_endisable(),
  - drivers/clk/shmobile/ was renamed to drivers/clk/renesas/,
  - Migrate from CLK_ENABLE_HAND_OFF to CLK_IS_CRITICAL.
---
 drivers/clk/renesas/clk-mstp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 9375777776d99407..c0319b8acf3521a2 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -144,6 +144,11 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw)
 	init.name = name;
 	init.ops = &cpg_mstp_clock_ops;
 	init.flags = CLK_IS_BASIC | CLK_SET_RATE_PARENT;
+	/* INTC-SYS is the module clock of the GIC, and must not be disabled */
+	if (!strcmp(name, "intc-sys")) {
+		pr_debug("MSTP %s setting CLK_IS_CRITICAL\n", name);
+		init.flags |= CLK_IS_CRITICAL;
+	}
 	init.parent_names = &parent_name;
 	init.num_parents = 1;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks
  2017-01-17 12:46 [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks Geert Uytterhoeven
  2017-01-17 12:46 ` [PATCH 1/2] clk: renesas: cpg-mssr: Migrate to CLK_IS_CRITICAL Geert Uytterhoeven
  2017-01-17 12:46 ` [PATCH 2/2] clk: renesas: mstp: Make INTC-SYS a critical clock Geert Uytterhoeven
@ 2017-01-20 23:00 ` Stephen Boyd
  2017-01-23  9:34   ` Geert Uytterhoeven
  2 siblings, 1 reply; 8+ messages in thread
From: Stephen Boyd @ 2017-01-20 23:00 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Michael Turquette, linux-clk, linux-renesas-soc

On 01/17, Geert Uytterhoeven wrote:
> 	Hi Mike, Stephen,
> 
> This patch series adds support for the CLK_IS_CRITICAL flag to drivers
> for module clocks on Renesas ARM SoCs.  For now, this is used to prevent
> disabling of the ARM GIC module clock, which would lead to a system
> lock-up when accessing the GIC's registers.
> 
>   1. The first patch migrates the Renesas CPG/MSSR driver from the
>      never merged CLK_ENABLE_HAND_OFF flag to the CLK_IS_CRITICAL flag.
>      Note that as the driver already handled critical clocks (i.e. it
>      ignored them :-), this is not a prerequisite for linking the GIC to
>      its module clock in DT.
> 
>   2. The second patch makes sure the CLK_IS_CRITICAL flag is set for the
>      INTC-SYS clock on SoCs not (yet) using the Renesas CPG/MSSR driver.
>      Note that this is a hard dependency for describing the INTC-SYS
>      clock in DT on R-Mobile APE6 and R-Car Gen2.
> 
> I plan to queue these patches in my clk-renesas-for-v4.11 branch, if
> you agree.
> 

Would the runtime PM patches for ccf make things any better here?
I still plan to support CLK_ENABLE_HAND_OFF somehow, but it's not
at the top of my priority list right now.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] clk: renesas: cpg-mssr: Migrate to CLK_IS_CRITICAL
  2017-01-17 12:46 ` [PATCH 1/2] clk: renesas: cpg-mssr: Migrate to CLK_IS_CRITICAL Geert Uytterhoeven
@ 2017-01-20 23:00   ` Stephen Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2017-01-20 23:00 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Michael Turquette, linux-clk, linux-renesas-soc

On 01/17, Geert Uytterhoeven wrote:
> When the Renesas CPG/MSSR driver was introduced, it was anticipated that
> critical clocks would be handled through a new CLK_ENABLE_HAND_OFF flag
> soon.  However, CLK_ENABLE_HAND_OFF never made it upstream.
> 
> Instead, commit 32b9b10961860860 ("clk: Allow clocks to be marked as
> CRITICAL") introduced CLK_IS_CRITICAL, a flag with slightly differing
> semantics.  Still, it can be used to prevent e.g. the GIC module clock
> from being turned off, until the GIC-400 driver has full support for
> Runtime PM.
> 
> Hence migrate the Renesas CPG/MSSR driver from CLK_ENABLE_HAND_OFF to
> CLK_IS_CRITICAL.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---

Acked-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] clk: renesas: mstp: Make INTC-SYS a critical clock
  2017-01-17 12:46 ` [PATCH 2/2] clk: renesas: mstp: Make INTC-SYS a critical clock Geert Uytterhoeven
@ 2017-01-20 23:12   ` Stephen Boyd
  2017-01-23  9:50     ` Geert Uytterhoeven
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Boyd @ 2017-01-20 23:12 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Michael Turquette, linux-clk, linux-renesas-soc

On 01/17, Geert Uytterhoeven wrote:
> INTC-SYS is the module clock for the GIC.  Accessing the GIC while it is
> disabled causes:
> 
>     Unhandled fault: asynchronous external abort (0x1211) at 0x00000000
> 
> Currently, the GIC-400 driver cannot enable its module clock for several
> reasons:
>   - It does not use a platform device, so Runtime PM is not an option,
>   - gic_of_init() runs before any clocks are registered, so it cannot
>     enable the clock explicitly,
>   - gic_of_init() cannot return -EPROBE_DEFER, as IRQCHIP_DECLARE()
>     doesn't support deferred probing.
> 
> Hence we have to keep on relying on the boot loader for enabling the
> module clock.
> 
> To prevent the module clock from being disabled when the CCF core thinks
> it is unused, and thus causing a system lock-up, add a check to the MSTP
> clock driver and enable CLK_IS_CRITICAL. This will make sure the module
> clock is never disabled.
> 
> This is a hard dependency for describing the INTC-SYS clock in DT on
> R-Mobile APE6 and R-Car Gen2.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---

Acked-by: Stephen Boyd <sboyd@codeaurora.org>

> diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
> index 9375777776d99407..c0319b8acf3521a2 100644
> --- a/drivers/clk/renesas/clk-mstp.c
> +++ b/drivers/clk/renesas/clk-mstp.c
> @@ -144,6 +144,11 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw)

Sad that git gets confused about which function this is in.

>  	init.name = name;
>  	init.ops = &cpg_mstp_clock_ops;
>  	init.flags = CLK_IS_BASIC | CLK_SET_RATE_PARENT;
> +	/* INTC-SYS is the module clock of the GIC, and must not be disabled */
> +	if (!strcmp(name, "intc-sys")) {
> +		pr_debug("MSTP %s setting CLK_IS_CRITICAL\n", name);
> +		init.flags |= CLK_IS_CRITICAL;
> +	}
>  	init.parent_names = &parent_name;
>  	init.num_parents = 1;
>  

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks
  2017-01-20 23:00 ` [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks Stephen Boyd
@ 2017-01-23  9:34   ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-01-23  9:34 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Geert Uytterhoeven, Michael Turquette, linux-clk, Linux-Renesas

Hi Stephen,

On Sat, Jan 21, 2017 at 12:00 AM, Stephen Boyd <sboyd@codeaurora.org> wrote:
> On 01/17, Geert Uytterhoeven wrote:
>> This patch series adds support for the CLK_IS_CRITICAL flag to drivers
>> for module clocks on Renesas ARM SoCs.  For now, this is used to prevent
>> disabling of the ARM GIC module clock, which would lead to a system
>> lock-up when accessing the GIC's registers.
>>
>>   1. The first patch migrates the Renesas CPG/MSSR driver from the
>>      never merged CLK_ENABLE_HAND_OFF flag to the CLK_IS_CRITICAL flag.
>>      Note that as the driver already handled critical clocks (i.e. it
>>      ignored them :-), this is not a prerequisite for linking the GIC to
>>      its module clock in DT.
>>
>>   2. The second patch makes sure the CLK_IS_CRITICAL flag is set for the
>>      INTC-SYS clock on SoCs not (yet) using the Renesas CPG/MSSR driver.
>>      Note that this is a hard dependency for describing the INTC-SYS
>>      clock in DT on R-Mobile APE6 and R-Car Gen2.
>>
>> I plan to queue these patches in my clk-renesas-for-v4.11 branch, if
>> you agree.
>
> Would the runtime PM patches for ccf make things any better here?

It won't make much of a difference, as typically you'll want the GIC running
all the time anyway, also for wake-up sources.
We just have to make sure it's not disabled indefinitely.

As such it's different from a real critical clock that kills the system
immediately (e.g. some secret core clock): you can disable the GIC clock,
just make sure to enable it again (and have a means to re-enable it, without
relying on interrupts ;-)

The only difference with a real critical clock is that you
> I still plan to support CLK_ENABLE_HAND_OFF somehow, but it's not
> at the top of my priority list right now.

Good, we can convert back later, perhaps when the GIC driver is ready to
support PM for non-secondary GICs...

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] clk: renesas: mstp: Make INTC-SYS a critical clock
  2017-01-20 23:12   ` Stephen Boyd
@ 2017-01-23  9:50     ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-01-23  9:50 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Geert Uytterhoeven, Michael Turquette, linux-clk, Linux-Renesas

Hi Stephen,

On Sat, Jan 21, 2017 at 12:12 AM, Stephen Boyd <sboyd@codeaurora.org> wrote:
> On 01/17, Geert Uytterhoeven wrote:
>> INTC-SYS is the module clock for the GIC.  Accessing the GIC while it is
>> disabled causes:
>>
>>     Unhandled fault: asynchronous external abort (0x1211) at 0x00000000
>>
>> Currently, the GIC-400 driver cannot enable its module clock for several
>> reasons:
>>   - It does not use a platform device, so Runtime PM is not an option,
>>   - gic_of_init() runs before any clocks are registered, so it cannot
>>     enable the clock explicitly,
>>   - gic_of_init() cannot return -EPROBE_DEFER, as IRQCHIP_DECLARE()
>>     doesn't support deferred probing.
>>
>> Hence we have to keep on relying on the boot loader for enabling the
>> module clock.
>>
>> To prevent the module clock from being disabled when the CCF core thinks
>> it is unused, and thus causing a system lock-up, add a check to the MSTP
>> clock driver and enable CLK_IS_CRITICAL. This will make sure the module
>> clock is never disabled.
>>
>> This is a hard dependency for describing the INTC-SYS clock in DT on
>> R-Mobile APE6 and R-Car Gen2.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> ---
>
> Acked-by: Stephen Boyd <sboyd@codeaurora.org>

Thanks!

>> diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
>> index 9375777776d99407..c0319b8acf3521a2 100644
>> --- a/drivers/clk/renesas/clk-mstp.c
>> +++ b/drivers/clk/renesas/clk-mstp.c
>> @@ -144,6 +144,11 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw)
>
> Sad that git gets confused about which function this is in.

Indeed. Will send a patch to fix that...

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-01-23  9:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-17 12:46 [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks Geert Uytterhoeven
2017-01-17 12:46 ` [PATCH 1/2] clk: renesas: cpg-mssr: Migrate to CLK_IS_CRITICAL Geert Uytterhoeven
2017-01-20 23:00   ` Stephen Boyd
2017-01-17 12:46 ` [PATCH 2/2] clk: renesas: mstp: Make INTC-SYS a critical clock Geert Uytterhoeven
2017-01-20 23:12   ` Stephen Boyd
2017-01-23  9:50     ` Geert Uytterhoeven
2017-01-20 23:00 ` [PATCH 0/2] clk: renesas: Use CLK_IS_CRITICAL to handle critical clocks Stephen Boyd
2017-01-23  9:34   ` Geert Uytterhoeven

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.