From: Kevin Hilman <khilman@deeprootsystems.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: "Woodruff, Richard" <r-woodruff2@ti.com>,
"linux-arm-kernel@lists.arm.linux.org.uk"
<linux-arm-kernel@lists.arm.linux.org.uk>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
Jouni Hogander <jouni.hogander@nokia.com>,
Paul Walmsley <paul@pwsan.com>
Subject: Re: [PATCH 01/11] OMAP2/3: PM: push core PM code from linux-omap
Date: Mon, 18 May 2009 17:23:26 -0700 [thread overview]
Message-ID: <87ws8e7xfl.fsf@deeprootsystems.com> (raw)
In-Reply-To: <20090518202431.GM7042@n2100.arm.linux.org.uk> (Russell King's message of "Mon\, 18 May 2009 21\:24\:31 +0100")
Russell King - ARM Linux <linux@arm.linux.org.uk> writes:
> On Mon, May 18, 2009 at 02:04:19PM -0500, Woodruff, Richard wrote:
>> cpu_init() is not yet accessible at the point this code is running.
>
> Not at that _exact_ point, but there's no need what so ever for it
> to be at that exact point. There's nothing stopping a call to
> cpu_init() happening later. Much later.
>
>> You could reduce the context perhaps trying to optimize to what the
>> Linux-ARM implementation is today or do a more generic save like is
>> there now.
>>
>> This code is copied into place from the .S code into SRAM. Its
>> position independent and is not linked for this address. If you want
>> to call functions outside of it you need to manually setup linkage.
>
> I wouldn't want to.
>
>> Calling functions on the way _UP_ from wake is NOT easy (like the one
>> you propose) as the MMU is not yet enabled. The MMU is enabled only
>> below this. Calling cpu_init() is not do able here. Even if you
>> dress up the calling pointer to the physical address, it won't work
>> as cpu_init() makes a global variable dereferences (smp_processor_id
>> & stacks[]).
>
> As long as IRQs and FIQs are disabled, you are in a 100% predictable
> environment.
>
> 1. No IRQ or FIQ will be entered; if they are the CPU is buggy.
> 2. No data or prefetch abort will be entered _unless_ you purposely
> access some non-present memory (and you're not exactly going to
> start paging memory in with IRQs disabled.)
>
> So restoring the abort and IRQ mode register state is just plain not
> necessary in your SRAM code.
>
> Let's look at the code. Here are the pertinent bits from Kevin's patch:
>
> static void omap3_pm_idle(void)
> {
> local_irq_disable();
> local_fiq_disable();
>
> omap_sram_idle();
>
> local_fiq_enable();
> local_irq_enable();
> }
>
> static void omap_sram_idle(void)
> {
> _omap_sram_idle(NULL, save_state);
> }
>
> _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend,
> omap34xx_cpu_suspend_sz);
> pm_idle = omap3_pm_idle;
>
> _omap_sram_idle() is the assembly code we're discussing, and here we're
> referring to its version in SRAM. From the above code, we can clearly
> see that this is entered with FIQs and IRQs disabled. So everything
> inside omap_sram_idle() is running in a well defined environment provided
> prefetch and data aborts don't happen.
>
> There is nothing stopping this from becoming:
>
> static void omap3_pm_idle(void)
> {
> local_irq_disable();
> local_fiq_disable();
>
> omap_sram_idle();
> + cpu_init();
>
> local_fiq_enable();
> local_irq_enable();
> }
>
> and having the saving of IRQ, FIQ and abort mode registers removed
> from the SRAM code.
I did some quick experiments on a kernel that includes full OFF-mode
support and this and this is working fine.
For it to work for both idle and suspend, I put the cpu_init()
immediately after the return from SRAM (IOW, right after the call to
_omap_sram_idle() inside omap_sram_idle()).
Now I can totally drop all the sp/lr/spsr save/restore code from the
asm code. Nice!
> Other SoCs do precisely this - let's look at PXA:
>
> pxa_cpu_pm_fns->enter(state);
> cpu_init();
>
> The call to the enter method essentially calls the core specific suspend
> function (eg, pxa25x_cpu_suspend()), which is an assembly function which
> ultimately ends up powering down the core resulting in full loss of state
> in the CPU. We seem to be able to avoid having to save the exception mode
> registers there.
>
> The same thing is done with sa11x0 and Samsung SoCs.
>
> I don't see any reason for OMAP to be "special" in this regard.
Neither do I. Thanks for the review and the suggestion.
Kevin
prev parent reply other threads:[~2009-05-19 0:23 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-15 18:40 [PATCH 00/11] OMAP2/3: PM sync-up Kevin Hilman
2009-05-15 18:40 ` [PATCH 01/11] OMAP2/3: PM: push core PM code from linux-omap Kevin Hilman
2009-05-15 18:40 ` [PATCH 02/11] OMAP: Add new function to check wether there is irq pending Kevin Hilman
2009-05-15 18:40 ` [PATCH 03/11] OMAP3: PM: Force IVA2 into idle during bootup Kevin Hilman
2009-05-15 18:40 ` [PATCH 04/11] OMAP3: PM: Add wake-up bit defintiions for CONTROL_PADCONF_X Kevin Hilman
2009-05-15 18:40 ` [PATCH 05/11] OMAP3: PM: UART: disable clocks when idle and off-mode support Kevin Hilman
2009-05-15 18:40 ` [PATCH 06/11] OMAP3: PM: Add D2D clocks and auto-idle setup to PRCM init Kevin Hilman
2009-05-15 18:40 ` [PATCH 07/11] OMAP3: PM: D2D clockdomain supports SW supervised transitions Kevin Hilman
2009-05-15 18:40 ` [PATCH 08/11] OMAP3: PM: Ensure MUSB block can idle when driver not loaded Kevin Hilman
2009-05-15 18:40 ` [PATCH 09/11] OMAP3: PM: Ensure PRCM interrupts are cleared at boot Kevin Hilman
2009-05-15 18:40 ` [PATCH 10/11] OMAP3: PM: Clear pending PRCM reset flags on init Kevin Hilman
2009-05-15 18:40 ` [PATCH 11/11] OMAP3: PM: prevent module wakeups from waking IVA2 Kevin Hilman
2009-05-18 13:16 ` [PATCH 08/11] OMAP3: PM: Ensure MUSB block can idle when driver not loaded Russell King - ARM Linux
2009-05-18 14:50 ` Kevin Hilman
2009-05-18 15:04 ` Tony Lindgren
2009-05-18 13:32 ` [PATCH 01/11] OMAP2/3: PM: push core PM code from linux-omap Russell King - ARM Linux
2009-05-18 17:00 ` Kevin Hilman
2009-05-18 17:06 ` Russell King - ARM Linux
2009-05-18 17:28 ` Kevin Hilman
2009-05-19 5:49 ` Artem Bityutskiy
2009-05-19 14:57 ` Kevin Hilman
2009-05-19 18:55 ` Kevin Hilman
2009-05-28 13:43 ` Russell King - ARM Linux
2009-05-18 17:08 ` Kevin Hilman
2009-05-18 18:30 ` Russell King - ARM Linux
2009-05-18 19:04 ` Woodruff, Richard
2009-05-18 20:24 ` Russell King - ARM Linux
2009-05-18 20:47 ` Woodruff, Richard
2009-05-18 21:11 ` Russell King - ARM Linux
2009-05-18 21:19 ` Woodruff, Richard
2009-05-19 0:23 ` Kevin Hilman [this message]
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=87ws8e7xfl.fsf@deeprootsystems.com \
--to=khilman@deeprootsystems.com \
--cc=jouni.hogander@nokia.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=paul@pwsan.com \
--cc=r-woodruff2@ti.com \
/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