Re: [PATCH v2] MAINTAINERS: Remove Mohit Kumar (email bounces)

2015-04-26 Thread Viresh Kumar
On Mon, Apr 27, 2015 at 11:13 AM, Viresh Kumar  wrote:
> Anyway, please hold on this patch and I will update it for them.

Ahh, its already gone. :)

Okay, I will let them handle it now. Guys please fix your email-ids in kernel.
--
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 v2] MAINTAINERS: Remove Mohit Kumar (email bounces)

2015-04-26 Thread Viresh Kumar
[Fixing Mohit's and Pratyush's email ids]

On Wed, Apr 22, 2015 at 1:58 AM, Bjorn Helgaas  wrote:
> Email to Mohit Kumar  has been bouncing, so remove the
> address from MAINTAINERS and add an entry in CREDITS.
>
> Signed-off-by: Bjorn Helgaas 
> ---
>  CREDITS |4 
>  MAINTAINERS |4 +---
>  2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/CREDITS b/CREDITS
> index 843e17647f3b..6bb0d51e83de 100644
> --- a/CREDITS
> +++ b/CREDITS
> @@ -2045,6 +2045,10 @@ D: pirq addr, CS5535 alsa audio driver
>  S: Gurgaon, India
>  S: Kuala Lumpur, Malaysia
>
> +N: Mohit Kumar
> +D: ST Microelectronics SPEAr13xx PCI host bridge driver
> +D: Synopsys Designware PCI host bridge driver
> +
>  N: Gabor Kuti
>  M: seas...@falcon.sch.bme.hu
>  M: seas...@makosteszta.sote.hu
> diff --git a/MAINTAINERS b/MAINTAINERS
> index a123c39b4f0e..1c95b707a5f6 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -7490,7 +7490,6 @@ S:Maintained
>  F: drivers/pci/host/pci-exynos.c
>
>  PCI DRIVER FOR SYNOPSIS DESIGNWARE
> -M: Mohit Kumar 
>  M: Jingoo Han 
>  L: linux-...@vger.kernel.org
>  S: Maintained
> @@ -7505,9 +7504,8 @@ F:
> Documentation/devicetree/bindings/pci/host-generic-pci.txt
>  F: drivers/pci/host/pci-host-generic.c
>
>  PCIE DRIVER FOR ST SPEAR13XX
> -M: Mohit Kumar 
>  L: linux-...@vger.kernel.org
> -S: Maintained
> +S: Orphan
>  F: drivers/pci/host/*spear*
>
>  PCMCIA SUBSYSTEM

Its really sad that we have to get down to this, these two
should have done it..

Anyway, please hold on this patch and I will update it for them.
--
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 3/3] btrfs: set FS_SUPPORTS_SEEK_HOLE flag.

2015-04-26 Thread NeilBrown
On Mon, 20 Apr 2015 02:48:55 -0700 Christoph Hellwig 
wrote:

> On Mon, Apr 20, 2015 at 10:46:49AM +0100, David Howells wrote:
> > NeilBrown  wrote:
> > 
> > > Missing patch 2 of the 3-patch series?
> > 
> > Yes. :-)
> > 
> > Do ext4 and xfs support this, do you know?
> 
> Yes.  As do f2fs, ocfs2, gfs2, ceph and NFSv4.2

Are you sure about NFSv4.2?

I see that it *can* report holes, but is there any guarantee that if you
create a new file and write only the 5th block, then READ_PLUS will reliably
report that the first 4 block are holes??

Because if it doesn't guarantee that, then NFSv4.2 doesn't fit the with the
others where SEEK_HOLE reliable reports holes.
On the other hand if NFSv4.2 *does* guarantee that then the current READ_PLUS
server patches are broken because they just use vfs_llseek and assume that
trust what it says.

It would be really nice if SEEK_{DATA,HOLE} either reported holes reliably or
returned ENXIO, but I guess there was a goo reason not to do that.

Thanks,
NeilBrown


pgplq8OqNgsRG.pgp
Description: OpenPGP digital signature


[PATCH v9 02/17] h8300: UAPI headers

2015-04-26 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/h8300/include/uapi/asm/Kbuild   |  29 
 arch/h8300/include/uapi/asm/auxvec.h |   4 ++
 arch/h8300/include/uapi/asm/byteorder.h  |   6 ++
 arch/h8300/include/uapi/asm/ptrace.h |  42 +++
 arch/h8300/include/uapi/asm/sigcontext.h |  18 +
 arch/h8300/include/uapi/asm/signal.h | 115 +++
 arch/h8300/include/uapi/asm/swab.h   |   1 +
 arch/h8300/include/uapi/asm/unistd.h |   3 +
 8 files changed, 218 insertions(+)
 create mode 100644 arch/h8300/include/uapi/asm/Kbuild
 create mode 100644 arch/h8300/include/uapi/asm/auxvec.h
 create mode 100644 arch/h8300/include/uapi/asm/byteorder.h
 create mode 100644 arch/h8300/include/uapi/asm/ptrace.h
 create mode 100644 arch/h8300/include/uapi/asm/sigcontext.h
 create mode 100644 arch/h8300/include/uapi/asm/signal.h
 create mode 100644 arch/h8300/include/uapi/asm/swab.h
 create mode 100644 arch/h8300/include/uapi/asm/unistd.h

diff --git a/arch/h8300/include/uapi/asm/Kbuild 
b/arch/h8300/include/uapi/asm/Kbuild
new file mode 100644
index 000..077e720
--- /dev/null
+++ b/arch/h8300/include/uapi/asm/Kbuild
@@ -0,0 +1,29 @@
+# UAPI Header export list
+include include/uapi/asm-generic/Kbuild.asm
+
+header-y += auxvec.h
+header-y += bitsperlong.h
+header-y += errno.h
+header-y += fcntl.h
+header-y += ioctl.h
+header-y += ioctls.h
+header-y += ipcbuf.h
+header-y += kvm_para.h
+header-y += mman.h
+header-y += msgbuf.h
+header-y += param.h
+header-y += poll.h
+header-y += posix_types.h
+header-y += resource.h
+header-y += sembuf.h
+header-y += setup.h
+header-y += shmbuf.h
+header-y += siginfo.h
+header-y += socket.h
+header-y += sockios.h
+header-y += stat.h
+header-y += statfs.h
+header-y += termbits.h
+header-y += termios.h
+header-y += types.h
+header-y += unistd.h
diff --git a/arch/h8300/include/uapi/asm/auxvec.h 
b/arch/h8300/include/uapi/asm/auxvec.h
new file mode 100644
index 000..1d36fe38
--- /dev/null
+++ b/arch/h8300/include/uapi/asm/auxvec.h
@@ -0,0 +1,4 @@
+#ifndef __ASMH8300_AUXVEC_H
+#define __ASMH8300_AUXVEC_H
+
+#endif
diff --git a/arch/h8300/include/uapi/asm/byteorder.h 
b/arch/h8300/include/uapi/asm/byteorder.h
new file mode 100644
index 000..13539da
--- /dev/null
+++ b/arch/h8300/include/uapi/asm/byteorder.h
@@ -0,0 +1,6 @@
+#ifndef _H8300_BYTEORDER_H
+#define _H8300_BYTEORDER_H
+
+#include 
+
+#endif /* _H8300_BYTEORDER_H */
diff --git a/arch/h8300/include/uapi/asm/ptrace.h 
b/arch/h8300/include/uapi/asm/ptrace.h
new file mode 100644
index 000..e132670d
--- /dev/null
+++ b/arch/h8300/include/uapi/asm/ptrace.h
@@ -0,0 +1,42 @@
+#ifndef _UAPI_H8300_PTRACE_H
+#define _UAPI_H8300_PTRACE_H
+
+#ifndef __ASSEMBLY__
+
+#define PT_ER10
+#define PT_ER21
+#define PT_ER32
+#define PT_ER43
+#define PT_ER54
+#define PT_ER65
+#define PT_ER06
+#define PT_USP7
+#define PT_ORIG_ER0   8
+#define PT_CCR9
+#define PT_PC 10
+#define PT_EXR 11
+
+/* this struct defines the way the registers are stored on the
+   stack during a system call. */
+
+struct pt_regs {
+   long retpc;
+   long er4;
+   long er5;
+   long er6;
+   long er3;
+   long er2;
+   long er1;
+   long orig_er0;
+   long sp;
+   unsigned short   ccr;
+   long er0;
+   long vector;
+#if defined(__H8300S__)
+   unsigned short   exr;
+#endif
+   unsigned long  pc;
+} __attribute__((aligned(2), packed));
+
+#endif /* __ASSEMBLY__ */
+#endif /* _UAPI_H8300_PTRACE_H */
diff --git a/arch/h8300/include/uapi/asm/sigcontext.h 
b/arch/h8300/include/uapi/asm/sigcontext.h
new file mode 100644
index 000..c41fdaa
--- /dev/null
+++ b/arch/h8300/include/uapi/asm/sigcontext.h
@@ -0,0 +1,18 @@
+#ifndef _ASM_H8300_SIGCONTEXT_H
+#define _ASM_H8300_SIGCONTEXT_H
+
+struct sigcontext {
+   unsigned long  sc_mask; /* old sigmask */
+   unsigned long  sc_usp;  /* old user stack pointer */
+   unsigned long  sc_er0;
+   unsigned long  sc_er1;
+   unsigned long  sc_er2;
+   unsigned long  sc_er3;
+   unsigned long  sc_er4;
+   unsigned long  sc_er5;
+   unsigned long  sc_er6;
+   unsigned short sc_ccr;
+   unsigned long  sc_pc;
+};
+
+#endif
diff --git a/arch/h8300/include/uapi/asm/signal.h 
b/arch/h8300/include/uapi/asm/signal.h
new file mode 100644
index 000..af3a6c3
--- /dev/null
+++ b/arch/h8300/include/uapi/asm/signal.h
@@ -0,0 +1,115 @@
+#ifndef _UAPI_H8300_SIGNAL_H
+#define _UAPI_H8300_SIGNAL_H
+
+#include 
+
+/* Avoid too many header ordering problems.  */
+struct siginfo;
+
+#ifndef __KERNEL__
+/* Here we must cater to libcs that poke about in kernel headers.  */
+
+#define NSIG   32
+typedef unsigned long sigset_t;
+
+#endif /* __KERNEL__ */
+
+#define SIGHUP  1
+#define SIGINT  2
+#define SIGQUIT 3
+#define SIGILL  4
+#define SIGTRAP

[PATCH v9 05/17] h8300: process and signals

2015-04-26 Thread Yoshinori Sato
process management helper and signal handling

Signed-off-by: Yoshinori Sato 
---
 arch/h8300/kernel/process.c | 171 ++
 arch/h8300/kernel/ptrace.c  | 203 +++
 arch/h8300/kernel/signal.c  | 289 
 3 files changed, 663 insertions(+)
 create mode 100644 arch/h8300/kernel/process.c
 create mode 100644 arch/h8300/kernel/ptrace.c
 create mode 100644 arch/h8300/kernel/signal.c

diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c
new file mode 100644
index 000..dee4125
--- /dev/null
+++ b/arch/h8300/kernel/process.c
@@ -0,0 +1,171 @@
+/*
+ *  linux/arch/h8300/kernel/process.c
+ *
+ * Yoshinori Sato 
+ *
+ *  Based on:
+ *
+ *  linux/arch/m68knommu/kernel/process.c
+ *
+ *  Copyright (C) 1998  D. Jeff Dionne ,
+ *  Kenneth Albanowski ,
+ *  The Silver Hammer Group, Ltd.
+ *
+ *  linux/arch/m68k/kernel/process.c
+ *
+ *  Copyright (C) 1995  Hamish Macdonald
+ *
+ *  68060 fixes by Jesper Skov
+ */
+
+/*
+ * This file handles the architecture-dependent parts of process handling..
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+void (*pm_power_off)(void) = NULL;
+EXPORT_SYMBOL(pm_power_off);
+
+asmlinkage void ret_from_fork(void);
+asmlinkage void ret_from_kernel_thread(void);
+
+/*
+ * The idle loop on an H8/300..
+ */
+void arch_cpu_idle(void)
+{
+   local_irq_enable();
+   __asm__("sleep");
+}
+
+void machine_restart(char *__unused)
+{
+   local_irq_disable();
+   __asm__("jmp @@0");
+}
+
+void machine_halt(void)
+{
+   local_irq_disable();
+   __asm__("sleep");
+   for (;;)
+   ;
+}
+
+void machine_power_off(void)
+{
+   local_irq_disable();
+   __asm__("sleep");
+   for (;;)
+   ;
+}
+
+void show_regs(struct pt_regs *regs)
+{
+   show_regs_print_info(KERN_DEFAULT);
+
+   pr_notice("\n");
+   pr_notice("PC: %08lx  Status: %02x\n",
+  regs->pc, regs->ccr);
+   pr_notice("ORIG_ER0: %08lx ER0: %08lx ER1: %08lx\n",
+  regs->orig_er0, regs->er0, regs->er1);
+   pr_notice("ER2: %08lx ER3: %08lx ER4: %08lx ER5: %08lx\n",
+  regs->er2, regs->er3, regs->er4, regs->er5);
+   pr_notice("ER6' %08lx ", regs->er6);
+   if (user_mode(regs))
+   printk("USP: %08lx\n", rdusp());
+   else
+   printk("\n");
+}
+
+void flush_thread(void)
+{
+}
+
+int copy_thread(unsigned long clone_flags,
+   unsigned long usp, unsigned long topstk,
+   struct task_struct *p)
+{
+   struct pt_regs *childregs;
+
+   childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1;
+
+   if (unlikely(p->flags & PF_KTHREAD)) {
+   memset(childregs, 0, sizeof(struct pt_regs));
+   childregs->retpc = (unsigned long) ret_from_kernel_thread;
+   childregs->er4 = topstk; /* arg */
+   childregs->er5 = usp; /* fn */
+   }  else {
+   *childregs = *current_pt_regs();
+   childregs->er0 = 0;
+   childregs->retpc = (unsigned long) ret_from_fork;
+   p->thread.usp = usp ?: rdusp();
+   }
+   p->thread.ksp = (unsigned long)childregs;
+
+   return 0;
+}
+
+unsigned long thread_saved_pc(struct task_struct *tsk)
+{
+   return ((struct pt_regs *)tsk->thread.esp0)->pc;
+}
+
+unsigned long get_wchan(struct task_struct *p)
+{
+   unsigned long fp, pc;
+   unsigned long stack_page;
+   int count = 0;
+
+   if (!p || p == current || p->state == TASK_RUNNING)
+   return 0;
+
+   stack_page = (unsigned long)p;
+   fp = ((struct pt_regs *)p->thread.ksp)->er6;
+   do {
+   if (fp < stack_page+sizeof(struct thread_info) ||
+   fp >= 8184+stack_page)
+   return 0;
+   pc = ((unsigned long *)fp)[1];
+   if (!in_sched_functions(pc))
+   return pc;
+   fp = *(unsigned long *) fp;
+   } while (count++ < 16);
+   return 0;
+}
+
+/* generic sys_clone is not enough registers */
+asmlinkage int sys_clone(unsigned long __user *args)
+{
+   unsigned long clone_flags;
+   unsigned long  newsp;
+   uintptr_t parent_tidptr;
+   uintptr_t child_tidptr;
+
+   get_user(clone_flags, [0]);
+   get_user(newsp, [1]);
+   get_user(parent_tidptr, [2]);
+   get_user(child_tidptr, [3]);
+   return do_fork(clone_flags, newsp, 0,
+  (int __user *)parent_tidptr, (int __user *)child_tidptr);
+}
diff --git a/arch/h8300/kernel/ptrace.c b/arch/h8300/kernel/ptrace.c
new file mode 100644
index 000..9207554
--- /dev/null
+++ b/arch/h8300/kernel/ptrace.c
@@ -0,0 +1,203 @@

[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 03/17] h8300: Exception and Interrupt handling

2015-04-26 Thread Yoshinori Sato
h8300 exception entry and exception / interrupt handling

Signed-off-by: Yoshinori Sato 
---
 arch/h8300/kernel/entry.S | 414 ++
 arch/h8300/kernel/irq.c   | 100 +++
 arch/h8300/kernel/traps.c | 161 ++
 3 files changed, 675 insertions(+)
 create mode 100644 arch/h8300/kernel/entry.S
 create mode 100644 arch/h8300/kernel/irq.c
 create mode 100644 arch/h8300/kernel/traps.c

diff --git a/arch/h8300/kernel/entry.S b/arch/h8300/kernel/entry.S
new file mode 100644
index 000..797dfa8
--- /dev/null
+++ b/arch/h8300/kernel/entry.S
@@ -0,0 +1,414 @@
+/*
+ *
+ *  linux/arch/h8300/kernel/entry.S
+ *
+ *  Yoshinori Sato 
+ *  David McCullough 
+ *
+ */
+
+/*
+ *  entry.S
+ *  include exception/interrupt gateway
+ *  system call entry
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#if defined(CONFIG_CPU_H8300H)
+#define USERRET 8
+INTERRUPTS = 64
+   .h8300h
+   .macro  SHLL2 reg
+   shll.l  \reg
+   shll.l  \reg
+   .endm
+   .macro  SHLR2 reg
+   shlr.l  \reg
+   shlr.l  \reg
+   .endm
+   .macro  SAVEREGS
+   mov.l   er0,@-sp
+   mov.l   er1,@-sp
+   mov.l   er2,@-sp
+   mov.l   er3,@-sp
+   .endm
+   .macro  RESTOREREGS
+   mov.l   @sp+,er3
+   mov.l   @sp+,er2
+   .endm
+   .macro  SAVEEXR
+   .endm
+   .macro  RESTOREEXR
+   .endm
+#endif
+#if defined(CONFIG_CPU_H8S)
+#define USERRET 10
+#define USEREXR 8
+INTERRUPTS = 128
+   .h8300s
+   .macro  SHLL2 reg
+   shll.l  #2,\reg
+   .endm
+   .macro  SHLR2 reg
+   shlr.l  #2,\reg
+   .endm
+   .macro  SAVEREGS
+   stm.l   er0-er3,@-sp
+   .endm
+   .macro  RESTOREREGS
+   ldm.l   @sp+,er2-er3
+   .endm
+   .macro  SAVEEXR
+   mov.w   @(USEREXR:16,er0),r1
+   mov.w   r1,@(LEXR-LER3:16,sp)   /* copy EXR */
+   .endm
+   .macro  RESTOREEXR
+   mov.w   @(LEXR-LER1:16,sp),r1   /* restore EXR */
+   mov.b   r1l,r1h
+   mov.w   r1,@(USEREXR:16,er0)
+   .endm
+#endif
+
+
+/* CPU context save/restore macros. */
+
+   .macro  SAVE_ALL
+   mov.l   er0,@-sp
+   stc ccr,r0l /* check kernel mode */
+   btst#4,r0l
+   bne 5f
+
+   /* user mode */
+   mov.l   sp,@_sw_usp
+   mov.l   @sp,er0 /* restore saved er0 */
+   orc #0x10,ccr   /* switch kernel stack */
+   mov.l   @_sw_ksp,sp
+   sub.l   #(LRET-LORIG),sp/* allocate LORIG - LRET */
+   SAVEREGS
+   mov.l   @_sw_usp,er0
+   mov.l   @(USERRET:16,er0),er1   /* copy the RET addr */
+   mov.l   er1,@(LRET-LER3:16,sp)
+   SAVEEXR
+
+   mov.l   @(LORIG-LER3:16,sp),er0
+   mov.l   er0,@(LER0-LER3:16,sp)  /* copy ER0 */
+   mov.w   e1,r1   /* e1 highbyte = ccr */
+   and #0xef,r1h   /* mask mode? flag */
+   bra 6f
+5:
+   /* kernel mode */
+   mov.l   @sp,er0 /* restore saved er0 */
+   subs#2,sp   /* set dummy ccr */
+   subs#4,sp   /* set dummp sp */
+   SAVEREGS
+   mov.w   @(LRET-LER3:16,sp),r1   /* copy old ccr */
+6:
+   mov.b   r1h,r1l
+   mov.b   #0,r1h
+   mov.w   r1,@(LCCR-LER3:16,sp)   /* set ccr */
+   mov.l   @_sw_usp,er2
+   mov.l   er2,@(LSP-LER3:16,sp)   /* set usp */
+   mov.l   er6,@-sp/* syscall arg #6 */
+   mov.l   er5,@-sp/* syscall arg #5 */
+   mov.l   er4,@-sp/* syscall arg #4 */
+   .endm   /* r1 = ccr */
+
+   .macro  RESTORE_ALL
+   mov.l   @sp+,er4
+   mov.l   @sp+,er5
+   mov.l   @sp+,er6
+   RESTOREREGS
+   mov.w   @(LCCR-LER1:16,sp),r0   /* check kernel mode */
+   btst#4,r0l
+   bne 7f
+
+   orc #0xc0,ccr
+   mov.l   @(LSP-LER1:16,sp),er0
+   mov.l   @(LER0-LER1:16,sp),er1  /* restore ER0 */
+   mov.l   er1,@er0
+   RESTOREEXR
+   mov.w   @(LCCR-LER1:16,sp),r1   /* restore the RET addr */
+   mov.b   r1l,r1h
+   mov.b   @(LRET+1-LER1:16,sp),r1l
+   mov.w   r1,e1
+   mov.w   @(LRET+2-LER1:16,sp),r1
+   mov.l   er1,@(USERRET:16,er0)
+
+   mov.l   @sp+,er1
+   add.l   #(LRET-LER1),sp /* remove LORIG - LRET */
+   mov.l   sp,@_sw_ksp
+   andc#0xef,ccr   /* switch to user mode */
+   mov.l   er0,sp
+   bra 8f
+7:
+   mov.l   @sp+,er1
+   add.l   #10,sp
+8:
+   mov.l   @sp+,er0
+   adds#4,sp   /* remove the sw created LVEC */
+   rte
+   .endm
+

[PATCH v9 04/17] h8300: kernel booting

2015-04-26 Thread Yoshinori Sato
zImage startup / kernel entry point / arch depend startup

Signed-off-by: Yoshinori Sato 
---
 arch/h8300/boot/Makefile   |  26 +
 arch/h8300/boot/compressed/Makefile|  37 +++
 arch/h8300/boot/compressed/head.S  |  48 +
 arch/h8300/boot/compressed/misc.c  |  74 ++
 arch/h8300/boot/compressed/vmlinux.lds |  32 ++
 arch/h8300/boot/compressed/vmlinux.scr |   9 ++
 arch/h8300/kernel/head_ram.S   |  60 
 arch/h8300/kernel/head_rom.S   | 108 
 arch/h8300/kernel/setup.c  | 174 +
 9 files changed, 568 insertions(+)
 create mode 100644 arch/h8300/boot/Makefile
 create mode 100644 arch/h8300/boot/compressed/Makefile
 create mode 100644 arch/h8300/boot/compressed/head.S
 create mode 100644 arch/h8300/boot/compressed/misc.c
 create mode 100644 arch/h8300/boot/compressed/vmlinux.lds
 create mode 100644 arch/h8300/boot/compressed/vmlinux.scr
 create mode 100644 arch/h8300/kernel/head_ram.S
 create mode 100644 arch/h8300/kernel/head_rom.S
 create mode 100644 arch/h8300/kernel/setup.c

diff --git a/arch/h8300/boot/Makefile b/arch/h8300/boot/Makefile
new file mode 100644
index 000..2f6393a
--- /dev/null
+++ b/arch/h8300/boot/Makefile
@@ -0,0 +1,26 @@
+# arch/h8300/boot/Makefile
+
+targets := vmlinux.srec vmlinux.bin zImage
+subdir- := compressed
+
+OBJCOPYFLAGS_vmlinux.srec := -Osrec
+OBJCOPYFLAGS_vmlinux.bin  := -Obinary
+OBJCOPYFLAGS_zImage := -O binary -R .note -R .comment -R .stab -R .stabstr -S
+
+UIMAGE_LOADADDR = $(CONFIG_RAMBASE)
+UIMAGE_ENTRYADDR = $(shell /bin/bash -c 'printf "0x%08x" \
+   $$[$(CONFIG_RAMBASE) + $(CONFIG_OFFSET)]')
+
+$(obj)/vmlinux.srec $(obj)/vmlinux.bin:  vmlinux FORCE
+   $(call if_changed,objcopy)
+
+$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
+   $(call if_changed,objcopy)
+
+$(obj)/compressed/vmlinux: FORCE
+   $(Q)$(MAKE) $(build)=$(obj)/compressed $@
+
+$(obj)/uImage.bin: $(obj)/vmlinux.bin
+   $(call if_changed,uimage,none)
+
+CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec 
arch/$(ARCH)/uImage.bin
diff --git a/arch/h8300/boot/compressed/Makefile 
b/arch/h8300/boot/compressed/Makefile
new file mode 100644
index 000..87d03b7
--- /dev/null
+++ b/arch/h8300/boot/compressed/Makefile
@@ -0,0 +1,37 @@
+#
+# linux/arch/sh/boot/compressed/Makefile
+#
+# create a compressed vmlinux image from the original vmlinux
+#
+
+targets:= vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o 
piggy.o
+
+OBJECTS = $(obj)/head.o $(obj)/misc.o
+
+#
+# IMAGE_OFFSET is the load offset of the compression loader
+# Assign dummy values if these 2 variables are not defined,
+# in order to suppress error message.
+#
+CONFIG_MEMORY_START ?= 0x0040
+CONFIG_BOOT_LINK_OFFSET ?= 0x0014
+IMAGE_OFFSET := $(shell printf "0x%08x" 
$$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET
+
+LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) 
-print-libgcc-file-name)
+LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup $(obj)/vmlinux.lds
+
+$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE
+   $(call if_changed,ld)
+   @:
+
+$(obj)/vmlinux.bin: vmlinux FORCE
+   $(call if_changed,objcopy)
+
+$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
+   $(call if_changed,gzip)
+
+LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T
+OBJCOPYFLAGS := -O binary
+
+$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
+   $(call if_changed,ld)
diff --git a/arch/h8300/boot/compressed/head.S 
b/arch/h8300/boot/compressed/head.S
new file mode 100644
index 000..74c0d8cc
--- /dev/null
+++ b/arch/h8300/boot/compressed/head.S
@@ -0,0 +1,48 @@
+/*
+ *  linux/arch/h8300/boot/compressed/head.S
+ *
+ *  Copyright (C) 2006 Yoshinori Sato
+ */
+
+#include 
+
+   .section.text..startup,"ax"
+   .global startup
+startup:
+   mov.l   er0, er4
+   mov.l   er0, sp
+   mov.l   #__sbss, er0
+   mov.l   #__ebss, er1
+   sub.l   er0, er1
+   shlrer1
+   shlrer1
+   sub.l   er2, er2
+1:
+   mov.l   er2, @er0
+   adds#4, er0
+   dec.l   #1, er1
+   bne 1b
+   jsr @decompress_kernel
+   mov.l   er4, er0
+   jmp @0x40
+
+   .align  9
+fake_headers_as_bzImage:
+   .word   0
+   .ascii  "HdrS"  ; header signature
+   .word   0x0202  ; header version number (>= 0x0105)
+   ; or else old loadlin-1.5 will fail)
+   .word   0   ; default_switch
+   .word   0   ; SETUPSEG
+   .word   0x1000
+   .word   0   ; pointing to kernel version string
+   .byte   0   ; = 0, old one (LILO, Loadlin,
+   ; 0xTV: T=0 for LILO
+   ;   V = version
+   .byte   1   ; Load flags bzImage=1
+   .word   

Re: Sharing credentials in general (Re: [GIT PULL] kdbus for 4.1-rc1)

2015-04-26 Thread George Spelvin
Linus wrote:
> It would be insane to say that the open system call should have an
> explicit argument saying that the vfs layer should take your privileges
> into account.

On the contrary, it would be a big improvement on the current interface.

To be clearer, it would be great if the open system call took an explicit
argument saying *which* privileges it should take into account.

All that screwing around with uid, euid and fsuid and crap would be
a lot simpler if it was explicit in the open() call which permissions
were desired.

In my "If I had a time machine and could go back and talk to Ken & Dennis"
fantasy, there would be no open(), only openat(), and the permissions
would be associated with the dirfd.

In addition to the now-current standard three fds, there would be
additional ones for root and cwd.  And, in a setuid program,
a separate set for effective uids.

So openat(fd, path, flags) would use the real or effective permissions
depending on which fd was in use.  A process could drop permissions
by closing the associated fd.  Etc.

(And a program which was written without setuid awareness would only
use the real-uid dirfds, and the setuidness would do nothing.)
--
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/


[PATCH v9 06/17] h8300: CPU depend helpers

2015-04-26 Thread Yoshinori Sato
H8/3069 and H8S2678 have little different specification
(peripheral, interrupt and trace).
Its difference is absorbed here.

Signed-off-by: Yoshinori Sato 
---
 arch/h8300/kernel/cpu/Makefile |   4 +
 arch/h8300/kernel/cpu/h83069/Makefile  |   1 +
 arch/h8300/kernel/cpu/h83069/setup.c   | 202 ++
 arch/h8300/kernel/cpu/h8s2678/Makefile |   1 +
 arch/h8300/kernel/cpu/h8s2678/setup.c  | 161 +
 arch/h8300/kernel/cpu/irq_h.c  |  62 
 arch/h8300/kernel/cpu/irq_s.c  |  70 +
 arch/h8300/kernel/cpu/ptrace_h.c   | 256 +
 arch/h8300/kernel/cpu/ptrace_s.c   |  44 ++
 9 files changed, 801 insertions(+)
 create mode 100644 arch/h8300/kernel/cpu/Makefile
 create mode 100644 arch/h8300/kernel/cpu/h83069/Makefile
 create mode 100644 arch/h8300/kernel/cpu/h83069/setup.c
 create mode 100644 arch/h8300/kernel/cpu/h8s2678/Makefile
 create mode 100644 arch/h8300/kernel/cpu/h8s2678/setup.c
 create mode 100644 arch/h8300/kernel/cpu/irq_h.c
 create mode 100644 arch/h8300/kernel/cpu/irq_s.c
 create mode 100644 arch/h8300/kernel/cpu/ptrace_h.c
 create mode 100644 arch/h8300/kernel/cpu/ptrace_s.c

diff --git a/arch/h8300/kernel/cpu/Makefile b/arch/h8300/kernel/cpu/Makefile
new file mode 100644
index 000..684475c
--- /dev/null
+++ b/arch/h8300/kernel/cpu/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_CPU_H8300H) += ptrace_h.o irq_h.o
+obj-$(CONFIG_CPU_H8S) += ptrace_s.o irq_s.o
+obj-$(CONFIG_H83069) += h83069/
+obj-$(CONFIG_H8S2678) += h8s2678/
diff --git a/arch/h8300/kernel/cpu/h83069/Makefile 
b/arch/h8300/kernel/cpu/h83069/Makefile
new file mode 100644
index 000..49d283e
--- /dev/null
+++ b/arch/h8300/kernel/cpu/h83069/Makefile
@@ -0,0 +1 @@
+obj-y = setup.o
diff --git a/arch/h8300/kernel/cpu/h83069/setup.c 
b/arch/h8300/kernel/cpu/h83069/setup.c
new file mode 100644
index 000..99c2716
--- /dev/null
+++ b/arch/h8300/kernel/cpu/h83069/setup.c
@@ -0,0 +1,202 @@
+/*
+ * H8/3069 Internal peripheral setup
+ *
+ *  Copyright (C) 2009,2014 Yoshinori Sato 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static struct resource sci0_resources[] = {
+   DEFINE_RES_MEM(0xb0, 8),
+   DEFINE_RES_IRQ(52),
+   DEFINE_RES_IRQ(53),
+   DEFINE_RES_IRQ(54),
+   DEFINE_RES_IRQ(55),
+};
+
+
+static struct plat_sci_port sci0_platform_data = {
+   .flags  = UPF_BOOT_AUTOCONF,
+   .scscr  = SCSCR_RE | SCSCR_TE,
+   .type   = PORT_SCI,
+};
+
+static struct resource sci1_resources[] = {
+   DEFINE_RES_MEM(0xb8, 8),
+   DEFINE_RES_IRQ(56),
+   DEFINE_RES_IRQ(57),
+   DEFINE_RES_IRQ(58),
+   DEFINE_RES_IRQ(59),
+};
+
+static struct plat_sci_port sci1_platform_data = {
+   .flags  = UPF_BOOT_AUTOCONF,
+   .scscr  = SCSCR_RE | SCSCR_TE,
+   .type   = PORT_SCI,
+};
+
+static struct platform_device sci0_device = {
+   .name   = "sh-sci",
+   .id = 0,
+   .resource   = sci0_resources,
+   .num_resources  = ARRAY_SIZE(sci0_resources),
+   .dev= {
+   .platform_data  = _platform_data,
+   },
+};
+
+static struct platform_device sci1_device = {
+   .name   = "sh-sci",
+   .id = 1,
+   .resource   = sci1_resources,
+   .num_resources  = ARRAY_SIZE(sci1_resources),
+   .dev= {
+   .platform_data  = _platform_data,
+   },
+};
+
+static struct h8300_timer8_config tm8_unit0_platform_data = {
+   .mode   = H8300_TMR8_CLKEVTDEV,
+   .div= H8300_TMR8_DIV_8,
+};
+
+static struct resource tm8_unit0_resources[] = {
+   DEFINE_RES_MEM(0x80, 9),
+   DEFINE_RES_IRQ(36),
+   DEFINE_RES_IRQ(39),
+};
+
+static struct platform_device timer8_unit0_device = {
+   .name   = "h8300-8timer",
+   .id = 0,
+   .dev = {
+   .platform_data  = _unit0_platform_data,
+   },
+   .resource   = tm8_unit0_resources,
+   .num_resources  = ARRAY_SIZE(tm8_unit0_resources),
+};
+
+static struct h8300_timer8_config tm8_unit1_platform_data = {
+   .mode   = H8300_TMR8_CLKSRC,
+   .div= H8300_TMR8_DIV_8,
+};
+
+static struct resource tm8_unit1_resources[] = {
+   DEFINE_RES_MEM(0x90, 9),
+   DEFINE_RES_IRQ(40),
+   DEFINE_RES_IRQ(43),
+};
+
+static struct platform_device timer8_unit1_device = {
+   .name   = "h8300-8timer",
+   .id = 1,
+   .dev = {
+   .platform_data  = _unit1_platform_data,
+   },
+   .resource   = tm8_unit1_resources,
+   .num_resources  = ARRAY_SIZE(tm8_unit1_resources),
+};
+
+
+static struct h8300_timer16_config timer16data0 = {
+ 

[PATCH v9 07/17] h8300: miscellaneous functions

2015-04-26 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/h8300/kernel/asm-offsets.c | 67 +
 arch/h8300/kernel/dma.c | 95 +
 arch/h8300/kernel/h8300_ksyms.c | 34 +++
 arch/h8300/kernel/module.c  | 70 ++
 arch/h8300/kernel/sim-console.c | 79 ++
 arch/h8300/kernel/syscalls.c| 14 ++
 6 files changed, 359 insertions(+)
 create mode 100644 arch/h8300/kernel/asm-offsets.c
 create mode 100644 arch/h8300/kernel/dma.c
 create mode 100644 arch/h8300/kernel/h8300_ksyms.c
 create mode 100644 arch/h8300/kernel/module.c
 create mode 100644 arch/h8300/kernel/sim-console.c
 create mode 100644 arch/h8300/kernel/syscalls.c

diff --git a/arch/h8300/kernel/asm-offsets.c b/arch/h8300/kernel/asm-offsets.c
new file mode 100644
index 000..dc2d16c
--- /dev/null
+++ b/arch/h8300/kernel/asm-offsets.c
@@ -0,0 +1,67 @@
+/*
+ * This program is used to generate definitions needed by
+ * assembly language modules.
+ *
+ * We use the technique used in the OSF Mach kernel code:
+ * generate asm statements containing #defines,
+ * compile this file to assembler, and then extract the
+ * #defines from the assembly-language output.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int main(void)
+{
+   /* offsets into the task struct */
+   OFFSET(TASK_STATE, task_struct, state);
+   OFFSET(TASK_FLAGS, task_struct, flags);
+   OFFSET(TASK_PTRACE, task_struct, ptrace);
+   OFFSET(TASK_BLOCKED, task_struct, blocked);
+   OFFSET(TASK_THREAD, task_struct, thread);
+   OFFSET(TASK_THREAD_INFO, task_struct, stack);
+   OFFSET(TASK_MM, task_struct, mm);
+   OFFSET(TASK_ACTIVE_MM, task_struct, active_mm);
+
+   /* offsets into the irq_cpustat_t struct */
+   DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t,
+__softirq_pending));
+
+   /* offsets into the thread struct */
+   OFFSET(THREAD_KSP, thread_struct, ksp);
+   OFFSET(THREAD_USP, thread_struct, usp);
+   OFFSET(THREAD_CCR, thread_struct, ccr);
+
+   /* offsets into the pt_regs struct */
+   DEFINE(LER0,  offsetof(struct pt_regs, er0)  - sizeof(long));
+   DEFINE(LER1,  offsetof(struct pt_regs, er1)  - sizeof(long));
+   DEFINE(LER2,  offsetof(struct pt_regs, er2)  - sizeof(long));
+   DEFINE(LER3,  offsetof(struct pt_regs, er3)  - sizeof(long));
+   DEFINE(LER4,  offsetof(struct pt_regs, er4)  - sizeof(long));
+   DEFINE(LER5,  offsetof(struct pt_regs, er5)  - sizeof(long));
+   DEFINE(LER6,  offsetof(struct pt_regs, er6)  - sizeof(long));
+   DEFINE(LORIG, offsetof(struct pt_regs, orig_er0) - sizeof(long));
+   DEFINE(LSP,   offsetof(struct pt_regs, sp)   - sizeof(long));
+   DEFINE(LCCR,  offsetof(struct pt_regs, ccr)  - sizeof(long));
+   DEFINE(LVEC,  offsetof(struct pt_regs, vector)   - sizeof(long));
+#if defined(CONFIG_CPU_H8S)
+   DEFINE(LEXR,  offsetof(struct pt_regs, exr)  - sizeof(long));
+#endif
+   DEFINE(LRET,  offsetof(struct pt_regs, pc)   - sizeof(long));
+
+   DEFINE(PT_PTRACED, PT_PTRACED);
+
+   /* offsets in thread_info structure */
+   OFFSET(TI_TASK, thread_info, task);
+   OFFSET(TI_FLAGS, thread_info, flags);
+   OFFSET(TI_CPU, thread_info, cpu);
+   OFFSET(TI_PRE, thread_info, preempt_count);
+
+   return 0;
+}
diff --git a/arch/h8300/kernel/dma.c b/arch/h8300/kernel/dma.c
new file mode 100644
index 000..061f3c3
--- /dev/null
+++ b/arch/h8300/kernel/dma.c
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+#undef DEBUG
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+void *dma_alloc_coherent(struct device *dev, size_t size,
+  dma_addr_t *dma_handle, gfp_t gfp)
+{
+   void *ret;
+   /* ignore region specifiers */
+   gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
+
+   if (dev == NULL || (*dev->dma_mask < 0x))
+   gfp |= GFP_DMA;
+   ret = (void *)__get_free_pages(gfp, get_order(size));
+
+   if (ret != NULL) {
+   memset(ret, 0, size);
+   *dma_handle = virt_to_phys(ret);
+   }
+   return ret;
+}
+EXPORT_SYMBOL(dma_alloc_coherent);
+
+void dma_free_coherent(struct device *dev, size_t size,
+void *vaddr, dma_addr_t dma_handle)
+{
+   free_pages((unsigned long)vaddr, get_order(size));
+}
+EXPORT_SYMBOL(dma_free_coherent);
+
+void dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
+   size_t size, enum dma_data_direction dir)
+{
+}
+EXPORT_SYMBOL(dma_sync_single_for_device);
+
+void 

[PATCH v9 13/17] h8300: configs

2015-04-26 Thread Yoshinori Sato
h8300h-sim_defconfig: H8/300H simulator config.
h8s-sim_defconfig:H8S simulator config.
edosk2674_defconfig:  EDOSK2674R evalution board config.

Signed-off-by: Yoshinori Sato 
---
 arch/h8300/configs/h8300h-sim_defconfig | 53 +
 arch/h8300/configs/h8s-sim_defconfig| 53 +
 2 files changed, 106 insertions(+)
 create mode 100644 arch/h8300/configs/h8300h-sim_defconfig
 create mode 100644 arch/h8300/configs/h8s-sim_defconfig

diff --git a/arch/h8300/configs/h8300h-sim_defconfig 
b/arch/h8300/configs/h8300h-sim_defconfig
new file mode 100644
index 000..bad1a1e
--- /dev/null
+++ b/arch/h8300/configs/h8300h-sim_defconfig
@@ -0,0 +1,53 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_USELIB is not set
+# CONFIG_INIT_FALLBACK is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_UID16 is not set
+# CONFIG_SYSFS_SYSCALL is not set
+# CONFIG_KALLSYMS is not set
+# CONFIG_BASE_FULL is not set
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_AIO is not set
+# CONFIG_ADVISE_SYSCALLS is not set
+CONFIG_EMBEDDED=y
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_COMPAT_BRK is not set
+CONFIG_SLOB=y
+# CONFIG_BLOCK is not set
+CONFIG_H8300H_SIM=y
+CONFIG_CPU_CLOCK=2000
+CONFIG_RAMSIZE=0x20
+# CONFIG_BINFMT_SCRIPT is not set
+CONFIG_BINFMT_FLAT=y
+# CONFIG_COREDUMP is not set
+# CONFIG_UEVENT_HELPER is not set
+# CONFIG_STANDALONE is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+# CONFIG_ALLOW_DEV_COREDUMP is not set
+# CONFIG_INPUT is not set
+# CONFIG_SERIO is not set
+# CONFIG_VT is not set
+# CONFIG_UNIX98_PTYS is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_SH_SCI=y
+CONFIG_SERIAL_SH_SCI_CONSOLE=y
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_IOMMU_SUPPORT is not set
+# CONFIG_FILE_LOCKING is not set
+# CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY_USER is not set
+# CONFIG_PROC_FS is not set
+# CONFIG_SYSFS is not set
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+# CONFIG_ENABLE_MUST_CHECK is not set
+# CONFIG_CRC32 is not set
diff --git a/arch/h8300/configs/h8s-sim_defconfig 
b/arch/h8300/configs/h8s-sim_defconfig
new file mode 100644
index 000..025cdd8
--- /dev/null
+++ b/arch/h8300/configs/h8s-sim_defconfig
@@ -0,0 +1,53 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_USELIB is not set
+# CONFIG_INIT_FALLBACK is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_UID16 is not set
+# CONFIG_SYSFS_SYSCALL is not set
+# CONFIG_KALLSYMS is not set
+# CONFIG_BASE_FULL is not set
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_AIO is not set
+# CONFIG_ADVISE_SYSCALLS is not set
+CONFIG_EMBEDDED=y
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_COMPAT_BRK is not set
+CONFIG_SLOB=y
+# CONFIG_BLOCK is not set
+CONFIG_H8S_SIM=y
+CONFIG_CPU_CLOCK=
+CONFIG_RAMSIZE=0x20
+# CONFIG_BINFMT_SCRIPT is not set
+CONFIG_BINFMT_FLAT=y
+# CONFIG_COREDUMP is not set
+# CONFIG_UEVENT_HELPER is not set
+# CONFIG_STANDALONE is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+# CONFIG_ALLOW_DEV_COREDUMP is not set
+# CONFIG_INPUT is not set
+# CONFIG_SERIO is not set
+# CONFIG_VT is not set
+# CONFIG_UNIX98_PTYS is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_SH_SCI=y
+CONFIG_SERIAL_SH_SCI_CONSOLE=y
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_IOMMU_SUPPORT is not set
+# CONFIG_FILE_LOCKING is not set
+# CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY_USER is not set
+# CONFIG_PROC_FS is not set
+# CONFIG_SYSFS is not set
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+# CONFIG_ENABLE_MUST_CHECK is not set
+# CONFIG_CRC32 is not set
-- 
2.1.4

--
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/


[PATCH v9 10/17] h8300: Build scripts

2015-04-26 Thread Yoshinori Sato
h8300's Makefile, Kconfig and memory layout.

Signed-off-by: Yoshinori Sato 
---
 arch/h8300/Kconfig  |  73 ++
 arch/h8300/Kconfig.cpu  | 111 
 arch/h8300/Makefile |  45 
 arch/h8300/kernel/Makefile  |  16 ++
 arch/h8300/kernel/vmlinux.lds.S |  67 
 5 files changed, 312 insertions(+)
 create mode 100644 arch/h8300/Kconfig
 create mode 100644 arch/h8300/Kconfig.cpu
 create mode 100644 arch/h8300/Makefile
 create mode 100644 arch/h8300/kernel/Makefile
 create mode 100644 arch/h8300/kernel/vmlinux.lds.S

diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
new file mode 100644
index 000..9e352e6
--- /dev/null
+++ b/arch/h8300/Kconfig
@@ -0,0 +1,73 @@
+config H8300
+   bool
+   default y
+   select GENERIC_ATOMIC64
+   select HAVE_UID16
+   select VIRT_TO_BUS
+   select ARCH_WANT_IPC_PARSE_VERSION
+   select GENERIC_IRQ_SHOW
+   select FRAME_POINTER
+   select GENERIC_CPU_DEVICES
+   select MODULES_USE_ELF_RELA
+   select GENERIC_CLOCKEVENTS
+   select CLKDEV_LOOKUP
+   select COMMON_CLK
+   select ARCH_WANT_FRAME_POINTERS
+
+config RWSEM_GENERIC_SPINLOCK
+   def_bool y
+
+config GENERIC_HWEIGHT
+   def_bool y
+
+config GENERIC_CALIBRATE_DELAY
+   def_bool y
+
+config NO_IOPORT_MAP
+   def_bool y
+
+config HZ
+   int
+   default 100
+
+config NR_CPUS
+   int
+   default 1
+
+source "init/Kconfig"
+
+source "kernel/Kconfig.freezer"
+
+source "arch/h8300/Kconfig.cpu"
+
+menu "Kernel Features"
+
+source "kernel/Kconfig.preempt"
+
+source "mm/Kconfig"
+
+endmenu
+
+menu "Executable file formats"
+
+source "fs/Kconfig.binfmt"
+
+endmenu
+
+source "net/Kconfig"
+
+source "drivers/Kconfig"
+
+source "fs/Kconfig"
+
+menu "Kernel hacking"
+
+source "lib/Kconfig.debug"
+
+endmenu
+
+source "security/Kconfig"
+
+source "crypto/Kconfig"
+
+source "lib/Kconfig"
diff --git a/arch/h8300/Kconfig.cpu b/arch/h8300/Kconfig.cpu
new file mode 100644
index 000..fdacf92
--- /dev/null
+++ b/arch/h8300/Kconfig.cpu
@@ -0,0 +1,111 @@
+config CPU_H8300H
+   bool
+
+config CPU_H8S
+   bool
+
+config H83069
+   bool
+   select CPU_H8300H
+   select H8300_TMR16
+
+config H8S2678
+   bool
+   select CPU_H8S
+   select H8300_TPU
+
+config RAMKERNEL
+   bool
+
+config ROMKERNEL
+   bool
+
+menu "Processor type and features"
+
+choice
+prompt "H8/300 platform"
+
+config H8300_AE3068
+   bool "AE-3068/69"
+   select H83069
+   select RAMKERNEL
+   help
+ AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support
+ More Information. (Japanese Only)
+ 
+ AE-3068/69 Evaluation Board Support
+ More Information.
+ 
+
+config H8300_H8MAX
+   bool "H8MAX"
+   select H83069
+   select RAMKERNEL
+   select HAVE_IDE
+   help
+ H8MAX Evaluation Board Support
+ More Information. (Japanese Only)
+ 
+
+config H8300_KANEBEBE
+   bool "KaneBebe"
+   select H83069
+   select RAMKERNEL
+   help
+ KaneBebe Evalition Board Support
+ More Information. (Japanese Only)
+ 
+
+config H8300H_SIM
+   bool "H8/300H GDB Simulator"
+   select H83069
+   select ROMKERNEL
+   help
+ GDB Simulator Support
+ More Information.
+ 
+
+config H8S_EDOSK2674
+   bool "EDOSK-2674"
+   select H8S2678
+   select RAMKERNEL
+   help
+ Renesas EDOSK-2674 Evaluation Board Support
+ More Information.
+ 
+ 

+
+config H8S_SIM
+   bool "H8S GDB Simulator"
+   select H8S2678
+   select ROMKERNEL
+   help
+ GDB Simulator Support
+ More Information.
+ 
+
+endchoice
+
+if ROMKERNEL
+config CPU_CLOCK
+   int "CPU Clock Frequency"
+   help
+ CPU Clock Frequency
+
+config ROMSIZE
+   hex "ROM size"
+   default 0x20
+
+config RAMSIZE
+   hex "RAM size"
+endif
+
+config RAMBASE
+   hex "RAM base address"
+   default 0x40
+
+config OFFSET
+hex "Load offset"
+   default 0
+
+endmenu
diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile
new file mode 100644
index 000..44e915c
--- /dev/null
+++ b/arch/h8300/Makefile
@@ -0,0 +1,45 @@
+#
+# arch/h8300/Makefile
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License.  See the file 

[PATCH v9 09/17] h8300: library functions

2015-04-26 Thread Yoshinori Sato
h8300 assembly functions and private libgcc.

Signed-off-by: Yoshinori Sato 
---
 arch/h8300/lib/Makefile|   7 ++
 arch/h8300/lib/abs.S   |  20 ++
 arch/h8300/lib/ashldi3.c   |  24 +++
 arch/h8300/lib/ashrdi3.c   |  24 +++
 arch/h8300/lib/checksum.c  | 167 +
 arch/h8300/lib/libgcc.h|  77 +
 arch/h8300/lib/lshrdi3.c   |  23 +++
 arch/h8300/lib/memcpy.S|  85 +++
 arch/h8300/lib/memset.S|  69 +++
 arch/h8300/lib/moddivsi3.S |  72 +++
 arch/h8300/lib/modsi3.S|  72 +++
 arch/h8300/lib/muldi3.c|  44 
 arch/h8300/lib/mulsi3.S|  38 +++
 arch/h8300/lib/strncpy.S   |  34 +
 arch/h8300/lib/ucmpdi2.c   |  17 +
 arch/h8300/lib/udivsi3.S   |  76 +
 16 files changed, 849 insertions(+)
 create mode 100644 arch/h8300/lib/Makefile
 create mode 100644 arch/h8300/lib/abs.S
 create mode 100644 arch/h8300/lib/ashldi3.c
 create mode 100644 arch/h8300/lib/ashrdi3.c
 create mode 100644 arch/h8300/lib/checksum.c
 create mode 100644 arch/h8300/lib/libgcc.h
 create mode 100644 arch/h8300/lib/lshrdi3.c
 create mode 100644 arch/h8300/lib/memcpy.S
 create mode 100644 arch/h8300/lib/memset.S
 create mode 100644 arch/h8300/lib/moddivsi3.S
 create mode 100644 arch/h8300/lib/modsi3.S
 create mode 100644 arch/h8300/lib/muldi3.c
 create mode 100644 arch/h8300/lib/mulsi3.S
 create mode 100644 arch/h8300/lib/strncpy.S
 create mode 100644 arch/h8300/lib/ucmpdi2.c
 create mode 100644 arch/h8300/lib/udivsi3.S

diff --git a/arch/h8300/lib/Makefile b/arch/h8300/lib/Makefile
new file mode 100644
index 000..8311a9f
--- /dev/null
+++ b/arch/h8300/lib/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for H8/300-specific library files..
+#
+
+lib-y  = checksum.o memcpy.o memset.o abs.o strncpy.o \
+mulsi3.o udivsi3.o muldi3.o moddivsi3.o \
+ashldi3.o lshrdi3.o ashrdi3.o ucmpdi2.o
diff --git a/arch/h8300/lib/abs.S b/arch/h8300/lib/abs.S
new file mode 100644
index 000..efda749
--- /dev/null
+++ b/arch/h8300/lib/abs.S
@@ -0,0 +1,20 @@
+;;; abs.S
+
+#include 
+
+#if defined(CONFIG_CPU_H8300H)
+   .h8300h
+#endif
+#if defined(CONFIG_CPU_H8S)
+   .h8300s
+#endif
+   .text
+.global _abs
+
+;;; int abs(int n)
+_abs:
+   mov.l   er0,er0
+   bpl 1f
+   neg.l   er0
+1:
+   rts
diff --git a/arch/h8300/lib/ashldi3.c b/arch/h8300/lib/ashldi3.c
new file mode 100644
index 000..c6aa8ea
--- /dev/null
+++ b/arch/h8300/lib/ashldi3.c
@@ -0,0 +1,24 @@
+#include "libgcc.h"
+
+DWtype
+__ashldi3(DWtype u, word_type b)
+{
+   const DWunion uu = {.ll = u};
+   const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+   DWunion w;
+
+   if (b == 0)
+   return u;
+
+   if (bm <= 0) {
+   w.s.low = 0;
+   w.s.high = (UWtype) uu.s.low << -bm;
+   } else {
+   const UWtype carries = (UWtype) uu.s.low >> bm;
+
+   w.s.low = (UWtype) uu.s.low << b;
+   w.s.high = ((UWtype) uu.s.high << b) | carries;
+   }
+
+   return w.ll;
+}
diff --git a/arch/h8300/lib/ashrdi3.c b/arch/h8300/lib/ashrdi3.c
new file mode 100644
index 000..070adf9
--- /dev/null
+++ b/arch/h8300/lib/ashrdi3.c
@@ -0,0 +1,24 @@
+#include "libgcc.h"
+
+DWtype __ashrdi3(DWtype u, word_type b)
+{
+   const DWunion uu = {.ll = u};
+   const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+   DWunion w;
+
+   if (b == 0)
+   return u;
+
+   if (bm <= 0) {
+   /* w.s.high = 1..1 or 0..0 */
+   w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
+   w.s.low = uu.s.high >> -bm;
+   } else {
+   const UWtype carries = (UWtype) uu.s.high << bm;
+
+   w.s.high = uu.s.high >> b;
+   w.s.low = ((UWtype) uu.s.low >> b) | carries;
+   }
+
+   return w.ll;
+}
diff --git a/arch/h8300/lib/checksum.c b/arch/h8300/lib/checksum.c
new file mode 100644
index 000..ae28469
--- /dev/null
+++ b/arch/h8300/lib/checksum.c
@@ -0,0 +1,167 @@
+/*
+ * INETAn implementation of the TCP/IP protocol suite for the 
LINUX
+ * operating system.  INET is implemented using the  BSD Socket
+ * interface as the means of communication with the user level.
+ *
+ * IP/TCP/UDP checksumming routines
+ *
+ * Authors:Jorge Cwik, 
+ * Arnt Gulbrandsen, 
+ * Tom May, 
+ * Andreas Schwab, 
+ * Lots of code moved from tcp.c and ip.c; see those files
+ * for more names.
+ *
+ * 03/02/96Jes Sorensen, Andreas Schwab, Roman Hodek:
+ * Fixed some nasty bugs, causing some horrible crashes.
+ * A: At some points, the sum (%0) was used as
+ * length-counter instead of the length counter
+ * (%1). Thanks 

[PATCH v9 17/17] Add H8/300 entry

2015-04-26 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 CREDITS |  5 -
 MAINTAINERS | 11 +++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/CREDITS b/CREDITS
index 40cc4bf..e88b597 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3219,11 +3219,6 @@ N: Dipankar Sarma
 E: dipan...@in.ibm.com
 D: RCU
 
-N: Yoshinori Sato
-E: ys...@users.sourceforge.jp
-D: uClinux for Renesas H8/300 (H8300)
-D: http://uclinux-h8.sourceforge.jp/
-
 N: Hannu Savolainen
 E: ha...@opensound.com
 D: Maintainer of the sound drivers until 2.1.x days.
diff --git a/MAINTAINERS b/MAINTAINERS
index 2e5bbc0..3c9c6f6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4473,6 +4473,17 @@ T:   git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/usb/stk1160/
 
+H8/300 ARCHITECTURE
+M: Yoshinori Sato 
+L: uclinux-h8-de...@lists.sourceforge.jp
+W: http://uclinux-h8.sourceforge.jp
+T: git git://git.sourceforge.jp/gitroot/uclinux-h8/linux.git
+S: Maintained
+F: arch/h8300/
+F: drivers/clocksource/h8300/
+F: drivers/clk/clk-h83069.c
+F: drivers/clk/clk-h8s2678.c
+
 HARD DRIVE ACTIVE PROTECTION SYSTEM (HDAPS) DRIVER
 M: Frank Seidel 
 L: platform-driver-...@vger.kernel.org
-- 
2.1.4

--
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/


[PATCH v9 15/17] Add ELF machine

2015-04-26 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 include/uapi/linux/elf-em.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index ae99f77..b088296 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -25,6 +25,7 @@
 #define EM_ARM 40  /* ARM 32 bit */
 #define EM_SH  42  /* SuperH */
 #define EM_SPARCV9 43  /* SPARC v9 64-bit */
+#define EM_H8_300  46  /* Renesas H8/300 */
 #define EM_IA_64   50  /* HP/Intel IA-64 */
 #define EM_X86_64  62  /* AMD x86-64 */
 #define EM_S39022  /* IBM S/390 */
-- 
2.1.4

--
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/


[PATCH v9 16/17] mksysmap: Add h8300 local symbol pattern

2015-04-26 Thread Yoshinori Sato
h8300's nm output have a lot of local symbols.
ex)
 N .Lframe0
0013 N .LLST1
0026 N .LLST2
0039 N .LLST3
004c N .LLST4
Added new pattern " .L" to filter rule.

Signed-off-by: Yoshinori Sato 
---
 scripts/mksysmap | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/mksysmap b/scripts/mksysmap
index 7ada35a..a35acc0 100755
--- a/scripts/mksysmap
+++ b/scripts/mksysmap
@@ -41,4 +41,4 @@
 # so we just ignore them to let readprofile continue to work.
 # (At least sparc64 has __crc_ in the middle).
 
-$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $2
+$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( .L\)' > $2
-- 
2.1.4

--
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/


[PATCH v9 14/17] serial: Add H8300.

2015-04-26 Thread Yoshinori Sato
h8300 internal serial controller of same as sh-sci.
So h8300 use SH_SCI.

Signed-off-by: Yoshinori Sato 
---
 drivers/tty/serial/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index f8120c1..130f201 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -728,7 +728,7 @@ config SERIAL_IP22_ZILOG_CONSOLE
 
 config SERIAL_SH_SCI
tristate "SuperH SCI(F) serial port support"
-   depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
+   depends on SUPERH || ARCH_SHMOBILE || H8300 || COMPILE_TEST 
select SERIAL_CORE
 
 config SERIAL_SH_SCI_NR_UARTS
-- 
2.1.4

--
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/


[PATCH v9 12/17] h8300: clocksource

2015-04-26 Thread Yoshinori Sato
H8/300 internal timer driver.
h8300_timer8 - 8bit Timer driver.
h8300_timer16 - 16bit Timer driver (only H8/3069).
h8300_tpu - Timer Pulse Unit driver (only H8S2678).

Signed-off-by: Yoshinori Sato 
---
 drivers/clocksource/Kconfig |   6 +
 drivers/clocksource/Makefile|   3 +
 drivers/clocksource/h8300_timer16.c | 332 ++
 drivers/clocksource/h8300_timer8.c  | 398 
 drivers/clocksource/h8300_tpu.c | 203 ++
 5 files changed, 942 insertions(+)
 create mode 100644 drivers/clocksource/h8300_timer16.c
 create mode 100644 drivers/clocksource/h8300_timer8.c
 create mode 100644 drivers/clocksource/h8300_tpu.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 51d7865f..96e2513 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -258,4 +258,10 @@ config CLKSRC_PXA
help
  This enables OST0 support available on PXA and SA-11x0
  platforms.
+config H8300_TMR16
+bool
+
+config H8300_TPU
+bool
+
 endmenu
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 5b85f6a..8288c4e 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -52,3 +52,6 @@ obj-$(CONFIG_ARCH_INTEGRATOR_AP)  += timer-integrator-ap.o
 obj-$(CONFIG_CLKSRC_VERSATILE) += versatile.o
 obj-$(CONFIG_CLKSRC_MIPS_GIC)  += mips-gic-timer.o
 obj-$(CONFIG_ASM9260_TIMER)+= asm9260_timer.o
+obj-$(CONFIG_H8300)+= h8300_timer8.o
+obj-$(CONFIG_H8300_TMR16)  += h8300_timer16.o
+obj-$(CONFIG_H8300_TPU)+= h8300_tpu.o
diff --git a/drivers/clocksource/h8300_timer16.c 
b/drivers/clocksource/h8300_timer16.c
new file mode 100644
index 000..5427cd0
--- /dev/null
+++ b/drivers/clocksource/h8300_timer16.c
@@ -0,0 +1,332 @@
+/*
+ *  linux/arch/h8300/kernel/timer/timer16.c
+ *
+ *  Yoshinori Sato 
+ *
+ *  16bit Timer clockevent device
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define TSTR   0
+#define TSNC   1
+#define TMDR   2
+#define TOLR   3
+#define TISRA  4
+#define TISRB  5
+#define TISRC  6
+
+#define TCR0
+#define TIOR   1
+#define TCNT   2
+#define GRA4
+#define GRB6
+
+#define FLAG_REPROGRAM (1 << 0)
+#define FLAG_SKIPEVENT (1 << 1)
+#define FLAG_IRQCONTEXT (1 << 2)
+#define FLAG_STARTED (1 << 3)
+
+#define ONESHOT  0
+#define PERIODIC 1
+
+#define RELATIVE 0
+#define ABSOLUTE 1
+
+struct timer16_priv {
+   struct platform_device *pdev;
+   struct clock_event_device ced;
+   struct irqaction irqaction;
+   unsigned long mapbase;
+   unsigned long mapcommon;
+   unsigned long flags;
+   unsigned int rate;
+   unsigned short gra;
+   unsigned char enb;
+   unsigned char imfa;
+   unsigned char imiea;
+   unsigned char ovf;
+   raw_spinlock_t lock;
+   struct clk *clk;
+};
+
+static unsigned long timer16_get_counter(struct timer16_priv *p)
+{
+   unsigned long v1, v2, v3;
+   int o1, o2;
+
+   o1 = ctrl_inb(p->mapcommon + TISRC) & p->ovf;
+
+   /* Make sure the timer value is stable. Stolen from acpi_pm.c */
+   do {
+   o2 = o1;
+   v1 = ctrl_inw(p->mapbase + TCNT);
+   v2 = ctrl_inw(p->mapbase + TCNT);
+   v3 = ctrl_inw(p->mapbase + TCNT);
+   o1 = ctrl_inb(p->mapcommon + TISRC) & p->ovf;
+   } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3)
+ || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));
+
+   v2 |= 0x1;
+   return v2;
+}
+
+
+static irqreturn_t timer16_interrupt(int irq, void *dev_id)
+{
+   struct timer16_priv *p = (struct timer16_priv *)dev_id;
+
+   ctrl_outb(ctrl_inb(p->mapcommon + TISRA) & ~p->imfa,
+ p->mapcommon + TISRA);
+
+   p->flags |= FLAG_IRQCONTEXT;
+   ctrl_outw(p->gra, p->mapbase + GRA);
+   if (!(p->flags & FLAG_SKIPEVENT)) {
+   if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT) {
+   ctrl_outb(ctrl_inb(p->mapcommon + TSTR) & ~p->enb,
+ p->mapcommon + TISRA);
+   }
+   p->ced.event_handler(>ced);
+   }
+
+   p->flags &= ~(FLAG_SKIPEVENT | FLAG_IRQCONTEXT);
+
+   return IRQ_HANDLED;
+}
+
+static void timer16_set_next(struct timer16_priv *p, unsigned long delta)
+{
+   unsigned long flags;
+   unsigned long now;
+
+   raw_spin_lock_irqsave(>lock, flags);
+   if (delta >= 0x1)
+   dev_warn(>pdev->dev, "delta out of range\n");
+   now = timer16_get_counter(p);
+   p->gra = delta;
+   ctrl_outb(ctrl_inb(p->mapcommon + TISRA) | p->imiea,
+ p->mapcommon + TISRA);
+   if (delta > now)
+   

[PATCH v9 11/17] h8300: clock driver

2015-04-26 Thread Yoshinori Sato
h8300 clock generator drivers.
H8/3069 is simple oscillator.
H8S2678 is PLL multiplier support.

Signed-off-by: Yoshinori Sato 
---
 drivers/clk/Makefile|   1 +
 drivers/clk/h8300/Makefile  |   2 +
 drivers/clk/h8300/clk-h83069.c  |  80 +++
 drivers/clk/h8300/clk-h8s2678.c | 171 
 include/linux/clk-provider.h|  12 +++
 5 files changed, 266 insertions(+)
 create mode 100644 drivers/clk/h8300/Makefile
 create mode 100644 drivers/clk/h8300/clk-h83069.c
 create mode 100644 drivers/clk/h8300/clk-h8s2678.c

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 3d00c25..9df871d 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -73,3 +73,4 @@ obj-$(CONFIG_ARCH_U8500)  += ux500/
 obj-$(CONFIG_COMMON_CLK_VERSATILE) += versatile/
 obj-$(CONFIG_X86)  += x86/
 obj-$(CONFIG_ARCH_ZYNQ)+= zynq/
+obj-$(CONFIG_H8300)+= h8300/
diff --git a/drivers/clk/h8300/Makefile b/drivers/clk/h8300/Makefile
new file mode 100644
index 000..82eab42
--- /dev/null
+++ b/drivers/clk/h8300/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_H83069) += clk-h83069.o
+obj-$(CONFIG_H8S2678) += clk-h8s2678.o
diff --git a/drivers/clk/h8300/clk-h83069.c b/drivers/clk/h8300/clk-h83069.c
new file mode 100644
index 000..0a20dd5
--- /dev/null
+++ b/drivers/clk/h8300/clk-h83069.c
@@ -0,0 +1,80 @@
+/*
+ * H8/3069 clock driver
+ *
+ * Copyright 2015 Yoshinori Sato 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static DEFINE_SPINLOCK(clklock);
+
+#define DIVCR ((unsigned char *)0xfee01b)
+#define DEVNAME "h83069-cpg"
+
+static int clk_probe(struct platform_device *pdev)
+{
+   struct clk *clk;
+   int *hz = dev_get_platdata(>dev);
+
+   clk = clk_register_fixed_rate(>dev, "master_clk", NULL,
+ CLK_IS_ROOT, *hz);
+   if (IS_ERR(clk)) {
+   dev_err(>dev, "failed to register clock");
+   return PTR_ERR(clk);
+   }
+   clk_register_clkdev(clk, "master_clk", DEVNAME ".%d", 0);
+
+   clk = clk_register_divider(>dev, "core_clk", "master_clk",
+  CLK_SET_RATE_GATE, DIVCR, 0, 2,
+  CLK_DIVIDER_POWER_OF_TWO, );
+   if (IS_ERR(clk)) {
+   dev_err(>dev, "failed to register clock");
+   return PTR_ERR(clk);
+   }
+   clk_register_clkdev(clk, "core_clk", DEVNAME ".%d", 0);
+
+   clk = clk_register_fixed_factor(>dev, "peripheral_clk", 
"core_clk",
+   0, 1, 1);
+   if (IS_ERR(clk)) {
+   dev_err(>dev, "failed to register clock");
+   return PTR_ERR(clk);
+   }
+   clk_register_clkdev(clk, "peripheral_clk", NULL);
+   return 0;
+}
+
+static struct platform_driver cpg_driver = {
+   .driver = {
+   .name = DEVNAME,
+   },
+   .probe = clk_probe,
+};
+
+early_platform_init(DEVNAME, _driver);
+
+static struct platform_device clk_device = {
+   .name   = DEVNAME,
+   .id = 0,
+};
+
+static struct platform_device *devices[] __initdata = {
+   _device,
+};
+
+int __init h8300_clk_init(int hz)
+{
+   static int master_hz;
+
+   master_hz = hz;
+   clk_device.dev.platform_data = _hz;
+   early_platform_add_devices(devices,
+  ARRAY_SIZE(devices));
+   early_platform_driver_register_all(DEVNAME);
+   early_platform_driver_probe(DEVNAME, 1, 0);
+   return 0;
+}
diff --git a/drivers/clk/h8300/clk-h8s2678.c b/drivers/clk/h8300/clk-h8s2678.c
new file mode 100644
index 000..55b490c
--- /dev/null
+++ b/drivers/clk/h8300/clk-h8s2678.c
@@ -0,0 +1,171 @@
+/*
+ * H8S2678 clock driver
+ *
+ * Copyright 2015 Yoshinori Sato 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static DEFINE_SPINLOCK(clklock);
+
+#define SCKCR 0x3b
+#define PLLCR 0x45
+#define DEVNAME "h8s2678-cpg"
+#define MAX_FREQ 
+#define MIN_FREQ  800
+
+static unsigned long pll_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   int mul = 1 << (ctrl_inb(PLLCR) & 3);
+
+   return parent_rate * mul;
+}
+
+static long pll_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *prate)
+{
+   int i, m = -1;
+   long offset[3];
+
+   if (rate > MAX_FREQ)
+   rate = MAX_FREQ;
+   if (rate < MIN_FREQ)
+   rate = MIN_FREQ;
+
+   for (i = 0; i < 3; i++)
+   offset[i] = abs(rate - (*prate * (1 << i)));
+   for (i = 0; i < 3; i++)
+   if (m < 0)
+   m = i;
+   else
+   m = (offset[i] < offset[m])?i:m;
+
+   return *prate * (1 << m);
+}
+
+static int pll_set_rate(struct clk_hw *hw, unsigned long rate,
+ 

[PATCH v9 08/17] h8300: Memory management

2015-04-26 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/h8300/mm/Makefile |   5 ++
 arch/h8300/mm/fault.c  |  57 +
 arch/h8300/mm/init.c   | 133 +
 arch/h8300/mm/kmap.c   |  61 +++
 arch/h8300/mm/memory.c |  53 
 5 files changed, 309 insertions(+)
 create mode 100644 arch/h8300/mm/Makefile
 create mode 100644 arch/h8300/mm/fault.c
 create mode 100644 arch/h8300/mm/init.c
 create mode 100644 arch/h8300/mm/kmap.c
 create mode 100644 arch/h8300/mm/memory.c

diff --git a/arch/h8300/mm/Makefile b/arch/h8300/mm/Makefile
new file mode 100644
index 000..117d71f
--- /dev/null
+++ b/arch/h8300/mm/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for the linux h8300-specific parts of the memory manager.
+#
+
+obj-y   := init.o fault.o memory.o kmap.o
diff --git a/arch/h8300/mm/fault.c b/arch/h8300/mm/fault.c
new file mode 100644
index 000..5924ff5
--- /dev/null
+++ b/arch/h8300/mm/fault.c
@@ -0,0 +1,57 @@
+/*
+ *  linux/arch/h8300/mm/fault.c
+ *
+ *  Copyright (C) 1998  D. Jeff Dionne ,
+ *  Copyright (C) 2000  Lineo, Inc.  (www.lineo.com)
+ *
+ *  Based on:
+ *
+ *  linux/arch/m68knommu/mm/fault.c
+ *  linux/arch/m68k/mm/fault.c
+ *
+ *  Copyright (C) 1995  Hamish Macdonald
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+void die(const char *str, struct pt_regs *fp, unsigned long err);
+
+/*
+ * This routine handles page faults.  It determines the problem, and
+ * then passes it off to one of the appropriate routines.
+ *
+ * error_code:
+ * bit 0 == 0 means no page found, 1 means protection fault
+ * bit 1 == 0 means read, 1 means write
+ *
+ * If this routine detects a bad access, it returns 1, otherwise it
+ * returns 0.
+ */
+asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
+ unsigned long error_code)
+{
+#ifdef DEBUG
+   pr_debug("regs->sr=%#x, regs->pc=%#lx, address=%#lx, %ld\n",
+regs->sr, regs->pc, address, error_code);
+#endif
+
+/*
+ * Oops. The kernel tried to access some bad page. We'll have to
+ * terminate things with extreme prejudice.
+ */
+   if ((unsigned long) address < PAGE_SIZE)
+   pr_alert("Unable to handle kernel NULL pointer dereference");
+   else
+   pr_alert("Unable to handle kernel access");
+   printk(" at virtual address %08lx\n", address);
+   if (!user_mode(regs))
+   die("Oops", regs, error_code);
+   do_exit(SIGKILL);
+
+   return 1;
+}
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
new file mode 100644
index 000..98028b1
--- /dev/null
+++ b/arch/h8300/mm/init.c
@@ -0,0 +1,133 @@
+/*
+ *  linux/arch/h8300/mm/init.c
+ *
+ *  Copyright (C) 1998  D. Jeff Dionne ,
+ *  Kenneth Albanowski ,
+ *  Copyright (C) 2000  Lineo, Inc.  (www.lineo.com)
+ *
+ *  Based on:
+ *
+ *  linux/arch/m68knommu/mm/init.c
+ *  linux/arch/m68k/mm/init.c
+ *
+ *  Copyright (C) 1995  Hamish Macdonald
+ *
+ *  JAN/1999 -- hacked to support ColdFire (g...@snapgear.com)
+ *  DEC/2000 -- linux 2.4 support 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * BAD_PAGE is the page that is used for page faults when linux
+ * is out-of-memory. Older versions of linux just did a
+ * do_exit(), but using this instead means there is less risk
+ * for a process dying in kernel mode, possibly leaving a inode
+ * unused etc..
+ *
+ * BAD_PAGETABLE is the accompanying page-table: it is initialized
+ * to point to BAD_PAGE entries.
+ *
+ * ZERO_PAGE is a special page that is used for zero-initialized
+ * data and COW.
+ */
+static unsigned long empty_bad_page_table;
+static unsigned long empty_bad_page;
+unsigned long empty_zero_page;
+
+/*
+ * paging_init() continues the virtual memory environment setup which
+ * was begun by the code in arch/head.S.
+ * The parameters are pointers to where to stick the starting and ending
+ * addresses of available kernel virtual memory.
+ */
+void __init paging_init(void)
+{
+   /*
+* Make sure start_mem is page aligned,  otherwise bootmem and
+* page_alloc get different views og the world.
+*/
+   unsigned long start_mem = PAGE_ALIGN(memory_start);
+   unsigned long end_mem   = memory_end & PAGE_MASK;
+
+   pr_debug("start_mem is %#lx\nvirtual_end is %#lx\n",
+start_mem, end_mem);
+
+   /*
+* Initialize the bad page table and bad page to point
+* to a couple of allocated pages.
+*/
+   empty_bad_page_table = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+   empty_bad_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+   empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+   memset((void *)empty_zero_page, 0, 

[PATCH v9 00/17] Re-introduce h8300 architecture

2015-04-26 Thread Yoshinori Sato
Hello.
I will re-introducing h8300.

Changes for v9
- remove exec domain
- timer update
- rebase to v4.1-rc1

Changes for v8
- rebase to v4.0

Changes for v7
- Add MAINTAINERS

Changes for v6
- rebase to v4.0-rc3
- remove unused headers
- optimized atomic operation
- System.map cleanup

Changes for v5
- Signal handling fix
- LD script cleanup

Changes for v4
- Remove signal mapping
- Organize Kconfig
- Coding style fix

Changes for v3
- Fix clone
- Add dma functions
- Add missing library
- Fix various errors

Changes for v2
- Use Common Clock Framework
- Use common unistd.h
- Use common ptrace function
- clocksource driver move to drivers/clocksource
- some cleanup

Changes for latest relase (v3.12)
- standard ELF toolchain (h8300-linux)
- use common driver support
- exception handling fix
- too many cleanup

git repository
git://git.sourceforge.jp/gitroot/uclinux-h8/linux.git h8300

Yoshinori Sato (17):
  h8300: Assembly headers.
  h8300: UAPI headers
  h8300: Exception and Interrupt handling
  h8300: kernel booting
  h8300: process and signals
  h8300: CPU depend helpers
  h8300: miscellaneous functions
  h8300: Memory management
  h8300: library functions
  h8300: Build scripts
  h8300: clock driver
  h8300: clocksource
  h8300: configs
  serial: Add H8300.
  Add ELF machine
  mksysmap: Add h8300 local symbol pattern
  Add H8/300 entry

 CREDITS|   5 -
 MAINTAINERS|  11 +
 arch/h8300/Kconfig |  73 +
 arch/h8300/Kconfig.cpu | 111 
 arch/h8300/Makefile|  45 
 arch/h8300/boot/Makefile   |  26 ++
 arch/h8300/boot/compressed/Makefile|  37 +++
 arch/h8300/boot/compressed/head.S  |  48 
 arch/h8300/boot/compressed/misc.c  |  74 ++
 arch/h8300/boot/compressed/vmlinux.lds |  32 +++
 arch/h8300/boot/compressed/vmlinux.scr |   9 +
 arch/h8300/configs/h8300h-sim_defconfig|  53 
 arch/h8300/configs/h8s-sim_defconfig   |  53 
 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 ++
 arch/h8300/include/uapi/asm/Kbuild |  29 ++
 arch/h8300/include/uapi/asm/auxvec.h   |   4 +
 arch/h8300/include/uapi/asm/byteorder.h|   6 +
 arch/h8300/include/uapi/asm/ptrace.h   |  42 +++
 arch/h8300/include/uapi/asm/sigcontext.h   |  18 ++
 arch/h8300/include/uapi/asm/signal.h   | 115 
 arch/h8300/include/uapi/asm/swab.h |   1 +
 arch/h8300/include/uapi/asm/unistd.h   |   3 +
 arch/h8300/kernel/Makefile |  16 ++
 arch/h8300/kernel/asm-offsets.c|  67 +
 arch/h8300/kernel/cpu/Makefile |   4 +
 arch/h8300/kernel/cpu/h83069/Makefile  |   1 +
 

RE: [PATCH] elevator: fix memory leak in ->elevator_init_fn

2015-04-26 Thread Chao Yu
Hi all,

I found that when we release eq->kobj by invoking kobject_put() we had gave
misson to workqueue, so that workqueue will release the elevator queue
space in elevator_alloc() which is registered in ->release of elv_ktype object.
We should not release it again.

So, this fix is wrong, please ignore this patch, sorry for the noisy!

Regards,

> -Original Message-
> From: Chao Yu [mailto:chao2...@samsung.com]
> Sent: Friday, April 24, 2015 10:09 AM
> To: 'ax...@kernel.dk'
> Cc: 'linux-kernel@vger.kernel.org'
> Subject: [PATCH] elevator: fix memory leak in ->elevator_init_fn
> 
> In ->elevator_init_fn, if we fail to call kzalloc_node, we should release
> elevator queue space which is allocated previously, otherwise it will cause
> memory leak.
> 
> Signed-off-by: Chao Yu 
> ---
>  block/cfq-iosched.c  | 1 +
>  block/deadline-iosched.c | 1 +
>  block/noop-iosched.c | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
> index 5da8e6e..2793fb7 100644
> --- a/block/cfq-iosched.c
> +++ b/block/cfq-iosched.c
> @@ -4391,6 +4391,7 @@ static int cfq_init_queue(struct request_queue *q, 
> struct elevator_type
> *e)
>   cfqd = kzalloc_node(sizeof(*cfqd), GFP_KERNEL, q->node);
>   if (!cfqd) {
>   kobject_put(>kobj);
> + kfree(eq);
>   return -ENOMEM;
>   }
>   eq->elevator_data = cfqd;
> diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
> index a753df2..bc6d7d9 100644
> --- a/block/deadline-iosched.c
> +++ b/block/deadline-iosched.c
> @@ -349,6 +349,7 @@ static int deadline_init_queue(struct request_queue *q, 
> struct elevator_type
> *e)
>   dd = kzalloc_node(sizeof(*dd), GFP_KERNEL, q->node);
>   if (!dd) {
>   kobject_put(>kobj);
> + kfree(eq);
>   return -ENOMEM;
>   }
>   eq->elevator_data = dd;
> diff --git a/block/noop-iosched.c b/block/noop-iosched.c
> index 3de89d4..1399c78 100644
> --- a/block/noop-iosched.c
> +++ b/block/noop-iosched.c
> @@ -71,6 +71,7 @@ static int noop_init_queue(struct request_queue *q, struct 
> elevator_type *e)
>   nd = kmalloc_node(sizeof(*nd), GFP_KERNEL, q->node);
>   if (!nd) {
>   kobject_put(>kobj);
> + kfree(eq);
>   return -ENOMEM;
>   }
>   eq->elevator_data = nd;
> --
> 2.3.3


--
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] [media] xilinx: Reflect dma header file move

2015-04-26 Thread Guenter Roeck

On 04/26/2015 10:22 PM, Michal Simek wrote:

On 04/24/2015 09:24 PM, Guenter Roeck wrote:

Commit 937abe88aea3 ("dmaengine: xilinx-dma: move header file to common
location") moved xilinx_dma.h to a common location but neglected to reflect
this move in all its users.

This causes compile errors for several builds.

drivers/media/platform/xilinx/xilinx-dma.c:15:35:
fatal error: linux/amba/xilinx_dma.h: No such file or directory

Cc: Kedareswara rao Appana 
Fixes: 937abe88aea3 ("dmaengine: xilinx-dma: move header file to common
location")
Signed-off-by: Guenter Roeck 
---
  drivers/media/platform/xilinx/xilinx-dma.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)


FYI:
http://www.serverphorums.com/read.php?12,1179281

https://lkml.org/lkml/2015/4/25/25



Yes, I noticed Stephen's patch in mainline.

Guenter


--
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/


[PATCH 2/8] rtl8712: don't duplicate ieee80211 constants for status/reason

2015-04-26 Thread Paul Gortmaker
These are all defined as a part of the standard and should not be
duplicated on a per-driver basis.  Use the global ones and delete the
local ones.

It seems that ieee80211 was already included everywhere it was needed,
since no explicit include <...> were needed to be added in order to
preserve getting a successful compile.

This isn't the totality of duplicated data removed, but it is a start.

Signed-off-by: Paul Gortmaker 
---
 drivers/staging/rtl8712/ieee80211.h | 29 -
 1 file changed, 29 deletions(-)

diff --git a/drivers/staging/rtl8712/ieee80211.h 
b/drivers/staging/rtl8712/ieee80211.h
index 8269be80437a..6e813a9c1aa2 100644
--- a/drivers/staging/rtl8712/ieee80211.h
+++ b/drivers/staging/rtl8712/ieee80211.h
@@ -314,35 +314,6 @@ struct ieee80211_snap_hdr {
 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
 
-/* Status codes */
-#define WLAN_STATUS_SUCCESS 0
-#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
-#define WLAN_STATUS_CAPS_UNSUPPORTED 10
-#define WLAN_STATUS_REASSOC_NO_ASSOC 11
-#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
-#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
-#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
-#define WLAN_STATUS_CHALLENGE_FAIL 15
-#define WLAN_STATUS_AUTH_TIMEOUT 16
-#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
-#define WLAN_STATUS_ASSOC_DENIED_RATES 18
-/* 802.11b */
-#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
-#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
-#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
-
-/* Reason codes */
-#define WLAN_REASON_UNSPECIFIED 1
-#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
-#define WLAN_REASON_DEAUTH_LEAVING 3
-#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
-#define WLAN_REASON_DISASSOC_AP_BUSY 5
-#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
-#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
-#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
-#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
-
-
 /* Information Element IDs */
 #define WLAN_EID_SSID 0
 #define WLAN_EID_SUPP_RATES 1
-- 
2.2.1

--
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/


[PATCH 7/8] rtl8192u: delete another embedded instance of generic reason codes

2015-04-26 Thread Paul Gortmaker
We have global copies of all these reason codes.  We don't need local
copies.  Worse is that these seem totally unused; a grep for some of
the fields comes up empty, and it still compiles after its complete
removal.

Signed-off-by: Paul Gortmaker 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 48 --
 1 file changed, 48 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h 
b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index 960769bfa15f..702bef6e2f56 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -188,54 +188,6 @@ typedef struct cb_desc {
 #define MGN_MCS14   0x8e
 #define MGN_MCS15   0x8f
 
-//
-// 802.11 Management frame Reason Code field
-//
-enum   _ReasonCode{
-   unspec_reason   = 0x1,
-   auth_not_valid  = 0x2,
-   deauth_lv_ss= 0x3,
-   inactivity  = 0x4,
-   ap_overload = 0x5,
-   class2_err  = 0x6,
-   class3_err  = 0x7,
-   disas_lv_ss = 0x8,
-   asoc_not_auth   = 0x9,
-
-   //MIC_CHECK
-   mic_failure = 0xe,
-   //END MIC_CHECK
-
-   // Reason code defined in 802.11i D10.0 p.28.
-   invalid_IE  = 0x0d,
-   four_way_tmout  = 0x0f,
-   two_way_tmout   = 0x10,
-   IE_dismatch = 0x11,
-   invalid_Gcipher = 0x12,
-   invalid_Pcipher = 0x13,
-   invalid_AKMP= 0x14,
-   unsup_RSNIEver = 0x15,
-   invalid_RSNIE   = 0x16,
-   auth_802_1x_fail= 0x17,
-   ciper_reject= 0x18,
-
-   // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 
2005-11-15.
-   QoS_unspec  = 0x20, // 32
-   QAP_bandwidth   = 0x21, // 33
-   poor_condition  = 0x22, // 34
-   no_facility = 0x23, // 35
-   // Where is 36???
-   req_declined= 0x25, // 37
-   invalid_param   = 0x26, // 38
-   req_not_honored= 0x27,  // 39
-   TS_not_created  = 0x2F, // 47
-   DL_not_allowed  = 0x30, // 48
-   dest_not_exist  = 0x31, // 49
-   dest_not_QSTA   = 0x32, // 50
-};
-
-
-
 #define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A || \
priv->ieee80211->current_network.mode == IEEE_N_24G || \
priv->ieee80211->current_network.mode == IEEE_N_5G) ? \
-- 
2.2.1

--
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/


[PATCH 0/8] staging/rtl8xxx: delete ieee80211 constant duplication

2015-04-26 Thread Paul Gortmaker
While looking at a non-staging wifi driver, I was searching for a constant
definition for an error code, and in addition to the expected one living
in the main include dir, I found a whole bunch of local copies in the
staging dir rtl8xxx wifi drivers.  This duplication covers the families
of WLAN_STATUS_ and WLAN_REASON_ values.

While one can understand that these things were wholesale copied at one
point to simplify out of tree building, we don't want duplicated stuff
for drivers that are in tree.  Even if they are in staging, they will
need cleanups like this if they ever want to get out of staging.

Some could be removed and trivially replaced with the associated include
of  but for a couple of others a couple of struct
fields had to be renamed to align with the main include first, and a
struct namespace collision between the main include and the local ones
had to be resolved to allow the duplicate constant removal as well.

Compile tested only, but the changes seem trivial enough so as to be
presumably zero runtime impact (famous last words)

---

Paul Gortmaker (8):
  rtl8188eu: don't duplicate ieee80211 constants for status/reason
  rtl8712: don't duplicate ieee80211 constants for status/reason
  rtl8192u: don't trample on  struct namespace
  rtl8192u: promote auth_mode to a full 8 bits
  rtl8192u: align local ieee80211_wmm_ac_param struct fields with global
  rtl8192u: don't duplicate ieee80211 constants for status/auth/reason
  rtl8192u: delete another embedded instance of generic reason codes
  rtl8192e: delete local copy of iee80211 reason codes.

 drivers/staging/rtl8188eu/core/rtw_ap.c|   2 +
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c  |  10 +-
 drivers/staging/rtl8188eu/core/rtw_recv.c  |   2 +
 drivers/staging/rtl8188eu/include/ieee80211.h  |  29 +---
 drivers/staging/rtl8188eu/include/wifi.h   |  77 --
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c |   2 +
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   |   3 +-
 drivers/staging/rtl8192e/rtllib.h  |  39 -
 drivers/staging/rtl8192e/rtllib_softmac.c  |   3 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 171 +++--
 .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c  |  10 +-
 .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c  |  26 ++--
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  |  76 -
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c |  32 ++--
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  |  14 +-
 .../staging/rtl8192u/ieee80211/rtl819x_BAProc.c|  48 +++---
 drivers/staging/rtl8192u/r8192U_core.c |  12 +-
 drivers/staging/rtl8712/ieee80211.h|  29 
 18 files changed, 150 insertions(+), 435 deletions(-)

-- 
2.2.1

--
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/


[PATCH 4/8] rtl8192u: promote auth_mode to a full 8 bits

2015-04-26 Thread Paul Gortmaker
Currently LEAP is defined to two locally but the identically named
global constant is 128 in .  In order for us to
switch over to using the global value, we need to adjust the local
storage which is currently not enough to hold the larger value.

This is now consistent with the similar struct used in
drivers/net/wireless/ipw2x00/libipw.h and other drivers.

Signed-off-by: Paul Gortmaker 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h 
b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index bdad6d07c574..f6db98c7824c 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -649,7 +649,7 @@ struct ieee80211_snap_hdr {
 /* Authentication algorithms */
 #define WLAN_AUTH_OPEN 0
 #define WLAN_AUTH_SHARED_KEY 1
-#define WLAN_AUTH_LEAP 2
+#define WLAN_AUTH_LEAP 128
 
 #define WLAN_AUTH_CHALLENGE_LEN 128
 
@@ -961,10 +961,10 @@ struct ieee80211_device;
 struct ieee80211_security {
u16 active_key:2,
enabled:1,
-   auth_mode:2,
auth_algo:4,
unicast_uses_group:1,
encrypt:1;
+   u8 auth_mode;
u8 key_sizes[WEP_KEYS];
u8 keys[WEP_KEYS][SCM_KEY_LEN];
u8 level;
-- 
2.2.1

--
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/


[PATCH 1/8] rtl8188eu: don't duplicate ieee80211 constants for status/reason

2015-04-26 Thread Paul Gortmaker
These are all defined as a part of the standard and should not be
duplicated on a per-driver basis.  Use the global ones and delete the
local ones.

Note that a couple of them had slight wording differences, things like
INVALID vs. NOT_VALID or similar, so they are aligned with the global
naming conventions here, as dictated by compile testing.

This isn't the totality of duplicated data removed, but it is a start.

Signed-off-by: Paul Gortmaker 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c|  2 +
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c  | 10 ++--
 drivers/staging/rtl8188eu/core/rtw_recv.c  |  2 +
 drivers/staging/rtl8188eu/include/ieee80211.h  | 29 +-
 drivers/staging/rtl8188eu/include/wifi.h   | 77 --
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c |  2 +
 6 files changed, 13 insertions(+), 109 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index e65ee6e858a8..1d3f72800492 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -19,6 +19,8 @@
  
**/
 #define _RTW_AP_C_
 
+#include 
+
 #include 
 #include 
 #include 
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index be9e34a0daef..2da2e97647d6 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -19,6 +19,8 @@
  
**/
 #define _RTW_MLME_EXT_C_
 
+#include 
+
 #include 
 #include 
 #include 
@@ -1048,10 +1050,10 @@ unsigned int OnAssocReq(struct adapter *padapter, 
struct recv_frame *precv_frame
pstat->wpa2_pairwise_cipher = 
pairwise_cipher>wpa2_pairwise_cipher;
 
if (!pstat->wpa2_group_cipher)
-   status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
+   status = WLAN_STATUS_INVALID_GROUP_CIPHER;
 
if (!pstat->wpa2_pairwise_cipher)
-   status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
+   status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER;
} else {
status = WLAN_STATUS_INVALID_IE;
}
@@ -1069,10 +1071,10 @@ unsigned int OnAssocReq(struct adapter *padapter, 
struct recv_frame *precv_frame
pstat->wpa_pairwise_cipher = 
pairwise_cipher>wpa_pairwise_cipher;
 
if (!pstat->wpa_group_cipher)
-   status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
+   status = WLAN_STATUS_INVALID_GROUP_CIPHER;
 
if (!pstat->wpa_pairwise_cipher)
-   status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
+   status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER;
} else {
status = WLAN_STATUS_INVALID_IE;
}
diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index cda725a8f9cd..8501eb898824 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -19,6 +19,8 @@
  
**/
 #define _RTW_RECV_C_
 
+#include 
+
 #include 
 #include 
 #include 
diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h 
b/drivers/staging/rtl8188eu/include/ieee80211.h
index 8fd35dcdbb94..b129ad148b47 100644
--- a/drivers/staging/rtl8188eu/include/ieee80211.h
+++ b/drivers/staging/rtl8188eu/include/ieee80211.h
@@ -493,34 +493,7 @@ struct ieee80211_snap_hdr {
 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
 
-/* Status codes */
-#define WLAN_STATUS_SUCCESS 0
-#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
-#define WLAN_STATUS_CAPS_UNSUPPORTED 10
-#define WLAN_STATUS_REASSOC_NO_ASSOC 11
-#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
-#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
-#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
-#define WLAN_STATUS_CHALLENGE_FAIL 15
-#define WLAN_STATUS_AUTH_TIMEOUT 16
-#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
-#define WLAN_STATUS_ASSOC_DENIED_RATES 18
-/* 802.11b */
-#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
-#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
-#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
-
-/* Reason codes */
-#define WLAN_REASON_UNSPECIFIED 1
-#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
-#define WLAN_REASON_DEAUTH_LEAVING 3
-#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
-#define WLAN_REASON_DISASSOC_AP_BUSY 5
-#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
-#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
-#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
-#define 

[PATCH 6/8] rtl8192u: don't duplicate ieee80211 constants for status/auth/reason

2015-04-26 Thread Paul Gortmaker
These are all defined as a part of the standard and should not be
duplicated on a per-driver basis.  Use the global ones and delete the
local ones.

In switching to  we have to delete a local copy of
an identical struct that we prepped earlier to have identical field
names, and we add explicit include <...> where needed in order to
preserve getting a successful compile.

This isn't the totality of duplicated data removed, but it is a start.

Signed-off-by: Paul Gortmaker 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 77 +-
 1 file changed, 1 insertion(+), 76 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h 
b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index 14ef5e193f2e..960769bfa15f 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -34,6 +34,7 @@
 
 #include 
 #include 
+#include 
 
 #include "rtl819x_HT.h"
 #include "rtl819x_BA.h"
@@ -646,13 +647,6 @@ struct ieee80211_snap_hdr {
 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
 #define WLAN_GET_SEQ_SEQ(seq)  (((seq) & IEEE80211_SCTL_SEQ) >> 4)
 
-/* Authentication algorithms */
-#define WLAN_AUTH_OPEN 0
-#define WLAN_AUTH_SHARED_KEY 1
-#define WLAN_AUTH_LEAP 128
-
-#define WLAN_AUTH_CHALLENGE_LEN 128
-
 #define WLAN_CAPABILITY_BSS (1<<0)
 #define WLAN_CAPABILITY_IBSS (1<<1)
 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
@@ -671,69 +665,6 @@ struct ieee80211_snap_hdr {
 #define WLAN_ERP_USE_PROTECTION (1<<1)
 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
 
-/* Status codes */
-enum ieee80211_statuscode {
-   WLAN_STATUS_SUCCESS = 0,
-   WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
-   WLAN_STATUS_CAPS_UNSUPPORTED = 10,
-   WLAN_STATUS_REASSOC_NO_ASSOC = 11,
-   WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
-   WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
-   WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
-   WLAN_STATUS_CHALLENGE_FAIL = 15,
-   WLAN_STATUS_AUTH_TIMEOUT = 16,
-   WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
-   WLAN_STATUS_ASSOC_DENIED_RATES = 18,
-   /* 802.11b */
-   WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
-   WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
-   WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
-   /* 802.11h */
-   WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
-   WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
-   WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
-   /* 802.11g */
-   WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
-   WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
-   /* 802.11i */
-   WLAN_STATUS_INVALID_IE = 40,
-   WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
-   WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
-   WLAN_STATUS_INVALID_AKMP = 43,
-   WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
-   WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
-   WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
-};
-
-/* Reason codes */
-enum ieee80211_reasoncode {
-   WLAN_REASON_UNSPECIFIED = 1,
-   WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
-   WLAN_REASON_DEAUTH_LEAVING = 3,
-   WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
-   WLAN_REASON_DISASSOC_AP_BUSY = 5,
-   WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
-   WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
-   WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
-   WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
-   /* 802.11h */
-   WLAN_REASON_DISASSOC_BAD_POWER = 10,
-   WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
-   /* 802.11i */
-   WLAN_REASON_INVALID_IE = 13,
-   WLAN_REASON_MIC_FAILURE = 14,
-   WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
-   WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
-   WLAN_REASON_IE_DIFFERENT = 17,
-   WLAN_REASON_INVALID_GROUP_CIPHER = 18,
-   WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
-   WLAN_REASON_INVALID_AKMP = 20,
-   WLAN_REASON_UNSUPP_RSN_VERSION = 21,
-   WLAN_REASON_INVALID_RSN_IE_CAP = 22,
-   WLAN_REASON_IEEE8021X_FAILED = 23,
-   WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
-};
-
 #define IEEE80211_STATMASK_SIGNAL (1<<0)
 #define IEEE80211_STATMASK_RSSI (1<<1)
 #define IEEE80211_STATMASK_NOISE (1<<2)
@@ -1276,12 +1207,6 @@ struct ieee80211_tim_parameters {
 } __packed;
 
 //#else
-struct ieee80211_wmm_ac_param {
-   u8 aci_aifsn;
-   u8 cw;
-   u16 txop_limit;
-};
-
 struct ieee80211_wmm_ts_info {
u8 ac_dir_tid;
u8 ac_up_psb;
-- 
2.2.1

--
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/


[PATCH 8/8] rtl8192e: delete local copy of iee80211 reason codes.

2015-04-26 Thread Paul Gortmaker
This driver has a copy of the standard reason codes from the file
 but with slightly different name fields.

Delete the local copy and remap the only two use cases onto the names
used by the global implementation with the same values.

Signed-off-by: Paul Gortmaker 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c |  3 ++-
 drivers/staging/rtl8192e/rtllib.h| 39 
 drivers/staging/rtl8192e/rtllib_softmac.c|  3 ++-
 3 files changed, 4 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 352d381b7c4a..ad0034575a18 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "rtl_core.h"
 #include "r8192E_phy.h"
 #include "r8192E_phyreg.h"
@@ -391,7 +392,7 @@ bool MgntActSet_RF_State(struct net_device *dev,
else
priv->blinked_ingpio = false;
rtllib_MgntDisconnect(priv->rtllib,
- disas_lv_ss);
+ 
WLAN_REASON_DISASSOC_STA_HAS_LEFT);
}
}
if ((ChangeSource == RF_CHANGE_BY_HW) && !priv->bHwRadioOff)
diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 3c8b708df5c3..bfec4fde01d1 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -261,45 +261,6 @@ struct sw_chnl_cmd {
 #defineMGN_MCS14_SG0x9e
 #defineMGN_MCS15_SG0x9f
 
-
-enum   _ReasonCode {
-   unspec_reason   = 0x1,
-   auth_not_valid  = 0x2,
-   deauth_lv_ss= 0x3,
-   inactivity  = 0x4,
-   ap_overload = 0x5,
-   class2_err  = 0x6,
-   class3_err  = 0x7,
-   disas_lv_ss = 0x8,
-   asoc_not_auth   = 0x9,
-
-   mic_failure = 0xe,
-
-   invalid_IE  = 0x0d,
-   four_way_tmout  = 0x0f,
-   two_way_tmout   = 0x10,
-   IE_dismatch = 0x11,
-   invalid_Gcipher = 0x12,
-   invalid_Pcipher = 0x13,
-   invalid_AKMP= 0x14,
-   unsup_RSNIEver = 0x15,
-   invalid_RSNIE   = 0x16,
-   auth_802_1x_fail = 0x17,
-   ciper_reject= 0x18,
-
-   QoS_unspec  = 0x20,
-   QAP_bandwidth   = 0x21,
-   poor_condition  = 0x22,
-   no_facility = 0x23,
-   req_declined= 0x25,
-   invalid_param   = 0x26,
-   req_not_honored = 0x27,
-   TS_not_created  = 0x2F,
-   DL_not_allowed  = 0x30,
-   dest_not_exist  = 0x31,
-   dest_not_QSTA   = 0x32,
-};
-
 enum hal_def_variable {
HAL_DEF_TPC_ENABLE,
HAL_DEF_INIT_GAIN,
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c 
b/drivers/staging/rtl8192e/rtllib_softmac.c
index 23b7a4c3b699..8f5e88b802c8 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "dot11d.h"
 
 short rtllib_is_54g(struct rtllib_network *net)
@@ -2983,7 +2984,7 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 
shutdown)
 
if (ieee->state == RTLLIB_LINKED) {
if (ieee->iw_mode == IW_MODE_INFRA)
-   SendDisassociation(ieee, 1, deauth_lv_ss);
+   SendDisassociation(ieee, 1, WLAN_REASON_DEAUTH_LEAVING);
rtllib_disassociate(ieee);
}
 
-- 
2.2.1

--
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/


[PATCH 3/8] rtl8192u: don't trample on struct namespace

2015-04-26 Thread Paul Gortmaker
In order to start reducing the duplicated code/constants/macros in this
driver, we need to include  to provide the defacto
versions.  However this driver has structs with the same name as the
ones in the main include, so namespace collision prevents us from doing
step #1.

Since the structs actually differ in their respective fields, we can't
simply delete the local ones without impacting the runtime; a conversion
to use the global ones can be considered at a later date if desired.

Rename the ones here with a vendor specific prefix so that we won't have
the namespace collision, and hence can continue on with the cleanup.

Automated conversion done with:

for i in `find . -name '*.[ch]'` ; do \
  sed -i 's/struct ieee80211_hdr/struct rtl_80211_hdr/g' $i ; \
done

Signed-off-by: Paul Gortmaker 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 44 +++---
 .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c  | 10 ++--
 .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c  | 26 -
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  | 68 +++---
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 32 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  | 14 ++---
 .../staging/rtl8192u/ieee80211/rtl819x_BAProc.c| 48 +++
 drivers/staging/rtl8192u/r8192U_core.c | 12 ++--
 8 files changed, 127 insertions(+), 127 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h 
b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index 0f53c6a97578..bdad6d07c574 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -1020,20 +1020,20 @@ enum ieee80211_mfie {
 /* Minimal header; can be used for passing 802.11 frames with sufficient
  * information to determine what type of underlying data type is actually
  * stored in the data. */
-struct ieee80211_hdr {
+struct rtl_80211_hdr {
__le16 frame_ctl;
__le16 duration_id;
u8 payload[0];
 } __packed;
 
-struct ieee80211_hdr_1addr {
+struct rtl_80211_hdr_1addr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
u8 payload[0];
 } __packed;
 
-struct ieee80211_hdr_2addr {
+struct rtl_80211_hdr_2addr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1041,7 +1041,7 @@ struct ieee80211_hdr_2addr {
u8 payload[0];
 } __packed;
 
-struct ieee80211_hdr_3addr {
+struct rtl_80211_hdr_3addr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1051,7 +1051,7 @@ struct ieee80211_hdr_3addr {
u8 payload[0];
 } __packed;
 
-struct ieee80211_hdr_4addr {
+struct rtl_80211_hdr_4addr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1062,7 +1062,7 @@ struct ieee80211_hdr_4addr {
u8 payload[0];
 } __packed;
 
-struct ieee80211_hdr_3addrqos {
+struct rtl_80211_hdr_3addrqos {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1073,7 +1073,7 @@ struct ieee80211_hdr_3addrqos {
__le16 qos_ctl;
 } __packed;
 
-struct ieee80211_hdr_4addrqos {
+struct rtl_80211_hdr_4addrqos {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1092,7 +1092,7 @@ struct ieee80211_info_element {
 } __packed;
 
 struct ieee80211_authentication {
-   struct ieee80211_hdr_3addr header;
+   struct rtl_80211_hdr_3addr header;
__le16 algorithm;
__le16 transaction;
__le16 status;
@@ -1101,18 +1101,18 @@ struct ieee80211_authentication {
 } __packed;
 
 struct ieee80211_disassoc {
-   struct ieee80211_hdr_3addr header;
+   struct rtl_80211_hdr_3addr header;
__le16 reason;
 } __packed;
 
 struct ieee80211_probe_request {
-   struct ieee80211_hdr_3addr header;
+   struct rtl_80211_hdr_3addr header;
/* SSID, supported rates */
struct ieee80211_info_element info_element[0];
 } __packed;
 
 struct ieee80211_probe_response {
-   struct ieee80211_hdr_3addr header;
+   struct rtl_80211_hdr_3addr header;
__le32 time_stamp[2];
__le16 beacon_interval;
__le16 capability;
@@ -1125,7 +1125,7 @@ struct ieee80211_probe_response {
 #define ieee80211_beacon ieee80211_probe_response
 
 struct ieee80211_assoc_request_frame {
-   struct ieee80211_hdr_3addr header;
+   struct rtl_80211_hdr_3addr header;
__le16 capability;
__le16 listen_interval;
/* SSID, supported rates, RSN */
@@ -1133,7 +1133,7 @@ struct ieee80211_assoc_request_frame {
 } __packed;
 
 struct ieee80211_reassoc_request_frame {
-   struct ieee80211_hdr_3addr header;
+   struct rtl_80211_hdr_3addr header;
__le16 capability;
__le16 listen_interval;
u8 current_ap[ETH_ALEN];
@@ -1142,7 +1142,7 @@ struct ieee80211_reassoc_request_frame {
 } __packed;
 
 struct ieee80211_assoc_response_frame {
-   struct 

[PATCH 5/8] rtl8192u: align local ieee80211_wmm_ac_param struct fields with global

2015-04-26 Thread Paul Gortmaker
The  and this local file both have a struct of the
same name.  They also have the same field sizes and generally the
same fields, as can be seen here:

   ~/git/linux-head$ git grep -A4 'struct ieee80211_wmm_ac_param {'
   drivers/staging/rtl8192u/ieee80211/ieee80211.h:struct ieee80211_wmm_ac_param 
{
   drivers/staging/rtl8192u/ieee80211/ieee80211.h- u8 ac_aci_acm_aifsn;
   drivers/staging/rtl8192u/ieee80211/ieee80211.h- u8 ac_ecwmin_ecwmax;
   drivers/staging/rtl8192u/ieee80211/ieee80211.h- u16 ac_txop_limit;
   drivers/staging/rtl8192u/ieee80211/ieee80211.h-};
   --
   include/linux/ieee80211.h:struct ieee80211_wmm_ac_param {
   include/linux/ieee80211.h-  u8 aci_aifsn; /* AIFSN, ACM, ACI */
   include/linux/ieee80211.h-  u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */
   include/linux/ieee80211.h-  __le16 txop_limit;
   include/linux/ieee80211.h-} __packed;
   ~/git/linux-head$

Here we just align the local field names with the main system one.  Then
we can add an include of the system one and delete the local copy in one
smooth step in a follow-on commit.

Not that the replacement:

 for i in `find . -name '*.[ch]'` ; do sed -i 's/ac_aci_acm_aifsn/aci_aifsn/g' 
$i ; done
 for i in `find . -name '*.[ch]'` ; do sed -i 's/ac_ecwmin_ecwmax/cw/g' $i ; 
done
 for i in `find . -name '*.[ch]'` ; do sed -i 's/ac_txop_limit/txop_limit/g' $i 
; done

implicitly shows that only one of the three fields is currently used.

Signed-off-by: Paul Gortmaker 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h| 6 +++---
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 8 
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h 
b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index f6db98c7824c..14ef5e193f2e 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -1277,9 +1277,9 @@ struct ieee80211_tim_parameters {
 
 //#else
 struct ieee80211_wmm_ac_param {
-   u8 ac_aci_acm_aifsn;
-   u8 ac_ecwmin_ecwmax;
-   u16 ac_txop_limit;
+   u8 aci_aifsn;
+   u8 cw;
+   u16 txop_limit;
 };
 
 struct ieee80211_wmm_ts_info {
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index e833687c7371..b374088c5ff8 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -2366,10 +2366,10 @@ static inline void update_network(struct 
ieee80211_network *dst,
 
/* dst->last_associate is not overwritten */
dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe 
response frame.
-   if (src->wmm_param[0].ac_aci_acm_aifsn|| \
-  src->wmm_param[1].ac_aci_acm_aifsn|| \
-  src->wmm_param[2].ac_aci_acm_aifsn|| \
-  src->wmm_param[3].ac_aci_acm_aifsn) {
+   if (src->wmm_param[0].aci_aifsn|| \
+  src->wmm_param[1].aci_aifsn|| \
+  src->wmm_param[2].aci_aifsn|| \
+  src->wmm_param[3].aci_aifsn) {
  memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
}
//dst->QoS_Enable = src->QoS_Enable;
-- 
2.2.1

--
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] [media] xilinx: Reflect dma header file move

2015-04-26 Thread Michal Simek
On 04/24/2015 09:24 PM, Guenter Roeck wrote:
> Commit 937abe88aea3 ("dmaengine: xilinx-dma: move header file to common
> location") moved xilinx_dma.h to a common location but neglected to reflect
> this move in all its users.
> 
> This causes compile errors for several builds.
> 
> drivers/media/platform/xilinx/xilinx-dma.c:15:35:
>   fatal error: linux/amba/xilinx_dma.h: No such file or directory
> 
> Cc: Kedareswara rao Appana 
> Fixes: 937abe88aea3 ("dmaengine: xilinx-dma: move header file to common
>   location")
> Signed-off-by: Guenter Roeck 
> ---
>  drivers/media/platform/xilinx/xilinx-dma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

FYI:
http://www.serverphorums.com/read.php?12,1179281

https://lkml.org/lkml/2015/4/25/25

Thanks,
Michal
--
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 v3] dmaengine: xgene-dma: Fix sparse wannings and coccinelle warnings

2015-04-26 Thread Fengguang Wu
On Mon, Apr 27, 2015 at 08:43:15AM +0530, Vinod Koul wrote:
> On Mon, Apr 20, 2015 at 08:38:18AM +0530, Rameshwar Sahu wrote:
> > Hi Vinod,
> >> >> @@ -2085,6 +2043,5 @@ module_platform_driver(xgene_dma_driver);
> > >>
> > >>  MODULE_DESCRIPTION("APM X-Gene SoC DMA driver");
> > >>  MODULE_AUTHOR("Rameshwar Prasad Sahu ");
> > >> -MODULE_AUTHOR("Loc Ho ");
> > > And why this?
> > 
> > I saw below warning reported by the kbuild robot test
> > 
> > drivers/dma/xgene-dma.c:2088:1: sparse: symbol
> > '__UNIQUE_ID_author__COUNTER__' has multiple initializers (originally
> > initialized at drivers/dma/xgene-dma.c:2087)
> > So, I kept only one author here.
> No that is not right, sparse shouldn't have cribbed here.
> 
> Fengguang can we get the bot to ignore this please

OK, sorry for the noises! CC sparse maintainer btw.

Thanks,
Fengguang
--
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/


[PATCH] block: turn Oops into WARNING if bdi_register_dev fails.

2015-04-26 Thread NeilBrown

add_disk() does not return an error status, but it can
still fail if there are problems elsewhere.

In particular a recent problem caused bdi_register_dev()
to sometimes fail because the name was already in use.

In that case bdi->dev is NULL, so

retval = sysfs_create_link(_to_dev(disk)->kobj, >dev->kobj,
   "bdi");

triggers an oops, after having already produced warnings.

This patch causes add_disk() to WARN and return if
bdi_register_dev() fails, much like it already does if
blk_alloc_devt() fails.

This should make no difference on a correctly functioning system, but
can make a developers life a bit easier.

Signed-off-by: NeilBrown 

diff --git a/block/genhd.c b/block/genhd.c
index 0a536dc05f3b..e351fc521053 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -612,6 +612,10 @@ void add_disk(struct gendisk *disk)
/* Register BDI before referencing it from bdev */
bdi = >queue->backing_dev_info;
bdi_register_dev(bdi, disk_devt(disk));
+   if (!bdi->dev) {
+   WARN_ON(1);
+   return;
+   }
 
blk_register_region(disk_devt(disk), disk->minors, NULL,
exact_match, exact_lock, disk);


pgpDN8swpNffB.pgp
Description: OpenPGP digital signature


Re: [PATCH 1/8] cpufreq: arm_big_little: add cluster regulator support

2015-04-26 Thread Viresh Kumar
On 21 April 2015 at 18:47, Bartlomiej Zolnierkiewicz
 wrote:
> Add cluster regulator support as a preparation to adding
> generic arm_big_little_dt cpufreq_dt driver support for
> ODROID-XU3 board.  This allows arm_big_little[_dt] driver

This is irrelevant here, its not about XU3 but any board that
wants to use it..

> to set not only the frequency but also the voltage (which
> is obtained from operating point's voltage value) for CPU
> clusters.
>
> Cc: Kukjin Kim 
> Cc: Doug Anderson 
> Cc: Javier Martinez Canillas 
> Cc: Andreas Faerber 
> Cc: Sachin Kamat 
> Cc: Thomas Abraham 
> Signed-off-by: Bartlomiej Zolnierkiewicz 
> ---
>  .../bindings/cpufreq/arm_big_little_dt.txt |4 +
>  drivers/cpufreq/arm_big_little.c   |  153 
> +---
>  2 files changed, 139 insertions(+), 18 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt 
> b/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt
> index 0715695..8ca4a12 100644
> --- a/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt
> +++ b/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt
> @@ -18,6 +18,10 @@ Required properties:
>  Optional properties:
>  - clock-latency: Specify the possible maximum transition latency for clock,
>in unit of nanoseconds.
> +- cpu-cluster.0-supply: Provides the regulator node supplying voltage to CPU
> +  cluster 0.
> +- cpu-cluster.1-supply: Provides the regulator node supplying voltage to CPU
> +  cluster 1.

I don't think you need these..

http://permalink.gmane.org/gmane.linux.power-management.general/58548

>  Examples:
>
> diff --git a/drivers/cpufreq/arm_big_little.c 
> b/drivers/cpufreq/arm_big_little.c
> index e1a6ba6..edb461b 100644
> --- a/drivers/cpufreq/arm_big_little.c
> +++ b/drivers/cpufreq/arm_big_little.c
> @@ -31,6 +31,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  #include "arm_big_little.h"
> @@ -54,6 +55,9 @@ static bool bL_switching_enabled;
>
>  static struct cpufreq_arm_bL_ops *arm_bL_ops;
>  static struct clk *clk[MAX_CLUSTERS];
> +static struct regulator *reg[MAX_CLUSTERS];
> +static struct device *cpu_devs[MAX_CLUSTERS];
> +static int transition_latencies[MAX_CLUSTERS];
>  static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS + 1];
>  static atomic_t cluster_usage[MAX_CLUSTERS + 1];
>
> @@ -122,7 +126,76 @@ static unsigned int bL_cpufreq_get_rate(unsigned int cpu)
> }
>  }
>
> -static unsigned int
> +static int
> +bL_cpufreq_set_rate_cluster(u32 cpu, u32 cluster, u32 new_rate)
> +{
> +   unsigned long volt = 0, volt_old = 0;
> +   long freq_Hz;
> +   u32 old_rate;
> +   int ret;
> +
> +   freq_Hz = new_rate * 1000;
> +   old_rate = clk_get_rate(clk[cluster]) / 1000;
> +
> +   if (!IS_ERR(reg[cluster])) {
> +   struct dev_pm_opp *opp;
> +   unsigned long opp_freq;
> +
> +   rcu_read_lock();
> +   opp = dev_pm_opp_find_freq_ceil(cpu_devs[cluster], _Hz);
> +   if (IS_ERR(opp)) {
> +   rcu_read_unlock();
> +   pr_err("%s: cpu %d, cluster: %d, failed to find OPP 
> for %ld\n",
> +   __func__, cpu, cluster, freq_Hz);
> +   return PTR_ERR(opp);
> +   }
> +   volt = dev_pm_opp_get_voltage(opp);
> +   opp_freq = dev_pm_opp_get_freq(opp);
> +   rcu_read_unlock();
> +   volt_old = regulator_get_voltage(reg[cluster]);
> +   pr_debug("%s: cpu %d, cluster: %d, Found OPP: %ld kHz, %ld 
> uV\n",
> +   __func__, cpu, cluster, opp_freq / 1000, volt);
> +   }
> +
> +   pr_debug("%s: cpu %d, cluster: %d, %u MHz, %ld mV --> %u MHz, %ld 
> mV\n",
> +   __func__, cpu, cluster,
> +   old_rate / 1000, (volt_old > 0) ? volt_old / 1000 : -1,
> +   new_rate / 1000, volt ? volt / 1000 : -1);
> +
> +   /* scaling up? scale voltage before frequency */
> +   if (!IS_ERR(reg[cluster]) && new_rate > old_rate) {
> +   ret = regulator_set_voltage_tol(reg[cluster], volt, 0);
> +   if (ret) {
> +   pr_err("%s: cpu: %d, cluster: %d, failed to scale 
> voltage up: %d\n",
> +   __func__, cpu, cluster, ret);
> +   return ret;
> +   }
> +   }
> +
> +   ret = clk_set_rate(clk[cluster], new_rate * 1000);
> +   if (WARN_ON(ret)) {
> +   pr_err("%s: clk_set_rate failed: %d, cluster: %d\n",
> +   __func__, cluster, ret);
> +   if (!IS_ERR(reg[cluster]) && volt_old > 0)
> +   regulator_set_voltage_tol(reg[cluster], volt_old, 0);
> +   return ret;
> +   }
> +
> +   /* scaling down? scale voltage after frequency */
> +   if (!IS_ERR(reg[cluster]) && new_rate < old_rate) 

Re: [PATCHv2 2/8] perf probe: Improve detection of file/function name in the probe pattern

2015-04-26 Thread Naveen N. Rao
On 2015/03/13 08:20PM, Masami Hiramatsu wrote:
> (2015/03/13 5:24), Arnaldo Carvalho de Melo wrote:
> > Em Mon, Dec 15, 2014 at 08:20:32PM +0530, Naveen N. Rao escreveu:
> >> Currently, perf probe considers patterns including a '.' to be a file.
> >> However, this causes problems on powerpc ABIv1 where all functions have
> >> a leading '.':
> >>
> >>   $ perf probe -F | grep schedule_timeout_interruptible
> >>   .schedule_timeout_interruptible
> >>   $ perf probe .schedule_timeout_interruptible
> >>   Semantic error :File always requires line number or lazy pattern.
> >> Error: Command Parse Error.
> >>
> >> Fix this by checking the probe pattern in more detail.
> > 
> > Masami, can I have your Acked-by or Reviewed-by?
> 
> As far as I can see, this is not enough for fixing that issue.
> Could you fold the first half of [4/8] to this patch?
> I also have some comments on it. See below.

Masami, Arnaldo,
Thanks for the review. v3 patches forthcoming...

- Naveen

--
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: [PATCHv2 5/8] perf probe powerpc: Allow matching against dot symbols

2015-04-26 Thread Naveen N. Rao
On 2015/03/12 05:30PM, Arnaldo Carvalho de Melo wrote:
> Em Mon, Dec 15, 2014 at 08:20:35PM +0530, Naveen N. Rao escreveu:
> > Allow perf probe to work on powerpc ABIv1 without the need to specify
> > the leading dot '.' for functions. 'perf probe do_fork' works with this
> > patch.
> > 
> > Introduce HAVE_ARCH_SYMBOL_HANDLING to indicate need for special
> > handling of symbols. In this patch, we override probe_function_filter()
> > on powerpc to account for dot symbols.
> 
> This one looks better, does arch specific stuff in tools/perf/arch,
> good, some nits below.
> 
> > Signed-off-by: Naveen N. Rao 
> > ---
> > Changes from the previous patchset:
> > Introduced arch helper to override the way probe function filter works.
> > 
> >  tools/perf/arch/powerpc/Makefile|  1 +
> >  tools/perf/arch/powerpc/util/sym-handling.c | 28 
> > 
> >  tools/perf/config/Makefile  |  1 +
> >  tools/perf/util/probe-event.c   | 10 +-
> >  tools/perf/util/probe-event.h   |  5 +
> >  5 files changed, 40 insertions(+), 5 deletions(-)
> >  create mode 100644 tools/perf/arch/powerpc/util/sym-handling.c
> > 
> > diff --git a/tools/perf/arch/powerpc/Makefile 
> > b/tools/perf/arch/powerpc/Makefile
> > index 6f7782b..1c3d435 100644
> > --- a/tools/perf/arch/powerpc/Makefile
> > +++ b/tools/perf/arch/powerpc/Makefile
> > @@ -3,4 +3,5 @@ PERF_HAVE_DWARF_REGS := 1
> >  LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
> >  LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/skip-callchain-idx.o
> >  endif
> > +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/sym-handling.o
> >  LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
> > diff --git a/tools/perf/arch/powerpc/util/sym-handling.c 
> > b/tools/perf/arch/powerpc/util/sym-handling.c
> > new file mode 100644
> > index 000..0a77825
> > --- /dev/null
> > +++ b/tools/perf/arch/powerpc/util/sym-handling.c
> > @@ -0,0 +1,28 @@
> > +/*
> > + * Special symbol handling for PowerPC:
> > + * - Handle dot symbols on ABIv1
> > + *
> > + * Copyright (C) 2014 Naveen N Rao, IBM Corporation.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License
> > + * as published by the Free Software Foundation; either version
> > + * 2 of the License, or (at your option) any later version.
> > + */
> > +
> > +#include "map.h"
> > +#include "symbol.h"
> > +#include "probe-event.h"
> > +
> > +int probe_function_filter(struct map *map __maybe_unused, struct symbol 
> > *sym)
> > +{
> > +   if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) {
> > +   if ((strcmp(looking_function_name, sym->name) == 0) ||
> > +   (sym->name[0] == '.' && looking_function_name[0] != '.' &&
> > +strcmp(looking_function_name, sym->name+1) == 0)) {
> > +   num_matched_functions++;
> > +   return 0;
> > +   }
> > +   }
> > +   return 1;
> > +}
> > diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
> > index 5d4b039..35cf934 100644
> > --- a/tools/perf/config/Makefile
> > +++ b/tools/perf/config/Makefile
> > @@ -383,6 +383,7 @@ ifeq ($(ARCH),powerpc)
> >ifndef NO_DWARF
> >  CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
> >endif
> > +  CFLAGS += -DHAVE_ARCH_SYMBOL_HANDLING
> 
> 
> Dunno about this naming, looks too general: SYMBOL_HANDLING, but can't
> come to some better one now, anyone?
> 
> >  endif
> >  
> >  ifndef NO_LIBUNWIND
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index 74b7fef..7eb9b27 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -50,6 +50,8 @@
> >  #define PERFPROBE_GROUP "probe"
> >  
> >  bool probe_event_dry_run;  /* Dry run flag */
> > +char *looking_function_name;
> > +int num_matched_functions;
> >  
> >  #define semantic_error(msg ...) pr_err("Semantic error :" msg)
> >  
> > @@ -2210,11 +2212,8 @@ static int __add_probe_trace_events(struct 
> > perf_probe_event *pev,
> > return ret;
> >  }
> >  
> > -static char *looking_function_name;
> > -static int num_matched_functions;
> > -
> > -static int probe_function_filter(struct map *map __maybe_unused,
> > - struct symbol *sym)
> > +#ifndef HAVE_ARCH_SYMBOL_HANDLING
> > +int probe_function_filter(struct map *map __maybe_unused, struct symbol 
> > *sym)
> >  {
> > if ((sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) &&
> > strcmp(looking_function_name, sym->name) == 0) {
> > @@ -2223,6 +,7 @@ static int probe_function_filter(struct map *map 
> > __maybe_unused,
> > }
> > return 1;
> >  }
> > +#endif /* HAVE_ARCH_SYMBOL_HANDLING */
> 
> Can't we do something like providing a weak function and let the linked
> to its work? I guess we have cases like this in tools/ already. I.e. not
> using the ifndef block. Minor nit tho.

That sounds like a good idea. I 

Re: [PATCHv2 3/8] perf probe powerpc: Fix symbol fixup issues due to ELF type

2015-04-26 Thread Naveen N. Rao
On 2015/03/12 05:23PM, Arnaldo Carvalho de Melo wrote:
> Em Mon, Dec 15, 2014 at 08:20:33PM +0530, Naveen N. Rao escreveu:
> > If using the symbol table, symbol addresses are not being fixed up
> > properly, resulting in probes being placed at wrong addresses:
> > 
> >   # perf probe do_fork
> >   Added new event:
> > probe:do_fork(on do_fork)
> > 
> >   You can now use it in all perf tools, such as:
> > 
> >   perf record -e probe:do_fork -aR sleep 1
> > 
> >   # cat /sys/kernel/debug/tracing/kprobe_events
> >   p:probe/do_fork _text+635952
> >   # printf "%x" 635952
> >   9b430
> >   # grep do_fork /boot/System.map
> >   c00ab430 T .do_fork
> > 
> > Fix by checking for ELF type ET_DYN used by ppc64 kernels.
> 
> Sorry if this was answered already, its been a while since this was
> posted/discussed... Are you completely sure this is not a problem on
> !ppc?
> 
> Woudln't it be more conservative to somehow only adjust symbols for this
> ET_DYN type if the arch is ppc? I.e. something like moving that
> adjust_symbols logic to be arch_adjust_symbols(), provide a default and
> then override it for ppc to include also ET_DYN?

I did check and I don't think any other arch kernel uses ET_DYN, but 
yes, being conservative, I could just make this a arch helper. Will do.

- Naveen

> 
> Looking at the other patches...
> 
> - Arnaldo
> 
> > Signed-off-by: Naveen N. Rao 
> > ---
> >  tools/perf/util/symbol-elf.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> > index 06fcd1b..7ac4e4c 100644
> > --- a/tools/perf/util/symbol-elf.c
> > +++ b/tools/perf/util/symbol-elf.c
> > @@ -683,7 +683,8 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, 
> > const char *name,
> >  NULL) != NULL);
> > } else {
> > ss->adjust_symbols = ehdr.e_type == ET_EXEC ||
> > -ehdr.e_type == ET_REL;
> > +ehdr.e_type == ET_REL ||
> > +ehdr.e_type == ET_DYN;
> > }
> >  
> > ss->name   = strdup(name);
> > -- 
> > 2.1.3
> 

--
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/


[PATCH 2/2] brcmfmac: keep WiFi chip's power during system suspension

2015-04-26 Thread Fu, Zhonghui
Need to keep the power supply for WiFi chip during system suspension.
Otherwise, the context of WiFi chip will be lost.

Signed-off-by: Zhonghui Fu 
---
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
index fdf8feb..03d3671 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
@@ -1251,15 +1251,17 @@ static int brcmf_ops_sdio_suspend(struct device *dev)
brcmf_sdiod_freezer_on(sdiodev);
brcmf_sdio_wd_timer(sdiodev->bus, 0);
 
+   sdio_flags = MMC_PM_KEEP_POWER;
if (sdiodev->wowl_enabled) {
-   sdio_flags = MMC_PM_KEEP_POWER;
if (sdiodev->pdata->oob_irq_supported)
enable_irq_wake(sdiodev->pdata->oob_irq_nr);
else
-   sdio_flags = MMC_PM_WAKE_SDIO_IRQ;
-   if (sdio_set_host_pm_flags(sdiodev->func[1], sdio_flags))
-   brcmf_err("Failed to set pm_flags %x\n", sdio_flags);
+   sdio_flags |= MMC_PM_WAKE_SDIO_IRQ;
}
+
+   if (sdio_set_host_pm_flags(sdiodev->func[1], sdio_flags))
+   brcmf_err("Failed to set pm_flags %x\n", sdio_flags);
+
return 0;
 }
 
-- 1.7.1

--
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: [PATCHv2 2/8] perf probe: Improve detection of file/function name in the probe pattern

2015-04-26 Thread Naveen N. Rao
On 2015/03/13 08:20PM, Masami Hiramatsu wrote:
> (2015/03/13 5:24), Arnaldo Carvalho de Melo wrote:
> > Em Mon, Dec 15, 2014 at 08:20:32PM +0530, Naveen N. Rao escreveu:
> >> Currently, perf probe considers patterns including a '.' to be a file.
> >> However, this causes problems on powerpc ABIv1 where all functions have
> >> a leading '.':
> >>
> >>   $ perf probe -F | grep schedule_timeout_interruptible
> >>   .schedule_timeout_interruptible
> >>   $ perf probe .schedule_timeout_interruptible
> >>   Semantic error :File always requires line number or lazy pattern.
> >> Error: Command Parse Error.
> >>
> >> Fix this by checking the probe pattern in more detail.
> > 
> > Masami, can I have your Acked-by or Reviewed-by?
> 
> As far as I can see, this is not enough for fixing that issue.
> Could you fold the first half of [4/8] to this patch?

Sure.

> I also have some comments on it. See below.
> 
> >  
> >> Signed-off-by: Naveen N. Rao 
> >> ---
> >>  tools/perf/util/probe-event.c | 23 ---
> >>  1 file changed, 20 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> >> index 28eb141..9943ff3 100644
> >> --- a/tools/perf/util/probe-event.c
> >> +++ b/tools/perf/util/probe-event.c
> >> @@ -999,6 +999,24 @@ static int parse_perf_probe_point(char *arg, struct 
> >> perf_probe_event *pev)
> >>arg = tmp;
> >>}
> >>  
> >> +  /*
> >> +   * Check arg is function or file name and copy it.
> >> +   *
> >> +   * We consider arg to be a file spec if and only if it satisfies
> >> +   * all of the below criteria::
> >> +   * - it does not include any of "+@%",
> >> +   * - it includes one of ":;", and
> >> +   * - it has a period '.' in the name.
> >> +   *
> >> +   * Otherwise, we consider arg to be a function specification.
> >> +   */
> >> +  c = 0;
> 
> Oh please, don't reuse 'char c' for a boolean flag, you should
> introduce new 'bool file_loc' etc.
> 
> >> +  if (!strpbrk(arg, "+@%") && (ptr = strpbrk(arg, ";:")) != NULL) {
> >> +  /* This is a file spec if it includes a '.' before ; or : */
> >> +  if (memchr(arg, '.', ptr-arg))
> ^^ add spaces around '-'.

Sure.

- Naveen
 

--
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] Bluetooth: Skip the shutdown routine if the interface is not up

2015-04-26 Thread David Miller
From: Marcel Holtmann 
Date: Sun, 26 Apr 2015 21:49:06 -0700

> Hi Gabriele,
> 
>> Most likely, the shutdown routine requires the interface to be up.
>> This is the case for BTUSB_INTEL: the routine tries to send a command
>> to the interface, but since this one is down, it fails and exits once
>> HCI_INIT_TIMEOUT has expired.
>> 
>> Signed-off-by: Gabriele Mazzotta 
>> ---
>> net/bluetooth/hci_core.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>> index 476709b..4663c3d 100644
>> --- a/net/bluetooth/hci_core.c
>> +++ b/net/bluetooth/hci_core.c
>> @@ -1557,7 +1557,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
>> {
>>  BT_DBG("%s %p", hdev->name, hdev);
>> 
>> -if (!hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
>> +if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
>> +test_bit(HCI_UP, >flags)) {
>>  /* Execute vendor specific shutdown routine */
>>  if (hdev->shutdown)
>>  hdev->shutdown(hdev);
> 
> this is a good catch.
> 
> Acked-by: Marcel Holtmann 
> Cc: sta...@vger.kernel.org # 4.0.x
> 
> Dave, do you want to take this patch straight into your stable tree?

Please handle this via the bluetooth tree, thanks.
--
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/


[PATCH 1/2] brcmfmac: prohibit ACPI power management for brcmfmac driver

2015-04-26 Thread Fu, Zhonghui
ACPI will manage WiFi chip's power state during suspend/resume
process on some tablet platforms(such as ASUS T100TA). This is
not supported by brcmfmac driver now, and the context of WiFi
chip will be damaged after resume. This patch disconnects the
relationship between WiFi chip and it's ACPI companion, and
prohibit ACPI PM for it.

Signed-off-by: Zhonghui Fu 
---
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
index 9b508bd..fdf8feb 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
@@ -1114,6 +1114,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
int err;
struct brcmf_sdio_dev *sdiodev;
struct brcmf_bus *bus_if;
+   struct device *dev;
 
brcmf_dbg(SDIO, "Enter\n");
brcmf_dbg(SDIO, "Class=%x\n", func->class);
@@ -1121,6 +1122,10 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
brcmf_dbg(SDIO, "sdio device ID: 0x%04x\n", func->device);
brcmf_dbg(SDIO, "Function#: %d\n", func->num);
 
+   /* prohibit ACPI power management for this device */
+   dev = >dev;
+   dev->fwnode = NULL;
+
/* Consume func num 1 but dont do anything with it. */
if (func->num == 1)
return 0;
-- 1.7.1

--
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/


[PATCH 3/3 v2] md/raid5: per hash value and exclusive wait_for_stripe

2015-04-26 Thread Yuanhan Liu
I noticed heavy spin lock contention at get_active_stripe() with fsmark
multiple thread write workloads.

Here is how this hot contention comes from. We have limited stripes, and
it's a multiple thread write workload. Hence, those stripes will be taken
soon, which puts later processes to sleep for waiting free stripes. When
enough stripes(>= 1/4 total stripes) are released, all process are woken,
trying to get the lock. But there is one only being able to get this lock
for each hash lock, making other processes spinning out there for acquiring
the lock.

Thus, it's effectiveless to wakeup all processes and let them battle for
a lock that permits one to access only each time. Instead, we could make
it be a exclusive wake up: wake up one process only. That avoids the heavy
spin lock contention naturally.

To do the exclusive wake up, we've to split wait_for_stripe into multiple
wait queues, to make it per hash value, just like the hash lock.

Here are some test results I have got with this patch applied(all test run
3 times):

`fsmark.files_per_sec'
=

next-20150317 this patch
- -
metric_value ±stddev  metric_value ±stddev change  
testbox/benchmark/testcase-params
- -    
--
  25.600 ±0.0  92.700 ±2.5  262.1% 
ivb44/fsmark/1x-64t-4BRD_12G-RAID5-btrfs-4M-30G-fsyncBeforeClose
  25.600 ±0.0  77.800 ±0.6  203.9% 
ivb44/fsmark/1x-64t-9BRD_6G-RAID5-btrfs-4M-30G-fsyncBeforeClose
  32.000 ±0.0  93.800 ±1.7  193.1% 
ivb44/fsmark/1x-64t-4BRD_12G-RAID5-ext4-4M-30G-fsyncBeforeClose
  32.000 ±0.0  81.233 ±1.7  153.9% 
ivb44/fsmark/1x-64t-9BRD_6G-RAID5-ext4-4M-30G-fsyncBeforeClose
  48.800 ±14.5 99.667 ±2.0  104.2% 
ivb44/fsmark/1x-64t-4BRD_12G-RAID5-xfs-4M-30G-fsyncBeforeClose
   6.400 ±0.0  12.800 ±0.0  100.0% 
ivb44/fsmark/1x-64t-3HDD-RAID5-btrfs-4M-40G-fsyncBeforeClose
  63.133 ±8.2  82.800 ±0.7   31.2% 
ivb44/fsmark/1x-64t-9BRD_6G-RAID5-xfs-4M-30G-fsyncBeforeClose
 245.067 ±0.7 306.567 ±7.9   25.1% 
ivb44/fsmark/1x-64t-4BRD_12G-RAID5-f2fs-4M-30G-fsyncBeforeClose
  17.533 ±0.3  21.000 ±0.8   19.8% 
ivb44/fsmark/1x-1t-3HDD-RAID5-xfs-4M-40G-fsyncBeforeClose
 188.167 ±1.9 215.033 ±3.1   14.3% 
ivb44/fsmark/1x-1t-4BRD_12G-RAID5-btrfs-4M-30G-NoSync
 254.500 ±1.8 290.733 ±2.4   14.2% 
ivb44/fsmark/1x-1t-9BRD_6G-RAID5-btrfs-4M-30G-NoSync

`time.system_time'
=

next-20150317 this patch
--
metric_value ±stddev metric_value ±stddev change   
testbox/benchmark/testcase-params
-- 
--
7235.603 ±1.2 185.163 ±1.9  -97.4% 
ivb44/fsmark/1x-64t-4BRD_12G-RAID5-btrfs-4M-30G-fsyncBeforeClose
7666.883 ±2.9 202.750 ±1.0  -97.4% 
ivb44/fsmark/1x-64t-9BRD_6G-RAID5-btrfs-4M-30G-fsyncBeforeClose
   14567.893 ±0.7 421.230 ±0.4  -97.1% 
ivb44/fsmark/1x-64t-3HDD-RAID5-btrfs-4M-40G-fsyncBeforeClose
3697.667 ±14.0148.190 ±1.7  -96.0% 
ivb44/fsmark/1x-64t-4BRD_12G-RAID5-xfs-4M-30G-fsyncBeforeClose
5572.867 ±3.8 310.717 ±1.4  -94.4% 
ivb44/fsmark/1x-64t-9BRD_6G-RAID5-ext4-4M-30G-fsyncBeforeClose
5565.050 ±0.5 313.277 ±1.5  -94.4% 
ivb44/fsmark/1x-64t-4BRD_12G-RAID5-ext4-4M-30G-fsyncBeforeClose
2420.707 ±17.1171.043 ±2.7  -92.9% 
ivb44/fsmark/1x-64t-9BRD_6G-RAID5-xfs-4M-30G-fsyncBeforeClose
3743.300 ±4.6 379.827 ±3.5  -89.9% 
ivb44/fsmark/1x-64t-3HDD-RAID5-ext4-4M-40G-fsyncBeforeClose
3308.687 ±6.3 363.050 ±2.0  -89.0% 
ivb44/fsmark/1x-64t-3HDD-RAID5-xfs-4M-40G-fsyncBeforeClose

Where,

 1x: where 'x' means iterations or loop, corresponding to the 'L' option of 
fsmark

 1t, 64t: where 't' means thread

 4M: means the single file size, corresponding to the '-s' option of fsmark
 40G, 30G, 120G: means the total test size

 4BRD_12G: BRD is the ramdisk, where '4' means 4 ramdisk, and where '12G' 
means
   the size of one ramdisk. So, it would be 48G in total. And we 
made a
   raid on those ramdisk

As you can see, though there are no much performance gain for hard disk
workload, the system time is dropped 

Re: [PATCH] Bluetooth: Skip the shutdown routine if the interface is not up

2015-04-26 Thread Marcel Holtmann
Hi Gabriele,

> Most likely, the shutdown routine requires the interface to be up.
> This is the case for BTUSB_INTEL: the routine tries to send a command
> to the interface, but since this one is down, it fails and exits once
> HCI_INIT_TIMEOUT has expired.
> 
> Signed-off-by: Gabriele Mazzotta 
> ---
> net/bluetooth/hci_core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 476709b..4663c3d 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -1557,7 +1557,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
> {
>   BT_DBG("%s %p", hdev->name, hdev);
> 
> - if (!hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
> + if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
> + test_bit(HCI_UP, >flags)) {
>   /* Execute vendor specific shutdown routine */
>   if (hdev->shutdown)
>   hdev->shutdown(hdev);

this is a good catch.

Acked-by: Marcel Holtmann 
Cc: sta...@vger.kernel.org # 4.0.x

Dave, do you want to take this patch straight into your stable tree?

Regards

Marcel

--
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/


[PATCH 1/3] wait: introduce wait_event_cmd_exclusive

2015-04-26 Thread Yuanhan Liu
It's just a variant of wait_event_cmd, with exclusive flag being set.

For cases like RAID5, which puts many processes to sleep until 1/4
resources are free, a wake_up wakes up all processes to run, but
there is one process being able to get the resource as it's protected
by a spin lock. That ends up introducing heavy lock contentions, and
hurts performance badly.

Here introduce wait_event_cmd_exclusive to relieve the lock contention
naturally by letting wake_up() just wake up one process.

Cc: Ingo Molnar 
Cc: Peter Zijlstra 
Signed-off-by: Yuanhan Liu 
---
 include/linux/wait.h | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 2db8334..6c3b4de 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -358,10 +358,18 @@ do {  
\
__ret;  \
 })
 
-#define __wait_event_cmd(wq, condition, cmd1, cmd2)\
-   (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0,  \
+#define __wait_event_cmd(wq, condition, cmd1, cmd2, exclusive) \
+   (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, exclusive, 0, \
cmd1; schedule(); cmd2)
 
+
+#define wait_event_cmd_exclusive(wq, condition, cmd1, cmd2)
\
+do {   \
+   if (condition)  \
+   break;  \
+   __wait_event_cmd(wq, condition, cmd1, cmd2, 1); \
+} while (0)
+
 /**
  * wait_event_cmd - sleep until a condition gets true
  * @wq: the waitqueue to wait on
@@ -380,7 +388,7 @@ do {
\
 do {   \
if (condition)  \
break;  \
-   __wait_event_cmd(wq, condition, cmd1, cmd2);\
+   __wait_event_cmd(wq, condition, cmd1, cmd2, 0); \
 } while (0)
 
 #define __wait_event_interruptible(wq, condition)  \
-- 
1.9.0

--
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/


[PATCH 2/3 v2] md/raid5: split wait_for_stripe and introduce wait_for_quiescent

2015-04-26 Thread Yuanhan Liu
I noticed heavy spin lock contention at get_active_stripe(), introduced
at being wake up stage, where a bunch of processes try to re-hold the
spin lock again.

After giving some thoughts on this issue, I found the lock could be
relieved(and even avoided) if we turn the wait_for_stripe to per
waitqueue for each lock hash and make the wake up exclusive: wake up
one process each time, which avoids the lock contention naturally.

Before go hacking with wait_for_stripe, I found it actually has 2
usages: for the array to enter or leave the quiescent state, and also
to wait for an available stripe in each of the hash lists.

So this patch splits the first usage off into a separate wait_queue,
wait_for_quiescent, and the next patch will turn the second usage into
one waitqueue for each hash value, and make it exclusive, to relieve
the lock contention.

v2: wake_up(wait_for_quiescent) when (active_stripes == 0)
Commit log refactor suggestion from Neil.

Signed-off-by: Yuanhan Liu 
---
 drivers/md/raid5.c | 15 +--
 drivers/md/raid5.h |  1 +
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 77dfd72..64d5bea 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -374,6 +374,8 @@ static void release_inactive_stripe_list(struct r5conf 
*conf,
 
if (do_wakeup) {
wake_up(>wait_for_stripe);
+   if (atomic_read(>active_stripes) == 0)
+   wake_up(>wait_for_quiescent);
if (conf->retry_read_aligned)
md_wakeup_thread(conf->mddev->thread);
}
@@ -667,7 +669,7 @@ get_active_stripe(struct r5conf *conf, sector_t sector,
spin_lock_irq(conf->hash_locks + hash);
 
do {
-   wait_event_lock_irq(conf->wait_for_stripe,
+   wait_event_lock_irq(conf->wait_for_quiescent,
conf->quiesce == 0 || noquiesce,
*(conf->hash_locks + hash));
sh = __find_stripe(conf, sector, conf->generation - previous);
@@ -4729,7 +4731,7 @@ static void raid5_align_endio(struct bio *bi, int error)
 raid_bi, 0);
bio_endio(raid_bi, 0);
if (atomic_dec_and_test(>active_aligned_reads))
-   wake_up(>wait_for_stripe);
+   wake_up(>wait_for_quiescent);
return;
}
 
@@ -4824,7 +4826,7 @@ static int chunk_aligned_read(struct mddev *mddev, struct 
bio * raid_bio)
align_bi->bi_iter.bi_sector += rdev->data_offset;
 
spin_lock_irq(>device_lock);
-   wait_event_lock_irq(conf->wait_for_stripe,
+   wait_event_lock_irq(conf->wait_for_quiescent,
conf->quiesce == 0,
conf->device_lock);
atomic_inc(>active_aligned_reads);
@@ -5668,7 +5670,7 @@ static int  retry_aligned_read(struct r5conf *conf, 
struct bio *raid_bio)
bio_endio(raid_bio, 0);
}
if (atomic_dec_and_test(>active_aligned_reads))
-   wake_up(>wait_for_stripe);
+   wake_up(>wait_for_quiescent);
return handled;
 }
 
@@ -6399,6 +6401,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
goto abort;
spin_lock_init(>device_lock);
seqcount_init(>gen_lock);
+   init_waitqueue_head(>wait_for_quiescent);
init_waitqueue_head(>wait_for_stripe);
init_waitqueue_head(>wait_for_overlap);
INIT_LIST_HEAD(>handle_list);
@@ -7422,7 +7425,7 @@ static void raid5_quiesce(struct mddev *mddev, int state)
 * active stripes can drain
 */
conf->quiesce = 2;
-   wait_event_cmd(conf->wait_for_stripe,
+   wait_event_cmd(conf->wait_for_quiescent,
atomic_read(>active_stripes) == 0 &&
atomic_read(>active_aligned_reads) == 
0,
unlock_all_device_hash_locks_irq(conf),
@@ -7436,7 +7439,7 @@ static void raid5_quiesce(struct mddev *mddev, int state)
case 0: /* re-enable writes */
lock_all_device_hash_locks_irq(conf);
conf->quiesce = 0;
-   wake_up(>wait_for_stripe);
+   wake_up(>wait_for_quiescent);
wake_up(>wait_for_overlap);
unlock_all_device_hash_locks_irq(conf);
break;
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index 7dc0dd8..4cc05ec 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -508,6 +508,7 @@ struct r5conf {
struct list_headinactive_list[NR_STRIPE_HASH_LOCKS];
atomic_tempty_inactive_list_nr;
struct llist_head   released_stripes;
+   wait_queue_head_t   wait_for_quiescent;

Re: [PATCH 3.10 06/31] tcp: tcp_make_synack() should clear skb->tstamp

2015-04-26 Thread David Miller
From: Willy Tarreau 
Date: Mon, 27 Apr 2015 06:02:22 +0200

> Hi Greg,
> 
> On Sun, Apr 26, 2015 at 03:46:26PM +0200, Greg Kroah-Hartman wrote:
>> 3.10-stable review patch.  If anyone has any objections, please let me know.
>> 
>> --
>> 
>> From: Eric Dumazet 
>> 
>> [ Upstream commit b50edd7812852d989f2ef09dcfc729690f54a42d ]
>> 
>> I noticed tcpdump was giving funky timestamps for locally
>> generated SYNACK messages on loopback interface.
>> 
>> 11:42:46.938990 IP 127.0.0.1.48245 > 127.0.0.2.23850: S
>> 945476042:945476042(0) win 43690 
>> 
>> 20:28:58.502209 IP 127.0.0.2.23850 > 127.0.0.1.48245: S
>> 3160535375:3160535375(0) ack 945476043 win 43690 > 65495,nop,nop,sackOK,nop,wscale 7>
>> 
>> This is because we need to clear skb->tstamp before
>> entering lower stack, otherwise net_timestamp_check()
>> does not set skb->tstamp.
>> 
>> Fixes: 7faee5c0d514 ("tcp: remove TCP_SKB_CB(skb)->when")
>> Signed-off-by: Eric Dumazet 
>> Signed-off-by: David S. Miller 
>> Signed-off-by: Greg Kroah-Hartman 
>> ---
> 
> Unless I missed something, the commit this patch fixes was not
> backported to 3.10 so I think we don't need this one. I have no
> idea whether it can have a side effect there though, Eric will
> probably know better.

Eric Dumazet mentioned this and said it's harmless.
--
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 1/1 linux-next] cpufreq: pxa: replace typedef pxa_freqs_t by structure

2015-04-26 Thread Viresh Kumar
On 25 April 2015 at 14:15, Fabian Frederick  wrote:
> See Documentation/CodingStyle.

Wow :)

> Signed-off-by: Fabian Frederick 
> ---
>  drivers/cpufreq/pxa2xx-cpufreq.c | 20 ++--
>  1 file changed, 10 insertions(+), 10 deletions(-)

Acked-by: Viresh Kumar 
--
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 2/2] cpufreq: powernv: Register for OCC related opal_message notification

2015-04-26 Thread Viresh Kumar
On 22 April 2015 at 22:34, Shilpasri G Bhat
 wrote:
> diff --git a/drivers/cpufreq/powernv-cpufreq.c 
> b/drivers/cpufreq/powernv-cpufreq.c

> +static char throttle_reason[6][50] = { "No throttling",

Don't need to mention 6 here.

And the max length you need right now is 27, so maybe s/50/30 ?

Also, start 'No Throttling' in a new line, like below.

> +   "Power Cap",
> +   "Processor Over Temperature",
> +   "Power Supply Failure",
> +   "OverCurrent",

s/OverCurrent/Over Current/ ?

> +   "OCC Reset"
> +};
> +
> +static int powernv_cpufreq_occ_msg(struct notifier_block *nb,
> +   unsigned long msg_type, void *msg)
> +{
> +   struct opal_msg *occ_msg = msg;
> +   uint64_t token;
> +   uint64_t chip_id, reason;
> +
> +   if (msg_type != OPAL_MSG_OCC)
> +   return 0;

Blank line here.

> +   token = be64_to_cpu(occ_msg->params[0]);

Here as well..

> +   switch (token) {
> +   case 0:
> +   occ_reset = true;
> +   /*
> +* powernv_cpufreq_throttle_check() is called in
> +* target() callback which can detect the throttle state
> +* for governors like ondemand.
> +* But static governors will not call target() often thus
> +* report throttling here.
> +*/

Now, do I understand correctly that this notifier will be called as
soon as we switch throttling state ?

If yes, then do we still need the throttle_check() routine you added
earlier ? Maybe not.

> +   if (!throttled) {
> +   throttled = true;
> +   pr_crit("CPU Frequency is throttled\n");
> +   }
> +   pr_info("OCC in Reset\n");
> +   break;
> +   case 1:
> +   pr_info("OCC is Loaded\n");
> +   break;
> +   case 2:
> +   chip_id = be64_to_cpu(occ_msg->params[1]);
> +   reason = be64_to_cpu(occ_msg->params[2]);

Blank line here.

> +   if (occ_reset) {
> +   occ_reset = false;
> +   throttled = false;
> +   pr_info("OCC is Active\n");
> +   /* Sanity check for static governors */
> +   powernv_cpufreq_throttle_check(smp_processor_id());
> +   } else if (reason) {
> +   throttled = true;
> +   pr_info("Pmax reduced due to %s on chip %x\n",
> +   throttle_reason[reason], 
> (int)chip_id);
> +   } else {
> +   throttled = false;
> +   pr_info("%s on chip %x\n",
> +   throttle_reason[reason], 
> (int)chip_id);
> +   }

Run checkpatch with --strict option, and you will see some warnings.

> +   break;
> +   }
> +   return 0;
> +}
> +
> +static struct notifier_block powernv_cpufreq_opal_nb = {
> +   .notifier_call  = powernv_cpufreq_occ_msg,
> +   .next   = NULL,
> +   .priority   = 0,
> +};
> +
>  static void powernv_cpufreq_stop_cpu(struct cpufreq_policy *policy)
>  {
> struct powernv_smp_call_data freq_data;
> @@ -430,6 +497,7 @@ static int __init powernv_cpufreq_init(void)
> }
>
> register_reboot_notifier(_cpufreq_reboot_nb);
> +   opal_message_notifier_register(OPAL_MSG_OCC, 
> _cpufreq_opal_nb);
> return cpufreq_register_driver(_cpufreq_driver);
>  }
>  module_init(powernv_cpufreq_init);
> --
> 1.9.3
>
--
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 1/1] Documentation: Add dt-binding for TI-btwilink driver

2015-04-26 Thread Marcel Holtmann
Hi Gigi,

> btwilink binds bluetooth hci0 interface with the shared transport driver
> 
> Signed-off-by: Gigi Joseph 
> ---
> Documentation/devicetree/bindings/btwilink.txt | 15 +++
> 1 file changed, 15 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/btwilink.txt
> 
> diff --git a/Documentation/devicetree/bindings/btwilink.txt 
> b/Documentation/devicetree/bindings/btwilink.txt
> new file mode 100644
> index 000..d286aea
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/btwilink.txt
> @@ -0,0 +1,15 @@
> +btwilink
> +
> +
> +Required properties:
> +
> + - compatible : must be "ti,btwilink"
> +
> +Example:
> +
> +Enable the btwilink driver to bind the bluetooth hci0 interface with
> +ti-st shared transport driver
> +
> +btwilink {
> + compatible = "ti,btwilink";
> +};

actually I wonder if someone finally starts re-writing the TI-ST driver to 
integrate with the new Bluetooth subsystem features (like hdev->setup, 
__hci_cmd_sync and h4_recv_buf) so that this complicated setup is no longer 
needed.

I do not think we actually would need a shared transport at all. We should have 
a Bluetooth HCI driver that can have children for FM radio and GPS exposed. 
Exposing proper platform devices with Bluetooth HCI as parent makes sense. The 
shared transport is not really a parent. First and foremost, this is a 
Bluetooth chip. The FM radio and GPS features are just glued on top of it.

Regards

Marcel

--
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 3.10 06/31] tcp: tcp_make_synack() should clear skb->tstamp

2015-04-26 Thread Eric Dumazet
Right.

Bug was introduced in 3.18,  the Fixes: tag tells us ;)

git describe --contains 7faee5c0d514
v3.18-rc1~52^2~148^2

Note that it does not hurt having this backport to prior kernel versions.

Field is already 0 after skb allocation/cloning.



On Sun, Apr 26, 2015 at 9:02 PM, Willy Tarreau  wrote:
> Hi Greg,
>
> On Sun, Apr 26, 2015 at 03:46:26PM +0200, Greg Kroah-Hartman wrote:
>> 3.10-stable review patch.  If anyone has any objections, please let me know.
>>
>> --
>>
>> From: Eric Dumazet 
>>
>> [ Upstream commit b50edd7812852d989f2ef09dcfc729690f54a42d ]
>>
>> I noticed tcpdump was giving funky timestamps for locally
>> generated SYNACK messages on loopback interface.
>>
>> 11:42:46.938990 IP 127.0.0.1.48245 > 127.0.0.2.23850: S
>> 945476042:945476042(0) win 43690 
>>
>> 20:28:58.502209 IP 127.0.0.2.23850 > 127.0.0.1.48245: S
>> 3160535375:3160535375(0) ack 945476043 win 43690 > 65495,nop,nop,sackOK,nop,wscale 7>
>>
>> This is because we need to clear skb->tstamp before
>> entering lower stack, otherwise net_timestamp_check()
>> does not set skb->tstamp.
>>
>> Fixes: 7faee5c0d514 ("tcp: remove TCP_SKB_CB(skb)->when")
>> Signed-off-by: Eric Dumazet 
>> Signed-off-by: David S. Miller 
>> Signed-off-by: Greg Kroah-Hartman 
>> ---
>
> Unless I missed something, the commit this patch fixes was not
> backported to 3.10 so I think we don't need this one. I have no
> idea whether it can have a side effect there though, Eric will
> probably know better.
>
> Thanks,
> Willy
>
--
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/


[PATCH -stable] block: destroy bdi before blockdev is unregistered.

2015-04-26 Thread NeilBrown

Because of the peculiar way that md devices are created (automatically
when the device node is opened), a new device can be created and
registered immediately after the
blk_unregister_region(disk_devt(disk), disk->minors);
call in del_gendisk().

Therefore it is important that all visible artifacts of the previous
device are removed before this call.  In particular, the 'bdi'.

Since:
commit c4db59d31e39ea067c32163ac961e9c80198fd37
Author: Christoph Hellwig 
fs: don't reassign dirty inodes to default_backing_dev_info

moved the
   device_unregister(bdi->dev);
call from bdi_unregister() to bdi_destroy() it has been quite easy to
lose a race and have a new (e.g.) "md127" be created after the
blk_unregister_region() call and before bdi_destroy() is ultimately
called by the final 'put_disk', which must come after del_gendisk().

The new device finds that the bdi name is already registered in sysfs
and complains

> [ 9627.630029] WARNING: CPU: 18 PID: 3330 at fs/sysfs/dir.c:31 
> sysfs_warn_dup+0x5a/0x70()
> [ 9627.630032] sysfs: cannot create duplicate filename 
> '/devices/virtual/bdi/9:127'

We can fix this by moving the bdi_destroy() call out of
blk_release_queue() (which can happen very late when a refcount
reaches zero) and into blk_cleanup_queue() - which happens exactly when the md
device driver calls it.

Then it is only necessary for md to call blk_cleanup_queue() before
del_gendisk().  As loop.c devices are also created on demand by
opening the device node, we make the same change there.

Fixes: c4db59d31e39ea067c32163ac961e9c80198fd37
Reported-by: Azat Khuzhin 
Cc: Christoph Hellwig 
Cc: sta...@vger.kernel.org (v4.0)
Signed-off-by: NeilBrown 

--
Hi Jens,
 if you could check this and forward on to Linus I'd really appreciate it.

Thanks,
NeilBrown


diff --git a/block/blk-core.c b/block/blk-core.c
index fd154b94447a..7871603f0a29 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -552,6 +552,8 @@ void blk_cleanup_queue(struct request_queue *q)
q->queue_lock = >__queue_lock;
spin_unlock_irq(lock);
 
+   bdi_destroy(>backing_dev_info);
+
/* @q is and will stay empty, shutdown and put */
blk_put_queue(q);
 }
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index faaf36ade7eb..2b8fd302f677 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -522,8 +522,6 @@ static void blk_release_queue(struct kobject *kobj)
 
blk_trace_shutdown(q);
 
-   bdi_destroy(>backing_dev_info);
-
ida_simple_remove(_queue_ida, q->id);
call_rcu(>rcu_head, blk_free_queue_rcu);
 }
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ae3fcb4199e9..d7173cb1ea76 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1620,8 +1620,8 @@ out:
 
 static void loop_remove(struct loop_device *lo)
 {
-   del_gendisk(lo->lo_disk);
blk_cleanup_queue(lo->lo_queue);
+   del_gendisk(lo->lo_disk);
blk_mq_free_tag_set(>tag_set);
put_disk(lo->lo_disk);
kfree(lo);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d4f31e195e26..593a02476c78 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4818,12 +4818,12 @@ static void md_free(struct kobject *ko)
if (mddev->sysfs_state)
sysfs_put(mddev->sysfs_state);
 
+   if (mddev->queue)
+   blk_cleanup_queue(mddev->queue);
if (mddev->gendisk) {
del_gendisk(mddev->gendisk);
put_disk(mddev->gendisk);
}
-   if (mddev->queue)
-   blk_cleanup_queue(mddev->queue);
 
kfree(mddev);
 }


pgps91FEHzQDw.pgp
Description: OpenPGP digital signature


Re: [PATCH v10 00/29] Refine PCI scan interfaces and make generic pci host bridge

2015-04-26 Thread Daniel Axtens
Hi Yijing,

I'm wondering if you might get some more momentum on these changes if
we could split them into a few smaller patch sets. I think we might
then be able to start getting bits of this in for 4.2, which should help
with getting the rest of it in.

I think there are a few things that would be easy to pull out.

  * #1 (xen/PCI: Don't use deprecated function
 pci_scan_bus_parented()) can go directly to Xen people and should
 be easy to merge. #2 (PCI: Remove deprecated
 pci_scan_bus_parented()) is then an easy fixup.

  * I think #12 (powerpc/PCI: Rename pcibios_root_bridge_prepare() to
pcibios_set_root_bus_speed()) could go to the PowerPC folks
individually. I'm not sure, however, that it's worth renaming it
and creating another function and another hook when no other arch
uses it. If mpe and benh don't want to pick it up, it'd be pretty
easy to take out set_root_bus_speed from the host_bridge_ops
struct, and this way we can still advance other parts of the
series.

  * #16 (PCI: Introduce pci_bus_child_max_busnr()) is self-contained
 and already has a user, so that should go in easily.

  * The domain/bus numbering cleanup stuff could be broken out:
#3  (PCI: Save domain in pci_host_bridge)
#4  (PCI: Move pci_bus_assign_domain_nr() declaration into
drivers/pci/pci.h)
#8  (PCI: Introduce pci_host_assign_domain_nr() to assign domain),
#28 (PCI: Remove platform specific pci_domain_nr())
#29 (PCI: Remove pci_bus_assign_domain_nr())



I've done a bunch of rebasing and compiles to try to make sure all of
these proposed divisions work and there are no dependencies that I've
missed. It it's helpful, you can see what I've done at
https://github.com/daxtens/linux in the YijingWang-enumer10
branch. Feel free to use it as you wish.

I think the remaining 20 patches could probably be split again at least
once - it looks like the bus/bus numbering stuff might be easy to split
out? I might have a look again in a few days.

Regards,
Daniel

My final set of series, using your original patch names:

Set 1 (Xen cleanup):
  xen/PCI: Don't use deprecated function pci_scan_bus_parented()
  PCI: Remove deprecated pci_scan_bus_parented()

Set 2 (PowerPC cleanup):
  powerpc/PCI: Rename pcibios_root_bridge_prepare() to
pcibios_set_root_bus_speed()

Set 3: (could possibly be merged with set 4)
  PCI: Introduce pci_bus_child_max_busnr()

Set 4: (_nr and friends)
  PCI: Save domain in pci_host_bridge
  PCI: Move pci_bus_assign_domain_nr() declaration into
   drivers/pci/pci.h
  PCI: Introduce pci_host_assign_domain_nr() to assign domain
  PCI: Remove platform specific pci_domain_nr()
  PCI: Remove pci_bus_assign_domain_nr()

Remainder:
  PCI: Remove argument bus for pci_create_root_bus()
  PCI: Alloc busn resource dynamically for pci_scan_bus()
  PCI: Allocate busn resource for pci_scan_root_bus()
  PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
  PCI: Introduce pci_host_bridge_list to manage host bridges
  PCI: Save sysdata in pci_host_bridge drvdata  
  PCI: Move pcibios_root_bridge_prepare() to pci_create_host_bridge()
  PCI: Introduce pci_host_bridge_ops to support host specific
operations
  PCI: Introduce new scan function pci_scan_host_bridge()
  x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
  powerpc/pci: Use pci_scan_host_bridge() for simplicity
  PCI: Remove pcibios_root_bridge_prepare() and
pcibos_set_root_bus_speed()
  sparc/PCI: Use pci_scan_host_bridge() for simplicity
  parisc/PCI: Use pci_scan_root_bus() for simplicity
  PCI/mvebu: Use pci_common_init_dev() to simplify code
  PCI/tegra: Remove redundant tegra_pcie_scan_bus()
  PCI/designware: Use pci_scan_root_bus() for simplicity
  PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
  PCI: Rename __pci_create_root_bus() to pci_create_root_bus()

On Tue, 2015-04-21 at 19:34 +0800, Yijing Wang wrote:
> This series could be pulled from:
> https://github.com/YijingWang/linux-pci.git enumer10
> 
> v9->v10:
>   Dynamically allocate busn resource if callers don't supply.
>   Try to adjust busn resource if host bridge busn resource conlict.
>   Rebase whole series on Bjorn's latest pci-next branch.
>   Major v9->v10 changes are in patch 5,6,7,10.
> v8->v9:
>   Add Thierry's Acked-by and Tested-by.
>   Fix the building error for powerpc found by Daniel.
>   Change pci_host_assign_domain_nr() to static.
> v7->v8:
>   Fix some cross building errors found by kbuild test.
>   Drop the rename patch for find_pci_host_bridge().
> v6->v7:
>   Drop previous patch which combined the domain and bus in one argument.
>   Make the pci_host_bridge hold the default busn resource, so we could
>   check whether new host busn resource is conflict with existing ones.
>   Move pci_host_assign_domain_nr() to drivers/pci/host-bridge.c
>  

Re: [PATCH 3.10 06/31] tcp: tcp_make_synack() should clear skb->tstamp

2015-04-26 Thread Willy Tarreau
Hi Greg,

On Sun, Apr 26, 2015 at 03:46:26PM +0200, Greg Kroah-Hartman wrote:
> 3.10-stable review patch.  If anyone has any objections, please let me know.
> 
> --
> 
> From: Eric Dumazet 
> 
> [ Upstream commit b50edd7812852d989f2ef09dcfc729690f54a42d ]
> 
> I noticed tcpdump was giving funky timestamps for locally
> generated SYNACK messages on loopback interface.
> 
> 11:42:46.938990 IP 127.0.0.1.48245 > 127.0.0.2.23850: S
> 945476042:945476042(0) win 43690 
> 
> 20:28:58.502209 IP 127.0.0.2.23850 > 127.0.0.1.48245: S
> 3160535375:3160535375(0) ack 945476043 win 43690  65495,nop,nop,sackOK,nop,wscale 7>
> 
> This is because we need to clear skb->tstamp before
> entering lower stack, otherwise net_timestamp_check()
> does not set skb->tstamp.
> 
> Fixes: 7faee5c0d514 ("tcp: remove TCP_SKB_CB(skb)->when")
> Signed-off-by: Eric Dumazet 
> Signed-off-by: David S. Miller 
> Signed-off-by: Greg Kroah-Hartman 
> ---

Unless I missed something, the commit this patch fixes was not
backported to 3.10 so I think we don't need this one. I have no
idea whether it can have a side effect there though, Eric will
probably know better.

Thanks,
Willy

--
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] dmaengine: dw: add Intel Broxton LPSS Integrated DMA support

2015-04-26 Thread Vinod Koul
On Tue, Apr 21, 2015 at 05:41:50AM +, Zha, Qipeng wrote:
> + dma maillist
Pls CC maintainer, or your patch will be missed!!

> 
> 
> 
> 
> Best wishes
> Qipeng
> 
> -Original Message-
> From: Zha, Qipeng 
> Sent: Tuesday, April 21, 2015 7:34 AM
> To: linux-kernel@vger.kernel.org
> Cc: viresh.li...@gmail.com; andriy.shevche...@linux.intel.com; Westerberg, 
> Mika; Chen, Jason CJ; Zheng, Qi; Zha, Qipeng; Zhong, Huiquan
> Subject: [PATCH] dmaengine: dw: add Intel Broxton LPSS Integrated DMA support
> 
> From: Huiquan Zhong 
> 
> Add Broxton Lower Power Sub System Integrated DMA support, Since the DMA 
> register space is very similar to DesignWare DMA register space.
> 
> Add DW_DMAC_TYPE_IDMA type to distinguish LPSS iDMA register.
> 
> Broxton LPSS iDMA's maximum block size is 0x1(128KB -1).
Looking at the patch aprt from DW_DMAC_TYPE_IDMA changes, rest are not
documented why, perhpas you cna split to multiple changes explainig what and
why. Then this is supporting BXT but I dont see any update to device table?

> 
> Signed-off-by: Huiquan Zhong 
> Signed-off-by: qipeng.zha 
> ---
>  drivers/dma/dw/core.c| 64 
> +---
>  drivers/dma/dw/internal.h|  3 --
>  drivers/dma/dw/regs.h| 14 
>  include/linux/dma/dw.h   |  8 +
>  include/linux/platform_data/dma-dw.h |  2 +-
>  5 files changed, 75 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c index 
> a8ad052..1d198c9 100644
> --- a/drivers/dma/dw/core.c
> +++ b/drivers/dma/dw/core.c
> @@ -144,8 +144,19 @@ static void dwc_initialize(struct dw_dma_chan *dwc)
>*/
>   BUG_ON(!dws->dma_dev || dws->dma_dev != dw->dma.dev);
>  
> - cfghi |= DWC_CFGH_DST_PER(dws->dst_id);
> - cfghi |= DWC_CFGH_SRC_PER(dws->src_id);
> + if (dw->type == DW_DMAC_TYPE_IDMA) {
> + /* Forces channel FIFO to drain while in suspension */
> + cfglo = IDMA_CFGL_CH_DRAIN;
> + /* Burst length aligned */
> + cfglo |= IDMA_CFGL_SRC_BURST_ALIGN
> + | IDMA_CFGL_DST_BURST_ALIGN;
> +
> + cfghi |= IDMA_CFGH_DST_PER(dws->dst_id);
> + cfghi |= IDMA_CFGH_SRC_PER(dws->src_id);
> + } else {
> + cfghi |= DWC_CFGH_DST_PER(dws->dst_id);
> + cfghi |= DWC_CFGH_SRC_PER(dws->src_id);
> + }
>   } else {
>   cfghi |= DWC_CFGH_DST_PER(dwc->dst_id);
>   cfghi |= DWC_CFGH_SRC_PER(dwc->src_id); @@ -346,9 +357,14 @@ 
> static void dwc_complete_all(struct dw_dma *dw, struct dw_dma_chan *dwc)
>  /* Returns how many bytes were already received from source */  static 
> inline u32 dwc_get_sent(struct dw_dma_chan *dwc)  {
> + struct dw_dma *dw = to_dw_dma(dwc->chan.device);
> +
>   u32 ctlhi = channel_readl(dwc, CTL_HI);
>   u32 ctllo = channel_readl(dwc, CTL_LO);
>  
> + if (dw->type == DW_DMAC_TYPE_IDMA)
> + return ctlhi & IDMA_CTLH_BLOCK_TS_MASK;
> +
>   return (ctlhi & DWC_CTLH_BLOCK_TS_MASK) * (1 << (ctllo >> 4 & 7));  }
>  
> @@ -775,6 +791,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct 
> scatterlist *sgl,
>   unsigned intreg_width;
>   unsigned intmem_width;
>   unsigned intdata_width;
> + unsigned intwidth_trf;
>   unsigned inti;
>   struct scatterlist  *sg;
>   size_t  total_len = 0;
> @@ -823,8 +840,14 @@ slave_sg_todev_fill_desc:
>   desc->lli.sar = mem;
>   desc->lli.dar = reg;
>   desc->lli.ctllo = ctllo | DWC_CTLL_SRC_WIDTH(mem_width);
> - if ((len >> mem_width) > dwc->block_size) {
> - dlen = dwc->block_size << mem_width;
> +
> + if (dw->type == DW_DMAC_TYPE_IDMA)
> + width_trf = 0;
why should this be zero?

> + else
> + width_trf = mem_width;
> +
> + if ((len >> width_trf) > dwc->block_size) {
> + dlen = dwc->block_size << width_trf;
>   mem += dlen;
>   len -= dlen;
>   } else {
> @@ -832,7 +855,7 @@ slave_sg_todev_fill_desc:
>   len = 0;
>   }
>  
> - desc->lli.ctlhi = dlen >> mem_width;
> + desc->lli.ctlhi = dlen >> width_trf;
>   desc->len = dlen;
>  
>   if (!first) {
> @@ -883,15 +906,20 @@ slave_sg_fromdev_fill_desc:
>   desc->lli.sar = reg;
>   desc->lli.dar = mem;
>   desc->lli.ctllo = ctllo | 

Re: [PATCH 00/23] gpio: sysfs: fixes and clean ups

2015-04-26 Thread Alexandre Courbot
On Wed, Apr 22, 2015 at 12:42 AM, Johan Hovold  wrote:
> These patches fix a number of issues with the gpio sysfs interface,
> including
>
>  - fix memory leaks and crashes on device hotplug
>  - straighten out the convoluted locking
>  - reduce sysfs-interface latencies through more fine-grained locking
>  - more clearly separate the sysfs-interface implementation from gpiolib
>core
>
> The first patch is marked for stable and could go into 4.1.
>
> Unfortunately we can't just kill the gpio sysfs interface, but these
> patches will make it more manageable and should allow us to implement a
> new user-space interface while maintaining the old one (for a while at
> least) without losing our sanity.
>
> Note that there is still a race between chip remove and gpiod_request (and
> therefore sysfs export), which needs to be fixed separately (for instance as
> part of a generic solution to chip hotplugging).

Thanks a lot for this great series. To my embarrassment I could not
find anything big to say about it. It simply fixes some of the biggest
issues with the sysfs interface and makes things much more
maintainable.

I made a few minor comments, but globally I like this very much.

Reviewed-by: Alexandre Courbot 
--
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 07/23] gpio: sysfs: rename gpiochip registration functions

2015-04-26 Thread Alexandre Courbot
On Wed, Apr 22, 2015 at 12:42 AM, Johan Hovold  wrote:
> Rename the gpio-chip export/unexport functions to the more descriptive
> names gpiochip_register and gpiochip_unregister.

Since these functions are related to sysfs, wouldn't
gpiochip_sysfs_export (or gpiochip_sysfs_register, although the former
sounds better to me) be even more descriptive?

The renaming should probably also cover the non-static gpiod_*
functions of gpiolib-sysfs.c which are equally ambiguous. Basically
anything non-static from gpiolib-sysfs.c should have that prefix.
--
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 06/23] gpio: sysfs: clean up chip class-device handling

2015-04-26 Thread Alexandre Courbot
On Wed, Apr 22, 2015 at 12:42 AM, Johan Hovold  wrote:
> Clean gpio-chip class device registration and deregistration.
>
> The class device is registered when a gpio-chip is added (or from
> gpiolib_sysfs_init post-core init call), and deregistered when the chip
> is removed.
>
> Store the class device in struct gpio_chip directly rather than do a
> class-device lookup on deregistration. This also removes the need for
> the exported flag.
>
> Signed-off-by: Johan Hovold 
> ---
>  drivers/gpio/gpiolib-sysfs.c | 39 +--
>  include/linux/gpio/driver.h  |  4 ++--
>  2 files changed, 15 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
> index c433f075f349..2f8bdce792f6 100644
> --- a/drivers/gpio/gpiolib-sysfs.c
> +++ b/drivers/gpio/gpiolib-sysfs.c
> @@ -567,7 +567,7 @@ int gpiod_export(struct gpio_desc *desc, bool 
> direction_may_change)
> mutex_lock(_lock);
>
> /* check if chip is being removed */
> -   if (!chip || !chip->exported) {
> +   if (!chip || !chip->cdev) {
> status = -ENODEV;
> goto fail_unlock;
> }
> @@ -752,7 +752,6 @@ EXPORT_SYMBOL_GPL(gpiod_unexport);
>
>  int gpiochip_export(struct gpio_chip *chip)
>  {
> -   int status;
> struct device   *dev;
>
> /* Many systems register gpio chips for SOC support very early,
> @@ -768,41 +767,29 @@ int gpiochip_export(struct gpio_chip *chip)
> chip, gpiochip_groups,
> "gpiochip%d", chip->base);
> if (IS_ERR(dev))
> -   status = PTR_ERR(dev);
> -   else
> -   status = 0;
> +   return PTR_ERR(dev);
>
> mutex_lock(_lock);
> -   chip->exported = (status == 0);
> +   chip->cdev = dev;
> mutex_unlock(_lock);
>
> -   if (status)
> -   chip_dbg(chip, "%s: status %d\n", __func__, status);
> -
> -   return status;
> +   return 0;
>  }
>
>  void gpiochip_unexport(struct gpio_chip *chip)
>  {
> -   int status;
> -   struct device   *dev;
> struct gpio_desc *desc;
> unsigned int i;
>
> -   dev = class_find_device(_class, NULL, chip, match_export);
> -   if (dev) {
> -   put_device(dev);
> -   device_unregister(dev);
> -   /* prevent further gpiod exports */
> -   mutex_lock(_lock);
> -   chip->exported = false;
> -   mutex_unlock(_lock);
> -   status = 0;
> -   } else
> -   status = -ENODEV;
> +   if (!chip->cdev)
> +   return;
>
> -   if (status)
> -   chip_dbg(chip, "%s: status %d\n", __func__, status);
> +   device_unregister(chip->cdev);
> +
> +   /* prevent further gpiod exports */
> +   mutex_lock(_lock);
> +   chip->cdev = NULL;
> +   mutex_unlock(_lock);
>
> /* unregister gpiod class devices owned by sysfs */
> for (i = 0; i < chip->ngpio; i++) {
> @@ -830,7 +817,7 @@ static int __init gpiolib_sysfs_init(void)
>  */
> spin_lock_irqsave(_lock, flags);
> list_for_each_entry(chip, _chips, list) {
> -   if (chip->exported)
> +   if (chip->cdev)
> continue;
>
> /*
> diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
> index f1b36593ec9f..8c26855fc6ec 100644
> --- a/include/linux/gpio/driver.h
> +++ b/include/linux/gpio/driver.h
> @@ -20,6 +20,7 @@ struct seq_file;
>   * struct gpio_chip - abstract a GPIO controller
>   * @label: for diagnostics
>   * @dev: optional device providing the GPIOs
> + * @cdev: class device (may be NULL)

Maybe a comment explaining that this field is non-NULL when a chip is
exported would be useful to understand how it is used in the code?
--
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 08/23] gpio: remove gpiod_sysfs_set_active_low

2015-04-26 Thread Alexandre Courbot
On Wed, Apr 22, 2015 at 12:42 AM, Johan Hovold  wrote:
> Remove gpiod_sysfs_set_active_low (and gpio_sysfs_set_active_low) which
> allowed code to change the polarity of a gpio line even after it had
> been exported through sysfs.
>
> Drivers should not care, and generally does not know, about gpio-line
> polarity which is a hardware feature that needs to be described by
> firmware.
>
> It is currently possible to define gpio-line polarity in device-tree and
> acpi firmware or using platform data. Userspace can also change the
> polarity through sysfs.
>
> Note that drivers using the legacy gpio interface could still use
> GPIOF_ACTIVE_LOW to change the polarity before exporting the gpio.
>
> There are no in-kernel users of this interface.
>
> Cc: Jonathan Corbet 
> Cc: Harry Wei 
> Cc: Arnd Bergmann 
> Cc: linux-...@vger.kernel.org
> Cc: linux-ker...@zh-kernel.org
> Cc: linux-a...@vger.kernel.org
> Signed-off-by: Johan Hovold 
> ---
>  Documentation/gpio/gpio-legacy.txt |  9 ---
>  Documentation/gpio/sysfs.txt   |  8 ---
>  Documentation/zh_CN/gpio.txt   |  8 ---
>  drivers/gpio/gpiolib-sysfs.c   | 48 
> ++
>  include/asm-generic/gpio.h |  5 
>  include/linux/gpio.h   |  7 --
>  include/linux/gpio/consumer.h  |  6 -
>  7 files changed, 2 insertions(+), 89 deletions(-)
>
> diff --git a/Documentation/gpio/gpio-legacy.txt 
> b/Documentation/gpio/gpio-legacy.txt
> index 6f83fa965b4b..79ab5648d69b 100644
> --- a/Documentation/gpio/gpio-legacy.txt
> +++ b/Documentation/gpio/gpio-legacy.txt
> @@ -751,9 +751,6 @@ requested using gpio_request():
> int gpio_export_link(struct device *dev, const char *name,
> unsigned gpio)
>
> -   /* change the polarity of a GPIO node in sysfs */
> -   int gpio_sysfs_set_active_low(unsigned gpio, int value);
> -
>  After a kernel driver requests a GPIO, it may only be made available in
>  the sysfs interface by gpio_export().  The driver can control whether the
>  signal direction may change.  This helps drivers prevent userspace code
> @@ -767,9 +764,3 @@ After the GPIO has been exported, gpio_export_link() 
> allows creating
>  symlinks from elsewhere in sysfs to the GPIO sysfs node.  Drivers can
>  use this to provide the interface under their own device in sysfs with
>  a descriptive name.
> -
> -Drivers can use gpio_sysfs_set_active_low() to hide GPIO line polarity
> -differences between boards from user space.  This only affects the
> -sysfs interface.  Polarity change can be done both before and after
> -gpio_export(), and previously enabled poll(2) support for either
> -rising or falling edge will be reconfigured to follow this setting.
> diff --git a/Documentation/gpio/sysfs.txt b/Documentation/gpio/sysfs.txt
> index c2c3a97f8ff7..535b6a8a7a7c 100644
> --- a/Documentation/gpio/sysfs.txt
> +++ b/Documentation/gpio/sysfs.txt
> @@ -132,9 +132,6 @@ requested using gpio_request():
> int gpiod_export_link(struct device *dev, const char *name,
>   struct gpio_desc *desc);
>
> -   /* change the polarity of a GPIO node in sysfs */
> -   int gpiod_sysfs_set_active_low(struct gpio_desc *desc, int value);
> -
>  After a kernel driver requests a GPIO, it may only be made available in
>  the sysfs interface by gpiod_export(). The driver can control whether the
>  signal direction may change. This helps drivers prevent userspace code
> @@ -148,8 +145,3 @@ After the GPIO has been exported, gpiod_export_link() 
> allows creating
>  symlinks from elsewhere in sysfs to the GPIO sysfs node. Drivers can
>  use this to provide the interface under their own device in sysfs with
>  a descriptive name.
> -
> -Drivers can use gpiod_sysfs_set_active_low() to hide GPIO line polarity
> -differences between boards from user space. Polarity change can be done both
> -before and after gpiod_export(), and previously enabled poll(2) support for
> -either rising or falling edge will be reconfigured to follow this setting.
> diff --git a/Documentation/zh_CN/gpio.txt b/Documentation/zh_CN/gpio.txt
> index d5b8f01833f4..bce972521065 100644
> --- a/Documentation/zh_CN/gpio.txt
> +++ b/Documentation/zh_CN/gpio.txt
> @@ -638,9 +638,6 @@ GPIO 控制器的路径类似 /sys/class/gpio/gpiochip42/ (对于从#42 GPIO
> int gpio_export_link(struct device *dev, const char *name,
> unsigned gpio)
>
> -   /* 改变 sysfs 中的一个 GPIO 节点的极性 */
> -   int gpio_sysfs_set_active_low(unsigned gpio, int value);
> -
>  在一个内核驱动申请一个 GPIO 之后,它可以通过 gpio_export()使其在 sysfs
>  接口中可见。该驱动可以控制信号方向是否可修改。这有助于防止用户空间代码无意间
>  破坏重要的系统状态。
> @@ -651,8 +648,3 @@ GPIO 控制器的路径类似 /sys/class/gpio/gpiochip42/ (对于从#42 GPIO
>  在 GPIO 被导出之后,gpio_export_link()允许在 sysfs 文件系统的任何地方
>  创建一个到这个 GPIO sysfs 节点的符号链接。这样驱动就可以通过一个描述性的
>  名字,在 sysfs 中他们所拥有的设备下提供一个(到这个 GPIO sysfs 节点的)接口。
> -
> -驱动可以使用 gpio_sysfs_set_active_low() 来在用户空间隐藏电路板之间
> -GPIO 线的极性差异。这个仅对 sysfs 接口起作用。极性的改变可以在 gpio_export()
> 

Re: [PATCH v2] Input - mt: Fix input_mt_get_slot_by_key

2015-04-26 Thread Peter Hutterer
On Fri, Apr 24, 2015 at 08:26:39AM +0200, Henrik Rydberg wrote:
> Peter,
> 
> It may be a long time ago now, but we had very vocal discussions regarding the
> MT protocol back then, and I am quite sure all the subtleties are well
> understood. In order to fully appreciate the simplicity of the protocol, one
> only needs to stop misintepreting it. In order to do that, please imagine a
> large piece of papers, a set of brushes, and a set of colors.
> 
> The MT protocol tracks brushes. When lines are drawn, positions are updated.
> When the color on the brush changes, the tracking id changes. When the brush 
> is
> lifted, the tracking id becomes -1, the "no color" color. There is a fixed set
> of brushes. The old test application mtview works precisely this way.
> 
> The add/remove protocol tracks colors. Technichally it tracks contacts, which
> are the combined (color, brush) objects, but in this analogy, colors and
> tracking ids are interchangeable. When lines a drawn, a color is first 
> assigned
> to the color and the brush attributes on the color are updated. The positions 
> on
> the color are subsequently updated. To change color, the brush is deassign 
> from
> the first color and then the brush is assign to the new color. To lift, the
> brush is deassign from the color. This is the abstraction the seems to prevail
> in userland at the moment.
> 
> > can't you just slot in an extra event that contains only the
> > ABS_MT_TRACKING_ID -1 for the needed slots, followed by an SYN_REPORT and
> > whatever BTN_TOOL_* updates are needed? You don't need extra slots here,
> > you're just putting one extra event in the queue before handling the new
> > touches as usual.
> 
> So you want to add a rule saying that before a brush changes color, it first 
> has
> to be cleaned. That may look simple enough, but it misses out on several 
> subtleties.
> 
> 1. It is no longer possible to create beautiful contiuous tracks of varying 
> color.
>
> 2. When a brush moves quickly, it will sometimes restart the track with a new
> color. This happens on all hardware with tracking support when you approach 
> the
> sampling limit. It happens in the kernel tracking as well, for the same 
> reasons.
> Incompatible with 1.
> 
> 3. There is a difference between losing track of a brush and lifting a brush.
> This is one of the situations where the add/remove protocol has to create very
> nonintuitive restrictions and rules to cope. The reason starts with 1.
> 
> Forcing tracks (brushes) into the add/remove protocol creates problems that 
> are
> on a more fundamental level than the subtle issues one may hope to resolve.
> 
> > thing is: I've always assumed that a touch is terminated by a -1 event
> > and this hasn't been a problem until very recently.
> 
> We have talked a lot about the differences, they can hardly have escaped 
> anyone
> deeply involved. 

well, they did. I honestly barely recall any conversations about that
protocol. it's now what, 5 years ago? and since the protocol itself worked
mostly fine I never had to think much about it, short of the various issues
with SYN_DROPPED.

I read through the documentation again after the weekend with fresh eyes and
it IMO can be read both ways. Couple that with seeing tracking IDs of -1 for
a couple of years before this issue came up and here we are at the current
situation. So regardless of what will eventually get merged, I recommend
putting an extra sentence in to explicitly spell out that a tracking ID can
change directly from non-negative to non-negative, and when this is allowed
to happen and what it means to the userspace process. And add an example for
it in the examples section.

> It is true that this is not normally a problem. It only becomes
> important when the sampling rate is too low to resolve all the actions we deem
> important.
> 
> > so anything I've ever
> > touched will be broken if we start switching tracking IDs directly.
> > That
> > includes xorg input, libinput and anything that uses libevdev. sorry.
> 
> This has been in the mainline kernel for the last five years, and obvisouly
> still works well most of the time. I sometimes experience glitches in the
> trackpad usage on my laptop, and it probably stems from this issues. It is
> slightly annoying, but not broken. No reason to panic.

what you're seeing is most likely the effect of libevdev.
libevdev discards the extra tracking ID and the driver will think it's the
same touch. which fixes the various stuck touch issues that we had, along
with crashes, and a couple of memory overflows (specifically in synaptics).

> > if the kernel switches from one tracking ID to another directly,
> > libevdev will actually discard the new tracking ID.
> > http://cgit.freedesktop.org/libevdev/tree/libevdev/libevdev.c#n968
> > (sorry again) aside from the warning, it's safe to switch directly though,
> > there shouldn't be any side-effects. 
> > as for fixing this: I can add something to libevdev to allow it but 

[PATCH 1/1] Documentation: Add dt-binding for TI-btwilink driver

2015-04-26 Thread Gigi Joseph
btwilink binds bluetooth hci0 interface with the shared transport driver

Signed-off-by: Gigi Joseph 
---
 Documentation/devicetree/bindings/btwilink.txt | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/btwilink.txt

diff --git a/Documentation/devicetree/bindings/btwilink.txt 
b/Documentation/devicetree/bindings/btwilink.txt
new file mode 100644
index 000..d286aea
--- /dev/null
+++ b/Documentation/devicetree/bindings/btwilink.txt
@@ -0,0 +1,15 @@
+btwilink
+
+
+Required properties:
+
+   - compatible : must be "ti,btwilink"
+
+Example:
+
+Enable the btwilink driver to bind the bluetooth hci0 interface with
+ti-st shared transport driver
+
+btwilink {
+   compatible = "ti,btwilink";
+};
-- 
1.9.1

--
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: Broadcom 43340 module on iMX6DL

2015-04-26 Thread Dong Aisheng
On Thu, Apr 23, 2015 at 05:50:33PM -0700, John Tobias wrote:
> Hello Guys,
> 
> I have a follow up questions:
> 
> 
> When the I power up the brcm44340 without loading the driver, the
> sdhci-esdhc-imx host controller configured it with the following info
> (cat /sys/kernel/debug/mmc0/ios):
> clock: 5000 Hz
> actual clock: 4950 Hz
> vdd: 17 (2.9 ~ 3.0 V)
> bus mode: 2 (push-pull)
> chip select: 0 (don't care)
> power mode: 2 (on)
> bus width: 2 (4 bits)
> timing spec: 2 (sd high-speed)
> signal voltage: 0 (3.30 V)
> 
> 
> Then, when I load the bcmdhd driver, the driver changed the clock to:

It seems the host is re-enumerating the card when load bcmdhd driver...
This might be required by WiFi driver.

> clock: 40 Hz
> actual clock: 386718 Hz
> vdd: 17 (2.9 ~ 3.0 V)
> bus mode: 2 (push-pull)
> chip select: 0 (don't care)
> power mode: 2 (on)
> bus width: 0 (1 bits)
> timing spec: 0 (legacy)
> signal voltage: 0 (3.30 V)
> 
> Trace from sdhci-esdhc-imx:
> MMC0: sdhci-esdhc-imx:  desired SD clock: 40, actual: 386718
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 40, actual: 386718
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 40, actual: 386718
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 40, actual: 386718
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 40, actual: 386718
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 30, actual: 281250
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 30, actual: 281250
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 30, actual: 281250
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 30, actual: 281250
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 30, actual: 281250
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  change pinctrl state for uhs 0
> MMC0: sdhci-esdhc-imx:  desired SD clock: 20, actual: 193359
> 
> Does the driver need to change the clock when loading the firmware?.
> 
> Is it possible to tell to the driver to skip changing the clock?.
> 
> Or any work around for the problem?.
> 

It is a feature implemented by MMC core that re-try a slower clock
when enumerate fails.
See:
drivers/mmc/core/core.c
mmc_claim_host(host);
for (i = 0; i < ARRAY_SIZE(freqs); i++) {
if (!mmc_rescan_try_freq(host, max(freqs[i], host->f_min)))
break;
if (freqs[i] <= host->f_min)
break;
}
mmc_release_host(host);

Regards
Dong Aisheng

> Note: attached is a verbose logs of the driver.
> 
> Regards,
> 
> John
> 
> On Thu, Apr 23, 2015 at 12:00 PM, Arend van Spriel  wrote:
> > + John Stultz
> >
> >
> > On 04/23/15 20:44, John Tobias wrote:
> >>
> >> Thanks Dmitry for the info.
> >>
> >> Arend:
> >>
> >> Yes, it's an android... Here's the info:
> >>
> >> 00060e80  de 02 f0 18 8c 00 e8 5e  8f 00 37 a3 00 e0 5e 8a
> >> |...^..7...^.|
> >> 00060e90  f4 77 a2 00 02 de 02 f0  00 00 01 bc 60 03 00 07
> >> |.w..`...|
> >> 00060ea0  aa 01 bc 60 03 00 07 ab  01 bc 60 03 00 07 b7 01
> >> |...`..`.|
> >> 00060eb0  bc 60 13 08 17 a1 00 02  5e 02 f0 01 28 00 b0 40
> >> |.`..^...(..@|
> >> 00060ec0  67 00 17 a3 01 80 60 02  03 37 a2 00 02 5e 02 f0
> >> |g.`..7...^..|
> >> 00060ed0  01 2c 00 b0 5e 8f 00 17  a2 00 02 5e 02 f0 01 2c
> >> |.,..^..^...,|
> >> 00060ee0  00 02 de 02 f0 00 00 01  bc 60 63 00 10 7b 00 b0
> >> |.`c..{..|
> >> 00060ef0  5e 8b 00 10 7a 01 ac 60  7e f4 30 75 02 87 41 d7
> >> |^...z..`~.0u..A.|
> >> 00060f00  00 18 9c 00 02 de 02 f0  00 00 01 bc 60 63 00 10
> >> |`c..|
> >> 00060f10  7b 00 b0 5e 8b 00 10 7a  01 ac 60 be f4 30 75 02
> >> |{..^...z..`..0u.|
> >> 00060f20  87 41 d7 00 18 a1 00 02  de 02 f0 00 00 00 00 00
> >> |.A..|
> >> 00060f30  00 00 00 00 7c ac 00 00  2d cb a7 58 06 0a be 31
> >> ||...-..X...1|
> >> 00060f40  b1 8d a0 53 00 5b 07 49  45 13 20 4e 7d 7e 47 28  |...S.[.IE.
> >> N}~G(|
> >> 00060f50  08 7c 77 d2 bc 44 87 13  01 bd 32 08 01 00 34 33
> >> |.|w..D2...43|
> >> 00060f60  33 34 31 62 30 2d 72 6f  6d 6c 2f 73 64 69 6f 2d
> >> |341b0-roml/sdio-|
> >> 00060f70  61 67 2d 70 6e 6f 2d 70  32 70 2d 63 63 78 2d 65
> >> |ag-pno-p2p-ccx-e|
> >> 00060f80  78 74 73 75 70 2d 70 72  6f 70 74 78 73 74 61 74
> >> |xtsup-proptxstat|
> >> 00060f90  75 73 2d 64 6d 61 74 78  72 63 2d 72 78 6f 76 2d
> >> |us-dmatxrc-rxov-|
> >> 00060fa0  70 6b 74 66 69 6c 74 65  72 2d 6b 65 65 70 61 6c
> >> |pktfilter-keepal|
> >> 00060fb0  69 76 65 2d 61 6f 65 

Re: Broadcom 43340 module on iMX6DL

2015-04-26 Thread Dong Aisheng
On Fri, Apr 24, 2015 at 09:03:04PM +0200, Arend van Spriel wrote:
> On 04/24/15 20:24, John Tobias wrote:
> >Hi Arend,
> >
> >Apologize for the confusion. I am asking the repo for the device
> >driver for 43340. Looking at the link you sent, it's more userspace
> >support and didn't see the device driver there...
> 
> crap. you are right. it is userspace and firmware. You need a kernel
> repo. There are some on the site I referred to, but you may need to
> contact Freescale whether they provide it publicly like on github or
> so.
> 

One simple question:
Does the brcmfmac driver in upstream kernel also work?
I mean this one:
drivers/net/wireless/brcm80211

Regards
Dong Aisheng

> Regards,
> Arend
> 
> >Regards,
> >
> >John
> >
> >
> >On Fri, Apr 24, 2015 at 11:14 AM, Arend van Spriel  
> >wrote:
> >>On 04/24/15 19:49, John Tobias wrote:
> >>>
> >>>Hi Arend,
> >>>
> >>>I am not pretty sure if the brcm43340 driver for android is the latest
> >>>one.  May I know repo?.
> >>
> >>
> >>Not sure what you are asking. I gave the url. Did you try using the
> >>brcmfmac4334-sdio.bin firmware file. I would like to know if that one works
> >>for your device.
> >>
> >>Regards,
> >>Arend
> >>
> >>
> >>>Regards,
> >>>
> >>>John
> >>>
> >>>On Fri, Apr 24, 2015 at 1:20 AM, Arend van Spriel
> >>>wrote:
> 
> On 04/24/15 03:04, John Tobias wrote:
> >
> >
> >Btw, where I could get a copy of the latest driver?.
> 
> 
> 
> The open-source bcmdhd is in AOSP [1]. I would stick to the android
> release
> branch you are running on your device.
> 
> Regards,
> Arend
> 
> [1] https://android.googlesource.com/platform/hardware/broadcom/wlan/
> 
> 
> >Regards,
> >
> >John
> >
> >On Thu, Apr 23, 2015 at 5:59 PM, John Tobias
> >wrote:
> >>
> >>
> >>Hi John,
> >>
> >>Is it possible to have a copy of the firmware for 43340?.
> >>
> >>Regards,
> >>
> >>John
> >>
> >>On Thu, Apr 23, 2015 at 5:57 PM, John Stultz
> >>wrote:
> >>>
> >>>
> >>>On Thu, Apr 23, 2015 at 12:00 PM, Arend van Spriel
> >>>wrote:
> 
> 
> By the name of the file I suspected you did. Personally, I verified
> the
> firmware works on 43341. John Stultz tested both 43340 and 43341 with
> this
> firmware.
> >>>
> >>>
> >>>
> >>>Minor correction here, I only tested on 43341 hardware. The confusion
> >>>might be that the firmware I originally had access to claimed it was
> >>>43340.
> >>>
> >>>thanks
> >>>-john
> 
> 
> 
> >>
> 
--
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/


[PATCH v2] spi: omap2-mcspi: Add support for GPIO chipselects

2015-04-26 Thread Michael Welling
This patch allows for GPIOs specified in the devicetree to be used as SPI
chipselects on TI OMAP2 SoCs.

Tested on the AM3354.

Signed-off-by: Michael Welling 
---

v2: Considers the possible use of SPI_CS_HIGH during chip select activation.

 drivers/spi/spi-omap2-mcspi.c |   13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index d1a5b9f..5e388a8 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -35,6 +35,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -246,6 +247,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, 
int cs_active)
 {
u32 l;
 
+   if (gpio_is_valid(spi->cs_gpio)) {
+   gpio_set_value(spi->cs_gpio, (cs_active) ?
+   !!(spi->mode & SPI_CS_HIGH) :
+   !(spi->mode & SPI_CS_HIGH));
+   }
+
l = mcspi_cached_chconf0(spi);
if (cs_active)
l |= OMAP2_MCSPI_CHCONF_FORCE;
@@ -1015,6 +1022,12 @@ static int omap2_mcspi_setup(struct spi_device *spi)
if (ret < 0)
return ret;
 
+   if (gpio_is_valid(spi->cs_gpio)) {
+   if (gpio_request(spi->cs_gpio, dev_name(>dev)) == 0)
+   gpio_direction_output(spi->cs_gpio,
+   !(spi->mode & SPI_CS_HIGH));
+   }
+
ret = omap2_mcspi_setup_transfer(spi, NULL);
pm_runtime_mark_last_busy(mcspi->dev);
pm_runtime_put_autosuspend(mcspi->dev);
-- 
1.7.9.5

--
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] perf/x86/intel/uncore: fix IMC missing box initialization

2015-04-26 Thread Liang, Kan

>
> > This leads me to believe that this patch:
> >
> > commit c05199e5a57a579fea1e8fa65e2b511ceb524ffc
> > Author: Kan Liang 
> > Date:   Tue Jan 20 04:54:25 2015 +
> >
> > perf/x86/intel/uncore: Move uncore_box_init() out of driver
> initialization
> >
> > If I revert it, I bet things will work again.
>
> Yes the initialization needs to be moved out of the IPI context.
>

Maybe we can move them to event init, which is not in IPI context.

What do you think of this patch?

---

>From 8a61c48144921e9d1c841656829c3bae9bfb4408 Mon Sep 17 00:00:00 2001
From: Kan Liang 
Date: Sun, 26 Apr 2015 16:24:59 -0400
Subject: [PATCH 1/1] perf/x86/intel/uncore: move uncore_box_init to uncore
 event init

commit c05199e5a57a("perf/x86/intel/uncore: Move uncore_box_init() out
of driver initialization") moves uncore_box_init into uncore_enable_box
to prevent potential boot failures. However, uncore_enable_box is not
called on some client platforms (SNB/IVB/HSW) for counting IMC event.
When it is not called, the box is not initialized, which hard locks the
system.

Additionally, uncore_enable_box along with the initialization code in it
is always called in uncore event start functions, which are in IPI
context. But the initizlization code should not be in IPI context. This
is because, for example, the IMC box initialization codes for client
platforms include ioremap, which is not allowed to be called in IPI
context.

This patch moves uncore_box_init out of IPI context, to uncore event
init. The box is initialized only when it has not yet been initialized.

Signed-off-by: Kan Liang 
---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 4 
 arch/x86/kernel/cpu/perf_event_intel_uncore.h | 2 --
 arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c | 3 +++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c 
b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index c635b8b..cbc1a93 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -623,6 +623,10 @@ static int uncore_pmu_event_init(struct perf_event *event)
box = uncore_pmu_to_box(pmu, event->cpu);
if (!box || box->cpu < 0)
return -EINVAL;
+
+   /* Init box if it's not initialized yet */
+   uncore_box_init(box);
+
event->cpu = box->cpu;

event->hw.idx = -1;
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h 
b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
index 6c8c1e7..1fb2905 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
@@ -273,8 +273,6 @@ static inline void uncore_disable_box(struct 
intel_uncore_box *box)

 static inline void uncore_enable_box(struct intel_uncore_box *box)
 {
-   uncore_box_init(box);
-
if (box->pmu->type->ops->enable_box)
box->pmu->type->ops->enable_box(box);
 }
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c 
b/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c
index 4562e9e..ead70a6 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c
@@ -279,6 +279,9 @@ static int snb_uncore_imc_event_init(struct perf_event 
*event)
if (!box || box->cpu < 0)
return -EINVAL;

+   /* Init box if it's not initialized yet */
+   uncore_box_init(box);
+
event->cpu = box->cpu;

event->hw.idx = -1;

Thanks,
Kan

> -Andi
>
>
> --
> a...@linux.intel.com -- Speaking for myself only
--
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: Broadcom 43340 module on iMX6DL

2015-04-26 Thread Dong Aisheng
On Fri, Apr 24, 2015 at 09:03:04PM +0200, Arend van Spriel wrote:
> On 04/24/15 20:24, John Tobias wrote:
> >Hi Arend,
> >
> >Apologize for the confusion. I am asking the repo for the device
> >driver for 43340. Looking at the link you sent, it's more userspace
> >support and didn't see the device driver there...
> 
> crap. you are right. it is userspace and firmware. You need a kernel
> repo. There are some on the site I referred to, but you may need to
> contact Freescale whether they provide it publicly like on github or
> so.
> 

Freescale does not provide Broadcom driver currently.
It might provide it for MX7D release in the future due to MX7D SDB board
integrated a Broadcom WiFi chip.
But it depends on whether the SLA signed with Broadcom can be ready
before the release.

Regards
Dong Aisheng

> Regards,
> Arend
> 
> >Regards,
> >
> >John
> >
> >
> >On Fri, Apr 24, 2015 at 11:14 AM, Arend van Spriel  
> >wrote:
> >>On 04/24/15 19:49, John Tobias wrote:
> >>>
> >>>Hi Arend,
> >>>
> >>>I am not pretty sure if the brcm43340 driver for android is the latest
> >>>one.  May I know repo?.
> >>
> >>
> >>Not sure what you are asking. I gave the url. Did you try using the
> >>brcmfmac4334-sdio.bin firmware file. I would like to know if that one works
> >>for your device.
> >>
> >>Regards,
> >>Arend
> >>
> >>
> >>>Regards,
> >>>
> >>>John
> >>>
> >>>On Fri, Apr 24, 2015 at 1:20 AM, Arend van Spriel
> >>>wrote:
> 
> On 04/24/15 03:04, John Tobias wrote:
> >
> >
> >Btw, where I could get a copy of the latest driver?.
> 
> 
> 
> The open-source bcmdhd is in AOSP [1]. I would stick to the android
> release
> branch you are running on your device.
> 
> Regards,
> Arend
> 
> [1] https://android.googlesource.com/platform/hardware/broadcom/wlan/
> 
> 
> >Regards,
> >
> >John
> >
> >On Thu, Apr 23, 2015 at 5:59 PM, John Tobias
> >wrote:
> >>
> >>
> >>Hi John,
> >>
> >>Is it possible to have a copy of the firmware for 43340?.
> >>
> >>Regards,
> >>
> >>John
> >>
> >>On Thu, Apr 23, 2015 at 5:57 PM, John Stultz
> >>wrote:
> >>>
> >>>
> >>>On Thu, Apr 23, 2015 at 12:00 PM, Arend van Spriel
> >>>wrote:
> 
> 
> By the name of the file I suspected you did. Personally, I verified
> the
> firmware works on 43341. John Stultz tested both 43340 and 43341 with
> this
> firmware.
> >>>
> >>>
> >>>
> >>>Minor correction here, I only tested on 43341 hardware. The confusion
> >>>might be that the firmware I originally had access to claimed it was
> >>>43340.
> >>>
> >>>thanks
> >>>-john
> 
> 
> 
> >>
> 
--
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 0/2] ppp: mppe: fixes MPPE desync on links which don't guarantee packet ordering

2015-04-26 Thread David Miller
From: Sylvain Rochet 
Date: Sun, 26 Apr 2015 20:40:51 +0200

> I am currently having an issue with PPP over L2TP (UDP) and MPPE in
> stateless mode (default mode), UDP does not guarantee packet ordering so
> we might get out of order packet. MPPE needs to be continuously synched
> so we should drop late UDP packet.
> 
> I added a printk on the number of time we rekeyed in MPPE decompressor,
> this is what we currently have if we receive a slightly out of order UDP
> packet:
 ...
> This is obviously wrong, we missed packet 1561 and we already rekeyed 2
> times for 1562 we previously received, we can't recover the decryption
> key we need for 1561, we should drop it instead of rekeying 4095 times.
> 
> This patch series drop any packet with are not within the 4096/2 forward
> window.

Series applied, thanks Sylvain.
--
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 v3] dmaengine: xgene-dma: Fix sparse wannings and coccinelle warnings

2015-04-26 Thread Vinod Koul
On Mon, Apr 20, 2015 at 08:38:18AM +0530, Rameshwar Sahu wrote:
> Hi Vinod,
>> >> @@ -2085,6 +2043,5 @@ module_platform_driver(xgene_dma_driver);
> >>
> >>  MODULE_DESCRIPTION("APM X-Gene SoC DMA driver");
> >>  MODULE_AUTHOR("Rameshwar Prasad Sahu ");
> >> -MODULE_AUTHOR("Loc Ho ");
> > And why this?
> 
> I saw below warning reported by the kbuild robot test
> 
> drivers/dma/xgene-dma.c:2088:1: sparse: symbol
> '__UNIQUE_ID_author__COUNTER__' has multiple initializers (originally
> initialized at drivers/dma/xgene-dma.c:2087)
> So, I kept only one author here.
No that is not right, sparse shouldn't have cribbed here.

Fengguang can we get the bot to ignore this please

-- 
~Vinod

--
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: [RFC PATCH 5/5] GHES: Make NMI handler have a single reader

2015-04-26 Thread Zheng, Lv
Hi,

> From: Borislav Petkov [mailto:b...@alien8.de]
> Sent: Friday, March 27, 2015 5:23 PM
> 
> From: Jiri Kosina 
> 
> Since GHES sources are global, we theoretically need only a single CPU
> reading them per NMI instead of a thundering herd of CPUs waiting on a
> spinlock in NMI context for no reason at all.
> 
> Do that.
> 
> Signed-off-by: Jiri Kosina 
> Signed-off-by: Borislav Petkov 
> ---
>  drivers/acpi/apei/ghes.c | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index 94a44bad5576..2bfd53cbfe80 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
> @@ -729,10 +729,10 @@ static struct llist_head ghes_estatus_llist;
>  static struct irq_work ghes_proc_irq_work;
> 
>  /*
> - * NMI may be triggered on any CPU, so ghes_nmi_lock is used for
> - * mutual exclusion.
> + * NMI may be triggered on any CPU, so ghes_in_nmi is used for
> + * having only one concurrent reader.
>   */
> -static DEFINE_RAW_SPINLOCK(ghes_nmi_lock);
> +static atomic_t ghes_in_nmi = ATOMIC_INIT(0);
> 
>  static LIST_HEAD(ghes_nmi);
> 
> @@ -840,7 +840,9 @@ static int ghes_notify_nmi(unsigned int cmd, struct 
> pt_regs *regs)
>   struct ghes *ghes;
>   int sev, ret = NMI_DONE;
> 
> - raw_spin_lock(_nmi_lock);
> + if (!atomic_add_unless(_in_nmi, 1, 1))
> + return ret;
> +

Just a simple question.
Why not just using cmpxchg here instead of atomic_add_unless so that no 
atomic_dec will be needed.

Thanks and best regards
-Lv

>   list_for_each_entry_rcu(ghes, _nmi, list) {
>   if (ghes_read_estatus(ghes, 1)) {
>   ghes_clear_estatus(ghes);
> @@ -863,7 +865,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct 
> pt_regs *regs)
>  #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
>   irq_work_queue(_proc_irq_work);
>  #endif
> - raw_spin_unlock(_nmi_lock);
> + atomic_dec(_in_nmi);
>   return ret;
>  }
> 
> --
> 2.3.3

--
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/


[PATCH v4 03/10] lib: public headers and API implementations for userspace programs

2015-04-26 Thread Hajime Tazaki
userspace programs which uses libos access via a public API, lib_init(),
with passed arguments struct SimImported and struct SimExported.

Signed-off-by: Hajime Tazaki 
Signed-off-by: Ryo Nakamura 
---
 arch/lib/include/sim-assert.h |  23 +++
 arch/lib/include/sim-init.h   | 134 ++
 arch/lib/include/sim-printf.h |  13 ++
 arch/lib/include/sim-types.h  |  53 ++
 arch/lib/include/sim.h|  51 ++
 arch/lib/lib-device.c | 187 +++
 arch/lib/lib-socket.c | 410 ++
 arch/lib/lib.c| 294 ++
 arch/lib/lib.h|  21 +++
 9 files changed, 1186 insertions(+)
 create mode 100644 arch/lib/include/sim-assert.h
 create mode 100644 arch/lib/include/sim-init.h
 create mode 100644 arch/lib/include/sim-printf.h
 create mode 100644 arch/lib/include/sim-types.h
 create mode 100644 arch/lib/include/sim.h
 create mode 100644 arch/lib/lib-device.c
 create mode 100644 arch/lib/lib-socket.c
 create mode 100644 arch/lib/lib.c
 create mode 100644 arch/lib/lib.h

diff --git a/arch/lib/include/sim-assert.h b/arch/lib/include/sim-assert.h
new file mode 100644
index 000..974122c
--- /dev/null
+++ b/arch/lib/include/sim-assert.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ */
+
+#ifndef SIM_ASSERT_H
+#define SIM_ASSERT_H
+
+#include "sim-printf.h"
+
+#define lib_assert(v) {
\
+   while (!(v)) {  \
+   lib_printf("Assert failed %s:%u \"" #v "\"\n",  \
+   __FILE__, __LINE__);\
+   char *p = 0;\
+   *p = 1; \
+   }   \
+   }
+
+
+#endif /* SIM_ASSERT_H */
diff --git a/arch/lib/include/sim-init.h b/arch/lib/include/sim-init.h
new file mode 100644
index 000..e871a59
--- /dev/null
+++ b/arch/lib/include/sim-init.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ */
+
+#ifndef SIM_INIT_H
+#define SIM_INIT_H
+
+#include 
+#include "sim-types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct _IO_FILE;
+typedef struct _IO_FILE FILE;
+
+struct SimExported {
+   struct SimTask *(*task_create)(void *priv, unsigned long pid);
+   void (*task_destroy)(struct SimTask *task);
+   void *(*task_get_private)(struct SimTask *task);
+
+   int (*sock_socket)(int domain, int type, int protocol,
+   struct SimSocket **socket);
+   int (*sock_close)(struct SimSocket *socket);
+   ssize_t (*sock_recvmsg)(struct SimSocket *socket, struct msghdr *msg,
+   int flags);
+   ssize_t (*sock_sendmsg)(struct SimSocket *socket,
+   const struct msghdr *msg, int flags);
+   int (*sock_getsockname)(struct SimSocket *socket,
+   struct sockaddr *name, int *namelen);
+   int (*sock_getpeername)(struct SimSocket *socket,
+   struct sockaddr *name, int *namelen);
+   int (*sock_bind)(struct SimSocket *socket, const struct sockaddr *name,
+   int namelen);
+   int (*sock_connect)(struct SimSocket *socket,
+   const struct sockaddr *name, int namelen,
+   int flags);
+   int (*sock_listen)(struct SimSocket *socket, int backlog);
+   int (*sock_shutdown)(struct SimSocket *socket, int how);
+   int (*sock_accept)(struct SimSocket *socket,
+   struct SimSocket **newSocket, int flags);
+   int (*sock_ioctl)(struct SimSocket *socket, int request, char *argp);
+   int (*sock_setsockopt)(struct SimSocket *socket, int level,
+   int optname,
+   const void *optval, int optlen);
+   int (*sock_getsockopt)(struct SimSocket *socket, int level,
+   int optname,
+   void *optval, int *optlen);
+
+   void (*sock_poll)(struct SimSocket *socket, void *ret);
+   void (*sock_pollfreewait)(void *polltable);
+
+   struct SimDevice *(*dev_create)(const char *ifname, void *priv,
+   enum SimDevFlags flags);
+   void (*dev_destroy)(struct SimDevice *dev);
+   void *(*dev_get_private)(struct SimDevice *task);
+   void (*dev_set_address)(struct SimDevice *dev,
+   unsigned char buffer[6]);
+   void (*dev_set_mtu)(struct SimDevice *dev, int mtu);
+   struct SimDevicePacket (*dev_create_packet)(struct SimDevice *dev,
+   int size);
+   void 

[PATCH v4 10/10] lib: tools used for test scripts

2015-04-26 Thread Hajime Tazaki
These auxiliary files are used for testing and debugging of net/ code
with libos. a simple test is implemented with make test ARCH=lib.

Signed-off-by: Hajime Tazaki 
---
 tools/testing/libos/.gitignore   |  6 +
 tools/testing/libos/Makefile | 38 +++
 tools/testing/libos/README   | 15 +++
 tools/testing/libos/bisect.sh| 10 +++
 tools/testing/libos/dce-test.sh  | 23 
 tools/testing/libos/nuse-test.sh | 57 
 6 files changed, 149 insertions(+)
 create mode 100644 tools/testing/libos/.gitignore
 create mode 100644 tools/testing/libos/Makefile
 create mode 100644 tools/testing/libos/README
 create mode 100755 tools/testing/libos/bisect.sh
 create mode 100755 tools/testing/libos/dce-test.sh
 create mode 100755 tools/testing/libos/nuse-test.sh

diff --git a/tools/testing/libos/.gitignore b/tools/testing/libos/.gitignore
new file mode 100644
index 000..57a74a0
--- /dev/null
+++ b/tools/testing/libos/.gitignore
@@ -0,0 +1,6 @@
+*.pcap
+files-*
+bake
+buildtop
+core
+exitprocs
diff --git a/tools/testing/libos/Makefile b/tools/testing/libos/Makefile
new file mode 100644
index 000..3da25429
--- /dev/null
+++ b/tools/testing/libos/Makefile
@@ -0,0 +1,38 @@
+ADD_PARAM?=
+
+all: test
+
+bake:
+   hg clone http://code.nsnam.org/bake
+
+check_pkgs:
+   @./bake/bake.py check | grep Bazaar | grep OK || (echo "bzr is missing" 
&& ./bake/bake.py check)
+   @./bake/bake.py check | grep autoreconf | grep OK || (echo "autotools 
is missing" && ./bake/bake.py check && exit 1)
+
+testbin: bake check_pkgs
+   @cp ../../../arch/lib/tools/bakeconf-linux.xml bake/bakeconf.xml
+   @mkdir -p buildtop/build/bin_dce
+   cd buildtop ; \
+   ../bake/bake.py configure -e dce-linux-inkernel $(BAKECONF_PARAMS)
+   cd buildtop ; \
+   ../bake/bake.py show --enabledTree | grep -v  -E 
"pygoocanvas|graphviz|python-dev" | grep Missing && (echo "required packages 
are missing") || echo ""
+   cd buildtop ; \
+   ../bake/bake.py download ; \
+   ../bake/bake.py update ; \
+   ../bake/bake.py build
+
+test:
+   @./dce-test.sh ADD_PARAM=$(ADD_PARAM)
+
+test-valgrind:
+   @./dce-test.sh -g ADD_PARAM=$(ADD_PARAM)
+
+test-fault-injection:
+   @./dce-test.sh -f ADD_PARAM=$(ADD_PARAM)
+
+clean:
+#  @rm -rf buildtop
+   @rm -f *.pcap
+   @rm -rf files-*
+   @rm -f exitprocs
+   @rm -f core
diff --git a/tools/testing/libos/README b/tools/testing/libos/README
new file mode 100644
index 000..51ac5a5
--- /dev/null
+++ b/tools/testing/libos/README
@@ -0,0 +1,15 @@
+
+- bisect.sh
+a sample script to bisect an issue of network stack code with the help
+of LibOS (and ns-3 network simulator). This was used to detect the issue
+for the following patch.
+
+http://patchwork.ozlabs.org/patch/436351/
+
+- dce-test.sh
+a test script invoked by 'make test ARCH=lib'. The contents of test
+scenario are implemented as test suites of ns-3 network simulator.
+
+- nuse-test.sh
+a simple test script for Network Stack in Userspace (NUSE).
+
diff --git a/tools/testing/libos/bisect.sh b/tools/testing/libos/bisect.sh
new file mode 100755
index 000..9377ac3
--- /dev/null
+++ b/tools/testing/libos/bisect.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+git merge origin/nuse --no-commit
+make clean ARCH=lib
+make library ARCH=lib OPT=no
+make test ARCH=lib ADD_PARAM=" -s dce-umip"
+RET=$?
+git reset --hard
+
+exit $RET
diff --git a/tools/testing/libos/dce-test.sh b/tools/testing/libos/dce-test.sh
new file mode 100755
index 000..e81e2d8
--- /dev/null
+++ b/tools/testing/libos/dce-test.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+set -e
+#set -x
+export LD_LOG=symbol-fail
+#VERBOSE="-v"
+VALGRIND=""
+FAULT_INJECTION=""
+
+if [ "$1" = "-g" ] ; then
+ VALGRIND="-g"
+# Not implemneted yet.
+#elif [ "$1" = "-f" ] ; then
+# FAULT_INJECTION="-f"
+fi
+
+# FIXME
+#export NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::\
+#DlmLoaderFactory[];ns3::TaskManager::FiberManagerType=UcontextFiberManager'
+
+cd buildtop/source/ns-3-dce
+LD_LIBRARY_PATH=${srctree} ./test.py -n ${VALGRIND} ${FAULT_INJECTION}\
+  ${VERBOSE} ${ADD_PARAM}
diff --git a/tools/testing/libos/nuse-test.sh b/tools/testing/libos/nuse-test.sh
new file mode 100755
index 000..198e7e4
--- /dev/null
+++ b/tools/testing/libos/nuse-test.sh
@@ -0,0 +1,57 @@
+#!/bin/bash -e
+
+LIBOS_TOOLS=arch/lib/tools
+
+IFNAME=`ip route |grep default | awk '{print $5}'`
+GW=`ip route |grep default | awk '{print $3}'`
+#XXX
+IPADDR=`echo $GW | sed -r "s/([0-9]+\.[0-9]+\.[0-9]+\.)([0-9]+)$/\1\`expr \2 + 
10\`/"`
+
+# ip route
+# ip address
+# ip link
+
+NUSE_CONF=/tmp/nuse.conf
+
+cat > ${NUSE_CONF} << ENDCONF
+
+interface ${IFNAME}
+   address ${IPADDR}
+   netmask 255.255.255.0
+   macaddr 00:01:01:01:01:02
+   viftype RAW
+
+route
+   network 0.0.0.0
+   netmask 0.0.0.0
+   gateway ${GW}
+
+ENDCONF
+
+cd 

[PATCH v4 01/10] sysctl: make some functions unstatic to access by arch/lib

2015-04-26 Thread Hajime Tazaki
libos (arch/lib) emulates a sysctl-like interface by a function call of
userspace by enumerating sysctl tree from sysctl_table_root. It requires
to be publicly accessible to this symbol and related functions.

Signed-off-by: Hajime Tazaki 
---
 fs/proc/proc_sysctl.c | 36 +++-
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index fea2561..7c5924c 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -35,7 +35,7 @@ static struct ctl_table root_table[] = {
},
{ }
 };
-static struct ctl_table_root sysctl_table_root = {
+struct ctl_table_root sysctl_table_root = {
.default_set.dir.header = {
{{.count = 1,
  .nreg = 1,
@@ -77,8 +77,9 @@ static int namecmp(const char *name1, int len1, const char 
*name2, int len2)
 }
 
 /* Called under sysctl_lock */
-static struct ctl_table *find_entry(struct ctl_table_header **phead,
-   struct ctl_dir *dir, const char *name, int namelen)
+struct ctl_table *ctl_table_find_entry(struct ctl_table_header **phead,
+  struct ctl_dir *dir, const char *name,
+  int namelen)
 {
struct ctl_table_header *head;
struct ctl_table *entry;
@@ -300,7 +301,7 @@ static struct ctl_table *lookup_entry(struct 
ctl_table_header **phead,
struct ctl_table *entry;
 
spin_lock(_lock);
-   entry = find_entry(, dir, name, namelen);
+   entry = ctl_table_find_entry(, dir, name, namelen);
if (entry && use_table(head))
*phead = head;
else
@@ -321,7 +322,7 @@ static struct ctl_node *first_usable_entry(struct rb_node 
*node)
return NULL;
 }
 
-static void first_entry(struct ctl_dir *dir,
+void ctl_table_first_entry(struct ctl_dir *dir,
struct ctl_table_header **phead, struct ctl_table **pentry)
 {
struct ctl_table_header *head = NULL;
@@ -339,7 +340,7 @@ static void first_entry(struct ctl_dir *dir,
*pentry = entry;
 }
 
-static void next_entry(struct ctl_table_header **phead, struct ctl_table 
**pentry)
+void ctl_table_next_entry(struct ctl_table_header **phead, struct ctl_table 
**pentry)
 {
struct ctl_table_header *head = *phead;
struct ctl_table *entry = *pentry;
@@ -670,7 +671,8 @@ static int proc_sys_readdir(struct file *file, struct 
dir_context *ctx)
 
pos = 2;
 
-   for (first_entry(ctl_dir, , ); h; next_entry(, )) {
+   for (ctl_table_first_entry(ctl_dir, , ); h;
+ctl_table_next_entry(, )) {
if (!scan(h, entry, , file, ctx)) {
sysctl_head_finish(h);
break;
@@ -828,7 +830,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
struct ctl_table_header *head;
struct ctl_table *entry;
 
-   entry = find_entry(, dir, name, namelen);
+   entry = ctl_table_find_entry(, dir, name, namelen);
if (!entry)
return ERR_PTR(-ENOENT);
if (!S_ISDIR(entry->mode))
@@ -924,13 +926,13 @@ failed:
return subdir;
 }
 
-static struct ctl_dir *xlate_dir(struct ctl_table_set *set, struct ctl_dir 
*dir)
+struct ctl_dir *ctl_table_xlate_dir(struct ctl_table_set *set, struct ctl_dir 
*dir)
 {
struct ctl_dir *parent;
const char *procname;
if (!dir->header.parent)
return >dir;
-   parent = xlate_dir(set, dir->header.parent);
+   parent = ctl_table_xlate_dir(set, dir->header.parent);
if (IS_ERR(parent))
return parent;
procname = dir->header.ctl_table[0].procname;
@@ -951,13 +953,13 @@ static int sysctl_follow_link(struct ctl_table_header 
**phead,
spin_lock(_lock);
root = (*pentry)->data;
set = lookup_header_set(root, namespaces);
-   dir = xlate_dir(set, (*phead)->parent);
+   dir = ctl_table_xlate_dir(set, (*phead)->parent);
if (IS_ERR(dir))
ret = PTR_ERR(dir);
else {
const char *procname = (*pentry)->procname;
head = NULL;
-   entry = find_entry(, dir, procname, strlen(procname));
+   entry = ctl_table_find_entry(, dir, procname, 
strlen(procname));
ret = -ENOENT;
if (entry && use_table(head)) {
unuse_table(*phead);
@@ -1069,7 +1071,7 @@ static bool get_links(struct ctl_dir *dir,
/* Are there links available for every entry in table? */
for (entry = table; entry->procname; entry++) {
const char *procname = entry->procname;
-   link = find_entry(, dir, procname, strlen(procname));
+   link = ctl_table_find_entry(, dir, procname, 
strlen(procname));
if (!link)
return false;
if (S_ISDIR(link->mode) && S_ISDIR(entry->mode))
@@ -1082,7 +1084,7 @@ static bool 

[PATCH v4 07/10] lib: other kernel glue layer code

2015-04-26 Thread Hajime Tazaki
These files are used to provide the same function calls so that other
network stack code keeps untouched.

Signed-off-by: Hajime Tazaki 
Signed-off-by: Christoph Paasch 
---
 arch/lib/capability.c |  25 +
 arch/lib/filemap.c|  32 ++
 arch/lib/fs.c |  70 
 arch/lib/glue.c   | 289 ++
 arch/lib/modules.c|  36 +++
 arch/lib/pid.c|  29 +
 arch/lib/print.c  |  56 ++
 arch/lib/proc.c   |  34 ++
 arch/lib/random.c |  53 +
 arch/lib/sysfs.c  |  83 +++
 arch/lib/vmscan.c |  26 +
 11 files changed, 733 insertions(+)
 create mode 100644 arch/lib/capability.c
 create mode 100644 arch/lib/filemap.c
 create mode 100644 arch/lib/fs.c
 create mode 100644 arch/lib/glue.c
 create mode 100644 arch/lib/modules.c
 create mode 100644 arch/lib/pid.c
 create mode 100644 arch/lib/print.c
 create mode 100644 arch/lib/proc.c
 create mode 100644 arch/lib/random.c
 create mode 100644 arch/lib/sysfs.c
 create mode 100644 arch/lib/vmscan.c

diff --git a/arch/lib/capability.c b/arch/lib/capability.c
new file mode 100644
index 000..3a1f301
--- /dev/null
+++ b/arch/lib/capability.c
@@ -0,0 +1,25 @@
+/*
+ * glue code for library version of Linux kernel
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ */
+
+#include "linux/capability.h"
+
+struct sock;
+struct sk_buff;
+
+int file_caps_enabled = 0;
+
+int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
+{
+   return 0;
+}
+
+bool file_ns_capable(const struct file *file, struct user_namespace *ns,
+int cap)
+{
+   return true;
+}
diff --git a/arch/lib/filemap.c b/arch/lib/filemap.c
new file mode 100644
index 000..ce424ff
--- /dev/null
+++ b/arch/lib/filemap.c
@@ -0,0 +1,32 @@
+/*
+ * glue code for library version of Linux kernel
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ * Frederic Urbani
+ */
+
+#include "sim.h"
+#include "sim-assert.h"
+#include 
+
+
+ssize_t generic_file_aio_read(struct kiocb *a, const struct iovec *b,
+ unsigned long c, loff_t d)
+{
+   lib_assert(false);
+
+   return 0;
+}
+
+int generic_file_readonly_mmap(struct file *file, struct vm_area_struct *vma)
+{
+   return -ENOSYS;
+}
+
+ssize_t
+generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
+{
+   return 0;
+}
diff --git a/arch/lib/fs.c b/arch/lib/fs.c
new file mode 100644
index 000..324e10b
--- /dev/null
+++ b/arch/lib/fs.c
@@ -0,0 +1,70 @@
+/*
+ * glue code for library version of Linux kernel
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ * Frederic Urbani
+ */
+
+#include 
+
+#include "sim-assert.h"
+
+__cacheline_aligned_in_smp DEFINE_SEQLOCK(mount_lock);
+unsigned int dirtytime_expire_interval;
+
+void __init mnt_init(void)
+{
+}
+
+/* Implementation taken from vfs_kern_mount from linux/namespace.c */
+struct vfsmount *kern_mount_data(struct file_system_type *type, void *data)
+{
+   static struct mount local_mnt;
+   static int count = 0;
+   struct mount *mnt = _mnt;
+   struct dentry *root = 0;
+
+   /* XXX */
+   if (count != 0) return _mnt.mnt;
+   count++;
+
+   memset(mnt, 0, sizeof(struct mount));
+   if (!type)
+   return ERR_PTR(-ENODEV);
+   int flags = MS_KERNMOUNT;
+   char *name = (char *)type->name;
+
+   if (flags & MS_KERNMOUNT)
+   mnt->mnt.mnt_flags = MNT_INTERNAL;
+
+   root = type->mount(type, flags, name, data);
+   if (IS_ERR(root))
+   return ERR_CAST(root);
+
+   mnt->mnt.mnt_root = root;
+   mnt->mnt.mnt_sb = root->d_sb;
+   mnt->mnt_mountpoint = mnt->mnt.mnt_root;
+   mnt->mnt_parent = mnt;
+   /* DCE is monothreaded , so we do not care of lock here */
+   list_add_tail(>mnt_instance, >d_sb->s_mounts);
+
+   return >mnt;
+}
+void inode_wait_for_writeback(struct inode *inode)
+{
+}
+void truncate_inode_pages_final(struct address_space *mapping)
+{
+}
+int dirtytime_interval_handler(struct ctl_table *table, int write,
+  void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+   return -ENOSYS;
+}
+
+unsigned int nr_free_buffer_pages(void)
+{
+   return 1024;
+}
diff --git a/arch/lib/glue.c b/arch/lib/glue.c
new file mode 100644
index 000..93f72d1
--- /dev/null
+++ b/arch/lib/glue.c
@@ -0,0 +1,289 @@
+/*
+ * glue code for library version of Linux kernel
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ * Frederic Urbani
+ */
+
+#include /* loff_t */
+#include /* ESPIPE */
+#include   /* PAGE_CACHE_SIZE */
+#include/* NAME_MAX */
+#include/* struct kstatfs */
+#include   /* 

[PATCH v4 06/10] lib: sysctl handling (kernel glue code)

2015-04-26 Thread Hajime Tazaki
This interacts with fs/proc_fs.c for sysctl-like interface registed via
lib_init() API.

Signed-off-by: Hajime Tazaki 
---
 arch/lib/sysctl.c | 270 ++
 1 file changed, 270 insertions(+)
 create mode 100644 arch/lib/sysctl.c

diff --git a/arch/lib/sysctl.c b/arch/lib/sysctl.c
new file mode 100644
index 000..5f08f9f
--- /dev/null
+++ b/arch/lib/sysctl.c
@@ -0,0 +1,270 @@
+/*
+ * sysctl wrapper for library version of Linux kernel
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "sim-assert.h"
+#include "sim-types.h"
+
+int drop_caches_sysctl_handler(struct ctl_table *table, int write,
+  void *buffer, size_t *length, loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *table, int write,
+   void *buffer, size_t *length,
+   loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+int min_free_kbytes_sysctl_handler(struct ctl_table *table, int write,
+  void *buffer, size_t *length, loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+
+int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *table, int write,
+   void *buffer, size_t *length,
+   loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+int dirty_background_ratio_handler(struct ctl_table *table, int write,
+  void *buffer, size_t *lenp,
+  loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+int dirty_background_bytes_handler(struct ctl_table *table, int write,
+  void *buffer, size_t *lenp,
+  loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+int dirty_ratio_handler(struct ctl_table *table, int write,
+   void *buffer, size_t *lenp,
+   loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+int dirty_bytes_handler(struct ctl_table *table, int write,
+   void *buffer, size_t *lenp,
+   loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
+ void *buffer, size_t *length,
+ loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+int scan_unevictable_handler(struct ctl_table *table, int write,
+void __user *buffer,
+size_t *length, loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+int sched_rt_handler(struct ctl_table *table, int write,
+void __user *buffer, size_t *lenp,
+loff_t *ppos)
+{
+   lib_assert(false);
+   return 0;
+}
+
+int sysctl_overcommit_memory = OVERCOMMIT_GUESS;
+int sysctl_overcommit_ratio = 50;
+int sysctl_panic_on_oom = 0;
+int sysctl_oom_dump_tasks = 0;
+int sysctl_oom_kill_allocating_task = 0;
+int sysctl_nr_trim_pages = 0;
+int sysctl_drop_caches = 0;
+int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES - 1] = { 32 };
+unsigned int sysctl_sched_child_runs_first = 0;
+unsigned int sysctl_sched_compat_yield = 0;
+unsigned int sysctl_sched_rt_period = 100;
+int sysctl_sched_rt_runtime = 95;
+
+int vm_highmem_is_dirtyable;
+unsigned long vm_dirty_bytes = 0;
+int vm_dirty_ratio = 20;
+int dirty_background_ratio = 10;
+unsigned int dirty_expire_interval = 30 * 100;
+unsigned int dirty_writeback_interval = 5 * 100;
+unsigned long dirty_background_bytes = 0;
+int percpu_pagelist_fraction = 0;
+int panic_timeout = 0;
+int panic_on_oops = 0;
+int printk_delay_msec = 0;
+int panic_on_warn = 0;
+DEFINE_RATELIMIT_STATE(printk_ratelimit_state, 5 * HZ, 10);
+
+#define RESERVED_PIDS 300
+int pid_max = PID_MAX_DEFAULT;
+int pid_max_min = RESERVED_PIDS + 1;
+int pid_max_max = PID_MAX_LIMIT;
+int min_free_kbytes = 1024;
+int max_threads = 100;
+int laptop_mode = 0;
+
+#define DEFAULT_MESSAGE_LOGLEVEL 4
+#define MINIMUM_CONSOLE_LOGLEVEL 1
+#define DEFAULT_CONSOLE_LOGLEVEL 7
+int console_printk[4] = {
+   DEFAULT_CONSOLE_LOGLEVEL,   /* console_loglevel */
+   DEFAULT_MESSAGE_LOGLEVEL,   /* default_message_loglevel */
+   MINIMUM_CONSOLE_LOGLEVEL,   /* minimum_console_loglevel */
+   DEFAULT_CONSOLE_LOGLEVEL,   /* default_console_loglevel */
+};
+
+int print_fatal_signals = 0;
+unsigned int core_pipe_limit = 0;
+int core_uses_pid = 0;
+int vm_swappiness = 60;
+int nr_pdflush_threads = 0;
+unsigned long scan_unevictable_pages = 0;
+int suid_dumpable = 0;
+int page_cluster = 0;
+int block_dump = 

[PATCH v4 04/10] lib: time handling (kernel glue code)

2015-04-26 Thread Hajime Tazaki
timer related (internal) functions such as add_timer(),
do_gettimeofday() of kernel are trivially reimplemented
for libos. these eventually call the functions registered by lib_init()
API.

Signed-off-by: Hajime Tazaki 
---
 arch/lib/hrtimer.c | 122 +++
 arch/lib/tasklet-hrtimer.c |  57 +++
 arch/lib/time.c| 144 +++
 arch/lib/timer.c   | 238 +
 4 files changed, 561 insertions(+)
 create mode 100644 arch/lib/hrtimer.c
 create mode 100644 arch/lib/tasklet-hrtimer.c
 create mode 100644 arch/lib/time.c
 create mode 100644 arch/lib/timer.c

diff --git a/arch/lib/hrtimer.c b/arch/lib/hrtimer.c
new file mode 100644
index 000..4565b59
--- /dev/null
+++ b/arch/lib/hrtimer.c
@@ -0,0 +1,122 @@
+/*
+ * glue code for library version of Linux kernel
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ */
+
+#include 
+#include "sim-assert.h"
+#include "sim.h"
+
+/**
+ * hrtimer_init - initialize a timer to the given clock
+ * @timer:  the timer to be initialized
+ * @clock_id:   the clock to be used
+ * @mode:   timer mode abs/rel
+ */
+void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
+ enum hrtimer_mode mode)
+{
+   memset(timer, 0, sizeof(*timer));
+}
+static void trampoline(void *context)
+{
+   struct hrtimer *timer = context;
+   enum hrtimer_restart restart = timer->function(timer);
+
+   if (restart == HRTIMER_RESTART) {
+   void *event =
+   lib_event_schedule_ns(ktime_to_ns(timer->_softexpires),
+ , timer);
+   timer->base = event;
+   } else {
+   /* mark as completed. */
+   timer->base = 0;
+   }
+}
+/**
+ * hrtimer_start_range_ns - (re)start an hrtimer on the current CPU
+ * @timer:  the timer to be added
+ * @tim:expiry time
+ * @delta_ns:   "slack" range for the timer
+ * @mode:   expiry mode: absolute (HRTIMER_ABS) or relative (HRTIMER_REL)
+ *
+ * Returns:
+ *  0 on success
+ *  1 when the timer was active
+ */
+int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
+unsigned long delta_ns,
+const enum hrtimer_mode mode,
+int wakeup)
+{
+   int ret = hrtimer_cancel(timer);
+   s64 ns = ktime_to_ns(tim);
+   void *event;
+
+   if (mode == HRTIMER_MODE_ABS)
+   ns -= lib_current_ns();
+   timer->_softexpires = ns_to_ktime(ns);
+   event = lib_event_schedule_ns(ns, , timer);
+   timer->base = event;
+   return ret;
+}
+/**
+ * hrtimer_try_to_cancel - try to deactivate a timer
+ * @timer:  hrtimer to stop
+ *
+ * Returns:
+ *  0 when the timer was not active
+ *  1 when the timer was active
+ * -1 when the timer is currently excuting the callback function and
+ *cannot be stopped
+ */
+int hrtimer_try_to_cancel(struct hrtimer *timer)
+{
+   /* Note: we cannot return -1 from this function.
+  see comment in hrtimer_cancel. */
+   if (timer->base == 0)
+   /* timer was not active yet */
+   return 1;
+   lib_event_cancel(timer->base);
+   timer->base = 0;
+   return 0;
+}
+/**
+ * hrtimer_cancel - cancel a timer and wait for the handler to finish.
+ * @timer:  the timer to be cancelled
+ *
+ * Returns:
+ *  0 when the timer was not active
+ *  1 when the timer was active
+ */
+int hrtimer_cancel(struct hrtimer *timer)
+{
+   /* Note: because we assume a uniprocessor non-interruptible */
+   /* system when running in the kernel, we know that the timer */
+   /* is not running when we execute this code, so, know that */
+   /* try_to_cancel cannot return -1 and we don't need to retry */
+   /* the cancel later to wait for the handler to finish. */
+   int ret = hrtimer_try_to_cancel(timer);
+
+   lib_assert(ret >= 0);
+   return ret;
+}
+int
+hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
+{
+   return __hrtimer_start_range_ns(timer, tim, 0, mode, 1);
+}
+int hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
+  unsigned long delta_ns, const enum hrtimer_mode mode)
+{
+   return __hrtimer_start_range_ns(timer, tim, delta_ns, mode, 1);
+}
+
+int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp)
+{
+   *tp = ns_to_timespec(1);
+   return 0;
+}
diff --git a/arch/lib/tasklet-hrtimer.c b/arch/lib/tasklet-hrtimer.c
new file mode 100644
index 000..fef4902
--- /dev/null
+++ b/arch/lib/tasklet-hrtimer.c
@@ -0,0 +1,57 @@
+/*
+ * glue code for library version of Linux kernel
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ */
+
+#include 
+#include "sim.h"
+#include 

[PATCH v4 09/10] lib: libos build scripts and documentation

2015-04-26 Thread Hajime Tazaki
document and build scripts for libos architecture.

Signed-off-by: Hajime Tazaki 
Signed-off-by: Ryo Nakamura 
---
 Documentation/virtual/libos-howto.txt | 144 
 MAINTAINERS   |   9 +
 arch/lib/.gitignore   |   3 +
 arch/lib/Kconfig  | 124 +++
 arch/lib/Makefile | 224 
 arch/lib/Makefile.print   |  45 +++
 arch/lib/defconfig| 653 ++
 arch/lib/generate-linker-script.py|  50 +++
 8 files changed, 1252 insertions(+)
 create mode 100644 Documentation/virtual/libos-howto.txt
 create mode 100644 arch/lib/.gitignore
 create mode 100644 arch/lib/Kconfig
 create mode 100644 arch/lib/Makefile
 create mode 100644 arch/lib/Makefile.print
 create mode 100644 arch/lib/defconfig
 create mode 100755 arch/lib/generate-linker-script.py

diff --git a/Documentation/virtual/libos-howto.txt 
b/Documentation/virtual/libos-howto.txt
new file mode 100644
index 000..fbf7946
--- /dev/null
+++ b/Documentation/virtual/libos-howto.txt
@@ -0,0 +1,144 @@
+Library operating system (libos) version of Linux
+=
+
+* Overview
+
+New hardware independent architecture 'arch/lib', configured by
+CONFIG_LIB gives you two features.
+
+- network stack in userspace (NUSE)
+  NUSE will give you a personalized network stack for each application
+  without replacing host operating system.
+
+- network simulator integration, which is called Direct Code Execution (DCE)
+  DCE will give us a network simulation environment with Linux network stack
+  to investigate the detail behavior protocol implementation with a flexible
+  network configuration. This is also useful for the testing environment.
+
+(- more abstracted implementation of underlying platform will be a future
+   direction (e.g., rump hypercall))
+
+In both features, Linux kernel network stack is running on top of
+userspace application with a linked or dynamically loaded library.
+
+They have their own, isolated network stack from host operating system
+so they are configured different IP addresses as other virtualization
+methods do.
+
+
+* How different with others ?
+
+- User-mode Linux (UML)
+
+UML is a way to execute Linux kernel code as a userspace
+application. It is completely isolated from host kernel but can host
+arbitrary userspace applications on top of UML.
+
+- namespace / container
+
+Container technologies with namespace brings a process-level isolation
+to host multiple network entities but shares the kernel among
+processes, which prevents to introduce new features implemented in
+kernel space.
+
+
+* How to build it ?
+
+configuration of arch/lib follows a standard configuration of kernel.
+
+ make defconfig ARCH=lib
+
+or
+
+ make menuconfig ARCH=lib
+
+then you can build a set of libraries for libos.
+
+ make library ARCH=lib
+
+This will give you a shared library file liblinux-$(KERNELVERSION).so
+in the top directory.
+
+* Hello world
+
+you may first need to configure a configuration file, named
+'nuse.conf' so that the library version of network stack can know what
+kind of IP configuration should be used. There is an example file
+at arch/lib/nuse.conf.sample: you may copy and modify it for your purpose.
+
+ sudo NUSECONF=nuse.conf ./nuse ping www.google.com
+
+
+
+* Example use cases
+- regression test with Direct Code Execution (DCE)
+
+'make test' by DCE gives a test platform for networking code, with the
+help of network simulator facilities like link delay/bandwidth/drop
+configurations, large network topology with userspace routing protocol
+daemons, etc.
+
+An interesting feature is the determinism of any test executions. A
+test script always gives same results in every execution if there is
+no modification on test target code.
+
+For the first step, you need to obtain network simulator
+environment. 'make testbin' does all the stuff for the preparation.
+
+% make testbin -C tools/testing/libos
+
+Then, you can 'make test' for your code.
+
+% make test ARCH=lib
+
+ PASS: TestSuite netlink-socket
+ PASS: TestSuite process-manager
+ PASS: TestSuite dce-cradle
+ PASS: TestSuite dce-mptcp
+ PASS: TestSuite dce-umip
+ PASS: TestSuite dce-quagga
+ PASS: Example dce-tcp-simple
+ PASS: Example dce-udp-simple
+
+
+- userspace network stack (NUSE)
+
+an application can use its own network stack, distinct from host network stack
+in order to personalize any network feature to the application specific one.
+The 'nuse' wrapper script, based on LD_PRELOAD technique, carefully replaces
+socket API and redirects system calls to the network stack library, provided by
+this framework.
+
+the network stack can be used with any kind of raw-socket like
+technologies such as Intel DPDK, netmap, etc.
+
+
+
+* Files / External Repository
+
+The kernel source tree (i.e., arch/lib) only contains a shared part of
+applications (NUSE/DCE). Pure userspace part is 

[PATCH v4 08/10] lib: auxially files for auto-generated asm-generic files of libos

2015-04-26 Thread Hajime Tazaki
these files works as stubs in order to transparently run the other
kernel part (e.g., net/) on libos environment.

Signed-off-by: Hajime Tazaki 
---
 arch/lib/include/asm/Kbuild   | 57 +++
 arch/lib/include/asm/atomic.h | 50 ++
 arch/lib/include/asm/barrier.h|  8 +
 arch/lib/include/asm/bitsperlong.h| 16 ++
 arch/lib/include/asm/current.h|  7 +
 arch/lib/include/asm/elf.h| 10 ++
 arch/lib/include/asm/hardirq.h|  8 +
 arch/lib/include/asm/page.h   | 14 +
 arch/lib/include/asm/pgtable.h| 30 ++
 arch/lib/include/asm/processor.h  | 19 
 arch/lib/include/asm/ptrace.h |  4 +++
 arch/lib/include/asm/segment.h|  6 
 arch/lib/include/asm/sembuf.h |  4 +++
 arch/lib/include/asm/shmbuf.h |  4 +++
 arch/lib/include/asm/shmparam.h   |  4 +++
 arch/lib/include/asm/sigcontext.h |  6 
 arch/lib/include/asm/stat.h   |  4 +++
 arch/lib/include/asm/statfs.h |  4 +++
 arch/lib/include/asm/swab.h   |  7 +
 arch/lib/include/asm/thread_info.h| 36 ++
 arch/lib/include/asm/uaccess.h| 14 +
 arch/lib/include/asm/unistd.h |  4 +++
 arch/lib/include/uapi/asm/byteorder.h |  6 
 23 files changed, 322 insertions(+)
 create mode 100644 arch/lib/include/asm/Kbuild
 create mode 100644 arch/lib/include/asm/atomic.h
 create mode 100644 arch/lib/include/asm/barrier.h
 create mode 100644 arch/lib/include/asm/bitsperlong.h
 create mode 100644 arch/lib/include/asm/current.h
 create mode 100644 arch/lib/include/asm/elf.h
 create mode 100644 arch/lib/include/asm/hardirq.h
 create mode 100644 arch/lib/include/asm/page.h
 create mode 100644 arch/lib/include/asm/pgtable.h
 create mode 100644 arch/lib/include/asm/processor.h
 create mode 100644 arch/lib/include/asm/ptrace.h
 create mode 100644 arch/lib/include/asm/segment.h
 create mode 100644 arch/lib/include/asm/sembuf.h
 create mode 100644 arch/lib/include/asm/shmbuf.h
 create mode 100644 arch/lib/include/asm/shmparam.h
 create mode 100644 arch/lib/include/asm/sigcontext.h
 create mode 100644 arch/lib/include/asm/stat.h
 create mode 100644 arch/lib/include/asm/statfs.h
 create mode 100644 arch/lib/include/asm/swab.h
 create mode 100644 arch/lib/include/asm/thread_info.h
 create mode 100644 arch/lib/include/asm/uaccess.h
 create mode 100644 arch/lib/include/asm/unistd.h
 create mode 100644 arch/lib/include/uapi/asm/byteorder.h

diff --git a/arch/lib/include/asm/Kbuild b/arch/lib/include/asm/Kbuild
new file mode 100644
index 000..c647b1c
--- /dev/null
+++ b/arch/lib/include/asm/Kbuild
@@ -0,0 +1,57 @@
+generic-y += auxvec.h
+generic-y += bitops.h
+generic-y += bug.h
+generic-y += cache.h
+generic-y += cacheflush.h
+generic-y += checksum.h
+generic-y += cputime.h
+generic-y += cmpxchg.h
+generic-y += delay.h
+generic-y += device.h
+generic-y += div64.h
+generic-y += dma.h
+generic-y += exec.h
+generic-y += emergency-restart.h
+generic-y += errno.h
+generic-y += fcntl.h
+generic-y += ftrace.h
+generic-y += io.h
+generic-y += ioctl.h
+generic-y += ioctls.h
+generic-y += ipcbuf.h
+generic-y += irq.h
+generic-y += irqflags.h
+generic-y += irq_regs.h
+generic-y += kdebug.h
+generic-y += kmap_types.h
+generic-y += linkage.h
+generic-y += local.h
+generic-y += mcs_spinlock.h
+generic-y += mman.h
+generic-y += mmu.h
+generic-y += mmu_context.h
+generic-y += module.h
+generic-y += mutex.h
+generic-y += param.h
+generic-y += pci.h
+generic-y += percpu.h
+generic-y += poll.h
+generic-y += posix_types.h
+generic-y += preempt.h
+generic-y += resource.h
+generic-y += scatterlist.h
+generic-y += sections.h
+generic-y += setup.h
+generic-y += signal.h
+generic-y += siginfo.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += string.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += timex.h
+generic-y += tlbflush.h
+generic-y += types.h
+generic-y += topology.h
+generic-y += trace_clock.h
+generic-y += unaligned.h
diff --git a/arch/lib/include/asm/atomic.h b/arch/lib/include/asm/atomic.h
new file mode 100644
index 000..41a49285
--- /dev/null
+++ b/arch/lib/include/asm/atomic.h
@@ -0,0 +1,50 @@
+#ifndef _ASM_SIM_ATOMIC_H
+#define _ASM_SIM_ATOMIC_H
+
+#include 
+
+#if !defined(CONFIG_64BIT)
+typedef struct {
+   volatile long long counter;
+} atomic64_t;
+#endif
+
+#define ATOMIC64_INIT(i) { (i) }
+
+#define atomic64_read(v)(*(volatile long *)&(v)->counter)
+void atomic64_add(long i, atomic64_t *v);
+static inline void atomic64_sub(long i, atomic64_t *v)
+{
+   v->counter -= i;
+}
+static inline void atomic64_inc(atomic64_t *v)
+{
+   v->counter++;
+}
+int atomic64_sub_and_test(long i, atomic64_t *v);
+#define atomic64_dec(v)atomic64_sub(1LL, (v))
+int atomic64_dec_and_test(atomic64_t *v);
+int atomic64_inc_and_test(atomic64_t 

[PATCH v4 05/10] lib: context and scheduling functions (kernel glue code) for libos

2015-04-26 Thread Hajime Tazaki
contexnt primitives of kernel such as soft interupts, scheduling,
tasklet are implemented for libos. these functions eventually call the
functions registered by lib_init() API as well.

Signed-off-by: Hajime Tazaki 
---
 arch/lib/sched.c | 406 +++
 arch/lib/softirq.c   | 108 ++
 arch/lib/tasklet.c   |  76 ++
 arch/lib/workqueue.c | 242 ++
 4 files changed, 832 insertions(+)
 create mode 100644 arch/lib/sched.c
 create mode 100644 arch/lib/softirq.c
 create mode 100644 arch/lib/tasklet.c
 create mode 100644 arch/lib/workqueue.c

diff --git a/arch/lib/sched.c b/arch/lib/sched.c
new file mode 100644
index 000..98a568a
--- /dev/null
+++ b/arch/lib/sched.c
@@ -0,0 +1,406 @@
+/*
+ * glue code for library version of Linux kernel
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "lib.h"
+#include "sim.h"
+#include "sim-assert.h"
+
+/**
+   called by wait_event macro:
+   - prepare_to_wait
+   - schedule
+   - finish_wait
+ */
+
+struct SimTask *lib_task_create(void *private, unsigned long pid)
+{
+   struct SimTask *task = lib_malloc(sizeof(struct SimTask));
+   struct cred *cred;
+   struct nsproxy *ns;
+   struct user_struct *user;
+   struct thread_info *info;
+   struct pid *kpid;
+
+   if (!task)
+   return NULL;
+   memset(task, 0, sizeof(struct SimTask));
+   cred = lib_malloc(sizeof(struct cred));
+   if (!cred)
+   return NULL;
+   /* XXX: we could optimize away this allocation by sharing it
+  for all tasks */
+   ns = lib_malloc(sizeof(struct nsproxy));
+   if (!ns)
+   return NULL;
+   user = lib_malloc(sizeof(struct user_struct));
+   if (!user)
+   return NULL;
+   info = alloc_thread_info(>kernel_task);
+   if (!info)
+   return NULL;
+   kpid = lib_malloc(sizeof(struct pid));
+   if (!kpid)
+   return NULL;
+   kpid->numbers[0].nr = pid;
+   cred->fsuid = make_kuid(current_user_ns(), 0);
+   cred->fsgid = make_kgid(current_user_ns(), 0);
+   cred->user = user;
+   atomic_set(>usage, 1);
+   info->task = >kernel_task;
+   info->preempt_count = 0;
+   info->flags = 0;
+   atomic_set(>count, 1);
+   ns->uts_ns = 0;
+   ns->ipc_ns = 0;
+   ns->mnt_ns = 0;
+   ns->pid_ns_for_children = 0;
+   ns->net_ns = _net;
+   task->kernel_task.cred = cred;
+   task->kernel_task.pid = pid;
+   task->kernel_task.pids[PIDTYPE_PID].pid = kpid;
+   task->kernel_task.pids[PIDTYPE_PGID].pid = kpid;
+   task->kernel_task.pids[PIDTYPE_SID].pid = kpid;
+   task->kernel_task.nsproxy = ns;
+   task->kernel_task.stack = info;
+   /* this is a hack. */
+   task->kernel_task.group_leader = >kernel_task;
+   task->private = private;
+   return task;
+}
+void lib_task_destroy(struct SimTask *task)
+{
+   lib_free((void *)task->kernel_task.nsproxy);
+   lib_free((void *)task->kernel_task.cred);
+   lib_free((void *)task->kernel_task.cred->user);
+   free_thread_info(task->kernel_task.stack);
+   lib_free(task);
+}
+void *lib_task_get_private(struct SimTask *task)
+{
+   return task->private;
+}
+
+int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
+{
+   struct SimTask *task = lib_task_start((void (*)(void *))fn, arg);
+
+   return task->kernel_task.pid;
+}
+
+struct task_struct *get_current(void)
+{
+   struct SimTask *lib_task = lib_task_current();
+
+   return _task->kernel_task;
+}
+
+struct thread_info *current_thread_info(void)
+{
+   return task_thread_info(get_current());
+}
+struct thread_info *alloc_thread_info(struct task_struct *task)
+{
+   return lib_malloc(sizeof(struct thread_info));
+}
+void free_thread_info(struct thread_info *ti)
+{
+   lib_free(ti);
+}
+
+
+void __put_task_struct(struct task_struct *t)
+{
+   lib_free(t);
+}
+
+void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
+{
+   wait->flags &= ~WQ_FLAG_EXCLUSIVE;
+   list_add(>task_list, >task_list);
+}
+void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait)
+{
+   wait->flags |= WQ_FLAG_EXCLUSIVE;
+   list_add_tail(>task_list, >task_list);
+}
+void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
+{
+   if (wait->task_list.prev != LIST_POISON2)
+   list_del(>task_list);
+}
+void
+prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state)
+{
+   wait->flags |= WQ_FLAG_EXCLUSIVE;
+   if (list_empty(>task_list))
+   list_add_tail(>task_list, >task_list);
+   set_current_state(state);
+}
+void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
+{
+   unsigned long 

[PATCH v4 00/10] an introduction of Linux library operating system (LibOS)

2015-04-26 Thread Hajime Tazaki
This is the 4th version of Linux LibOS patchset which reflects a
couple of comments received from people.

changes from v3:
- Patch 09/10 ("lib: libos build scripts and documentation")
1) Remove RFC (now it's a proposal)
2) build environment cleanup (commented by Paul Bolle)
- Overall
3) change based tree from arnd/asm-generic to torvalds/linux.git
   (commented by Richard Weinberger)
4) rebased to Linux 4.1-rc1 (b787f68c36d49bb1d9236f403813641efa74a031)
5) change the title of cover letter a bit

changes from v2:
- Patch 02/11 ("slab: add private memory allocator header for arch/lib")
1) add new allocator named SLIB (Library Allocator): Patch 04/11 is integrated
   to 02 (commented by Christoph Lameter)
- Overall
2) rewrite commit log messages

changes from v1:
- Patch 01/11 ("sysctl: make some functions unstatic to access by arch/lib"):
1) add prefix ctl_table_ to newly publiced functions (commented by Joe Perches)
- Patch 08/11 ("lib: other kernel glue layer code"):
2) significantly reduce glue codes (stubs) (commented by Richard Weinberger)
- Others
3) adapt to linux-4.0.0
4) detect make dependency by Kbuild .cmd files

patchset history
-
[v3] : https://lkml.org/lkml/2015/4/19/63
[v2] : https://lkml.org/lkml/2015/4/17/140
[v1] : https://lkml.org/lkml/2015/3/24/254

This is an introduction of Linux library operating system (LibOS).

Our objective is to build the kernel network stack as a shared library
that can be linked to by userspace programs to provide network stack
personalization and testing facilities, and allow researchers to more
easily simulate complex network topologies of linux routers/hosts.

Although the architecture itself can virtualize various things, the
current design only focuses on the network stack. You can benefit
network stack feature such as TCP, UDP, SCTP, DCCP (IPv4 and IPv6),
Mobie IPv6, Multipath TCP (IPv4/IPv6, out-of-tree at the present
moment), and netlink with various userspace applications (quagga,
iproute2, iperf, wget, and thttpd).

== What is LibOS ? ==

The library exposes an entry point as API, which is lib_init(), in
order to connect userspace applications to the (userspace-version)
kernel network stack. The clock source, virtual struct net_device, and
scheduler are provided by caller while kernel resource like system
calls is provided by callee.

Once the LibOS is initialized via the API, userspace applications with
POSIX socket can use the system calls defined in LibOS by replacing
from the original socket-related symbols to the LibOS-specific
one. Then application can benefit the network stack of LibOS without
involving the host network stack.

Currently, there are two users of LibOS: Network Stack in Userspace
(NUSE) and ns-3 network simulatior with Direct Code Execution
(DCE). These codes are managed at an external repository(*1).


== How to use it ? ==

to build the library,
% make {defconfig,menuconfig} ARCH=lib

then, build it.
% make library ARCH=lib

You will see liblinux-$(KERNELVERSION).so in the top directory.

== More information ==

The crucial difference between UML (user-mode linux) and this approach
is that we allow multiple network stack instances to co-exist within a
single process with dlmopen(3) like linking for easy debugging.


These patches are also available on this branch:

git://github.com/libos-nuse/net-next-nuse.git for-linus-upstream-libos-v4

(based on the commit b787f68c36d49bb1d9236f403813641efa74a031 of 
torvalds/linux.git)


For further information, here is a slideset presented at the last
netdev0.1 conference.

http://www.slideshare.net/hajimetazaki/library-operating-system-for-linux-netdev01

I would appreciate any kind of your feedback regarding to upstream
this feature.

*1 https://github.com/libos-nuse/linux-libos-tools

Hajime Tazaki (10):
  sysctl: make some functions unstatic to access by arch/lib
  slab: add SLIB (Library memory allocator) for  arch/lib
  lib: public headers and API implementations for userspace programs
  lib: time handling (kernel glue code)
  lib: context and scheduling functions (kernel glue code) for libos
  lib: sysctl handling (kernel glue code)
  lib: other kernel glue layer code
  lib: auxially files for auto-generated asm-generic files of libos
  lib: libos build scripts and documentation
  lib: tools used for test scripts

 Documentation/virtual/libos-howto.txt | 144 
 MAINTAINERS   |   9 +
 arch/lib/.gitignore   |   3 +
 arch/lib/Kconfig  | 124 +++
 arch/lib/Makefile | 224 
 arch/lib/Makefile.print   |  45 +++
 arch/lib/capability.c |  25 ++
 arch/lib/defconfig| 653 ++
 arch/lib/filemap.c|  32 ++
 arch/lib/fs.c |  70 
 arch/lib/generate-linker-script.py|  50 +++
 arch/lib/glue.c   | 289 +++
 arch/lib/hrtimer.c   

[PATCH v4 02/10] slab: add SLIB (Library memory allocator) for arch/lib

2015-04-26 Thread Hajime Tazaki
add SLIB allocator for arch/lib (CONFIG_LIB) to wrap kmalloc and co.
This will bring user's own allocator of libos: malloc(3) etc.

Signed-off-by: Hajime Tazaki 
---
 include/linux/slab.h |   6 +-
 include/linux/slib_def.h |  21 +
 mm/Makefile  |   1 +
 mm/slab.h|   4 +
 mm/slib.c| 205 +++
 5 files changed, 236 insertions(+), 1 deletion(-)
 create mode 100644 include/linux/slib_def.h
 create mode 100644 mm/slib.c

diff --git a/include/linux/slab.h b/include/linux/slab.h
index ffd24c8..0288cf8 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -191,7 +191,7 @@ size_t ksize(const void *);
 #endif
 #endif
 
-#ifdef CONFIG_SLOB
+#if defined(CONFIG_SLOB) || defined(CONFIG_SLIB)
 /*
  * SLOB passes all requests larger than one page to the page allocator.
  * No kmalloc array is necessary since objects of different sizes can
@@ -356,6 +356,9 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int 
order)
 }
 #endif
 
+#ifdef CONFIG_SLIB
+#include 
+#else
 static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
 {
unsigned int order = get_order(size);
@@ -434,6 +437,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t 
flags)
}
return __kmalloc(size, flags);
 }
+#endif /* CONFIG_SLIB */
 
 /*
  * Determine size used for the nth kmalloc cache.
diff --git a/include/linux/slib_def.h b/include/linux/slib_def.h
new file mode 100644
index 000..d9fe7d5
--- /dev/null
+++ b/include/linux/slib_def.h
@@ -0,0 +1,21 @@
+#ifndef _LINUX_SLLB_DEF_H
+#define _LINUX_SLLB_DEF_H
+
+
+struct kmem_cache {
+   unsigned int object_size;
+   const char *name;
+   size_t size;
+   size_t align;
+   unsigned long flags;
+   void (*ctor)(void *);
+};
+
+void *__kmalloc(size_t size, gfp_t flags);
+void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
+static __always_inline void *kmalloc(size_t size, gfp_t flags)
+{
+   return __kmalloc(size, flags);
+}
+
+#endif /* _LINUX_SLLB_DEF_H */
diff --git a/mm/Makefile b/mm/Makefile
index 98c4eae..7d8314f 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_NUMA)+= mempolicy.o
 obj-$(CONFIG_SPARSEMEM)+= sparse.o
 obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o
 obj-$(CONFIG_SLOB) += slob.o
+obj-$(CONFIG_SLIB) += slib.o
 obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o
 obj-$(CONFIG_KSM) += ksm.o
 obj-$(CONFIG_PAGE_POISONING) += debug-pagealloc.o
diff --git a/mm/slab.h b/mm/slab.h
index 4c3ac12..2ea37c9 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -37,6 +37,10 @@ struct kmem_cache {
 #include 
 #endif
 
+#ifdef CONFIG_SLIB
+#include 
+#endif
+
 #include 
 
 /*
diff --git a/mm/slib.c b/mm/slib.c
new file mode 100644
index 000..37596862
--- /dev/null
+++ b/mm/slib.c
@@ -0,0 +1,205 @@
+/*
+ * Library Slab Allocator (SLIB)
+ *
+ * Copyright (c) 2015 INRIA, Hajime Tazaki
+ *
+ * Author: Mathieu Lacage 
+ * Hajime Tazaki 
+ */
+
+#include "sim.h"
+#include "sim-assert.h"
+#include 
+#include 
+#include 
+#include 
+
+/* glues */
+struct kmem_cache *files_cachep;
+
+void kfree(const void *p)
+{
+   unsigned long start;
+
+   if (p == 0)
+   return;
+   start = (unsigned long)p;
+   start -= sizeof(size_t);
+   lib_free((void *)start);
+}
+size_t ksize(const void *p)
+{
+   size_t *psize = (size_t *)p;
+
+   psize--;
+   return *psize;
+}
+void *__kmalloc(size_t size, gfp_t flags)
+{
+   void *p = lib_malloc(size + sizeof(size));
+   unsigned long start;
+
+   if (!p)
+   return NULL;
+
+   if (p != 0 && (flags & __GFP_ZERO))
+   lib_memset(p, 0, size + sizeof(size));
+   lib_memcpy(p, , sizeof(size));
+   start = (unsigned long)p;
+   return (void *)(start + sizeof(size));
+}
+
+void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller)
+{
+   return kmalloc(size, flags);
+}
+
+void *krealloc(const void *p, size_t new_size, gfp_t flags)
+{
+   void *ret;
+
+   if (!new_size) {
+   kfree(p);
+   return ZERO_SIZE_PTR;
+   }
+
+   ret = __kmalloc(new_size, flags);
+   if (ret && p != ret)
+   kfree(p);
+
+   return ret;
+}
+
+struct kmem_cache *
+kmem_cache_create(const char *name, size_t size, size_t align,
+ unsigned long flags, void (*ctor)(void *))
+{
+   struct kmem_cache *cache = kmalloc(sizeof(struct kmem_cache), flags);
+
+   if (!cache)
+   return NULL;
+   cache->name = name;
+   cache->size = size;
+   cache->align = align;
+   cache->flags = flags;
+   cache->ctor = ctor;
+   return cache;
+}
+void kmem_cache_destroy(struct kmem_cache *cache)
+{
+   kfree(cache);
+}
+int kmem_cache_shrink(struct kmem_cache *cache)
+{
+   return 1;
+}
+const char *kmem_cache_name(struct kmem_cache *cache)
+{
+   return cache->name;
+}
+void 

[PATCH v2]block:bounce: fix call inc_|dec_zone_page_state on different pages confuse value of NR_BOUNCE

2015-04-26 Thread Wang YanQing
Commit d2c5e30c9a1420902262aa923794d2ae4e0bc391
("[PATCH] zoned vm counters: conversion of nr_bounce to per zone counter")
convert statistic of nr_bounce to per zone and one global value in vm_stat,
but it call inc_|dec_zone_page_state on different pages, then different
zones, and cause us to get unexpected value of NR_BOUNCE.

Below is the result on my machine:
Mar  2 09:26:08 udknight kernel: [144766.778265] Mem-Info:
Mar  2 09:26:08 udknight kernel: [144766.778266] DMA per-cpu:
Mar  2 09:26:08 udknight kernel: [144766.778268] CPU0: hi:0, btch:   1 
usd:   0
Mar  2 09:26:08 udknight kernel: [144766.778269] CPU1: hi:0, btch:   1 
usd:   0
Mar  2 09:26:08 udknight kernel: [144766.778270] Normal per-cpu:
Mar  2 09:26:08 udknight kernel: [144766.778271] CPU0: hi:  186, btch:  31 
usd:   0
Mar  2 09:26:08 udknight kernel: [144766.778273] CPU1: hi:  186, btch:  31 
usd:   0
Mar  2 09:26:08 udknight kernel: [144766.778274] HighMem per-cpu:
Mar  2 09:26:08 udknight kernel: [144766.778275] CPU0: hi:  186, btch:  31 
usd:   0
Mar  2 09:26:08 udknight kernel: [144766.778276] CPU1: hi:  186, btch:  31 
usd:   0
Mar  2 09:26:08 udknight kernel: [144766.778279] active_anon:46926 
inactive_anon:287406 isolated_anon:0
Mar  2 09:26:08 udknight kernel: [144766.778279]  active_file:105085 
inactive_file:139432 isolated_file:0
Mar  2 09:26:08 udknight kernel: [144766.778279]  unevictable:653 dirty:0 
writeback:0 unstable:0
Mar  2 09:26:08 udknight kernel: [144766.778279]  free:178957 
slab_reclaimable:6419 slab_unreclaimable:9966
Mar  2 09:26:08 udknight kernel: [144766.778279]  mapped:4426 shmem:305277 
pagetables:784 bounce:0
Mar  2 09:26:08 udknight kernel: [144766.778279]  free_cma:0
Mar  2 09:26:08 udknight kernel: [144766.778286] DMA free:3324kB min:68kB 
low:84kB high:100kB active_anon:0kB inactive_anon:0kB active_file:0kB 
inactive_file:0kB unevictable:0kB isolated(anon):0kB isolated(file):0kB 
present:15976kB managed:15900kB mlocked:0kB dirty:0kB writeback:0kB mapped:0kB 
shmem:0kB slab_reclaimable:0kB slab_unreclaimable:0kB kernel_stack:0kB 
pagetables:0kB unstable:0kB bounce:0kB free_cma:0kB writeback_tmp:0kB 
pages_scanned:0 all_unreclaimable? yes
Mar  2 09:26:08 udknight kernel: [144766.778287] lowmem_reserve[]: 0 822 3754 
3754
Mar  2 09:26:08 udknight kernel: [144766.778293] Normal free:26828kB min:3632kB 
low:4540kB high:5448kB active_anon:4872kB inactive_anon:68kB active_file:1796kB 
inactive_file:1796kB unevictable:0kB isolated(anon):0kB isolated(file):0kB 
present:892920kB managed:842560kB mlocked:0kB dirty:0kB writeback:0kB 
mapped:0kB shmem:4144kB slab_reclaimable:25676kB slab_unreclaimable:39864kB 
kernel_stack:1944kB pagetables:3136kB unstable:0kB bounce:0kB free_cma:0kB 
writeback_tmp:0kB pages_scanned:2412612 all_unreclaimable? yes
Mar  2 09:26:08 udknight kernel: [144766.778294] lowmem_reserve[]: 0 0 23451 
23451
Mar  2 09:26:08 udknight kernel: [144766.778299] HighMem free:685676kB 
min:512kB low:3748kB high:6984kB active_anon:182832kB inactive_anon:1149556kB 
active_file:418544kB inactive_file:555932kB unevictable:2612kB 
isolated(anon):0kB isolated(file):0kB present:3001732kB managed:3001732kB 
mlocked:0kB dirty:0kB writeback:0kB mapped:17704kB shmem:1216964kB 
slab_reclaimable:0kB slab_unreclaimable:0kB kernel_stack:0kB pagetables:0kB 
unstable:0kB bounce:75771152kB free_cma:0kB writeback_tmp:0kB pages_scanned:0 
all_unreclaimable? no
Mar  2 09:26:08 udknight kernel: [144766.778300] lowmem_reserve[]: 0 0 0 0

You can see bounce:75771152kB for HighMem, but bounce:0 for lowmem and global.

This patch fix it.

Signed-off-by: Wang YanQing 
---
 Changes
 v1-v2: fix comment issue reported by Leon Romanovsky

 block/bounce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/bounce.c b/block/bounce.c
index ab21ba2..ed9dd80 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -221,8 +221,8 @@ bounce:
if (page_to_pfn(page) <= queue_bounce_pfn(q) && !force)
continue;
 
-   inc_zone_page_state(to->bv_page, NR_BOUNCE);
to->bv_page = mempool_alloc(pool, q->bounce_gfp);
+   inc_zone_page_state(to->bv_page, NR_BOUNCE);
 
if (rw == WRITE) {
char *vto, *vfrom;
-- 
1.8.5.6.2.g3d8a54e.dirty
--
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 3/3] mm: Defer flush of writable TLB entries

2015-04-26 Thread Rik van Riel
On 04/25/2015 01:45 PM, Mel Gorman wrote:
> If a PTE is unmapped and it's dirty then it was writable recently. Due
> to deferred TLB flushing, it's best to assume a writable TLB cache entry
> exists. With that assumption, the TLB must be flushed before any IO can
> start or the page is freed to avoid lost writes or data corruption. This
> patch defers flushing of potentially writable TLBs as long as possible.
> 
> Signed-off-by: Mel Gorman 

Reviewed-by: Rik van Riel 

-- 
All rights reversed
--
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 2/3] mm: Send one IPI per CPU to TLB flush multiple pages that were recently unmapped

2015-04-26 Thread Rik van Riel
On 04/25/2015 01:45 PM, Mel Gorman wrote:
> An IPI is sent to flush remote TLBs when a page is unmapped that was
> recently accessed by other CPUs. There are many circumstances where this
> happens but the obvious one is kswapd reclaiming pages belonging to a
> running process as kswapd and the task are likely running on separate CPUs.

> It's still a noticeable improvement with vmstat showing interrupts went
> from roughly 500K per second to 45K per second.
> 
> The patch will have no impact on workloads with no memory pressure or
> have relatively few mapped pages.
> 
> Signed-off-by: Mel Gorman 

Reviewed-by: Rik van Riel 


-- 
All rights reversed
--
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 1/2] md/raid5: split wait_for_stripe and introduce wait_for_quiesce

2015-04-26 Thread NeilBrown
On Mon, 27 Apr 2015 10:12:49 +0800 Yuanhan Liu 
wrote:

> On Mon, Apr 27, 2015 at 10:10:24AM +1000, NeilBrown wrote:
> > On Fri, 24 Apr 2015 21:39:03 +0800 Yuanhan Liu 
> > wrote:
> > 
> > > If I read code correctly, current wait_for_stripe actually has 2 usage:
> > > 
> > > - wait for there is enough free stripe cache, triggered when
> > >   get_free_stripe() failed. This is what wait_for_stripe intend
> > >   for literally.
> > > 
> > > - wait for quiesce == 0 or
> > >active_aligned_reads == 0 && active_stripes == 0
> > > 
> > >   It has nothing to do with wait_for_stripe literally, and releasing
> > >   an active stripe won't actually wake them up. On the contrary, wake_up
> > >   from under this case won't actually wake up the process waiting for
> > >   an free stripe being available.
> > 
> > I disagree.  Releasing an active stripe *will* (or *can*) wake up that third
> > case, as it decrements "active_stripes" which will eventually reach zero.
> > 
> > I don't think your new code will properly wake up a process which is waiting
> > for "active_stripes == 0".
> 
> Right, and thanks for pointing it out. So, is this enough?
> 
> ---
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 2d8fcc1..3f23035 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -383,6 +383,9 @@ static void release_inactive_stripe_list(struct
> r5conf *conf,
> }
> }
> }
> +
> +   if (!atomic_read(>active_stripes))
> +   wake_up(>wait_for_quiesce);
>  }
> 
>  /* should hold conf->device_lock already */
> 
> 
> Or, should I put it a bit ahead, trying to invoke 
> wake_up(>wait_for_quiesce)
> after each atomic_dec(>active_stripes)?
> 
>   if (atomic_dec_return(>active_stripes) == 0)
>   wake_up(>wait_for_quiesce);

I think the first version is fine.  While waiting for active_stripes to be
zero, ->quiesce is set to 2, and so no new stripes should get used.

> 
> > 
> > > 
> > > Hence, we'd better split wait_for_stripe, and here I introduce
> > > wait_for_quiesce for the second usage. The name may not well taken, or
> > > even taken wrongly. Feel free to correct me then.
> > > 
> > > This is also a prepare patch for next patch: make wait_for_stripe
> > > exclusive.
> > 
> > I think you have this commit description upside down :-)
> > 
> > The real motivation is that you are seeing contention on some spinlock and 
> > so
> > you want to split 'wait_for_stripe' up in to multiple wait_queues so that 
> > you
> > can use exclusive wakeup.  As this is the main motivation, it should be
> > stated first.
> > 
> > Then explain that 'wait_for_stripe' is used to wait for the array to enter 
> > or
> > leave the quiescent state, and also to wait for an available stripe in each
> > of the hash lists.
> > 
> > So this patch splits the first usage off into a separate wait_queue, and the
> > next patch will split the second usage into one waitqueue for each hash 
> > value.
> > 
> > Then explain just is what is needed for that first step.
> > 
> > When you put it that way around, the patch makes lots of sense.
> 
> It does, and thanks!
> 
> > 
> > So: could you please resubmit with the description the right way around, and
> 
> To make sure I followed you correctly, my patch order is correct(I mean,
> split lock first, and make wait_for_stripe per lock hash and exclusive
> second), and what I need to do is re-writing the commit log as you suggested,
> and fixing all issues you pointed out. Right?

Correct.

Thanks,
NeilBrown


> 
>   --yliu
> 
> > with an appropriate wakeup call to ensure raid5_quiesce is woken up when
> > active_stripes reaches zero?
> > 
> > Thanks,
> > NeilBrown
> > 
> > 
> > > 
> > > Signed-off-by: Yuanhan Liu 
> > > ---
> > >  drivers/md/raid5.c | 13 +++--
> > >  drivers/md/raid5.h |  1 +
> > >  2 files changed, 8 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> > > index 9716319..b7e385f 100644
> > > --- a/drivers/md/raid5.c
> > > +++ b/drivers/md/raid5.c
> > > @@ -667,7 +667,7 @@ get_active_stripe(struct r5conf *conf, sector_t 
> > > sector,
> > >   spin_lock_irq(conf->hash_locks + hash);
> > >  
> > >   do {
> > > - wait_event_lock_irq(conf->wait_for_stripe,
> > > + wait_event_lock_irq(conf->wait_for_quiesce,
> > >   conf->quiesce == 0 || noquiesce,
> > >   *(conf->hash_locks + hash));
> > >   sh = __find_stripe(conf, sector, conf->generation - previous);
> > > @@ -4725,7 +4725,7 @@ static void raid5_align_endio(struct bio *bi, int 
> > > error)
> > >raid_bi, 0);
> > >   bio_endio(raid_bi, 0);
> > >   if (atomic_dec_and_test(>active_aligned_reads))
> > > - wake_up(>wait_for_stripe);
> > > + wake_up(>wait_for_quiesce);
> > >   return;
> > >   }
> > >  
> > > @@ -4820,7 +4820,7 @@ 

Re: [PATCH v2] thermal: exynos: Add the support for Exynos5433 TMU

2015-04-26 Thread Chanwoo Choi
Hi Eduardo and Lukasz,

I checked this patch merged on linux-next.git.
But, this patch is not merged on Linux 4.1-rc1.

Thanks,
Chanwoo Choi

On 03/18/2015 04:39 PM, Lukasz Majewski wrote:
> Hi Chanwoo,
> 
>> Hi Lukasz,
>>
>> Genlty Ping.
> 
> I've got your patches at the back of my head :-)
> 
> I will try to review them today or tomorrow.
> 
>>
>> Best Regards,
>> Chanwoo Choi
>>
>> On 03/10/2015 11:23 AM, Chanwoo Choi wrote:
>>> This patch adds the support for Exynos5433's TMU (Thermal
>>> Management Unit). Exynos5433 has a little different register bit
>>> fields as following description:
>>> - Support the eight trip points for rising/falling interrupt by
>>> using two registers
>>> - Read the calibration type (1-point or 2-point) and sensor id from
>>> TRIMINFO register
>>> - Use a little different register address
>>>
>>> Cc: Zhang Rui 
>>> Cc: Eduardo Valentin 
>>> Cc: Lukasz Majewski 
>>> Signed-off-by: Chanwoo Choi 
>>> ---
>>> Changes from v1:
>>> (https://lkml.org/lkml/2015/2/26/234)
>>> - Add exynos5433_tmu_control() instead of using
>>> exynos7_tmu_control() on both Exynos5433 and Exynos7.
>>> - Separate the patches related to devicetree and then send send
>>> Exnos5433's tmu patches[1] with other Exynos5433 devicetree patches.
>>>   [1] https://lkml.org/lkml/2015/3/9/1036
>>>
>>>  drivers/thermal/samsung/exynos_tmu.c | 187
>>> ++-
>>> drivers/thermal/samsung/exynos_tmu.h |   1 + 2 files changed, 186
>>> insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/thermal/samsung/exynos_tmu.c
>>> b/drivers/thermal/samsung/exynos_tmu.c index 1d30b09..531f4b17
>>> 100644 --- a/drivers/thermal/samsung/exynos_tmu.c
>>> +++ b/drivers/thermal/samsung/exynos_tmu.c
>>> @@ -97,6 +97,32 @@
>>>  #define EXYNOS4412_MUX_ADDR_VALUE  6
>>>  #define EXYNOS4412_MUX_ADDR_SHIFT  20
>>>  
>>> +/* Exynos5433 specific registers */
>>> +#define EXYNOS5433_TMU_REG_CONTROL10x024
>>> +#define EXYNOS5433_TMU_SAMPLING_INTERVAL   0x02c
>>> +#define EXYNOS5433_TMU_COUNTER_VALUE0  0x030
>>> +#define EXYNOS5433_TMU_COUNTER_VALUE1  0x034
>>> +#define EXYNOS5433_TMU_REG_CURRENT_TEMP1   0x044
>>> +#define EXYNOS5433_THD_TEMP_RISE3_00x050
>>> +#define EXYNOS5433_THD_TEMP_RISE7_40x054
>>> +#define EXYNOS5433_THD_TEMP_FALL3_00x060
>>> +#define EXYNOS5433_THD_TEMP_FALL7_40x064
>>> +#define EXYNOS5433_TMU_REG_INTEN   0x0c0
>>> +#define EXYNOS5433_TMU_REG_INTPEND 0x0c8
>>> +#define EXYNOS5433_TMU_EMUL_CON0x110
>>> +#define EXYNOS5433_TMU_PD_DET_EN   0x130
>>> +
>>> +#define EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT16
>>> +#define EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT23
>>> +#define EXYNOS5433_TRIMINFO_SENSOR_ID_MASK \
>>> +   (0xf <<
>>> EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT) +#define
>>> EXYNOS5433_TRIMINFO_CALIB_SEL_MASK  BIT(23) +
>>> +#define EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING 0
>>> +#define EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING 1
>>> +
>>> +#define EXYNOS5433_PD_DET_EN   1
>>> +
>>>  /*exynos5440 specific registers*/
>>>  #define EXYNOS5440_TMU_S0_7_TRIM   0x000
>>>  #define EXYNOS5440_TMU_S0_7_CTRL   0x020
>>> @@ -484,6 +510,101 @@ out:
>>> return ret;
>>>  }
>>>  
>>> +static int exynos5433_tmu_initialize(struct platform_device *pdev)
>>> +{
>>> +   struct exynos_tmu_data *data = platform_get_drvdata(pdev);
>>> +   struct exynos_tmu_platform_data *pdata = data->pdata;
>>> +   struct thermal_zone_device *tz = data->tzd;
>>> +   unsigned int status, trim_info;
>>> +   unsigned int rising_threshold = 0, falling_threshold = 0;
>>> +   unsigned long temp, temp_hist;
>>> +   int ret = 0, threshold_code, i, sensor_id, cal_type;
>>> +
>>> +   status = readb(data->base + EXYNOS_TMU_REG_STATUS);
>>> +   if (!status) {
>>> +   ret = -EBUSY;
>>> +   goto out;
>>> +   }
>>> +
>>> +   trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
>>> +   sanitize_temp_error(data, trim_info);
>>> +
>>> +   /* Read the temperature sensor id */
>>> +   sensor_id = (trim_info &
>>> EXYNOS5433_TRIMINFO_SENSOR_ID_MASK)
>>> +   >>
>>> EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT;
>>> +   dev_info(>dev, "Temperature sensor ID: 0x%x\n",
>>> sensor_id); +
>>> +   /* Read the calibration mode */
>>> +   writel(trim_info, data->base + EXYNOS_TMU_REG_TRIMINFO);
>>> +   cal_type = (trim_info & EXYNOS5433_TRIMINFO_CALIB_SEL_MASK)
>>> +   >>
>>> EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT; +
>>> +   switch (cal_type) {
>>> +   case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING:
>>> +   pdata->cal_type = TYPE_ONE_POINT_TRIMMING;
>>> +   break;
>>> +   case EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING:
>>> +   pdata->cal_type = TYPE_TWO_POINT_TRIMMING;
>>> +   break;
>>> +   default:
>>> +   pdata->cal_type = 

linux-next: Tree for Apr 27

2015-04-26 Thread Stephen Rothwell
Hi all,

Changes since 20150424:

*crickets*

Non-merge commits (relative to Linus' tree): 681
 1010 files changed, 59579 insertions(+), 13623 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log files
in the Next directory.  Between each merge, the tree was built with
a ppc64_defconfig for powerpc and an allmodconfig for x86_64 and a
multi_v7_defconfig for arm. After the final fixups (if any), it is also
built with powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig and
allyesconfig (this fails its final link) and i386, sparc, sparc64 and arm
defconfig.

Below is a summary of the state of the merge.

I am currently merging 214 trees (counting Linus' and 30 trees of patches
pending for Linus' tree).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

$ git checkout master
$ git reset --hard stable
Merging origin/master (c8b3fd0ce313 Merge tag 'pm+acpi-4.1-rc1-2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm)
Merging fixes/master (b94d525e58dc Merge 
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net)
Merging kbuild-current/rc-fixes (c517d838eb7d Linux 4.0-rc1)
Merging arc-current/for-curr (e4140819dadc ARC: signal handling robustify)
Merging arm-current/fixes (6c5c2a01fcfd ARM: proc-arm94*.S: fix setup function)
Merging m68k-current/for-linus (b24f670b7f5b m68k/mac: Fix out-of-bounds array 
index in OSS IRQ source initialization)
Merging metag-fixes/fixes (0164a711c97b metag: Fix ioremap_wc/ioremap_cached 
build errors)
Merging mips-fixes/mips-fixes (1795cd9b3a91 Linux 3.16-rc5)
Merging powerpc-merge-mpe/fixes (2e826695d87c powerpc/mm: Fix build error with 
CONFIG_PPC_TRANSACTIONAL_MEM disabled)
Merging powerpc-merge/merge (c517d838eb7d Linux 4.0-rc1)
Merging sparc/master (acc455cffa75 sparc64: Setup sysfs to mark LDOM sockets, 
cores and threads correctly)
Merging net/master (a31196b07f80 net: rfs: fix crash in get_rps_cpus())
Merging ipsec/master (092a29a40bab vti6: fix uninit when using x-netns)
Merging sound-current/for-linus (e8191a8e4755 ALSA: hda - fix headset mic 
detection problem for one more machine)
Merging pci-current/for-linus (9fbbda5c8e0a ia64/PCI: Treat all host bridge 
Address Space Descriptors (even consumers) as windows)
Merging wireless-drivers/master (69628cd0652a Merge tag 
'iwlwifi-for-kalle-2015-03-30' of 
https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-fixes)
Merging driver-core.current/driver-core-linus (bc465aa9d045 Linux 4.0-rc5)
Merging tty.current/tty-linus (f22e6e847115 Linux 4.0-rc7)
Merging usb.current/usb-linus (f22e6e847115 Linux 4.0-rc7)
Merging usb-gadget-fixes/fixes (65582a7f4ce5 usb: isp1760: fix spin unlock in 
the error path of isp1760_udc_start)
Merging usb-serial-fixes/usb-linus (39a8804455fb Linux 4.0)
Merging staging.current/staging-linus (f22e6e847115 Linux 4.0-rc7)
Merging char-misc.current/char-misc-linus (bc465aa9d045 Linux 4.0-rc5)
Merging input-current/for-linus (48853389f206 Merge branch 'next' into 
for-linus)
Merging crypto-current/master (8c98ebd7a6ff crypto: img-hash - 
CRYPTO_DEV_IMGTEC_HASH should depend on HAS_DMA)
Merging ide/master (d681f1166919 ide: remove deprecated use of pci api)
Merging devicetree-current/devicetree/merge (41d9489319f2 drivers/of: Add empty 
ranges quirk for PA-Semi)
Merging rr-fixes/fixes (f47689345931 lguest: update help text.)
Merging vfio-fixes/for-linus (ec76f4007079 vfio-pci: Add missing break to 
enable VFIO_PCI_ERR_IRQ_INDEX)
Merging kselftest-fixes/fixes (67d8712dcc70 selftests: Fix build failures when 
invoked from kselftest target)
Merging drm-intel-fixes/for-linux-next-fixes (39a8804455fb Linux 4.0)
Merging asm-generic/master (643165c8bbc8 Merge tag 'uaccess_for_upstream' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost into asm-generic)
Merging arc/for-next (d8f6ad85cbb7 ARC: perf: don't add code for impossible 
case)
Merging arm/for-next (6b7acae74fc2 Merge branches 'misc' and 'vdso' into 
for-next)
Merging arm-perf/for-next/perf (39a8804455fb Linux 4.0)
Merging 

Re: [PATCH 2/2] md/raid5: exclusive wait_for_stripe

2015-04-26 Thread Yuanhan Liu
On Mon, Apr 27, 2015 at 10:24:05AM +1000, NeilBrown wrote:
> On Fri, 24 Apr 2015 21:39:04 +0800 Yuanhan Liu 
> wrote:
> 
> > I noticed heavy spin lock contention at get_active_stripe() with fsmark
> > multiple thread write workloads.
> > 
> > Here is how this hot contention comes from. We have limited stripes, and
> > it's a multiple thread write workload. Hence, those stripes will be taken
> > soon, which puts later processes to sleep for waiting free stripes. When
> > enough stripes(> 1/4 total stripes) are released, all process are woken,
> > trying to get the lock. But there is one only being able to get this lock
> > for each hash lock, making other processes spinning out there for acquiring
> > the lock.
> > 
> > Thus, it's effectiveless to wakeup all processes and let them battle for
> > a lock that permits one to access only each time. Instead, we could make
> > it be a exclusive wake up: wake up one process only. That avoids the heavy
> > spin lock contention naturally.
> > 
> > Here are some test results I have got with this patch applied(all test run
> > 3 times):
> > 
> > `fsmark.files_per_sec'
> > =
> > 
> > next-20150317 this patch
> > - -
> > metric_value ±stddev  metric_value ±stddev change  
> > testbox/benchmark/testcase-params
> > - -    
> > --
> >   25.600 ±0.0  92.700 ±2.5  262.1% 
> > ivb44/fsmark/1x-64t-4BRD_12G-RAID5-btrfs-4M-30G-fsyncBeforeClose
> >   25.600 ±0.0  77.800 ±0.6  203.9% 
> > ivb44/fsmark/1x-64t-9BRD_6G-RAID5-btrfs-4M-30G-fsyncBeforeClose
> >   32.000 ±0.0  93.800 ±1.7  193.1% 
> > ivb44/fsmark/1x-64t-4BRD_12G-RAID5-ext4-4M-30G-fsyncBeforeClose
> >   32.000 ±0.0  81.233 ±1.7  153.9% 
> > ivb44/fsmark/1x-64t-9BRD_6G-RAID5-ext4-4M-30G-fsyncBeforeClose
> >   48.800 ±14.5 99.667 ±2.0  104.2% 
> > ivb44/fsmark/1x-64t-4BRD_12G-RAID5-xfs-4M-30G-fsyncBeforeClose
> >6.400 ±0.0  12.800 ±0.0  100.0% 
> > ivb44/fsmark/1x-64t-3HDD-RAID5-btrfs-4M-40G-fsyncBeforeClose
> >   63.133 ±8.2  82.800 ±0.7   31.2% 
> > ivb44/fsmark/1x-64t-9BRD_6G-RAID5-xfs-4M-30G-fsyncBeforeClose
> >  245.067 ±0.7 306.567 ±7.9   25.1% 
> > ivb44/fsmark/1x-64t-4BRD_12G-RAID5-f2fs-4M-30G-fsyncBeforeClose
> >   17.533 ±0.3  21.000 ±0.8   19.8% 
> > ivb44/fsmark/1x-1t-3HDD-RAID5-xfs-4M-40G-fsyncBeforeClose
> >  188.167 ±1.9 215.033 ±3.1   14.3% 
> > ivb44/fsmark/1x-1t-4BRD_12G-RAID5-btrfs-4M-30G-NoSync
> >  254.500 ±1.8 290.733 ±2.4   14.2% 
> > ivb44/fsmark/1x-1t-9BRD_6G-RAID5-btrfs-4M-30G-NoSync
> > 
> > `time.system_time'
> > =
> > 
> > next-20150317 this patch
> > --
> > metric_value ±stddev metric_value ±stddev change   
> > testbox/benchmark/testcase-params
> > -- 
> > --
> > 7235.603 ±1.2 185.163 ±1.9  -97.4% 
> > ivb44/fsmark/1x-64t-4BRD_12G-RAID5-btrfs-4M-30G-fsyncBeforeClose
> > 7666.883 ±2.9 202.750 ±1.0  -97.4% 
> > ivb44/fsmark/1x-64t-9BRD_6G-RAID5-btrfs-4M-30G-fsyncBeforeClose
> >14567.893 ±0.7 421.230 ±0.4  -97.1% 
> > ivb44/fsmark/1x-64t-3HDD-RAID5-btrfs-4M-40G-fsyncBeforeClose
> > 3697.667 ±14.0148.190 ±1.7  -96.0% 
> > ivb44/fsmark/1x-64t-4BRD_12G-RAID5-xfs-4M-30G-fsyncBeforeClose
> > 5572.867 ±3.8 310.717 ±1.4  -94.4% 
> > ivb44/fsmark/1x-64t-9BRD_6G-RAID5-ext4-4M-30G-fsyncBeforeClose
> > 5565.050 ±0.5 313.277 ±1.5  -94.4% 
> > ivb44/fsmark/1x-64t-4BRD_12G-RAID5-ext4-4M-30G-fsyncBeforeClose
> > 2420.707 ±17.1171.043 ±2.7  -92.9% 
> > ivb44/fsmark/1x-64t-9BRD_6G-RAID5-xfs-4M-30G-fsyncBeforeClose
> > 3743.300 ±4.6 379.827 ±3.5  -89.9% 
> > ivb44/fsmark/1x-64t-3HDD-RAID5-ext4-4M-40G-fsyncBeforeClose
> > 3308.687 ±6.3 363.050 ±2.0  -89.0% 
> > ivb44/fsmark/1x-64t-3HDD-RAID5-xfs-4M-40G-fsyncBeforeClose
> > 
> > Where,
> > 
> >  1x: where 'x' means iterations or loop, corresponding to the 'L' 
> > option of fsmark
> > 
> >  1t, 64t: where 't' means thread
> > 
> >  4M: means the single file size, corresponding to the '-s' option of 
> > fsmark
> >  40G, 30G, 120G: means the 

Re: [PATCH 1/2] md/raid5: split wait_for_stripe and introduce wait_for_quiesce

2015-04-26 Thread Yuanhan Liu
On Mon, Apr 27, 2015 at 10:10:24AM +1000, NeilBrown wrote:
> On Fri, 24 Apr 2015 21:39:03 +0800 Yuanhan Liu 
> wrote:
> 
> > If I read code correctly, current wait_for_stripe actually has 2 usage:
> > 
> > - wait for there is enough free stripe cache, triggered when
> >   get_free_stripe() failed. This is what wait_for_stripe intend
> >   for literally.
> > 
> > - wait for quiesce == 0 or
> >active_aligned_reads == 0 && active_stripes == 0
> > 
> >   It has nothing to do with wait_for_stripe literally, and releasing
> >   an active stripe won't actually wake them up. On the contrary, wake_up
> >   from under this case won't actually wake up the process waiting for
> >   an free stripe being available.
> 
> I disagree.  Releasing an active stripe *will* (or *can*) wake up that third
> case, as it decrements "active_stripes" which will eventually reach zero.
> 
> I don't think your new code will properly wake up a process which is waiting
> for "active_stripes == 0".

Right, and thanks for pointing it out. So, is this enough?

---
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 2d8fcc1..3f23035 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -383,6 +383,9 @@ static void release_inactive_stripe_list(struct
r5conf *conf,
}
}
}
+
+   if (!atomic_read(>active_stripes))
+   wake_up(>wait_for_quiesce);
 }

 /* should hold conf->device_lock already */


Or, should I put it a bit ahead, trying to invoke 
wake_up(>wait_for_quiesce)
after each atomic_dec(>active_stripes)?

if (atomic_dec_return(>active_stripes) == 0)
wake_up(>wait_for_quiesce);

> 
> > 
> > Hence, we'd better split wait_for_stripe, and here I introduce
> > wait_for_quiesce for the second usage. The name may not well taken, or
> > even taken wrongly. Feel free to correct me then.
> > 
> > This is also a prepare patch for next patch: make wait_for_stripe
> > exclusive.
> 
> I think you have this commit description upside down :-)
> 
> The real motivation is that you are seeing contention on some spinlock and so
> you want to split 'wait_for_stripe' up in to multiple wait_queues so that you
> can use exclusive wakeup.  As this is the main motivation, it should be
> stated first.
> 
> Then explain that 'wait_for_stripe' is used to wait for the array to enter or
> leave the quiescent state, and also to wait for an available stripe in each
> of the hash lists.
> 
> So this patch splits the first usage off into a separate wait_queue, and the
> next patch will split the second usage into one waitqueue for each hash value.
> 
> Then explain just is what is needed for that first step.
> 
> When you put it that way around, the patch makes lots of sense.

It does, and thanks!

> 
> So: could you please resubmit with the description the right way around, and

To make sure I followed you correctly, my patch order is correct(I mean,
split lock first, and make wait_for_stripe per lock hash and exclusive
second), and what I need to do is re-writing the commit log as you suggested,
and fixing all issues you pointed out. Right?

--yliu

> with an appropriate wakeup call to ensure raid5_quiesce is woken up when
> active_stripes reaches zero?
> 
> Thanks,
> NeilBrown
> 
> 
> > 
> > Signed-off-by: Yuanhan Liu 
> > ---
> >  drivers/md/raid5.c | 13 +++--
> >  drivers/md/raid5.h |  1 +
> >  2 files changed, 8 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> > index 9716319..b7e385f 100644
> > --- a/drivers/md/raid5.c
> > +++ b/drivers/md/raid5.c
> > @@ -667,7 +667,7 @@ get_active_stripe(struct r5conf *conf, sector_t sector,
> > spin_lock_irq(conf->hash_locks + hash);
> >  
> > do {
> > -   wait_event_lock_irq(conf->wait_for_stripe,
> > +   wait_event_lock_irq(conf->wait_for_quiesce,
> > conf->quiesce == 0 || noquiesce,
> > *(conf->hash_locks + hash));
> > sh = __find_stripe(conf, sector, conf->generation - previous);
> > @@ -4725,7 +4725,7 @@ static void raid5_align_endio(struct bio *bi, int 
> > error)
> >  raid_bi, 0);
> > bio_endio(raid_bi, 0);
> > if (atomic_dec_and_test(>active_aligned_reads))
> > -   wake_up(>wait_for_stripe);
> > +   wake_up(>wait_for_quiesce);
> > return;
> > }
> >  
> > @@ -4820,7 +4820,7 @@ static int chunk_aligned_read(struct mddev *mddev, 
> > struct bio * raid_bio)
> > align_bi->bi_iter.bi_sector += rdev->data_offset;
> >  
> > spin_lock_irq(>device_lock);
> > -   wait_event_lock_irq(conf->wait_for_stripe,
> > +   wait_event_lock_irq(conf->wait_for_quiesce,
> > conf->quiesce == 0,
> > conf->device_lock);
> > atomic_inc(>active_aligned_reads);
> > 

Re: [PATCH v2] x86_64, asm: Work around AMD SYSRET SS descriptor attribute issue

2015-04-26 Thread H. Peter Anvin
In case it matters:

Acked-by: H. Peter Anvin 

On April 26, 2015 5:51:26 PM PDT, Linus Torvalds 
 wrote:
>Just a heads-up to the x86 people: I'm going to merge this directly,
>since I'm doing -rc1 momentarily, and without this patch 32-bit
>user-land on a 64-bit kernel is flaky on all AMD CPU's. Which I don't
>want for -rc1.
>
> Linus
>
>On Sun, Apr 26, 2015 at 4:47 PM, Andy Lutomirski 
>wrote:
>> AMD CPUs don't reinitialize the SS descriptor on SYSRET, so SYSRET
>> with SS == 0 results in an invalid usermode state in which SS is
>> apparently equal to __USER_DS but causes #SS if used.
>>
>> Work around the issue by setting SS to __KERNEL_DS __switch_to, thus
>> ensuring that SYSRET never happens with SS set to NULL.

-- 
Sent from my mobile phone.  Please pardon brevity and lack of formatting.
--
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/


Linux 4.1-rc1

2015-04-26 Thread Linus Torvalds
It's been a normal merge window, and I'm releasing according to the
normal schedule. The few days of travel didn't seem to matter, as I
had internet access at all times.

The merge window is pretty normal in terms of what got merged too.
Just eyeballing the size, it looks like this is going to fit right in
- while 4.0 was a bit smaller than usual, 4.1 seems to be smack dab in
the middle of the normal range for the last couple of years. And all
the patch statistics look normal as well: the bulk of the changes are
to drivers (just under 60% of the patch), with arch updates being
about 20% of it all, and the rest is spread all over.

No earth-shattering new features come to mind, even if initial support
for ACPI on arm64 looks funny. Depending on what you care about, your
notion of "big new feature" may differ from mine, of course. There's a
lot of work all over, and some of it might just make a big difference
to your use cases.

So go out and test. Even -rc1, as raw as it may sometimes be, has
tended to be pretty good. It's not that scary. Promise.

Linus

---

Al Viro (4):
vfs update
second vfs update
third hunk of vfs changes
fourth vfs update

Alex Williamson (1):
VFIO updates

Andrew Morton (3):
first patchbomb
second patchbomb
third patchbomb

Bjorn Helgaas (2):
PCI changes
PCI fixes

Bob Peterson (1):
GFS2 updates

Borislav Petkov (1):
EDAC updates

Brian Norris (1):
MTD updates

Bruce Fields (1):
nfsd updates

Bryan Wu (1):
LED subsystem updates

Chris Mason (2):
btrfs updates
btrfs fixes

Chris Metcalf (1):
arch/tile updates

Chris Zankel (1):
Xtensa updates

Darren Hart (1):
x86 platform driver updates

Dave Airlie (2):
drm updates
intel drm fixes

Dave Chinner (1):
xfs update

David Kleikamp (1):
jfs update

David Miller (6):
networking updates
sparc updates
networking fixes
IDE update
networking fixes
sparc fixes

David Vrabel (1):
xen features and fixes

David Woodhouse (1):
intel iommu updates

Dmitry Torokhov (2):
input subsystem updates
more input subsystem updates

Eric Biederman (1):
usernamespace mount fixes

Eric Van Hensbergen (1):
9pfs updates

Geert Uytterhoeven (1):
m68k updates

Grant Likely (1):
devicetree changes

Greg KH (5):
USB driver updates
driver core updates
staging driver updates
tty/serial updates
char/misc driver updates

Greg Ungerer (1):
m68k fixes

Guenter Roeck (1):
hwmon updates

Hans-Christian Egtvedt (1):
avr32 fix

Helge Deller (1):
parisc fixes

Herbert Xu (2):
crypto update
crypto fixes

Ingo Molnar (25):
EFI update
core locking changes
scheduler changes
timer updates
x86 apic changes
x86 asm changes
x86 boot changes
x86 build changes
x86 cleanups
x86 cacheinfo sysfs changes
x86 debug changes
x86 fpu changes
x86 microcode changes
x86 mm changes
x86 platform change
x86 RAS changes
x86 fix
x86 vdso changes
RCU changes
NOHZ changes
perf changes
locking fixes
perf updates
x86 fixes
PMEM driver

Jaegeuk Kim (1):
f2fs updates

James Bottomley (2):
SCSI updates
SCSI fixes

James Hogan (1):
Metag architecture updates

James Morris (1):
security subsystem updates

Jan Kara (1):
quota and udf updates

Jassi Brar (1):
mailbox updates

Jeff Layton (1):
file locking related changes

Jens Axboe (3):
block layer core bits
block driver updates
block core fix

Jesper Nilsson (1):
arch/cris updates

Jiri Kosina (3):
HID updates
trivial tree
livepatching updates

Joerg Roedel (1):
IOMMU updates

Jonathan Corbet (1):
documentation updates

Lee Jones (2):
MFD updates
backlight updates

Len Brown (1):
turbostat update

Ley Foon Tan (1):
arch/nios2 updates

Linus Walleij (3):
pincontrol updates
GPIO updates
pincontrol Kconfig fix

Marek Szyprowski (1):
DMA-mapping updates

Mark Brown (3):
regmap update
spi updates
regulator updates

Mark Salter (1):
arch/c6x fixes

Martin Schwidefsky (2):
s390 updates
more s390 updates

Mauro Carvalho Chehab (1):
media updates

Michael Ellerman (2):
powerpc updates
powerpc fixes

Michael Turquette (1):
clock framework updates

Michal Marek (2):
kbuild updates
kconfig updates

Mike Snitzer (1):
device mapper updates

Neil Brown (2):
md fixes
md updates

Nicholas Bellinger (1):
SCSI target updates

Ohad Ben-Cohen (1):
remoteproc update

Olof Johansson (10):
ARM SoC fixes
ARM SoC cleanups
ARM SoC platform updates
ARM DT updates
ARM SoC driver updates
ARM SoC multiplatform code changes
ARM SoC defconfig updates
ARM SoC 64-bit changes
ARM SoC late changes
chrome platform updates

Paolo Bonzini (2):
KVM updates
second batch of KVM 

Re: [alsa-devel] [PATCH v3 1/2] extcon: arizona: Add support for select accessory detect mode when headphone detection

2015-04-26 Thread Inha Song
Hi,

Thanks for your comments :)


On Sat, 25 Apr 2015 13:50:25 +0100
Charles Keepax  wrote:

> On Wed, Apr 22, 2015 at 08:23:20PM +0900, Inha Song wrote:
> > This patch add support for select accessory detect mode to HPDETL or HPDETR.
> > Arizona provides a headphone detection circuit on the HPDETL and HPDETR pins
> > to measure the impedance of an external load connected to the headphone.
> > 
> > Depending on board design, headphone detect pins can change to HPDETR or 
> > HPDETL.
> > 
> > Signed-off-by: Inha Song 
> > ---
> >  
> > +static int arizona_extcon_of_get_pdata(struct arizona *arizona)
> > +{
> > +   struct arizona_pdata *pdata = >pdata;
> > +   unsigned int val;
> 
> I would rather this is "unsigned int val =
> ARIZONA_ACCDET_MODE_HPL;".
> 
> > +
> > +   of_property_read_u32(arizona->dev->of_node, "wlf,hpdet-channel", );
> 
> Because this won't fill val if the DT entry isn't present.
> 
> > +   switch (val) {
> 
> Which means we hit this with val uninitialised.
> 
> > +   case ARIZONA_ACCDET_MODE_HPL:
> > +   case ARIZONA_ACCDET_MODE_HPR:
> 
> So we may select either channel at random.

Opps, Ok, I will set the default value to ARIZONA_ACCDET_MODE_HPL.

> 
> > +   pdata->hpdet_channel = val;
> > +   break;
> > +   default:
> > +   dev_err(arizona->dev,
> > +   "Wrong wlf,hpdet-channel DT value %d\n", val);
> 
> Or most likely just print an error but the DT being missing
> shouldn't really be an error it is an optional entry.

If the default value is set to ARIZONA_ACCDET_MODE_HPL,
Only the print will be shown, when an invalid value is set by DT.
So, This is a resonable error message.

Best Regards,
Inha Song.

> 
> > +   pdata->hpdet_channel = ARIZONA_ACCDET_MODE_HPL;
> > +   }
> > +
> > +   return 0;
> > +}
> 
> Thanks,
> Charles
--
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 3.10 27/31] deal with deadlock in d_walk()

2015-04-26 Thread Ben Hutchings
On Sun, 2015-04-26 at 15:49 +0200, Greg Kroah-Hartman wrote:
> 3.10-stable review patch.  If anyone has any objections, please let me know.
> 
> --
> 
> From: Al Viro 
> 
> commit ca5358ef75fc69fee5322a38a340f5739d997c10 upstream.
> 
> ... by not hitting rename_retry for reasons other than rename having
> happened.  In other words, do _not_ restart when finding that
> between unlocking the child and locking the parent the former got
> into __dentry_kill().  Skip the killed siblings instead...
> 
> Signed-off-by: Al Viro 
> Cc: Ben Hutchings 
> [hujianyang: Backported to 3.10 refer to the work of Ben Hutchings in 3.2:
>  - As we only have try_to_ascend() and not d_walk(), apply this
>change to all callers of try_to_ascend()
>  - Adjust context to make __dentry_kill() apply to d_kill()]
> Signed-off-by: hujianyang 
> Signed-off-by: Greg Kroah-Hartman 

This is broken; you need to fold in commit 20defcec264c from 3.2.y
("dcache: Fix locking bugs in backported "deal with deadlock in
d_walk()"").

Ben.

> ---
>  fs/dcache.c |  102 
> 
>  1 file changed, 62 insertions(+), 40 deletions(-)
> 
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -364,9 +364,9 @@ static struct dentry *d_kill(struct dent
>   __releases(parent->d_lock)
>   __releases(dentry->d_inode->i_lock)
>  {
> - list_del(>d_child);
> + __list_del_entry(>d_child);
>   /*
> -  * Inform try_to_ascend() that we are no longer attached to the
> +  * Inform ascending readers that we are no longer attached to the
>* dentry tree
>*/
>   dentry->d_flags |= DCACHE_DENTRY_KILLED;
> @@ -988,35 +988,6 @@ void shrink_dcache_for_umount(struct sup
>  }
>  
>  /*
> - * This tries to ascend one level of parenthood, but
> - * we can race with renaming, so we need to re-check
> - * the parenthood after dropping the lock and check
> - * that the sequence number still matches.
> - */
> -static struct dentry *try_to_ascend(struct dentry *old, int locked, unsigned 
> seq)
> -{
> - struct dentry *new = old->d_parent;
> -
> - rcu_read_lock();
> - spin_unlock(>d_lock);
> - spin_lock(>d_lock);
> -
> - /*
> -  * might go back up the wrong parent if we have had a rename
> -  * or deletion
> -  */
> - if (new != old->d_parent ||
> -  (old->d_flags & DCACHE_DENTRY_KILLED) ||
> -  (!locked && read_seqretry(_lock, seq))) {
> - spin_unlock(>d_lock);
> - new = NULL;
> - }
> - rcu_read_unlock();
> - return new;
> -}
> -
> -
> -/*
>   * Search for at least 1 mount point in the dentry's subdirs.
>   * We descend to the next level whenever the d_subdirs
>   * list is non-empty and continue searching.
> @@ -1070,17 +1041,32 @@ resume:
>   /*
>* All done at this level ... ascend and resume the search.
>*/
> + rcu_read_lock();
> +ascend:
>   if (this_parent != parent) {
>   struct dentry *child = this_parent;
> - this_parent = try_to_ascend(this_parent, locked, seq);
> - if (!this_parent)
> + this_parent = child->d_parent;
> +
> + spin_unlock(>d_lock);
> + spin_lock(_parent->d_lock);
> +
> + /* might go back up the wrong parent if we have had a rename. */
> + if (!locked && read_seqretry(_lock, seq))
>   goto rename_retry;
>   next = child->d_child.next;
> + while (unlikely(child->d_flags & DCACHE_DENTRY_KILLED)) {
> + if (next == _parent->d_subdirs)
> + goto ascend;
> + child = list_entry(next, struct dentry, d_child);
> + next = next->next;
> + }
> + rcu_read_unlock();
>   goto resume;
>   }
> - spin_unlock(_parent->d_lock);
>   if (!locked && read_seqretry(_lock, seq))
>   goto rename_retry;
> + spin_unlock(_parent->d_lock);
> + rcu_read_unlock();
>   if (locked)
>   write_sequnlock(_lock);
>   return 0; /* No mount points found in tree */
> @@ -1092,6 +1078,8 @@ positive:
>   return 1;
>  
>  rename_retry:
> + spin_unlock(_parent->d_lock);
> + rcu_read_unlock();
>   if (locked)
>   goto again;
>   locked = 1;
> @@ -1177,23 +1165,40 @@ resume:
>   /*
>* All done at this level ... ascend and resume the search.
>*/
> + rcu_read_lock();
> +ascend:
>   if (this_parent != parent) {
>   struct dentry *child = this_parent;
> - this_parent = try_to_ascend(this_parent, locked, seq);
> - if (!this_parent)
> + this_parent = child->d_parent;
> +
> + spin_unlock(>d_lock);
> + spin_lock(_parent->d_lock);
> +
> + /* might go back up the wrong parent if we have had a rename. */
> + if (!locked && 

RE: [PATCH 2/2] ARM: dts: Fix pinctrl settings for S2MPS11 RTC alarm IRQ on Arndale Octa

2015-04-26 Thread Kukjin Kim
Krzysztof Kozlowski wrote:
> 
> 2015-04-02 23:36 GMT+09:00 Krzysztof Kozlowski :
> > On Arndale Octa the S2MPS11 RTC alarm interrupt was not handled at all
> > because of wrong configuration of interrupt and gpx3-2.
> > 1. Interrupt is signaled by falling edge.
> > 2. This GPIO line is hard-wired on the board to PVDD_APIO_1V8 through a
> >resistor so pull-up/down must be disabled.
> >
> > Signed-off-by: Krzysztof Kozlowski 
> > ---
> >  arch/arm/boot/dts/exynos5420-arndale-octa.dts | 13 -
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> Dear Kukjin,
> 
> Any comments  on this and other patches. A lot of emails waits for
> your opinion. Is there anything I could do to help you in smooth
> review or applying?
> 
Sorry for the delay and looks good to me.

Will apply into fixes branch and thanks.

- Kukjin

> Best regards,
> Krzysztof
> 
> >
> > diff --git a/arch/arm/boot/dts/exynos5420-arndale-octa.dts 
> > b/arch/arm/boot/dts/exynos5420-arndale-
> octa.dts
> > index d78fcd997ce6..97346df31d41 100644
> > --- a/arch/arm/boot/dts/exynos5420-arndale-octa.dts
> > +++ b/arch/arm/boot/dts/exynos5420-arndale-octa.dts
> > @@ -87,7 +87,9 @@
> > s2mps11,buck4-ramp-enable = <1>;
> >
> > interrupt-parent = <>;
> > -   interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
> > +   interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
> > +   pinctrl-names = "default";
> > +   pinctrl-0 = <_irq>;
> >
> > s2mps11_osc: clocks {
> > #clock-cells = <1>;
> > @@ -379,3 +381,12 @@
> > clocks = < CLK_RTC>, <_osc S2MPS11_CLK_AP>;
> > clock-names = "rtc", "rtc_src";
> >  };
> > +
> > +_0 {
> > +   s2mps11_irq: s2mps11-irq {
> > +   samsung,pins = "gpx3-2";
> > +   samsung,pin-function = <0xf>;
> > +   samsung,pin-pud = <0>;
> > +   samsung,pin-drv = <0>;
> > +   };
> > +};
> > --
> > 1.9.1

--
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 v2] x86_64, asm: Work around AMD SYSRET SS descriptor attribute issue

2015-04-26 Thread Linus Torvalds
Just a heads-up to the x86 people: I'm going to merge this directly,
since I'm doing -rc1 momentarily, and without this patch 32-bit
user-land on a 64-bit kernel is flaky on all AMD CPU's. Which I don't
want for -rc1.

 Linus

On Sun, Apr 26, 2015 at 4:47 PM, Andy Lutomirski  wrote:
> AMD CPUs don't reinitialize the SS descriptor on SYSRET, so SYSRET
> with SS == 0 results in an invalid usermode state in which SS is
> apparently equal to __USER_DS but causes #SS if used.
>
> Work around the issue by setting SS to __KERNEL_DS __switch_to, thus
> ensuring that SYSRET never happens with SS set to NULL.
--
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/


[git pull] drm intel fixes

2015-04-26 Thread Dave Airlie

Hi Linus,

playing the race -rc1 game, nothing too urgent if this doesn't get in 
though, Jani sent it after I started my weekend so I felt I should send 
it on.

Just intel fixes 3 of them.

Dave.

The following changes since commit c8b3fd0ce313443731e8fd6d5a541085eb465f99:

  Merge tag 'pm+acpi-4.1-rc1-2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm (2015-04-26 
13:56:35 -0700)

are available in the git repository at:

  git://people.freedesktop.org/~airlied/linux drm-fixes

for you to fetch changes up to 59fd7e4b0b0769638b5162e56c28bbb027a118d3:

  Merge tag 'drm-intel-next-fixes-2015-04-25' of 
git://anongit.freedesktop.org/drm-intel into drm-fixes (2015-04-27 10:35:15 
+1000)


Dave Airlie (1):
  Merge tag 'drm-intel-next-fixes-2015-04-25' of 
git://anongit.freedesktop.org/drm-intel into drm-fixes

Dmitry Torokhov (1):
  drm/i915: cope with large i2c transfers

Imre Deak (1):
  drm/i915: vlv: fix save/restore of GFX_MAX_REQ_COUNT reg

Michel Thierry (1):
  drm/i915: Workaround to avoid lite restore with HEAD==TAIL

 drivers/gpu/drm/i915/i915_drv.c  |  4 +--
 drivers/gpu/drm/i915/i915_gem.c  |  3 +-
 drivers/gpu/drm/i915/i915_reg.h  |  1 +
 drivers/gpu/drm/i915/intel_i2c.c | 66 ++--
 drivers/gpu/drm/i915/intel_lrc.c | 35 -
 5 files changed, 95 insertions(+), 14 deletions(-)
--
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 2/2] md/raid5: exclusive wait_for_stripe

2015-04-26 Thread NeilBrown
On Fri, 24 Apr 2015 21:39:04 +0800 Yuanhan Liu 
wrote:

> I noticed heavy spin lock contention at get_active_stripe() with fsmark
> multiple thread write workloads.
> 
> Here is how this hot contention comes from. We have limited stripes, and
> it's a multiple thread write workload. Hence, those stripes will be taken
> soon, which puts later processes to sleep for waiting free stripes. When
> enough stripes(> 1/4 total stripes) are released, all process are woken,
> trying to get the lock. But there is one only being able to get this lock
> for each hash lock, making other processes spinning out there for acquiring
> the lock.
> 
> Thus, it's effectiveless to wakeup all processes and let them battle for
> a lock that permits one to access only each time. Instead, we could make
> it be a exclusive wake up: wake up one process only. That avoids the heavy
> spin lock contention naturally.
> 
> Here are some test results I have got with this patch applied(all test run
> 3 times):
> 
> `fsmark.files_per_sec'
> =
> 
> next-20150317 this patch
> - -
> metric_value ±stddev  metric_value ±stddev change  
> testbox/benchmark/testcase-params
> - -    
> --
>   25.600 ±0.0  92.700 ±2.5  262.1% 
> ivb44/fsmark/1x-64t-4BRD_12G-RAID5-btrfs-4M-30G-fsyncBeforeClose
>   25.600 ±0.0  77.800 ±0.6  203.9% 
> ivb44/fsmark/1x-64t-9BRD_6G-RAID5-btrfs-4M-30G-fsyncBeforeClose
>   32.000 ±0.0  93.800 ±1.7  193.1% 
> ivb44/fsmark/1x-64t-4BRD_12G-RAID5-ext4-4M-30G-fsyncBeforeClose
>   32.000 ±0.0  81.233 ±1.7  153.9% 
> ivb44/fsmark/1x-64t-9BRD_6G-RAID5-ext4-4M-30G-fsyncBeforeClose
>   48.800 ±14.5 99.667 ±2.0  104.2% 
> ivb44/fsmark/1x-64t-4BRD_12G-RAID5-xfs-4M-30G-fsyncBeforeClose
>6.400 ±0.0  12.800 ±0.0  100.0% 
> ivb44/fsmark/1x-64t-3HDD-RAID5-btrfs-4M-40G-fsyncBeforeClose
>   63.133 ±8.2  82.800 ±0.7   31.2% 
> ivb44/fsmark/1x-64t-9BRD_6G-RAID5-xfs-4M-30G-fsyncBeforeClose
>  245.067 ±0.7 306.567 ±7.9   25.1% 
> ivb44/fsmark/1x-64t-4BRD_12G-RAID5-f2fs-4M-30G-fsyncBeforeClose
>   17.533 ±0.3  21.000 ±0.8   19.8% 
> ivb44/fsmark/1x-1t-3HDD-RAID5-xfs-4M-40G-fsyncBeforeClose
>  188.167 ±1.9 215.033 ±3.1   14.3% 
> ivb44/fsmark/1x-1t-4BRD_12G-RAID5-btrfs-4M-30G-NoSync
>  254.500 ±1.8 290.733 ±2.4   14.2% 
> ivb44/fsmark/1x-1t-9BRD_6G-RAID5-btrfs-4M-30G-NoSync
> 
> `time.system_time'
> =
> 
> next-20150317 this patch
> --
> metric_value ±stddev metric_value ±stddev change   
> testbox/benchmark/testcase-params
> -- 
> --
> 7235.603 ±1.2 185.163 ±1.9  -97.4% 
> ivb44/fsmark/1x-64t-4BRD_12G-RAID5-btrfs-4M-30G-fsyncBeforeClose
> 7666.883 ±2.9 202.750 ±1.0  -97.4% 
> ivb44/fsmark/1x-64t-9BRD_6G-RAID5-btrfs-4M-30G-fsyncBeforeClose
>14567.893 ±0.7 421.230 ±0.4  -97.1% 
> ivb44/fsmark/1x-64t-3HDD-RAID5-btrfs-4M-40G-fsyncBeforeClose
> 3697.667 ±14.0148.190 ±1.7  -96.0% 
> ivb44/fsmark/1x-64t-4BRD_12G-RAID5-xfs-4M-30G-fsyncBeforeClose
> 5572.867 ±3.8 310.717 ±1.4  -94.4% 
> ivb44/fsmark/1x-64t-9BRD_6G-RAID5-ext4-4M-30G-fsyncBeforeClose
> 5565.050 ±0.5 313.277 ±1.5  -94.4% 
> ivb44/fsmark/1x-64t-4BRD_12G-RAID5-ext4-4M-30G-fsyncBeforeClose
> 2420.707 ±17.1171.043 ±2.7  -92.9% 
> ivb44/fsmark/1x-64t-9BRD_6G-RAID5-xfs-4M-30G-fsyncBeforeClose
> 3743.300 ±4.6 379.827 ±3.5  -89.9% 
> ivb44/fsmark/1x-64t-3HDD-RAID5-ext4-4M-40G-fsyncBeforeClose
> 3308.687 ±6.3 363.050 ±2.0  -89.0% 
> ivb44/fsmark/1x-64t-3HDD-RAID5-xfs-4M-40G-fsyncBeforeClose
> 
> Where,
> 
>  1x: where 'x' means iterations or loop, corresponding to the 'L' option 
> of fsmark
> 
>  1t, 64t: where 't' means thread
> 
>  4M: means the single file size, corresponding to the '-s' option of 
> fsmark
>  40G, 30G, 120G: means the total test size
> 
>  4BRD_12G: BRD is the ramdisk, where '4' means 4 ramdisk, and where '12G' 
> means
>the size of one ramdisk. So, it would be 48G in total. And we 
> made a
>raid on those ramdisk
> 
> As 

Re: [PATCH 1/2] md/raid5: split wait_for_stripe and introduce wait_for_quiesce

2015-04-26 Thread NeilBrown
On Fri, 24 Apr 2015 21:39:03 +0800 Yuanhan Liu 
wrote:

> If I read code correctly, current wait_for_stripe actually has 2 usage:
> 
> - wait for there is enough free stripe cache, triggered when
>   get_free_stripe() failed. This is what wait_for_stripe intend
>   for literally.
> 
> - wait for quiesce == 0 or
>active_aligned_reads == 0 && active_stripes == 0
> 
>   It has nothing to do with wait_for_stripe literally, and releasing
>   an active stripe won't actually wake them up. On the contrary, wake_up
>   from under this case won't actually wake up the process waiting for
>   an free stripe being available.

I disagree.  Releasing an active stripe *will* (or *can*) wake up that third
case, as it decrements "active_stripes" which will eventually reach zero.

I don't think your new code will properly wake up a process which is waiting
for "active_stripes == 0".

> 
> Hence, we'd better split wait_for_stripe, and here I introduce
> wait_for_quiesce for the second usage. The name may not well taken, or
> even taken wrongly. Feel free to correct me then.
> 
> This is also a prepare patch for next patch: make wait_for_stripe
> exclusive.

I think you have this commit description upside down :-)

The real motivation is that you are seeing contention on some spinlock and so
you want to split 'wait_for_stripe' up in to multiple wait_queues so that you
can use exclusive wakeup.  As this is the main motivation, it should be
stated first.

Then explain that 'wait_for_stripe' is used to wait for the array to enter or
leave the quiescent state, and also to wait for an available stripe in each
of the hash lists.

So this patch splits the first usage off into a separate wait_queue, and the
next patch will split the second usage into one waitqueue for each hash value.

Then explain just is what is needed for that first step.

When you put it that way around, the patch makes lots of sense.

So: could you please resubmit with the description the right way around, and
with an appropriate wakeup call to ensure raid5_quiesce is woken up when
active_stripes reaches zero?

Thanks,
NeilBrown


> 
> Signed-off-by: Yuanhan Liu 
> ---
>  drivers/md/raid5.c | 13 +++--
>  drivers/md/raid5.h |  1 +
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 9716319..b7e385f 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -667,7 +667,7 @@ get_active_stripe(struct r5conf *conf, sector_t sector,
>   spin_lock_irq(conf->hash_locks + hash);
>  
>   do {
> - wait_event_lock_irq(conf->wait_for_stripe,
> + wait_event_lock_irq(conf->wait_for_quiesce,
>   conf->quiesce == 0 || noquiesce,
>   *(conf->hash_locks + hash));
>   sh = __find_stripe(conf, sector, conf->generation - previous);
> @@ -4725,7 +4725,7 @@ static void raid5_align_endio(struct bio *bi, int error)
>raid_bi, 0);
>   bio_endio(raid_bi, 0);
>   if (atomic_dec_and_test(>active_aligned_reads))
> - wake_up(>wait_for_stripe);
> + wake_up(>wait_for_quiesce);
>   return;
>   }
>  
> @@ -4820,7 +4820,7 @@ static int chunk_aligned_read(struct mddev *mddev, 
> struct bio * raid_bio)
>   align_bi->bi_iter.bi_sector += rdev->data_offset;
>  
>   spin_lock_irq(>device_lock);
> - wait_event_lock_irq(conf->wait_for_stripe,
> + wait_event_lock_irq(conf->wait_for_quiesce,
>   conf->quiesce == 0,
>   conf->device_lock);
>   atomic_inc(>active_aligned_reads);
> @@ -5659,7 +5659,7 @@ static int  retry_aligned_read(struct r5conf *conf, 
> struct bio *raid_bio)
>   bio_endio(raid_bio, 0);
>   }
>   if (atomic_dec_and_test(>active_aligned_reads))
> - wake_up(>wait_for_stripe);
> + wake_up(>wait_for_quiesce);
>   return handled;
>  }
>  
> @@ -6390,6 +6390,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
>   goto abort;
>   spin_lock_init(>device_lock);
>   seqcount_init(>gen_lock);
> + init_waitqueue_head(>wait_for_quiesce);
>   init_waitqueue_head(>wait_for_stripe);
>   init_waitqueue_head(>wait_for_overlap);
>   INIT_LIST_HEAD(>handle_list);
> @@ -7413,7 +7414,7 @@ static void raid5_quiesce(struct mddev *mddev, int 
> state)
>* active stripes can drain
>*/
>   conf->quiesce = 2;
> - wait_event_cmd(conf->wait_for_stripe,
> + wait_event_cmd(conf->wait_for_quiesce,
>   atomic_read(>active_stripes) == 0 &&
>   atomic_read(>active_aligned_reads) == 
> 0,
>   unlock_all_device_hash_locks_irq(conf),
> @@ 

[PATCH v2] x86_64, asm: Work around AMD SYSRET SS descriptor attribute issue

2015-04-26 Thread Andy Lutomirski
AMD CPUs don't reinitialize the SS descriptor on SYSRET, so SYSRET
with SS == 0 results in an invalid usermode state in which SS is
apparently equal to __USER_DS but causes #SS if used.

Work around the issue by setting SS to __KERNEL_DS __switch_to, thus
ensuring that SYSRET never happens with SS set to NULL.

This was exposed by a recent vDSO cleanup.

Fixes: e7d6eefaaa44 x86/vdso32/syscall.S: Do not load __USER32_DS to %ss
Signed-off-by: Andy Lutomirski 
---

Changes since v1:
 - Improve comments per Denys' advice
 - Force SS to __KERNEL_DS -- don't just check for NULL.

Please apply my test case patch, too.

arch/x86/ia32/ia32entry.S |  7 +++
 arch/x86/include/asm/cpufeature.h |  1 +
 arch/x86/kernel/cpu/amd.c |  3 +++
 arch/x86/kernel/entry_64.S|  9 +
 arch/x86/kernel/process_64.c  | 28 
 5 files changed, 48 insertions(+)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 3c9fadf8b95c..c84b90bd30a7 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -421,6 +421,13 @@ sysretl_from_sys_call:
 * cs and ss are loaded from MSRs.
 * (Note: 32bit->32bit SYSRET is different: since r11
 * does not exist, it merely sets eflags.IF=1).
+*
+* NB: On AMD CPUs with the X86_BUG_SYSRET_SS_ATTRS bug, the ss
+* descriptor is not reinitialized.  This means that we must
+* avoid SYSRET with SS == NULL, which could happen if we schedule,
+* exit the kernel, and re-enter using an interrupt vector.  (All
+* interrupt entries on x86_64 set SS to NULL.)  We prevent that
+* from happening by reloading SS in __switch_to.
 */
USERGS_SYSRET32
 
diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 854c04b3c9c2..7e244f626301 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -257,6 +257,7 @@
 #define X86_BUG_11AP   X86_BUG(5) /* Bad local APIC aka 11AP */
 #define X86_BUG_FXSAVE_LEAKX86_BUG(6) /* FXSAVE leaks FOP/FIP/FOP */
 #define X86_BUG_CLFLUSH_MONITORX86_BUG(7) /* AAI65, CLFLUSH required 
before MONITOR */
+#define X86_BUG_SYSRET_SS_ATTRSX86_BUG(8) /* SYSRET doesn't fix up SS 
attrs */
 
 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
 
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index fd470ebf924e..e4cf63301ff4 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -720,6 +720,9 @@ static void init_amd(struct cpuinfo_x86 *c)
if (!cpu_has(c, X86_FEATURE_3DNOWPREFETCH))
if (cpu_has(c, X86_FEATURE_3DNOW) || cpu_has(c, X86_FEATURE_LM))
set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH);
+
+   /* AMD CPUs don't reset SS attributes on SYSRET */
+   set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
 }
 
 #ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 0034012d04ea..2a14b1568f8a 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -295,6 +295,15 @@ system_call_fastpath:
 * rflags from r11 (but RF and VM bits are forced to 0),
 * cs and ss are loaded from MSRs.
 * Restoration of rflags re-enables interrupts.
+*
+* NB: On AMD CPUs with the X86_BUG_SYSRET_SS_ATTRS bug, the ss
+* descriptor is not reinitialized.  This means that we should
+* avoid SYSRET with SS == NULL, which could happen if we schedule,
+* exit the kernel, and re-enter using an interrupt vector.  (All
+* interrupt entries on x86_64 set SS to NULL.)  We prevent that
+* from happening by reloading SS in __switch_to.  (Actually
+* detecting the failure in 64-bit userspace is tricky but can be
+* done.)
 */
USERGS_SYSRET64
 
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 4baaa972f52a..ddfdbf74f174 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -419,6 +419,34 @@ __switch_to(struct task_struct *prev_p, struct task_struct 
*next_p)
 task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV))
__switch_to_xtra(prev_p, next_p, tss);
 
+   if (static_cpu_has_bug(X86_BUG_SYSRET_SS_ATTRS)) {
+   /*
+* AMD CPUs have a misfeature: SYSRET sets the SS selector but
+* does not update the cached descriptor.  As a result, if we
+* do SYSRET while SS is NULL, we'll end up in user mode with
+* SS apparently equal to __USER_DS but actually unusable.
+*
+* The straightforward workaround would be to fix it up just
+* before SYSRET, but that would slow down the system call
+* fast paths.  Instead, we ensure that SS is never NULL in
+* system call context.  We do this by 

  1   2   3   4   5   6   7   8   >