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: [RFC PATCH 3/3] ARM: mm: add l2x0 suspend/resume support
Date: Mon, 26 Sep 2011 16:06:45 +0100	[thread overview]
Message-ID: <20110926150645.GN22455@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1317047561-11020-4-git-send-email-lorenzo.pieralisi@arm.com>

On Mon, Sep 26, 2011 at 03:32:41PM +0100, Lorenzo Pieralisi wrote:
> Context is saved once for all at boot time, along with the L2 physical address
> and cache type.

Why is this assembly code?  As Barry's previous patch shows, it's
entirely possible to save all the state required at init time from
the existing C code without needing any additional functions.

> The resume hook avoids using the stack since it might be called
> before the C environment is up and running and fetches data using
> program counter relative addressing so that it can be run both
> with MMU on or off to simplify its adoption.

What about parts where the security gets in the way of reinitializing
the L2 cache?

> +resume_l210:
> +	ldr	r2, [r0], #4				@ just use scratch regs
> +	str	r2, [r1, #L2X0_AUX_CTRL]
> +	mov	r3, #0
> +	mov	r12, #L2X0_LOCKDOWN_WAY_D_BASE
> +	mov	r2, r12
> +	str	r3, [r1, r2]
> +	add	r2, r2, #4
> +	str	r3, [r1, r2]
> +	movne	r0, #0x1				@ if l210 we are done
> +	strne	r0, [r1, #L2X0_CTRL]			@ enable L2
> +	movne	pc, lr

It's not very obvious where the compare is for this conditional (which is
at the end of l2x0_resume in the .data section.  Also, wouldn't a branch
to the enable at the end of this function be better and a more obvious
flow?

> +resume_l310:
> +	add	r12, r12, r1
> +	add	r12, r12, #L2X0_LOCKDOWN_STRIDE		@ start D lock
> +	mov	r2, #0
> +	mov	r3, #7
> +unlock:
> +	str	r2, [r12, #4]				@ I lock
> +	str	r2, [r12], #L2X0_LOCKDOWN_STRIDE	@ D lock and increment
> +	subs	r3, r3, #1
> +	bne 	unlock

Why not reverse r2 and r3 here?  r3 was already set to zero previously.

And given what you're doing, this code could become:

	mov	r3, #0
	add	r12, r1, #L2X0_LOCKDOWN_WAY_D_BASE
	str	r3, [r12, #4]				@ I lock
	str	r3, [r12], #L2X0_LOCKDOWN_STRIDE	@ D lock and increment
	bne	enable_l2
resume_l310:
	mov	r2, #7
unlock:
	str	r3, [r12, #4]				@ I lock
	str	r3, [r12], #L2X0_LOCKDOWN_STRIDE	@ D lock and increment
	subs	r2, r2, #1
	bne	unlock


> +	ldmia	r0!, {r2, r3, r12}
> +	str	r2, [r1, #L2X0_TAG_LATENCY_CTRL]
> +	str	r3, [r1, #L2X0_DATA_LATENCY_CTRL]
> +	str	r12, [r1, #L2X0_ADDR_FILTER_START]
> +	ldmia	r0!, {r2, r3, r12}
> +	str	r2, [r1, #L2X0_ADDR_FILTER_END]
> +	str	r3, [r1, #L2X0_DEBUG_CTRL]
> +	str	r12, [r1, #L2X0_PREFETCH_CTRL]
> +	ldr	r2, [r0]
> +	str	r2, [r1, #L2X0_POWER_CTRL]

enable_l2:

> +	mov	r0, #0x1
> +	str	r0, [r1, #L2X0_CTRL]			@ enable L2
> +	mov	pc, lr

  parent reply	other threads:[~2011-09-26 15:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-26 14:32 [RFC PATCH 0/3] ARM: mm: add L2 suspend/resume support Lorenzo Pieralisi
2011-09-26 14:32 ` [RFC PATCH 1/3] ARM: mm: add outercache resume hook Lorenzo Pieralisi
2011-09-26 14:32 ` [RFC PATCH 2/3] ARM: mm: add l2x0 physical address parameter to init Lorenzo Pieralisi
2011-09-26 14:51   ` Russell King - ARM Linux
2011-09-26 16:02     ` Lorenzo Pieralisi
2011-09-26 14:32 ` [RFC PATCH 3/3] ARM: mm: add l2x0 suspend/resume support Lorenzo Pieralisi
2011-09-26 14:55   ` Russell King - ARM Linux
2011-09-26 16:27     ` Lorenzo Pieralisi
2011-09-26 15:06   ` Russell King - ARM Linux [this message]
2011-09-26 17:14     ` Lorenzo Pieralisi
2011-09-27  5:29       ` Santosh Shilimkar
2011-09-27 10:28         ` Lorenzo Pieralisi
2011-09-27 10:57           ` Santosh Shilimkar
2011-09-28 19:24             ` Russell King - ARM Linux
2011-09-29  5:38               ` Santosh Shilimkar

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=20110926150645.GN22455@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).