All of lore.kernel.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] ARM: use generic version of identical asm headers
Date: Mon, 16 Jul 2012 10:51:58 +0000	[thread overview]
Message-ID: <201207161051.58878.arnd@arndb.de> (raw)
In-Reply-To: <1342410836-6010-2-git-send-email-robherring2@gmail.com>

On Monday 16 July 2012, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> Inspired by the AArgh64 claim that it should be separate from ARM and one
> reason was being able to use more asm-generic headers. Doing a diff of
> arch/arm/include/asm and include/asm-generic there are numerous asm
> headers which are functionally identical to their asm-generic counterparts.
> Delete the ARM version and use the generic ones.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>

Great stuff!

I had a similar series once but lost it when the kernel.org went down.
I've looked at all your patches and noticed two files that are changing
semantically with your patch. If we want to have the generic behavior,
it's probably best to do those as separate patches.


> -/*
> - * Translate a "termio" structure into a "termios". Ugh.
> - */
> -#define SET_LOW_TERMIOS_BITS(termios, termio, x) {		\
> -	unsigned short __tmp;					\
> -	get_user(__tmp,&(termio)->x);				\
> -	*(unsigned short *) &(termios)->x = __tmp;		\
> -}
> -
> -#define user_termio_to_kernel_termios(termios, termio) \
> -({ \
> -	SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
> -	SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
> -	SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
> -	SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
> -	copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
> -})

This code is not endian-safe, which means it's currently broken
on big-endian machines. Using the asm-generic version fixes that
problem but increases the code sizes.

> -/*
> - * Translate a "termios" structure into a "termio". Ugh.
> - */
> -#define kernel_termios_to_user_termio(termio, termios) \
> -({ \
> -	put_user((termios)->c_iflag, &(termio)->c_iflag); \
> -	put_user((termios)->c_oflag, &(termio)->c_oflag); \
> -	put_user((termios)->c_cflag, &(termio)->c_cflag); \
> -	put_user((termios)->c_lflag, &(termio)->c_lflag); \
> -	put_user((termios)->c_line,  &(termio)->c_line); \
> -	copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
> -})

This code is missing error handling, and again fixing this
will increase the code size.

I think it's a good idea to fix these two issues, but let's
use a separate patch for it.

> diff --git a/arch/arm/include/asm/unaligned.h b/arch/arm/include/asm/unaligned.h
> deleted file mode 100644
> index 44593a8..0000000
> --- a/arch/arm/include/asm/unaligned.h
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -#ifndef _ASM_ARM_UNALIGNED_H
> -#define _ASM_ARM_UNALIGNED_H
> -
> -#include <linux/unaligned/le_byteshift.h>
> -#include <linux/unaligned/be_byteshift.h>
> -#include <linux/unaligned/generic.h>
> -
> -/*
> - * Select endianness
> - */
> -#ifndef __ARMEB__
> -#define get_unaligned	__get_unaligned_le
> -#define put_unaligned	__put_unaligned_le
> -#else
> -#define get_unaligned	__get_unaligned_be
> -#define put_unaligned	__put_unaligned_be
> -#endif
> -
> -#endif /* _ASM_ARM_UNALIGNED_H */

The asm-generic version uses the "struct" version for native-endian
unaligned access and the "byteshift" version for the opposite endianess.
The current ARM version however uses the "byteshift" implementation for
both. I don't know what works better on ARM, but I'd say we should not
change it unless we understand the effects.

	Arnd

  reply	other threads:[~2012-07-16 10:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-16  3:53 [PATCH 0/3] Use more asm-generic headers Rob Herring
2012-07-16  3:53 ` [PATCH 1/3] ARM: use generic version of identical asm headers Rob Herring
2012-07-16 10:51   ` Arnd Bergmann [this message]
2012-07-16 15:37     ` Nicolas Pitre
2012-07-16  3:53 ` [PATCH 2/3] ARM: use asm-generic version of kmap_types.h Rob Herring
2012-07-16  9:18   ` Arnd Bergmann
2012-07-16 16:15     ` Rob Herring
2012-07-16  3:53 ` [PATCH 3/3] ARM: convert asm/irqflags.h to use asm-generic/irqflags.h Rob Herring
2012-07-16  6:35   ` Hui Wang
2012-07-16 16:10     ` Rob Herring
2012-07-17  1:42       ` Hui Wang

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=201207161051.58878.arnd@arndb.de \
    --to=arnd@arndb.de \
    --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.