2021-05-07 22:13:20

by Arnd Bergmann

[permalink] [raw]
Subject: [RFC 01/12] asm-generic: use asm-generic/unaligned.h for most architectures

From: Arnd Bergmann <[email protected]>

There are several architectures that just duplicate the contents
of asm-generic/unaligned.h, so change those over to use the
file directly, to make future modifications easier.

The exceptions are:

- arm32 sets HAVE_EFFICIENT_UNALIGNED_ACCESS, but wants the
unaligned-struct version

- ppc64le disables HAVE_EFFICIENT_UNALIGNED_ACCESS but includes
the access-ok version

- m68k (non-dragonball) also uses the access-ok version without
setting HAVE_EFFICIENT_UNALIGNED_ACCESS.

- sh4a has a custom inline asm version

- openrisc is the only one using the memmove version that
generally leads to worse code.

Signed-off-by: Arnd Bergmann <[email protected]>
---
arch/alpha/include/asm/unaligned.h | 12 ----------
arch/ia64/include/asm/unaligned.h | 12 ----------
arch/m68k/include/asm/unaligned.h | 9 +-------
arch/microblaze/include/asm/unaligned.h | 27 -----------------------
arch/parisc/include/asm/unaligned.h | 6 +----
arch/sparc/include/asm/unaligned.h | 11 ----------
arch/x86/include/asm/unaligned.h | 15 -------------
arch/xtensa/include/asm/unaligned.h | 29 -------------------------
8 files changed, 2 insertions(+), 119 deletions(-)
delete mode 100644 arch/alpha/include/asm/unaligned.h
delete mode 100644 arch/ia64/include/asm/unaligned.h
delete mode 100644 arch/microblaze/include/asm/unaligned.h
delete mode 100644 arch/sparc/include/asm/unaligned.h
delete mode 100644 arch/x86/include/asm/unaligned.h
delete mode 100644 arch/xtensa/include/asm/unaligned.h

diff --git a/arch/alpha/include/asm/unaligned.h b/arch/alpha/include/asm/unaligned.h
deleted file mode 100644
index 863c807b66f8..000000000000
--- a/arch/alpha/include/asm/unaligned.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_ALPHA_UNALIGNED_H
-#define _ASM_ALPHA_UNALIGNED_H
-
-#include <linux/unaligned/le_struct.h>
-#include <linux/unaligned/be_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#define get_unaligned __get_unaligned_le
-#define put_unaligned __put_unaligned_le
-
-#endif /* _ASM_ALPHA_UNALIGNED_H */
diff --git a/arch/ia64/include/asm/unaligned.h b/arch/ia64/include/asm/unaligned.h
deleted file mode 100644
index 328942e3cbce..000000000000
--- a/arch/ia64/include/asm/unaligned.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_IA64_UNALIGNED_H
-#define _ASM_IA64_UNALIGNED_H
-
-#include <linux/unaligned/le_struct.h>
-#include <linux/unaligned/be_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#define get_unaligned __get_unaligned_le
-#define put_unaligned __put_unaligned_le
-
-#endif /* _ASM_IA64_UNALIGNED_H */
diff --git a/arch/m68k/include/asm/unaligned.h b/arch/m68k/include/asm/unaligned.h
index 98c8930d3d35..84e437337344 100644
--- a/arch/m68k/include/asm/unaligned.h
+++ b/arch/m68k/include/asm/unaligned.h
@@ -2,15 +2,8 @@
#ifndef _ASM_M68K_UNALIGNED_H
#define _ASM_M68K_UNALIGNED_H

