Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-28 Thread Yoshinori Sato
At Mon, 27 Apr 2015 10:40:51 +0200,
Arnd Bergmann wrote:
> 
> On Monday 27 April 2015 14:35:08 Yoshinori Sato wrote:
> > diff --git a/arch/h8300/include/asm/asm-offsets.h 
> > b/arch/h8300/include/asm/asm-offsets.h
> > new file mode 100644
> > index 000..d370ee3
> > --- /dev/null
> > +++ b/arch/h8300/include/asm/asm-offsets.h
> > @@ -0,0 +1 @@
> > +#include 
> 
> Could you add a file with these contents to include/asm-generic and use that
> instead of providing your own copy?

OK.

> > diff --git a/arch/h8300/include/asm/delay.h b/arch/h8300/include/asm/delay.h
> > new file mode 100644
> > index 000..2bdde59
> > --- /dev/null
> > +++ b/arch/h8300/include/asm/delay.h
> > @@ -0,0 +1,38 @@
> > +#ifndef _H8300_DELAY_H
> > +#define _H8300_DELAY_H
> > +
> > +#include 
> > +
> > +/*
> > + * Copyright (C) 2002 Yoshinori Sato 
> > + *
> > + * Delay routines, using a pre-computed "loops_per_second" value.
> > + */
> > +
> > +static inline void __delay(unsigned long loops)
> > +{
> > +   __asm__ __volatile__ ("1:\n\t"
> > + "dec.l #1,%0\n\t"
> > + "bne 1b"
> > + : "=r" (loops) : "0"(loops));
> > +}
> > +
> 
> This could be optimized by using the clocksource instead, if that is
> accurate enough. Doing so will speed up the boot as well, because you
> can avoid calibrating the delay loop.

OK.
remove it.

> 
> > +#endif /* _H8300_DELAY_H */
> > diff --git a/arch/h8300/include/asm/device.h 
> > b/arch/h8300/include/asm/device.h
> > new file mode 100644
> > index 000..06746c5
> > --- /dev/null
> > +++ b/arch/h8300/include/asm/device.h
> > @@ -0,0 +1,6 @@
> > +/*
> > + * Arch specific extensions to struct device
> > + *
> > + * This file is released under the GPLv2
> > + */
> > +#include 
> 
> This one can obviously just use 'generic-y' isntead of including the file.
> 
> > diff --git a/arch/h8300/include/asm/emergency-restart.h 
> > b/arch/h8300/include/asm/emergency-restart.h
> > new file mode 100644
> > index 000..108d8c4
> > --- /dev/null
> > +++ b/arch/h8300/include/asm/emergency-restart.h
> > @@ -0,0 +1,6 @@
> > +#ifndef _ASM_EMERGENCY_RESTART_H
> > +#define _ASM_EMERGENCY_RESTART_H
> > +
> > +#include 
> > +
> > +#endif /* _ASM_EMERGENCY_RESTART_H */
> 
> Same here.

OK.

> > diff --git a/arch/h8300/include/asm/io.h b/arch/h8300/include/asm/io.h
> > new file mode 100644
> > index 000..51ee096
> > --- /dev/null
> > +++ b/arch/h8300/include/asm/io.h
> > @@ -0,0 +1,314 @@
> > +#ifndef _H8300_IO_H
> > +#define _H8300_IO_H
> > +
> > +#ifdef __KERNEL__
> > +
> > +#include 
> > +
> > +#define __raw_readb(addr) ({ u8 __v = *(volatile u8 *)(addr); __v; })
> > +
> > +#define __raw_readw(addr) ({ u16 __v = *(volatile u16 *)(addr); __v; })
> > +
> > +#define __raw_readl(addr) ({ u32 __v = *(volatile u32 *)(addr); __v; })
> > +
> > +#define __raw_writeb(b, addr) (void)((*(volatile u8 *)(addr)) = (b))
> > +
> > +#define __raw_writew(b, addr) (void)((*(volatile u16 *)(addr)) = (b))
> > +
> > +#define __raw_writel(b, addr) (void)((*(volatile u32 *)(addr)) = (b))
> > +
> > +#define readb __raw_readb
> > +#define readw __raw_readw
> > +#define readl __raw_readl
> > +#define writeb __raw_writeb
> > +#define writew __raw_writew
> > +#define writel __raw_writel
> 
> We have recently changed this so you now have to provide readl_relaxed()
> and writel_relaxed() as well.

OK.

> As a side-note: The current definition here prevents you from ever
> using PCI devices, which are by definition little-endian. If there is
> any chance that you might need to support PCI devices later, better
> don't use the readl/writel family of accessors for platform specific
> drivers and use ioread_be32/iowrite_be32 (or an h8300-specific variant
> thereof) for any big-endian devices, and define read() etc to do a
> byte swap.

PCI is not supported.

