From: Paul Walmsley <paul@pwsan.com> To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Kevin Hilman <khilman@deeprootsystems.com> Subject: [PATCH 08/12] ARM: OMAP2+: powerdomain: cache the powerdomain's previous power state Date: Sun, 09 Dec 2012 13:03:27 -0700 [thread overview] Message-ID: <20121209200326.3196.35867.stgit@dusk.lan> (raw) In-Reply-To: <20121209200108.3196.12452.stgit@dusk.lan> Cache the powerdomain previous power state registers. The objective here is to avoid unneeded reads from the previous power state registers. Reads from these registers can be extremely slow, even by I/O device standards. I no longer recall the exact measurements, but my recollection was that they cost several microseconds. The cache is invalidated as part of the powerdomain pre-transition code, which runs shortly before WFI/WFE. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Kevin Hilman <khilman@deeprootsystems.com> --- arch/arm/mach-omap2/powerdomain.c | 9 +++++++++ arch/arm/mach-omap2/powerdomain.h | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index 425c868..f5e2727 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c @@ -499,6 +499,9 @@ static int _pwrdm_read_prev_fpwrst(struct powerdomain *pwrdm) if (!_pwrdm_pwrst_can_change(pwrdm)) return PWRDM_FUNC_PWRST_ON; + if (pwrdm->_flags & _PWRDM_PREV_FPWRST_IS_VALID) + return pwrdm->prev_fpwrst; + pwrst = arch_pwrdm->pwrdm_read_prev_pwrst(pwrdm); if (pwrst < 0) return pwrst; @@ -512,6 +515,10 @@ static int _pwrdm_read_prev_fpwrst(struct powerdomain *pwrdm) } ret = _pwrdm_pwrst_to_fpwrst(pwrdm, pwrst, logic_pwrst, &fpwrst); + if (!ret) { + pwrdm->prev_fpwrst = fpwrst; + pwrdm->_flags |= _PWRDM_PREV_FPWRST_IS_VALID; + } return (ret) ? ret : fpwrst; } @@ -1017,6 +1024,8 @@ int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm) pr_debug("powerdomain: %s: clearing previous power state reg\n", pwrdm->name); + pwrdm->_flags &= ~_PWRDM_PREV_FPWRST_IS_VALID; + if (arch_pwrdm && arch_pwrdm->pwrdm_clear_all_prev_pwrst) ret = arch_pwrdm->pwrdm_clear_all_prev_pwrst(pwrdm); diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h index 1fb21f5..f4a189a 100644 --- a/arch/arm/mach-omap2/powerdomain.h +++ b/arch/arm/mach-omap2/powerdomain.h @@ -90,8 +90,17 @@ enum pwrdm_func_state { * powerdomain's next-functional-power-state -- struct * powerdomain.next_fpwrst -- is valid. If this bit is not set, * the code needs to load the current value from the hardware. + * + * _PWRDM_PREV_FPWRST_IS_VALID: the locally-cached copy of the + * powerdomain's previous-functional-power-state -- struct + * powerdomain.prev_fpwrst -- is valid. If this bit is not set, + * the code needs to load the current value from the hardware. The + * previous-functional-power-state cache for the CORE and MPU needs + * to be invalidated right before WFI, unless they were not programmed + * to change power states. */ #define _PWRDM_NEXT_FPWRST_IS_VALID BIT(0) +#define _PWRDM_PREV_FPWRST_IS_VALID BIT(1) /* * Number of memory banks that are power-controllable. On OMAP4430, the @@ -138,6 +147,7 @@ struct powerdomain; * @fpwrst: current func power state (set in pwrdm_state_switch() or post_trans) * @fpwrst_counter: estimated number of times the pwrdm entered the power states * @next_fpwrst: cache of the powerdomain's next-power-state + * @prev_fpwrst: cache of the powerdomain's previous-power-state bitfield * @timer: sched_clock() timestamp of last pwrdm_state_switch() * @fpwrst_timer: estimated nanoseconds of residency in the various power states * @_lock: spinlock used to serialize powerdomain and some clockdomain ops @@ -146,6 +156,9 @@ struct powerdomain; * * @prcm_partition possible values are defined in mach-omap2/prcm44xx.h. * + * @prev_fpwrst is updated during pwrdm_pre_transition(), but presumably + * should also be updated upon clock/IP block idle transitions. + * * Possible values for @_flags are documented above in the * "Powerdomain internal flags (struct powerdomain._flags)" comments. */ @@ -165,6 +178,7 @@ struct powerdomain { const u8 prcm_partition; u8 fpwrst; u8 next_fpwrst; + u8 prev_fpwrst; u8 _flags; struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS]; struct list_head node;
WARNING: multiple messages have this Message-ID (diff)
From: paul@pwsan.com (Paul Walmsley) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 08/12] ARM: OMAP2+: powerdomain: cache the powerdomain's previous power state Date: Sun, 09 Dec 2012 13:03:27 -0700 [thread overview] Message-ID: <20121209200326.3196.35867.stgit@dusk.lan> (raw) In-Reply-To: <20121209200108.3196.12452.stgit@dusk.lan> Cache the powerdomain previous power state registers. The objective here is to avoid unneeded reads from the previous power state registers. Reads from these registers can be extremely slow, even by I/O device standards. I no longer recall the exact measurements, but my recollection was that they cost several microseconds. The cache is invalidated as part of the powerdomain pre-transition code, which runs shortly before WFI/WFE. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Kevin Hilman <khilman@deeprootsystems.com> --- arch/arm/mach-omap2/powerdomain.c | 9 +++++++++ arch/arm/mach-omap2/powerdomain.h | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index 425c868..f5e2727 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c @@ -499,6 +499,9 @@ static int _pwrdm_read_prev_fpwrst(struct powerdomain *pwrdm) if (!_pwrdm_pwrst_can_change(pwrdm)) return PWRDM_FUNC_PWRST_ON; + if (pwrdm->_flags & _PWRDM_PREV_FPWRST_IS_VALID) + return pwrdm->prev_fpwrst; + pwrst = arch_pwrdm->pwrdm_read_prev_pwrst(pwrdm); if (pwrst < 0) return pwrst; @@ -512,6 +515,10 @@ static int _pwrdm_read_prev_fpwrst(struct powerdomain *pwrdm) } ret = _pwrdm_pwrst_to_fpwrst(pwrdm, pwrst, logic_pwrst, &fpwrst); + if (!ret) { + pwrdm->prev_fpwrst = fpwrst; + pwrdm->_flags |= _PWRDM_PREV_FPWRST_IS_VALID; + } return (ret) ? ret : fpwrst; } @@ -1017,6 +1024,8 @@ int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm) pr_debug("powerdomain: %s: clearing previous power state reg\n", pwrdm->name); + pwrdm->_flags &= ~_PWRDM_PREV_FPWRST_IS_VALID; + if (arch_pwrdm && arch_pwrdm->pwrdm_clear_all_prev_pwrst) ret = arch_pwrdm->pwrdm_clear_all_prev_pwrst(pwrdm); diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h index 1fb21f5..f4a189a 100644 --- a/arch/arm/mach-omap2/powerdomain.h +++ b/arch/arm/mach-omap2/powerdomain.h @@ -90,8 +90,17 @@ enum pwrdm_func_state { * powerdomain's next-functional-power-state -- struct * powerdomain.next_fpwrst -- is valid. If this bit is not set, * the code needs to load the current value from the hardware. + * + * _PWRDM_PREV_FPWRST_IS_VALID: the locally-cached copy of the + * powerdomain's previous-functional-power-state -- struct + * powerdomain.prev_fpwrst -- is valid. If this bit is not set, + * the code needs to load the current value from the hardware. The + * previous-functional-power-state cache for the CORE and MPU needs + * to be invalidated right before WFI, unless they were not programmed + * to change power states. */ #define _PWRDM_NEXT_FPWRST_IS_VALID BIT(0) +#define _PWRDM_PREV_FPWRST_IS_VALID BIT(1) /* * Number of memory banks that are power-controllable. On OMAP4430, the @@ -138,6 +147,7 @@ struct powerdomain; * @fpwrst: current func power state (set in pwrdm_state_switch() or post_trans) * @fpwrst_counter: estimated number of times the pwrdm entered the power states * @next_fpwrst: cache of the powerdomain's next-power-state + * @prev_fpwrst: cache of the powerdomain's previous-power-state bitfield * @timer: sched_clock() timestamp of last pwrdm_state_switch() * @fpwrst_timer: estimated nanoseconds of residency in the various power states * @_lock: spinlock used to serialize powerdomain and some clockdomain ops @@ -146,6 +156,9 @@ struct powerdomain; * * @prcm_partition possible values are defined in mach-omap2/prcm44xx.h. * + * @prev_fpwrst is updated during pwrdm_pre_transition(), but presumably + * should also be updated upon clock/IP block idle transitions. + * * Possible values for @_flags are documented above in the * "Powerdomain internal flags (struct powerdomain._flags)" comments. */ @@ -165,6 +178,7 @@ struct powerdomain { const u8 prcm_partition; u8 fpwrst; u8 next_fpwrst; + u8 prev_fpwrst; u8 _flags; struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS]; struct list_head node;
next prev parent reply other threads:[~2012-12-09 20:05 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-12-09 20:02 [PATCH 00/12] ARM: OMAP2+: powerdomain updates after the functional power state conversion Paul Walmsley 2012-12-09 20:02 ` Paul Walmsley 2012-12-09 20:02 ` [PATCH 01/12] ARM: OMAP2+: powerdomain: consolidate arch_pwrdm check code Paul Walmsley 2012-12-09 20:02 ` Paul Walmsley 2012-12-09 20:03 ` [PATCH 02/12] ARM: OMAP2+: PM/powerdomain: move the power state time tracking into the powerdomain code Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley 2012-12-09 20:03 ` [PATCH 03/12] ARM: OMAP2+: powerdomain: split pwrdm_state_switch() Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley 2012-12-09 20:03 ` [PATCH 04/12] ARM: OMAP2+: PM: clean up some debugfs functions Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley 2012-12-09 20:03 ` [PATCH 05/12] ARM: OMAP2+: powerdomain: remove some redundant checks; add some notes Paul Walmsley 2012-12-09 20:03 ` [PATCH 06/12] ARM: OMAP2+: CM: use the cached copy of the clockdomain's hwsup state Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley 2012-12-09 20:03 ` [PATCH 07/12] ARM: OMAP2+: powerdomain: cache the powerdomain next power state Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley [this message] 2012-12-09 20:03 ` [PATCH 08/12] ARM: OMAP2+: powerdomain: cache the powerdomain's previous " Paul Walmsley 2012-12-09 20:03 ` [PATCH 09/12] ARM: OMAP2+: powerdomain: skip register reads for powerdomains known to be on Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley 2012-12-12 10:22 ` Vaibhav Hiremath 2012-12-12 10:22 ` Vaibhav Hiremath 2012-12-19 21:09 ` Jon Hunter 2012-12-19 21:09 ` Jon Hunter 2012-12-20 17:22 ` Paul Walmsley 2012-12-20 17:22 ` Paul Walmsley 2012-12-21 6:33 ` Santosh Shilimkar 2012-12-21 6:33 ` Santosh Shilimkar 2012-12-26 6:21 ` Bedia, Vaibhav 2012-12-26 6:21 ` Bedia, Vaibhav 2012-12-26 6:31 ` Bedia, Vaibhav 2012-12-26 6:31 ` Bedia, Vaibhav 2012-12-26 20:49 ` Paul Walmsley 2012-12-26 20:49 ` Paul Walmsley 2012-12-09 20:03 ` [PATCH 10/12] ARM: OMAP2+: powerdomain: skip previous-power-state read if next_pwrst is ON Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley 2012-12-09 20:03 ` [PATCH 11/12] ARM: OMAP2xxx: powerdomain: add previous power state tracking Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley 2012-12-09 20:03 ` [PATCH 12/12] ARM: OMAP2xxx: PM: add pwrdm_(pre|post)_transition() calls to the 2xxx PM code Paul Walmsley 2012-12-09 20:03 ` Paul Walmsley 2013-01-04 14:26 ` [PATCH 00/12] ARM: OMAP2+: powerdomain updates after the functional power state conversion Tero Kristo 2013-01-04 14:26 ` Tero Kristo
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=20121209200326.3196.35867.stgit@dusk.lan \ --to=paul@pwsan.com \ --cc=khilman@deeprootsystems.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-omap@vger.kernel.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.