All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: Kevin Hilman <khilman@kernel.org>
Cc: amit daniel kachhap <amit.daniel@samsung.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Kukjin Kim <kgene.kim@samsung.com>,
	Mike Turquette <mturquette@linaro.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	pankaj.dubey@samsung.com,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	LAK <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 03/12] PM / Domains: Add notifier support for power domain transitions
Date: Fri, 28 Nov 2014 19:04:32 +0100	[thread overview]
Message-ID: <5478B930.4090300@samsung.com> (raw)
In-Reply-To: <7h8ujmsvcv.fsf@deeprootsystems.com>

On 07/11/14 19:45, Kevin Hilman wrote:
> Sylwester Nawrocki <s.nawrocki@samsung.com> writes:
>> On 04/11/14 07:44, amit daniel kachhap wrote:
>>> On Mon, Nov 3, 2014 at 11:53 PM, Kevin Hilman <khilman@kernel.org> wrote:
>>>> "Rafael J. Wysocki" <rjw@rjwysocki.net> writes:
>>>>> On Monday, November 03, 2014 09:23:01 AM Amit Daniel Kachhap wrote:
[...]
>> Indeed, the somehow complicated power domain power on/off sequences
>> are SoC specific.  They involve not only groups of clocks (usually
>> gate, mux clock registers of all devices in a power domain) but also
>> SoC-specific PMU (Power Management Unit) registers.
>> I assume it would be inappropriate to push such details to device 
>> drivers.  Moreover, a device driver could not be even loaded.
>>
>> Since the clocks' state is already maintained by clk driver we came 
>> up with an idea of having generic calls from power domain driver back 
>> to the clock controller driver.
> 
> For the clock tree, it still seems to me that this is better handled in
> the SoC clock driver.  For example, when a power domain is about to be
> gated, all the devices in that domain are runtime suspended, and
> presumably all of their gate clocks are disabled.  Now, doesn't the
> clock driver know the clock tree parent-child hierarchy and shouldn't it
> be capable of saving the state of parent clocks (like mux clocks) etc?
> 
> Stated diffrently, it still seems to me like we're pushing functionality
> in PM core notifiers that should be the responsibility of subsystem
> drivers. 

My apologies for not replying earlier, I got distracted by other 
activities.

I'd prefer not adding anything new to the PM core, however there are
dependencies between the power domain and clock controller driver 
which are hard to model in the current APIs.  I assume resorting to 
inter-exynos-driver API is not a good idea either.

Saving/restoring the clock hierarchy in the clock controller driver
during the power domain state transitions has a caveat that the clock
turn off/on sequences are IP/SoC subsystem specific.  So simply 
restoring saved registers from memory is not going to work.

The other detail I might have forgotten to mention is that the whole
clock controller may be in same power domain as the consumer devices.
That means the clock controller's registers must not be touched when
a related power domain is turned off.  Naturally when a power domain 
gets switched off all the clock controller's registers reset to their 
default values.  If we decided to use pm_runtime_{get_sync, put} in
the clock controller driver I'm not sure how it would need to interact
with the clk API.
In current mainline there is an issue with exynos4x12 that the system
may hang if clk_summary is attempted to read as the clock controller
driver doesn't take the ISP power domain into account.

[...]
>>>> Personally, I'm uncomfortable with notifiers like this because it
>>>> suggests that underlying frameworks are not doing the right thing, or
>>>> are not being used.  (I also don't like the implementation here where a
>>>> single global notifier list is maintained by the core, but the notifiers
>>>> are actually triggered by SoC specific code.)
>>>
>>> Yes right the global notifier block can be moved to per genpd structure.
>>> Also SoC trigger can be moved to core files.
>>>>
>>>> IIUC, the usage in this series seems to be that certain clock related
>>>> registers need to be saved/restored across a power domain transition.
>>>>
>>>> Wouldn't an alternative solution be to add a feature to the clock driver
>>>> such that the state of each clock is saved when the clock is disabled,
>>>> and restored when the clock is enabled?   That would allow any clock
>>>> context to survive any power domain transtion also, correct?
>>>
>>> I also thought about same. But the trigger point for this would be
>>> driver calling clk disable/enable and not the power domain. so this 
>>> will lead to lot of save/restore for each power domain child.
>>
>> Even though we would have saved/restored at that points still the power
>> domain driver would need to enforce some specific clock/PMU registers 
>> state before/after a power domain state transition. And this is what I 
>> found difficult with the existing APIs.
> 
> This is what I'm not understanding.
> 
> Why can't the power domain driver's power_on/power_off callback just
> call the PMU APIs and/or the clk_enable/_disable calls it needs?

I was concerned that it would not have been reliable by using the clk 
API due to the clk enable refcounting.  But that might not be a valid 
argument, since as you pointed out when a power domain is about to 
be gated related the clocks should be already disabled.