-
#ifdef CONFIG_CPU_HAS_NO_UNALIGNED
-#include <linux/unaligned/be_struct.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#define get_unaligned __get_unaligned_be
-#define put_unaligned __put_unaligned_be
-
+#include <asm-generic/unaligned.h>
#else
/*
* The m68k can do unaligned accesses itself.
diff --git a/arch/microblaze/include/asm/unaligned.h b/arch/microblaze/include/asm/unaligned.h
deleted file mode 100644
index 448299beab69..000000000000
--- a/arch/microblaze/include/asm/unaligned.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2008 Michal Simek <[email protected]>
- * Copyright (C) 2006 Atmark Techno, Inc.
- */
-
-#ifndef _ASM_MICROBLAZE_UNALIGNED_H
-#define _ASM_MICROBLAZE_UNALIGNED_H
-
-# ifdef __KERNEL__
-
-# ifdef __MICROBLAZEEL__
-# include <linux/unaligned/le_struct.h>
-# include <linux/unaligned/be_byteshift.h>
-# define get_unaligned __get_unaligned_le
-# define put_unaligned __put_unaligned_le
-# else
-# include <linux/unaligned/be_struct.h>
-# include <linux/unaligned/le_byteshift.h>
-# define get_unaligned __get_unaligned_be
-# define put_unaligned __put_unaligned_be
-# endif
-
-# include <linux/unaligned/generic.h>
-
-# endif /* __KERNEL__ */
-#endif /* _ASM_MICROBLAZE_UNALIGNED_H */
diff --git a/arch/parisc/include/asm/unaligned.h b/arch/parisc/include/asm/unaligned.h
index e9029c7c2a69..3bda16773ba6 100644
--- a/arch/parisc/include/asm/unaligned.h
+++ b/arch/parisc/include/asm/unaligned.h
@@ -2,11 +2,7 @@
#ifndef _ASM_PARISC_UNALIGNED_H
#define _ASM_PARISC_UNALIGNED_H

-#include <linux/unaligned/be_struct.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-#define get_unaligned __get_unaligned_be
-#define put_unaligned __put_unaligned_be
+#include <asm-generic/unaligned.h>

#ifdef __KERNEL__
struct pt_regs;
diff --git a/arch/sparc/include/asm/unaligned.h b/arch/sparc/include/asm/unaligned.h
deleted file mode 100644
index 7971d89d2f54..000000000000
--- a/arch/sparc/include/asm/unaligned.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_SPARC_UNALIGNED_H
-#define _ASM_SPARC_UNALIGNED_H
-
-#include <linux/unaligned/be_struct.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-#define get_unaligned __get_unaligned_be
-#define put_unaligned __put_unaligned_be
-
-#endif /* _ASM_SPARC_UNALIGNED_H */
diff --git a/arch/x86/include/asm/unaligned.h b/arch/x86/include/asm/unaligned.h
deleted file mode 100644
index 9c754a7447aa..000000000000
--- a/arch/x86/include/asm/unaligned.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_X86_UNALIGNED_H
-#define _ASM_X86_UNALIGNED_H
-
-/*
- * The x86 can do unaligned accesses itself.
- */
-
-#include <linux/unaligned/access_ok.h>
-#include <linux/unaligned/generic.h>
-
-#define get_unaligned __get_unaligned_le
-#define put_unaligned __put_unaligned_le
-
-#endif /* _ASM_X86_UNALIGNED_H */
diff --git a/arch/xtensa/include/asm/unaligned.h b/arch/xtensa/include/asm/unaligned.h
deleted file mode 100644
index 8e7ed046bfed..000000000000
--- a/arch/xtensa/include/asm/unaligned.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Xtensa doesn't handle unaligned accesses efficiently.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2001 - 2005 Tensilica Inc.
- */
-#ifndef _ASM_XTENSA_UNALIGNED_H
-#define _ASM_XTENSA_UNALIGNED_H
-
-#include <asm/byteorder.h>
-
-#ifdef __LITTLE_ENDIAN
-# include <linux/unaligned/le_struct.h>
-# include <linux/unaligned/be_byteshift.h>
-# include <linux/unaligned/generic.h>
-# define get_unaligned __get_unaligned_le
-# define put_unaligned __put_unaligned_le
-#else
-# include <linux/unaligned/be_struct.h>
-# include <linux/unaligned/le_byteshift.h>
-# include <linux/unaligned/generic.h>
-# define get_unaligned __get_unaligned_be
-# define put_unaligned __put_unaligned_be
-#endif
-
-#endif /* _ASM_XTENSA_UNALIGNED_H */
--
2.29.2


2021-05-07 23:03:50

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [RFC 01/12] asm-generic: use asm-generic/unaligned.h for most architectures

