From: Tetsuyuki Kobayashi <koba@kmckk.co.jp>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] arm: enable unaligned access on ARMv7
Date: Wed, 27 Jun 2012 19:14:43 +0900 [thread overview]
Message-ID: <4FEADD13.2040708@kmckk.co.jp> (raw)
In-Reply-To: <4FEA21F5.4080803@gmail.com>
Hi Rob and all,
>>>
>>> Am Dienstag, den 05.06.2012, 12:42 -0600 schrieb Stephen Warren:
>>>> On 06/05/2012 11:47 AM, Lucas Stach wrote:
>>>>> Recent toolchains default to using the hardware feature for
>>>>> unaligned access on ARM v7, rather than doing the software
>>>>> fallback. According to ARM this is safe as all v7 implementations
>>>>> have to support this feature.
>>>>> (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471c/BABJFFAE.html)
>>>>>
>>>>> To avoid CPU hangs when doing unaligned memory access, we have to
>>>>> turn off alignment checking in our CPU initialisation code.
>>>>> (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/CIHCGCFD.html)
>>>>
>>>> Does this behavior change trickle down to Linux/... too, or would
>>>> an OS completely re-initialize this state, and hence not be
>>>> affected?
>>>>
>>>
>>> Linux in particular does reinitialize this state and I expect any
>>> reasonable OS to do so.
>>
>> Then what is the point of enabling it on U-Boot? Does it fix some issue
>> whereby some mis-aligned piece of data cannot be properly aligned?
>>
>
> This is a new optimization feature in gcc 4.7 (and backported to some
> 4.6 versions like the ubuntu 12.04 arm cross compiler (4.6.3)):
>
> http://lists.linaro.org/pipermail/linaro-dev/2012-June/012360.html
>
> http://seabright.co.nz/2012/06/11/kernel-not-booting-with-linaro-gcc/
>
> If you don't want to enable unaligned accesses, then
> "-mno-unaligned-access" needs to be added.
>
I verified it. Option "-mno-unaligned-access" works good.
include/mtd/cfi_flash.h
/* CFI standard query structure */
struct cfi_qry {
u8 qry[3];
u16 p_id; <-- unaligned!
...
} __attribute__((packed));
$ ${CROSS_COMPILE}gcc --version
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.6.2 20110921 (release) [ARM/embedded-4_6-branch revision 182083]
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=====================================================================
Compiled without --mno-unaligned-access
$ ${CROSS_COMPILE}objdump -d -S u-boot
info->vendor = le16_to_cpu(qry.p_id);
cc88: e3003a1c movw r3, #2588 ; 0xa1c
cc8c: e1dd11bb ldrh r1, [sp, #27] <-- this is unaligned access
cc90: ...
cc94: e18410b3 strh r1, [r4, r3]
=====================================================================
Compiled with --mno-unaligned-access
$ ${CROSS_COMPILE}objdump -d -S u-boot
info->vendor = le16_to_cpu(qry.p_id);
cce8: e5dd101c ldrb r1, [sp, #28] <--
ccec: e5dd301b ldrb r3, [sp, #27] <-- separated 2 byte accesses
ccf0: ...
ccf4: e1831401 orr r1, r3, r1, lsl #8
ccf8: e3003a1c movw r3, #2588 ; 0xa1c
ccfc: e18410b3 strh r1, [r4, r3]
next prev parent reply other threads:[~2012-06-27 10:14 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-05 17:47 [U-Boot] [PATCH] arm: enable unaligned access on ARMv7 Lucas Stach
2012-06-05 18:42 ` Stephen Warren
2012-06-05 19:06 ` Lucas Stach
2012-06-22 9:15 ` Albert ARIBAUD
2012-06-22 9:36 ` Lucas Stach
2012-06-22 11:16 ` Albert ARIBAUD
2012-06-22 11:47 ` Lucas Stach
2012-06-22 22:11 ` Aneesh V
2012-06-22 22:13 ` Aneesh V
2012-06-23 9:01 ` Albert ARIBAUD
2012-06-23 17:43 ` V, Aneesh
2012-06-25 20:34 ` Albert ARIBAUD
2012-06-25 21:49 ` Aneesh V
2012-06-25 22:02 ` Wolfgang Denk
2012-06-23 19:50 ` Måns Rullgård
2012-06-24 6:30 ` Lucas Stach
[not found] ` <20120625221741.3a32790e@lilith>
2012-06-25 21:34 ` Lucas Stach
2012-06-26 20:56 ` Rob Herring
2012-06-27 10:14 ` Tetsuyuki Kobayashi [this message]
2012-07-02 9:42 ` [U-Boot] [PATCH] arm: armv7: add compile option -mno-unaligned-access if available Tetsuyuki Kobayashi
2012-07-02 9:53 ` Måns Rullgård
2012-07-02 15:16 ` Lucas Stach
2012-07-02 16:14 ` Måns Rullgård
2012-07-03 7:10 ` Tetsuyuki Kobayashi
2012-07-05 7:57 ` Albert ARIBAUD
2012-07-18 21:37 ` Albert ARIBAUD
2012-07-19 4:31 ` Mike Frysinger
2012-07-19 4:29 ` Mike Frysinger
2012-07-19 6:28 ` Albert ARIBAUD
2012-07-19 14:27 ` Mike Frysinger
2012-07-20 7:12 ` Albert ARIBAUD
2012-07-12 15:12 ` Gary Thomas
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=4FEADD13.2040708@kmckk.co.jp \
--to=koba@kmckk.co.jp \
--cc=u-boot@lists.denx.de \
/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