* [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count
@ 2010-12-18 1:14 Kevin Hilman
2010-12-18 1:14 ` [PATCH 2/3] OMAP: PM: implement context loss count APIs Kevin Hilman
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Kevin Hilman @ 2010-12-18 1:14 UTC (permalink / raw)
To: linux-arm-kernel
Add new powerdomain API
u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm)
for checking how many times the powerdomain has lost context. The
loss count is the sum sum of the powerdomain off-mode counter, the
logic off counter and the per-bank memory off counter.
Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
arch/arm/mach-omap2/powerdomain.c | 26 ++++++++++++++++++++++++++
arch/arm/mach-omap2/powerdomain.h | 1 +
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 06ef60e..b147a82 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -909,3 +909,29 @@ int pwrdm_post_transition(void)
pwrdm_for_each(_pwrdm_post_transition_cb, NULL);
return 0;
}
+
+/**
+ * pwrdm_get_context_loss_count - get powerdomain's context loss count
+ * @pwrdm: struct powerdomain * to wait for
+ *
+ * Context loss count is a sum of powerdomain off-mode counter,
+ * the logic off counter and the per-bank memory off counter.
+ */
+u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm)
+{
+ int i, count;
+
+ if (!pwrdm)
+ return -EINVAL;
+
+ count = pwrdm->state_counter[PWRDM_POWER_OFF];
+ count += pwrdm->ret_logic_off_counter;
+
+ for (i = 0; i < pwrdm->banks; i++)
+ count += pwrdm->ret_mem_off_counter[i];
+
+ pr_debug("powerdomain: %s: context loss count = %u\n",
+ pwrdm->name, count);
+
+ return count;
+}
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index 35b5b48..c66431e 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -211,6 +211,7 @@ int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
int pwrdm_pre_transition(void);
int pwrdm_post_transition(void);
int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
+u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm);
extern void omap2xxx_powerdomains_init(void);
extern void omap3xxx_powerdomains_init(void);
--
1.7.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] OMAP: PM: implement context loss count APIs
2010-12-18 1:14 [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count Kevin Hilman
@ 2010-12-18 1:14 ` Kevin Hilman
2010-12-18 1:14 ` [PATCH 3/3] OMAP: PM noop: implement context loss count for non-omap_devices Kevin Hilman
2010-12-22 2:06 ` [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count Paul Walmsley
2 siblings, 0 replies; 7+ messages in thread
From: Kevin Hilman @ 2010-12-18 1:14 UTC (permalink / raw)
To: linux-arm-kernel
Implement OMAP PM layer omap_pm_get_dev_context_loss_count() API by
creating similar APIs at the omap_device and omap_hwmod levels. The
omap_hwmod level call is the layer with access to the powerdomain
core, so it is the place where the powerdomain is queried to get the
context loss count.
The new APIs return an unsigned value that can wrap as the
context-loss count grows. However, the wrapping is not important as
the role of this function is to determine context loss by checking for
any difference in subsequent calls to this function.
Note that these APIs at each level can return zero when no context
loss is detected, or on errors. This is to avoid returning error
codes which could potentially be mistaken for large context loss
counters.
NOTE: only works for devices which have been converted to use
omap_device/omap_hwmod.
Longer term, we could possibly remove this API from the OMAP PM layer,
and instead directly use the omap_device level API.
Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
arch/arm/mach-omap2/omap_hwmod.c | 22 +++++++++++++++++++
arch/arm/plat-omap/include/plat/omap-pm.h | 4 +-
arch/arm/plat-omap/include/plat/omap_device.h | 1 +
arch/arm/plat-omap/include/plat/omap_hwmod.h | 1 +
arch/arm/plat-omap/omap-pm-noop.c | 23 +++++++++----------
arch/arm/plat-omap/omap_device.c | 28 +++++++++++++++++++++++++
6 files changed, 65 insertions(+), 14 deletions(-)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 81c1097..08da0f3 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2220,3 +2220,25 @@ ohsps_unlock:
return ret;
}
+
+/**
+ * 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 the powerdomain assocated with @oh
+ * upon success, or zero if no powerdomain exists for @oh.
+ */
+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);
+
+ return ret;
+}
diff --git a/arch/arm/plat-omap/include/plat/omap-pm.h b/arch/arm/plat-omap/include/plat/omap-pm.h
index 9870b4f..2f0bee8 100644
--- a/arch/arm/plat-omap/include/plat/omap-pm.h
+++ b/arch/arm/plat-omap/include/plat/omap-pm.h
@@ -368,9 +368,9 @@ unsigned long omap_pm_cpu_get_freq(void);
* driver must restore device context. If the number of context losses
* exceeds the maximum positive integer, the function will wrap to 0 and
* continue counting. Returns the number of context losses for this device,
- * or -EINVAL upon error.
+ * or zero upon error.
*/
-int omap_pm_get_dev_context_loss_count(struct device *dev);
+u32 omap_pm_get_dev_context_loss_count(struct device *dev);
#endif
diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
index 28e2d1a..e4c349f 100644
--- a/arch/arm/plat-omap/include/plat/omap_device.h
+++ b/arch/arm/plat-omap/include/plat/omap_device.h
@@ -107,6 +107,7 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od);
int omap_device_align_pm_lat(struct platform_device *pdev,
u32 new_wakeup_lat_limit);
struct powerdomain *omap_device_get_pwrdm(struct omap_device *od);
+u32 omap_device_get_context_loss_count(struct platform_device *pdev);
/* Other */
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 62bdb23..3fdb574 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -568,6 +568,7 @@ int omap_hwmod_for_each_by_class(const char *classname,
void *user);
int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state);
+u32 omap_hwmod_get_context_loss_count(struct omap_hwmod *oh);
/*
* Chip variant-specific hwmod init routines - XXX should be converted
diff --git a/arch/arm/plat-omap/omap-pm-noop.c b/arch/arm/plat-omap/omap-pm-noop.c
index 7578366..f7d1307 100644
--- a/arch/arm/plat-omap/omap-pm-noop.c
+++ b/arch/arm/plat-omap/omap-pm-noop.c
@@ -20,9 +20,11 @@
#include <linux/init.h>
#include <linux/cpufreq.h>
#include <linux/device.h>
+#include <linux/platform_device.h>
/* Interface documentation is in mach/omap-pm.h */
#include <plat/omap-pm.h>
+#include <plat/omap_device.h>
struct omap_opp *dsp_opps;
struct omap_opp *mpu_opps;
@@ -286,22 +288,19 @@ unsigned long omap_pm_cpu_get_freq(void)
* Device context loss tracking
*/
-int omap_pm_get_dev_context_loss_count(struct device *dev)
+u32 omap_pm_get_dev_context_loss_count(struct device *dev)
{
- if (!dev) {
- WARN_ON(1);
- return -EINVAL;
- };
+ struct platform_device *pdev = to_platform_device(dev);
+ u32 count;
- pr_debug("OMAP PM: returning context loss count for dev %s\n",
- dev_name(dev));
+ if (WARN_ON(!dev))
+ return 0;
- /*
- * Map the device to the powerdomain. Return the powerdomain
- * off counter.
- */
+ count = omap_device_get_context_loss_count(pdev);
+ pr_debug("OMAP PM: context loss count for dev %s = %d\n",
+ dev_name(dev), count);
- return 0;
+ return count;
}
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index abe933c..57adb27 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -280,6 +280,34 @@ static void _add_optional_clock_alias(struct omap_device *od,
/* Public functions for use by core code */
/**
+ * omap_device_get_context_loss_count - get lost context count
+ * @od: struct omap_device *
+ *
+ * Using the primary hwmod, query the context loss count for this
+ * device.
+ *
+ * Callers should consider context for this device lost any time this
+ * function returns a value different than the value the caller got
+ * the last time it called this function.
+ *
+ * If any hwmods exist for the omap_device assoiated with @pdev,
+ * return the context loss counter for that hwmod, otherwise return
+ * zero.
+ */
+u32 omap_device_get_context_loss_count(struct platform_device *pdev)
+{
+ struct omap_device *od;
+ u32 ret = 0;
+
+ od = _find_by_pdev(pdev);
+
+ if (od->hwmods_cnt)
+ ret = omap_hwmod_get_context_loss_count(od->hwmods[0]);
+
+ return ret;
+}
+
+/**
* omap_device_count_resources - count number of struct resource entries needed
* @od: struct omap_device *
*
--
1.7.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] OMAP: PM noop: implement context loss count for non-omap_devices
2010-12-18 1:14 [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count Kevin Hilman
2010-12-18 1:14 ` [PATCH 2/3] OMAP: PM: implement context loss count APIs Kevin Hilman
@ 2010-12-18 1:14 ` Kevin Hilman
2010-12-22 4:38 ` Paul Walmsley
2010-12-22 2:06 ` [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count Paul Walmsley
2 siblings, 1 reply; 7+ messages in thread
From: Kevin Hilman @ 2010-12-18 1:14 UTC (permalink / raw)
To: linux-arm-kernel
For devices which have not (yet) been converted to use omap_device,
implement the context loss counter using the "brutal method" as
originally proposed by Paul Walmsley[1].
The dummy context loss counter is incremented every time it is
checked, but only when off-mode is enabled. When off-mode is
disabled, the dummy counter stops incrementing.
Tested on 36xx/Zoom3 using MMC driver, which is currently the
only in-tree user of this API.
This patch should be reverted after all devices are converted to using
omap_device.
[1] http://marc.info/?l=linux-omap&m=129176260000626&w=2
Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
arch/arm/mach-omap2/pm-debug.c | 5 ++++
arch/arm/plat-omap/include/plat/omap-pm.h | 2 +
arch/arm/plat-omap/omap-pm-noop.c | 38 +++++++++++++++++++++++++++-
3 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index e535082..125f565 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -32,6 +32,7 @@
#include "powerdomain.h"
#include "clockdomain.h"
#include <plat/dmtimer.h>
+#include <plat/omap-pm.h>
#include "cm2xxx_3xxx.h"
#include "prm2xxx_3xxx.h"
@@ -581,6 +582,10 @@ static int option_set(void *data, u64 val)
*option = val;
if (option == &enable_off_mode) {
+ if (val)
+ omap_pm_enable_off_mode();
+ else
+ omap_pm_disable_off_mode();
if (cpu_is_omap34xx())
omap3_pm_off_mode_enable(val);
}
diff --git a/arch/arm/plat-omap/include/plat/omap-pm.h b/arch/arm/plat-omap/include/plat/omap-pm.h
index 2f0bee8..6242b25 100644
--- a/arch/arm/plat-omap/include/plat/omap-pm.h
+++ b/arch/arm/plat-omap/include/plat/omap-pm.h
@@ -372,5 +372,7 @@ unsigned long omap_pm_cpu_get_freq(void);
*/
u32 omap_pm_get_dev_context_loss_count(struct device *dev);
+void omap_pm_enable_off_mode(void);
+void omap_pm_disable_off_mode(void);
#endif
diff --git a/arch/arm/plat-omap/omap-pm-noop.c b/arch/arm/plat-omap/omap-pm-noop.c
index f7d1307..12b2bfe 100644
--- a/arch/arm/plat-omap/omap-pm-noop.c
+++ b/arch/arm/plat-omap/omap-pm-noop.c
@@ -30,6 +30,9 @@ struct omap_opp *dsp_opps;
struct omap_opp *mpu_opps;
struct omap_opp *l3_opps;
+static bool off_mode_enabled;
+static u32 dummy_context_loss_counter;
+
/*
* Device-driver-originated constraints (via board-*.c files)
*/
@@ -284,10 +287,31 @@ unsigned long omap_pm_cpu_get_freq(void)
return 0;
}
+/**
+ * omap_pm_enable_off_mode - notify OMAP PM that off-mode is enabled
+ *
+ * Intended for use only by OMAP PM core code to notify this layer
+ * that off mode has been enabled.
+ */
+void omap_pm_enable_off_mode(void)
+{
+ off_mode_enabled = true;
+}
+
+/**
+ * omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
+ *
+ * Intended for use only by OMAP PM core code to notify this layer
+ * that off mode has been disabled.
+ */
+void omap_pm_disable_off_mode(void)
+{
+ off_mode_enabled = false;
+}
+
/*
* Device context loss tracking
*/
-
u32 omap_pm_get_dev_context_loss_count(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
@@ -296,7 +320,17 @@ u32 omap_pm_get_dev_context_loss_count(struct device *dev)
if (WARN_ON(!dev))
return 0;
- count = omap_device_get_context_loss_count(pdev);
+ if (dev->parent == &omap_device_parent) {
+ count = omap_device_get_context_loss_count(pdev);
+ } else {
+ WARN_ONCE(off_mode_enabled, "using dummy context loss counter, "
+ "device %s should be converted to omap_device.",
+ __func__, dev_name(dev));
+ if (off_mode_enabled)
+ dummy_context_loss_counter++;
+ count = dummy_context_loss_counter;
+ }
+
pr_debug("OMAP PM: context loss count for dev %s = %d\n",
dev_name(dev), count);
--
1.7.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count
2010-12-18 1:14 [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count Kevin Hilman
2010-12-18 1:14 ` [PATCH 2/3] OMAP: PM: implement context loss count APIs Kevin Hilman
2010-12-18 1:14 ` [PATCH 3/3] OMAP: PM noop: implement context loss count for non-omap_devices Kevin Hilman
@ 2010-12-22 2:06 ` Paul Walmsley
2010-12-22 3:26 ` Paul Walmsley
2 siblings, 1 reply; 7+ messages in thread
From: Paul Walmsley @ 2010-12-22 2:06 UTC (permalink / raw)
To: linux-arm-kernel
Hi Kevin
On Fri, 17 Dec 2010, Kevin Hilman wrote:
> Add new powerdomain API
>
> u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm)
>
> for checking how many times the powerdomain has lost context. The
> loss count is the sum sum of the powerdomain off-mode counter, the
> logic off counter and the per-bank memory off counter.
>
> Cc: Paul Walmsley <paul@pwsan.com>
> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
I've updated this patch to tweak the function's comments and to remove the
negative return code from a function returning an u32. Updated patch is
below.
- Paul
From: Kevin Hilman <khilman@deeprootsystems.com>
Date: Fri, 17 Dec 2010 17:14:13 -0800
Subject: [PATCH] OMAP2+: powerdomain: add API to get context loss count
Add new powerdomain API
u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm)
for checking how many times the powerdomain has lost context. The
loss count is the sum of the powerdomain off-mode counter, the
logic off counter and the per-bank memory off counter.
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
[paul at pwsan.com: removed bogus return value on error; improved kerneldoc;
tweaked commit message]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
arch/arm/mach-omap2/powerdomain.c | 29 +++++++++++++++++++++++++++++
arch/arm/mach-omap2/powerdomain.h | 1 +
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 06ef60ee..eaed0df 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -909,3 +909,32 @@ int pwrdm_post_transition(void)
pwrdm_for_each(_pwrdm_post_transition_cb, NULL);
return 0;
}
+
+/**
+ * pwrdm_get_context_loss_count - get powerdomain's context loss count
+ * @pwrdm: struct powerdomain * to wait for
+ *
+ * Context loss count is the sum of powerdomain off-mode counter, the
+ * logic off counter and the per-bank memory off counter. Returns 0
+ * (and WARNs) upon error, otherwise, returns the context loss count.
+ */
+u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm)
+{
+ int i, count;
+
+ if (!pwrdm) {
+ WARN(1, "powerdomain: %s: pwrdm is null\n", __func__);
+ return 0;
+ }
+
+ count = pwrdm->state_counter[PWRDM_POWER_OFF];
+ count += pwrdm->ret_logic_off_counter;
+
+ for (i = 0; i < pwrdm->banks; i++)
+ count += pwrdm->ret_mem_off_counter[i];
+
+ pr_debug("powerdomain: %s: context loss count = %u\n",
+ pwrdm->name, count);
+
+ return count;
+}
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index 35b5b48..c66431e 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -211,6 +211,7 @@ int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
int pwrdm_pre_transition(void);
int pwrdm_post_transition(void);
int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
+u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm);
extern void omap2xxx_powerdomains_init(void);
extern void omap3xxx_powerdomains_init(void);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count
2010-12-22 2:06 ` [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count Paul Walmsley
@ 2010-12-22 3:26 ` Paul Walmsley
0 siblings, 0 replies; 7+ messages in thread
From: Paul Walmsley @ 2010-12-22 3:26 UTC (permalink / raw)
To: linux-arm-kernel
Hi Kevin
I've queued this series for 2.6.38. It is the 'omap_pm_a_2.6.38' branch
on git://git.pwsan.com/linux-2.6.
It's integrated with the other changes I have queued at the
'integration-2.6.38-20101221-008' tag of
git://git.pwsan.com/linux-integration - this is based on Tony's new
omap-for-linus head at b9e7683bbca638967a56e5d7fd4035a947109621.
- Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] OMAP: PM noop: implement context loss count for non-omap_devices
2010-12-18 1:14 ` [PATCH 3/3] OMAP: PM noop: implement context loss count for non-omap_devices Kevin Hilman
@ 2010-12-22 4:38 ` Paul Walmsley
2010-12-22 5:38 ` Paul Walmsley
0 siblings, 1 reply; 7+ messages in thread
From: Paul Walmsley @ 2010-12-22 4:38 UTC (permalink / raw)
To: linux-arm-kernel
Hi Kevin
On Fri, 17 Dec 2010, Kevin Hilman wrote:
> For devices which have not (yet) been converted to use omap_device,
> implement the context loss counter using the "brutal method" as
> originally proposed by Paul Walmsley[1].
>
> The dummy context loss counter is incremented every time it is
> checked, but only when off-mode is enabled. When off-mode is
> disabled, the dummy counter stops incrementing.
>
> Tested on 36xx/Zoom3 using MMC driver, which is currently the
> only in-tree user of this API.
>
> This patch should be reverted after all devices are converted to using
> omap_device.
just FYI this patch generated a compile warning:
arch/arm/plat-omap/omap-pm-noop.c: In function 'omap_pm_get_dev_context_loss_count':
arch/arm/plat-omap/omap-pm-noop.c:322: warning: too many arguments for format
Updated to fix that; here's the version that I merged.
- Paul
From: Kevin Hilman <khilman@deeprootsystems.com>
Date: Tue, 21 Dec 2010 21:31:55 -0700
Subject: [PATCH] OMAP: PM noop: implement context loss count for non-omap_devices
For devices which have not (yet) been converted to use omap_device,
implement the context loss counter using the "brutal method" as
originally proposed by Paul Walmsley[1].
The dummy context loss counter is incremented every time it is
checked, but only when off-mode is enabled. When off-mode is
disabled, the dummy counter stops incrementing.
Tested on 36xx/Zoom3 using MMC driver, which is currently the
only in-tree user of this API.
This patch should be reverted after all devices are converted to using
omap_device.
[1] http://marc.info/?l=linux-omap&m=129176260000626&w=2
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
[paul at pwsan.com: fixed compile warning]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
arch/arm/mach-omap2/pm-debug.c | 5 ++++
arch/arm/plat-omap/include/plat/omap-pm.h | 2 +
arch/arm/plat-omap/omap-pm-noop.c | 37 +++++++++++++++++++++++++++-
3 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index e535082..125f565 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -32,6 +32,7 @@
#include "powerdomain.h"
#include "clockdomain.h"
#include <plat/dmtimer.h>
+#include <plat/omap-pm.h>
#include "cm2xxx_3xxx.h"
#include "prm2xxx_3xxx.h"
@@ -581,6 +582,10 @@ static int option_set(void *data, u64 val)
*option = val;
if (option == &enable_off_mode) {
+ if (val)
+ omap_pm_enable_off_mode();
+ else
+ omap_pm_disable_off_mode();
if (cpu_is_omap34xx())
omap3_pm_off_mode_enable(val);
}
diff --git a/arch/arm/plat-omap/include/plat/omap-pm.h b/arch/arm/plat-omap/include/plat/omap-pm.h
index c07bb44..c0a7520 100644
--- a/arch/arm/plat-omap/include/plat/omap-pm.h
+++ b/arch/arm/plat-omap/include/plat/omap-pm.h
@@ -354,5 +354,7 @@ unsigned long omap_pm_cpu_get_freq(void);
*/
u32 omap_pm_get_dev_context_loss_count(struct device *dev);
+void omap_pm_enable_off_mode(void);
+void omap_pm_disable_off_mode(void);
#endif
diff --git a/arch/arm/plat-omap/omap-pm-noop.c b/arch/arm/plat-omap/omap-pm-noop.c
index af58dad..0287ae7 100644
--- a/arch/arm/plat-omap/omap-pm-noop.c
+++ b/arch/arm/plat-omap/omap-pm-noop.c
@@ -26,6 +26,9 @@
#include <plat/omap-pm.h>
#include <plat/omap_device.h>
+static bool off_mode_enabled;
+static u32 dummy_context_loss_counter;
+
/*
* Device-driver-originated constraints (via board-*.c files)
*/
@@ -280,10 +283,31 @@ unsigned long omap_pm_cpu_get_freq(void)
return 0;
}
+/**
+ * omap_pm_enable_off_mode - notify OMAP PM that off-mode is enabled
+ *
+ * Intended for use only by OMAP PM core code to notify this layer
+ * that off mode has been enabled.
+ */
+void omap_pm_enable_off_mode(void)
+{
+ off_mode_enabled = true;
+}
+
+/**
+ * omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
+ *
+ * Intended for use only by OMAP PM core code to notify this layer
+ * that off mode has been disabled.
+ */
+void omap_pm_disable_off_mode(void)
+{
+ off_mode_enabled = false;
+}
+
/*
* Device context loss tracking
*/
-
u32 omap_pm_get_dev_context_loss_count(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
@@ -292,7 +316,16 @@ u32 omap_pm_get_dev_context_loss_count(struct device *dev)
if (WARN_ON(!dev))
return 0;
- count = omap_device_get_context_loss_count(pdev);
+ if (dev->parent == &omap_device_parent) {
+ count = omap_device_get_context_loss_count(pdev);
+ } else {
+ WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device",
+ dev_name(dev));
+ if (off_mode_enabled)
+ dummy_context_loss_counter++;
+ count = dummy_context_loss_counter;
+ }
+
pr_debug("OMAP PM: context loss count for dev %s = %d\n",
dev_name(dev), count);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] OMAP: PM noop: implement context loss count for non-omap_devices
2010-12-22 4:38 ` Paul Walmsley
@ 2010-12-22 5:38 ` Paul Walmsley
0 siblings, 0 replies; 7+ messages in thread
From: Paul Walmsley @ 2010-12-22 5:38 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, 21 Dec 2010, Paul Walmsley wrote:
> On Fri, 17 Dec 2010, Kevin Hilman wrote:
>
> > For devices which have not (yet) been converted to use omap_device,
> > implement the context loss counter using the "brutal method" as
> > originally proposed by Paul Walmsley[1].
> >
> > The dummy context loss counter is incremented every time it is
> > checked, but only when off-mode is enabled. When off-mode is
> > disabled, the dummy counter stops incrementing.
> >
> > Tested on 36xx/Zoom3 using MMC driver, which is currently the
> > only in-tree user of this API.
> >
> > This patch should be reverted after all devices are converted to using
> > omap_device.
>
> just FYI this patch generated a compile warning:
>
> arch/arm/plat-omap/omap-pm-noop.c: In function 'omap_pm_get_dev_context_loss_count':
> arch/arm/plat-omap/omap-pm-noop.c:322: warning: too many arguments for format
>
> Updated to fix that; here's the version that I merged.
Also, the patch doesn't compile on OMAP1. Here's the fixed version.
The integration tag that contains this patch is
'integration-2.6.38-20101221-015'
- Paul
From: Kevin Hilman <khilman@deeprootsystems.com>
Date: Tue, 21 Dec 2010 21:31:55 -0700
Subject: [PATCH] OMAP: PM noop: implement context loss count for non-omap_devices
For devices which have not (yet) been converted to use omap_device,
implement the context loss counter using the "brutal method" as
originally proposed by Paul Walmsley[1].
The dummy context loss counter is incremented every time it is
checked, but only when off-mode is enabled. When off-mode is
disabled, the dummy counter stops incrementing.
Tested on 36xx/Zoom3 using MMC driver, which is currently the
only in-tree user of this API.
This patch should be reverted after all devices are converted to using
omap_device.
[1] http://marc.info/?l=linux-omap&m=129176260000626&w=2
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
[paul at pwsan.com: fixed compile warning; fixed to compile on OMAP1]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
arch/arm/mach-omap2/pm-debug.c | 5 +++
arch/arm/plat-omap/include/plat/omap-pm.h | 2 +
arch/arm/plat-omap/omap-pm-noop.c | 46 ++++++++++++++++++++++++++++-
3 files changed, 52 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index e535082..125f565 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -32,6 +32,7 @@
#include "powerdomain.h"
#include "clockdomain.h"
#include <plat/dmtimer.h>
+#include <plat/omap-pm.h>
#include "cm2xxx_3xxx.h"
#include "prm2xxx_3xxx.h"
@@ -581,6 +582,10 @@ static int option_set(void *data, u64 val)
*option = val;
if (option == &enable_off_mode) {
+ if (val)
+ omap_pm_enable_off_mode();
+ else
+ omap_pm_disable_off_mode();
if (cpu_is_omap34xx())
omap3_pm_off_mode_enable(val);
}
diff --git a/arch/arm/plat-omap/include/plat/omap-pm.h b/arch/arm/plat-omap/include/plat/omap-pm.h
index c07bb44..c0a7520 100644
--- a/arch/arm/plat-omap/include/plat/omap-pm.h
+++ b/arch/arm/plat-omap/include/plat/omap-pm.h
@@ -354,5 +354,7 @@ unsigned long omap_pm_cpu_get_freq(void);
*/
u32 omap_pm_get_dev_context_loss_count(struct device *dev);
+void omap_pm_enable_off_mode(void);
+void omap_pm_disable_off_mode(void);
#endif
diff --git a/arch/arm/plat-omap/omap-pm-noop.c b/arch/arm/plat-omap/omap-pm-noop.c
index af58dad..b0471bb2 100644
--- a/arch/arm/plat-omap/omap-pm-noop.c
+++ b/arch/arm/plat-omap/omap-pm-noop.c
@@ -26,6 +26,9 @@
#include <plat/omap-pm.h>
#include <plat/omap_device.h>
+static bool off_mode_enabled;
+static u32 dummy_context_loss_counter;
+
/*
* Device-driver-originated constraints (via board-*.c files)
*/
@@ -280,10 +283,34 @@ unsigned long omap_pm_cpu_get_freq(void)
return 0;
}
+/**
+ * omap_pm_enable_off_mode - notify OMAP PM that off-mode is enabled
+ *
+ * Intended for use only by OMAP PM core code to notify this layer
+ * that off mode has been enabled.
+ */
+void omap_pm_enable_off_mode(void)
+{
+ off_mode_enabled = true;
+}
+
+/**
+ * omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
+ *
+ * Intended for use only by OMAP PM core code to notify this layer
+ * that off mode has been disabled.
+ */
+void omap_pm_disable_off_mode(void)
+{
+ off_mode_enabled = false;
+}
+
/*
* Device context loss tracking
*/
+#ifdef CONFIG_ARCH_OMAP2PLUS
+
u32 omap_pm_get_dev_context_loss_count(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
@@ -292,13 +319,30 @@ u32 omap_pm_get_dev_context_loss_count(struct device *dev)
if (WARN_ON(!dev))
return 0;
- count = omap_device_get_context_loss_count(pdev);
+ if (dev->parent == &omap_device_parent) {
+ count = omap_device_get_context_loss_count(pdev);
+ } else {
+ WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device",
+ dev_name(dev));
+ if (off_mode_enabled)
+ dummy_context_loss_counter++;
+ count = dummy_context_loss_counter;
+ }
+
pr_debug("OMAP PM: context loss count for dev %s = %d\n",
dev_name(dev), count);
return count;
}
+#else
+
+u32 omap_pm_get_dev_context_loss_count(struct device *dev)
+{
+ return dummy_context_loss_counter;
+}
+
+#endif
/* Should be called before clk framework init */
int __init omap_pm_if_early_init(void)
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-12-22 5:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-18 1:14 [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count Kevin Hilman
2010-12-18 1:14 ` [PATCH 2/3] OMAP: PM: implement context loss count APIs Kevin Hilman
2010-12-18 1:14 ` [PATCH 3/3] OMAP: PM noop: implement context loss count for non-omap_devices Kevin Hilman
2010-12-22 4:38 ` Paul Walmsley
2010-12-22 5:38 ` Paul Walmsley
2010-12-22 2:06 ` [PATCH 1/3] OMAP2+: powerdomain: add API to get context loss count Paul Walmsley
2010-12-22 3:26 ` Paul Walmsley
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).