All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] cpufreq: resource management in preparation for module build
@ 2015-02-02 20:58 Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                   ` (16 more replies)
  0 siblings, 17 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar; +Cc: Eduardo Valentin

Dear all,

The exynos cpufreq driver needs to be build as module. The need is to fix
the problem risen by Arnd due to the added OF thermal dependency [1].

Therefore, this series, in preparation to allow building this driver as
a module, changes the way this driver handles allocated resources. Now
it is expected to free the allocated resources uppon driver exit.

A couple of changes in the data structure organization and callbacks were necessary.
Therefore, changes were added accordingly.

Please review. I do not have a way to test these patch in a board today though. So, testing
is more than welcome :-).

[1] - https://lkml.org/lkml/2015/1/31/175

Cheers,

Eduardo Valentin (14):
  cpufreq: exynos4210: properly put of node
  cpufreq: exynos4210: iounmap in error path
  cpufreq: exynos4210: use devm_clk_get
  cpufreq: exynos4x12: properly put of node
  cpufreq: exynos4x12: iounmap in error path
  cpufreq: exynos4x12: use devm_clk_get
  cpufreq: exynos5250: properly put of node
  cpufreq: exynos5250: iounmap in error path
  cpufreq: exynos5250: use devm_clk_get
  cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback
  cpufreq: exynos4210: remove unused symbol cpufreq
  cpufreq: exynos4x12: remove unused symbol cpufreq
  cpufreq: exynos5250: remove unused symbol cpufreq
  cpufreq: exynos-cpufreq: release resources by using managed allocation

 drivers/cpufreq/exynos-cpufreq.c     | 101 ++++++++++++++++++++++-------------
 drivers/cpufreq/exynos-cpufreq.h     |   7 ++-
 drivers/cpufreq/exynos4210-cpufreq.c |  47 ++++++++--------
 drivers/cpufreq/exynos4x12-cpufreq.c |  49 +++++++++--------
 drivers/cpufreq/exynos5250-cpufreq.c |  49 +++++++++--------
 5 files changed, 140 insertions(+), 113 deletions(-)

-- 
2.1.3


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 01/14] cpufreq: exynos4210: properly put of node
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

Call of_node_put when necessary during init.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4210-cpufreq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 843ec82..dba48f0 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -169,6 +169,7 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
 	info->set_freq = exynos4210_set_frequency;
 
 	cpufreq = info;
+	of_node_put(np);
 
 	return 0;
 
@@ -179,6 +180,8 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
+
 	return -EINVAL;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 01/14] cpufreq: exynos4210: properly put of node
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

Call of_node_put when necessary during init.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4210-cpufreq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 843ec82..dba48f0 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -169,6 +169,7 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
 	info->set_freq = exynos4210_set_frequency;
 
 	cpufreq = info;
+	of_node_put(np);
 
 	return 0;
 
@@ -179,6 +180,8 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
+
 	return -EINVAL;
 }
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 02/14] cpufreq: exynos4210: iounmap in error path
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

When error occurs, allow systems to release iomapped area.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4210-cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index dba48f0..8a25dce 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -180,6 +180,7 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 02/14] cpufreq: exynos4210: iounmap in error path
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

When error occurs, allow systems to release iomapped area.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4210-cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index dba48f0..8a25dce 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -180,6 +180,7 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
 
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 03/14] cpufreq: exynos4210: use devm_clk_get
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

Switch to managed clk_get to properly release resources when
they are not needed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4210-cpufreq.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 8a25dce..fc02a39 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -142,23 +142,23 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
 		return -EFAULT;
 	}
 
-	cpu_clk = clk_get(NULL, "armclk");
+	cpu_clk = devm_clk_get(info->dev, "armclk");
 	if (IS_ERR(cpu_clk))
-		return PTR_ERR(cpu_clk);
+		goto err;
 
-	moutcore = clk_get(NULL, "moutcore");
+	moutcore = devm_clk_get(info->dev, "moutcore");
 	if (IS_ERR(moutcore))
-		goto err_moutcore;
+		goto err;
 
-	mout_mpll = clk_get(NULL, "mout_mpll");
+	mout_mpll = devm_clk_get(info->dev, "mout_mpll");
 	if (IS_ERR(mout_mpll))
-		goto err_mout_mpll;
+		goto err;
 
 	rate = clk_get_rate(mout_mpll) / 1000;
 
-	mout_apll = clk_get(NULL, "mout_apll");
+	mout_apll = devm_clk_get(info->dev, "mout_apll");
 	if (IS_ERR(mout_apll))
-		goto err_mout_apll;
+		goto err;
 
 	info->mpll_freq_khz = rate;
 	/* 800Mhz */
@@ -173,13 +173,7 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
 
 	return 0;
 
-err_mout_apll:
-	clk_put(mout_mpll);
-err_mout_mpll:
-	clk_put(moutcore);
-err_moutcore:
-	clk_put(cpu_clk);
-
+err:
 	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 03/14] cpufreq: exynos4210: use devm_clk_get
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

Switch to managed clk_get to properly release resources when
they are not needed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4210-cpufreq.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 8a25dce..fc02a39 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -142,23 +142,23 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
 		return -EFAULT;
 	}
 
-	cpu_clk = clk_get(NULL, "armclk");
+	cpu_clk = devm_clk_get(info->dev, "armclk");
 	if (IS_ERR(cpu_clk))
-		return PTR_ERR(cpu_clk);
+		goto err;
 
-	moutcore = clk_get(NULL, "moutcore");
+	moutcore = devm_clk_get(info->dev, "moutcore");
 	if (IS_ERR(moutcore))
-		goto err_moutcore;
+		goto err;
 
-	mout_mpll = clk_get(NULL, "mout_mpll");
+	mout_mpll = devm_clk_get(info->dev, "mout_mpll");
 	if (IS_ERR(mout_mpll))
-		goto err_mout_mpll;
+		goto err;
 
 	rate = clk_get_rate(mout_mpll) / 1000;
 
-	mout_apll = clk_get(NULL, "mout_apll");
+	mout_apll = devm_clk_get(info->dev, "mout_apll");
 	if (IS_ERR(mout_apll))
-		goto err_mout_apll;
+		goto err;
 
 	info->mpll_freq_khz = rate;
 	/* 800Mhz */
@@ -173,13 +173,7 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
 
 	return 0;
 
-err_mout_apll:
-	clk_put(mout_mpll);
-err_mout_mpll:
-	clk_put(moutcore);
-err_moutcore:
-	clk_put(cpu_clk);
-
+err:
 	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 04/14] cpufreq: exynos4x12: properly put of node
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (14 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

Call of_node_put when necessary during init.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4x12-cpufreq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 9e78a85..3d067f2 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -221,6 +221,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 	info->set_freq = exynos4x12_set_frequency;
 
 	cpufreq = info;
+	of_node_put(np);
 
 	return 0;
 
@@ -231,6 +232,8 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
+
 	return -EINVAL;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 04/14] cpufreq: exynos4x12: properly put of node
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: linux-samsung-soc, Rafael J. Wysocki, linux-kernel,
	Eduardo Valentin, Kukjin Kim, linux-arm-kernel

Call of_node_put when necessary during init.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4x12-cpufreq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 9e78a85..3d067f2 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -221,6 +221,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 	info->set_freq = exynos4x12_set_frequency;
 
 	cpufreq = info;
+	of_node_put(np);
 
 	return 0;
 
@@ -231,6 +232,8 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
+
 	return -EINVAL;
 }
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 04/14] cpufreq: exynos4x12: properly put of node
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

Call of_node_put when necessary during init.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4x12-cpufreq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 9e78a85..3d067f2 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -221,6 +221,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 	info->set_freq = exynos4x12_set_frequency;
 
 	cpufreq = info;
+	of_node_put(np);
 
 	return 0;
 
@@ -231,6 +232,8 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
+
 	return -EINVAL;
 }
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 05/14] cpufreq: exynos4x12: iounmap in error path
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
                   ` (3 preceding siblings ...)
  2015-02-02 20:58   ` Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar; +Cc: Eduardo Valentin

When error occurs, allow systems to release iomapped area.

Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4x12-cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 3d067f2..3da36baf 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -232,6 +232,7 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 06/14] cpufreq: exynos4x12: use devm_clk_get
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

Switch to managed clk_get to properly release resources when
they are not needed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4x12-cpufreq.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 3da36baf..7e0dd2a 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -189,23 +189,23 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 		return -EFAULT;
 	}
 
-	cpu_clk = clk_get(NULL, "armclk");
+	cpu_clk = devm_clk_get(info->dev, "armclk");
 	if (IS_ERR(cpu_clk))
-		return PTR_ERR(cpu_clk);
+		goto err;
 
-	moutcore = clk_get(NULL, "moutcore");
+	moutcore = devm_clk_get(info->dev, "moutcore");
 	if (IS_ERR(moutcore))
-		goto err_moutcore;
+		goto err;
 
-	mout_mpll = clk_get(NULL, "mout_mpll");
+	mout_mpll = devm_clk_get(info->dev, "mout_mpll");
 	if (IS_ERR(mout_mpll))
-		goto err_mout_mpll;
+		goto err;
 
 	rate = clk_get_rate(mout_mpll) / 1000;
 
-	mout_apll = clk_get(NULL, "mout_apll");
+	mout_apll = devm_clk_get(info->dev, "mout_apll");
 	if (IS_ERR(mout_apll))
-		goto err_mout_apll;
+		goto err;
 
 	if (info->type == EXYNOS_SOC_4212)
 		apll_freq_4x12 = apll_freq_4212;
@@ -225,13 +225,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 
 	return 0;
 
-err_mout_apll:
-	clk_put(mout_mpll);
-err_mout_mpll:
-	clk_put(moutcore);
-err_moutcore:
-	clk_put(cpu_clk);
-
+err:
 	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 06/14] cpufreq: exynos4x12: use devm_clk_get
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

Switch to managed clk_get to properly release resources when
they are not needed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4x12-cpufreq.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 3da36baf..7e0dd2a 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -189,23 +189,23 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 		return -EFAULT;
 	}
 
-	cpu_clk = clk_get(NULL, "armclk");
+	cpu_clk = devm_clk_get(info->dev, "armclk");
 	if (IS_ERR(cpu_clk))
-		return PTR_ERR(cpu_clk);
+		goto err;
 
-	moutcore = clk_get(NULL, "moutcore");
+	moutcore = devm_clk_get(info->dev, "moutcore");
 	if (IS_ERR(moutcore))
-		goto err_moutcore;
+		goto err;
 
-	mout_mpll = clk_get(NULL, "mout_mpll");
+	mout_mpll = devm_clk_get(info->dev, "mout_mpll");
 	if (IS_ERR(mout_mpll))
-		goto err_mout_mpll;
+		goto err;
 
 	rate = clk_get_rate(mout_mpll) / 1000;
 
-	mout_apll = clk_get(NULL, "mout_apll");
+	mout_apll = devm_clk_get(info->dev, "mout_apll");
 	if (IS_ERR(mout_apll))
-		goto err_mout_apll;
+		goto err;
 
 	if (info->type == EXYNOS_SOC_4212)
 		apll_freq_4x12 = apll_freq_4212;
@@ -225,13 +225,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 
 	return 0;
 
-err_mout_apll:
-	clk_put(mout_mpll);
-err_mout_mpll:
-	clk_put(moutcore);
-err_moutcore:
-	clk_put(cpu_clk);
-
+err:
 	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_debug("%s: failed initialization\n", __func__);
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 07/14] cpufreq: exynos5250: properly put of node
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
                   ` (5 preceding siblings ...)
  2015-02-02 20:58   ` Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar; +Cc: Eduardo Valentin

Call of_node_put when necessary during init.

Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos5250-cpufreq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index 3eafdc7..50b0cdf 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -195,6 +195,7 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
 	info->set_freq = exynos5250_set_frequency;
 
 	cpufreq = info;
+	of_node_put(np);
 
 	return 0;
 
@@ -205,6 +206,8 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	of_node_put(np);
 	pr_err("%s: failed initialization\n", __func__);
+
 	return -EINVAL;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 08/14] cpufreq: exynos5250: iounmap in error path
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

When error occurs, allow systems to release iomapped area.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos5250-cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index 50b0cdf..e61d149 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -206,6 +206,7 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_err("%s: failed initialization\n", __func__);
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 08/14] cpufreq: exynos5250: iounmap in error path
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

When error occurs, allow systems to release iomapped area.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos5250-cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index 50b0cdf..e61d149 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -206,6 +206,7 @@ err_mout_mpll:
 err_moutcore:
 	clk_put(cpu_clk);
 
+	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_err("%s: failed initialization\n", __func__);
 
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 09/14] cpufreq: exynos5250: use devm_clk_get
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

Switch to managed clk_get to properly release resources when
they are not needed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos5250-cpufreq.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index e61d149..d3ce829 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -168,23 +168,23 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
 		return -EFAULT;
 	}
 
-	cpu_clk = clk_get(NULL, "armclk");
+	cpu_clk = devm_clk_get(info->dev, "armclk");
 	if (IS_ERR(cpu_clk))
-		return PTR_ERR(cpu_clk);
+		goto err;
 
-	moutcore = clk_get(NULL, "mout_cpu");
+	moutcore = devm_clk_get(info->dev, "mout_cpu");
 	if (IS_ERR(moutcore))
-		goto err_moutcore;
+		goto err;
 
-	mout_mpll = clk_get(NULL, "mout_mpll");
+	mout_mpll = devm_clk_get(info->dev, "mout_mpll");
 	if (IS_ERR(mout_mpll))
-		goto err_mout_mpll;
+		goto err;
 
 	rate = clk_get_rate(mout_mpll) / 1000;
 
-	mout_apll = clk_get(NULL, "mout_apll");
+	mout_apll = devm_clk_get(info->dev, "mout_apll");
 	if (IS_ERR(mout_apll))
-		goto err_mout_apll;
+		goto err;
 
 	info->mpll_freq_khz = rate;
 	/* 800Mhz */
@@ -199,13 +199,7 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
 
 	return 0;
 
-err_mout_apll:
-	clk_put(mout_mpll);
-err_mout_mpll:
-	clk_put(moutcore);
-err_moutcore:
-	clk_put(cpu_clk);
-
+err:
 	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_err("%s: failed initialization\n", __func__);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 09/14] cpufreq: exynos5250: use devm_clk_get
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

Switch to managed clk_get to properly release resources when
they are not needed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos5250-cpufreq.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index e61d149..d3ce829 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -168,23 +168,23 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
 		return -EFAULT;
 	}
 
-	cpu_clk = clk_get(NULL, "armclk");
+	cpu_clk = devm_clk_get(info->dev, "armclk");
 	if (IS_ERR(cpu_clk))
-		return PTR_ERR(cpu_clk);
+		goto err;
 
-	moutcore = clk_get(NULL, "mout_cpu");
+	moutcore = devm_clk_get(info->dev, "mout_cpu");
 	if (IS_ERR(moutcore))
-		goto err_moutcore;
+		goto err;
 
-	mout_mpll = clk_get(NULL, "mout_mpll");
+	mout_mpll = devm_clk_get(info->dev, "mout_mpll");
 	if (IS_ERR(mout_mpll))
-		goto err_mout_mpll;
+		goto err;
 
 	rate = clk_get_rate(mout_mpll) / 1000;
 
-	mout_apll = clk_get(NULL, "mout_apll");
+	mout_apll = devm_clk_get(info->dev, "mout_apll");
 	if (IS_ERR(mout_apll))
-		goto err_mout_apll;
+		goto err;
 
 	info->mpll_freq_khz = rate;
 	/* 800Mhz */
@@ -199,13 +199,7 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
 
 	return 0;
 
-err_mout_apll:
-	clk_put(mout_mpll);
-err_mout_mpll:
-	clk_put(moutcore);
-err_moutcore:
-	clk_put(cpu_clk);
-
+err:
 	iounmap(info->cmu_regs);
 	of_node_put(np);
 	pr_err("%s: failed initialization\n", __func__);
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 10/14] cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

This change passes the exynos_dvfs_info to the .set_freq callback
to avoid using local static variables. Now, the core can use
same allocated data structure and child code can work on same
data structure.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos-cpufreq.c     |  2 +-
 drivers/cpufreq/exynos-cpufreq.h     |  2 +-
 drivers/cpufreq/exynos4210-cpufreq.c | 17 ++++++++++-------
 drivers/cpufreq/exynos4x12-cpufreq.c | 19 +++++++++++--------
 drivers/cpufreq/exynos5250-cpufreq.c | 19 +++++++++++--------
 5 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 5e98c6b..a964602 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -108,7 +108,7 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 		}
 	}
 
-	exynos_info->set_freq(old_index, index);
+	exynos_info->set_freq(exynos_info, old_index, index);
 
 	/* When the new frequency is lower than current frequency */
 	if ((target_freq < old_freq) ||
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h
index 9f2062a..b59558e 100644
--- a/drivers/cpufreq/exynos-cpufreq.h
+++ b/drivers/cpufreq/exynos-cpufreq.h
@@ -48,7 +48,7 @@ struct exynos_dvfs_info {
 	struct clk	*cpu_clk;
 	unsigned int	*volt_table;
 	struct cpufreq_frequency_table	*freq_table;
-	void (*set_freq)(unsigned int, unsigned int);
+	void (*set_freq)(struct exynos_dvfs_info *, unsigned int, unsigned int);
 	bool (*need_apll_change)(unsigned int, unsigned int);
 	void __iomem	*cmu_regs;
 };
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index fc02a39..00889a4 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -55,7 +55,8 @@ static struct apll_freq apll_freq_4210[] = {
 	APLL_FREQ(200,  0, 1, 3, 1, 3, 1, 0, 0, 3, 0, 0, 200, 6, 3),
 };
 
-static void exynos4210_set_clkdiv(unsigned int div_index)
+static void exynos4210_set_clkdiv(struct exynos_dvfs_info *cpufreq,
+				  unsigned int div_index)
 {
 	unsigned int tmp;
 
@@ -80,7 +81,8 @@ static void exynos4210_set_clkdiv(unsigned int div_index)
 	} while (tmp & 0x11);
 }
 
-static void exynos4210_set_apll(unsigned int index)
+static void exynos4210_set_apll(struct exynos_dvfs_info *cpufreq,
+				unsigned int index)
 {
 	unsigned int tmp, freq = apll_freq_4210[index].freq;
 
@@ -104,15 +106,16 @@ static void exynos4210_set_apll(unsigned int index)
 	} while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT));
 }
 
-static void exynos4210_set_frequency(unsigned int old_index,
+static void exynos4210_set_frequency(struct exynos_dvfs_info *cpufreq,
+				     unsigned int old_index,
 				     unsigned int new_index)
 {
 	if (old_index > new_index) {
-		exynos4210_set_clkdiv(new_index);
-		exynos4210_set_apll(new_index);
+		exynos4210_set_clkdiv(cpufreq, new_index);
+		exynos4210_set_apll(cpufreq, new_index);
 	} else if (old_index < new_index) {
-		exynos4210_set_apll(new_index);
-		exynos4210_set_clkdiv(new_index);
+		exynos4210_set_apll(cpufreq, new_index);
+		exynos4210_set_clkdiv(cpufreq, new_index);
 	}
 }
 
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 7e0dd2a..d12087b 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -100,7 +100,8 @@ static struct apll_freq apll_freq_4412[] = {
 	APLL_FREQ(200,  0, 1, 3, 0, 1, 1, 1, 0, 3, 0, 0, 100, 3, 2),
 };
 
-static void exynos4x12_set_clkdiv(unsigned int div_index)
+static void exynos4x12_set_clkdiv(struct exynos_dvfs_info *cpufreq,
+				  unsigned int div_index)
 {
 	unsigned int tmp;
 
@@ -125,7 +126,8 @@ static void exynos4x12_set_clkdiv(unsigned int div_index)
 	} while (tmp != 0x0);
 }
 
-static void exynos4x12_set_apll(unsigned int index)
+static void exynos4x12_set_apll(struct exynos_dvfs_info *cpufreq,
+				unsigned int index)
 {
 	unsigned int tmp, freq = apll_freq_4x12[index].freq;
 
@@ -151,15 +153,16 @@ static void exynos4x12_set_apll(unsigned int index)
 	} while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT));
 }
 
-static void exynos4x12_set_frequency(unsigned int old_index,
-				  unsigned int new_index)
+static void exynos4x12_set_frequency(struct exynos_dvfs_info *cpufreq,
+				     unsigned int old_index,
+				     unsigned int new_index)
 {
 	if (old_index > new_index) {
-		exynos4x12_set_clkdiv(new_index);
-		exynos4x12_set_apll(new_index);
+		exynos4x12_set_clkdiv(cpufreq, new_index);
+		exynos4x12_set_apll(cpufreq, new_index);
 	} else if (old_index < new_index) {
-		exynos4x12_set_apll(new_index);
-		exynos4x12_set_clkdiv(new_index);
+		exynos4x12_set_apll(cpufreq, new_index);
+		exynos4x12_set_clkdiv(cpufreq, new_index);
 	}
 }
 
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index d3ce829..191a511 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -80,7 +80,8 @@ static struct apll_freq apll_freq_5250[] = {
 	APLL_FREQ(200,  0, 1, 7, 7, 1, 1, 1, 0, 0, 2, 0, 100, 3, 2),
 };
 
-static void set_clkdiv(unsigned int div_index)
+static void set_clkdiv(struct exynos_dvfs_info *cpufreq,
+		       unsigned int div_index)
 {
 	unsigned int tmp;
 
@@ -103,7 +104,8 @@ static void set_clkdiv(unsigned int div_index)
 		cpu_relax();
 }
 
-static void set_apll(unsigned int index)
+static void set_apll(struct exynos_dvfs_info *cpufreq,
+		     unsigned int index)
 {
 	unsigned int tmp;
 	unsigned int freq = apll_freq_5250[index].freq;
@@ -130,15 +132,16 @@ static void set_apll(unsigned int index)
 	} while (tmp != (0x1 << 16));
 }
 
-static void exynos5250_set_frequency(unsigned int old_index,
-				  unsigned int new_index)
+static void exynos5250_set_frequency(struct exynos_dvfs_info *exynos_info,
+				     unsigned int old_index,
+				     unsigned int new_index)
 {
 	if (old_index > new_index) {
-		set_clkdiv(new_index);
-		set_apll(new_index);
+		set_clkdiv(exynos_info, new_index);
+		set_apll(exynos_info, new_index);
 	} else if (old_index < new_index) {
-		set_apll(new_index);
-		set_clkdiv(new_index);
+		set_apll(exynos_info, new_index);
+		set_clkdiv(exynos_info, new_index);
 	}
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 10/14] cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

This change passes the exynos_dvfs_info to the .set_freq callback
to avoid using local static variables. Now, the core can use
same allocated data structure and child code can work on same
data structure.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos-cpufreq.c     |  2 +-
 drivers/cpufreq/exynos-cpufreq.h     |  2 +-
 drivers/cpufreq/exynos4210-cpufreq.c | 17 ++++++++++-------
 drivers/cpufreq/exynos4x12-cpufreq.c | 19 +++++++++++--------
 drivers/cpufreq/exynos5250-cpufreq.c | 19 +++++++++++--------
 5 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 5e98c6b..a964602 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -108,7 +108,7 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 		}
 	}
 
-	exynos_info->set_freq(old_index, index);
+	exynos_info->set_freq(exynos_info, old_index, index);
 
 	/* When the new frequency is lower than current frequency */
 	if ((target_freq < old_freq) ||
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h
index 9f2062a..b59558e 100644
--- a/drivers/cpufreq/exynos-cpufreq.h
+++ b/drivers/cpufreq/exynos-cpufreq.h
@@ -48,7 +48,7 @@ struct exynos_dvfs_info {
 	struct clk	*cpu_clk;
 	unsigned int	*volt_table;
 	struct cpufreq_frequency_table	*freq_table;
-	void (*set_freq)(unsigned int, unsigned int);
+	void (*set_freq)(struct exynos_dvfs_info *, unsigned int, unsigned int);
 	bool (*need_apll_change)(unsigned int, unsigned int);
 	void __iomem	*cmu_regs;
 };
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index fc02a39..00889a4 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -55,7 +55,8 @@ static struct apll_freq apll_freq_4210[] = {
 	APLL_FREQ(200,  0, 1, 3, 1, 3, 1, 0, 0, 3, 0, 0, 200, 6, 3),
 };
 
-static void exynos4210_set_clkdiv(unsigned int div_index)
+static void exynos4210_set_clkdiv(struct exynos_dvfs_info *cpufreq,
+				  unsigned int div_index)
 {
 	unsigned int tmp;
 
@@ -80,7 +81,8 @@ static void exynos4210_set_clkdiv(unsigned int div_index)
 	} while (tmp & 0x11);
 }
 
-static void exynos4210_set_apll(unsigned int index)
+static void exynos4210_set_apll(struct exynos_dvfs_info *cpufreq,
+				unsigned int index)
 {
 	unsigned int tmp, freq = apll_freq_4210[index].freq;
 
@@ -104,15 +106,16 @@ static void exynos4210_set_apll(unsigned int index)
 	} while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT));
 }
 
-static void exynos4210_set_frequency(unsigned int old_index,
+static void exynos4210_set_frequency(struct exynos_dvfs_info *cpufreq,
+				     unsigned int old_index,
 				     unsigned int new_index)
 {
 	if (old_index > new_index) {
-		exynos4210_set_clkdiv(new_index);
-		exynos4210_set_apll(new_index);
+		exynos4210_set_clkdiv(cpufreq, new_index);
+		exynos4210_set_apll(cpufreq, new_index);
 	} else if (old_index < new_index) {
-		exynos4210_set_apll(new_index);
-		exynos4210_set_clkdiv(new_index);
+		exynos4210_set_apll(cpufreq, new_index);
+		exynos4210_set_clkdiv(cpufreq, new_index);
 	}
 }
 
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 7e0dd2a..d12087b 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -100,7 +100,8 @@ static struct apll_freq apll_freq_4412[] = {
 	APLL_FREQ(200,  0, 1, 3, 0, 1, 1, 1, 0, 3, 0, 0, 100, 3, 2),
 };
 
-static void exynos4x12_set_clkdiv(unsigned int div_index)
+static void exynos4x12_set_clkdiv(struct exynos_dvfs_info *cpufreq,
+				  unsigned int div_index)
 {
 	unsigned int tmp;
 
@@ -125,7 +126,8 @@ static void exynos4x12_set_clkdiv(unsigned int div_index)
 	} while (tmp != 0x0);
 }
 
-static void exynos4x12_set_apll(unsigned int index)
+static void exynos4x12_set_apll(struct exynos_dvfs_info *cpufreq,
+				unsigned int index)
 {
 	unsigned int tmp, freq = apll_freq_4x12[index].freq;
 
@@ -151,15 +153,16 @@ static void exynos4x12_set_apll(unsigned int index)
 	} while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT));
 }
 
-static void exynos4x12_set_frequency(unsigned int old_index,
-				  unsigned int new_index)
+static void exynos4x12_set_frequency(struct exynos_dvfs_info *cpufreq,
+				     unsigned int old_index,
+				     unsigned int new_index)
 {
 	if (old_index > new_index) {
-		exynos4x12_set_clkdiv(new_index);
-		exynos4x12_set_apll(new_index);
+		exynos4x12_set_clkdiv(cpufreq, new_index);
+		exynos4x12_set_apll(cpufreq, new_index);
 	} else if (old_index < new_index) {
-		exynos4x12_set_apll(new_index);
-		exynos4x12_set_clkdiv(new_index);
+		exynos4x12_set_apll(cpufreq, new_index);
+		exynos4x12_set_clkdiv(cpufreq, new_index);
 	}
 }
 
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index d3ce829..191a511 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -80,7 +80,8 @@ static struct apll_freq apll_freq_5250[] = {
 	APLL_FREQ(200,  0, 1, 7, 7, 1, 1, 1, 0, 0, 2, 0, 100, 3, 2),
 };
 
-static void set_clkdiv(unsigned int div_index)
+static void set_clkdiv(struct exynos_dvfs_info *cpufreq,
+		       unsigned int div_index)
 {
 	unsigned int tmp;
 
@@ -103,7 +104,8 @@ static void set_clkdiv(unsigned int div_index)
 		cpu_relax();
 }
 
-static void set_apll(unsigned int index)
+static void set_apll(struct exynos_dvfs_info *cpufreq,
+		     unsigned int index)
 {
 	unsigned int tmp;
 	unsigned int freq = apll_freq_5250[index].freq;
@@ -130,15 +132,16 @@ static void set_apll(unsigned int index)
 	} while (tmp != (0x1 << 16));
 }
 
-static void exynos5250_set_frequency(unsigned int old_index,
-				  unsigned int new_index)
+static void exynos5250_set_frequency(struct exynos_dvfs_info *exynos_info,
+				     unsigned int old_index,
+				     unsigned int new_index)
 {
 	if (old_index > new_index) {
-		set_clkdiv(new_index);
-		set_apll(new_index);
+		set_clkdiv(exynos_info, new_index);
+		set_apll(exynos_info, new_index);
 	} else if (old_index < new_index) {
-		set_apll(new_index);
-		set_clkdiv(new_index);
+		set_apll(exynos_info, new_index);
+		set_clkdiv(exynos_info, new_index);
 	}
 }
 
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 11/14] cpufreq: exynos4210: remove unused symbol cpufreq
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

Now that the set_freq call back receives the intended
data struct, the global cpufreq variable may be removed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4210-cpufreq.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 00889a4..6757bda 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -25,7 +25,6 @@ static struct clk *cpu_clk;
 static struct clk *moutcore;
 static struct clk *mout_mpll;
 static struct clk *mout_apll;
-static struct exynos_dvfs_info *cpufreq;
 
 static unsigned int exynos4210_volt_table[] = {
 	1250000, 1150000, 1050000, 975000, 950000,
@@ -171,7 +170,6 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
 	info->freq_table = exynos4210_freq_table;
 	info->set_freq = exynos4210_set_frequency;
 
-	cpufreq = info;
 	of_node_put(np);
 
 	return 0;
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 11/14] cpufreq: exynos4210: remove unused symbol cpufreq
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

Now that the set_freq call back receives the intended
data struct, the global cpufreq variable may be removed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4210-cpufreq.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 00889a4..6757bda 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -25,7 +25,6 @@ static struct clk *cpu_clk;
 static struct clk *moutcore;
 static struct clk *mout_mpll;
 static struct clk *mout_apll;
-static struct exynos_dvfs_info *cpufreq;
 
 static unsigned int exynos4210_volt_table[] = {
 	1250000, 1150000, 1050000, 975000, 950000,
@@ -171,7 +170,6 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
 	info->freq_table = exynos4210_freq_table;
 	info->set_freq = exynos4210_set_frequency;
 
-	cpufreq = info;
 	of_node_put(np);
 
 	return 0;
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 12/14] cpufreq: exynos4x12: remove unused symbol cpufreq
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
                   ` (10 preceding siblings ...)
  2015-02-02 20:58   ` Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar; +Cc: Eduardo Valentin

Now that the set_freq call back receives the intended
data struct, the global cpufreq variable may be removed.

Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos4x12-cpufreq.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index d12087b..5ea5dad 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -25,7 +25,6 @@ static struct clk *cpu_clk;
 static struct clk *moutcore;
 static struct clk *mout_mpll;
 static struct clk *mout_apll;
-static struct exynos_dvfs_info *cpufreq;
 
 static unsigned int exynos4x12_volt_table[] = {
 	1350000, 1287500, 1250000, 1187500, 1137500, 1087500, 1037500,
@@ -223,7 +222,6 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 	info->freq_table = exynos4x12_freq_table;
 	info->set_freq = exynos4x12_set_frequency;
 
-	cpufreq = info;
 	of_node_put(np);
 
 	return 0;
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 13/14] cpufreq: exynos5250: remove unused symbol cpufreq
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

Now that the set_freq call back receives the intended
data struct, the global cpufreq variable may be removed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos5250-cpufreq.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index 191a511..ee274c9 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -25,7 +25,6 @@ static struct clk *cpu_clk;
 static struct clk *moutcore;
 static struct clk *mout_mpll;
 static struct clk *mout_apll;
-static struct exynos_dvfs_info *cpufreq;
 
 static unsigned int exynos5250_volt_table[] = {
 	1300000, 1250000, 1225000, 1200000, 1150000,
@@ -197,7 +196,6 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
 	info->freq_table = exynos5250_freq_table;
 	info->set_freq = exynos5250_set_frequency;
 
-	cpufreq = info;
 	of_node_put(np);
 
 	return 0;
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 13/14] cpufreq: exynos5250: remove unused symbol cpufreq
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

Now that the set_freq call back receives the intended
data struct, the global cpufreq variable may be removed.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos5250-cpufreq.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index 191a511..ee274c9 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -25,7 +25,6 @@ static struct clk *cpu_clk;
 static struct clk *moutcore;
 static struct clk *mout_mpll;
 static struct clk *mout_apll;
-static struct exynos_dvfs_info *cpufreq;
 
 static unsigned int exynos5250_volt_table[] = {
 	1300000, 1250000, 1225000, 1200000, 1150000,
@@ -197,7 +196,6 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
 	info->freq_table = exynos5250_freq_table;
 	info->set_freq = exynos5250_set_frequency;
 
-	cpufreq = info;
 	of_node_put(np);
 
 	return 0;
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 14/14] cpufreq: exynos-cpufreq: release resources by using managed allocation
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
@ 2015-02-02 20:58   ` Eduardo Valentin
  2015-02-02 20:58   ` Eduardo Valentin
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: Linux PM, Viresh Kumar
  Cc: Eduardo Valentin, Rafael J. Wysocki, Kukjin Kim,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

This change allows the proper resource release used by this driver.
The resources are now allocated using managed allocation by means
of the devm_* helper functions. Those resources that cannot be managed
are properly released during the device removal time.

The global variables have been removed as well. All static variables
were moved to driver data and properly assigned to cpufreq
driver data. In callbacks, now the data structure allocated
in probe time is fetched from cpufreq policy.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos-cpufreq.c | 99 +++++++++++++++++++++++++---------------
 drivers/cpufreq/exynos-cpufreq.h |  5 ++
 2 files changed, 67 insertions(+), 37 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index a964602..f1a13e8 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -23,12 +23,8 @@
 
 #include "exynos-cpufreq.h"
 
-static struct exynos_dvfs_info *exynos_info;
-static struct thermal_cooling_device *cdev;
-static struct regulator *arm_regulator;
-static unsigned int locking_frequency;
-
-static int exynos_cpufreq_get_index(unsigned int freq)
+static int exynos_cpufreq_get_index(struct exynos_dvfs_info *exynos_info,
+				    unsigned int freq)
 {
 	struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
 	struct cpufreq_frequency_table *pos;
@@ -43,7 +39,8 @@ static int exynos_cpufreq_get_index(unsigned int freq)
 	return pos - freq_table;
 }
 
-static int exynos_cpufreq_scale(unsigned int target_freq)
+static int exynos_cpufreq_scale(struct exynos_dvfs_info *exynos_info,
+				unsigned int target_freq)
 {
 	struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
 	unsigned int *volt_table = exynos_info->volt_table;
@@ -62,13 +59,13 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 	 * old_index with cpufreq_frequency_table_target(). Thus, ignore
 	 * policy and get the index from the raw frequency table.
 	 */
-	old_index = exynos_cpufreq_get_index(old_freq);
+	old_index = exynos_cpufreq_get_index(exynos_info, old_freq);
 	if (old_index < 0) {
 		ret = old_index;
 		goto out;
 	}
 
-	index = exynos_cpufreq_get_index(target_freq);
+	index = exynos_cpufreq_get_index(exynos_info, target_freq);
 	if (index < 0) {
 		ret = index;
 		goto out;
@@ -90,7 +87,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 	/* When the new frequency is higher than current frequency */
 	if ((target_freq > old_freq) && !safe_arm_volt) {
 		/* Firstly, voltage up to increase frequency */
-		ret = regulator_set_voltage(arm_regulator, arm_volt, arm_volt);
+		ret = regulator_set_voltage(exynos_info->arm_regulator,
+					    arm_volt, arm_volt);
 		if (ret) {
 			dev_err(dev, "failed to set cpu voltage to %d\n",
 				arm_volt);
@@ -99,8 +97,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 	}
 
 	if (safe_arm_volt) {
-		ret = regulator_set_voltage(arm_regulator, safe_arm_volt,
-				      safe_arm_volt);
+		ret = regulator_set_voltage(exynos_info->arm_regulator,
+					    safe_arm_volt, safe_arm_volt);
 		if (ret) {
 			dev_err(dev, "failed to set cpu voltage to %d\n",
 				safe_arm_volt);
@@ -114,8 +112,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 	if ((target_freq < old_freq) ||
 	   ((target_freq > old_freq) && safe_arm_volt)) {
 		/* down the voltage after frequency change */
-		ret = regulator_set_voltage(arm_regulator, arm_volt,
-				arm_volt);
+		ret = regulator_set_voltage(exynos_info->arm_regulator,
+					    arm_volt, arm_volt);
 		if (ret) {
 			dev_err(dev, "failed to set cpu voltage to %d\n",
 				arm_volt);
@@ -131,22 +129,39 @@ out:
 
 static int exynos_target(struct cpufreq_policy *policy, unsigned int index)
 {
-	return exynos_cpufreq_scale(exynos_info->freq_table[index].frequency);
+	struct exynos_dvfs_info *exynos_info = policy->driver_data;
+
+	return exynos_cpufreq_scale(exynos_info,
+				    exynos_info->freq_table[index].frequency);
 }
 
 static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
 {
+	struct exynos_dvfs_info *exynos_info = policy->driver_data;
+
 	policy->clk = exynos_info->cpu_clk;
-	policy->suspend_freq = locking_frequency;
+	policy->suspend_freq = exynos_info->locking_frequency;
 	return cpufreq_generic_init(policy, exynos_info->freq_table, 100000);
 }
 
+static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
+{
+	struct exynos_dvfs_info *info = policy->driver_data;
+
+	if (info->cdev)
+		cpufreq_cooling_unregister(info->cdev);
+	dev_pm_opp_free_cpufreq_table(info->dev, &policy->freq_table);
+	iounmap(info->cmu_regs);
+
+	return 0;
+}
 static struct cpufreq_driver exynos_driver = {
 	.flags		= CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
 	.verify		= cpufreq_generic_frequency_table_verify,
 	.target_index	= exynos_target,
 	.get		= cpufreq_generic_get,
 	.init		= exynos_cpufreq_cpu_init,
+	.exit		= exynos_cpufreq_cpu_exit,
 	.name		= "exynos_cpufreq",
 	.attr		= cpufreq_generic_attr,
 #ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
@@ -159,10 +174,12 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct exynos_dvfs_info *exynos_info;
 	struct device_node *cpus, *np;
 	int ret = -EINVAL;
 
-	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
+	exynos_info = devm_kzalloc(&pdev->dev, sizeof(*exynos_info),
+				   GFP_KERNEL);
 	if (!exynos_info)
 		return -ENOMEM;
 
@@ -186,57 +203,64 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	}
 
 	if (ret)
-		goto err_vdd_arm;
+		return -EINVAL;
 
 	if (exynos_info->set_freq == NULL) {
 		dev_err(&pdev->dev, "No set_freq function (ERR)\n");
-		goto err_vdd_arm;
+		return -EINVAL;
 	}
 
-	arm_regulator = regulator_get(NULL, "vdd_arm");
-	if (IS_ERR(arm_regulator)) {
+	exynos_info->arm_regulator = devm_regulator_get(exynos_info->dev,
+							"vdd_arm");
+	if (IS_ERR(exynos_info->arm_regulator)) {
 		dev_err(&pdev->dev, "failed to get resource vdd_arm\n");
-		goto err_vdd_arm;
+		return -EINVAL;
 	}
 
 	/* Done here as we want to capture boot frequency */
-	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
+	exynos_info->locking_frequency = clk_get_rate(exynos_info->cpu_clk) /
+					1000;
+
+	exynos_driver.driver_data = exynos_info;
 
 	ret = cpufreq_register_driver(&exynos_driver);
-	if (ret)
-		goto err_cpufreq_reg;
+	if (ret) {
+		dev_err(&pdev->dev, "failed to register cpufreq driver\n");
+		return -EINVAL;
+	}
 
 	cpus = of_find_node_by_path("/cpus");
 	if (!cpus) {
 		pr_err("failed to find cpus node\n");
-		return 0;
+		return -EINVAL;
 	}
 
 	np = of_get_next_child(cpus, NULL);
 	if (!np) {
 		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
+		goto of_exit;
 	}
 
 	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+		exynos_info->cdev = of_cpufreq_cooling_register(np,
 						   cpu_present_mask);
-		if (IS_ERR(cdev))
+		if (IS_ERR(exynos_info->cdev))
 			pr_err("running cpufreq without cooling device: %ld\n",
-			       PTR_ERR(cdev));
+			       PTR_ERR(exynos_info->cdev));
 	}
+
+of_exit:
 	of_node_put(np);
 	of_node_put(cpus);
 
 	return 0;
+}
 
-err_cpufreq_reg:
-	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
-	regulator_put(arm_regulator);
-err_vdd_arm:
-	kfree(exynos_info);
-	return -EINVAL;
+static int exynos_cpufreq_remove(struct platform_device *pdev)
+{
+	cpufreq_unregister_driver(&exynos_driver);
+
+	return 0;
 }
 
 static struct platform_driver exynos_cpufreq_platdrv = {
@@ -244,5 +268,6 @@ static struct platform_driver exynos_cpufreq_platdrv = {
 		.name	= "exynos-cpufreq",
 	},
 	.probe = exynos_cpufreq_probe,
+	.remove = exynos_cpufreq_remove,
 };
 module_platform_driver(exynos_cpufreq_platdrv);
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h
index b59558e..ac31d5d 100644
--- a/drivers/cpufreq/exynos-cpufreq.h
+++ b/drivers/cpufreq/exynos-cpufreq.h
@@ -9,6 +9,8 @@
  * published by the Free Software Foundation.
 */
 
+#include <linux/thermal.h>
+
 enum cpufreq_level_index {
 	L0, L1, L2, L3, L4,
 	L5, L6, L7, L8, L9,
@@ -51,6 +53,9 @@ struct exynos_dvfs_info {
 	void (*set_freq)(struct exynos_dvfs_info *, unsigned int, unsigned int);
 	bool (*need_apll_change)(unsigned int, unsigned int);
 	void __iomem	*cmu_regs;
+	struct thermal_cooling_device *cdev;
+	struct regulator *arm_regulator;
+	unsigned int locking_frequency;
 };
 
 #ifdef CONFIG_ARM_EXYNOS4210_CPUFREQ
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 14/14] cpufreq: exynos-cpufreq: release resources by using managed allocation
@ 2015-02-02 20:58   ` Eduardo Valentin
  0 siblings, 0 replies; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