> > +#if defined(CONFIG_H83069)
> > +#define ABWCR  0xFEE020
> > +#elif defined(CONFIG_H8S2678)
> > +#define ABWCR  0xFFFEC0
> > +#endif
> > +
> > +#ifdef CONFIG_H8300_BUBSSWAP
> > +#define _swapw(x) __builtin_bswap16(x)
> > +#define _swapl(x) __builtin_bswap32(x)
> > +#else
> > +#define _swapw(x) (x)
> > +#define _swapl(x) (x)
> > +#endif
> 
> Is this swapping configurable by software? The best way to do this
> is normally not to do any bus swapping in hardware at all but
> let the drivers take care of it, otherwise you will get things
> wrong in the end.
> 
> > +static inline void io_outsw(unsigned int addr, const void *buf, int len)
> > +{
> > +   volatile unsigned short *ap = (volatile unsigned short *) addr;
> > +   unsigned short *bp = (unsigned short *) buf;
> > +
> > +   while (len--)
> > +   *ap = _swapw(*bp++);
> > +}
> > +
> > +static inline void io_outsl(unsigned int addr, const void *buf, int len)
> > +{
> > +   volatile unsigned short *ap = (volatile unsigned short *) addr;
> > +   unsigned short *bp = (unsigned short *) buf;
> > +
> > +   while (len--) {
> > +   *(ap + 1) = _swapw(*(bp + 

Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-28 Thread Yoshinori Sato
At Mon, 27 Apr 2015 09:42:41 +0200,
Tobias Klauser wrote:
> 
> On 2015-04-27 at 07:35:08 +0200, Yoshinori Sato  
> wrote:
> [...]
> > diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
> > new file mode 100644
> > index 000..09031d0
> > --- /dev/null
> > +++ b/arch/h8300/include/asm/elf.h
> > @@ -0,0 +1,101 @@
> > +#ifndef __ASM_H8300_ELF_H
> > +#define __ASM_H8300_ELF_H
> > +
> > +/*
> > + * ELF register definitions..
> > + */
> > +
> > +#include 
> > +#include 
> > +
> > +typedef unsigned long elf_greg_t;
> > +
> > +#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
> > +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
> > +typedef unsigned long elf_fpregset_t;
> > +
> > +/*
> > + * This is used to ensure we don't load something for the wrong 
> > architecture.
> > + */
> > +#define elf_check_arch(x) ((x)->e_machine == EM_H8_300)
> 
> EM_H8_300 is still used before it is introduced in patch 15/17, please
> change the patch order. Otherwise you break bisectability.

Oh. sorry.
I forgat change order.

> [...]
> > diff --git a/arch/h8300/include/asm/pgtable.h 
> > b/arch/h8300/include/asm/pgtable.h
> > new file mode 100644
> > index 000..8341db6
> > --- /dev/null
> > +++ b/arch/h8300/include/asm/pgtable.h
> > @@ -0,0 +1,49 @@
> > +#ifndef _H8300_PGTABLE_H
> > +#define _H8300_PGTABLE_H
> > +#include 
> > +#include 
> > +#define pgtable_cache_init()   do { } while (0)
> > +extern void paging_init(void);
> > +#define PAGE_NONE  __pgprot(0)/* these mean nothing to NO_MM */
> > +#define PAGE_SHARED__pgprot(0)/* these mean nothing to 
> > NO_MM */
> > +#define PAGE_COPY  __pgprot(0)/* these mean nothing to NO_MM */
> > +#define PAGE_READONLY  __pgprot(0)/* these mean nothing to NO_MM */
> > +#define PAGE_KERNEL__pgprot(0)/* these mean nothing to 
> > NO_MM */
> > +#define __swp_type(x)  (0)
> > +#define __swp_offset(x)(0)
> > +#define __swp_entry(typ, off)  ((swp_entry_t) { ((typ) | ((off) << 7)) 
> > })
> > +#define __pte_to_swp_entry(pte)((swp_entry_t) { pte_val(pte) })
> > +#define __swp_entry_to_pte(x)  ((pte_t) { (x).val })
> > +#define kern_addr_valid(addr)  (1)
> > +#define pgprot_writecombine(prot)  (prot)
> > +#define pgprot_noncached pgprot_writecombine
> > +
> > +static inline int pte_file(pte_t pte) { return 0; }
> 
> No need to define pte_file() anymore. Please see my review comments for
> v8.

OK.

> 
> > +#define swapper_pg_dir ((pgd_t *) 0)
> > +/*
> > + * ZERO_PAGE is a global shared page that is always zero: used
> > + * for zero-mapped memory areas etc..
> > + */
> > +#define ZERO_PAGE(vaddr)   (virt_to_page(0))
> > +
> > +/*
> > + * These would be in other places but having them here reduces the diffs.
> > + */
> > +extern unsigned int kobjsize(const void *objp);
> > +extern int is_in_rom(unsigned long);
> 
> These aren't needed as well, as mentioned in my earlier review comments.

OK.
Thanks.

-- 
Yoshinori Sato

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-28 Thread Yoshinori Sato
At Mon, 27 Apr 2015 09:42:41 +0200,
Tobias Klauser wrote:
 
 On 2015-04-27 at 07:35:08 +0200, Yoshinori Sato ys...@users.sourceforge.jp 
 wrote:
 [...]
  diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
  new file mode 100644
  index 000..09031d0
  --- /dev/null
  +++ b/arch/h8300/include/asm/elf.h
  @@ -0,0 +1,101 @@
  +#ifndef __ASM_H8300_ELF_H
  +#define __ASM_H8300_ELF_H
  +
  +/*
  + * ELF register definitions..
  + */
  +
  +#include asm/ptrace.h
  +#include asm/user.h
  +
  +typedef unsigned long elf_greg_t;
  +
  +#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
  +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  +typedef unsigned long elf_fpregset_t;
  +
  +/*
  + * This is used to ensure we don't load something for the wrong 
  architecture.
  + */
  +#define elf_check_arch(x) ((x)-e_machine == EM_H8_300)
 
 EM_H8_300 is still used before it is introduced in patch 15/17, please
 change the patch order. Otherwise you break bisectability.

Oh. sorry.
I forgat change order.

 [...]
  diff --git a/arch/h8300/include/asm/pgtable.h 
  b/arch/h8300/include/asm/pgtable.h
  new file mode 100644
  index 000..8341db6
  --- /dev/null
  +++ b/arch/h8300/include/asm/pgtable.h
  @@ -0,0 +1,49 @@
  +#ifndef _H8300_PGTABLE_H
  +#define _H8300_PGTABLE_H
  +#include asm-generic/pgtable-nopud.h
  +#include asm-generic/pgtable.h
  +#define pgtable_cache_init()   do { } while (0)
  +extern void paging_init(void);
  +#define PAGE_NONE  __pgprot(0)/* these mean nothing to NO_MM */
  +#define PAGE_SHARED__pgprot(0)/* these mean nothing to 
  NO_MM */
  +#define PAGE_COPY  __pgprot(0)/* these mean nothing to NO_MM */
  +#define PAGE_READONLY  __pgprot(0)/* these mean nothing to NO_MM */
  +#define PAGE_KERNEL__pgprot(0)/* these mean nothing to 
  NO_MM */
  +#define __swp_type(x)  (0)
  +#define __swp_offset(x)(0)
  +#define __swp_entry(typ, off)  ((swp_entry_t) { ((typ) | ((off)  7)) 
  })
  +#define __pte_to_swp_entry(pte)((swp_entry_t) { pte_val(pte) })
  +#define __swp_entry_to_pte(x)  ((pte_t) { (x).val })
  +#define kern_addr_valid(addr)  (1)
  +#define pgprot_writecombine(prot)  (prot)
  +#define pgprot_noncached pgprot_writecombine
  +
  +static inline int pte_file(pte_t pte) { return 0; }
 
 No need to define pte_file() anymore. Please see my review comments for
 v8.

OK.

 
  +#define swapper_pg_dir ((pgd_t *) 0)
  +/*
  + * ZERO_PAGE is a global shared page that is always zero: used
  + * for zero-mapped memory areas etc..
  + */
  +#define ZERO_PAGE(vaddr)   (virt_to_page(0))
  +
  +/*
  + * These would be in other places but having them here reduces the diffs.
  + */
  +extern unsigned int kobjsize(const void *objp);
  +extern int is_in_rom(unsigned long);
 
 These aren't needed as well, as mentioned in my earlier review comments.

OK.
Thanks.

-- 
Yoshinori Sato
ys...@users.sourceforge.jp
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-28 Thread Yoshinori Sato
At Mon, 27 Apr 2015 10:40:51 +0200,
Arnd Bergmann wrote:
 
 On Monday 27 April 2015 14:35:08 Yoshinori Sato wrote:
  diff --git a/arch/h8300/include/asm/asm-offsets.h 
  b/arch/h8300/include/asm/asm-offsets.h
  new file mode 100644
  index 000..d370ee3
  --- /dev/null
  +++ b/arch/h8300/include/asm/asm-offsets.h
  @@ -0,0 +1 @@
  +#include generated/asm-offsets.h
 
 Could you add a file with these contents to include/asm-generic and use that
 instead of providing your own copy?

OK.

  diff --git a/arch/h8300/include/asm/delay.h b/arch/h8300/include/asm/delay.h
  new file mode 100644
  index 000..2bdde59
  --- /dev/null
  +++ b/arch/h8300/include/asm/delay.h
  @@ -0,0 +1,38 @@
  +#ifndef _H8300_DELAY_H
  +#define _H8300_DELAY_H
  +
  +#include asm/param.h
  +
  +/*
  + * Copyright (C) 2002 Yoshinori Sato ys...@sourceforge.jp
  + *
  + * Delay routines, using a pre-computed loops_per_second value.
  + */
  +
  +static inline void __delay(unsigned long loops)
  +{
  +   __asm__ __volatile__ (1:\n\t
  + dec.l #1,%0\n\t
  + bne 1b
  + : =r (loops) : 0(loops));
  +}
  +
 
 This could be optimized by using the clocksource instead, if that is
 accurate enough. Doing so will speed up the boot as well, because you
 can avoid calibrating the delay loop.

