From: Dirk Behme <dirk.behme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Uwe Kleine-König"
<u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
"Rob Herring" <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Geert Uytterhoeven
<geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Dirk Behme <dirk.behme-V5te9oGctAVWk0Htik3J/w@public.gmane.org>,
Linux PM list <linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Stephen Boyd <sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
Michael Turquette
<mturquette-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>,
"Rafael J. Wysocki" <rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org>,
Linux-Renesas
<linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Kevin Hilman <khilman-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>,
linux-clk <linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: Clocks used by another OS/CPU (was: Re: [RFC PATCH] clk: renesas: cpg-mssr: Add interface for critical core clocks)
Date: Sat, 1 Jul 2017 07:02:48 +0200 [thread overview]
Message-ID: <8d86a9aa-1928-6b52-1487-d5fb9dae17f4@gmail.com> (raw)
In-Reply-To: <20170630202453.eh6vaehkap3as4np-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
On 30.06.2017 22:24, Uwe Kleine-König wrote:
> Hello,
>
> On Fri, Jun 30, 2017 at 10:58:26AM -0500, Rob Herring wrote:
>>> TL;DR: Clocks may be in use by another CPU not running Linux, while Linux
>>> disables them as being unused.
>
> not long ago I thought with a few colleagues about this. The scenario is
> to start a Linux kernel on a Cortex-M companion to a Cortex-A.
>
>>> On Mon, Jun 26, 2017 at 1:30 PM, Dirk Behme <dirk.behme-V5te9oGctAVWk0Htik3J/w@public.gmane.org> wrote:
>>>> With commit 72f5df2c2bbb6 ("clk: renesas: cpg-mssr: Migrate to
>>>> CLK_IS_CRITICAL") we are able to handle critical module clocks.
>>>> Introduce the same logic for critical core clocks.
>>>>
>>>> Signed-off-by: Dirk Behme <dirk.behme-V5te9oGctAVWk0Htik3J/w@public.gmane.org>
>>>> ---
>>>> Commit
>>>>
>>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/clk/renesas?id=72f5df2c2bbb66d4a555cb51eb9f412abf1af77f
>>>>
>>>> is quite nice to avoid *module* clocks being disabled. Unfortunately,
>>>> there are *core* clocks, too. E.g. using an other OS on the Cortex R7
>>>> core of the r8a7795, the 'canfd' is a quite popular core clock which
>>>> shouldn't be disabled by Linux.
>>>>
>>>> Therefore, this patch is a proposal to use the same 'mark clocks as
>>>> critical' logic implemented for the module clocks for the core
>>>> clocks, too.
>>>>
>>>> Opinions?
>>>
>>> On r8a7795, there are several Cortex A cores running Linux, and a Cortex R7
>>> core which may run another OS.
>>> This is an interesting issue, and relevant to other SoCs, too.
>>>
>>> In this particular case, the "canfd" clock is a core clock used as an
>>> auxiliary clock for the CAN0, CAN1, and CANFD interfaces. This can lead
>>> to three scenarios:
>>> 1. Linux controls all CAN interfaces
>>> => no issue,
>>> 2. The OS on the RT CPU controls all CAN interfaces
>>> => issue, Linux disables the clock
>>> 3. Mix of 1 and 2
>>> => More issues.
>>> Of course this is not limited to clocks, but also to e.g. PM domains.
>>>
>>> How can this be handled?
>>> I believe just marking the "canfd" clock critical is not the right solution,
>>> as about any clock could be used by the RT CPU.
>>>
>>> Still, Linux needs to be made aware that devices (clocks and PM domains) are
>>> controlled by another CPU/OS.
>>>
>>> Should this be described in DT? It feels like software policy to me.
>>
>> No, it shouldn't. It is Linux policy to disable all unused clocks, so
>> Linux gets to deal with the consequences.
>
> The ideal solution I imagine is to make the other CPU's OS a consumer of
> the Linux clock driver. This would require a generic device driver on the
> companion CPU that forwards clk requests via inter-cpu communication to
> the Linux clk driver. It could be feed with the necessary information by
> the rproc glue. So when the companion cpu is supposed to care for the
> can0 device, the steps that should happen are:
>
> - make sure can0 isn't occupied by the Linux Host
> - reroute the can irq to the companion cpu (if necessary)
> - create a dtb containing something like this for the companion CPU:
>
> clks: virtclk {
> compatible = ???
> #clock-cells = <1>;
> ...
> };
>
> can@$address {
> compatible = ...
> regs = ...
> clocks = <&clks 3>;
> clock-names = ...
> ...
> };
>
> where the driver binding to the virtclk device just forwards clk
> requests to the Linux host side which then knows that clk 3 is the
> can clock and does the necessary stuff.
>
> This way the can clock doesn't need special handling in the host's dtb
> and no clock necessary for the companion is disabled as unused because
> it is requested and enabled.
>
> The only problem I see is that implementing such a driver/protocol
> probably is time consuming.
The other problem is security related. If, at all, you have to do it
the other way around, then:
Make Linux a consumer of the other CPU's (trusted/trustzone/whatever
secured) OS clock driver.
Best regards
Dirk
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-07-01 5:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-29 9:27 Clocks used by another OS/CPU (was: Re: [RFC PATCH] clk: renesas: cpg-mssr: Add interface for critical core clocks) Geert Uytterhoeven
2017-06-29 10:28 ` Dirk Behme
2017-06-29 11:18 ` Geert Uytterhoeven
2017-06-29 13:18 ` Clocks used by another OS/CPU Dirk Behme
2017-06-29 13:22 ` Geert Uytterhoeven
[not found] ` <CAMuHMdW9+CNTTOVO4SRRUxuz3ajLbY2j1uG8b_RpHX52NPwXrQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-29 11:56 ` Clocks used by another OS/CPU (was: Re: [RFC PATCH] clk: renesas: cpg-mssr: Add interface for critical core clocks) Geert Uytterhoeven
2017-06-29 12:07 ` Clocks used by another OS/CPU Dirk Behme
2017-06-29 12:45 ` Geert Uytterhoeven
2017-06-29 12:55 ` Dirk Behme
2017-06-30 8:02 ` Clocks used by another OS/CPU (was: Re: [RFC PATCH] clk: renesas: cpg-mssr: Add interface for critical core clocks) Peter De Schrijver
2017-06-30 15:58 ` Rob Herring
2017-06-30 20:24 ` Uwe Kleine-König
[not found] ` <20170630202453.eh6vaehkap3as4np-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-07-01 5:02 ` Dirk Behme [this message]
2017-07-01 18:14 ` Uwe Kleine-König
2017-07-02 5:48 ` Dirk Behme
[not found] ` <6098d579-f206-5a23-bbfc-ac13e0448479-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-07-02 9:23 ` Uwe Kleine-König
2017-07-03 7:40 ` Geert Uytterhoeven
[not found] ` <20170701181408.yuocymwtj5dgt74d-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-07-03 9:17 ` Sudeep Holla
2017-07-04 7:31 ` Peter De Schrijver
2017-07-04 8:49 ` Sudeep Holla
2017-07-05 7:25 ` Peter De Schrijver
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=8d86a9aa-1928-6b52-1487-d5fb9dae17f4@gmail.com \
--to=dirk.behme-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dirk.behme-V5te9oGctAVWk0Htik3J/w@public.gmane.org \
--cc=geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
--cc=khilman-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=mturquette-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
--cc=rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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