On Sat, May 08 2021 at 00:07, Arnd Bergmann wrote:
> diff --git a/arch/x86/include/asm/unaligned.h b/arch/x86/include/asm/unaligned.h
> deleted file mode 100644
> index 9c754a7447aa..000000000000
> --- a/arch/x86/include/asm/unaligned.h
> +++ /dev/null
> @@ -1,15 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> -#ifndef _ASM_X86_UNALIGNED_H
> -#define _ASM_X86_UNALIGNED_H
> -
> -/*
> - * The x86 can do unaligned accesses itself.
> - */
> -
> -#include <linux/unaligned/access_ok.h>
> -#include <linux/unaligned/generic.h>
> -
> -#define get_unaligned __get_unaligned_le
> -#define put_unaligned __put_unaligned_le
> -
> -#endif /* _ASM_X86_UNALIGNED_H */

Reviewed-by: Thomas Gleixner <[email protected]>

Thanks for cleaning that up!

tglx

2021-05-10 10:18:31

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [RFC 01/12] asm-generic: use asm-generic/unaligned.h for most architectures

Hi Arnd,

On Sat, May 8, 2021 at 12:09 AM Arnd Bergmann <[email protected]> wrote:
> From: Arnd Bergmann <[email protected]>
>
> There are several architectures that just duplicate the contents
> of asm-generic/unaligned.h, so change those over to use the
> file directly, to make future modifications easier.
>
> The exceptions are:
>
> - arm32 sets HAVE_EFFICIENT_UNALIGNED_ACCESS, but wants the
> unaligned-struct version
>
> - ppc64le disables HAVE_EFFICIENT_UNALIGNED_ACCESS but includes
> the access-ok version
>
> - m68k (non-dragonball) also uses the access-ok version without
> setting HAVE_EFFICIENT_UNALIGNED_ACCESS.

This not only applies to dragonball, which has the CPU32 core, but also
to plain 68000, and any SoCs including the 68EC000 core.

It also applies to early Coldfire, but AFAIK Linux doesn't support these
(see dfe1d26d4a90287e ("m68knommu: Allow ColdFire CPUs to use unaligned
accesses")).

> - sh4a has a custom inline asm version
>
> - openrisc is the only one using the memmove version that
> generally leads to worse code.
>
> Signed-off-by: Arnd Bergmann <[email protected]>

> arch/m68k/include/asm/unaligned.h | 9 +-------

Reviewed-by: Geert Uytterhoeven <[email protected]>
Acked-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2021-05-10 13:28:12

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [RFC 01/12] asm-generic: use asm-generic/unaligned.h for most architectures

On Mon, May 10, 2021 at 12:16 PM Geert Uytterhoeven
<[email protected]> wrote:
> On Sat, May 8, 2021 at 12:09 AM Arnd Bergmann <[email protected]> wrote:
> > From: Arnd Bergmann <[email protected]>
> >
> > There are several architectures that just duplicate the contents
> > of asm-generic/unaligned.h, so change those over to use the
> > file directly, to make future modifications easier.
> >
> > The exceptions are:
> >
> > - arm32 sets HAVE_EFFICIENT_UNALIGNED_ACCESS, but wants the
> > unaligned-struct version
> >
> > - ppc64le disables HAVE_EFFICIENT_UNALIGNED_ACCESS but includes
> > the access-ok version
> >
> > - m68k (non-dragonball) also uses the access-ok version without
> > setting HAVE_EFFICIENT_UNALIGNED_ACCESS.
>
> This not only applies to dragonball, which has the CPU32 core, but also
> to plain 68000, and any SoCs including the 68EC000 core.

I meant out of the machines that are currently supported in the kernel.
As far as I can tell, the only 68000 variants that are supported are
all Dragonball CONFIG_M68328, CONFIG_M68EZ328 and
CONFIG_M68VZ328.

CONFIG_MCPU32 has been dead since a3595962d824 ("m68knommu:
remove obsolete 68360 support")

> Reviewed-by: Geert Uytterhoeven <[email protected]>
> Acked-by: Geert Uytterhoeven <[email protected]>

Thanks!

Arnd