This change allows the proper resource release used by this driver.
The resources are now allocated using managed allocation by means
of the devm_* helper functions. Those resources that cannot be managed
are properly released during the device removal time.

The global variables have been removed as well. All static variables
were moved to driver data and properly assigned to cpufreq
driver data. In callbacks, now the data structure allocated
in probe time is fetched from cpufreq policy.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/cpufreq/exynos-cpufreq.c | 99 +++++++++++++++++++++++++---------------
 drivers/cpufreq/exynos-cpufreq.h |  5 ++
 2 files changed, 67 insertions(+), 37 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index a964602..f1a13e8 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -23,12 +23,8 @@
 
 #include "exynos-cpufreq.h"
 
-static struct exynos_dvfs_info *exynos_info;
-static struct thermal_cooling_device *cdev;
-static struct regulator *arm_regulator;
-static unsigned int locking_frequency;
-
-static int exynos_cpufreq_get_index(unsigned int freq)
+static int exynos_cpufreq_get_index(struct exynos_dvfs_info *exynos_info,
+				    unsigned int freq)
 {
 	struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
 	struct cpufreq_frequency_table *pos;
@@ -43,7 +39,8 @@ static int exynos_cpufreq_get_index(unsigned int freq)
 	return pos - freq_table;
 }
 