OK.
remove it.

 
  +#endif /* _H8300_DELAY_H */
  diff --git a/arch/h8300/include/asm/device.h 
  b/arch/h8300/include/asm/device.h
  new file mode 100644
  index 000..06746c5
  --- /dev/null
  +++ b/arch/h8300/include/asm/device.h
  @@ -0,0 +1,6 @@
  +/*
  + * Arch specific extensions to struct device
  + *
  + * This file is released under the GPLv2
  + */
  +#include asm-generic/device.h
 
 This one can obviously just use 'generic-y' isntead of including the file.
 
  diff --git a/arch/h8300/include/asm/emergency-restart.h 
  b/arch/h8300/include/asm/emergency-restart.h
  new file mode 100644
  index 000..108d8c4
  --- /dev/null
  +++ b/arch/h8300/include/asm/emergency-restart.h
  @@ -0,0 +1,6 @@
  +#ifndef _ASM_EMERGENCY_RESTART_H
  +#define _ASM_EMERGENCY_RESTART_H
  +
  +#include asm-generic/emergency-restart.h
  +
  +#endif /* _ASM_EMERGENCY_RESTART_H */
 
 Same here.

OK.

  diff --git a/arch/h8300/include/asm/io.h b/arch/h8300/include/asm/io.h
  new file mode 100644
  index 000..51ee096
  --- /dev/null
  +++ b/arch/h8300/include/asm/io.h
  @@ -0,0 +1,314 @@
  +#ifndef _H8300_IO_H
  +#define _H8300_IO_H
  +
  +#ifdef __KERNEL__
  +
  +#include linux/types.h
  +
  +#define __raw_readb(addr) ({ u8 __v = *(volatile u8 *)(addr); __v; })
  +
  +#define __raw_readw(addr) ({ u16 __v = *(volatile u16 *)(addr); __v; })
  +
  +#define __raw_readl(addr) ({ u32 __v = *(volatile u32 *)(addr); __v; })
  +
  +#define __raw_writeb(b, addr) (void)((*(volatile u8 *)(addr)) = (b))
  +
  +#define __raw_writew(b, addr) (void)((*(volatile u16 *)(addr)) = (b))
  +
  +#define __raw_writel(b, addr) (void)((*(volatile u32 *)(addr)) = (b))
  +
  +#define readb __raw_readb
  +#define readw __raw_readw
  +#define readl __raw_readl
  +#define writeb __raw_writeb
  +#define writew __raw_writew
  +#define writel __raw_writel
 
 We have recently changed this so you now have to provide readl_relaxed()
 and writel_relaxed() as well.

OK.

 As a side-note: The current definition here prevents you from ever
 using PCI devices, which are by definition little-endian. If there is
 any chance that you might need to support PCI devices later, better
 don't use the readl/writel family of accessors for platform specific
 drivers and use ioread_be32/iowrite_be32 (or an h8300-specific variant
 thereof) for any big-endian devices, and define read() etc to do a
 byte swap.

PCI is not supported.

  +#if defined(CONFIG_H83069)
  +#define ABWCR  0xFEE020
  +#elif defined(CONFIG_H8S2678)
  +#define ABWCR  0xFFFEC0
  +#endif
  +
  +#ifdef CONFIG_H8300_BUBSSWAP
  +#define _swapw(x) __builtin_bswap16(x)
  +#define _swapl(x) __builtin_bswap32(x)
  +#else
  +#define _swapw(x) (x)
  +#define _swapl(x) (x)
  +#endif
 
 Is this swapping configurable by software? The best way to do this
 is normally not to do any bus swapping in hardware at all but
 let the drivers take care of it, otherwise you will get things
 wrong in the end.
 
  +static inline void io_outsw(unsigned int addr, const void *buf, int len)
  +{
  +   volatile unsigned short *ap = (volatile unsigned short *) addr;
  +   unsigned short *bp = (unsigned short *) buf;
  +
  +   while (len--)
  +   *ap = _swapw(*bp++);
  +}
  +
  +static inline void io_outsl(unsigned int addr, const void *buf, int len)
  +{
  +   volatile unsigned short *ap = (volatile unsigned short *) addr;
  +   unsigned short *bp = (unsigned short *) buf;
  +
  +   while (len--) {
  +   *(ap + 1) = _swapw(*(bp + 0));
  +   *(ap + 0) = _swapw(*(bp + 1));
  +   bp += 2;
  +   }
  +}
 
 In particular, the outsw/insw/readsw/writesw/iowrite16_rep/ioread16_rep()
 

Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Arnd Bergmann
On Monday 27 April 2015 11:26:22 Tobias Klauser wrote:
> On 2015-04-27 at 09:48:39 +0200, Arnd Bergmann  wrote:
> > On Monday 27 April 2015 09:42:41 Tobias Klauser wrote:
> > > > diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
> > > > new file mode 100644
> > > > index 000..09031d0
> > > > --- /dev/null
> > > > +++ b/arch/h8300/include/asm/elf.h
> > > > @@ -0,0 +1,101 @@
> > > > +#ifndef __ASM_H8300_ELF_H
> > > > +#define __ASM_H8300_ELF_H
> > > > +
> > > > +/*
> > > > + * ELF register definitions..
> > > > + */
> > > > +
> > > > +#include 
> > > > +#include 
> > > > +
> > > > +typedef unsigned long elf_greg_t;
> > > > +
> > > > +#define ELF_NGREG (sizeof(struct user_regs_struct) / 
> > > > sizeof(elf_greg_t))
> > > > +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
> > > > +typedef unsigned long elf_fpregset_t;
> > > > +
> > > > +/*
> > > > + * This is used to ensure we don't load something for the wrong 
> > > > architecture.
> > > > + */
> > > > +#define elf_check_arch(x) ((x)->e_machine == EM_H8_300)
> > > 
> > > EM_H8_300 is still used before it is introduced in patch 15/17, please
> > > change the patch order. Otherwise you break bisectability.
> > 
> > While that is true in principle, I really wouldn't care about that
> > when introducing a new architecture: There is no way to use this
> > code unless you introduce all code first.
> 
> Agreed. But should the ELF machine at least be introduced before the
> build infrastructure (patch 10/17) is added? Otherwise we're able to
> compile the new arch port in principle but it will fail due to the
> missing definition.
> 