The other concern was atomicity in enabling/disabling groups of clocks,
i.e. setting group of bits in a clock gate register at once, rather
than a bit for each clock one by one.  But I'm not 100% sure about 
such a hardware requirement myself, would need to do some more testing 
and/or find a hardware engineer who could explain this. 

Additionally specifying clocks in device tree would be a bit messy and
there would very likely anyway be an additional information required 
in the power domain driver per each power domain regarding the clock 
handling sequence. 

-- 
Regards,
Sylwester

WARNING: multiple messages have this Message-ID (diff)
From: s.nawrocki@samsung.com (Sylwester Nawrocki)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/12] PM / Domains: Add notifier support for power domain transitions
Date: Fri, 28 Nov 2014 19:04:32 +0100	[thread overview]
Message-ID: <5478B930.4090300@samsung.com> (raw)
In-Reply-To: <7h8ujmsvcv.fsf@deeprootsystems.com>

On 07/11/14 19:45, Kevin Hilman wrote:
> Sylwester Nawrocki <s.nawrocki@samsung.com> writes:
>> On 04/11/14 07:44, amit daniel kachhap wrote:
>>> On Mon, Nov 3, 2014 at 11:53 PM, Kevin Hilman <khilman@kernel.org> wrote:
>>>> "Rafael J. Wysocki" <rjw@rjwysocki.net> writes:
>>>>> On Monday, November 03, 2014 09:23:01 AM Amit Daniel Kachhap wrote:
[...]
>> Indeed, the somehow complicated power domain power on/off sequences
>> are SoC specific.  They involve not only groups of clocks (usually
>> gate, mux clock registers of all devices in a power domain) but also
>> SoC-specific PMU (Power Management Unit) registers.
>> I assume it would be inappropriate to push such details to device 
>> drivers.  Moreover, a device driver could not be even loaded.
>>
>> Since the clocks' state is already maintained by clk driver we came 
>> up with an idea of having generic calls from power domain driver back 
>> to the clock controller driver.
> 
> For the clock tree, it still seems to me that this is better handled in
> the SoC clock driver.  For example, when a power domain is about to be
> gated, all the devices in that domain are runtime suspended, and
> presumably all of their gate clocks are disabled.  Now, doesn't the
> clock driver know the clock tree parent-child hierarchy and shouldn't it
> be capable of saving the state of parent clocks (like mux clocks) etc?
> 
> Stated diffrently, it still seems to me like we're pushing functionality
> in PM core notifiers that should be the responsibility of subsystem
> drivers. 

My apologies for not replying earlier, I got distracted by other 
activities.

I'd prefer not adding anything new to the PM core, however there are
dependencies between the power domain and clock controller driver 
which are hard to model in the current APIs.  I assume resorting to 
inter-exynos-driver API is not a good idea either.

Saving/restoring the clock hierarchy in the clock controller driver
during the power domain state transitions has a caveat that the clock
turn off/on sequences are IP/SoC subsystem specific.  So simply 
restoring saved registers from memory is not going to work.

The other detail I might have forgotten to mention is that the whole
clock controller may be in same power domain as the consumer devices.
That means the clock controller's registers must not be touched when
a related power domain is turned off.  Naturally when a power domain 
gets switched off all the clock controller's registers reset to their 
default values.  If we decided to use pm_runtime_{get_sync, put} in
the clock controller driver I'm not sure how it would need to interact
with the clk API.
In current mainline there is an issue with exynos4x12 that the system
may hang if clk_summary is attempted to read as the clock controller
driver doesn't take the ISP power domain into account.

[...]
>>>> Personally, I'm uncomfortable with notifiers like this because it
>>>> suggests that underlying frameworks are not doing the right thing, or
>>>> are not being used.  (I also don't like the implementation here where a
>>>> single global notifier list is maintained by the core, but the notifiers
>>>> are actually triggered by SoC specific code.)
>>>
>>> Yes right the global notifier block can be moved to per genpd structure.
>>> Also SoC trigger can be moved to core files.
>>>>
>>>> IIUC, the usage in this series seems to be that certain clock related
>>>> registers need to be saved/restored across a power domain transition.
>>>>
>>>> Wouldn't an alternative solution be to add a feature to the clock driver
>>>> such that the state of each clock is saved when the clock is disabled,
>>>> and restored when the clock is enabled?   That would allow any clock
>>>> context to survive any power domain transtion also, correct?
>>>
>>> I also thought about same. But the trigger point for this would be
>>> driver calling clk disable/enable and not the power domain. so this 
>>> will lead to lot of save/restore for each power domain child.
>>
>> Even though we would have saved/restored at that points still the power
>> domain driver would need to enforce some specific clock/PMU registers 
>> state before/after a power domain state transition. And this is what I 
>> found difficult with the existing APIs.
> 
> This is what I'm not understanding.
> 
> Why can't the power domain driver's power_on/power_off callback just
> call the PMU APIs and/or the clk_enable/_disable calls it needs?

I was concerned that it would not have been reliable by using the clk 
API due to the clk enable refcounting.  But that might not be a valid 
argument, since as you pointed out when a power domain is about to 
be gated related the clocks should be already disabled.

