From: t-kristo@ti.com (Tero Kristo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv5 03/10] ARM: OMAP3: add manual control for mpu / core pwrdm usecounting
Date: Tue, 25 Sep 2012 12:32:38 +0300 [thread overview]
Message-ID: <1348565565-14744-4-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1348565565-14744-1-git-send-email-t-kristo@ti.com>
mpu / core powerdomain usecounts are now statically increased
by 1 during MPU activity. This allows the domains to reflect
actual usage, and will allow the usecount to reach 0 just before
all CPUs are ready to idle. Proper powerdomain usecounts are
propageted to voltagedomain level also, and will allow vc
callbacks to be triggered at right point of time.
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/common.h | 6 ++
arch/arm/mach-omap2/omap-mpuss-lowpower.c | 72 ++++++++++++++++++++++++++++-
arch/arm/mach-omap2/omap-smp.c | 2 +
arch/arm/mach-omap2/pm34xx.c | 21 ++++++++
4 files changed, 100 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 6ea837a..a445a02 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -292,6 +292,8 @@ extern int omap4_finish_suspend(unsigned long cpu_state);
extern void omap4_cpu_resume(void);
extern int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state);
extern u32 omap4_mpuss_read_prev_context_state(void);
+extern void omap4_pm_cpu_online(void);
+extern void omap4_pm_cpu_offline(void);
#else
static inline int omap4_enter_lowpower(unsigned int cpu,
unsigned int power_state)
@@ -323,6 +325,10 @@ static inline u32 omap4_mpuss_read_prev_context_state(void)
{
return 0;
}
+
+static inline void omap4_pm_cpu_online(void) { }
+
+static inline void omap4_pm_cpu_offline(void) { }
#endif
struct omap_sdrc_params;
diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index 230bdcd..0ad2337 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -72,8 +72,9 @@ struct omap4_cpu_pm_info {
};
static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
-static struct powerdomain *mpuss_pd;
+static struct powerdomain *mpuss_pd, *core_pd;
static void __iomem *sar_base;
+static atomic_t __initdata init_cpu_online_count;
/*
* Program the wakeup routine address for the CPU0 and CPU1
@@ -216,6 +217,50 @@ static void save_l2x0_context(void)
#endif
/**
+ * omap4_pm_cpu_online - increase the number of online CPUs
+ *
+ * This function increases the usecounts for MPU and CORE powerdomains,
+ * which allows the domains to properly reflect usage with online CPUs
+ * also. CORE powerdomain usecount is increased, as MPU is using memories,
+ * which are powered through CORE powerdomain (SDRAM). If this function is
+ * called before PM init has completed (mpuss_pd / core_pd are not defined),
+ * a temporary init time variable is increased instead; its contents
+ * will be moved to the powerdomain usecounts once PM init completes.
+ */
+void omap4_pm_cpu_online(void)
+{
+ if (!mpuss_pd || !core_pd) {
+ atomic_inc(&init_cpu_online_count);
+ return;
+ }
+
+ pwrdm_clkdm_enable(mpuss_pd);
+ pwrdm_clkdm_enable(core_pd);
+}
+
+/**
+ * omap4_pm_cpu_offline - decrease the number of online CPUs
+ *
+ * This function decreases the usecounts for MPU and CORE powerdomains,
+ * which allows the domains to properly reflect usage with online CPUs
+ * also. CORE powerdomain usecount is decreased, as MPU is using memories,
+ * which are powered through CORE powerdomain (SDRAM). If this function is
+ * called before PM init has completed (mpuss_pd / core_pd are not defined),
+ * a temporary init time variable is increased instead; its contents
+ * will be moved to the powerdomain usecounts once PM init completes.
+ */
+void omap4_pm_cpu_offline(void)
+{
+ if (!mpuss_pd || !core_pd) {
+ atomic_dec(&init_cpu_online_count);
+ return;
+ }
+
+ pwrdm_clkdm_disable(mpuss_pd);
+ pwrdm_clkdm_disable(core_pd);
+}
+
+/**
* omap4_enter_lowpower: OMAP4 MPUSS Low Power Entry Function
* The purpose of this function is to manage low power programming
* of OMAP4 MPUSS subsystem
@@ -274,11 +319,17 @@ int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state)
scu_pwrst_prepare(cpu, power_state);
l2x0_pwrst_prepare(cpu, save_state);
+ /* Decrement usecounts for MPU and CORE pd as we are entering idle */
+ omap4_pm_cpu_offline();
+
/*
* Call low level function with targeted low power state.
*/
cpu_suspend(save_state, omap4_finish_suspend);
+ /* Increment usecounts for MPU and CORE pd as we are leaving idle */
+ omap4_pm_cpu_online();
+
/*
* Restore the CPUx power state to ON otherwise CPUx
* power domain can transitions to programmed low power
@@ -315,6 +366,8 @@ int __cpuinit omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
set_cpu_wakeup_addr(cpu, virt_to_phys(pm_info->secondary_startup));
scu_pwrst_prepare(cpu, power_state);
+ omap4_pm_cpu_offline();
+
/*
* CPU never retuns back if targeted power state is OFF mode.
* CPU ONLINE follows normal CPU ONLINE ptah via
@@ -322,6 +375,8 @@ int __cpuinit omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
*/
omap4_finish_suspend(cpu_state);
+ omap4_pm_cpu_online();
+
set_cpu_next_pwrst(cpu, PWRDM_FUNC_PWRST_ON);
return 0;
}
@@ -386,9 +441,24 @@ int __init omap4_mpuss_init(void)
pr_err("Failed to lookup MPUSS power domain\n");
return -ENODEV;
}
+ core_pd = pwrdm_lookup("core_pwrdm");
+ if (!core_pd) {
+ pr_err("Failed to lookup CORE power domain\n");
+ return -ENODEV;
+ }
pwrdm_clear_all_prev_pwrst(mpuss_pd);
mpuss_clear_prev_logic_pwrst();
+ /* Notify pwrdm usecounters about active CPU */
+ omap4_pm_cpu_online();
+
+ /*
+ * If CPUs became online / offline during init time, push
+ * the pending counter updates also.
+ */
+ while (atomic_dec_return(&init_cpu_online_count) >= 0)
+ omap4_pm_cpu_online();
+
/* Save device type on scratchpad for low level code to use */
if (omap_type() != OMAP2_DEVICE_TYPE_GP)
__raw_writel(1, sar_base + OMAP_TYPE_OFFSET);
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index b9738e2..f296e35 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -71,6 +71,8 @@ void __cpuinit platform_secondary_init(unsigned int cpu)
*/
gic_secondary_init(0);
+ omap4_pm_cpu_online();
+
/*
* Synchronise with the boot thread.
*/
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 5b6505f..7a423f7 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -294,6 +294,14 @@ void omap_sram_idle(void)
omap3_intc_prepare_idle();
/*
+ * CPU going offline, update pwrdm counters. Core pwrdm
+ * count is decreased as MPU is using SDRAM which resides
+ * under core pwrdm.
+ */
+ pwrdm_clkdm_disable(mpu_pwrdm);
+ pwrdm_clkdm_disable(core_pwrdm);
+
+ /*
* On EMU/HS devices ROM code restores a SRDC value
* from scratchpad which has automatic self refresh on timeout
* of AUTO_CNT = 1 enabled. This takes care of erratum ID i443.
@@ -324,6 +332,12 @@ void omap_sram_idle(void)
core_next_state == PWRDM_FUNC_PWRST_OFF)
sdrc_write_reg(sdrc_pwr, SDRC_POWER);
+ /*
+ * CPU is coming back online, increase pwrdm usecounts
+ */
+ pwrdm_clkdm_enable(mpu_pwrdm);
+ pwrdm_clkdm_enable(core_pwrdm);
+
/* CORE */
if (core_next_state < PWRDM_FUNC_PWRST_ON) {
core_prev_state = pwrdm_read_prev_fpwrst(core_pwrdm);
@@ -718,6 +732,13 @@ int __init omap3_pm_init(void)
omap_pm_suspend = omap3_pm_suspend;
#endif
+ /*
+ * CPU online, increase pwrdm usecounts for MPU and CORE domains.
+ * MPU is using memory subsystem which resides in CORE domain.
+ */
+ pwrdm_clkdm_enable(mpu_pwrdm);
+ pwrdm_clkdm_enable(core_pwrdm);
+
arm_pm_idle = omap3_pm_idle;
omap3_idle_init();
--
1.7.4.1
next prev parent reply other threads:[~2012-09-25 9:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-25 9:32 [PATCHv5 00/10] ARM: OMAP: PM usecounting changes Tero Kristo
2012-09-25 9:32 ` [PATCHv5 01/10] ARM: OMAP3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking Tero Kristo
2012-09-25 9:32 ` [PATCHv5 02/10] ARM: OMAP3+: voltage: add support for voltagedomain usecounts Tero Kristo
2012-09-25 9:41 ` Russell King - ARM Linux
2012-09-25 12:02 ` Tero Kristo
2012-09-25 9:32 ` Tero Kristo [this message]
2012-09-25 9:32 ` [PATCHv5 04/10] ARM: OMAP3: set autoidle flag for sdrc_ick Tero Kristo
2012-09-25 9:32 ` [PATCHv5 05/10] ARM: OMAP: clockdomain: add support for preventing autodep delete Tero Kristo
2012-09-25 9:32 ` [PATCHv5 06/10] ARM: OMAP3: do not delete per_clkdm autodeps during idle Tero Kristo
2012-09-25 9:32 ` [PATCHv5 07/10] ARM: OMAP4: clock data: set autoidle flag for dss_fck Tero Kristo
2012-09-25 9:32 ` [PATCHv5 08/10] ARM: OMAP4: hwmod: add support for hwmod autoidle flag Tero Kristo
2012-09-25 9:32 ` [PATCHv5 09/10] ARM: OMAP4: hwmod data: set mpu hwmod modulemode to hwauto Tero Kristo
2012-09-25 9:32 ` [PATCHv5 10/10] ARM: OMAP4: clock data: flag hw controlled clocks as autoidle Tero Kristo
2012-09-25 10:26 ` [PATCHv5 00/10] ARM: OMAP: PM usecounting changes Rajendra Nayak
2012-09-25 11:53 ` Tero Kristo
2012-09-25 12:23 ` Rajendra Nayak
2012-09-25 14:17 ` Tero Kristo
2012-09-26 4:15 ` Rajendra Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1348565565-14744-4-git-send-email-t-kristo@ti.com \
--to=t-kristo@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).