Yes, moving the the patch that adds the build scripts last in the
series makes sense.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Tobias Klauser
On 2015-04-27 at 09:48:39 +0200, Arnd Bergmann  wrote:
> On Monday 27 April 2015 09:42:41 Tobias Klauser wrote:
> > > diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
> > > new file mode 100644
> > > index 000..09031d0
> > > --- /dev/null
> > > +++ b/arch/h8300/include/asm/elf.h
> > > @@ -0,0 +1,101 @@
> > > +#ifndef __ASM_H8300_ELF_H
> > > +#define __ASM_H8300_ELF_H
> > > +
> > > +/*
> > > + * ELF register definitions..
> > > + */
> > > +
> > > +#include 
> > > +#include 
> > > +
> > > +typedef unsigned long elf_greg_t;
> > > +
> > > +#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
> > > +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
> > > +typedef unsigned long elf_fpregset_t;
> > > +
> > > +/*
> > > + * This is used to ensure we don't load something for the wrong 
> > > architecture.
> > > + */
> > > +#define elf_check_arch(x) ((x)->e_machine == EM_H8_300)
> > 
> > EM_H8_300 is still used before it is introduced in patch 15/17, please
> > change the patch order. Otherwise you break bisectability.
> 
> While that is true in principle, I really wouldn't care about that
> when introducing a new architecture: There is no way to use this
> code unless you introduce all code first.

Agreed. But should the ELF machine at least be introduced before the
build infrastructure (patch 10/17) is added? Otherwise we're able to
compile the new arch port in principle but it will fail due to the
missing definition.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Arnd Bergmann
On Monday 27 April 2015 09:42:41 Tobias Klauser wrote:
> > diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
> > new file mode 100644
> > index 000..09031d0
> > --- /dev/null
> > +++ b/arch/h8300/include/asm/elf.h
> > @@ -0,0 +1,101 @@
> > +#ifndef __ASM_H8300_ELF_H
> > +#define __ASM_H8300_ELF_H
> > +
> > +/*
> > + * ELF register definitions..
> > + */
> > +
> > +#include 
> > +#include 
> > +
> > +typedef unsigned long elf_greg_t;
> > +
> > +#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
> > +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
> > +typedef unsigned long elf_fpregset_t;
> > +
> > +/*
> > + * This is used to ensure we don't load something for the wrong 
> > architecture.
> > + */
> > +#define elf_check_arch(x) ((x)->e_machine == EM_H8_300)
> 
> EM_H8_300 is still used before it is introduced in patch 15/17, please
> change the patch order. Otherwise you break bisectability.

While that is true in principle, I really wouldn't care about that
when introducing a new architecture: There is no way to use this
code unless you introduce all code first.

For any later add-ons, bisectability should of course be maintained.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Arnd Bergmann
On Monday 27 April 2015 14:35:08 Yoshinori Sato wrote:
> diff --git a/arch/h8300/include/asm/asm-offsets.h 
> b/arch/h8300/include/asm/asm-offsets.h
> new file mode 100644
> index 000..d370ee3
> --- /dev/null
> +++ b/arch/h8300/include/asm/asm-offsets.h
> @@ -0,0 +1 @@
> +#include 

Could you add a file with these contents to include/asm-generic and use that
instead of providing your own copy?

> diff --git a/arch/h8300/include/asm/delay.h b/arch/h8300/include/asm/delay.h
> new file mode 100644
> index 000..2bdde59
> --- /dev/null
> +++ b/arch/h8300/include/asm/delay.h
> @@ -0,0 +1,38 @@
> +#ifndef _H8300_DELAY_H
> +#define _H8300_DELAY_H
> +
> +#include 
> +
> +/*
> + * Copyright (C) 2002 Yoshinori Sato 
> + *
> + * Delay routines, using a pre-computed "loops_per_second" value.
> + */
> +
> +static inline void __delay(unsigned long loops)
> +{
> + __asm__ __volatile__ ("1:\n\t"
> +   "dec.l #1,%0\n\t"
> +   "bne 1b"
> +   : "=r" (loops) : "0"(loops));
> +}
> +

This could be optimized by using the clocksource instead, if that is
accurate enough. Doing so will speed up the boot as well, because you
can avoid calibrating the delay loop.

> +#endif /* _H8300_DELAY_H */
> diff --git a/arch/h8300/include/asm/device.h b/arch/h8300/include/asm/device.h
> new file mode 100644
> index 000..06746c5
> --- /dev/null
> +++ b/arch/h8300/include/asm/device.h
> @@ -0,0 +1,6 @@
> +/*
> + * Arch specific extensions to struct device
> + *
> + * This file is released under the GPLv2
> + */
> +#include 

This one can obviously just use 'generic-y' isntead of including the file.

> diff --git a/arch/h8300/include/asm/emergency-restart.h 
> b/arch/h8300/include/asm/emergency-restart.h
> new file mode 100644
> index 000..108d8c4
> --- /dev/null
> +++ b/arch/h8300/include/asm/emergency-restart.h
> @@ -0,0 +1,6 @@
> +#ifndef _ASM_EMERGENCY_RESTART_H
> +#define _ASM_EMERGENCY_RESTART_H
> +
> +#include 
> +
> +#endif /* _ASM_EMERGENCY_RESTART_H */

Same here.

> diff --git a/arch/h8300/include/asm/io.h b/arch/h8300/include/asm/io.h
> new file mode 100644
> index 000..51ee096
> --- /dev/null
> +++ b/arch/h8300/include/asm/io.h
> @@ -0,0 +1,314 @@
> +#ifndef _H8300_IO_H
> +#define _H8300_IO_H
> +
> +#ifdef __KERNEL__
> +
> +#include 
> +
> +#define __raw_readb(addr) ({ u8 __v = *(volatile u8 *)(addr); __v; })
> +
> +#define __raw_readw(addr) ({ u16 __v = *(volatile u16 *)(addr); __v; })
> +
> +#define __raw_readl(addr) ({ u32 __v = *(volatile u32 *)(addr); __v; })
> +
> +#define __raw_writeb(b, addr) (void)((*(volatile u8 *)(addr)) = (b))
> +
> +#define __raw_writew(b, addr) (void)((*(volatile u16 *)(addr)) = (b))
> +
> +#define __raw_writel(b, addr) (void)((*(volatile u32 *)(addr)) = (b))
> +
> +#define readb __raw_readb
> +#define readw __raw_readw
> +#define readl __raw_readl
> +#define writeb __raw_writeb
> +#define writew __raw_writew
> +#define writel __raw_writel

We have recently changed this so you now have to provide readl_relaxed()
and writel_relaxed() as well.

As a side-note: The current definition here prevents you from ever
using PCI devices, which are by definition little-endian. If there is
any chance that you might need to support PCI devices later, better
don't use the readl/writel family of accessors for platform specific
drivers and use ioread_be32/iowrite_be32 (or an h8300-specific variant
thereof) for any big-endian devices, and define read() etc to do a
byte swap.

> +#if defined(CONFIG_H83069)
> +#define ABWCR  0xFEE020
> +#elif defined(CONFIG_H8S2678)
> +#define ABWCR  0xFFFEC0
> +#endif
> +
> +#ifdef CONFIG_H8300_BUBSSWAP
> +#define _swapw(x) __builtin_bswap16(x)
> +#define _swapl(x) __builtin_bswap32(x)
> +#else
> +#define _swapw(x) (x)
> +#define _swapl(x) (x)
> +#endif

Is this swapping configurable by software? The best way to do this
is normally not to do any bus swapping in hardware at all but
let the drivers take care of it, otherwise you will get things
wrong in the end.

