linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] at91 : implement the standby function for pm/cpuidle
Date: Wed, 18 Jan 2012 22:18:45 +0000	[thread overview]
Message-ID: <20120118221845.GS1068@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <4F1742E8.8090108@gmail.com>

On Thu, Jan 19, 2012 at 09:08:40AM +1100, Ryan Mallon wrote:
> On 18/01/12 10:40, Daniel Lezcano wrote:
> 
> > This patch groups the self-refresh on/cpu_do_idle/self-refresh off into
> > a single 'standby' function.
> > 
> > The standby routine for rm9200 has been turned into an asm routine to have
> > a better control of the self refresh and to prevent a memory access when
> > running this code.
> > 
> > Draining the write buffer is done automatically when switching for the self
> > refresh on sam9, so the instruction is added to the rm9200 only.
> > 
> > Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> 
> 
> I don't think is an improvement. Russell's suggestion was to convert the
> pm operations into a structure, like:
> 
> struct at91_pm_ops {
> 	u32  (*sdram_selfrefresh_enable)(void);
> 	void (*sdram_selfrefresh_disable)(u32 saved_lpr);
> };

Actually no, that was my first suggestion.  I then went on to a second
suggestion, which is what Daniel has implemented.

The improvement is we've gone from this:

		asm("b 1f; .align 5; 1:");
		asm("mcr p15, 0, r0, c7, c10, 4");	/* drain write buffer */
		cpu_do_idle();
		sdram_selfrefresh_disable(saved_lpr);

which is really undefined, and may break with a later compiler, to:

	u32 lpr = at91_sys_read(AT91_SDRAMC_LPR);

	asm volatile(
		"b    1f\n\t"
		".align    5\n\t"
		"1:  mcr    p15, 0, %0, c7, c10, 4\n\t"
		"    str    %0, [%1, %2]\n\t"
		"    str    %3, [%1, %4]\n\t"
		"    mcr    p15, 0, %0, c7, c0, 4\n\t"
		"    str    %5, [%1, %2]"

which gcc guarantees it won't insert instructions randomly into the
middle of this.

So this is technically a far superior solution.

It also means that the implementation of at91_standby() can preserve
as many registers as are necessary over the standby itself - it seems
some AT91 SoCs require two registers rather than just one.

  reply	other threads:[~2012-01-18 22:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-17 23:40 [PATCH 0/4] at91 : cleanup pm.h Daniel Lezcano
2012-01-17 23:40 ` [PATCH 1/4] at91 : coding style fixes Daniel Lezcano
2012-01-17 23:40 ` [PATCH 2/4] at91 : declare header name Daniel Lezcano
2012-01-17 23:40 ` [PATCH 3/4] at91 : remove wait_for_interrupt definition Daniel Lezcano
2012-01-18 21:53   ` Ryan Mallon
2012-01-17 23:40 ` [PATCH 4/4] at91 : implement the standby function for pm/cpuidle Daniel Lezcano
2012-01-18 22:08   ` Ryan Mallon
2012-01-18 22:18     ` Russell King - ARM Linux [this message]
2012-01-18 22:25       ` Ryan Mallon
2012-01-18 22:45         ` Russell King - ARM Linux
2012-01-19  9:18           ` Daniel Lezcano
2012-01-19  9:25 ` [PATCH 0/4] at91 : cleanup pm.h Nicolas Ferre
  -- strict thread matches above, loose matches on Subject: below --
2012-01-24 23:56 [PATCH 1/4] at91 : coding style fixes Daniel Lezcano
2012-01-24 23:56 ` [PATCH 4/4] at91 : implement the standby function for pm/cpuidle Daniel Lezcano

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=20120118221845.GS1068@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --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).