-static int exynos_cpufreq_scale(unsigned int target_freq)
+static int exynos_cpufreq_scale(struct exynos_dvfs_info *exynos_info,
+				unsigned int target_freq)
 {
 	struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
 	unsigned int *volt_table = exynos_info->volt_table;
@@ -62,13 +59,13 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 	 * old_index with cpufreq_frequency_table_target(). Thus, ignore
 	 * policy and get the index from the raw frequency table.
 	 */
-	old_index = exynos_cpufreq_get_index(old_freq);
+	old_index = exynos_cpufreq_get_index(exynos_info, old_freq);
 	if (old_index < 0) {
 		ret = old_index;
 		goto out;
 	}
 
-	index = exynos_cpufreq_get_index(target_freq);
+	index = exynos_cpufreq_get_index(exynos_info, target_freq);
 	if (index < 0) {
 		ret = index;
 		goto out;
@@ -90,7 +87,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 	/* When the new frequency is higher than current frequency */
 	if ((target_freq > old_freq) && !safe_arm_volt) {
 		/* Firstly, voltage up to increase frequency */
-		ret = regulator_set_voltage(arm_regulator, arm_volt, arm_volt);
+		ret = regulator_set_voltage(exynos_info->arm_regulator,
+					    arm_volt, arm_volt);
 		if (ret) {
 			dev_err(dev, "failed to set cpu voltage to %d\n",
 				arm_volt);
@@ -99,8 +97,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 	}
 
 	if (safe_arm_volt) {
-		ret = regulator_set_voltage(arm_regulator, safe_arm_volt,
-				      safe_arm_volt);
+		ret = regulator_set_voltage(exynos_info->arm_regulator,
+					    safe_arm_volt, safe_arm_volt);
 		if (ret) {
 			dev_err(dev, "failed to set cpu voltage to %d\n",
 				safe_arm_volt);
@@ -114,8 +112,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 	if ((target_freq < old_freq) ||
 	   ((target_freq > old_freq) && safe_arm_volt)) {
 		/* down the voltage after frequency change */
-		ret = regulator_set_voltage(arm_regulator, arm_volt,
-				arm_volt);
+		ret = regulator_set_voltage(exynos_info->arm_regulator,
+					    arm_volt, arm_volt);
 		if (ret) {
 			dev_err(dev, "failed to set cpu voltage to %d\n",
 				arm_volt);
@@ -131,22 +129,39 @@ out:
 
 static int exynos_target(struct cpufreq_policy *policy, unsigned int index)
 {
-	return exynos_cpufreq_scale(exynos_info->freq_table[index].frequency);
+	struct exynos_dvfs_info *exynos_info = policy->driver_data;
+
+	return exynos_cpufreq_scale(exynos_info,
+				    exynos_info->freq_table[index].frequency);
 }
 
 static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
 {
+	struct exynos_dvfs_info *exynos_info = policy->driver_data;
+
 	policy->clk = exynos_info->cpu_clk;
-	policy->suspend_freq = locking_frequency;
+	policy->suspend_freq = exynos_info->locking_frequency;
 	return cpufreq_generic_init(policy, exynos_info->freq_table, 100000);
 }
 
+static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
+{
+	struct exynos_dvfs_info *info = policy->driver_data;
+
+	if (info->cdev)
+		cpufreq_cooling_unregister(info->cdev);
+	dev_pm_opp_free_cpufreq_table(info->dev, &policy->freq_table);
+	iounmap(info->cmu_regs);
+
+	return 0;
+}
 static struct cpufreq_driver exynos_driver = {
 	.flags		= CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
 	.verify		= cpufreq_generic_frequency_table_verify,
 	.target_index	= exynos_target,
 	.get		= cpufreq_generic_get,
 	.init		= exynos_cpufreq_cpu_init,
+	.exit		= exynos_cpufreq_cpu_exit,
 	.name		= "exynos_cpufreq",
 	.attr		= cpufreq_generic_attr,
 #ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
@@ -159,10 +174,12 @@ static struct cpufreq_driver exynos_driver = {
 
 static int exynos_cpufreq_probe(struct platform_device *pdev)
 {
+	struct exynos_dvfs_info *exynos_info;
 	struct device_node *cpus, *np;
 	int ret = -EINVAL;
 
-	exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
+	exynos_info = devm_kzalloc(&pdev->dev, sizeof(*exynos_info),
+				   GFP_KERNEL);
 	if (!exynos_info)
 		return -ENOMEM;
 
@@ -186,57 +203,64 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	}
 
 	if (ret)
-		goto err_vdd_arm;
+		return -EINVAL;
 
 	if (exynos_info->set_freq == NULL) {
 		dev_err(&pdev->dev, "No set_freq function (ERR)\n");
-		goto err_vdd_arm;
+		return -EINVAL;
 	}
 
-	arm_regulator = regulator_get(NULL, "vdd_arm");
-	if (IS_ERR(arm_regulator)) {
+	exynos_info->arm_regulator = devm_regulator_get(exynos_info->dev,
+							"vdd_arm");
+	if (IS_ERR(exynos_info->arm_regulator)) {
 		dev_err(&pdev->dev, "failed to get resource vdd_arm\n");
-		goto err_vdd_arm;
+		return -EINVAL;
 	}
 
 	/* Done here as we want to capture boot frequency */
-	locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
+	exynos_info->locking_frequency = clk_get_rate(exynos_info->cpu_clk) /
+					1000;
+
+	exynos_driver.driver_data = exynos_info;
 
 	ret = cpufreq_register_driver(&exynos_driver);
-	if (ret)
-		goto err_cpufreq_reg;
+	if (ret) {
+		dev_err(&pdev->dev, "failed to register cpufreq driver\n");
+		return -EINVAL;
+	}
 
 	cpus = of_find_node_by_path("/cpus");
 	if (!cpus) {
 		pr_err("failed to find cpus node\n");
-		return 0;
+		return -EINVAL;
 	}
 
 	np = of_get_next_child(cpus, NULL);
 	if (!np) {
 		pr_err("failed to find cpus child node\n");
-		of_node_put(cpus);
-		return 0;
+		goto of_exit;
 	}
 
 	if (of_find_property(np, "#cooling-cells", NULL)) {
-		cdev = of_cpufreq_cooling_register(np,
+		exynos_info->cdev = of_cpufreq_cooling_register(np,
 						   cpu_present_mask);
-		if (IS_ERR(cdev))
+		if (IS_ERR(exynos_info->cdev))
 			pr_err("running cpufreq without cooling device: %ld\n",
-			       PTR_ERR(cdev));
+			       PTR_ERR(exynos_info->cdev));
 	}
+
+of_exit:
 	of_node_put(np);
 	of_node_put(cpus);
 
 	return 0;
+}
 
-err_cpufreq_reg:
-	dev_err(&pdev->dev, "failed to register cpufreq driver\n");
-	regulator_put(arm_regulator);
-err_vdd_arm:
-	kfree(exynos_info);
-	return -EINVAL;
+static int exynos_cpufreq_remove(struct platform_device *pdev)
+{
+	cpufreq_unregister_driver(&exynos_driver);
+
+	return 0;
 }
 
 static struct platform_driver exynos_cpufreq_platdrv = {
@@ -244,5 +268,6 @@ static struct platform_driver exynos_cpufreq_platdrv = {
 		.name	= "exynos-cpufreq",
 	},
 	.probe = exynos_cpufreq_probe,
+	.remove = exynos_cpufreq_remove,
 };
 module_platform_driver(exynos_cpufreq_platdrv);
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h
index b59558e..ac31d5d 100644
--- a/drivers/cpufreq/exynos-cpufreq.h
+++ b/drivers/cpufreq/exynos-cpufreq.h
@@ -9,6 +9,8 @@
  * published by the Free Software Foundation.
 */
 
+#include <linux/thermal.h>
+
 enum cpufreq_level_index {
 	L0, L1, L2, L3, L4,
 	L5, L6, L7, L8, L9,
@@ -51,6 +53,9 @@ struct exynos_dvfs_info {
 	void (*set_freq)(struct exynos_dvfs_info *, unsigned int, unsigned int);
 	bool (*need_apll_change)(unsigned int, unsigned int);
 	void __iomem	*cmu_regs;
+	struct thermal_cooling_device *cdev;
+	struct regulator *arm_regulator;
+	unsigned int locking_frequency;
 };
 
 #ifdef CONFIG_ARM_EXYNOS4210_CPUFREQ
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/14] cpufreq: resource management in preparation for module build
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
                   ` (13 preceding siblings ...)
  2015-02-02 20:58   ` Eduardo Valentin
@ 2015-02-02 22:54 ` Rafael J. Wysocki
  2015-02-03  4:05 ` Viresh Kumar
  2015-02-04  8:52 ` Lukasz Majewski
  16 siblings, 0 replies; 33+ messages in thread
From: Rafael J. Wysocki @ 2015-02-02 22:54 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Linux PM, Viresh Kumar

On Monday, February 02, 2015 04:58:03 PM Eduardo Valentin wrote:
> Dear all,
> 
> The exynos cpufreq driver needs to be build as module. The need is to fix
> the problem risen by Arnd due to the added OF thermal dependency [1].
> 
> Therefore, this series, in preparation to allow building this driver as
> a module, changes the way this driver handles allocated resources. Now
> it is expected to free the allocated resources uppon driver exit.
> 
> A couple of changes in the data structure organization and callbacks were necessary.
> Therefore, changes were added accordingly.
> 
> Please review. I do not have a way to test these patch in a board today though. So, testing
> is more than welcome :-).
> 
> [1] - https://lkml.org/lkml/2015/1/31/175
> 
> Cheers,
> 
> Eduardo Valentin (14):
>   cpufreq: exynos4210: properly put of node
>   cpufreq: exynos4210: iounmap in error path
>   cpufreq: exynos4210: use devm_clk_get
>   cpufreq: exynos4x12: properly put of node
>   cpufreq: exynos4x12: iounmap in error path
>   cpufreq: exynos4x12: use devm_clk_get
>   cpufreq: exynos5250: properly put of node
>   cpufreq: exynos5250: iounmap in error path
>   cpufreq: exynos5250: use devm_clk_get
>   cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback
>   cpufreq: exynos4210: remove unused symbol cpufreq
>   cpufreq: exynos4x12: remove unused symbol cpufreq
>   cpufreq: exynos5250: remove unused symbol cpufreq
>   cpufreq: exynos-cpufreq: release resources by using managed allocation
> 
>  drivers/cpufreq/exynos-cpufreq.c     | 101 ++++++++++++++++++++++-------------
>  drivers/cpufreq/exynos-cpufreq.h     |   7 ++-
>  drivers/cpufreq/exynos4210-cpufreq.c |  47 ++++++++--------
>  drivers/cpufreq/exynos4x12-cpufreq.c |  49 +++++++++--------
>  drivers/cpufreq/exynos5250-cpufreq.c |  49 +++++++++--------
>  5 files changed, 140 insertions(+), 113 deletions(-)

Since this only seems to touch the Exynos files, I'm leaving the cpufreq part
of it to Viresh.

Eventually, it should go it through the Samsung tree anyway.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/14] cpufreq: resource management in preparation for module build
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
                   ` (14 preceding siblings ...)
  2015-02-02 22:54 ` [PATCH 00/14] cpufreq: resource management in preparation for module build Rafael J. Wysocki
@ 2015-02-03  4:05 ` Viresh Kumar
  2015-02-03 19:31   ` Eduardo Valentin
  2015-02-04  8:52 ` Lukasz Majewski
  16 siblings, 1 reply; 33+ messages in thread
From: Viresh Kumar @ 2015-02-03  4:05 UTC (permalink / raw)
  To: Eduardo Valentin, Kukjin Kim; +Cc: Linux PM

On 3 February 2015 at 02:28, Eduardo Valentin <edubezval@gmail.com> wrote:
> Dear all,
>
> The exynos cpufreq driver needs to be build as module. The need is to fix
> the problem risen by Arnd due to the added OF thermal dependency [1].
>
> Therefore, this series, in preparation to allow building this driver as
> a module, changes the way this driver handles allocated resources. Now
> it is expected to free the allocated resources uppon driver exit.
>
> A couple of changes in the data structure organization and callbacks were necessary.
> Therefore, changes were added accordingly.
>
> Please review. I do not have a way to test these patch in a board today though. So, testing
> is more than welcome :-).
>
> [1] - https://lkml.org/lkml/2015/1/31/175
>
> Cheers,
>
> Eduardo Valentin (14):
>   cpufreq: exynos4210: properly put of node
>   cpufreq: exynos4210: iounmap in error path
>   cpufreq: exynos4210: use devm_clk_get
>   cpufreq: exynos4x12: properly put of node
>   cpufreq: exynos4x12: iounmap in error path
>   cpufreq: exynos4x12: use devm_clk_get
>   cpufreq: exynos5250: properly put of node
>   cpufreq: exynos5250: iounmap in error path
>   cpufreq: exynos5250: use devm_clk_get
>   cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback
>   cpufreq: exynos4210: remove unused symbol cpufreq
>   cpufreq: exynos4x12: remove unused symbol cpufreq
>   cpufreq: exynos5250: remove unused symbol cpufreq
>   cpufreq: exynos-cpufreq: release resources by using managed allocation

Some of this might be unnecessary ..
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/304984.html

And please cc samsung maintainers next time ..

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/14] cpufreq: resource management in preparation for module build
  2015-02-03  4:05 ` Viresh Kumar
@ 2015-02-03 19:31   ` Eduardo Valentin
  2015-02-04  4:58     ` Viresh Kumar
  0 siblings, 1 reply; 33+ messages in thread
From: Eduardo Valentin @ 2015-02-03 19:31 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: Kukjin Kim, Linux PM

[-- Attachment #1: Type: text/plain, Size: 2403 bytes --]

On Tue, Feb 03, 2015 at 09:35:01AM +0530, Viresh Kumar wrote:
> On 3 February 2015 at 02:28, Eduardo Valentin <edubezval@gmail.com> wrote:
> > Dear all,
> >
> > The exynos cpufreq driver needs to be build as module. The need is to fix
> > the problem risen by Arnd due to the added OF thermal dependency [1].
> >
> > Therefore, this series, in preparation to allow building this driver as
> > a module, changes the way this driver handles allocated resources. Now
> > it is expected to free the allocated resources uppon driver exit.
> >
> > A couple of changes in the data structure organization and callbacks were necessary.
> > Therefore, changes were added accordingly.
> >
> > Please review. I do not have a way to test these patch in a board today though. So, testing
> > is more than welcome :-).
> >
> > [1] - https://lkml.org/lkml/2015/1/31/175
> >
> > Cheers,
> >
> > Eduardo Valentin (14):
> >   cpufreq: exynos4210: properly put of node
> >   cpufreq: exynos4210: iounmap in error path
> >   cpufreq: exynos4210: use devm_clk_get
> >   cpufreq: exynos4x12: properly put of node
> >   cpufreq: exynos4x12: iounmap in error path
> >   cpufreq: exynos4x12: use devm_clk_get
> >   cpufreq: exynos5250: properly put of node
> >   cpufreq: exynos5250: iounmap in error path
> >   cpufreq: exynos5250: use devm_clk_get
> >   cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback
> >   cpufreq: exynos4210: remove unused symbol cpufreq
> >   cpufreq: exynos4x12: remove unused symbol cpufreq
> >   cpufreq: exynos5250: remove unused symbol cpufreq
> >   cpufreq: exynos-cpufreq: release resources by using managed allocation
> 
> Some of this might be unnecessary ..
> http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/304984.html

OK. Pick what makes sense. 


> 
> And please cc samsung maintainers next time ..

Sure. The patches were all copied to what get_maintainers.pl told me.
I missed them in Patch 0 though.

I would appreciate if we can fix this issue so that I can send out the
thermal changes in exynos code without breaking things apart.

What would be the best way to proceed here? Would you be picking the
rework in exynos cpufreq code and then the cleanups to make to make
possible to build it as a module? Or should this go together with the
thermal changes?

Cheers,

Eduardo Valentin


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/14] cpufreq: resource management in preparation for module build
  2015-02-03 19:31   ` Eduardo Valentin
@ 2015-02-04  4:58     ` Viresh Kumar
  0 siblings, 0 replies; 33+ messages in thread
From: Viresh Kumar @ 2015-02-04  4:58 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Kukjin Kim, Linux PM

On 4 February 2015 at 01:01, Eduardo Valentin <edubezval@gmail.com> wrote:
> OK. Pick what makes sense.

Because most of your patches are touching files already removed, it
requires a resend of these.

>> And please cc samsung maintainers next time ..
>
> Sure. The patches were all copied to what get_maintainers.pl told me.
> I missed them in Patch 0 though.
>
> I would appreciate if we can fix this issue so that I can send out the
> thermal changes in exynos code without breaking things apart.
>
> What would be the best way to proceed here? Would you be picking the
> rework in exynos cpufreq code and then the cleanups to make to make
> possible to build it as a module? Or should this go together with the
> thermal changes?

I think the thermal changes can go without your patches. If module removal
breaks, it would only break for exynos and nobody was using it until now
that way.

Over that, Kukjin needs to confirm what's going on with the other thread.
Why isn't that pushed to mainline yet ?

--
viresh

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/14] cpufreq: resource management in preparation for module build
  2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
                   ` (15 preceding siblings ...)
  2015-02-03  4:05 ` Viresh Kumar
@ 2015-02-04  8:52 ` Lukasz Majewski
  2015-02-04  9:56   ` Viresh Kumar
  16 siblings, 1 reply; 33+ messages in thread
From: Lukasz Majewski @ 2015-02-04  8:52 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Viresh Kumar, Linux PM

Hi Eduardo,

> Dear all,
> 
> The exynos cpufreq driver needs to be build as module. 

I might be wrong, but as fair as I remember there was a discussion
(when BOOST was developed) about having CPUfreq build as a module.

And the answer then was that it is not feasible to have cpufreq
compiled as a module, because it is an integral part of the platform.

After regarding [1]:

I can imagine that in "real life" (not caused by build allmodconf error)
we might want to insert cpufreq module (including core and e.g.
Exynos4412 specific callbacks) after booting the board.

However, it seems hard to predict problems which emerge when we would
like to remove cpufreq support (especially data in exynos4x12-cpufreq.c
- responsible for setting APLL/MPLL) after some time. 

And one more thought - why (as of 3.19.0-rc5) there is no tri state on
CONFIG_CPU_FREQ? Is there any ongoing work to provide this?


> The need is to
> fix the problem risen by Arnd due to the added OF thermal dependency
> [1].
> 
> Therefore, this series, in preparation to allow building this driver
> as a module, changes the way this driver handles allocated resources.
> Now it is expected to free the allocated resources uppon driver exit.
> 
> A couple of changes in the data structure organization and callbacks
> were necessary. Therefore, changes were added accordingly.
> 
> Please review. I do not have a way to test these patch in a board
> today though. So, testing is more than welcome :-).
> 
> [1] - https://lkml.org/lkml/2015/1/31/175
> 
> Cheers,
> 
> Eduardo Valentin (14):
>   cpufreq: exynos4210: properly put of node
>   cpufreq: exynos4210: iounmap in error path
>   cpufreq: exynos4210: use devm_clk_get
>   cpufreq: exynos4x12: properly put of node
>   cpufreq: exynos4x12: iounmap in error path
>   cpufreq: exynos4x12: use devm_clk_get
>   cpufreq: exynos5250: properly put of node
>   cpufreq: exynos5250: iounmap in error path
>   cpufreq: exynos5250: use devm_clk_get
>   cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback
	     ^^^^^^ exynos

>   cpufreq: exynos4210: remove unused symbol cpufreq
>   cpufreq: exynos4x12: remove unused symbol cpufreq
>   cpufreq: exynos5250: remove unused symbol cpufreq
>   cpufreq: exynos-cpufreq: release resources by using managed
> allocation
> 
>  drivers/cpufreq/exynos-cpufreq.c     | 101
> ++++++++++++++++++++++-------------
> drivers/cpufreq/exynos-cpufreq.h     |   7 ++-
> drivers/cpufreq/exynos4210-cpufreq.c |  47 ++++++++--------
> drivers/cpufreq/exynos4x12-cpufreq.c |  49 +++++++++--------
> drivers/cpufreq/exynos5250-cpufreq.c |  49 +++++++++-------- 5 files
> changed, 140 insertions(+), 113 deletions(-)
> 

Eduardo, could you provide the exact information about the branch (and
any prerequisite patches) on which shall I apply this work?

I'm able to test it on Exynos 4210, 4x12 and 5250.

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/14] cpufreq: resource management in preparation for module build
  2015-02-04  8:52 ` Lukasz Majewski
@ 2015-02-04  9:56   ` Viresh Kumar
  0 siblings, 0 replies; 33+ messages in thread
From: Viresh Kumar @ 2015-02-04  9:56 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Eduardo Valentin, Linux PM

On 4 February 2015 at 14:22, Lukasz Majewski <l.majewski@samsung.com> wrote:
> And one more thought - why (as of 3.19.0-rc5) there is no tri state on
> CONFIG_CPU_FREQ? Is there any ongoing work to provide this?

There is no requirement for the framework to be compilable as module.

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2015-02-04  9:56 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02 20:58 [PATCH 00/14] cpufreq: resource management in preparation for module build Eduardo Valentin
2015-02-02 20:58 ` [PATCH 01/14] cpufreq: exynos4210: properly put of node Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 02/14] cpufreq: exynos4210: iounmap in error path Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 03/14] cpufreq: exynos4210: use devm_clk_get Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 04/14] cpufreq: exynos4x12: properly put of node Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 05/14] cpufreq: exynos4x12: iounmap in error path Eduardo Valentin
2015-02-02 20:58 ` [PATCH 06/14] cpufreq: exynos4x12: use devm_clk_get Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 07/14] cpufreq: exynos5250: properly put of node Eduardo Valentin
2015-02-02 20:58 ` [PATCH 08/14] cpufreq: exynos5250: iounmap in error path Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 09/14] cpufreq: exynos5250: use devm_clk_get Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 10/14] cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 11/14] cpufreq: exynos4210: remove unused symbol cpufreq Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 12/14] cpufreq: exynos4x12: " Eduardo Valentin
2015-02-02 20:58 ` [PATCH 13/14] cpufreq: exynos5250: " Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 14/14] cpufreq: exynos-cpufreq: release resources by using managed allocation Eduardo Valentin
2015-02-02 20:58   ` Eduardo Valentin
2015-02-02 22:54 ` [PATCH 00/14] cpufreq: resource management in preparation for module build Rafael J. Wysocki
2015-02-03  4:05 ` Viresh Kumar
2015-02-03 19:31   ` Eduardo Valentin
2015-02-04  4:58     ` Viresh Kumar
2015-02-04  8:52 ` Lukasz Majewski
2015-02-04  9:56   ` Viresh Kumar

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.