> +static inline void io_outsw(unsigned int addr, const void *buf, int len)
> +{
> + volatile unsigned short *ap = (volatile unsigned short *) addr;
> + unsigned short *bp = (unsigned short *) buf;
> +
> + while (len--)
> + *ap = _swapw(*bp++);
> +}
> +
> +static inline void io_outsl(unsigned int addr, const void *buf, int len)
> +{
> + volatile unsigned short *ap = (volatile unsigned short *) addr;
> + unsigned short *bp = (unsigned short *) buf;
> +
> + while (len--) {
> + *(ap + 1) = _swapw(*(bp + 0));
> + *(ap + 0) = _swapw(*(bp + 1));
> + bp += 2;
> + }
> +}

In particular, the outsw/insw/readsw/writesw/iowrite16_rep/ioread16_rep()
family of function is assumed to never perform any byte swapping, because
they are used to access FIFO registers from a lot of the drivers. These
FIFOs normally contain byte streams in memory order, and Linux drivers
are written 

Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Tobias Klauser
On 2015-04-27 at 07:35:08 +0200, Yoshinori Sato  
wrote:
[...]
> diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
> new file mode 100644
> index 000..09031d0
> --- /dev/null
> +++ b/arch/h8300/include/asm/elf.h
> @@ -0,0 +1,101 @@
> +#ifndef __ASM_H8300_ELF_H
> +#define __ASM_H8300_ELF_H
> +
> +/*
> + * ELF register definitions..
> + */
> +
> +#include 
> +#include 
> +
> +typedef unsigned long elf_greg_t;
> +
> +#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
> +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
> +typedef unsigned long elf_fpregset_t;
> +
> +/*
> + * This is used to ensure we don't load something for the wrong architecture.
> + */
> +#define elf_check_arch(x) ((x)->e_machine == EM_H8_300)

EM_H8_300 is still used before it is introduced in patch 15/17, please
change the patch order. Otherwise you break bisectability.

[...]
> diff --git a/arch/h8300/include/asm/pgtable.h 
> b/arch/h8300/include/asm/pgtable.h
> new file mode 100644
> index 000..8341db6
> --- /dev/null
> +++ b/arch/h8300/include/asm/pgtable.h
> @@ -0,0 +1,49 @@
> +#ifndef _H8300_PGTABLE_H
> +#define _H8300_PGTABLE_H
> +#include 
> +#include 
> +#define pgtable_cache_init()   do { } while (0)
> +extern void paging_init(void);
> +#define PAGE_NONE__pgprot(0)/* these mean nothing to NO_MM */
> +#define PAGE_SHARED  __pgprot(0)/* these mean nothing to NO_MM */
> +#define PAGE_COPY__pgprot(0)/* these mean nothing to NO_MM */
> +#define PAGE_READONLY__pgprot(0)/* these mean nothing to NO_MM */
> +#define PAGE_KERNEL  __pgprot(0)/* these mean nothing to NO_MM */
> +#define __swp_type(x)(0)
> +#define __swp_offset(x)  (0)
> +#define __swp_entry(typ, off)((swp_entry_t) { ((typ) | ((off) << 7)) 
> })
> +#define __pte_to_swp_entry(pte)  ((swp_entry_t) { pte_val(pte) })
> +#define __swp_entry_to_pte(x)((pte_t) { (x).val })
> +#define kern_addr_valid(addr)(1)
> +#define pgprot_writecombine(prot)  (prot)
> +#define pgprot_noncached pgprot_writecombine
> +
> +static inline int pte_file(pte_t pte) { return 0; }

No need to define pte_file() anymore. Please see my review comments for
v8.

> +#define swapper_pg_dir ((pgd_t *) 0)
> +/*
> + * ZERO_PAGE is a global shared page that is always zero: used
> + * for zero-mapped memory areas etc..
> + */
> +#define ZERO_PAGE(vaddr) (virt_to_page(0))
> +
> +/*
> + * These would be in other places but having them here reduces the diffs.
> + */
> +extern unsigned int kobjsize(const void *objp);
> +extern int is_in_rom(unsigned long);

These aren't needed as well, as mentioned in my earlier review comments.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Tobias Klauser
On 2015-04-27 at 09:48:39 +0200, Arnd Bergmann a...@arndb.de wrote:
 On Monday 27 April 2015 09:42:41 Tobias Klauser wrote:
   diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
   new file mode 100644
   index 000..09031d0
   --- /dev/null
   +++ b/arch/h8300/include/asm/elf.h
   @@ -0,0 +1,101 @@
   +#ifndef __ASM_H8300_ELF_H
   +#define __ASM_H8300_ELF_H
   +
   +/*
   + * ELF register definitions..
   + */
   +
   +#include asm/ptrace.h
   +#include asm/user.h
   +
   +typedef unsigned long elf_greg_t;
   +
   +#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
   +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
   +typedef unsigned long elf_fpregset_t;
   +
   +/*
   + * This is used to ensure we don't load something for the wrong 
   architecture.
   + */
   +#define elf_check_arch(x) ((x)-e_machine == EM_H8_300)
  
  EM_H8_300 is still used before it is introduced in patch 15/17, please
  change the patch order. Otherwise you break bisectability.
 
 While that is true in principle, I really wouldn't care about that
 when introducing a new architecture: There is no way to use this
 code unless you introduce all code first.

Agreed. But should the ELF machine at least be introduced before the
build infrastructure (patch 10/17) is added? Otherwise we're able to
compile the new arch port in principle but it will fail due to the
missing definition.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Arnd Bergmann
On Monday 27 April 2015 11:26:22 Tobias Klauser wrote:
 On 2015-04-27 at 09:48:39 +0200, Arnd Bergmann a...@arndb.de wrote:
  On Monday 27 April 2015 09:42:41 Tobias Klauser wrote:
diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
new file mode 100644
index 000..09031d0
--- /dev/null
+++ b/arch/h8300/include/asm/elf.h
@@ -0,0 +1,101 @@
+#ifndef __ASM_H8300_ELF_H
+#define __ASM_H8300_ELF_H
+
+/*
+ * ELF register definitions..
+ */
+
+#include asm/ptrace.h
+#include asm/user.h
+
+typedef unsigned long elf_greg_t;
+
+#define ELF_NGREG (sizeof(struct user_regs_struct) / 
sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+typedef unsigned long elf_fpregset_t;
+
+/*
+ * This is used to ensure we don't load something for the wrong 
architecture.
+ */
+#define elf_check_arch(x) ((x)-e_machine == EM_H8_300)
   
   EM_H8_300 is still used before it is introduced in patch 15/17, please
   change the patch order. Otherwise you break bisectability.
  
  While that is true in principle, I really wouldn't care about that
  when introducing a new architecture: There is no way to use this
  code unless you introduce all code first.
 
 Agreed. But should the ELF machine at least be introduced before the
 build infrastructure (patch 10/17) is added? Otherwise we're able to
 compile the new arch port in principle but it will fail due to the
 missing definition.
 

Yes, moving the the patch that adds the build scripts last in the
series makes sense.

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Arnd Bergmann
On Monday 27 April 2015 09:42:41 Tobias Klauser wrote:
  diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
  new file mode 100644
  index 000..09031d0
  --- /dev/null
  +++ b/arch/h8300/include/asm/elf.h
  @@ -0,0 +1,101 @@
  +#ifndef __ASM_H8300_ELF_H
  +#define __ASM_H8300_ELF_H
  +
  +/*
  + * ELF register definitions..
  + */
  +
  +#include asm/ptrace.h
  +#include asm/user.h
  +
  +typedef unsigned long elf_greg_t;
  +
  +#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
  +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  +typedef unsigned long elf_fpregset_t;
  +
  +/*
  + * This is used to ensure we don't load something for the wrong 
  architecture.
  + */
  +#define elf_check_arch(x) ((x)-e_machine == EM_H8_300)
 
 EM_H8_300 is still used before it is introduced in patch 15/17, please
 change the patch order. Otherwise you break bisectability.

