OMAP2+: powerdomain: add API to get context loss count
Subsystems (5)
PATCH 1/3 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 sum of the powerdomain off-mode counter, the logic off counter and the per-bank memory off counter.
--- arch/arm/mach-omap2/powerdomain.c | 26 ++++++++++++++++++++++++++ arch/arm/mach-omap2/powerdomain.h | 1 + 2 files changed, 27 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/powerdomain.c +26 -0
@@ -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; +}
arch/arm/mach-omap2/powerdomain.h +1 -0
@@ -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 );
Signature · 1 line
1.7.2.1
PATCH 2/3 OMAP: PM: implement context loss count APIs
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.
--- 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(-)
arch/arm/mach-omap2/omap_hwmod.c +22 -0
@@ -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; +}
arch/arm/plat-omap/include/plat/omap-pm.h +2 -2
@@ -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
arch/arm/plat-omap/include/plat/omap_device.h +1 -0
@@ -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 */
arch/arm/plat-omap/include/plat/omap_hwmod.h +1 -0
@@ -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
arch/arm/plat-omap/omap-pm-noop.c +11 -12
@@ -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; }
arch/arm/plat-omap/omap_device.c +28 -0
@@ -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 * *
Signature · 1 line
1.7.2.1
PATCH 3/3 OMAP: PM noop: implement context loss count for non-omap_devices
In reply to Kevin HilmanFor 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
--- 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(-)
arch/arm/mach-omap2/pm-debug.c +5 -0
@@ -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); }
arch/arm/plat-omap/include/plat/omap-pm.h +2 -0
@@ -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
arch/arm/plat-omap/omap-pm-noop.c +36 -2
@@ -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);
Signature · 1 line
1.7.2.1
Paul Walmsley
maintainerPATCH 3/3 OMAP: PM noop: implement context loss count for non-omap_devices
Hi Kevin
Quoted 8 lines · Kevin Hilman
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.
Quoted 5 lines
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 <[email protected]>
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
--- 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(-)
arch/arm/mach-omap2/pm-debug.c +5 -0
@@ -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); }
arch/arm/plat-omap/include/plat/omap-pm.h +2 -0
@@ -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
arch/arm/plat-omap/omap-pm-noop.c +35 -2
@@ -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);
Signature · 1 line
1.7.2.3
Paul Walmsley
maintainerPATCH 3/3 OMAP: PM noop: implement context loss count for non-omap_devices
Quoted 16 lines · Paul Walmsley
Quoted 8 lines · Kevin Hilman
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.
Quoted 5 lines
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.
Quoted 6 lines
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 formatUpdated 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 <[email protected]>
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
--- 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(-)
arch/arm/mach-omap2/pm-debug.c +5 -0
@@ -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); }
arch/arm/plat-omap/include/plat/omap-pm.h +2 -0
@@ -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
arch/arm/plat-omap/omap-pm-noop.c +45 -1
74 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Paul Walmsley
maintainerPATCH 1/3 OMAP2+: powerdomain: add API to get context loss count
In reply to Kevin HilmanHi Kevin
Quoted 10 lines · Kevin Hilman
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 <[email protected]>Signed-off-by Kevin Hilman <[email protected]>
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 <[email protected]>
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.
[paul at pwsan.com: removed bogus return value on error; improved kerneldoc;
tweaked commit message]
--- arch/arm/mach-omap2/powerdomain.c | 29 +++++++++++++++++++++++++++++ arch/arm/mach-omap2/powerdomain.h | 1 + 2 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/powerdomain.c +29 -0
@@ -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; +}
arch/arm/mach-omap2/powerdomain.h +1 -0
@@ -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 );
Signature · 1 line
1.7.2.3
Paul Walmsley
maintainerPATCH 1/3 OMAP2+: powerdomain: add API to get context loss count
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 ofgit://git.pwsan.com/linux-integration - this is based on Tony's new omap-for-linus head at b9e7683bbca638967a56e5d7fd4035a947109621.
- Paul