linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ARM: DAVINCI: cpuidle - cleanups
@ 2012-05-10  8:44 Daniel Lezcano
  2012-05-10  8:44 ` [PATCH 1/2] ARM: DAVINCI: cpuidle - remove useless state count initialization Daniel Lezcano
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Daniel Lezcano @ 2012-05-10  8:44 UTC (permalink / raw)
  To: nsekhar, khilman, lenb
  Cc: davinci-linux-open-source, linaro-dev, linux-pm, patches

These couple of patches use the new cpuidle core api to refactor
some part of the code. The first one removes the state count initialization
as it is done from the cpuidle core and the second one use the new
API and removes the ops.

The patchset is based on Lenb's tree on top of Robert Lee cpuidle consolidation
work.

I don't have this board, I was not able to test these patches.

Daniel Lezcano (2):
  ARM: DAVINCI: cpuidle - remove useless state count initialization
  ARM: DAVINCI: cpuidle - remove ops

 arch/arm/mach-davinci/cpuidle.c |   83 +++++++++++++--------------------------
 1 files changed, 27 insertions(+), 56 deletions(-)

-- 
1.7.5.4

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

* [PATCH 1/2] ARM: DAVINCI: cpuidle - remove useless state count initialization
  2012-05-10  8:44 [PATCH 0/2] ARM: DAVINCI: cpuidle - cleanups Daniel Lezcano
@ 2012-05-10  8:44 ` Daniel Lezcano
       [not found]   ` <1336639485-26955-2-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
       [not found] ` <1336639485-26955-1-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  2012-05-19  9:26 ` [PATCH 0/2] ARM: DAVINCI: cpuidle - cleanups Daniel Lezcano
  2 siblings, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2012-05-10  8:44 UTC (permalink / raw)
  To: nsekhar, khilman, lenb
  Cc: davinci-linux-open-source, linaro-dev, linux-pm, patches

The state count is initialized in the driver structure, the cpuidle
core uses it to initialize the device state count.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-davinci/cpuidle.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
index 9107691..f0f179c 100644
--- a/arch/arm/mach-davinci/cpuidle.c
+++ b/arch/arm/mach-davinci/cpuidle.c
@@ -128,8 +128,6 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev)
 		davinci_states[1].flags |= DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN;
 	cpuidle_set_statedata(&device->states_usage[1], &davinci_states[1]);
 
-	device->state_count = DAVINCI_CPUIDLE_MAX_STATES;
-
 	ret = cpuidle_register_driver(&davinci_idle_driver);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register driver\n");
-- 
1.7.5.4

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

* [PATCH 2/2] ARM: DAVINCI: cpuidle - remove ops
       [not found] ` <1336639485-26955-1-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2012-05-10  8:44   ` Daniel Lezcano
       [not found]     ` <1336639485-26955-3-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2012-05-10  8:44 UTC (permalink / raw)
  To: nsekhar-l0cyMroinI0, khilman-l0cyMroinI0,
	lenb-DgEjT+Ai2ygdnm+yROfE0A
  Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	linaro-dev-cunTk1MwBs8s++Sfvej+rw,
	linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	patches-QSEj5FYQhm4dnm+yROfE0A

This patch removes the ops usage because we have the index
passed as parameter to the idle function and we can determine
if we do WFI or memory retention.

The benefit of this cleanup is the removal of:
 * the ops
 * the statedata usage because we want to get rid of it in all the drivers
 * extra structure definition
 * extra functions definition
 * pointless macro definition BIT(0)

It also benefits the readability.

Signed-off-by: Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 arch/arm/mach-davinci/cpuidle.c |   81 +++++++++++++--------------------------
 1 files changed, 27 insertions(+), 54 deletions(-)

diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
index f0f179c..61f4e52 100644
--- a/arch/arm/mach-davinci/cpuidle.c
+++ b/arch/arm/mach-davinci/cpuidle.c
@@ -25,35 +25,46 @@
 
 #define DAVINCI_CPUIDLE_MAX_STATES	2
 