The other concern was atomicity in enabling/disabling groups of clocks,
i.e. setting group of bits in a clock gate register at once, rather
than a bit for each clock one by one.  But I'm not 100% sure about 
such a hardware requirement myself, would need to do some more testing 
and/or find a hardware engineer who could explain this. 

Additionally specifying clocks in device tree would be a bit messy and
there would very likely anyway be an additional information required 
in the power domain driver per each power domain regarding the clock 
handling sequence. 

-- 
Regards,
Sylwester

  parent reply	other threads:[~2014-11-28 18:04 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-03  3:52 [PATCH 00/12] soc: samsung: Modify and enhance power domain driver Amit Daniel Kachhap
2014-11-03  3:52 ` Amit Daniel Kachhap
2014-11-03  3:52 ` [PATCH 01/12] ARM: EXYNOS: Move pmu specific header files under "linux/mfd/samsung" Amit Daniel Kachhap
2014-11-03  3:52   ` Amit Daniel Kachhap
2014-11-03  3:53 ` [PATCH 02/12] drivers: mfd: Add support for Exynos PMU driver Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03 15:26   ` Lee Jones
2014-11-03 15:26     ` Lee Jones
2014-11-04  3:18     ` Pankaj Dubey
2014-11-04  3:18       ` Pankaj Dubey
2014-11-04  8:24       ` Lee Jones
2014-11-04  8:24         ` Lee Jones
2014-11-05 13:47       ` Sylwester Nawrocki
2014-11-05 13:47         ` Sylwester Nawrocki
2014-11-03  3:53 ` [PATCH 03/12] PM / Domains: Add notifier support for power domain transitions Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03 14:54   ` Rafael J. Wysocki
2014-11-03 14:54     ` Rafael J. Wysocki
2014-11-03 14:52     ` Ulf Hansson
2014-11-03 14:52       ` Ulf Hansson
2014-11-04  6:18       ` amit daniel kachhap
2014-11-04  6:18         ` amit daniel kachhap
2014-11-03 18:23     ` Kevin Hilman
2014-11-03 18:23       ` Kevin Hilman
2014-11-04  6:44       ` amit daniel kachhap
2014-11-04  6:44         ` amit daniel kachhap
2014-11-04 11:01         ` Sylwester Nawrocki
2014-11-04 11:01           ` Sylwester Nawrocki
2014-11-07 18:45           ` Kevin Hilman
2014-11-07 18:45             ` Kevin Hilman
2014-11-10  9:08             ` amit daniel kachhap
2014-11-10  9:08               ` amit daniel kachhap
2014-11-28 18:04             ` Sylwester Nawrocki [this message]
2014-11-28 18:04               ` Sylwester Nawrocki
2014-11-03 18:21   ` Sylwester Nawrocki
2014-11-03 18:21     ` Sylwester Nawrocki
2014-11-03 18:41     ` Sylwester Nawrocki
2014-11-03 18:41       ` Sylwester Nawrocki
2014-11-04  3:23       ` Pankaj Dubey
2014-11-04  3:23         ` Pankaj Dubey
2014-11-04  6:16     ` amit daniel kachhap
2014-11-04  6:16       ` amit daniel kachhap
2014-11-04 12:08       ` Sylwester Nawrocki
2014-11-04 12:08         ` Sylwester Nawrocki
2014-11-04 18:10         ` [RFC PATCH] pm: Add PM domain state transition notifications Sylwester Nawrocki
2014-11-04 18:10           ` Sylwester Nawrocki
2014-11-03  3:53 ` [PATCH 04/12] mfd: exynos-pmu: Register exynos-pmu driver as a mfd driver Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03  3:53 ` [PATCH 05/12] arm: exynos: Add platform driver support for power domain driver Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03  3:53 ` [PATCH 06/12] soc: exynos: Move exynos power domain file to driver/soc/samsung folder Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03  3:53 ` [PATCH 07/12] soc: samsung: pm_domain: Use compatible name for power domain name Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03  3:53 ` [PATCH 08/12] soc: samsung: pm_domain: Add a new parameter for power configuration Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03  3:53 ` [PATCH 09/12] soc: samsung: pm_domain: Add support for parent power domain Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03  3:53 ` [PATCH 10/12] soc: samsung: pm_domain: Use the recently added PM Domain notifiers Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03  3:53 ` [PATCH 11/12] clk: samsung: save and restore clock registers for power domain Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap
2014-11-03  3:53 ` [PATCH 12/12] arm64: Kconfig: Enable PM_GENERIC_DOMAINS for exynos7 Amit Daniel Kachhap
2014-11-03  3:53   ` Amit Daniel Kachhap

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=5478B930.4090300@samsung.com \
    --to=s.nawrocki@samsung.com \
    --cc=amit.daniel@samsung.com \
    --cc=geert@linux-m68k.org \
    --cc=kgene.kim@samsung.com \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=pankaj.dubey@samsung.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=ulf.hansson@linaro.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.