All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Support omap_pm_get_dev_context_loss_count() for OMAP4
@ 2011-11-03 10:54 ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-11-03 10:54 UTC (permalink / raw)
  To: b-cousson, paul; +Cc: linux-omap, tony, linux-arm-kernel, Rajendra Nayak

Hi,

This series adds support for OMAP-PM api omap_pm_get_dev_context_loss_count()
on OMAP4 platforms. This api is mainly used by drivers to determine if the
device context was lost, before doing a restore.

regards,
Rajendra

Rajendra Nayak (3):
  ARM: OMAP: hmwod: Add support for per hwmod/module context lost count
  ARM: OMAP: hwmod: Update/Clear module specific context lost counters
  ARM: OMAP: hwmod: Look for hwmod/module level context lost count if
    supported

 arch/arm/mach-omap2/omap_hwmod.c             |   39 ++++++++++++++++++++++++--
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    2 +
 2 files changed, 38 insertions(+), 3 deletions(-)


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

* [PATCH 0/3] Support omap_pm_get_dev_context_loss_count() for OMAP4
@ 2011-11-03 10:54 ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-11-03 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

This series adds support for OMAP-PM api omap_pm_get_dev_context_loss_count()
on OMAP4 platforms. This api is mainly used by drivers to determine if the
device context was lost, before doing a restore.

regards,
Rajendra

Rajendra Nayak (3):
  ARM: OMAP: hmwod: Add support for per hwmod/module context lost count
  ARM: OMAP: hwmod: Update/Clear module specific context lost counters
  ARM: OMAP: hwmod: Look for hwmod/module level context lost count if
    supported

 arch/arm/mach-omap2/omap_hwmod.c             |   39 ++++++++++++++++++++++++--
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    2 +
 2 files changed, 38 insertions(+), 3 deletions(-)

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

* [PATCH 1/3] ARM: OMAP: hmwod: Add support for per hwmod/module context lost count
  2011-11-03 10:54 ` Rajendra Nayak
@ 2011-11-03 10:54   ` Rajendra Nayak
  -1 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-11-03 10:54 UTC (permalink / raw)
  To: b-cousson, paul; +Cc: linux-omap, tony, linux-arm-kernel, Rajendra Nayak

OMAP4 has module specific context lost registers which
makes it now possible to have module level context loss
count, instead of relying on the powerdomain level context
count.

Add 2 private hwmod api's to update/clear the hwmod/module specific
context lost counters/register.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   26 ++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    2 ++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index d713807..d7f9dd1 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1426,6 +1426,32 @@ static int _reset(struct omap_hwmod *oh)
 	return ret;
 }
 
+static void _update_context_lost(struct omap_hwmod *oh)
+{
+	if (oh->prcm.omap4.context_offs)
+		if (omap4_prminst_read_inst_reg(
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.context_offs))
+				oh->prcm.omap4.context_lost_counter++;
+}
+
+static void _clear_context_lost(struct omap_hwmod *oh)
+{
+	u32 context_reg;
+
+	if (oh->prcm.omap4.context_offs) {
+		context_reg = omap4_prminst_read_inst_reg(
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.context_offs);
+		omap4_prminst_write_inst_reg(context_reg,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.context_offs);
+	}
+}
+
 /**
  * _enable - enable an omap_hwmod
  * @oh: struct omap_hwmod *
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 5419f1a..540e424 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -363,12 +363,14 @@ struct omap_hwmod_omap2_prcm {
  * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
  * @clkctrl_reg: PRCM address of the clock control register
  * @rstctrl_reg: address of the XXX_RSTCTRL register located in the PRM
+ * context_lost_counter: Count of module level context lost
  * @submodule_wkdep_bit: bit shift of the WKDEP range
  */
 struct omap_hwmod_omap4_prcm {
 	u16		clkctrl_offs;
 	u16		rstctrl_offs;
 	u16		context_offs;
+	unsigned	context_lost_counter;
 	u8		submodule_wkdep_bit;
 	u8		modulemode;
 };
-- 
1.7.1


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

* [PATCH 1/3] ARM: OMAP: hmwod: Add support for per hwmod/module context lost count
@ 2011-11-03 10:54   ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-11-03 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

OMAP4 has module specific context lost registers which
makes it now possible to have module level context loss
count, instead of relying on the powerdomain level context
count.

Add 2 private hwmod api's to update/clear the hwmod/module specific
context lost counters/register.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   26 ++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    2 ++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index d713807..d7f9dd1 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1426,6 +1426,32 @@ static int _reset(struct omap_hwmod *oh)
 	return ret;
 }
 
+static void _update_context_lost(struct omap_hwmod *oh)
+{
+	if (oh->prcm.omap4.context_offs)
+		if (omap4_prminst_read_inst_reg(
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.context_offs))
+				oh->prcm.omap4.context_lost_counter++;
+}
+
+static void _clear_context_lost(struct omap_hwmod *oh)
+{
+	u32 context_reg;
+
+	if (oh->prcm.omap4.context_offs) {
+		context_reg = omap4_prminst_read_inst_reg(
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.context_offs);
+		omap4_prminst_write_inst_reg(context_reg,
+				oh->clkdm->pwrdm.ptr->prcm_partition,
+				oh->clkdm->pwrdm.ptr->prcm_offs,
+				oh->prcm.omap4.context_offs);
+	}
+}
+
 /**
  * _enable - enable an omap_hwmod
  * @oh: struct omap_hwmod *
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 5419f1a..540e424 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -363,12 +363,14 @@ struct omap_hwmod_omap2_prcm {
  * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
  * @clkctrl_reg: PRCM address of the clock control register
  * @rstctrl_reg: address of the XXX_RSTCTRL register located in the PRM
+ * context_lost_counter: Count of module level context lost
  * @submodule_wkdep_bit: bit shift of the WKDEP range
  */
 struct omap_hwmod_omap4_prcm {
 	u16		clkctrl_offs;
 	u16		rstctrl_offs;
 	u16		context_offs;
+	unsigned	context_lost_counter;
 	u8		submodule_wkdep_bit;
 	u8		modulemode;
 };
-- 
1.7.1

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

* [PATCH 2/3] ARM: OMAP: hwmod: Update/Clear module specific context lost counters
  2011-11-03 10:54 ` Rajendra Nayak
@ 2011-11-03 10:54   ` Rajendra Nayak
  -1 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-11-03 10:54 UTC (permalink / raw)
  To: b-cousson, paul; +Cc: linux-omap, tony, linux-arm-kernel, Rajendra Nayak

Update the module specific context_lost_counter just after
enabling the module, and clear the context register just
before disabling the module.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index d7f9dd1..ac17748 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1510,6 +1510,7 @@ static int _enable(struct omap_hwmod *oh)
 
 	_enable_clocks(oh);
 	_enable_module(oh);