-struct davinci_ops {
-	void (*enter) (u32 flags);
-	void (*exit) (u32 flags);
-	u32 flags;
-};
+static bool ddr2_pwdn = false;
+
+static void __iomem *ddr2_reg_base;
+
+static void davinci_save_ddr_power(int enter, bool pdown)
+{
+	u32 val;
+
+	val = __raw_readl(ddr2_reg_base + DDR2_SDRCR_OFFSET);
+
+	if (enter) {
+		if (pdown)
+			val |= DDR2_SRPD_BIT;
+		else
+			val &= ~DDR2_SRPD_BIT;
+		val |= DDR2_LPMODEN_BIT;
+	} else {
+		val &= ~(DDR2_SRPD_BIT | DDR2_LPMODEN_BIT);
+	}
+
+	__raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET);
+}
 
 /* Actual code that puts the SoC in different idle states */
 static int davinci_enter_idle(struct cpuidle_device *dev,
 				struct cpuidle_driver *drv,
 						int index)
 {
-	struct cpuidle_state_usage *state_usage = &dev->states_usage[index];
-	struct davinci_ops *ops = cpuidle_get_statedata(state_usage);
-
-	if (ops && ops->enter)
-		ops->enter(ops->flags);
+	if (index)
+		davinci_save_ddr_power(1, ddr2_pwdn);
 
 	index = cpuidle_wrap_enter(dev,	drv, index,
 				arm_cpuidle_simple_enter);
 
-	if (ops && ops->exit)
-		ops->exit(ops->flags);
+	if (index)
+		davinci_save_ddr_power(0, ddr2_pwdn);
 
 	return index;
 }
 
-/* fields in davinci_ops.flags */
-#define DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN	BIT(0)
-
 static struct cpuidle_driver davinci_idle_driver = {
 	.name			= "cpuidle-davinci",
 	.owner			= THIS_MODULE,
@@ -71,43 +82,6 @@ static struct cpuidle_driver davinci_idle_driver = {
 };
 
 static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device);
-static void __iomem *ddr2_reg_base;
-
-static void davinci_save_ddr_power(int enter, bool pdown)
-{
-	u32 val;
-
-	val = __raw_readl(ddr2_reg_base + DDR2_SDRCR_OFFSET);
-
-	if (enter) {
-		if (pdown)
-			val |= DDR2_SRPD_BIT;
-		else
-			val &= ~DDR2_SRPD_BIT;
-		val |= DDR2_LPMODEN_BIT;
-	} else {
-		val &= ~(DDR2_SRPD_BIT | DDR2_LPMODEN_BIT);
-	}
-
-	__raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET);
-}
-
-static void davinci_c2state_enter(u32 flags)
-{
-	davinci_save_ddr_power(1, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN));
-}
-
-static void davinci_c2state_exit(u32 flags)
-{
-	davinci_save_ddr_power(0, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN));
-}
-
-static struct davinci_ops davinci_states[DAVINCI_CPUIDLE_MAX_STATES] = {
-	[1] = {
-		.enter	= davinci_c2state_enter,
-		.exit	= davinci_c2state_exit,
-	},
-};
 
 static int __init davinci_cpuidle_probe(struct platform_device *pdev)
 {
@@ -125,8 +99,7 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev)
 	ddr2_reg_base = pdata->ddr2_ctlr_base;
 
 	if (pdata->ddr2_pdown)
