All of lore.kernel.org
 help / color / mirror / Atom feed
From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: decompressor: clear SCTLR.A bit for v7 cores
Date: Mon, 5 Nov 2012 17:26:24 +0000	[thread overview]
Message-ID: <20121105172624.GE2005@linaro.org> (raw)
In-Reply-To: <alpine.LFD.2.02.1211051111150.21033@xanadu.home>

On Mon, Nov 05, 2012 at 11:13:51AM -0500, Nicolas Pitre wrote:
> On Mon, 5 Nov 2012, Russell King - ARM Linux wrote:
> 
> > On Mon, Nov 05, 2012 at 01:02:55PM +0000, Dave Martin wrote:
> > > Why not allow unaligned accesses in the decompressor, though, both
> > > for v6 and v7?
> > 
> > EXACTLY.
> 
> I have no objections to that.  In fact, I made a remark to this effect 
> in my initial review of this patch.  Whether or not gcc does take 
> advantage of this hardware ability in the end is orthogonal.

For the sake of argument, here's how it might look.

Currently, I make no attempt to restore the original state of the U bit.
The A bit if forced later by the kernel during boot, after a short window
during which we should only run low-level arch code and therefore where
no unaligned accesses should happen.

Does anyone think these issues are likely to be important?

Cheers
---Dave


>From 160a5576b53264951ff8164775146b2d4feddecb Mon Sep 17 00:00:00 2001
From: Dave Martin <dave.martin@linaro.org>
Date: Mon, 5 Nov 2012 16:34:57 +0000
Subject: [PATCH] ARM: decompressor: Enable unaligned memory access for v6 and above

Modern GCC can generate code which makes use of the CPU's native
unaligned memory access capabilities.  This is useful for the C
decompressor implementations used for unpacking compressed kernels.

This patch disables the alignment faults and enabled the v6
unaligned access on CPUs which support these features (i.e., v6 and
later), allowing full unaligned access support for C code in the
decompressor.

The decompressor C code must not be built to assume that unaligned
access works if support for v5 or older platforms is included in
the kernel.

Signed-off-by: Dave Martin <dave.martin@linaro.org>
---
Note: I have only build-tested this so far.

 arch/arm/boot/compressed/head.S |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 90275f0..cfbb4c9 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -652,6 +652,15 @@ __setup_mmu:	sub	r3, r4, #16384		@ Page directory size
 		mov	pc, lr
 ENDPROC(__setup_mmu)
 
+@ Enable unaligned access on v6, to allow better code generation
+@ for the decompressor C code:
+__armv6_mmu_cache_on:
+		mrc	p15, 0, r0, c1, c0, 0	@ read SCTLR
+		bic	r0, r0, #2		@ A (no unaligned access fault)
+		orr	r0, r0, #1 << 22	@ U (v6 unaligned access model)
+		mcr	p15, 0, r0, c1, c0, 0	@ write SCTLR
+		b	__armv4_mmu_cache_on
+
 __arm926ejs_mmu_cache_on:
 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
 		mov	r0, #4			@ put dcache in WT mode
@@ -694,6 +703,7 @@ __armv7_mmu_cache_on:
 		bic	r0, r0, #1 << 28	@ clear SCTLR.TRE
 		orr	r0, r0, #0x5000		@ I-cache enable, RR cache replacement
 		orr	r0, r0, #0x003c		@ write buffer
+		bic	r0, r0, #2		@ A (no unaligned access fault)
 #ifdef CONFIG_MMU
 #ifdef CONFIG_CPU_ENDIAN_BE8
 		orr	r0, r0, #1 << 25	@ big-endian page tables
@@ -914,7 +924,7 @@ proc_types:
 
 		.word	0x0007b000		@ ARMv6
 		.word	0x000ff000
-		W(b)	__armv4_mmu_cache_on
+		W(b)	__armv6_mmu_cache_on
 		W(b)	__armv4_mmu_cache_off
 		W(b)	__armv6_mmu_cache_flush
 
-- 
1.7.4.1

  reply	other threads:[~2012-11-05 17:26 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-05  1:23 [PATCH v2 0/5] Use more asm-generic headers Rob Herring
2012-08-05  1:23 ` [PATCH v2 1/5] ARM: use generic version of identical asm headers Rob Herring
2012-08-05  1:23 ` [PATCH v2 2/5] ARM: add strstr declaration for decompressors Rob Herring
2012-08-05  1:23 ` [PATCH v2 3/5] ARM: use generic unaligned.h Rob Herring
2012-10-08 16:43   ` Shawn Guo
2012-10-08 20:34     ` Rob Herring
2012-10-08 23:28       ` Shawn Guo
2012-10-09  2:27         ` Rob Herring
2012-10-09  2:45           ` Shawn Guo
2012-10-09  4:01           ` Nicolas Pitre
2012-10-10 13:29             ` Rob Herring
2012-10-10 13:57               ` Nicolas Pitre
2012-10-11 12:43                 ` [PATCH] ARM: decompressor: clear SCTLR.A bit for v7 cores Rob Herring
2012-10-11 13:09                   ` Russell King - ARM Linux
2012-10-11 13:31                     ` Rob Herring
2012-10-11 13:41                       ` Russell King - ARM Linux
2012-10-11 15:44                         ` Nicolas Pitre
2012-10-23 20:32                           ` Gregory CLEMENT
2012-10-25 12:07                             ` Russell King - ARM Linux
2012-10-11 13:59                       ` Russell King - ARM Linux
2012-10-11 15:58                         ` Nicolas Pitre
2012-10-25  9:34                   ` Johannes Stezenbach
2012-10-25 12:41                     ` Rob Herring
2012-10-25 13:30                       ` Arnd Bergmann
2012-10-25 14:16                       ` Johannes Stezenbach
2012-10-25 14:25                         ` Rob Herring
2012-10-25 15:02                           ` Nicolas Pitre
2012-10-25 15:08                           ` Johannes Stezenbach
2012-11-05 10:48                             ` Dave Martin
2012-11-05 11:13                               ` Russell King - ARM Linux
2012-11-05 13:02                                 ` Dave Martin
2012-11-05 13:43                                   ` Johannes Stezenbach
2012-11-05 15:39                                   ` Russell King - ARM Linux
2012-11-05 16:13                                     ` Nicolas Pitre
2012-11-05 17:26                                       ` Dave Martin [this message]
2012-11-05 17:44                                         ` Rob Herring
2012-11-05 20:02                                           ` Nicolas Pitre
2012-11-05 17:46                                         ` Nicolas Pitre
2012-11-05 13:48                                 ` Rob Herring
2012-11-05 22:02                                   ` Michael Hope
2013-02-20 14:56                                     ` Johannes Stezenbach
2013-02-20 15:07                                       ` Johannes Stezenbach
2012-08-05  1:23 ` [PATCH v2 4/5] ARM: use generic termios.h Rob Herring
2012-08-05  1:24 ` [PATCH v2 5/5] ARM: convert asm/irqflags.h to use asm-generic/irqflags.h Rob Herring
2012-08-05  9:34 ` [PATCH v2 0/5] Use more asm-generic headers Thomas Petazzoni
2012-08-06 14:35 ` Arnd Bergmann

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=20121105172624.GE2005@linaro.org \
    --to=dave.martin@linaro.org \
    --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 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.