While that is true in principle, I really wouldn't care about that
when introducing a new architecture: There is no way to use this
code unless you introduce all code first.

For any later add-ons, bisectability should of course be maintained.

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Tobias Klauser
On 2015-04-27 at 07:35:08 +0200, Yoshinori Sato ys...@users.sourceforge.jp 
wrote:
[...]
 diff --git a/arch/h8300/include/asm/elf.h b/arch/h8300/include/asm/elf.h
 new file mode 100644
 index 000..09031d0
 --- /dev/null
 +++ b/arch/h8300/include/asm/elf.h
 @@ -0,0 +1,101 @@
 +#ifndef __ASM_H8300_ELF_H
 +#define __ASM_H8300_ELF_H
 +
 +/*
 + * ELF register definitions..
 + */
 +
 +#include asm/ptrace.h
 +#include asm/user.h
 +
 +typedef unsigned long elf_greg_t;
 +
 +#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
 +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 +typedef unsigned long elf_fpregset_t;
 +
 +/*
 + * This is used to ensure we don't load something for the wrong architecture.
 + */
 +#define elf_check_arch(x) ((x)-e_machine == EM_H8_300)

EM_H8_300 is still used before it is introduced in patch 15/17, please
change the patch order. Otherwise you break bisectability.

[...]
 diff --git a/arch/h8300/include/asm/pgtable.h 
 b/arch/h8300/include/asm/pgtable.h
 new file mode 100644
 index 000..8341db6
 --- /dev/null
 +++ b/arch/h8300/include/asm/pgtable.h
 @@ -0,0 +1,49 @@
 +#ifndef _H8300_PGTABLE_H
 +#define _H8300_PGTABLE_H
 +#include asm-generic/pgtable-nopud.h
 +#include asm-generic/pgtable.h
 +#define pgtable_cache_init()   do { } while (0)
 +extern void paging_init(void);
 +#define PAGE_NONE__pgprot(0)/* these mean nothing to NO_MM */
 +#define PAGE_SHARED  __pgprot(0)/* these mean nothing to NO_MM */
 +#define PAGE_COPY__pgprot(0)/* these mean nothing to NO_MM */
 +#define PAGE_READONLY__pgprot(0)/* these mean nothing to NO_MM */
 +#define PAGE_KERNEL  __pgprot(0)/* these mean nothing to NO_MM */
 +#define __swp_type(x)(0)
 +#define __swp_offset(x)  (0)
 +#define __swp_entry(typ, off)((swp_entry_t) { ((typ) | ((off)  7)) 
 })
 +#define __pte_to_swp_entry(pte)  ((swp_entry_t) { pte_val(pte) })
 +#define __swp_entry_to_pte(x)((pte_t) { (x).val })
 +#define kern_addr_valid(addr)(1)
 +#define pgprot_writecombine(prot)  (prot)
 +#define pgprot_noncached pgprot_writecombine
 +
 +static inline int pte_file(pte_t pte) { return 0; }

No need to define pte_file() anymore. Please see my review comments for
v8.

 +#define swapper_pg_dir ((pgd_t *) 0)
 +/*
 + * ZERO_PAGE is a global shared page that is always zero: used
 + * for zero-mapped memory areas etc..
 + */
 +#define ZERO_PAGE(vaddr) (virt_to_page(0))
 +
 +/*
 + * These would be in other places but having them here reduces the diffs.
 + */
 +extern unsigned int kobjsize(const void *objp);
 +extern int is_in_rom(unsigned long);

These aren't needed as well, as mentioned in my earlier review comments.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 01/17] h8300: Assembly headers.

2015-04-27 Thread Arnd Bergmann
On Monday 27 April 2015 14:35:08 Yoshinori Sato wrote:
 diff --git a/arch/h8300/include/asm/asm-offsets.h 
 b/arch/h8300/include/asm/asm-offsets.h
 new file mode 100644
 index 000..d370ee3
 --- /dev/null
 +++ b/arch/h8300/include/asm/asm-offsets.h
 @@ -0,0 +1 @@
 +#include generated/asm-offsets.h

Could you add a file with these contents to include/asm-generic and use that
instead of providing your own copy?

 diff --git a/arch/h8300/include/asm/delay.h b/arch/h8300/include/asm/delay.h
 new file mode 100644
 index 000..2bdde59
 --- /dev/null
 +++ b/arch/h8300/include/asm/delay.h
 @@ -0,0 +1,38 @@
 +#ifndef _H8300_DELAY_H
 +#define _H8300_DELAY_H
 +
 +#include asm/param.h
 +
 +/*
 + * Copyright (C) 2002 Yoshinori Sato ys...@sourceforge.jp
 + *
 + * Delay routines, using a pre-computed loops_per_second value.
 + */
 +
 +static inline void __delay(unsigned long loops)
 +{
 + __asm__ __volatile__ (1:\n\t
 +   dec.l #1,%0\n\t
 +   bne 1b
 +   : =r (loops) : 0(loops));
 +}
 +

This could be optimized by using the clocksource instead, if that is
accurate enough. Doing so will speed up the boot as well, because you
can avoid calibrating the delay loop.

 +#endif /* _H8300_DELAY_H */
 diff --git a/arch/h8300/include/asm/device.h b/arch/h8300/include/asm/device.h
 new file mode 100644
 index 000..06746c5
 --- /dev/null
 +++ b/arch/h8300/include/asm/device.h
 @@ -0,0 +1,6 @@
 +/*
 + * Arch specific extensions to struct device
 + *
 + * This file is released under the GPLv2
 + */
 +#include asm-generic/device.h

This one can obviously just use 'generic-y' isntead of including the file.

 diff --git a/arch/h8300/include/asm/emergency-restart.h 
 b/arch/h8300/include/asm/emergency-restart.h
 new file mode 100644
 index 000..108d8c4
 --- /dev/null
 +++ b/arch/h8300/include/asm/emergency-restart.h
 @@ -0,0 +1,6 @@
 +#ifndef _ASM_EMERGENCY_RESTART_H
 +#define _ASM_EMERGENCY_RESTART_H
 +
 +#include asm-generic/emergency-restart.h
 +
 +#endif /* _ASM_EMERGENCY_RESTART_H */

Same here.

 diff --git a/arch/h8300/include/asm/io.h b/arch/h8300/include/asm/io.h
 new file mode 100644
 index 000..51ee096
 --- /dev/null
 +++ b/arch/h8300/include/asm/io.h
 @@ -0,0 +1,314 @@
 +#ifndef _H8300_IO_H
 +#define _H8300_IO_H
 +
 +#ifdef __KERNEL__
 +
 +#include linux/types.h
 +
 +#define __raw_readb(addr) ({ u8 __v = *(volatile u8 *)(addr); __v; })
 +
 +#define __raw_readw(addr) ({ u16 __v = *(volatile u16 *)(addr); __v; })
 +
 +#define __raw_readl(addr) ({ u32 __v = *(volatile u32 *)(addr); __v; })
 +
 +#define __raw_writeb(b, addr) (void)((*(volatile u8 *)(addr)) = (b))
 +
 +#define __raw_writew(b, addr) (void)((*(volatile u16 *)(addr)) = (b))
 +
 +#define __raw_writel(b, addr) (void)((*(volatile u32 *)(addr)) = (b))
 +
 +#define readb __raw_readb
 +#define readw __raw_readw
 +#define readl __raw_readl
 +#define writeb __raw_writeb
 +#define writew __raw_writew
 +#define writel __raw_writel