+	_update_context_lost(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
@@ -1563,6 +1564,7 @@ static int _idle(struct omap_hwmod *oh)
 	if (oh->class->sysc)
 		_idle_sysc(oh);
 	_del_initiator_dep(oh, mpu_oh);
+	_clear_context_lost(oh);
 	_disable_module(oh);
 	ret = _wait_target_disable(oh);
 	if (ret)
-- 
1.7.1


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

* [PATCH 2/3] ARM: OMAP: hwmod: Update/Clear module specific context lost counters
@ 2011-11-03 10:54   ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-11-03 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

Update the module specific context_lost_counter just after
enabling the module, and clear the context register just
before disabling the module.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index d7f9dd1..ac17748 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1510,6 +1510,7 @@ static int _enable(struct omap_hwmod *oh)
 
 	_enable_clocks(oh);
 	_enable_module(oh);
+	_update_context_lost(oh);
 
 	r = _wait_target_ready(oh);
 	if (!r) {
@@ -1563,6 +1564,7 @@ static int _idle(struct omap_hwmod *oh)
 	if (oh->class->sysc)
 		_idle_sysc(oh);
 	_del_initiator_dep(oh, mpu_oh);
+	_clear_context_lost(oh);
 	_disable_module(oh);
 	ret = _wait_target_disable(oh);
 	if (ret)
-- 
1.7.1

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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-11-03 10:54 ` Rajendra Nayak
@ 2011-11-03 10:54   ` Rajendra Nayak
  -1 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-11-03 10:54 UTC (permalink / raw)
  To: b-cousson, paul; +Cc: linux-omap, tony, linux-arm-kernel, Rajendra Nayak

Now that OMAP4 has hwmod/module level context lost counters, make
omap_hwmod_get_context_loss_count() return them on platforms where they
exist, else fall back on the pwrdm level counters for older platforms.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index ac17748..9d140c4 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2658,9 +2658,14 @@ u32 omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
 	struct powerdomain *pwrdm;
 	int ret = 0;
 
-	pwrdm = omap_hwmod_get_pwrdm(oh);
-	if (pwrdm)
-		ret = pwrdm_get_context_loss_count(pwrdm);
+	if (oh->prcm.omap4.context_offs) {
+		/* Support for per-hwmod context register */
+		ret = oh->prcm.omap4.context_lost_counter;
+	} else {
+		pwrdm = omap_hwmod_get_pwrdm(oh);
+		if (pwrdm)
+			ret = pwrdm_get_context_loss_count(pwrdm);
+	}
 
 	return ret;
 }
-- 
1.7.1


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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-11-03 10:54   ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-11-03 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

Now that OMAP4 has hwmod/module level context lost counters, make
omap_hwmod_get_context_loss_count() return them on platforms where they
exist, else fall back on the pwrdm level counters for older platforms.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index ac17748..9d140c4 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2658,9 +2658,14 @@ u32 omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
 	struct powerdomain *pwrdm;
 	int ret = 0;
 
-	pwrdm = omap_hwmod_get_pwrdm(oh);
-	if (pwrdm)
-		ret = pwrdm_get_context_loss_count(pwrdm);
+	if (oh->prcm.omap4.context_offs) {
+		/* Support for per-hwmod context register */
+		ret = oh->prcm.omap4.context_lost_counter;
+	} else {
+		pwrdm = omap_hwmod_get_pwrdm(oh);
+		if (pwrdm)
+			ret = pwrdm_get_context_loss_count(pwrdm);
+	}
 
 	return ret;
 }
-- 
1.7.1

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

