* [PATCH V2 0/4] OPP: Some cleanups
@ 2015-10-15 16:12 Viresh Kumar
2015-10-15 16:12 ` [PATCH V2 1/4] PM / OPP: Improve debug print messages with pr_fmt Viresh Kumar
` (5 more replies)
0 siblings, 6 replies; 17+ messages in thread
From: Viresh Kumar @ 2015-10-15 16:12 UTC (permalink / raw)
To: Rafael Wysocki; +Cc: linaro-kernel, linux-pm, sboyd, nm, Viresh Kumar
Rafael,
These are some random cleanups, which were part of the multi-regulator
series earlier. Sending them separately to make that series a bit light
weight.
V1->V2:
- Just sending them separately.
Viresh Kumar (4):
PM / OPP: Improve debug print messages with pr_fmt
PM / OPP: Rename routines specific to old bindings with _v1
PM / OPP: Parse all power-supply related bindings together
PM / OPP: Create separate structure for regulator/supplies
drivers/base/power/opp/core.c | 78 +++++++++++++++++++++++++++----------------
drivers/base/power/opp/cpu.c | 3 ++
drivers/base/power/opp/opp.h | 29 +++++++++++-----
3 files changed, 73 insertions(+), 37 deletions(-)
--
2.4.0
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH V2 1/4] PM / OPP: Improve debug print messages with pr_fmt 2015-10-15 16:12 [PATCH V2 0/4] OPP: Some cleanups Viresh Kumar @ 2015-10-15 16:12 ` Viresh Kumar 2015-10-15 19:04 ` Stephen Boyd 2015-10-15 16:12 ` [PATCH V2 2/4] PM / OPP: Rename routines specific to old bindings with _v1 Viresh Kumar ` (4 subsequent siblings) 5 siblings, 1 reply; 17+ messages in thread From: Viresh Kumar @ 2015-10-15 16:12 UTC (permalink / raw) To: Rafael Wysocki Cc: linaro-kernel, linux-pm, sboyd, nm, Viresh Kumar, Bartlomiej Zolnierkiewicz, Dan Carpenter, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek With debug options on, it is difficult to locate OPP core's debug prints. Fix this by prefixing OPP debug prints with KBUILD_MODNAME. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- drivers/base/power/opp/core.c | 2 ++ drivers/base/power/opp/cpu.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index d5c1149ff123..a422ebf2501f 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -11,6 +11,8 @@ * published by the Free Software Foundation. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/errno.h> #include <linux/err.h> #include <linux/slab.h> diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c index 7654c5606307..c27a1cdffec9 100644 --- a/drivers/base/power/opp/cpu.c +++ b/drivers/base/power/opp/cpu.c @@ -10,6 +10,9 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/cpu.h> #include <linux/cpufreq.h> #include <linux/err.h> -- 2.4.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH V2 1/4] PM / OPP: Improve debug print messages with pr_fmt 2015-10-15 16:12 ` [PATCH V2 1/4] PM / OPP: Improve debug print messages with pr_fmt Viresh Kumar @ 2015-10-15 19:04 ` Stephen Boyd 2015-10-16 5:37 ` Viresh Kumar 0 siblings, 1 reply; 17+ messages in thread From: Stephen Boyd @ 2015-10-15 19:04 UTC (permalink / raw) To: Viresh Kumar Cc: Rafael Wysocki, linaro-kernel, linux-pm, nm, Bartlomiej Zolnierkiewicz, Dan Carpenter, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek On 10/15, Viresh Kumar wrote: > With debug options on, it is difficult to locate OPP core's debug > prints. Fix this by prefixing OPP debug prints with KBUILD_MODNAME. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Why not use dynamic debug's m flag to turn on KBUILD_MODNAME when debugging? >From Documentation/dynamic-debug-howto.txt m Include module name in the printed message -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH V2 1/4] PM / OPP: Improve debug print messages with pr_fmt 2015-10-15 19:04 ` Stephen Boyd @ 2015-10-16 5:37 ` Viresh Kumar 2015-10-16 19:20 ` Stephen Boyd 0 siblings, 1 reply; 17+ messages in thread From: Viresh Kumar @ 2015-10-16 5:37 UTC (permalink / raw) To: Stephen Boyd Cc: Rafael Wysocki, linaro-kernel, linux-pm, nm, Bartlomiej Zolnierkiewicz, Dan Carpenter, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek On 15-10-15, 12:04, Stephen Boyd wrote: > On 10/15, Viresh Kumar wrote: > > With debug options on, it is difficult to locate OPP core's debug > > prints. Fix this by prefixing OPP debug prints with KBUILD_MODNAME. > > > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > > Why not use dynamic debug's m flag to turn on KBUILD_MODNAME when > debugging? > > >From Documentation/dynamic-debug-howto.txt > > m Include module name in the printed message It wasn't just about debug messages but pr_info and pr_err as well. And so I defined pr_fmt instead. -- viresh ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH V2 1/4] PM / OPP: Improve debug print messages with pr_fmt 2015-10-16 5:37 ` Viresh Kumar @ 2015-10-16 19:20 ` Stephen Boyd 2015-10-17 4:15 ` [PATCH V3 1/4] PM / OPP: Improve " Viresh Kumar 0 siblings, 1 reply; 17+ messages in thread From: Stephen Boyd @ 2015-10-16 19:20 UTC (permalink / raw) To: Viresh Kumar Cc: Rafael Wysocki, linaro-kernel, linux-pm, nm, Bartlomiej Zolnierkiewicz, Dan Carpenter, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek On 10/16, Viresh Kumar wrote: > On 15-10-15, 12:04, Stephen Boyd wrote: > > On 10/15, Viresh Kumar wrote: > > > With debug options on, it is difficult to locate OPP core's debug > > > prints. Fix this by prefixing OPP debug prints with KBUILD_MODNAME. > > > > > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > > > > Why not use dynamic debug's m flag to turn on KBUILD_MODNAME when > > debugging? > > > > >From Documentation/dynamic-debug-howto.txt > > > > m Include module name in the printed message > > It wasn't just about debug messages but pr_info and pr_err as well. > And so I defined pr_fmt instead. > Ok, well the commit text exclusively mentions debug, leading me to believe this is all about making the debug prints (i.e. pr_debug) have KBUILD_MODNAME. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH V3 1/4] PM / OPP: Improve print messages with pr_fmt 2015-10-16 19:20 ` Stephen Boyd @ 2015-10-17 4:15 ` Viresh Kumar 2015-10-28 18:49 ` Stephen Boyd 0 siblings, 1 reply; 17+ messages in thread From: Viresh Kumar @ 2015-10-17 4:15 UTC (permalink / raw) To: Rafael Wysocki Cc: linaro-kernel, linux-pm, sboyd, nm, Viresh Kumar, Bartlomiej Zolnierkiewicz, Dan Carpenter, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek To identify OPP core's print messages easily, prefix them with KBUILD_MODNAME. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- V2->V3: - Improved commit-log. drivers/base/power/opp/core.c | 2 ++ drivers/base/power/opp/cpu.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index d5c1149ff123..a422ebf2501f 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -11,6 +11,8 @@ * published by the Free Software Foundation. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/errno.h> #include <linux/err.h> #include <linux/slab.h> diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c index 7654c5606307..c27a1cdffec9 100644 --- a/drivers/base/power/opp/cpu.c +++ b/drivers/base/power/opp/cpu.c @@ -10,6 +10,9 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/cpu.h> #include <linux/cpufreq.h> #include <linux/err.h> -- 2.4.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH V3 1/4] PM / OPP: Improve print messages with pr_fmt 2015-10-17 4:15 ` [PATCH V3 1/4] PM / OPP: Improve " Viresh Kumar @ 2015-10-28 18:49 ` Stephen Boyd 0 siblings, 0 replies; 17+ messages in thread From: Stephen Boyd @ 2015-10-28 18:49 UTC (permalink / raw) To: Viresh Kumar Cc: Rafael Wysocki, linaro-kernel, linux-pm, nm, Bartlomiej Zolnierkiewicz, Dan Carpenter, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek On 10/17, Viresh Kumar wrote: > To identify OPP core's print messages easily, prefix them with > KBUILD_MODNAME. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > --- Reviewed-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] 17+ messages in thread
* [PATCH V2 2/4] PM / OPP: Rename routines specific to old bindings with _v1 2015-10-15 16:12 [PATCH V2 0/4] OPP: Some cleanups Viresh Kumar 2015-10-15 16:12 ` [PATCH V2 1/4] PM / OPP: Improve debug print messages with pr_fmt Viresh Kumar @ 2015-10-15 16:12 ` Viresh Kumar 2015-10-28 18:48 ` Stephen Boyd 2015-10-15 16:12 ` [PATCH V2 3/4] PM / OPP: Parse all power-supply related bindings together Viresh Kumar ` (3 subsequent siblings) 5 siblings, 1 reply; 17+ messages in thread From: Viresh Kumar @ 2015-10-15 16:12 UTC (permalink / raw) To: Rafael Wysocki Cc: linaro-kernel, linux-pm, sboyd, nm, Viresh Kumar, Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek Clearly distinguish routines based on what version of bindings they parse. We have already postfixed routines properly with _v2 for new bindings. Postfix the older ones now with _v1. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- drivers/base/power/opp/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index a422ebf2501f..63b0f57601b8 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -703,7 +703,7 @@ static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, } /** - * _opp_add_dynamic() - Allocate a dynamic OPP. + * _opp_add_v1() - Allocate a OPP based on v1 bindings. * @dev: device for which we do this operation * @freq: Frequency in Hz for this OPP * @u_volt: Voltage in uVolts for this OPP @@ -729,8 +729,8 @@ static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, * Duplicate OPPs (both freq and volt are same) and !opp->available * -ENOMEM Memory allocation failure */ -static int _opp_add_dynamic(struct device *dev, unsigned long freq, - long u_volt, bool dynamic) +static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, + bool dynamic) { struct device_opp *dev_opp; struct dev_pm_opp *new_opp; @@ -941,7 +941,7 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np) */ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) { - return _opp_add_dynamic(dev, freq, u_volt, true); + return _opp_add_v1(dev, freq, u_volt, true); } EXPORT_SYMBOL_GPL(dev_pm_opp_add); @@ -1243,7 +1243,7 @@ static int _of_add_opp_table_v1(struct device *dev) unsigned long freq = be32_to_cpup(val++) * 1000; unsigned long volt = be32_to_cpup(val++); - if (_opp_add_dynamic(dev, freq, volt, false)) + if (_opp_add_v1(dev, freq, volt, false)) dev_warn(dev, "%s: Failed to add OPP %ld\n", __func__, freq); nr -= 2; -- 2.4.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH V2 2/4] PM / OPP: Rename routines specific to old bindings with _v1 2015-10-15 16:12 ` [PATCH V2 2/4] PM / OPP: Rename routines specific to old bindings with _v1 Viresh Kumar @ 2015-10-28 18:48 ` Stephen Boyd 0 siblings, 0 replies; 17+ messages in thread From: Stephen Boyd @ 2015-10-28 18:48 UTC (permalink / raw) To: Viresh Kumar Cc: Rafael Wysocki, linaro-kernel, linux-pm, nm, Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek On 10/15, Viresh Kumar wrote: > Clearly distinguish routines based on what version of bindings they > parse. We have already postfixed routines properly with _v2 for new > bindings. Postfix the older ones now with _v1. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > --- Reviewed-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] 17+ messages in thread
* [PATCH V2 3/4] PM / OPP: Parse all power-supply related bindings together 2015-10-15 16:12 [PATCH V2 0/4] OPP: Some cleanups Viresh Kumar 2015-10-15 16:12 ` [PATCH V2 1/4] PM / OPP: Improve debug print messages with pr_fmt Viresh Kumar 2015-10-15 16:12 ` [PATCH V2 2/4] PM / OPP: Rename routines specific to old bindings with _v1 Viresh Kumar @ 2015-10-15 16:12 ` Viresh Kumar 2015-10-28 18:48 ` Stephen Boyd 2015-10-15 16:12 ` [PATCH V2 4/4] PM / OPP: Create separate structure for regulator/supplies Viresh Kumar ` (2 subsequent siblings) 5 siblings, 1 reply; 17+ messages in thread From: Viresh Kumar @ 2015-10-15 16:12 UTC (permalink / raw) To: Rafael Wysocki Cc: linaro-kernel, linux-pm, sboyd, nm, Viresh Kumar, Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek Move all DT parsing for the power supplies to a single function, rather than keeping them at separate places. This will help manage things properly. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- drivers/base/power/opp/core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 63b0f57601b8..8fa522f41226 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -772,9 +772,10 @@ static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, } /* TODO: Support multiple regulators */ -static int opp_get_microvolt(struct dev_pm_opp *opp, struct device *dev) +static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev) { u32 microvolt[3] = {0}; + u32 val; int count, ret; /* Missing property isn't a problem, but an invalid entry is */ @@ -807,6 +808,9 @@ static int opp_get_microvolt(struct dev_pm_opp *opp, struct device *dev) opp->u_volt_min = microvolt[1]; opp->u_volt_max = microvolt[2]; + if (!of_property_read_u32(opp->np, "opp-microamp", &val)) + opp->u_amp = val; + return 0; } @@ -871,13 +875,10 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np) if (!of_property_read_u32(np, "clock-latency-ns", &val)) new_opp->clock_latency_ns = val; - ret = opp_get_microvolt(new_opp, dev); + ret = opp_parse_supplies(new_opp, dev); if (ret) goto free_opp; - if (!of_property_read_u32(new_opp->np, "opp-microamp", &val)) - new_opp->u_amp = val; - ret = _opp_add(dev, new_opp, dev_opp); if (ret) goto free_opp; -- 2.4.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH V2 3/4] PM / OPP: Parse all power-supply related bindings together 2015-10-15 16:12 ` [PATCH V2 3/4] PM / OPP: Parse all power-supply related bindings together Viresh Kumar @ 2015-10-28 18:48 ` Stephen Boyd 0 siblings, 0 replies; 17+ messages in thread From: Stephen Boyd @ 2015-10-28 18:48 UTC (permalink / raw) To: Viresh Kumar Cc: Rafael Wysocki, linaro-kernel, linux-pm, nm, Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek On 10/15, Viresh Kumar wrote: > Move all DT parsing for the power supplies to a single function, rather > than keeping them at separate places. This will help manage things > properly. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > --- Reviewed-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] 17+ messages in thread
* [PATCH V2 4/4] PM / OPP: Create separate structure for regulator/supplies 2015-10-15 16:12 [PATCH V2 0/4] OPP: Some cleanups Viresh Kumar ` (2 preceding siblings ...) 2015-10-15 16:12 ` [PATCH V2 3/4] PM / OPP: Parse all power-supply related bindings together Viresh Kumar @ 2015-10-15 16:12 ` Viresh Kumar 2015-10-28 8:37 ` Viresh Kumar 2015-10-28 8:25 ` [PATCH V2 0/4] OPP: Some cleanups Rafael J. Wysocki 2015-11-05 22:44 ` Rafael J. Wysocki 5 siblings, 1 reply; 17+ messages in thread From: Viresh Kumar @ 2015-10-15 16:12 UTC (permalink / raw) To: Rafael Wysocki Cc: linaro-kernel, linux-pm, sboyd, nm, Viresh Kumar, Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek Support for multiple regulators will be added later, until then move all power-supply related information in a separate structure. To make allocating/freeing memory for these supply structures easy, allocate memory for them along with opp. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- drivers/base/power/opp/core.c | 57 ++++++++++++++++++++++++++++--------------- drivers/base/power/opp/opp.h | 29 ++++++++++++++++------ 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 8fa522f41226..4c00ba719ae4 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -127,7 +127,7 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) if (IS_ERR_OR_NULL(tmp_opp) || !tmp_opp->available) pr_err("%s: Invalid parameters\n", __func__); else - v = tmp_opp->u_volt; + v = tmp_opp->supplies[0].u_volt; return v; } @@ -483,13 +483,14 @@ struct device_list_opp *_add_list_dev(const struct device *dev, /** * _add_device_opp() - Find device OPP table or allocate a new one * @dev: device for which we do this operation + * @supply_count: Number of supplies available for each OPP. * * It tries to find an existing table first, if it couldn't find one, it * allocates a new OPP table and returns that. * * Return: valid device_opp pointer if success, else NULL. */ -static struct device_opp *_add_device_opp(struct device *dev) +static struct device_opp *_add_device_opp(struct device *dev, int supply_count) { struct device_opp *dev_opp; struct device_list_opp *list_dev; @@ -507,6 +508,7 @@ static struct device_opp *_add_device_opp(struct device *dev) if (!dev_opp) return NULL; + dev_opp->supply_count = supply_count; INIT_LIST_HEAD(&dev_opp->dev_list); list_dev = _add_list_dev(dev, dev_opp); @@ -643,24 +645,31 @@ void dev_pm_opp_remove(struct device *dev, unsigned long freq) } EXPORT_SYMBOL_GPL(dev_pm_opp_remove); -static struct dev_pm_opp *_allocate_opp(struct device *dev, - struct device_opp **dev_opp) +static struct dev_pm_opp * +_allocate_opp(struct device *dev, struct device_opp **dev_opp, int supply_count) { struct dev_pm_opp *opp; + size_t size = sizeof(*opp); + + /* Memory for the OPP and its supplies is allocated together */ + size += supply_count * sizeof(*opp->supplies); /* allocate new OPP node */ - opp = kzalloc(sizeof(*opp), GFP_KERNEL); + opp = kzalloc(size, GFP_KERNEL); if (!opp) return NULL; INIT_LIST_HEAD(&opp->node); - *dev_opp = _add_device_opp(dev); + *dev_opp = _add_device_opp(dev, supply_count); if (!*dev_opp) { kfree(opp); return NULL; } + /* Supplies points to the memory right after the opp */ + opp->supplies = (struct opp_supply *)(opp + 1); + return opp; } @@ -689,10 +698,12 @@ static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, /* Duplicate OPPs */ dev_warn(dev, "%s: duplicate OPPs detected. Existing: freq: %lu, volt: %lu, enabled: %d. New: freq: %lu, volt: %lu, enabled: %d\n", - __func__, opp->rate, opp->u_volt, opp->available, - new_opp->rate, new_opp->u_volt, new_opp->available); + __func__, opp->rate, opp->supplies[0].u_volt, + opp->available, new_opp->rate, + new_opp->supplies[0].u_volt, new_opp->available); - return opp->available && new_opp->u_volt == opp->u_volt ? + return opp->available && + opp->supplies[0].u_volt == new_opp->supplies[0].u_volt ? 0 : -EEXIST; } @@ -739,7 +750,7 @@ static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, /* Hold our list modification lock here */ mutex_lock(&dev_opp_list_lock); - new_opp = _allocate_opp(dev, &dev_opp); + new_opp = _allocate_opp(dev, &dev_opp, 1); if (!new_opp) { ret = -ENOMEM; goto unlock; @@ -747,7 +758,7 @@ static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, /* populate the opp table */ new_opp->rate = freq; - new_opp->u_volt = u_volt; + new_opp->supplies[0].u_volt = u_volt; new_opp->available = true; new_opp->dynamic = dynamic; @@ -774,6 +785,7 @@ static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, /* TODO: Support multiple regulators */ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev) { + struct opp_supply *supply = &opp->supplies[0]; u32 microvolt[3] = {0}; u32 val; int count, ret; @@ -804,12 +816,12 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev) return -EINVAL; } - opp->u_volt = microvolt[0]; - opp->u_volt_min = microvolt[1]; - opp->u_volt_max = microvolt[2]; + supply->u_volt = microvolt[0]; + supply->u_volt_min = microvolt[1]; + supply->u_volt_max = microvolt[2]; if (!of_property_read_u32(opp->np, "opp-microamp", &val)) - opp->u_amp = val; + supply->u_amp = val; return 0; } @@ -818,6 +830,7 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev) * _opp_add_static_v2() - Allocate static OPPs (As per 'v2' DT bindings) * @dev: device for which we do this operation * @np: device node + * @supply_count: Number of supplies available for each OPP * * This function adds an opp definition to the opp list and returns status. The * opp can be controlled using dev_pm_opp_enable/disable functions and may be @@ -837,10 +850,12 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev) * -ENOMEM Memory allocation failure * -EINVAL Failed parsing the OPP node */ -static int _opp_add_static_v2(struct device *dev, struct device_node *np) +static int _opp_add_static_v2(struct device *dev, struct device_node *np, + int supply_count) { struct device_opp *dev_opp; struct dev_pm_opp *new_opp; + struct opp_supply *supply; u64 rate; u32 val; int ret; @@ -848,7 +863,7 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np) /* Hold our list modification lock here */ mutex_lock(&dev_opp_list_lock); - new_opp = _allocate_opp(dev, &dev_opp); + new_opp = _allocate_opp(dev, &dev_opp, supply_count); if (!new_opp) { ret = -ENOMEM; goto unlock; @@ -898,9 +913,10 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np) mutex_unlock(&dev_opp_list_lock); + supply = &new_opp->supplies[0]; pr_debug("%s: turbo:%d rate:%lu uv:%lu uvmin:%lu uvmax:%lu latency:%lu\n", - __func__, new_opp->turbo, new_opp->rate, new_opp->u_volt, - new_opp->u_volt_min, new_opp->u_volt_max, + __func__, new_opp->turbo, new_opp->rate, supply->u_volt, + supply->u_volt_min, supply->u_volt_max, new_opp->clock_latency_ns); /* @@ -1187,7 +1203,8 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) for_each_available_child_of_node(opp_np, np) { count++; - ret = _opp_add_static_v2(dev, np); + /* Todo: Add support for multiple supplies */ + ret = _opp_add_static_v2(dev, np, 1); if (ret) { dev_err(dev, "%s: Failed to add OPP, %d\n", __func__, ret); diff --git a/drivers/base/power/opp/opp.h b/drivers/base/power/opp/opp.h index dcb38f78dae4..bdc2bbab1444 100644 --- a/drivers/base/power/opp/opp.h +++ b/drivers/base/power/opp/opp.h @@ -38,6 +38,22 @@ */ /** + * struct opp_supply - Per power-supply structure + * @u_volt: Target voltage in microvolts corresponding to this OPP + * @u_volt_min: Minimum voltage in microvolts corresponding to this OPP + * @u_volt_max: Maximum voltage in microvolts corresponding to this OPP + * @u_amp: Maximum current drawn by the device in microamperes + * + * This structure stores the OPP power-supply information for a given device. + */ +struct opp_supply { + unsigned long u_volt; + unsigned long u_volt_min; + unsigned long u_volt_max; + unsigned long u_amp; +}; + +/** * struct dev_pm_opp - Generic OPP description structure * @node: opp list node. The nodes are maintained throughout the lifetime * of boot. It is expected only an optimal set of OPPs are @@ -51,10 +67,7 @@ * @available: true/false - marks if this OPP as available or not * @turbo: true if turbo (boost) OPP * @rate: Frequency in hertz - * @u_volt: Target voltage in microvolts corresponding to this OPP - * @u_volt_min: Minimum voltage in microvolts corresponding to this OPP - * @u_volt_max: Maximum voltage in microvolts corresponding to this OPP - * @u_amp: Maximum current drawn by the device in microamperes + * @supplies: Array of power-supplies for the device. * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's * frequency from any other OPP's frequency. * @dev_opp: points back to the device_opp struct this opp belongs to @@ -71,10 +84,8 @@ struct dev_pm_opp { bool turbo; unsigned long rate; - unsigned long u_volt; - unsigned long u_volt_min; - unsigned long u_volt_max; - unsigned long u_amp; + struct opp_supply *supplies; + unsigned long clock_latency_ns; struct device_opp *dev_opp; @@ -110,6 +121,7 @@ struct device_list_opp { * @dev_list: list of devices that share these OPPs * @opp_list: list of opps * @np: struct device_node pointer for opp's DT node. + * @supply_count: Number of power-supplies * @shared_opp: OPP is shared between multiple devices. * * This is an internal data structure maintaining the link to opps attached to @@ -130,6 +142,7 @@ struct device_opp { struct device_node *np; unsigned long clock_latency_ns_max; + unsigned int supply_count; bool shared_opp; struct dev_pm_opp *suspend_opp; }; -- 2.4.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH V2 4/4] PM / OPP: Create separate structure for regulator/supplies 2015-10-15 16:12 ` [PATCH V2 4/4] PM / OPP: Create separate structure for regulator/supplies Viresh Kumar @ 2015-10-28 8:37 ` Viresh Kumar 0 siblings, 0 replies; 17+ messages in thread From: Viresh Kumar @ 2015-10-28 8:37 UTC (permalink / raw) To: Rafael Wysocki Cc: linaro-kernel, linux-pm, sboyd, nm, Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Greg Kroah-Hartman, Len Brown, open list, Pavel Machek On 15-10-15, 21:42, Viresh Kumar wrote: > Support for multiple regulators will be added later, until then move > all power-supply related information in a separate structure. > > To make allocating/freeing memory for these supply structures easy, > allocate memory for them along with opp. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > --- > drivers/base/power/opp/core.c | 57 ++++++++++++++++++++++++++++--------------- > drivers/base/power/opp/opp.h | 29 ++++++++++++++++------ > 2 files changed, 58 insertions(+), 28 deletions(-) Please drop this patch for now, I will get it included in the multi-regulator series later. -- viresh ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH V2 0/4] OPP: Some cleanups 2015-10-15 16:12 [PATCH V2 0/4] OPP: Some cleanups Viresh Kumar ` (3 preceding siblings ...) 2015-10-15 16:12 ` [PATCH V2 4/4] PM / OPP: Create separate structure for regulator/supplies Viresh Kumar @ 2015-10-28 8:25 ` Rafael J. Wysocki 2015-10-28 8:40 ` Viresh Kumar 2015-11-05 22:44 ` Rafael J. Wysocki 5 siblings, 1 reply; 17+ messages in thread From: Rafael J. Wysocki @ 2015-10-28 8:25 UTC (permalink / raw) To: Viresh Kumar; +Cc: linaro-kernel, linux-pm, sboyd, nm On Thursday, October 15, 2015 09:42:42 PM Viresh Kumar wrote: > Rafael, > > These are some random cleanups, which were part of the multi-regulator > series earlier. Sending them separately to make that series a bit light > weight. > > V1->V2: > - Just sending them separately. > > Viresh Kumar (4): > PM / OPP: Improve debug print messages with pr_fmt > PM / OPP: Rename routines specific to old bindings with _v1 > PM / OPP: Parse all power-supply related bindings together > PM / OPP: Create separate structure for regulator/supplies > > drivers/base/power/opp/core.c | 78 +++++++++++++++++++++++++++---------------- > drivers/base/power/opp/cpu.c | 3 ++ > drivers/base/power/opp/opp.h | 29 +++++++++++----- > 3 files changed, 73 insertions(+), 37 deletions(-) I'd like to receive an ACK from someone like Stephen on this one. Thanks, Rafael ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH V2 0/4] OPP: Some cleanups 2015-10-28 8:25 ` [PATCH V2 0/4] OPP: Some cleanups Rafael J. Wysocki @ 2015-10-28 8:40 ` Viresh Kumar 2015-10-28 18:48 ` Stephen Boyd 0 siblings, 1 reply; 17+ messages in thread From: Viresh Kumar @ 2015-10-28 8:40 UTC (permalink / raw) To: Rafael J. Wysocki; +Cc: linaro-kernel, linux-pm, sboyd, nm On 28-10-15, 09:25, Rafael J. Wysocki wrote: > On Thursday, October 15, 2015 09:42:42 PM Viresh Kumar wrote: > > Rafael, > > > > These are some random cleanups, which were part of the multi-regulator > > series earlier. Sending them separately to make that series a bit light > > weight. > > > > V1->V2: > > - Just sending them separately. > > > > Viresh Kumar (4): > > PM / OPP: Improve debug print messages with pr_fmt > > PM / OPP: Rename routines specific to old bindings with _v1 > > PM / OPP: Parse all power-supply related bindings together > > PM / OPP: Create separate structure for regulator/supplies > > > > drivers/base/power/opp/core.c | 78 +++++++++++++++++++++++++++---------------- > > drivers/base/power/opp/cpu.c | 3 ++ > > drivers/base/power/opp/opp.h | 29 +++++++++++----- > > 3 files changed, 73 insertions(+), 37 deletions(-) > > I'd like to receive an ACK from someone like Stephen on this one. He isn't around probably, I couldn't find him on IRC for last few days. I have just asked you (in another reply) to drop the fourth patch for now. Apart from that things are really trivial, renaming/moving code around. Please see if those can be included without waiting for Stephen to return. -- viresh ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH V2 0/4] OPP: Some cleanups 2015-10-28 8:40 ` Viresh Kumar @ 2015-10-28 18:48 ` Stephen Boyd 0 siblings, 0 replies; 17+ messages in thread From: Stephen Boyd @ 2015-10-28 18:48 UTC (permalink / raw) To: Viresh Kumar; +Cc: Rafael J. Wysocki, linaro-kernel, linux-pm, nm On 10/28, Viresh Kumar wrote: > On 28-10-15, 09:25, Rafael J. Wysocki wrote: > > On Thursday, October 15, 2015 09:42:42 PM Viresh Kumar wrote: > > > Rafael, > > > > > > These are some random cleanups, which were part of the multi-regulator > > > series earlier. Sending them separately to make that series a bit light > > > weight. > > > > > > V1->V2: > > > - Just sending them separately. > > > > > > Viresh Kumar (4): > > > PM / OPP: Improve debug print messages with pr_fmt > > > PM / OPP: Rename routines specific to old bindings with _v1 > > > PM / OPP: Parse all power-supply related bindings together > > > PM / OPP: Create separate structure for regulator/supplies > > > > > > drivers/base/power/opp/core.c | 78 +++++++++++++++++++++++++++---------------- > > > drivers/base/power/opp/cpu.c | 3 ++ > > > drivers/base/power/opp/opp.h | 29 +++++++++++----- > > > 3 files changed, 73 insertions(+), 37 deletions(-) > > > > I'd like to receive an ACK from someone like Stephen on this one. > > He isn't around probably, I couldn't find him on IRC for last few > days. I have just asked you (in another reply) to drop the fourth > patch for now. > > Apart from that things are really trivial, renaming/moving code > around. Please see if those can be included without waiting for > Stephen to return. > Sorry it seems I got booted from freenode and didn't notice. I've sent Reviewed-by for the three patches. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH V2 0/4] OPP: Some cleanups 2015-10-15 16:12 [PATCH V2 0/4] OPP: Some cleanups Viresh Kumar ` (4 preceding siblings ...) 2015-10-28 8:25 ` [PATCH V2 0/4] OPP: Some cleanups Rafael J. Wysocki @ 2015-11-05 22:44 ` Rafael J. Wysocki 5 siblings, 0 replies; 17+ messages in thread From: Rafael J. Wysocki @ 2015-11-05 22:44 UTC (permalink / raw) To: Viresh Kumar; +Cc: linaro-kernel, linux-pm, sboyd, nm On Thursday, October 15, 2015 09:42:42 PM Viresh Kumar wrote: > Rafael, > > These are some random cleanups, which were part of the multi-regulator > series earlier. Sending them separately to make that series a bit light > weight. > > V1->V2: > - Just sending them separately. > > Viresh Kumar (4): > PM / OPP: Improve debug print messages with pr_fmt > PM / OPP: Rename routines specific to old bindings with _v1 > PM / OPP: Parse all power-supply related bindings together > PM / OPP: Create separate structure for regulator/supplies > > drivers/base/power/opp/core.c | 78 +++++++++++++++++++++++++++---------------- > drivers/base/power/opp/cpu.c | 3 ++ > drivers/base/power/opp/opp.h | 29 +++++++++++----- > 3 files changed, 73 insertions(+), 37 deletions(-) Applied [1-3/4], thanks! Rafael ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2015-11-05 22:15 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-10-15 16:12 [PATCH V2 0/4] OPP: Some cleanups Viresh Kumar 2015-10-15 16:12 ` [PATCH V2 1/4] PM / OPP: Improve debug print messages with pr_fmt Viresh Kumar 2015-10-15 19:04 ` Stephen Boyd 2015-10-16 5:37 ` Viresh Kumar 2015-10-16 19:20 ` Stephen Boyd 2015-10-17 4:15 ` [PATCH V3 1/4] PM / OPP: Improve " Viresh Kumar 2015-10-28 18:49 ` Stephen Boyd 2015-10-15 16:12 ` [PATCH V2 2/4] PM / OPP: Rename routines specific to old bindings with _v1 Viresh Kumar 2015-10-28 18:48 ` Stephen Boyd 2015-10-15 16:12 ` [PATCH V2 3/4] PM / OPP: Parse all power-supply related bindings together Viresh Kumar 2015-10-28 18:48 ` Stephen Boyd 2015-10-15 16:12 ` [PATCH V2 4/4] PM / OPP: Create separate structure for regulator/supplies Viresh Kumar 2015-10-28 8:37 ` Viresh Kumar 2015-10-28 8:25 ` [PATCH V2 0/4] OPP: Some cleanups Rafael J. Wysocki 2015-10-28 8:40 ` Viresh Kumar 2015-10-28 18:48 ` Stephen Boyd 2015-11-05 22:44 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).