We have recently changed this so you now have to provide readl_relaxed()
and writel_relaxed() as well.

As a side-note: The current definition here prevents you from ever
using PCI devices, which are by definition little-endian. If there is
any chance that you might need to support PCI devices later, better
don't use the readl/writel family of accessors for platform specific
drivers and use ioread_be32/iowrite_be32 (or an h8300-specific variant
thereof) for any big-endian devices, and define read() etc to do a
byte swap.

 +#if defined(CONFIG_H83069)
 +#define ABWCR  0xFEE020
 +#elif defined(CONFIG_H8S2678)
 +#define ABWCR  0xFFFEC0
 +#endif
 +
 +#ifdef CONFIG_H8300_BUBSSWAP
 +#define _swapw(x) __builtin_bswap16(x)
 +#define _swapl(x) __builtin_bswap32(x)
 +#else
 +#define _swapw(x) (x)
 +#define _swapl(x) (x)
 +#endif

Is this swapping configurable by software? The best way to do this
is normally not to do any bus swapping in hardware at all but
let the drivers take care of it, otherwise you will get things
wrong in the end.

 +static inline void io_outsw(unsigned int addr, const void *buf, int len)
 +{
 + volatile unsigned short *ap = (volatile unsigned short *) addr;
 + unsigned short *bp = (unsigned short *) buf;
 +
 + while (len--)
 + *ap = _swapw(*bp++);
 +}
 +
 +static inline void io_outsl(unsigned int addr, const void *buf, int len)
 +{
 + volatile unsigned short *ap = (volatile unsigned short *) addr;
 + unsigned short *bp = (unsigned short *) buf;
 +
 + while (len--) {
 + *(ap + 1) = _swapw(*(bp + 0));
 + *(ap + 0) = _swapw(*(bp + 1));
 + bp += 2;
 + }
 +}

In particular, the outsw/insw/readsw/writesw/iowrite16_rep/ioread16_rep()
family of function is assumed to never perform any byte swapping, because
they are used to access FIFO registers from a lot of the drivers. These
FIFOs normally contain byte streams in memory order, and Linux drivers
are written to assume that 

[PATCH v9 01/17] h8300: Assembly headers.

2015-04-26 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/h8300/include/asm/Kbuild  |  66 ++
 arch/h8300/include/asm/asm-offsets.h   |   1 +
 arch/h8300/include/asm/atomic.h| 159 +++
 arch/h8300/include/asm/bitops.h| 185 +
 arch/h8300/include/asm/bootparams.h|  17 ++
 arch/h8300/include/asm/bug.h   |  12 ++
 arch/h8300/include/asm/cache.h |  11 +
 arch/h8300/include/asm/checksum.h  | 102 ++
 arch/h8300/include/asm/cmpxchg.h   |  65 ++
 arch/h8300/include/asm/delay.h |  38 
 arch/h8300/include/asm/device.h|   6 +
 arch/h8300/include/asm/dma-mapping.h   | 124 
 arch/h8300/include/asm/elf.h   | 101 ++
 arch/h8300/include/asm/emergency-restart.h |   6 +
 arch/h8300/include/asm/flat.h  |  27 +++
 arch/h8300/include/asm/io.h| 314 +
 arch/h8300/include/asm/irq.h   |  26 +++
 arch/h8300/include/asm/irqflags.h  |  96 +
 arch/h8300/include/asm/mc146818rtc.h   |   9 +
 arch/h8300/include/asm/mutex.h |   9 +
 arch/h8300/include/asm/page.h  |  18 ++
 arch/h8300/include/asm/page_offset.h   |   2 +
 arch/h8300/include/asm/pci.h   |  19 ++
 arch/h8300/include/asm/pgtable.h   |  49 +
 arch/h8300/include/asm/processor.h | 144 +
 arch/h8300/include/asm/ptrace.h|  36 
 arch/h8300/include/asm/segment.h   |  49 +
 arch/h8300/include/asm/signal.h|  22 ++
 arch/h8300/include/asm/smp.h   |   1 +
 arch/h8300/include/asm/spinlock.h  |   6 +
 arch/h8300/include/asm/string.h|  17 ++
 arch/h8300/include/asm/switch_to.h |  51 +
 arch/h8300/include/asm/syscall.h   |  56 +
 arch/h8300/include/asm/thread_info.h   | 108 ++
 arch/h8300/include/asm/timer.h |  31 +++
 arch/h8300/include/asm/tlb.h   |   8 +
 arch/h8300/include/asm/topology.h  |   6 +
 arch/h8300/include/asm/traps.h |  41 
 arch/h8300/include/asm/uaccess.h   | 136 +
 arch/h8300/include/asm/unaligned.h |  11 +
 arch/h8300/include/asm/user.h  |  74 +++
 41 files changed, 2259 insertions(+)
 create mode 100644 arch/h8300/include/asm/Kbuild
 create mode 100644 arch/h8300/include/asm/asm-offsets.h
 create mode 100644 arch/h8300/include/asm/atomic.h
 create mode 100644 arch/h8300/include/asm/bitops.h
 create mode 100644 arch/h8300/include/asm/bootparams.h
 create mode 100644 arch/h8300/include/asm/bug.h
 create mode 100644 arch/h8300/include/asm/cache.h
 create mode 100644 arch/h8300/include/asm/checksum.h
 create mode 100644 arch/h8300/include/asm/cmpxchg.h
 create mode 100644 arch/h8300/include/asm/delay.h
 create mode 100644 arch/h8300/include/asm/device.h
 create mode 100644 arch/h8300/include/asm/dma-mapping.h
 create mode 100644 arch/h8300/include/asm/elf.h
 create mode 100644 arch/h8300/include/asm/emergency-restart.h
 create mode 100644 arch/h8300/include/asm/flat.h
 create mode 100644 arch/h8300/include/asm/io.h
 create mode 100644 arch/h8300/include/asm/irq.h
 create mode 100644 arch/h8300/include/asm/irqflags.h
 create mode 100644 arch/h8300/include/asm/mc146818rtc.h
 create mode 100644 arch/h8300/include/asm/mutex.h
 create mode 100644 arch/h8300/include/asm/page.h
 create mode 100644 arch/h8300/include/asm/page_offset.h
 create mode 100644 arch/h8300/include/asm/pci.h
 create mode 100644 arch/h8300/include/asm/pgtable.h
 create mode 100644 arch/h8300/include/asm/processor.h
 create mode 100644 arch/h8300/include/asm/ptrace.h
 create mode 100644 arch/h8300/include/asm/segment.h
 create mode 100644 arch/h8300/include/asm/signal.h
 create mode 100644 arch/h8300/include/asm/smp.h
 create mode 100644 arch/h8300/include/asm/spinlock.h
 create mode 100644 arch/h8300/include/asm/string.h
 create mode 100644 arch/h8300/include/asm/switch_to.h
 create mode 100644 arch/h8300/include/asm/syscall.h
 create mode 100644 arch/h8300/include/asm/thread_info.h
 create mode 100644 arch/h8300/include/asm/timer.h
 create mode 100644 arch/h8300/include/asm/tlb.h
 create mode 100644 arch/h8300/include/asm/topology.h
 create mode 100644 arch/h8300/include/asm/traps.h
 create mode 100644 arch/h8300/include/asm/uaccess.h
 create mode 100644 arch/h8300/include/asm/unaligned.h
 create mode 100644 arch/h8300/include/asm/user.h

