* [PATCH v3 0/3] cpufreq-dt: add suspend frequency support
@ 2015-09-03 18:11 Bartlomiej Zolnierkiewicz
2015-09-03 18:11 ` [PATCH v3 1/3] PM / OPP: add dev_pm_opp_get_suspend_opp() helper Bartlomiej Zolnierkiewicz
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2015-09-03 18:11 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
This patch series adds suspend frequency support (using opp-v2
bindings and suspend-opp functionality) to cpufreq-dt driver and
then adds suspend opp for Exynos4412 based boards.
This patch series fixes suspend/resume support on Exynos4412
based Trats2 board and reboot hang on Exynos4412 based Odroid
U3 board.
Changes since v2:
- rewrited to use suspend-opp functionality
Changes since v1:
- removed superfluous ";"
Depends on:
- next-20150902 branch of linux-next kernel tree
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Bartlomiej Zolnierkiewicz (3):
PM / OPP: add dev_pm_opp_get_suspend_opp() helper
cpufreq-dt: add suspend frequency support
ARM: dts: add suspend opp to exynos4412
arch/arm/boot/dts/exynos4412.dtsi | 1 +
drivers/base/power/opp.c | 28 ++++++++++++++++++++++++++++
drivers/cpufreq/cpufreq-dt.c | 32 ++++++++++++++++++++++++++++++++
include/linux/pm_opp.h | 6 ++++++
4 files changed, 67 insertions(+)
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/3] PM / OPP: add dev_pm_opp_get_suspend_opp() helper
2015-09-03 18:11 [PATCH v3 0/3] cpufreq-dt: add suspend frequency support Bartlomiej Zolnierkiewicz
@ 2015-09-03 18:11 ` Bartlomiej Zolnierkiewicz
2015-09-07 5:56 ` Viresh Kumar
2015-09-03 18:11 ` [PATCH v3 2/3] cpufreq-dt: add suspend frequency support Bartlomiej Zolnierkiewicz
2015-09-03 18:11 ` [PATCH v3 3/3] ARM: dts: add suspend opp to exynos4412 Bartlomiej Zolnierkiewicz
2 siblings, 1 reply; 7+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2015-09-03 18:11 UTC (permalink / raw)
To: linux-arm-kernel
Add dev_pm_opp_get_suspend_opp() helper to obtain suspend opp.
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
drivers/base/power/opp.c | 28 ++++++++++++++++++++++++++++
include/linux/pm_opp.h | 6 ++++++
2 files changed, 34 insertions(+)
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index eb25449..eaafca7 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -341,6 +341,34 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency);
/**
+ * dev_pm_opp_get_suspend_opp() - Get suspend opp
+ * @dev: device for which we do this operation
+ *
+ * Return: This function returns pointer to the suspend opp if it is
+ * defined, otherwise it returns NULL.
+ *
+ * Locking: This function takes rcu_read_lock().
+ */
+struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
+{
+ struct device_opp *dev_opp;
+ struct dev_pm_opp *suspend_opp;
+
+ rcu_read_lock();
+
+ dev_opp = _find_device_opp(dev);
+ if (IS_ERR(dev_opp))
+ suspend_opp = NULL;
+ else
+ suspend_opp = dev_opp->suspend_opp;
+
+ rcu_read_unlock();
+
+ return suspend_opp;
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp);
+
+/**
* dev_pm_opp_get_opp_count() - Get number of opps available in the opp list
* @dev: device for which we do this operation
*
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index cab7ba5..e817722 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -34,6 +34,7 @@ bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
int dev_pm_opp_get_opp_count(struct device *dev);
unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
+struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev);
struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
unsigned long freq,
@@ -80,6 +81,11 @@ static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
return 0;
}
+static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
+{
+ return NULL;
+}
+
static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
unsigned long freq, bool available)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/3] cpufreq-dt: add suspend frequency support
2015-09-03 18:11 [PATCH v3 0/3] cpufreq-dt: add suspend frequency support Bartlomiej Zolnierkiewicz
2015-09-03 18:11 ` [PATCH v3 1/3] PM / OPP: add dev_pm_opp_get_suspend_opp() helper Bartlomiej Zolnierkiewicz
@ 2015-09-03 18:11 ` Bartlomiej Zolnierkiewicz
2015-09-07 5:58 ` Viresh Kumar
2015-09-03 18:11 ` [PATCH v3 3/3] ARM: dts: add suspend opp to exynos4412 Bartlomiej Zolnierkiewicz
2 siblings, 1 reply; 7+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2015-09-03 18:11 UTC (permalink / raw)
To: linux-arm-kernel
Add suspend frequency support and if needed set it to
the frequency obtained from the suspend opp (can be defined
using opp-v2 bindings and is optional). Also implement
custom suspend method (needed to not error out on platforms
which don't require suspend frequency).
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
drivers/cpufreq/cpufreq-dt.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index c3583cd..ba4ca85 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -196,6 +196,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
struct device *cpu_dev;
struct regulator *cpu_reg;
struct clk *cpu_clk;
+ struct dev_pm_opp *suspend_opp;
unsigned long min_uV = ~0, max_uV = 0;
unsigned int transition_latency;
bool need_update = false;
@@ -329,6 +330,11 @@ static int cpufreq_init(struct cpufreq_policy *policy)
policy->driver_data = priv;
policy->clk = cpu_clk;
+
+ suspend_opp = dev_pm_opp_get_suspend_opp(cpu_dev);
+ if (suspend_opp)
+ policy->suspend_freq = dev_pm_opp_get_freq(suspend_opp) / 1000;
+
ret = cpufreq_table_validate_and_show(policy, freq_table);
if (ret) {
dev_err(cpu_dev, "%s: invalid frequency table: %d\n", __func__,
@@ -409,6 +415,31 @@ static void cpufreq_ready(struct cpufreq_policy *policy)
of_node_put(np);
}
+#ifdef CONFIG_PM
+static int cpufreq_dt_suspend(struct cpufreq_policy *policy)
+{
+ int ret;
+
+ if (!policy->suspend_freq) {
+ pr_debug("%s: suspend_freq not defined\n", __func__);
+ return 0;
+ }
+
+ pr_debug("%s: Setting suspend-freq: %u\n", __func__,
+ policy->suspend_freq);
+
+ ret = __cpufreq_driver_target(policy, policy->suspend_freq,
+ CPUFREQ_RELATION_H);
+ if (ret)
+ pr_err("%s: unable to set suspend-freq: %u. err: %d\n",
+ __func__, policy->suspend_freq, ret);
+
+ return ret;
+}
+#else
+#define cpufreq_dt_suspend NULL
+#endif
+
static struct cpufreq_driver dt_cpufreq_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify,
@@ -419,6 +450,7 @@ static struct cpufreq_driver dt_cpufreq_driver = {
.ready = cpufreq_ready,
.name = "cpufreq-dt",
.attr = cpufreq_dt_attr,
+ .suspend = cpufreq_dt_suspend,
};
static int dt_cpufreq_probe(struct platform_device *pdev)
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/3] ARM: dts: add suspend opp to exynos4412
2015-09-03 18:11 [PATCH v3 0/3] cpufreq-dt: add suspend frequency support Bartlomiej Zolnierkiewicz
2015-09-03 18:11 ` [PATCH v3 1/3] PM / OPP: add dev_pm_opp_get_suspend_opp() helper Bartlomiej Zolnierkiewicz
2015-09-03 18:11 ` [PATCH v3 2/3] cpufreq-dt: add suspend frequency support Bartlomiej Zolnierkiewicz
@ 2015-09-03 18:11 ` Bartlomiej Zolnierkiewicz
2015-09-07 5:59 ` Viresh Kumar
2 siblings, 1 reply; 7+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2015-09-03 18:11 UTC (permalink / raw)
To: linux-arm-kernel
Mark 800MHz OPP as a suspend opp for Exynos4412 based
boards so effectively cpufreq-dt driver behavior w.r.t.
suspend frequency matches what the old exynos-cpufreq
driver has been doing.
This patch fixes suspend/resume support on Exynos4412 based
Trats2 board and reboot hang on Exynos4412 based Odroid U3
board.
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
arch/arm/boot/dts/exynos4412.dtsi | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index ca0e3c1..294cfe4 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -98,6 +98,7 @@
opp-hz = /bits/ 64 <800000000>;
opp-microvolt = <1000000>;
clock-latency-ns = <200000>;
+ opp-suspend;
};
opp07 {
opp-hz = /bits/ 64 <900000000>;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 1/3] PM / OPP: add dev_pm_opp_get_suspend_opp() helper
2015-09-03 18:11 ` [PATCH v3 1/3] PM / OPP: add dev_pm_opp_get_suspend_opp() helper Bartlomiej Zolnierkiewicz
@ 2015-09-07 5:56 ` Viresh Kumar
0 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2015-09-07 5:56 UTC (permalink / raw)
To: linux-arm-kernel
On 03-09-15, 20:11, Bartlomiej Zolnierkiewicz wrote:
> Add dev_pm_opp_get_suspend_opp() helper to obtain suspend opp.
>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Thomas Abraham <thomas.ab@samsung.com>
> Cc: Javier Martinez Canillas <javier@osg.samsung.com>
> Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> ---
> drivers/base/power/opp.c | 28 ++++++++++++++++++++++++++++
> include/linux/pm_opp.h | 6 ++++++
> 2 files changed, 34 insertions(+)
>
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index eb25449..eaafca7 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -341,6 +341,34 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
> EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency);
>
> /**
> + * dev_pm_opp_get_suspend_opp() - Get suspend opp
> + * @dev: device for which we do this operation
> + *
> + * Return: This function returns pointer to the suspend opp if it is
> + * defined, otherwise it returns NULL.
> + *
> + * Locking: This function takes rcu_read_lock().
> + */
> +struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
> +{
> + struct device_opp *dev_opp;
> + struct dev_pm_opp *suspend_opp;
> +
> + rcu_read_lock();
This is wrong. Please have a look at other exported APIs that return
an OPP. RCU protected structures must be accessed from within RCU
locks _ONLY_. But your function returns the pointer after dropping
the locks. Which essentially means that the OPP can be freed by core,
by the time you start using it. :)
So, in such cases, its upto the caller to ensure that locks are taken
properly.
You can look at dev_pm_opp_find_freq_exact() as an example.
--
viresh
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 2/3] cpufreq-dt: add suspend frequency support
2015-09-03 18:11 ` [PATCH v3 2/3] cpufreq-dt: add suspend frequency support Bartlomiej Zolnierkiewicz
@ 2015-09-07 5:58 ` Viresh Kumar
0 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2015-09-07 5:58 UTC (permalink / raw)
To: linux-arm-kernel
On 03-09-15, 20:11, Bartlomiej Zolnierkiewicz wrote:
> Add suspend frequency support and if needed set it to
> the frequency obtained from the suspend opp (can be defined
> using opp-v2 bindings and is optional). Also implement
> custom suspend method (needed to not error out on platforms
> which don't require suspend frequency).
>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Thomas Abraham <thomas.ab@samsung.com>
> Cc: Javier Martinez Canillas <javier@osg.samsung.com>
> Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> ---
> drivers/cpufreq/cpufreq-dt.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> +#ifdef CONFIG_PM
> +static int cpufreq_dt_suspend(struct cpufreq_policy *policy)
> +{
> + int ret;
> +
> + if (!policy->suspend_freq) {
> + pr_debug("%s: suspend_freq not defined\n", __func__);
> + return 0;
> + }
> +
> + pr_debug("%s: Setting suspend-freq: %u\n", __func__,
> + policy->suspend_freq);
> +
> + ret = __cpufreq_driver_target(policy, policy->suspend_freq,
> + CPUFREQ_RELATION_H);
> + if (ret)
> + pr_err("%s: unable to set suspend-freq: %u. err: %d\n",
> + __func__, policy->suspend_freq, ret);
> +
> + return ret;
> +}
> +#else
> +#define cpufreq_dt_suspend NULL
> +#endif
No, there is no point replicating the exactly same routine again.
Rather modify cpufreq_generic_suspend() to not print error and instead
do pr_debug(), on !policy->suspend_freq.
--
viresh
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 3/3] ARM: dts: add suspend opp to exynos4412
2015-09-03 18:11 ` [PATCH v3 3/3] ARM: dts: add suspend opp to exynos4412 Bartlomiej Zolnierkiewicz
@ 2015-09-07 5:59 ` Viresh Kumar
0 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2015-09-07 5:59 UTC (permalink / raw)
To: linux-arm-kernel
On 03-09-15, 20:11, Bartlomiej Zolnierkiewicz wrote:
> Mark 800MHz OPP as a suspend opp for Exynos4412 based
> boards so effectively cpufreq-dt driver behavior w.r.t.
> suspend frequency matches what the old exynos-cpufreq
> driver has been doing.
>
> This patch fixes suspend/resume support on Exynos4412 based
> Trats2 board and reboot hang on Exynos4412 based Odroid U3
> board.
>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Thomas Abraham <thomas.ab@samsung.com>
> Cc: Javier Martinez Canillas <javier@osg.samsung.com>
> Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> ---
> arch/arm/boot/dts/exynos4412.dtsi | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
> index ca0e3c1..294cfe4 100644
> --- a/arch/arm/boot/dts/exynos4412.dtsi
> +++ b/arch/arm/boot/dts/exynos4412.dtsi
> @@ -98,6 +98,7 @@
> opp-hz = /bits/ 64 <800000000>;
> opp-microvolt = <1000000>;
> clock-latency-ns = <200000>;
> + opp-suspend;
> };
> opp07 {
> opp-hz = /bits/ 64 <900000000>;
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-09-07 5:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-03 18:11 [PATCH v3 0/3] cpufreq-dt: add suspend frequency support Bartlomiej Zolnierkiewicz
2015-09-03 18:11 ` [PATCH v3 1/3] PM / OPP: add dev_pm_opp_get_suspend_opp() helper Bartlomiej Zolnierkiewicz
2015-09-07 5:56 ` Viresh Kumar
2015-09-03 18:11 ` [PATCH v3 2/3] cpufreq-dt: add suspend frequency support Bartlomiej Zolnierkiewicz
2015-09-07 5:58 ` Viresh Kumar
2015-09-03 18:11 ` [PATCH v3 3/3] ARM: dts: add suspend opp to exynos4412 Bartlomiej Zolnierkiewicz
2015-09-07 5:59 ` Viresh Kumar
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).