diff mbox

arm64: add appropriate asm/unaligned.h

Message ID 1395927591-20938-1-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel March 27, 2014, 1:39 p.m. UTC
The generic asm/unaligned.h does not allow unaligned accesses, resulting in all
invocations of get_unaligned_xxx() and put_unaligned_xxx() to be expanded into
byte size accesses. On arm64, this is unnecessary, so provide a more permissive
asm/unaligned.h instead.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/arm64/include/asm/Kbuild      |  1 -
 arch/arm64/include/asm/unaligned.h | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/include/asm/unaligned.h

Comments

Rob Herring March 27, 2014, 2:15 p.m. UTC | #1
On Thu, Mar 27, 2014 at 8:39 AM, Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
> The generic asm/unaligned.h does not allow unaligned accesses, resulting in all
> invocations of get_unaligned_xxx() and put_unaligned_xxx() to be expanded into
> byte size accesses. On arm64, this is unnecessary, so provide a more permissive
> asm/unaligned.h instead.

Couldn't the generic version learn to use
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS on arches that enable it?

Rob
Ard Biesheuvel March 27, 2014, 2:20 p.m. UTC | #2
On 27 March 2014 15:15, Rob Herring <robherring2@gmail.com> wrote:
> On Thu, Mar 27, 2014 at 8:39 AM, Ard Biesheuvel
> <ard.biesheuvel@linaro.org> wrote:
>> The generic asm/unaligned.h does not allow unaligned accesses, resulting in all
>> invocations of get_unaligned_xxx() and put_unaligned_xxx() to be expanded into
>> byte size accesses. On arm64, this is unnecessary, so provide a more permissive
>> asm/unaligned.h instead.
>
> Couldn't the generic version learn to use
> CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS on arches that enable it?
>

I wasn't aware of that option, but I agree that it seems reasonable to
test for that in the asm-generic version.
diff mbox

Patch

diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 43a2c9d2d6f4..f88986a0c1dd 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -46,7 +46,6 @@  generic-y += termios.h
 generic-y += topology.h
 generic-y += trace_clock.h
 generic-y += types.h
-generic-y += unaligned.h
 generic-y += user.h
 generic-y += vga.h
 generic-y += xor.h
diff --git a/arch/arm64/include/asm/unaligned.h b/arch/arm64/include/asm/unaligned.h
new file mode 100644
index 000000000000..00c4a4e02fd1
--- /dev/null
+++ b/arch/arm64/include/asm/unaligned.h
@@ -0,0 +1,17 @@ 
+#ifndef __ASM_UNALIGNED_H
+#define __ASM_UNALIGNED_H
+
+#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/generic.h>
+
+#if defined(__LITTLE_ENDIAN)
+#define get_unaligned		__get_unaligned_le
+#define put_unaligned		__put_unaligned_le
+#elif defined(__BIG_ENDIAN)
+#define get_unaligned		__get_unaligned_be
+#define put_unaligned		__put_unaligned_be
+#else
+#error need to define endianess
+#endif
+
+#endif /* __ASM_UNALIGNED_H */