-		davinci_states[1].flags |= DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN;
-	cpuidle_set_statedata(&device->states_usage[1], &davinci_states[1]);
+		ddr2_pwdn = true;
 
 	ret = cpuidle_register_driver(&davinci_idle_driver);
 	if (ret) {
-- 
1.7.5.4

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

* Re: [PATCH 0/2] ARM: DAVINCI: cpuidle - cleanups
  2012-05-10  8:44 [PATCH 0/2] ARM: DAVINCI: cpuidle - cleanups Daniel Lezcano
  2012-05-10  8:44 ` [PATCH 1/2] ARM: DAVINCI: cpuidle - remove useless state count initialization Daniel Lezcano
       [not found] ` <1336639485-26955-1-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2012-05-19  9:26 ` Daniel Lezcano
  2 siblings, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2012-05-19  9:26 UTC (permalink / raw)
  To: nsekhar, khilman; +Cc: davinci-linux-open-source, patches, linaro-dev, linux-pm

On 05/10/2012 10:44 AM, Daniel Lezcano wrote:
> These couple of patches use the new cpuidle core api to refactor
> some part of the code. The first one removes the state count initialization
> as it is done from the cpuidle core and the second one use the new
> API and removes the ops.
>
> The patchset is based on Lenb's tree on top of Robert Lee cpuidle consolidation
> work.
>
> I don't have this board, I was not able to test these patches.
>
> Daniel Lezcano (2):
>    ARM: DAVINCI: cpuidle - remove useless state count initialization
>    ARM: DAVINCI: cpuidle - remove ops
>
>   arch/arm/mach-davinci/cpuidle.c |   83 +++++++++++++--------------------------
>   1 files changed, 27 insertions(+), 56 deletions(-)
>

Hi,

maybe these patches did not raise attention.
Do you think they sound good ?

Thanks
-- Daniel

-- 
  <http://www.linaro.org/>  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:<http://www.facebook.com/pages/Linaro>  Facebook |
<http://twitter.com/#!/linaroorg>  Twitter |
<http://www.linaro.org/linaro-blog/>  Blog


_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-pm

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

* Re: [PATCH 1/2] ARM: DAVINCI: cpuidle - remove useless state count initialization
       [not found]   ` <1336639485-26955-2-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2012-05-20  9:24     ` Sekhar Nori
  0 siblings, 0 replies; 7+ messages in thread
From: Sekhar Nori @ 2012-05-20  9:24 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: khilman-l0cyMroinI0,
	davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	linaro-dev-cunTk1MwBs8s++Sfvej+rw, patches-QSEj5FYQhm4dnm+yROfE0A,
	linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	lenb-DgEjT+Ai2ygdnm+yROfE0A

Hi Daniel,

On 5/10/2012 2:14 PM, Daniel Lezcano wrote:
> The state count is initialized in the driver structure, the cpuidle
> core uses it to initialize the device state count.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Looks good to me. Will queue for v3.6

Nit: In future, please use davinci in small case in subject line to keep
it consistent with other DaVinci patches.

Thanks,
Sekhar

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

* Re: [PATCH 2/2] ARM: DAVINCI: cpuidle - remove ops
       [not found]     ` <1336639485-26955-3-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2012-05-20 10:19       ` Sekhar Nori
  2012-05-20 10:37         ` Daniel Lezcano
  0 siblings, 1 reply; 7+ messages in thread
From: Sekhar Nori @ 2012-05-20 10:19 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: khilman-l0cyMroinI0,
	davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	linaro-dev-cunTk1MwBs8s++Sfvej+rw, patches-QSEj5FYQhm4dnm+yROfE0A,
	linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	lenb-DgEjT+Ai2ygdnm+yROfE0A

Hi Daniel,

On 5/10/2012 2:14 PM, Daniel Lezcano wrote:
> This patch removes the ops usage because we have the index
> passed as parameter to the idle function and we can determine
> if we do WFI or memory retention.
> 
> The benefit of this cleanup is the removal of:
>  * the ops
>  * the statedata usage because we want to get rid of it in all the drivers
>  * extra structure definition
>  * extra functions definition
>  * pointless macro definition BIT(0)

This macro was not pointless in the original code. This comment seems to
suggest so.

> 
> It also benefits the readability.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  arch/arm/mach-davinci/cpuidle.c |   81 +++++++++++++--------------------------
>  1 files changed, 27 insertions(+), 54 deletions(-)
> 
> diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
> index f0f179c..61f4e52 100644
> --- a/arch/arm/mach-davinci/cpuidle.c
> +++ b/arch/arm/mach-davinci/cpuidle.c
> @@ -25,35 +25,46 @@
>  
>  #define DAVINCI_CPUIDLE_MAX_STATES	2
>  
> -struct davinci_ops {
> -	void (*enter) (u32 flags);
> -	void (*exit) (u32 flags);
> -	u32 flags;
> -};
> +static bool ddr2_pwdn = false;

This zero initialization is not required. In fact this throws a
checkpatch error.

> +
> +static void __iomem *ddr2_reg_base;
> +
> +static void davinci_save_ddr_power(int enter, bool pdown)
> +{
> +	u32 val;
> +
> +	val = __raw_readl(ddr2_reg_base + DDR2_SDRCR_OFFSET);
> +
> +	if (enter) {
> +		if (pdown)
> +			val |= DDR2_SRPD_BIT;
> +		else
> +			val &= ~DDR2_SRPD_BIT;
> +		val |= DDR2_LPMODEN_BIT;
> +	} else {
> +		val &= ~(DDR2_SRPD_BIT | DDR2_LPMODEN_BIT);
> +	}
> +
> +	__raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET);

Can you please use readl/writel instead of the __raw variants. I know
this is carried from original code, but we need to git rid of it with
cleanups like this.

Thanks,
Sekhar

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

* Re: [PATCH 2/2] ARM: DAVINCI: cpuidle - remove ops
  2012-05-20 10:19       ` Sekhar Nori
@ 2012-05-20 10:37         ` Daniel Lezcano
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2012-05-20 10:37 UTC (permalink / raw)
  To: Sekhar Nori
  Cc: khilman, davinci-linux-open-source, linaro-dev, patches, linux-pm

On 05/20/2012 12:19 PM, Sekhar Nori wrote:
> Hi Daniel,
>
> On 5/10/2012 2:14 PM, Daniel Lezcano wrote:
>> This patch removes the ops usage because we have the index
>> passed as parameter to the idle function and we can determine
>> if we do WFI or memory retention.
>>
>> The benefit of this cleanup is the removal of:
>>   * the ops
>>   * the statedata usage because we want to get rid of it in all the drivers
>>   * extra structure definition
>>   * extra functions definition
>>   * pointless macro definition BIT(0)
>
> This macro was not pointless in the original code. This comment seems to
> suggest so.
>
>>
>> It also benefits the readability.
>>
>> Signed-off-by: Daniel Lezcano<daniel.lezcano@linaro.org>
>> ---
>>   arch/arm/mach-davinci/cpuidle.c |   81 +++++++++++++--------------------------
>>   1 files changed, 27 insertions(+), 54 deletions(-)
>>
>> diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
>> index f0f179c..61f4e52 100644
>> --- a/arch/arm/mach-davinci/cpuidle.c
>> +++ b/arch/arm/mach-davinci/cpuidle.c
>> @@ -25,35 +25,46 @@
>>
>>   #define DAVINCI_CPUIDLE_MAX_STATES	2
>>
>> -struct davinci_ops {
>> -	void (*enter) (u32 flags);
>> -	void (*exit) (u32 flags);
>> -	u32 flags;
>> -};
>> +static bool ddr2_pwdn = false;
>
> This zero initialization is not required. In fact this throws a
> checkpatch error.
>
>> +
>> +static void __iomem *ddr2_reg_base;
>> +
>> +static void davinci_save_ddr_power(int enter, bool pdown)
>> +{
>> +	u32 val;
>> +
>> +	val = __raw_readl(ddr2_reg_base + DDR2_SDRCR_OFFSET);
>> +
>> +	if (enter) {
>> +		if (pdown)
>> +			val |= DDR2_SRPD_BIT;
>> +		else
>> +			val&= ~DDR2_SRPD_BIT;
>> +		val |= DDR2_LPMODEN_BIT;
>> +	} else {
>> +		val&= ~(DDR2_SRPD_BIT | DDR2_LPMODEN_BIT);
>> +	}
>> +
>> +	__raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET);
>
> Can you please use readl/writel instead of the __raw variants. I know
> this is carried from original code, but we need to git rid of it with
> cleanups like this.

Sure, I will resend a version without the initialization and the 
_raw_write variant.

Thanks
   -- Daniel


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-pm

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

end of thread, other threads:[~2012-05-20 10:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-10  8:44 [PATCH 0/2] ARM: DAVINCI: cpuidle - cleanups Daniel Lezcano
2012-05-10  8:44 ` [PATCH 1/2] ARM: DAVINCI: cpuidle - remove useless state count initialization Daniel Lezcano
     [not found]   ` <1336639485-26955-2-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-20  9:24     ` Sekhar Nori
     [not found] ` <1336639485-26955-1-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-10  8:44   ` [PATCH 2/2] ARM: DAVINCI: cpuidle - remove ops Daniel Lezcano
     [not found]     ` <1336639485-26955-3-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-05-20 10:19       ` Sekhar Nori
2012-05-20 10:37         ` Daniel Lezcano
2012-05-19  9:26 ` [PATCH 0/2] ARM: DAVINCI: cpuidle - cleanups Daniel Lezcano

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).