Skip to contentSkip to conversation

OMAP: hmwod: Update the sysc_cache in case module context is lost

PATCH Superseded Rajendra Nayak 4 participants 8 messages Oct 14, 2010 – Oct 21, 2010

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 OMAP: hmwod: Update the sysc_cache in case module context is lost

Do not skip the sysc programming in the hmwod framework based on the cached value alone, since at times the module might have lost context (due to the Powerdomain in which the module belongs transitions to either Open Switch RET or OFF).

Cc Paul Walmsley <[email protected]>
Cc Benoit Cousson <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 arch/arm/mach-omap2/omap_hwmod.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +4 -1
index cb911d7..e57fe21 100644
@@ -115,7 +115,10 @@ static void _write_sysconfig(u32 v, struct omap_hwmod *oh)
 
 	/* XXX ensure module interface clock is up */
 
-	if (oh->_sysc_cache != v) {
+	if ((oh->_sysc_cache != v) ||
+		/* Did the module go to off and loose context? */
+		(oh->_sysc_cache !=
+			 omap_hwmod_readl(oh, oh->class->sysc->sysc_offs))) {
 		oh->_sysc_cache = v;
 		omap_hwmod_writel(v, oh, oh->class->sysc->sysc_offs);
 	}
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 4 lines · Rajendra Nayak

Do not skip the sysc programming in the hmwod framework based on the cached value alone, since at times the module might have lost context (due to the Powerdomain in which the module belongs transitions to either Open Switch RET or OFF).

Shouldn't the driver for each IP be responsible for restoring it's register contents after context loss, including it's SYSC?

Seems to me that if SYSC is lost, it means the driver's save/restore is buggy.

Kevin

Quoted 25 lines
Cc Paul Walmsley <[email protected]>
Cc Benoit Cousson <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 arch/arm/mach-omap2/omap_hwmod.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +4 -1
index cb911d7..e57fe21 100644
@@ -115,7 +115,10 @@ static void _write_sysconfig(u32 v, struct omap_hwmod *oh)
 
 	/* XXX ensure module interface clock is up */
 
-	if (oh->_sysc_cache != v) {
+	if ((oh->_sysc_cache != v) ||
+		/* Did the module go to off and loose context? */
+		(oh->_sysc_cache !=
+			 omap_hwmod_readl(oh, oh->class->sysc->sysc_offs))) {
 		oh->_sysc_cache = v;
 		omap_hwmod_writel(v, oh, oh->class->sysc->sysc_offs);
 	}
#2 lore raw
Quoted 16 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, October 15, 2010 3:44 AM
To: Nayak, Rajendra
Cc: [email protected]; Paul Walmsley; Cousson, Benoit; Shilimkar, Santosh
Subject: Re: [PATCH] OMAP: hmwod: Update the sysc_cache in case module context is lost

Quoted 4 lines · Rajendra Nayak

Do not skip the sysc programming in the hmwod framework based on the cached value alone, since at times the module might have lost context (due to the Powerdomain in which the module belongs transitions to either Open Switch RET or OFF).

Quoted 6 lines

Shouldn't the driver for each IP be responsible for restoring it's register contents after context loss, including it's SYSC?

Seems to me that if SYSC is lost, it means the driver's save/restore is buggy.

I am glad you asked this question. I had a same argument with Benoit that driver anyway does context save restore for other registers and it can do SYSC as well.

But Benoit's point was that "sysconfig is a part of the PRCM located in the IP, but this is purely TI implementation specific. The same IP in another platform will not have this sysconfig entry. That's why its important to hide them from the driver "

This make sense too.

Quoted 28 lines

arch/arm/mach-

Quoted 11 lines
Cc Paul Walmsley <[email protected]>
Cc Benoit Cousson <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 arch/arm/mach-omap2/omap_hwmod.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-omap2/omap_hwmod.c +0 -0

omap2/omap_hwmod.c

arch/arm/mach-omap2/omap_hwmod.c static void _write_sysconfig(u32 v, struct

Quoted 4 lines

index cb911d7..e57fe21 100644

arch/arm/mach-omap2/omap_hwmod.c +0 -0
@@ -115,7 +115,10 @@ static void _write_sysconfig(u32 v, struct

omap_hwmod *oh)

Quoted 11 lines
arch/arm/mach-omap2/omap_hwmod.c +4 -1
 	/* XXX ensure module interface clock is up */
 
-	if (oh->_sysc_cache != v) {
+	if ((oh->_sysc_cache != v) ||
+		/* Did the module go to off and loose context? */
+		(oh->_sysc_cache !=
+			 omap_hwmod_readl(oh, oh->class->sysc->sysc_offs))) {
 		oh->_sysc_cache = v;
 		omap_hwmod_writel(v, oh, oh->class->sysc->sysc_offs);
 	}
#3 lore raw

Hi Santosh,

Quoted 16 lines · Santosh
Quoted 10 lines

From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, October 15, 2010 3:44 AM

Quoted 4 lines · Rajendra Nayak

Do not skip the sysc programming in the hmwod framework based on the cached value alone, since at times the module might have lost context (due to the Powerdomain in which the module belongs transitions to either Open Switch RET or OFF).

Quoted 6 lines

Shouldn't the driver for each IP be responsible for restoring it's register contents after context loss, including it's SYSC?

Seems to me that if SYSC is lost, it means the driver's save/restore is buggy.

Quoted 8 lines

I am glad you asked this question. I had a same argument with Benoit that driver anyway does context save restore for other registers and it can do SYSC as well.

But Benoit's point was that "sysconfig is a part of the PRCM located in the IP, but this is purely TI implementation specific. The same IP in another platform will not have this sysconfig entry. That's why its important to hide them from the driver "

I don't have anything to add :-)

Thanks Santosh,
Benoit

Quoted 31 lines

This make sense too.

Quoted 28 lines

arch/arm/mach-

Quoted 11 lines
Cc Paul Walmsley<[email protected]>
Cc Benoit Cousson<[email protected]>
Cc Santosh Shilimkar<[email protected]>
Cc Kevin Hilman<[email protected]>
---
  arch/arm/mach-omap2/omap_hwmod.c |    5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-omap2/omap_hwmod.c +0 -0

omap2/omap_hwmod.c

arch/arm/mach-omap2/omap_hwmod.c static void _write_sysconfig(u32 v, struct

Quoted 4 lines

index cb911d7..e57fe21 100644

arch/arm/mach-omap2/omap_hwmod.c +0 -0
@@ -115,7 +115,10 @@ static void _write_sysconfig(u32 v, struct

omap_hwmod *oh)

Quoted 11 lines
arch/arm/mach-omap2/omap_hwmod.c +4 -1
  	/* XXX ensure module interface clock is up */
 
-	if (oh->_sysc_cache != v) {
+	if ((oh->_sysc_cache != v) ||
+		/* Did the module go to off and loose context? */
+		(oh->_sysc_cache !=
+			 omap_hwmod_readl(oh, oh->class->sysc->sysc_offs))) {
  		oh->_sysc_cache = v;
  		omap_hwmod_writel(v, oh, oh->class->sysc->sysc_offs);
  	}
#4 lore raw
In reply to Shilimkar, Santosh
Quoted 22 lines · Santosh
Quoted 16 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, October 15, 2010 3:44 AM
To: Nayak, Rajendra
Cc: [email protected]; Paul Walmsley; Cousson, Benoit; Shilimkar, Santosh
Subject: Re: [PATCH] OMAP: hmwod: Update the sysc_cache in case module context is lost

Quoted 4 lines · Rajendra Nayak

Do not skip the sysc programming in the hmwod framework based on the cached value alone, since at times the module might have lost context (due to the Powerdomain in which the module belongs transitions to either Open Switch RET or OFF).

Quoted 5 lines

Shouldn't the driver for each IP be responsible for restoring it's register contents after context loss, including it's SYSC?

Seems to me that if SYSC is lost, it means the driver's save/restore is buggy.

Quoted 8 lines

I am glad you asked this question. I had a same argument with Benoit that driver anyway does context save restore for other registers and it can do SYSC as well.

But Benoit's point was that "sysconfig is a part of the PRCM located in the IP, but this is purely TI implementation specific. The same IP in another platform will not have this sysconfig entry. That's why its important to hide them from the driver "

OK, but this patch still doesn't address the real problem. Namely, that *somebody* needs to save/restore the SYSC reg for the IP.

Otherwise, all this patch does is refresh the _sysc_cache with completely unknown contents. It also somewhat defeats the purpose of having a cache. If you're going to read SYSC in order to determine whether or not you can avoid a write, you might as well just blindly write.

One option to fix the save/restore would be that TI specific context save/restore could be done in the device layer by adding some additional save/restore do the functions calling omap_device_[idle|enable].

IOW, most devices just call omap_device directly by doing something like:

struct omap_device_pm_latency omap_wdt_latency[] = {
[0] = {
.deactivate_func = omap_device_idle_hwmods,
.activate_func = omap_device_enable_hwmods,
.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
},
};

But these [de]activate functions can be anything, and could be made into functions that do some additional save/restore and then call omap_device_*

Kevin

#5 lore raw
Quoted 37 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, October 15, 2010 9:10 PM
To: Shilimkar, Santosh
Cc: Nayak, Rajendra; [email protected]; Paul Walmsley; Cousson, Benoit
Subject: Re: [PATCH] OMAP: hmwod: Update the sysc_cache in case module context is lost

Quoted 26 lines · Santosh
Quoted 16 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, October 15, 2010 3:44 AM
To: Nayak, Rajendra
Cc: [email protected]; Paul Walmsley; Cousson, Benoit; Shilimkar, Santosh
Subject: Re: [PATCH] OMAP: hmwod: Update the sysc_cache in case module context is lost

Quoted 4 lines · Rajendra Nayak

Do not skip the sysc programming in the hmwod framework based on the cached value alone, since at times the module might have lost context (due to the Powerdomain in which the module belongs transitions to either Open Switch RET or OFF).

Quoted 5 lines

Shouldn't the driver for each IP be responsible for restoring it's register contents after context loss, including it's SYSC?

Seems to me that if SYSC is lost, it means the driver's save/restore is buggy.

I am glad you asked this question. I had a same argument with Benoit that driver anyway does context save restore for other registers and it can do SYSC as well.

Quoted 7 lines
Quoted 4 lines

But Benoit's point was that "sysconfig is a part of the PRCM located in the IP, but this is purely TI implementation specific. The same IP in another platform will not have this sysconfig entry. That's why its important to hide them from the driver "

OK, but this patch still doesn't address the real problem. Namely, that *somebody* needs to save/restore the SYSC reg for the IP.

Hi Kevin,

What the patch does is reprogram's the sysc value (from the cache) whenever its lost. So its infact saved in the cache and restored when needed.

Quoted 6 lines

Otherwise, all this patch does is refresh the _sysc_cache with completely unknown contents. It also somewhat defeats the purpose of having a cache. If you're going to read SYSC in order to determine whether or not you can avoid a write, you might as well just blindly write.

I thought of this and dismissed it thinking I would end up with a read/or/write and instead a read always to avoid write is better.
But now looking back again, it does make sense to still keep the cache to avoid a read (since a read has significantly more latency than write) and do a blind write always. Does that make sense?

Regards,
Rajendra

Quoted 21 lines

One option to fix the save/restore would be that TI specific context save/restore could be done in the device layer by adding some additional save/restore do the functions calling omap_device_[idle|enable].

IOW, most devices just call omap_device directly by doing something like:

struct omap_device_pm_latency omap_wdt_latency[] = {
[0] = {
.deactivate_func = omap_device_idle_hwmods,
.activate_func = omap_device_enable_hwmods,
.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
},
};

But these [de]activate functions can be anything, and could be made into functions that do some additional save/restore and then call omap_device_*

Kevin

#6 lore raw

On 10/21/2010 12:13 PM, Nayak, Rajendra wrote:

<snip>

Quoted 13 lines

Hi Kevin,

What the patch does is reprogram's the sysc value (from the cache) whenever its lost. So its infact saved in the cache and restored when needed.

Quoted 6 lines

Otherwise, all this patch does is refresh the _sysc_cache with completely unknown contents. It also somewhat defeats the purpose of having a cache. If you're going to read SYSC in order to determine whether or not you can avoid a write, you might as well just blindly write.

Quoted 5 lines

I thought of this and dismissed it thinking I would end up with a read/or/write and instead a read always to avoid write is better.
But now looking back again, it does make sense to still keep the cache to avoid a read (since a read has significantly more latency than write) and do a blind write always. Does that make sense?

That seems indeed better. The point is that cache is already a location for the "save" part. So writing blindly will do the restore with always the good value.
It is anyway faster than trying to check if we lost context or not through PRM registers.

Benoit

#7 lore raw
In reply to Nayak, Rajendra
Quoted 56 lines · Rajendra
Quoted 35 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, October 15, 2010 9:10 PM
To: Shilimkar, Santosh
Cc: Nayak, Rajendra; [email protected]; Paul Walmsley; Cousson, Benoit
Subject: Re: [PATCH] OMAP: hmwod: Update the sysc_cache in case module context is lost

Quoted 26 lines · Santosh
Quoted 16 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, October 15, 2010 3:44 AM
To: Nayak, Rajendra
Cc: [email protected]; Paul Walmsley; Cousson, Benoit; Shilimkar, Santosh
Subject: Re: [PATCH] OMAP: hmwod: Update the sysc_cache in case module context is lost

Quoted 4 lines · Rajendra Nayak

Do not skip the sysc programming in the hmwod framework based on the cached value alone, since at times the module might have lost context (due to the Powerdomain in which the module belongs transitions to either Open Switch RET or OFF).

Quoted 5 lines

Shouldn't the driver for each IP be responsible for restoring it's register contents after context loss, including it's SYSC?

Seems to me that if SYSC is lost, it means the driver's save/restore is buggy.

I am glad you asked this question. I had a same argument with Benoit that driver anyway does context save restore for other registers and it can do SYSC as well.

Quoted 7 lines
Quoted 4 lines

But Benoit's point was that "sysconfig is a part of the PRCM located in the IP, but this is purely TI implementation specific. The same IP in another platform will not have this sysconfig entry. That's why its important to hide them from the driver "

OK, but this patch still doesn't address the real problem. Namely, that *somebody* needs to save/restore the SYSC reg for the IP.

Hi Kevin,

What the patch does is reprogram's the sysc value (from the cache) whenever its lost. So its infact saved in the cache and restored when needed.

Quoted 6 lines

Otherwise, all this patch does is refresh the _sysc_cache with completely unknown contents. It also somewhat defeats the purpose of having a cache. If you're going to read SYSC in order to determine whether or not you can avoid a write, you might as well just blindly write.

Quoted 5 lines

I thought of this and dismissed it thinking I would end up with a read/or/write and instead a read always to avoid write is better.
But now looking back again, it does make sense to still keep the cache to avoid a read (since a read has significantly more latency than write) and do a blind write always. Does that make sense?

Makes sense to me.

Kevin