diff --git a/arch/h8300/include/asm/Kbuild b/arch/h8300/include/asm/Kbuild
new file mode 100644
index 000..9e9f4f3
--- /dev/null
+++ b/arch/h8300/include/asm/Kbuild
@@ -0,0 +1,66 @@
+generic-y += barrier.h
+generic-y += bitsperlong.h
+generic-y += bugs.h
+generic-y += cacheflush.h
+generic-y += clkdev.h
+generic-y += cputime.h
+generic-y += current.h
+generic-y += div64.h
+generic-y += dma.h
+generic-y += emergency-restart.h
+generic-y += 

[PATCH v9 01/17] h8300: Assembly headers.

2015-04-26 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato ys...@users.sourceforge.jp
---
 arch/h8300/include/asm/Kbuild  |  66 ++
 arch/h8300/include/asm/asm-offsets.h   |   1 +
 arch/h8300/include/asm/atomic.h| 159 +++
 arch/h8300/include/asm/bitops.h| 185 +
 arch/h8300/include/asm/bootparams.h|  17 ++
 arch/h8300/include/asm/bug.h   |  12 ++
 arch/h8300/include/asm/cache.h |  11 +
 arch/h8300/include/asm/checksum.h  | 102 ++
 arch/h8300/include/asm/cmpxchg.h   |  65 ++
 arch/h8300/include/asm/delay.h |  38 
 arch/h8300/include/asm/device.h|   6 +
 arch/h8300/include/asm/dma-mapping.h   | 124 
 arch/h8300/include/asm/elf.h   | 101 ++
 arch/h8300/include/asm/emergency-restart.h |   6 +
 arch/h8300/include/asm/flat.h  |  27 +++
 arch/h8300/include/asm/io.h| 314 +
 arch/h8300/include/asm/irq.h   |  26 +++
 arch/h8300/include/asm/irqflags.h  |  96 +
 arch/h8300/include/asm/mc146818rtc.h   |   9 +
 arch/h8300/include/asm/mutex.h |   9 +
 arch/h8300/include/asm/page.h  |  18 ++
 arch/h8300/include/asm/page_offset.h   |   2 +
 arch/h8300/include/asm/pci.h   |  19 ++
 arch/h8300/include/asm/pgtable.h   |  49 +
 arch/h8300/include/asm/processor.h | 144 +
 arch/h8300/include/asm/ptrace.h|  36 
 arch/h8300/include/asm/segment.h   |  49 +
 arch/h8300/include/asm/signal.h|  22 ++
 arch/h8300/include/asm/smp.h   |   1 +
 arch/h8300/include/asm/spinlock.h  |   6 +
 arch/h8300/include/asm/string.h|  17 ++
 arch/h8300/include/asm/switch_to.h |  51 +
 arch/h8300/include/asm/syscall.h   |  56 +
 arch/h8300/include/asm/thread_info.h   | 108 ++
 arch/h8300/include/asm/timer.h |  31 +++
 arch/h8300/include/asm/tlb.h   |   8 +
 arch/h8300/include/asm/topology.h  |   6 +
 arch/h8300/include/asm/traps.h |  41 
 arch/h8300/include/asm/uaccess.h   | 136 +
 arch/h8300/include/asm/unaligned.h |  11 +
 arch/h8300/include/asm/user.h  |  74 +++
 41 files changed, 2259 insertions(+)
 create mode 100644 arch/h8300/include/asm/Kbuild
 create mode 100644 arch/h8300/include/asm/asm-offsets.h
 create mode 100644 arch/h8300/include/asm/atomic.h
 create mode 100644 arch/h8300/include/asm/bitops.h
 create mode 100644 arch/h8300/include/asm/bootparams.h
 create mode 100644 arch/h8300/include/asm/bug.h
 create mode 100644 arch/h8300/include/asm/cache.h
 create mode 100644 arch/h8300/include/asm/checksum.h
 create mode 100644 arch/h8300/include/asm/cmpxchg.h
 create mode 100644 arch/h8300/include/asm/delay.h
 create mode 100644 arch/h8300/include/asm/device.h
 create mode 100644 arch/h8300/include/asm/dma-mapping.h
 create mode 100644 arch/h8300/include/asm/elf.h
 create mode 100644 arch/h8300/include/asm/emergency-restart.h
 create mode 100644 arch/h8300/include/asm/flat.h
 create mode 100644 arch/h8300/include/asm/io.h
 create mode 100644 arch/h8300/include/asm/irq.h
 create mode 100644 arch/h8300/include/asm/irqflags.h
 create mode 100644 arch/h8300/include/asm/mc146818rtc.h
 create mode 100644 arch/h8300/include/asm/mutex.h
 create mode 100644 arch/h8300/include/asm/page.h
 create mode 100644 arch/h8300/include/asm/page_offset.h
 create mode 100644 arch/h8300/include/asm/pci.h
 create mode 100644 arch/h8300/include/asm/pgtable.h
 create mode 100644 arch/h8300/include/asm/processor.h
 create mode 100644 arch/h8300/include/asm/ptrace.h
 create mode 100644 arch/h8300/include/asm/segment.h
 create mode 100644 arch/h8300/include/asm/signal.h
 create mode 100644 arch/h8300/include/asm/smp.h
 create mode 100644 arch/h8300/include/asm/spinlock.h
 create mode 100644 arch/h8300/include/asm/string.h
 create mode 100644 arch/h8300/include/asm/switch_to.h
 create mode 100644 arch/h8300/include/asm/syscall.h
 create mode 100644 arch/h8300/include/asm/thread_info.h
 create mode 100644 arch/h8300/include/asm/timer.h
 create mode 100644 arch/h8300/include/asm/tlb.h
 create mode 100644 arch/h8300/include/asm/topology.h
 create mode 100644 arch/h8300/include/asm/traps.h
 create mode 100644 arch/h8300/include/asm/uaccess.h
 create mode 100644 arch/h8300/include/asm/unaligned.h
 create mode 100644 arch/h8300/include/asm/user.h

diff --git a/arch/h8300/include/asm/Kbuild b/arch/h8300/include/asm/Kbuild
new file mode 100644
index 000..9e9f4f3
--- /dev/null
+++ b/arch/h8300/include/asm/Kbuild
@@ -0,0 +1,66 @@
+generic-y += barrier.h
+generic-y += bitsperlong.h
+generic-y += bugs.h
+generic-y += cacheflush.h
+generic-y += clkdev.h
+generic-y += cputime.h
+generic-y += current.h
+generic-y += div64.h
+generic-y += dma.h
+generic-y +=