From: Nishanth Menon <nm@ti.com>
To: Mike Turquette <mturquette@linaro.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Viresh Kumar <viresh.kumar@linaro.org>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Mark Brown <broonie@kernel.org>
Cc: devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-omap@vger.kernel.org
Subject: Re: [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling
Date: Thu, 27 Feb 2014 08:42:53 -0600 [thread overview]
Message-ID: <530F4EED.9050207@ti.com> (raw)
In-Reply-To: <20140227050043.12081.54173@quantum>
On 02/26/2014 11:00 PM, Mike Turquette wrote:
> Quoting Nishanth Menon (2014-02-26 18:34:55)
>> +/**
>> + * pm_runtime_get_rate() - Returns the device operational frequency
>> + * @dev: Device to handle
>> + * @rate: Returns rate in Hz.
>> + *
>> + * Returns appropriate error value in case of error conditions, else
>> + * returns 0 and rate is updated. The pm_domain logic does all the necessary
>> + * operation (which may consider magic hardware stuff) to provide the rate.
>> + *
>> + * NOTE: the rate returned is a snapshot and in many cases just a bypass
>> + * to clk api to set the rate.
>> + */
>> +int pm_runtime_get_rate(struct device *dev, unsigned long *rate)
>
> Instead of "rate", how about we use "level" and leave it undefined as to
> what that means? It would be equally valid for level to represent a
> clock rate, or an opp from a table of opp's, or a p-state, or some value
> passed to a PM microcontroller.
IMHO, from a driver which already exists for multiple SoCs/
architectures, we cannot have variant definitions that a generic
driver will be unable to depend upon. what should such a driver
expect? level == rate OR level == index to p-state or magic PM
controller value?
Today the definitions are very clear to such a driver, pm_runtime APIs
are used for device specific idle management, but for active
management, use clk and regulator code as needed - ofcourse, that
machine specificity triggers the need for the 50 odd cpufreq drivers
we have today - intent was to be able to abstract it enough for a
generic logic to exist.
>
> Code that is tightly coupled to the hardware would simply know what
> value to use with no extra sugar.
agreed on the machine specific implementation, but the logic at driver
level will then get tied down to machine specific implementation as well
>
> Generic code would need to get the various supported "levels" populated
> at run time, but a DT binding could do that, or a query to the ACPI
> tables, or whatever.
then we'd also have to introduce a translator API for drivers that
need frequency -> we go back to the old world of having specific
functions depending on usage in the frequency world, ACPI world, PM
controller world.
That completely breaks the concept of having a higher level function,
right?
>
>> +{
>> + unsigned long flags;
>> + int error = -ENOSYS;
>> +
>> + if (!rate || !dev)
>> + return -EINVAL;
>> +
>> + spin_lock_irqsave(&dev->power.lock, flags);
>> + if (!pm_runtime_active(dev)) {
>> + error = -EINVAL;
>> + goto out;
>> + }
>> +
>> + if (dev->pm_domain && dev->pm_domain->active_ops.get_rate)
>> + error = dev->pm_domain->active_ops.get_rate(dev, rate);
>> +out:
>> + spin_unlock_irqrestore(&dev->power.lock, flags);
>> +
>> + return error;
>> +}
>> +
>> +/**
>> + * pm_runtime_set_rate() - Set a specific rate for the device operation
>> + * @dev: Device to handle
>> + * @rate: Rate to set in Hz
>> + *
>> + * Returns appropriate error value in case of error conditions, else
>> + * returns 0. The pm_domain logic does all the necessary operation (which
>> + * may include voltage scale operations or other magic hardware stuff) to
>> + * achieve the operation. It is guarenteed that the requested rate is achieved
>> + * on returning from this function if return value is 0.
>> + */
>> +int pm_runtime_set_rate(struct device *dev, unsigned long rate)
>
> Additionally I wonder if the function signature should include a way to
> specify the sub-unit of a device that we are operating on? This is a way
> to tackle the issues you raised regarding multiple clocks per device,
> etc. Two approaches come to mind:
>
> int pm_runtime_set_rate(struct device *dev, int index,
> unsigned long rate);
>
> Where index is a sub-unit of struct device *dev.
Here the problem is trying to define what that index is. should it be
clk index? how again would a generic driver be able to consistently
function? lets, for a moment replace that with a string - "clk_name"
to uniquely identify the clk -> but then, it still, in concept makes
it no better than a clk_set_rate since we are uniquely identifying the
clk to operate upon -> and we can definitely add "magic dvfs" stuff on
existing clock framework without a need for additional wrappers (which
what the original $subject series does).
>The second approach is
> to create a publicly declared structure representing the sub-unit. Some
> variations on that theme:
>
> int pm_runtime_set_rate(struct perf_domain *perfdm, unsigned long rate);
>
> or,
>
> int pm_runtime_set_rate(struct generic_power_domain *gpd,
> unsigned long rate);
>
> or whatever that sub-unit looks like. The gpd thing might be a total
> layering violation, I don't know. Or perhaps it's a decent idea but it
> shouldn't be as a PM runtime call. Again, I dunno.
Again, we goes back to the same question, right? which clock in a
power_domain/perf_domain are we intending with the rate? a device
belongs to a perf domain -> Taking drivers/cpufreq/imx6q-cpufreq.c as
an example.
Clocks needed: arm_clk, pll1_sys_clk, pll1_sw_clk, step_clk,
pll2_pfd2_396m_clk.
regulators needed: arm_reg, pu_reg, soc_reg.
The device we want to set a frequency is the ARM processor. by
describing "perf_domain" or "generic power domain" as a single clock
entity, we might as well use clk_set_rate instead to be specific,
instead of writing one wrapper on top of the entire thing.
I apologize, more I think in this angle, less I think such a generic
api seems feasible.
--
Regards,
Nishanth Menon
WARNING: multiple messages have this Message-ID (diff)
From: nm@ti.com (Nishanth Menon)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling
Date: Thu, 27 Feb 2014 08:42:53 -0600 [thread overview]
Message-ID: <530F4EED.9050207@ti.com> (raw)
In-Reply-To: <20140227050043.12081.54173@quantum>
On 02/26/2014 11:00 PM, Mike Turquette wrote:
> Quoting Nishanth Menon (2014-02-26 18:34:55)
>> +/**
>> + * pm_runtime_get_rate() - Returns the device operational frequency
>> + * @dev: Device to handle
>> + * @rate: Returns rate in Hz.
>> + *
>> + * Returns appropriate error value in case of error conditions, else
>> + * returns 0 and rate is updated. The pm_domain logic does all the necessary
>> + * operation (which may consider magic hardware stuff) to provide the rate.
>> + *
>> + * NOTE: the rate returned is a snapshot and in many cases just a bypass
>> + * to clk api to set the rate.
>> + */
>> +int pm_runtime_get_rate(struct device *dev, unsigned long *rate)
>
> Instead of "rate", how about we use "level" and leave it undefined as to
> what that means? It would be equally valid for level to represent a
> clock rate, or an opp from a table of opp's, or a p-state, or some value
> passed to a PM microcontroller.
IMHO, from a driver which already exists for multiple SoCs/
architectures, we cannot have variant definitions that a generic
driver will be unable to depend upon. what should such a driver
expect? level == rate OR level == index to p-state or magic PM
controller value?
Today the definitions are very clear to such a driver, pm_runtime APIs
are used for device specific idle management, but for active
management, use clk and regulator code as needed - ofcourse, that
machine specificity triggers the need for the 50 odd cpufreq drivers
we have today - intent was to be able to abstract it enough for a
generic logic to exist.
>
> Code that is tightly coupled to the hardware would simply know what
> value to use with no extra sugar.
agreed on the machine specific implementation, but the logic at driver
level will then get tied down to machine specific implementation as well
>
> Generic code would need to get the various supported "levels" populated
> at run time, but a DT binding could do that, or a query to the ACPI
> tables, or whatever.
then we'd also have to introduce a translator API for drivers that
need frequency -> we go back to the old world of having specific
functions depending on usage in the frequency world, ACPI world, PM
controller world.
That completely breaks the concept of having a higher level function,
right?
>
>> +{
>> + unsigned long flags;
>> + int error = -ENOSYS;
>> +
>> + if (!rate || !dev)
>> + return -EINVAL;
>> +
>> + spin_lock_irqsave(&dev->power.lock, flags);
>> + if (!pm_runtime_active(dev)) {
>> + error = -EINVAL;
>> + goto out;
>> + }
>> +
>> + if (dev->pm_domain && dev->pm_domain->active_ops.get_rate)
>> + error = dev->pm_domain->active_ops.get_rate(dev, rate);
>> +out:
>> + spin_unlock_irqrestore(&dev->power.lock, flags);
>> +
>> + return error;
>> +}
>> +
>> +/**
>> + * pm_runtime_set_rate() - Set a specific rate for the device operation
>> + * @dev: Device to handle
>> + * @rate: Rate to set in Hz
>> + *
>> + * Returns appropriate error value in case of error conditions, else
>> + * returns 0. The pm_domain logic does all the necessary operation (which
>> + * may include voltage scale operations or other magic hardware stuff) to
>> + * achieve the operation. It is guarenteed that the requested rate is achieved
>> + * on returning from this function if return value is 0.
>> + */
>> +int pm_runtime_set_rate(struct device *dev, unsigned long rate)
>
> Additionally I wonder if the function signature should include a way to
> specify the sub-unit of a device that we are operating on? This is a way
> to tackle the issues you raised regarding multiple clocks per device,
> etc. Two approaches come to mind:
>
> int pm_runtime_set_rate(struct device *dev, int index,
> unsigned long rate);
>
> Where index is a sub-unit of struct device *dev.
Here the problem is trying to define what that index is. should it be
clk index? how again would a generic driver be able to consistently
function? lets, for a moment replace that with a string - "clk_name"
to uniquely identify the clk -> but then, it still, in concept makes
it no better than a clk_set_rate since we are uniquely identifying the
clk to operate upon -> and we can definitely add "magic dvfs" stuff on
existing clock framework without a need for additional wrappers (which
what the original $subject series does).
>The second approach is
> to create a publicly declared structure representing the sub-unit. Some
> variations on that theme:
>
> int pm_runtime_set_rate(struct perf_domain *perfdm, unsigned long rate);
>
> or,
>
> int pm_runtime_set_rate(struct generic_power_domain *gpd,
> unsigned long rate);
>
> or whatever that sub-unit looks like. The gpd thing might be a total
> layering violation, I don't know. Or perhaps it's a decent idea but it
> shouldn't be as a PM runtime call. Again, I dunno.
Again, we goes back to the same question, right? which clock in a
power_domain/perf_domain are we intending with the rate? a device
belongs to a perf domain -> Taking drivers/cpufreq/imx6q-cpufreq.c as
an example.
Clocks needed: arm_clk, pll1_sys_clk, pll1_sw_clk, step_clk,
pll2_pfd2_396m_clk.
regulators needed: arm_reg, pu_reg, soc_reg.
The device we want to set a frequency is the ARM processor. by
describing "perf_domain" or "generic power domain" as a single clock
entity, we might as well use clk_set_rate instead to be specific,
instead of writing one wrapper on top of the entire thing.
I apologize, more I think in this angle, less I think such a generic
api seems feasible.
--
Regards,
Nishanth Menon
WARNING: multiple messages have this Message-ID (diff)
From: Nishanth Menon <nm@ti.com>
To: Mike Turquette <mturquette@linaro.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Viresh Kumar <viresh.kumar@linaro.org>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Mark Brown <broonie@kernel.org>
Cc: <devicetree@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <cpufreq@vger.kernel.org>,
<linux-pm@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-omap@vger.kernel.org>
Subject: Re: [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling
Date: Thu, 27 Feb 2014 08:42:53 -0600 [thread overview]
Message-ID: <530F4EED.9050207@ti.com> (raw)
In-Reply-To: <20140227050043.12081.54173@quantum>
On 02/26/2014 11:00 PM, Mike Turquette wrote:
> Quoting Nishanth Menon (2014-02-26 18:34:55)
>> +/**
>> + * pm_runtime_get_rate() - Returns the device operational frequency
>> + * @dev: Device to handle
>> + * @rate: Returns rate in Hz.
>> + *
>> + * Returns appropriate error value in case of error conditions, else
>> + * returns 0 and rate is updated. The pm_domain logic does all the necessary
>> + * operation (which may consider magic hardware stuff) to provide the rate.
>> + *
>> + * NOTE: the rate returned is a snapshot and in many cases just a bypass
>> + * to clk api to set the rate.
>> + */
>> +int pm_runtime_get_rate(struct device *dev, unsigned long *rate)
>
> Instead of "rate", how about we use "level" and leave it undefined as to
> what that means? It would be equally valid for level to represent a
> clock rate, or an opp from a table of opp's, or a p-state, or some value
> passed to a PM microcontroller.
IMHO, from a driver which already exists for multiple SoCs/
architectures, we cannot have variant definitions that a generic
driver will be unable to depend upon. what should such a driver
expect? level == rate OR level == index to p-state or magic PM
controller value?
Today the definitions are very clear to such a driver, pm_runtime APIs
are used for device specific idle management, but for active
management, use clk and regulator code as needed - ofcourse, that
machine specificity triggers the need for the 50 odd cpufreq drivers
we have today - intent was to be able to abstract it enough for a
generic logic to exist.
>
> Code that is tightly coupled to the hardware would simply know what
> value to use with no extra sugar.
agreed on the machine specific implementation, but the logic at driver
level will then get tied down to machine specific implementation as well
>
> Generic code would need to get the various supported "levels" populated
> at run time, but a DT binding could do that, or a query to the ACPI
> tables, or whatever.
then we'd also have to introduce a translator API for drivers that
need frequency -> we go back to the old world of having specific
functions depending on usage in the frequency world, ACPI world, PM
controller world.
That completely breaks the concept of having a higher level function,
right?
>
>> +{
>> + unsigned long flags;
>> + int error = -ENOSYS;
>> +
>> + if (!rate || !dev)
>> + return -EINVAL;
>> +
>> + spin_lock_irqsave(&dev->power.lock, flags);
>> + if (!pm_runtime_active(dev)) {
>> + error = -EINVAL;
>> + goto out;
>> + }
>> +
>> + if (dev->pm_domain && dev->pm_domain->active_ops.get_rate)
>> + error = dev->pm_domain->active_ops.get_rate(dev, rate);
>> +out:
>> + spin_unlock_irqrestore(&dev->power.lock, flags);
>> +
>> + return error;
>> +}
>> +
>> +/**
>> + * pm_runtime_set_rate() - Set a specific rate for the device operation
>> + * @dev: Device to handle
>> + * @rate: Rate to set in Hz
>> + *
>> + * Returns appropriate error value in case of error conditions, else
>> + * returns 0. The pm_domain logic does all the necessary operation (which
>> + * may include voltage scale operations or other magic hardware stuff) to
>> + * achieve the operation. It is guarenteed that the requested rate is achieved
>> + * on returning from this function if return value is 0.
>> + */
>> +int pm_runtime_set_rate(struct device *dev, unsigned long rate)
>
> Additionally I wonder if the function signature should include a way to
> specify the sub-unit of a device that we are operating on? This is a way
> to tackle the issues you raised regarding multiple clocks per device,
> etc. Two approaches come to mind:
>
> int pm_runtime_set_rate(struct device *dev, int index,
> unsigned long rate);
>
> Where index is a sub-unit of struct device *dev.
Here the problem is trying to define what that index is. should it be
clk index? how again would a generic driver be able to consistently
function? lets, for a moment replace that with a string - "clk_name"
to uniquely identify the clk -> but then, it still, in concept makes
it no better than a clk_set_rate since we are uniquely identifying the
clk to operate upon -> and we can definitely add "magic dvfs" stuff on
existing clock framework without a need for additional wrappers (which
what the original $subject series does).
>The second approach is
> to create a publicly declared structure representing the sub-unit. Some
> variations on that theme:
>
> int pm_runtime_set_rate(struct perf_domain *perfdm, unsigned long rate);
>
> or,
>
> int pm_runtime_set_rate(struct generic_power_domain *gpd,
> unsigned long rate);
>
> or whatever that sub-unit looks like. The gpd thing might be a total
> layering violation, I don't know. Or perhaps it's a decent idea but it
> shouldn't be as a PM runtime call. Again, I dunno.
Again, we goes back to the same question, right? which clock in a
power_domain/perf_domain are we intending with the rate? a device
belongs to a perf domain -> Taking drivers/cpufreq/imx6q-cpufreq.c as
an example.
Clocks needed: arm_clk, pll1_sys_clk, pll1_sw_clk, step_clk,
pll2_pfd2_396m_clk.
regulators needed: arm_reg, pu_reg, soc_reg.
The device we want to set a frequency is the ARM processor. by
describing "perf_domain" or "generic power domain" as a single clock
entity, we might as well use clk_set_rate instead to be specific,
instead of writing one wrapper on top of the entire thing.
I apologize, more I think in this angle, less I think such a generic
api seems feasible.
--
Regards,
Nishanth Menon
next prev parent reply other threads:[~2014-02-27 14:42 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-18 20:32 [RFC PATCH 0/6] PM: introduce voltage domain abstraction Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` [RFC PATCH 1/6] PM / Voltagedomain: Add generic clk notifier handler for regulator based dynamic voltage scaling Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-25 5:51 ` Mike Turquette
2014-02-25 5:51 ` Mike Turquette
2014-02-25 5:51 ` Mike Turquette
2014-02-25 20:56 ` Nishanth Menon
2014-02-25 20:56 ` Nishanth Menon
2014-02-25 20:56 ` Nishanth Menon
2014-02-27 2:34 ` Nishanth Menon
2014-02-27 2:34 ` Nishanth Menon
2014-02-27 2:34 ` Nishanth Menon
2014-02-27 2:34 ` Nishanth Menon
2014-02-27 5:00 ` Mike Turquette
2014-02-27 5:00 ` Mike Turquette
2014-02-27 14:42 ` Nishanth Menon [this message]
2014-02-27 14:42 ` Nishanth Menon
2014-02-27 14:42 ` Nishanth Menon
2014-02-27 18:59 ` Felipe Balbi
2014-02-27 18:59 ` Felipe Balbi
2014-02-27 18:59 ` Felipe Balbi
2014-02-18 20:32 ` [RFC PATCH 2/6] cpufreq: cpufreq-cpu0: use clk rate-change notifiers Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` [RFC PATCH 3/6] PM / Voltagedomain: introduce voltage domain driver support Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-24 1:58 ` Mark Brown
2014-02-24 1:58 ` Mark Brown
2014-02-24 14:38 ` Nishanth Menon
2014-02-24 14:38 ` Nishanth Menon
2014-02-24 14:38 ` Nishanth Menon
2014-03-03 3:54 ` Mark Brown
2014-03-03 3:54 ` Mark Brown
2014-03-10 17:11 ` Nishanth Menon
2014-03-10 17:11 ` Nishanth Menon
2014-03-10 17:11 ` Nishanth Menon
2014-03-10 17:22 ` Mark Brown
2014-03-10 17:22 ` Mark Brown
2014-03-10 17:41 ` Nishanth Menon
2014-03-10 17:41 ` Nishanth Menon
2014-03-10 17:41 ` Nishanth Menon
2014-03-10 18:01 ` Mark Brown
2014-03-10 18:01 ` Mark Brown
2014-03-10 19:25 ` Nishanth Menon
2014-03-10 19:25 ` Nishanth Menon
2014-03-10 19:25 ` Nishanth Menon
2014-03-19 22:35 ` Mike Turquette
2014-03-19 22:35 ` Mike Turquette
2014-02-18 20:32 ` [RFC PATCH 4/6] devicetree: bindings: add documentation for voltagedomain Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` [RFC PATCH 5/6] PM / Voltagedomain: introduce basic voltage domain support for OMAP Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` [RFC PATCH 6/6] devicetree: bindings: voltagedomain: add bindings for OMAP compatible SoCs Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
2014-02-18 20:32 ` Nishanth Menon
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=530F4EED.9050207@ti.com \
--to=nm@ti.com \
--cc=broonie@kernel.org \
--cc=cpufreq@vger.kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=myungjoo.ham@samsung.com \
--cc=rjw@rjwysocki.net \
--cc=viresh.kumar@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.