* Re: [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-11-03 10:54   ` Rajendra Nayak
@ 2011-11-29 18:10     ` Cousson, Benoit
  -1 siblings, 0 replies; 26+ messages in thread
From: Cousson, Benoit @ 2011-11-29 18:10 UTC (permalink / raw)
  To: Nayak, Rajendra; +Cc: paul, linux-omap, tony, linux-arm-kernel

Hi Rajendra,

Sorry for the delay, I kind of forgot your series :-(

On 11/3/2011 11:54 AM, Nayak, Rajendra wrote:
> Now that OMAP4 has hwmod/module level context lost counters, make
> omap_hwmod_get_context_loss_count() return them on platforms where they
> exist, else fall back on the pwrdm level counters for older platforms.
>
> Signed-off-by: Rajendra Nayak<rnayak@ti.com>
> ---
>   arch/arm/mach-omap2/omap_hwmod.c |   11 ++++++++---
>   1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index ac17748..9d140c4 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -2658,9 +2658,14 @@ u32 omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
>   	struct powerdomain *pwrdm;
>   	int ret = 0;
>
> -	pwrdm = omap_hwmod_get_pwrdm(oh);
> -	if (pwrdm)
> -		ret = pwrdm_get_context_loss_count(pwrdm);
> +	if (oh->prcm.omap4.context_offs) {

I don't think it is safe to use that, since this is an union.
You do know what OMAP2 & 3 will put in that location.
It might be zero, but who knows?

> +		/* Support for per-hwmod context register */
> +		ret = oh->prcm.omap4.context_lost_counter;
> +	} else {
> +		pwrdm = omap_hwmod_get_pwrdm(oh);
> +		if (pwrdm)
> +			ret = pwrdm_get_context_loss_count(pwrdm);
> +	}
>
>   	return ret;
>   }

Regards,
Benoit

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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-11-29 18:10     ` Cousson, Benoit
  0 siblings, 0 replies; 26+ messages in thread
From: Cousson, Benoit @ 2011-11-29 18:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Rajendra,

Sorry for the delay, I kind of forgot your series :-(

On 11/3/2011 11:54 AM, Nayak, Rajendra wrote:
> Now that OMAP4 has hwmod/module level context lost counters, make
> omap_hwmod_get_context_loss_count() return them on platforms where they
> exist, else fall back on the pwrdm level counters for older platforms.
>
> Signed-off-by: Rajendra Nayak<rnayak@ti.com>
> ---
>   arch/arm/mach-omap2/omap_hwmod.c |   11 ++++++++---
>   1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index ac17748..9d140c4 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -2658,9 +2658,14 @@ u32 omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
>   	struct powerdomain *pwrdm;
>   	int ret = 0;
>
> -	pwrdm = omap_hwmod_get_pwrdm(oh);
> -	if (pwrdm)
> -		ret = pwrdm_get_context_loss_count(pwrdm);
> +	if (oh->prcm.omap4.context_offs) {

I don't think it is safe to use that, since this is an union.
You do know what OMAP2 & 3 will put in that location.
It might be zero, but who knows?

> +		/* Support for per-hwmod context register */
> +		ret = oh->prcm.omap4.context_lost_counter;
> +	} else {
> +		pwrdm = omap_hwmod_get_pwrdm(oh);
> +		if (pwrdm)
> +			ret = pwrdm_get_context_loss_count(pwrdm);
> +	}
>
>   	return ret;
>   }

Regards,
Benoit

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

* Re: [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-11-29 18:10     ` Cousson, Benoit
@ 2011-12-02  4:46       ` Rajendra Nayak
  -1 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-12-02  4:46 UTC (permalink / raw)
  To: Cousson, Benoit; +Cc: paul, linux-omap, tony, linux-arm-kernel

On Tuesday 29 November 2011 11:40 PM, Cousson, Benoit wrote:
> Hi Rajendra,
>
> Sorry for the delay, I kind of forgot your series :-(
>
> On 11/3/2011 11:54 AM, Nayak, Rajendra wrote:
>> Now that OMAP4 has hwmod/module level context lost counters, make
>> omap_hwmod_get_context_loss_count() return them on platforms where they
>> exist, else fall back on the pwrdm level counters for older platforms.
>>
>> Signed-off-by: Rajendra Nayak<rnayak@ti.com>
>> ---
>> arch/arm/mach-omap2/omap_hwmod.c | 11 ++++++++---
>> 1 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/omap_hwmod.c
>> b/arch/arm/mach-omap2/omap_hwmod.c
>> index ac17748..9d140c4 100644
>> --- a/arch/arm/mach-omap2/omap_hwmod.c
>> +++ b/arch/arm/mach-omap2/omap_hwmod.c
>> @@ -2658,9 +2658,14 @@ u32 omap_hwmod_get_context_loss_count(struct
>> omap_hwmod *oh)
>> struct powerdomain *pwrdm;
>> int ret = 0;
>>
>> - pwrdm = omap_hwmod_get_pwrdm(oh);
>> - if (pwrdm)
>> - ret = pwrdm_get_context_loss_count(pwrdm);
>> + if (oh->prcm.omap4.context_offs) {
>
> I don't think it is safe to use that, since this is an union.
> You do know what OMAP2 & 3 will put in that location.
> It might be zero, but who knows?

Thats true, I need to figure out a better way to identify
when a module level context count is supported and when its
at the pwrdm level. Will repost with a fix.

Thanks for the review.

>
>> + /* Support for per-hwmod context register */
>> + ret = oh->prcm.omap4.context_lost_counter;
>> + } else {
>> + pwrdm = omap_hwmod_get_pwrdm(oh);
>> + if (pwrdm)
>> + ret = pwrdm_get_context_loss_count(pwrdm);
>> + }
>>
>> return ret;
>> }
>
> Regards,
> Benoit


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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-12-02  4:46       ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-12-02  4:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday 29 November 2011 11:40 PM, Cousson, Benoit wrote:
> Hi Rajendra,
>
> Sorry for the delay, I kind of forgot your series :-(
>
> On 11/3/2011 11:54 AM, Nayak, Rajendra wrote:
>> Now that OMAP4 has hwmod/module level context lost counters, make
>> omap_hwmod_get_context_loss_count() return them on platforms where they
>> exist, else fall back on the pwrdm level counters for older platforms.
>>
>> Signed-off-by: Rajendra Nayak<rnayak@ti.com>
>> ---
>> arch/arm/mach-omap2/omap_hwmod.c | 11 ++++++++---
>> 1 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/omap_hwmod.c
>> b/arch/arm/mach-omap2/omap_hwmod.c
>> index ac17748..9d140c4 100644
>> --- a/arch/arm/mach-omap2/omap_hwmod.c
>> +++ b/arch/arm/mach-omap2/omap_hwmod.c
>> @@ -2658,9 +2658,14 @@ u32 omap_hwmod_get_context_loss_count(struct
>> omap_hwmod *oh)
>> struct powerdomain *pwrdm;
>> int ret = 0;
>>
>> - pwrdm = omap_hwmod_get_pwrdm(oh);
>> - if (pwrdm)
>> - ret = pwrdm_get_context_loss_count(pwrdm);
>> + if (oh->prcm.omap4.context_offs) {
>
> I don't think it is safe to use that, since this is an union.
> You do know what OMAP2 & 3 will put in that location.
> It might be zero, but who knows?

Thats true, I need to figure out a better way to identify
when a module level context count is supported and when its
at the pwrdm level. Will repost with a fix.

Thanks for the review.

>
>> + /* Support for per-hwmod context register */
>> + ret = oh->prcm.omap4.context_lost_counter;
>> + } else {
>> + pwrdm = omap_hwmod_get_pwrdm(oh);
>> + if (pwrdm)
>> + ret = pwrdm_get_context_loss_count(pwrdm);
>> + }
>>
>> return ret;
>> }
>
> Regards,
> Benoit

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

* Re: [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-12-02  4:46       ` Rajendra Nayak
@ 2011-12-16 11:16         ` Paul Walmsley
  -1 siblings, 0 replies; 26+ messages in thread
From: Paul Walmsley @ 2011-12-16 11:16 UTC (permalink / raw)
  To: Rajendra Nayak; +Cc: Cousson, Benoit, linux-omap, tony, linux-arm-kernel


Hi Rajendra,

I've combined your patches down to one patch and changed the logic a 
little bit.  It looks to me that the update and clear context registers 
can be done in one step, since an IP block shouldn't lose context when 
it's enabled.  But maybe I'm missing something?  

Anyway, I'd appreciate any comments you might have, and if you have an 
environment where you can test this patch, that would also be very 
welcome.


- Paul

From: Rajendra Nayak <rnayak@ti.com>
Date: Fri, 16 Dec 2011 04:12:48 -0700
Subject: [PATCH] ARM: OMAP: hwmod: Add support for per hwmod/module context
 lost count

OMAP4 has module specific context lost registers which makes it now
possible to have module level context loss count, instead of relying
on the powerdomain level context count.

Add 2 private hwmod api's to update/clear the hwmod/module specific
context lost counters/register.

Update the module specific context_lost_counter and clear the hardware
bits just after enabling the module.

omap_hwmod_get_context_loss_count() now returns the hwmod context loss
count them on platforms where they exist (OMAP4), else fall back on
the pwrdm level counters for older platforms.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
[paul@pwsan.com: added function kerneldoc, fixed structure kerneldoc,
 rearranged structure to avoid memory waste, marked fns as OMAP4-specific,
 prevent fn entry on non-OMAP4 chips, reduced indentation, merged update
 and clear, merged patches]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   54 ++++++++++++++++++++++++--
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    8 +++-
 2 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 0a89335..5702462 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1435,6 +1435,42 @@ static int _reset(struct omap_hwmod *oh)
 }
 
 /**
+ * _omap4_update_context_lost - increment hwmod context loss counter if
+ * hwmod context was lost, and clear hardware context loss reg
+ * @oh: hwmod to check for context loss
+ *
+ * If the PRCM indicates that the hwmod @oh lost context, increment
+ * our in-memory context loss counter, and clear the RM_*_CONTEXT
+ * bits.  XXX Will not work correctly if the RM_*_CONTEXT register
+ * offset is 0 -- probably a flag should be used to avoid this
+ * situation, rather than testing @oh->prcm.omap4.context_offs.  No
+ * return value.
+ */
+static void _omap4_update_context_lost(struct omap_hwmod *oh)
+{
+	u32 r;
+
+	if (!cpu_is_omap44xx())
+		return;
+
+	if (!oh->prcm.omap4.context_offs)
+		return;
+
+	r = omap4_prminst_read_inst_reg(oh->clkdm->pwrdm.ptr->prcm_partition,
+					oh->clkdm->pwrdm.ptr->prcm_offs,
+					oh->prcm.omap4.context_offs);
+
+	if (!r)
+		return;
+
+	oh->prcm.omap4.context_lost_counter++;
+
+	omap4_prminst_write_inst_reg(r, oh->clkdm->pwrdm.ptr->prcm_partition,
+				     oh->clkdm->pwrdm.ptr->prcm_offs,
+				     oh->prcm.omap4.context_offs);
+}
+
+/**
  * _enable - enable an omap_hwmod
  * @oh: struct omap_hwmod *
  *
@@ -1512,6 +1548,8 @@ static int _enable(struct omap_hwmod *oh)
 	_enable_clocks(oh);
 	_enable_module(oh);
 
+	_omap4_update_context_lost(oh);
+
 	r = _wait_target_ready(oh);
 	if (!r) {
 		/*
@@ -2640,17 +2678,25 @@ ohsps_unlock:
  * omap_hwmod_get_context_loss_count - get lost context count
  * @oh: struct omap_hwmod *
  *
- * Query the powerdomain of of @oh to get the context loss
- * count for this device.
+ * Returns the context loss count of associated with @oh
+ * upon success, or zero if no context loss data is available.
  *
- * Returns the context loss count of the powerdomain assocated with @oh
- * upon success, or zero if no powerdomain exists for @oh.
+ * On OMAP4, this queries the per-hwmod context loss register,
+ * assuming one exists.  If not, or on OMAP2/3, this queries the
+ * enclosing powerdomain context loss count.
  */
 int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
 {
 	struct powerdomain *pwrdm;
 	int ret = 0;
 
+	/*
+	 * XXX This should use a flag to determine whether to check
+	 * context_offs, as context_offs == 0 is potentially valid
+	 */
+	if (cpu_is_omap44xx() && oh->prcm.omap4.context_offs)
+		return oh->prcm.omap4.context_lost_counter;
+
 	pwrdm = omap_hwmod_get_pwrdm(oh);
 	if (pwrdm)
 		ret = pwrdm_get_context_loss_count(pwrdm);
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 1a13c02..3aea95e 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -361,9 +361,12 @@ struct omap_hwmod_omap2_prcm {
 
 /**
  * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
- * @clkctrl_reg: PRCM address of the clock control register
- * @rstctrl_reg: address of the XXX_RSTCTRL register located in the PRM
+ * @clkctrl_offs: offset of the PRCM clock control register
+ * @rstctrl_offs: offset of the XXX_RSTCTRL register located in the PRM
+ * @context_offs: offset of the RM_*_CONTEXT register
  * @submodule_wkdep_bit: bit shift of the WKDEP range
+ * @modulemode: allowable modulemodes
+ * @context_lost_counter: Count of module level context lost
  */
 struct omap_hwmod_omap4_prcm {
 	u16		clkctrl_offs;
@@ -371,6 +374,7 @@ struct omap_hwmod_omap4_prcm {
 	u16		context_offs;
 	u8		submodule_wkdep_bit;
 	u8		modulemode;
+	unsigned	context_lost_counter;
 };
 
 
-- 
1.7.7.3


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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-12-16 11:16         ` Paul Walmsley
  0 siblings, 0 replies; 26+ messages in thread
From: Paul Walmsley @ 2011-12-16 11:16 UTC (permalink / raw)
  To: linux-arm-kernel


Hi Rajendra,

I've combined your patches down to one patch and changed the logic a 
little bit.  It looks to me that the update and clear context registers 
can be done in one step, since an IP block shouldn't lose context when 
it's enabled.  But maybe I'm missing something?  

Anyway, I'd appreciate any comments you might have, and if you have an 
environment where you can test this patch, that would also be very 
welcome.


- Paul

From: Rajendra Nayak <rnayak@ti.com>
Date: Fri, 16 Dec 2011 04:12:48 -0700
Subject: [PATCH] ARM: OMAP: hwmod: Add support for per hwmod/module context
 lost count

OMAP4 has module specific context lost registers which makes it now
possible to have module level context loss count, instead of relying
on the powerdomain level context count.

Add 2 private hwmod api's to update/clear the hwmod/module specific
context lost counters/register.

Update the module specific context_lost_counter and clear the hardware
bits just after enabling the module.

omap_hwmod_get_context_loss_count() now returns the hwmod context loss
count them on platforms where they exist (OMAP4), else fall back on
the pwrdm level counters for older platforms.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
[paul at pwsan.com: added function kerneldoc, fixed structure kerneldoc,
 rearranged structure to avoid memory waste, marked fns as OMAP4-specific,
 prevent fn entry on non-OMAP4 chips, reduced indentation, merged update
 and clear, merged patches]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c             |   54 ++++++++++++++++++++++++--
 arch/arm/plat-omap/include/plat/omap_hwmod.h |    8 +++-
 2 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 0a89335..5702462 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1435,6 +1435,42 @@ static int _reset(struct omap_hwmod *oh)
 }
 
 /**
+ * _omap4_update_context_lost - increment hwmod context loss counter if
+ * hwmod context was lost, and clear hardware context loss reg
+ * @oh: hwmod to check for context loss
+ *
+ * If the PRCM indicates that the hwmod @oh lost context, increment
+ * our in-memory context loss counter, and clear the RM_*_CONTEXT
+ * bits.  XXX Will not work correctly if the RM_*_CONTEXT register
+ * offset is 0 -- probably a flag should be used to avoid this
+ * situation, rather than testing @oh->prcm.omap4.context_offs.  No
+ * return value.
+ */
+static void _omap4_update_context_lost(struct omap_hwmod *oh)
+{
+	u32 r;
+
+	if (!cpu_is_omap44xx())
+		return;
+
+	if (!oh->prcm.omap4.context_offs)
+		return;
+
+	r = omap4_prminst_read_inst_reg(oh->clkdm->pwrdm.ptr->prcm_partition,
+					oh->clkdm->pwrdm.ptr->prcm_offs,
+					oh->prcm.omap4.context_offs);
+
+	if (!r)
+		return;
+
+	oh->prcm.omap4.context_lost_counter++;
+
+	omap4_prminst_write_inst_reg(r, oh->clkdm->pwrdm.ptr->prcm_partition,
+				     oh->clkdm->pwrdm.ptr->prcm_offs,
+				     oh->prcm.omap4.context_offs);
+}
+
+/**
  * _enable - enable an omap_hwmod
  * @oh: struct omap_hwmod *
  *
@@ -1512,6 +1548,8 @@ static int _enable(struct omap_hwmod *oh)
 	_enable_clocks(oh);
 	_enable_module(oh);
 
+	_omap4_update_context_lost(oh);
+
 	r = _wait_target_ready(oh);
 	if (!r) {
 		/*
@@ -2640,17 +2678,25 @@ ohsps_unlock:
  * omap_hwmod_get_context_loss_count - get lost context count
  * @oh: struct omap_hwmod *
  *
- * Query the powerdomain of of @oh to get the context loss
- * count for this device.
+ * Returns the context loss count of associated with @oh
+ * upon success, or zero if no context loss data is available.
  *
- * Returns the context loss count of the powerdomain assocated with @oh
- * upon success, or zero if no powerdomain exists for @oh.
+ * On OMAP4, this queries the per-hwmod context loss register,
+ * assuming one exists.  If not, or on OMAP2/3, this queries the
+ * enclosing powerdomain context loss count.
  */
 int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
 {
 	struct powerdomain *pwrdm;
 	int ret = 0;
 
+	/*
+	 * XXX This should use a flag to determine whether to check
+	 * context_offs, as context_offs == 0 is potentially valid
+	 */
+	if (cpu_is_omap44xx() && oh->prcm.omap4.context_offs)
+		return oh->prcm.omap4.context_lost_counter;
+
 	pwrdm = omap_hwmod_get_pwrdm(oh);
 	if (pwrdm)
 		ret = pwrdm_get_context_loss_count(pwrdm);
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 1a13c02..3aea95e 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -361,9 +361,12 @@ struct omap_hwmod_omap2_prcm {
 
 /**
  * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
- * @clkctrl_reg: PRCM address of the clock control register
- * @rstctrl_reg: address of the XXX_RSTCTRL register located in the PRM
+ * @clkctrl_offs: offset of the PRCM clock control register
+ * @rstctrl_offs: offset of the XXX_RSTCTRL register located in the PRM
+ * @context_offs: offset of the RM_*_CONTEXT register
  * @submodule_wkdep_bit: bit shift of the WKDEP range
+ * @modulemode: allowable modulemodes
+ * @context_lost_counter: Count of module level context lost
  */
 struct omap_hwmod_omap4_prcm {
 	u16		clkctrl_offs;
@@ -371,6 +374,7 @@ struct omap_hwmod_omap4_prcm {
 	u16		context_offs;
 	u8		submodule_wkdep_bit;
 	u8		modulemode;
+	unsigned	context_lost_counter;
 };
 
 
-- 
1.7.7.3

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

* Re: [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-12-16 11:16         ` Paul Walmsley
@ 2011-12-16 11:23           ` Paul Walmsley
  -1 siblings, 0 replies; 26+ messages in thread
From: Paul Walmsley @ 2011-12-16 11:23 UTC (permalink / raw)
  To: Rajendra Nayak; +Cc: Cousson, Benoit, linux-omap, tony, linux-arm-kernel

Hi

On Fri, 16 Dec 2011, Paul Walmsley wrote:

> + * XXX Will not work correctly if the RM_*_CONTEXT register
> + * offset is 0 -- probably a flag should be used to avoid this
> + * situation, rather than testing @oh->prcm.omap4.context_offs.  No
> + * return value.

By the way, I'm also worried about this case.  Am wondering if we should 
add a flag here just to be sure, rather than testing the offset.  
Thoughts?


- Paul

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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-12-16 11:23           ` Paul Walmsley
  0 siblings, 0 replies; 26+ messages in thread
From: Paul Walmsley @ 2011-12-16 11:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hi

On Fri, 16 Dec 2011, Paul Walmsley wrote:

> + * XXX Will not work correctly if the RM_*_CONTEXT register
> + * offset is 0 -- probably a flag should be used to avoid this
> + * situation, rather than testing @oh->prcm.omap4.context_offs.  No
> + * return value.

By the way, I'm also worried about this case.  Am wondering if we should 
add a flag here just to be sure, rather than testing the offset.  
Thoughts?


- Paul

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

* Re: [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-12-16 11:16         ` Paul Walmsley
@ 2011-12-16 12:17           ` Rajendra Nayak
  -1 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-12-16 12:17 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: Cousson, Benoit, linux-omap, tony, linux-arm-kernel

Hi Paul,

On Friday 16 December 2011 04:46 PM, Paul Walmsley wrote:
>
> Hi Rajendra,
>
> I've combined your patches down to one patch and changed the logic a
> little bit.  It looks to me that the update and clear context registers
> can be done in one step, since an IP block shouldn't lose context when
> it's enabled.  But maybe I'm missing something?

Thanks for the patch. The changes look fine and I also did a quick
test on an internal tree which supports core OSWR and it seems to
work fine too.

regards,
Rajendra

>
> Anyway, I'd appreciate any comments you might have, and if you have an
> environment where you can test this patch, that would also be very
> welcome.
>
>
> - Paul
>
> From: Rajendra Nayak<rnayak@ti.com>
> Date: Fri, 16 Dec 2011 04:12:48 -0700
> Subject: [PATCH] ARM: OMAP: hwmod: Add support for per hwmod/module context
>   lost count
>
> OMAP4 has module specific context lost registers which makes it now
> possible to have module level context loss count, instead of relying
> on the powerdomain level context count.
>
> Add 2 private hwmod api's to update/clear the hwmod/module specific
> context lost counters/register.
>
> Update the module specific context_lost_counter and clear the hardware
> bits just after enabling the module.
>
> omap_hwmod_get_context_loss_count() now returns the hwmod context loss
> count them on platforms where they exist (OMAP4), else fall back on
> the pwrdm level counters for older platforms.
>
> Signed-off-by: Rajendra Nayak<rnayak@ti.com>
> [paul@pwsan.com: added function kerneldoc, fixed structure kerneldoc,
>   rearranged structure to avoid memory waste, marked fns as OMAP4-specific,
>   prevent fn entry on non-OMAP4 chips, reduced indentation, merged update
>   and clear, merged patches]
> Signed-off-by: Paul Walmsley<paul@pwsan.com>
> ---
>   arch/arm/mach-omap2/omap_hwmod.c             |   54 ++++++++++++++++++++++++--
>   arch/arm/plat-omap/include/plat/omap_hwmod.h |    8 +++-
>   2 files changed, 56 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index 0a89335..5702462 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -1435,6 +1435,42 @@ static int _reset(struct omap_hwmod *oh)
>   }
>
>   /**
> + * _omap4_update_context_lost - increment hwmod context loss counter if
> + * hwmod context was lost, and clear hardware context loss reg
> + * @oh: hwmod to check for context loss
> + *
> + * If the PRCM indicates that the hwmod @oh lost context, increment
> + * our in-memory context loss counter, and clear the RM_*_CONTEXT
> + * bits.  XXX Will not work correctly if the RM_*_CONTEXT register
> + * offset is 0 -- probably a flag should be used to avoid this
> + * situation, rather than testing @oh->prcm.omap4.context_offs.  No
> + * return value.
> + */
> +static void _omap4_update_context_lost(struct omap_hwmod *oh)
> +{
> +	u32 r;
> +
> +	if (!cpu_is_omap44xx())
> +		return;
> +
> +	if (!oh->prcm.omap4.context_offs)
> +		return;
> +
> +	r = omap4_prminst_read_inst_reg(oh->clkdm->pwrdm.ptr->prcm_partition,
> +					oh->clkdm->pwrdm.ptr->prcm_offs,
> +					oh->prcm.omap4.context_offs);
> +
> +	if (!r)
> +		return;
> +
> +	oh->prcm.omap4.context_lost_counter++;
> +
> +	omap4_prminst_write_inst_reg(r, oh->clkdm->pwrdm.ptr->prcm_partition,
> +				     oh->clkdm->pwrdm.ptr->prcm_offs,
> +				     oh->prcm.omap4.context_offs);
> +}
> +
> +/**
>    * _enable - enable an omap_hwmod
>    * @oh: struct omap_hwmod *
>    *
> @@ -1512,6 +1548,8 @@ static int _enable(struct omap_hwmod *oh)
>   	_enable_clocks(oh);
>   	_enable_module(oh);
>
> +	_omap4_update_context_lost(oh);
> +
>   	r = _wait_target_ready(oh);
>   	if (!r) {
>   		/*
> @@ -2640,17 +2678,25 @@ ohsps_unlock:
>    * omap_hwmod_get_context_loss_count - get lost context count
>    * @oh: struct omap_hwmod *
>    *
> - * Query the powerdomain of of @oh to get the context loss
> - * count for this device.
> + * Returns the context loss count of associated with @oh
> + * upon success, or zero if no context loss data is available.
>    *
> - * Returns the context loss count of the powerdomain assocated with @oh
> - * upon success, or zero if no powerdomain exists for @oh.
> + * On OMAP4, this queries the per-hwmod context loss register,
> + * assuming one exists.  If not, or on OMAP2/3, this queries the
> + * enclosing powerdomain context loss count.
>    */
>   int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
>   {
>   	struct powerdomain *pwrdm;
>   	int ret = 0;
>
> +	/*
> +	 * XXX This should use a flag to determine whether to check
> +	 * context_offs, as context_offs == 0 is potentially valid
> +	 */
> +	if (cpu_is_omap44xx()&&  oh->prcm.omap4.context_offs)
> +		return oh->prcm.omap4.context_lost_counter;
> +
>   	pwrdm = omap_hwmod_get_pwrdm(oh);
>   	if (pwrdm)
>   		ret = pwrdm_get_context_loss_count(pwrdm);
> diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
> index 1a13c02..3aea95e 100644
> --- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
> +++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
> @@ -361,9 +361,12 @@ struct omap_hwmod_omap2_prcm {
>
>   /**
>    * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
> - * @clkctrl_reg: PRCM address of the clock control register
> - * @rstctrl_reg: address of the XXX_RSTCTRL register located in the PRM
> + * @clkctrl_offs: offset of the PRCM clock control register
> + * @rstctrl_offs: offset of the XXX_RSTCTRL register located in the PRM
> + * @context_offs: offset of the RM_*_CONTEXT register
>    * @submodule_wkdep_bit: bit shift of the WKDEP range
> + * @modulemode: allowable modulemodes
> + * @context_lost_counter: Count of module level context lost
>    */
>   struct omap_hwmod_omap4_prcm {
>   	u16		clkctrl_offs;
> @@ -371,6 +374,7 @@ struct omap_hwmod_omap4_prcm {
>   	u16		context_offs;
>   	u8		submodule_wkdep_bit;
>   	u8		modulemode;
> +	unsigned	context_lost_counter;
>   };
>
>


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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-12-16 12:17           ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-12-16 12:17 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Paul,

On Friday 16 December 2011 04:46 PM, Paul Walmsley wrote:
>
> Hi Rajendra,
>
> I've combined your patches down to one patch and changed the logic a
> little bit.  It looks to me that the update and clear context registers
> can be done in one step, since an IP block shouldn't lose context when
> it's enabled.  But maybe I'm missing something?

Thanks for the patch. The changes look fine and I also did a quick
test on an internal tree which supports core OSWR and it seems to
work fine too.

regards,
Rajendra

>
> Anyway, I'd appreciate any comments you might have, and if you have an
> environment where you can test this patch, that would also be very
> welcome.
>
>
> - Paul
>
> From: Rajendra Nayak<rnayak@ti.com>
> Date: Fri, 16 Dec 2011 04:12:48 -0700
> Subject: [PATCH] ARM: OMAP: hwmod: Add support for per hwmod/module context
>   lost count
>
> OMAP4 has module specific context lost registers which makes it now
> possible to have module level context loss count, instead of relying
> on the powerdomain level context count.
>
> Add 2 private hwmod api's to update/clear the hwmod/module specific
> context lost counters/register.
>
> Update the module specific context_lost_counter and clear the hardware
> bits just after enabling the module.
>
> omap_hwmod_get_context_loss_count() now returns the hwmod context loss
> count them on platforms where they exist (OMAP4), else fall back on
> the pwrdm level counters for older platforms.
>
> Signed-off-by: Rajendra Nayak<rnayak@ti.com>
> [paul at pwsan.com: added function kerneldoc, fixed structure kerneldoc,
>   rearranged structure to avoid memory waste, marked fns as OMAP4-specific,
>   prevent fn entry on non-OMAP4 chips, reduced indentation, merged update
>   and clear, merged patches]
> Signed-off-by: Paul Walmsley<paul@pwsan.com>
> ---
>   arch/arm/mach-omap2/omap_hwmod.c             |   54 ++++++++++++++++++++++++--
>   arch/arm/plat-omap/include/plat/omap_hwmod.h |    8 +++-
>   2 files changed, 56 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index 0a89335..5702462 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -1435,6 +1435,42 @@ static int _reset(struct omap_hwmod *oh)
>   }
>
>   /**
> + * _omap4_update_context_lost - increment hwmod context loss counter if
> + * hwmod context was lost, and clear hardware context loss reg
> + * @oh: hwmod to check for context loss
> + *
> + * If the PRCM indicates that the hwmod @oh lost context, increment
> + * our in-memory context loss counter, and clear the RM_*_CONTEXT
> + * bits.  XXX Will not work correctly if the RM_*_CONTEXT register
> + * offset is 0 -- probably a flag should be used to avoid this
> + * situation, rather than testing @oh->prcm.omap4.context_offs.  No
> + * return value.
> + */
> +static void _omap4_update_context_lost(struct omap_hwmod *oh)
> +{
> +	u32 r;
> +
> +	if (!cpu_is_omap44xx())
> +		return;
> +
> +	if (!oh->prcm.omap4.context_offs)
> +		return;
> +
> +	r = omap4_prminst_read_inst_reg(oh->clkdm->pwrdm.ptr->prcm_partition,
> +					oh->clkdm->pwrdm.ptr->prcm_offs,
> +					oh->prcm.omap4.context_offs);
> +
> +	if (!r)
> +		return;
> +
> +	oh->prcm.omap4.context_lost_counter++;
> +
> +	omap4_prminst_write_inst_reg(r, oh->clkdm->pwrdm.ptr->prcm_partition,
> +				     oh->clkdm->pwrdm.ptr->prcm_offs,
> +				     oh->prcm.omap4.context_offs);
> +}
> +
> +/**
>    * _enable - enable an omap_hwmod
>    * @oh: struct omap_hwmod *
>    *
> @@ -1512,6 +1548,8 @@ static int _enable(struct omap_hwmod *oh)
>   	_enable_clocks(oh);
>   	_enable_module(oh);
>
> +	_omap4_update_context_lost(oh);
> +
>   	r = _wait_target_ready(oh);
>   	if (!r) {
>   		/*
> @@ -2640,17 +2678,25 @@ ohsps_unlock:
>    * omap_hwmod_get_context_loss_count - get lost context count
>    * @oh: struct omap_hwmod *
>    *
> - * Query the powerdomain of of @oh to get the context loss
> - * count for this device.
> + * Returns the context loss count of associated with @oh
> + * upon success, or zero if no context loss data is available.
>    *
> - * Returns the context loss count of the powerdomain assocated with @oh
> - * upon success, or zero if no powerdomain exists for @oh.
> + * On OMAP4, this queries the per-hwmod context loss register,
> + * assuming one exists.  If not, or on OMAP2/3, this queries the
> + * enclosing powerdomain context loss count.
>    */
>   int omap_hwmod_get_context_loss_count(struct omap_hwmod *oh)
>   {
>   	struct powerdomain *pwrdm;
>   	int ret = 0;
>
> +	/*
> +	 * XXX This should use a flag to determine whether to check
> +	 * context_offs, as context_offs == 0 is potentially valid
> +	 */
> +	if (cpu_is_omap44xx()&&  oh->prcm.omap4.context_offs)
> +		return oh->prcm.omap4.context_lost_counter;
> +
>   	pwrdm = omap_hwmod_get_pwrdm(oh);
>   	if (pwrdm)
>   		ret = pwrdm_get_context_loss_count(pwrdm);
> diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
> index 1a13c02..3aea95e 100644
> --- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
> +++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
> @@ -361,9 +361,12 @@ struct omap_hwmod_omap2_prcm {
>
>   /**
>    * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
> - * @clkctrl_reg: PRCM address of the clock control register
> - * @rstctrl_reg: address of the XXX_RSTCTRL register located in the PRM
> + * @clkctrl_offs: offset of the PRCM clock control register
> + * @rstctrl_offs: offset of the XXX_RSTCTRL register located in the PRM
> + * @context_offs: offset of the RM_*_CONTEXT register
>    * @submodule_wkdep_bit: bit shift of the WKDEP range
> + * @modulemode: allowable modulemodes
> + * @context_lost_counter: Count of module level context lost
>    */
>   struct omap_hwmod_omap4_prcm {
>   	u16		clkctrl_offs;
> @@ -371,6 +374,7 @@ struct omap_hwmod_omap4_prcm {
>   	u16		context_offs;
>   	u8		submodule_wkdep_bit;
>   	u8		modulemode;
> +	unsigned	context_lost_counter;
>   };
>
>

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

* Re: [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-12-16 11:23           ` Paul Walmsley
@ 2011-12-16 12:21             ` Rajendra Nayak
  -1 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-12-16 12:21 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: Cousson, Benoit, linux-omap, tony, linux-arm-kernel

On Friday 16 December 2011 04:53 PM, Paul Walmsley wrote:
> Hi
>
> On Fri, 16 Dec 2011, Paul Walmsley wrote:
>
>> + * XXX Will not work correctly if the RM_*_CONTEXT register
>> + * offset is 0 -- probably a flag should be used to avoid this
>> + * situation, rather than testing @oh->prcm.omap4.context_offs.  No
>> + * return value.
>
> By the way, I'm also worried about this case.  Am wondering if we should
> add a flag here just to be sure, rather than testing the offset.
> Thoughts?

I am not sure if we even have any modules on OMAP4 which *do not*
support module level context loss status and for which we need to fall
back on pwrdm level status. So maybe we could even get rid of the check
for a valid context_offset altogether and expect it to be populated for
all modules as we do with the clkctrl offset.

>
>
> - Paul


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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-12-16 12:21             ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-12-16 12:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 16 December 2011 04:53 PM, Paul Walmsley wrote:
> Hi
>
> On Fri, 16 Dec 2011, Paul Walmsley wrote:
>
>> + * XXX Will not work correctly if the RM_*_CONTEXT register
>> + * offset is 0 -- probably a flag should be used to avoid this
>> + * situation, rather than testing @oh->prcm.omap4.context_offs.  No
>> + * return value.
>
> By the way, I'm also worried about this case.  Am wondering if we should
> add a flag here just to be sure, rather than testing the offset.
> Thoughts?

I am not sure if we even have any modules on OMAP4 which *do not*
support module level context loss status and for which we need to fall
back on pwrdm level status. So maybe we could even get rid of the check
for a valid context_offset altogether and expect it to be populated for
all modules as we do with the clkctrl offset.

>
>
> - Paul

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

* Re: [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-12-16 12:21             ` Rajendra Nayak
@ 2011-12-16 12:38               ` Paul Walmsley
  -1 siblings, 0 replies; 26+ messages in thread
From: Paul Walmsley @ 2011-12-16 12:38 UTC (permalink / raw)
  To: Rajendra Nayak; +Cc: Cousson, Benoit, linux-omap, tony, linux-arm-kernel

On Fri, 16 Dec 2011, Rajendra Nayak wrote:

> On Friday 16 December 2011 04:53 PM, Paul Walmsley wrote:
> > On Fri, 16 Dec 2011, Paul Walmsley wrote:
> > 
> > > + * XXX Will not work correctly if the RM_*_CONTEXT register
> > > + * offset is 0 -- probably a flag should be used to avoid this
> > > + * situation, rather than testing @oh->prcm.omap4.context_offs.  No
> > > + * return value.
> > 
> > By the way, I'm also worried about this case.  Am wondering if we should
> > add a flag here just to be sure, rather than testing the offset.
> > Thoughts?
> 
> I am not sure if we even have any modules on OMAP4 which *do not*
> support module level context loss status and for which we need to fall
> back on pwrdm level status. So maybe we could even get rid of the check
> for a valid context_offset altogether and expect it to be populated for
> all modules as we do with the clkctrl offset.

Okay, we'll probably want to double-check that in the data and make sure 
it's true.  We should probably wait on this one until someone has a chance 
to check that out, I guess during the 3.4 time frame?


- Paul

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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-12-16 12:38               ` Paul Walmsley
  0 siblings, 0 replies; 26+ messages in thread
From: Paul Walmsley @ 2011-12-16 12:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 16 Dec 2011, Rajendra Nayak wrote:

> On Friday 16 December 2011 04:53 PM, Paul Walmsley wrote:
> > On Fri, 16 Dec 2011, Paul Walmsley wrote:
> > 
> > > + * XXX Will not work correctly if the RM_*_CONTEXT register
> > > + * offset is 0 -- probably a flag should be used to avoid this
> > > + * situation, rather than testing @oh->prcm.omap4.context_offs.  No
> > > + * return value.
> > 
> > By the way, I'm also worried about this case.  Am wondering if we should
> > add a flag here just to be sure, rather than testing the offset.
> > Thoughts?
> 
> I am not sure if we even have any modules on OMAP4 which *do not*
> support module level context loss status and for which we need to fall
> back on pwrdm level status. So maybe we could even get rid of the check
> for a valid context_offset altogether and expect it to be populated for
> all modules as we do with the clkctrl offset.

Okay, we'll probably want to double-check that in the data and make sure 
it's true.  We should probably wait on this one until someone has a chance 
to check that out, I guess during the 3.4 time frame?


- Paul

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

* Re: [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-12-16 12:17           ` Rajendra Nayak
@ 2011-12-16 12:38             ` Paul Walmsley
  -1 siblings, 0 replies; 26+ messages in thread
From: Paul Walmsley @ 2011-12-16 12:38 UTC (permalink / raw)
  To: Rajendra Nayak; +Cc: Cousson, Benoit, linux-omap, tony, linux-arm-kernel

On Fri, 16 Dec 2011, Rajendra Nayak wrote:

> On Friday 16 December 2011 04:46 PM, Paul Walmsley wrote:
> > 
> > Hi Rajendra,
> > 
> > I've combined your patches down to one patch and changed the logic a
> > little bit.  It looks to me that the update and clear context registers
> > can be done in one step, since an IP block shouldn't lose context when
> > it's enabled.  But maybe I'm missing something?
> 
> Thanks for the patch. The changes look fine and I also did a quick
> test on an internal tree which supports core OSWR and it seems to
> work fine too.

Great, thanks.  Will wait on this one until you have a chance to tinker 
with it during the 3.4 time frame.


- Paul

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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-12-16 12:38             ` Paul Walmsley
  0 siblings, 0 replies; 26+ messages in thread
From: Paul Walmsley @ 2011-12-16 12:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 16 Dec 2011, Rajendra Nayak wrote:

> On Friday 16 December 2011 04:46 PM, Paul Walmsley wrote:
> > 
> > Hi Rajendra,
> > 
> > I've combined your patches down to one patch and changed the logic a
> > little bit.  It looks to me that the update and clear context registers
> > can be done in one step, since an IP block shouldn't lose context when
> > it's enabled.  But maybe I'm missing something?
> 
> Thanks for the patch. The changes look fine and I also did a quick
> test on an internal tree which supports core OSWR and it seems to
> work fine too.

Great, thanks.  Will wait on this one until you have a chance to tinker 
with it during the 3.4 time frame.


- Paul

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

* Re: [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
  2011-12-16 12:38             ` Paul Walmsley
@ 2011-12-16 12:41               ` Rajendra Nayak
  -1 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-12-16 12:41 UTC (permalink / raw)
  To: Paul Walmsley; +Cc: Cousson, Benoit, linux-omap, tony, linux-arm-kernel

On Friday 16 December 2011 06:08 PM, Paul Walmsley wrote:
> On Fri, 16 Dec 2011, Rajendra Nayak wrote:
>
>> On Friday 16 December 2011 04:46 PM, Paul Walmsley wrote:
>>>
>>> Hi Rajendra,
>>>
>>> I've combined your patches down to one patch and changed the logic a
>>> little bit.  It looks to me that the update and clear context registers
>>> can be done in one step, since an IP block shouldn't lose context when
>>> it's enabled.  But maybe I'm missing something?
>>
>> Thanks for the patch. The changes look fine and I also did a quick
>> test on an internal tree which supports core OSWR and it seems to
>> work fine too.
>
> Great, thanks.  Will wait on this one until you have a chance to tinker
> with it during the 3.4 time frame.

Sure, will work some more on this and maybe re-submit it with open 
switch RET support on OMAP4 when it would really be useful and can
also be tested to work well.

thanks,
Rajendra
>
>
> - Paul


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

* [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported
@ 2011-12-16 12:41               ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2011-12-16 12:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 16 December 2011 06:08 PM, Paul Walmsley wrote:
> On Fri, 16 Dec 2011, Rajendra Nayak wrote:
>
>> On Friday 16 December 2011 04:46 PM, Paul Walmsley wrote:
>>>
>>> Hi Rajendra,
>>>
>>> I've combined your patches down to one patch and changed the logic a
>>> little bit.  It looks to me that the update and clear context registers
>>> can be done in one step, since an IP block shouldn't lose context when
>>> it's enabled.  But maybe I'm missing something?
>>
>> Thanks for the patch. The changes look fine and I also did a quick
>> test on an internal tree which supports core OSWR and it seems to
>> work fine too.
>
> Great, thanks.  Will wait on this one until you have a chance to tinker
> with it during the 3.4 time frame.

Sure, will work some more on this and maybe re-submit it with open 
switch RET support on OMAP4 when it would really be useful and can
also be tested to work well.

thanks,
Rajendra
>
>
> - Paul

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

end of thread, other threads:[~2011-12-16 12:41 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-03 10:54 [PATCH 0/3] Support omap_pm_get_dev_context_loss_count() for OMAP4 Rajendra Nayak
2011-11-03 10:54 ` Rajendra Nayak
2011-11-03 10:54 ` [PATCH 1/3] ARM: OMAP: hmwod: Add support for per hwmod/module context lost count Rajendra Nayak
2011-11-03 10:54   ` Rajendra Nayak
2011-11-03 10:54 ` [PATCH 2/3] ARM: OMAP: hwmod: Update/Clear module specific context lost counters Rajendra Nayak
2011-11-03 10:54   ` Rajendra Nayak
2011-11-03 10:54 ` [PATCH 3/3] ARM: OMAP: hwmod: Look for hwmod/module level context lost count if supported Rajendra Nayak
2011-11-03 10:54   ` Rajendra Nayak
2011-11-29 18:10   ` Cousson, Benoit
2011-11-29 18:10     ` Cousson, Benoit
2011-12-02  4:46     ` Rajendra Nayak
2011-12-02  4:46       ` Rajendra Nayak
2011-12-16 11:16       ` Paul Walmsley
2011-12-16 11:16         ` Paul Walmsley
2011-12-16 11:23         ` Paul Walmsley
2011-12-16 11:23           ` Paul Walmsley
2011-12-16 12:21           ` Rajendra Nayak
2011-12-16 12:21             ` Rajendra Nayak
2011-12-16 12:38             ` Paul Walmsley
2011-12-16 12:38               ` Paul Walmsley
2011-12-16 12:17         ` Rajendra Nayak
2011-12-16 12:17           ` Rajendra Nayak
2011-12-16 12:38           ` Paul Walmsley
2011-12-16 12:38             ` Paul Walmsley
2011-12-16 12:41             ` Rajendra Nayak
2011-12-16 12:41               ` Rajendra Nayak

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.