Re: [PATCH v4 2/2] powerpc: Uprobes port to powerpc

2012-08-24 Thread Benjamin Herrenschmidt
On Fri, 2012-08-24 at 11:13 +1000, Michael Ellerman wrote:
> 
> Yeah. A NULL regs here is a kernel bug, so I think it's actually
> preferable to crash than silently return. 

Or best, if you think there's a remote chance that the bug might hit:

if (WARN(!regs))
return

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/3] powerpc: Consolidate *probe definitions

2012-08-24 Thread Ananth N Mavinakayanahalli
From: Ananth N Mavinakayanahalli 

Move is_trap() and relatives to a common file to be shared between *probes.
Code movement only; no change in functionality.

Suggested by Michael Ellerman.

Signed-off-by: Ananth N Mavinakayanahalli 
---
 arch/powerpc/include/asm/kprobes.h |   15 +
 arch/powerpc/include/asm/probes.h  |   42 +
 2 files changed, 44 insertions(+), 13 deletions(-)

Index: linux-tip-23aug/arch/powerpc/include/asm/kprobes.h
===
--- linux-tip-23aug.orig/arch/powerpc/include/asm/kprobes.h
+++ linux-tip-23aug/arch/powerpc/include/asm/kprobes.h
@@ -29,21 +29,16 @@
 #include 
 #include 
 #include 
+#include 
 
 #define  __ARCH_WANT_KPROBES_INSN_SLOT
 
 struct pt_regs;
 struct kprobe;
 
-typedef unsigned int kprobe_opcode_t;
-#define BREAKPOINT_INSTRUCTION 0x7fe8  /* trap */
+typedef opcode_t kprobe_opcode_t;
 #define MAX_INSN_SIZE 1
 
-#define IS_TW(instr)   (((instr) & 0xfc0007fe) == 0x7c08)
-#define IS_TD(instr)   (((instr) & 0xfc0007fe) == 0x7c88)
-#define IS_TDI(instr)  (((instr) & 0xfc00) == 0x0800)
-#define IS_TWI(instr)  (((instr) & 0xfc00) == 0x0c00)
-
 #ifdef CONFIG_PPC64
 /*
  * 64bit powerpc uses function descriptors.
@@ -72,12 +67,6 @@ typedef unsigned int kprobe_opcode_t;
addr = (kprobe_opcode_t *)kallsyms_lookup_name(dot_name); \
}   \
 }
-
-#define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \
-   IS_TWI(instr) || IS_TDI(instr))
-#else
-/* Use stock kprobe_lookup_name since ppc32 doesn't use function descriptors */
-#define is_trap(instr) (IS_TW(instr) || IS_TWI(instr))
 #endif
 
 #define flush_insn_slot(p) do { } while (0)
Index: linux-tip-23aug/arch/powerpc/include/asm/probes.h
===
--- /dev/null
+++ linux-tip-23aug/arch/powerpc/include/asm/probes.h
@@ -0,0 +1,42 @@
+#ifndef _ASM_POWERPC_PROBES_H
+#define _ASM_POWERPC_PROBES_H
+#ifdef __KERNEL__
+/*
+ * Definitions common to probes files
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright IBM Corporation, 2012
+ */
+#include 
+
+typedef u32 opcode_t;
+#define BREAKPOINT_INSTRUCTION 0x7fe8  /* trap */
+
+/* Trap definitions per ISA */
+#define IS_TW(instr)   (((instr) & 0xfc0007fe) == 0x7c08)
+#define IS_TD(instr)   (((instr) & 0xfc0007fe) == 0x7c88)
+#define IS_TDI(instr)  (((instr) & 0xfc00) == 0x0800)
+#define IS_TWI(instr)  (((instr) & 0xfc00) == 0x0c00)
+
+#ifdef CONFIG_PPC64
+#define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \
+   IS_TWI(instr) || IS_TDI(instr))
+#else
+#define is_trap(instr) (IS_TW(instr) || IS_TWI(instr))
+#endif /* CONFIG_PPC64 */
+
+#endif /* __KERNEL__ */
+#endif /* _ASM_POWERPC_PROBES_H */

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 2/3] powerpc: Add trap_nr to thread_struct

2012-08-24 Thread Ananth N Mavinakayanahalli
From: Ananth N Mavinakayanahalli 

Add thread_struct.trap_nr and use it to store the last exception
the thread experienced. In this patch, we populate the field at
various places where we force_sig_info() to the process.

This is also used in uprobes to determine if the probed instruction
caused an exception.

Signed-off-by: Ananth N Mavinakayanahalli 
---
 arch/powerpc/include/asm/processor.h |1 +
 arch/powerpc/kernel/process.c|2 ++
 arch/powerpc/kernel/traps.c  |1 +
 arch/powerpc/mm/fault.c  |1 +
 4 files changed, 5 insertions(+)

Index: linux-26jul/arch/powerpc/include/asm/processor.h
===
--- linux-26jul.orig/arch/powerpc/include/asm/processor.h
+++ linux-26jul/arch/powerpc/include/asm/processor.h
@@ -219,6 +219,7 @@ struct thread_struct {
 #endif /* CONFIG_HAVE_HW_BREAKPOINT */
 #endif
unsigned long   dabr;   /* Data address breakpoint register */
+   unsigned long   trap_nr;/* last trap # on this thread */
 #ifdef CONFIG_ALTIVEC
/* Complete AltiVec register set */
vector128   vr[32] __attribute__((aligned(16)));
Index: linux-26jul/arch/powerpc/kernel/process.c
===
--- linux-26jul.orig/arch/powerpc/kernel/process.c
+++ linux-26jul/arch/powerpc/kernel/process.c
@@ -258,6 +258,7 @@ void do_send_trap(struct pt_regs *regs, 
 {
siginfo_t info;
 
+   current->thread.trap_nr = signal_code;
if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
11, SIGSEGV) == NOTIFY_STOP)
return;
@@ -275,6 +276,7 @@ void do_dabr(struct pt_regs *regs, unsig
 {
siginfo_t info;
 
+   current->thread.trap_nr = TRAP_HWBKPT;
if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
11, SIGSEGV) == NOTIFY_STOP)
return;
Index: linux-26jul/arch/powerpc/kernel/traps.c
===
--- linux-26jul.orig/arch/powerpc/kernel/traps.c
+++ linux-26jul/arch/powerpc/kernel/traps.c
@@ -251,6 +251,7 @@ void _exception(int signr, struct pt_reg
if (arch_irqs_disabled() && !arch_irq_disabled_regs(regs))
local_irq_enable();
 
+   current->thread.trap_nr = code;
memset(&info, 0, sizeof(info));
info.si_signo = signr;
info.si_code = code;
Index: linux-26jul/arch/powerpc/mm/fault.c
===
--- linux-26jul.orig/arch/powerpc/mm/fault.c
+++ linux-26jul/arch/powerpc/mm/fault.c
@@ -133,6 +133,7 @@ static int do_sigbus(struct pt_regs *reg
up_read(¤t->mm->mmap_sem);
 
if (user_mode(regs)) {
+   current->thread.trap_nr = BUS_ADRERR;
info.si_signo = SIGBUS;
info.si_errno = 0;
info.si_code = BUS_ADRERR;

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v5 3/3] powerpc: Uprobes port to powerpc

2012-08-24 Thread Ananth N Mavinakayanahalli
From: Ananth N Mavinakayanahalli 

This is the port of uprobes to powerpc. Usage is similar to x86.

[root@ ~]# ./bin/perf probe -x /lib64/libc.so.6 malloc
Added new event:
  probe_libc:malloc(on 0xb4860)

You can now use it in all perf tools, such as:

perf record -e probe_libc:malloc -aR sleep 1

[root@ ~]# ./bin/perf record -e probe_libc:malloc -aR sleep 20
[ perf record: Woken up 22 times to write data ]
[ perf record: Captured and wrote 5.843 MB perf.data (~255302 samples) ]
[root@ ~]# ./bin/perf report --stdio
...

# Samples: 83K of event 'probe_libc:malloc'
# Event count (approx.): 83484
#
# Overhead   Command  Shared Object  Symbol
#     .  ..
#
69.05%   tar  libc-2.12.so   [.] malloc
28.57%rm  libc-2.12.so   [.] malloc
 1.32%  avahi-daemon  libc-2.12.so   [.] malloc
 0.58%  bash  libc-2.12.so   [.] malloc
 0.28%  sshd  libc-2.12.so   [.] malloc
 0.08%irqbalance  libc-2.12.so   [.] malloc
 0.05% bzip2  libc-2.12.so   [.] malloc
 0.04% sleep  libc-2.12.so   [.] malloc
 0.03%multipathd  libc-2.12.so   [.] malloc
 0.01%  sendmail  libc-2.12.so   [.] malloc
 0.01% automount  libc-2.12.so   [.] malloc

The trap_nr addition patch is a prereq.

Signed-off-by: Ananth N Mavinakayanahalli 
---

Tested on POWER6; I don't see anything here that should stop it from
working on a ppc32; since I don't have access to a ppc32 machine, it
would be good if somoene could verify that part.

TODO:
Testsuite for uprobes (Not powerpc specific).

V5:
a. Incorporated Oleg's suggestion to make arch_uprobe a union for
   easier deref of u32 on powerpc.
b. Incorporated various review comments by Michael Ellerman and
   Benjamin Herrenschmidt.

V4:
Enhance arch_analyze_uprobe_insn() to reject uprobes on trap variants.

V3:
Added abort_xol() logic for powerpc, using thread_struct.trap_nr to
determine if the stepped instruction caused an exception.

V2:
a. arch_uprobe_analyze_insn() now gets unsigned long addr.
b. Verified that mtmsr[d] and rfi[d] are handled correctly by
   emulate_step() (no changes to this patch).

 arch/powerpc/Kconfig   |3 
 arch/powerpc/include/asm/thread_info.h |4 
 arch/powerpc/include/asm/uprobes.h |   55 +
 arch/powerpc/kernel/Makefile   |1 
 arch/powerpc/kernel/signal.c   |6 +
 arch/powerpc/kernel/uprobes.c  |  184 +
 6 files changed, 252 insertions(+), 1 deletion(-)

Index: linux-tip-23aug/arch/powerpc/include/asm/thread_info.h
===
--- linux-tip-23aug.orig/arch/powerpc/include/asm/thread_info.h
+++ linux-tip-23aug/arch/powerpc/include/asm/thread_info.h
@@ -102,6 +102,7 @@ static inline struct thread_info *curren
 #define TIF_RESTOREALL 11  /* Restore all regs (implies NOERROR) */
 #define TIF_NOERROR12  /* Force successful syscall return */
 #define TIF_NOTIFY_RESUME  13  /* callback before returning to user */
+#define TIF_UPROBE 14  /* breakpointed or single-stepping */
 #define TIF_SYSCALL_TRACEPOINT 15  /* syscall tracepoint instrumentation */
 
 /* as above, but as bit values */
@@ -118,12 +119,13 @@ static inline struct thread_info *curren
 #define _TIF_RESTOREALL(1<
+ */
+
+#include 
+#include 
+
+typedef opcode_t uprobe_opcode_t;
+
+#define MAX_UINSN_BYTES4
+#define UPROBE_XOL_SLOT_BYTES  (MAX_UINSN_BYTES)
+
+/* The following alias is needed for reference from arch-agnostic code */
+#define UPROBE_SWBP_INSN   BREAKPOINT_INSTRUCTION
+#define UPROBE_SWBP_INSN_SIZE  4 /* swbp insn size in bytes */
+
+struct arch_uprobe {
+   union {
+   u8  insn[MAX_UINSN_BYTES];
+   u32 ainsn;
+   };
+};
+
+struct arch_uprobe_task {
+   unsigned long   saved_trap_nr;
+};
+
+extern int  arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct 
*mm, unsigned long addr);
+extern unsigned long uprobe_get_swbp_addr(struct pt_regs *regs);
+extern int  arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs);
+extern int  arch_uprobe_post_xol(struct arch_uprobe *aup, struct pt_regs 
*regs);
+extern bool arch_uprobe_xol_was_trapped(struct task_struct *tsk);
+extern int  arch_uprobe_exception_notify(struct notifier_block *self, unsigned 
long val, void *data);
+extern void arch_uprobe_abort_xol(struct arch_uprobe *aup, struct pt_regs 
*regs);
+#endif /* _ASM_UPROBES_H */
Index: linux-tip-23aug/arch/powerpc/kernel/Makefile
===
--- linux-tip-23aug.orig/arch/powerpc/kernel/Makefile
+++ linux-tip-23aug/arch/powerpc/kernel/Makefile
@@ -96,6 +96,7 @@ obj-$(CONFIG_MODULES) += ppc_ksyms.o
 obj-$(CONFIG_BOOTX_TEXT)   += btext.o
 obj-$(CONFIG_SMP)  +=

Re: [PATCH v4 2/2] powerpc: Uprobes port to powerpc

2012-08-24 Thread Ananth N Mavinakayanahalli
On Fri, Aug 24, 2012 at 05:07:31PM +1000, Benjamin Herrenschmidt wrote:
> On Fri, 2012-08-24 at 11:13 +1000, Michael Ellerman wrote:
> > 
> > Yeah. A NULL regs here is a kernel bug, so I think it's actually
> > preferable to crash than silently return. 
> 
> Or best, if you think there's a remote chance that the bug might hit:
> 
>   if (WARN(!regs))
>   return

Incorporated this and other suggestions from Michael in v5 I just
posted.

Ananth

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/2] powerpc: Fix xmon dl command for new printk implementation

2012-08-24 Thread Michael Ellerman
Since the printk internals were reworked the xmon 'dl' command which
dumps the content of __log_buf has stopped working.

It is now a structured buffer, so just dumping it doesn't really work.

Use the helpers added for kgdb to print out the content.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/xmon/xmon.c |   36 ++--
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index eab3492..013f286 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2148,40 +2149,23 @@ print_address(unsigned long addr)
 void
 dump_log_buf(void)
 {
-const unsigned long size = 128;
-unsigned long end, addr;
-unsigned char buf[size + 1];
-
-addr = 0;
-buf[size] = '\0';
+   struct kmsg_dumper dumper = { .active = 1 };
+   unsigned char buf[128];
+   size_t len;
 
 if (setjmp(bus_error_jmp) != 0) {
-printf("Unable to lookup symbol __log_buf!\n");
+   printf("Error dumping printk buffer!\n");
 return;
 }
 
 catch_memory_errors = 1;
 sync();
-addr = kallsyms_lookup_name("__log_buf");
-
-if (! addr)
-printf("Symbol __log_buf not found!\n");
-else {
-end = addr + (1 << CONFIG_LOG_BUF_SHIFT);
-while (addr < end) {
-if (! mread(addr, buf, size)) {
-printf("Can't read memory at address 0x%lx\n", 
addr);
-break;
-}
-
-printf("%s", buf);
 
-if (strlen(buf) < size)
-break;
-
-addr += size;
-}
-}
+   kmsg_dump_rewind_nolock(&dumper);
+   while (kmsg_dump_get_line_nolock(&dumper, false, buf, sizeof(buf), 
&len)) {
+   buf[len] = '\0';
+   printf("%s", buf);
+   }
 
 sync();
 /* wait a little while to see if we get a machine check */
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 2/2] powerpc: Fixup whitespace in xmon

2012-08-24 Thread Michael Ellerman
There are a few whitespace goolies in xmon.c, some of them appear to
be my fault. Fix them all in one go.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/xmon/xmon.c |   40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 013f286..9b49c65 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -895,13 +895,13 @@ cmds(struct pt_regs *excp)
 #endif
default:
printf("Unrecognized command: ");
-   do {
+   do {
if (' ' < cmd && cmd <= '~')
putchar(cmd);
else
printf("\\x%x", cmd);
cmd = inchar();
-   } while (cmd != '\n'); 
+   } while (cmd != '\n');
printf(" (type ? for help)\n");
break;
}
@@ -1098,7 +1098,7 @@ static long check_bp_loc(unsigned long addr)
return 1;
 }
 
-static char *breakpoint_help_string = 
+static char *breakpoint_help_string =
 "Breakpoint command usage:\n"
 "bshow breakpoints\n"
 "b  [cnt]   set breakpoint at given instr addr\n"
@@ -1194,7 +1194,7 @@ bpt_cmds(void)
 
default:
termch = cmd;
-   cmd = skipbl();
+   cmd = skipbl();
if (cmd == '?') {
printf(breakpoint_help_string);
break;
@@ -1360,7 +1360,7 @@ static void xmon_show_stack(unsigned long sp, unsigned 
long lr,
   sp + REGS_OFFSET);
break;
}
-printf("--- Exception: %lx %s at ", regs.trap,
+   printf("--- Exception: %lx %s at ", regs.trap,
   getvecname(TRAP(®s)));
pc = regs.nip;
lr = regs.link;
@@ -1624,14 +1624,14 @@ static void super_regs(void)
 
cmd = skipbl();
if (cmd == '\n') {
-   unsigned long sp, toc;
+   unsigned long sp, toc;
asm("mr %0,1" : "=r" (sp) :);
asm("mr %0,2" : "=r" (toc) :);
 
printf("msr  = "REG"  sprg0= "REG"\n",
   mfmsr(), mfspr(SPRN_SPRG0));
printf("pvr  = "REG"  sprg1= "REG"\n",
-  mfspr(SPRN_PVR), mfspr(SPRN_SPRG1)); 
+  mfspr(SPRN_PVR), mfspr(SPRN_SPRG1));
printf("dec  = "REG"  sprg2= "REG"\n",
   mfspr(SPRN_DEC), mfspr(SPRN_SPRG2));
printf("sp   = "REG"  sprg3= "REG"\n", sp, mfspr(SPRN_SPRG3));
@@ -1784,7 +1784,7 @@ byterev(unsigned char *val, int size)
 static int brev;
 static int mnoread;
 
-static char *memex_help_string = 
+static char *memex_help_string =
 "Memory examine command usage:\n"
 "m [addr] [flags] examine/change memory\n"
 "  addr is optional.  will start where left off.\n"
@@ -1799,7 +1799,7 @@ static char *memex_help_string =
 "NOTE: flags are saved as defaults\n"
 "";
 
-static char *memex_subcmd_help_string = 
+static char *memex_subcmd_help_string =
 "Memory examine subcommands:\n"
 "  hexval   write this val to current location\n"
 "  'string' write chars from string to this location\n"
@@ -2065,7 +2065,7 @@ prdump(unsigned long adrs, long ndump)
nr = mread(adrs, temp, r);
adrs += nr;
for (m = 0; m < r; ++m) {
-   if ((m & (sizeof(long) - 1)) == 0 && m > 0)
+   if ((m & (sizeof(long) - 1)) == 0 && m > 0)
putchar(' ');
if (m < nr)
printf("%.2x", temp[m]);
@@ -2073,7 +2073,7 @@ prdump(unsigned long adrs, long ndump)
printf("%s", fault_chars[fault_type]);
}
for (; m < 16; ++m) {
-   if ((m & (sizeof(long) - 1)) == 0)
+   if ((m & (sizeof(long) - 1)) == 0)
putchar(' ');
printf("  ");
}
@@ -2153,13 +2153,13 @@ dump_log_buf(void)
unsigned char buf[128];
size_t len;
 
-if (setjmp(bus_error_jmp) != 0) {
+   if (setjmp(bus_error_jmp) != 0) {
printf("Error dumping printk buffer!\n");
-return;
-}
+   return;
+   }
 
-catch_memory_errors = 1;
-sync();
+   catch_memory_errors = 1;
+   sync();
 
kmsg_dump_rewind_nolock(&dumper);
while (kmsg_dump_get_line_nolock(&dumper, false, buf, sizeof(buf), 
&len)) {
@@ -2167,10 +2167,10 @@ dump_log_buf(voi

Re: [PATCH] powerpc: dts: 52xx: drop critical IRQ from dts files

2012-08-24 Thread Wolfram Sang
On Thu, Aug 23, 2012 at 04:59:26PM +0100, Grant Likely wrote:
> On Thu, Aug 23, 2012 at 4:31 PM, Wolfram Sang  wrote:
> > The wakeup-gpios have been assigned a critical IRQ in current
> > devicetrees. The PIC driver does not support critical IRQs, though, which
> > leads to the following error when booting (a PCM030 in this case):
> >
> > mpc52xx_irqhost_map: invalid irq: virq=16, l1=0, l2=3
> > irq: irq-16==>hwirq-0x3 mapping failed: -22
> > [WARNing skipped]
> >
> > Remove these entries until they are supported, if ever.
> 
> The warning is a bug since the irq specifier is valid. Removing the
> irqs from the .dts files isn't the solution.

Adding another warning (not error) that critical IRQ are not supported
is?

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[git pull] Please pull powerpc.git merge branch

2012-08-24 Thread Benjamin Herrenschmidt
Hi Linus !

I meant to sent that earlier but got swamped with other things, so here
are some powerpc fixes for 3.6. A few regression fixes and some bug
fixes that I deemed should still make it.

There's a FSL update from Kumar with a bunch of defconfig updates along
with a few embedded fixes.

I also reverted my g5_defconfig update that I merged earlier as it was
completely busted, not too sure what happened there, I'll do a new one
later.

Cheers,
Ben.

The following changes since commit 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee:

  Linux 3.6-rc1 (2012-08-02 16:38:10 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc.git merge

for you to fetch changes up to 2c39bf49fd05305bea6d70670855047b2191d3f5:

  Revert "powerpc: Update g5_defconfig" (2012-08-24 20:55:55 +1000)


Aaro Koskinen (1):
  powerpc/dma-iommu: Fix IOMMU window check

Anton Blanchard (2):
  powerpc: POWER7 copy_to_user/copy_from_user patch applied twice
  powerpc: Fix VMX in interrupt check in POWER7 copy loops

Benjamin Herrenschmidt (1):
  Revert "powerpc: Update g5_defconfig"

Jia Hongtao (1):
  powerpc/fsl-pci: Only scan PCI bus if configured as a host

Jiri Kosina (1):
  powerpc: Fix personality handling in ppc64_personality()

Kim Phillips (2):
  powerpc/fsl: update defconfigs
  powerpc/fsl: fix "Failed to mount /dev: No such device" errors

Michael Ellerman (2):
  powerpc: Fix xmon dl command for new printk implementation
  powerpc: Fixup whitespace in xmon

Michael Neuling (2):
  powerpc: Fix null pointer deref in perf hardware breakpoints
  powerpc: Remove unnecessary ifdefs

Scott Wood (1):
  powerpc/mpic_msgr: Add missing includes

Shengzhou Liu (1):
  powerpc/p4080ds: dts - add usb controller version info and port0

Sukadev Bhattiprolu (1):
  powerpc/perf: Use pmc_overflow() to detect rolled back events

Tiejun Chen (4):
  booke/wdt: some ioctls do not return values properly
  powerpc/kgdb: Do not set kgdb_single_step on ppc
  powerpc/kgdb: Bail out of KGDB when we've been triggered
  powerpc/kgdb: Restore current_thread_info properly

Zhao Chenhui (1):
  powerpc/85xx: mpc85xx_defconfig - add VIA PATA support for MPC85xxCDS

 arch/powerpc/boot/dts/fsl/p4080si-post.dtsi  |7 ++
 arch/powerpc/configs/85xx/p1023rds_defconfig |   31 +++-
 arch/powerpc/configs/corenet32_smp_defconfig |   29 +++-
 arch/powerpc/configs/corenet64_smp_defconfig |1 +
 arch/powerpc/configs/g5_defconfig|  103 ++
 arch/powerpc/configs/mpc83xx_defconfig   |   18 ++---
 arch/powerpc/configs/mpc85xx_defconfig   |   33 +++--
 arch/powerpc/configs/mpc85xx_smp_defconfig   |   32 ++--
 arch/powerpc/include/asm/cputable.h  |2 -
 arch/powerpc/include/asm/mpic_msgr.h |1 +
 arch/powerpc/kernel/dma-iommu.c  |9 +--
 arch/powerpc/kernel/hw_breakpoint.c  |2 +-
 arch/powerpc/kernel/kgdb.c   |   27 ++-
 arch/powerpc/kernel/syscalls.c   |8 +-
 arch/powerpc/lib/copyuser_power7.S   |   35 +
 arch/powerpc/lib/memcpy_power7.S |4 +-
 arch/powerpc/perf/core-book3s.c  |2 +-
 arch/powerpc/sysdev/fsl_pci.c|   13 ++--
 arch/powerpc/sysdev/mpic_msgr.c  |3 +
 arch/powerpc/xmon/xmon.c |   84 +
 drivers/watchdog/booke_wdt.c |7 +-
 21 files changed, 209 insertions(+), 242 deletions(-)


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH][v2] powerpc/mm: using two zones for freescale 64 bit kernel

2012-08-24 Thread Shaohui Xie
PowerPC platform only supports ZONE_DMA zone for 64bit kernel, so all the
memory will be put into this zone. If the memory size is greater than
the device's DMA capability and device uses dma_alloc_coherent to allocate
memory, it will get an address which is over the device's DMA addressing,
the device will fail.

So we split the memory to two zones: zone ZONE_DMA32 & ZONE_NORMAL, since
we already allocate PCICSRBAR/PEXCSRBAR right below the 4G boundary (if the
lowest PCI address is above 4G), so we constrain the DMA zone ZONE_DMA32
to 2GB, also, we clear flag __GFP_DMA & __GFP_DMA32 and set __GFP_DMA32 only
if the device's dma_mask < total memory size. By doing this, devices which
cannot DMA all the memory will be limited to ZONE_DMA32, but devices which
can DMA all the memory will not be affected by this limitation.

Signed-off-by: Shaohui Xie 
Signed-off-by: Mingkai Hu 
Signed-off-by: Chen Yuanquan 
---
changes for v2:
1. use a config option for using two zones (ZONE_DMA32 & ZONE_NORMAL) in
freescale 64 bit kernel.

 arch/powerpc/Kconfig  |3 +++
 arch/powerpc/kernel/dma.c |   15 +++
 arch/powerpc/mm/mem.c |4 
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 352f416..a96fbbb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -629,6 +629,9 @@ config ZONE_DMA
bool
default y
 
+config ZONE_DMA32
+   def_bool (PPC64 && PPC_FSL_BOOK3E)
+
 config NEED_DMA_MAP_STATE
def_bool (PPC64 || NOT_COHERENT_CACHE)
 
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 355b9d8..cbf5ac1 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -41,9 +41,24 @@ void *dma_direct_alloc_coherent(struct device *dev, size_t 
size,
 #else
struct page *page;
int node = dev_to_node(dev);
+#ifdef CONFIG_ZONE_DMA32
+   phys_addr_t top_ram_pfn = memblock_end_of_DRAM();
 
+   /*
+* check for crappy device which has dma_mask < ZONE_DMA, and
+* we are not going to support it, just warn and fail.
+*/
+   if (*dev->dma_mask < DMA_BIT_MASK(31)) {
+   dev_err(dev, "Unsupported dma_mask 0x%llx\n", *dev->dma_mask);
+   return NULL;
+   }
/* ignore region specifiers */
+   flag  &= ~(__GFP_HIGHMEM | __GFP_DMA | __GFP_DMA32);
+   if (*dev->dma_mask < top_ram_pfn - 1)
+   flag |= __GFP_DMA32;
+#else
flag  &= ~(__GFP_HIGHMEM);
+#endif
 
page = alloc_pages_node(node, flag, get_order(size));
if (page == NULL)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index baaafde..2a11e49 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -280,6 +280,10 @@ void __init paging_init(void)
 #ifdef CONFIG_HIGHMEM
max_zone_pfns[ZONE_DMA] = lowmem_end_addr >> PAGE_SHIFT;
max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
+#elif defined CONFIG_ZONE_DMA32
+   max_zone_pfns[ZONE_DMA32] = min_t(phys_addr_t, top_of_ram,
+   1ull << 31) >> PAGE_SHIFT;
+   max_zone_pfns[ZONE_NORMAL] = top_of_ram >> PAGE_SHIFT;
 #else
max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
 #endif
-- 
1.6.4


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] kconfig: remove CONFIG_MTD_NAND_VERIFY_WRITE

2012-08-24 Thread Artem Bityutskiy
On Wed, 2012-08-15 at 17:12 +0800, Huang Shijie wrote:
> Just as Artem suggested:
> 
> "Both UBI and JFFS2 are able to read verify what they wrote already.
> There are also MTD tests which do this verification. So I think there
> is no reason to keep this in the NAND layer, let alone wasting RAM in
> the driver to support this feature."
> 
> So kill MTD_NAND_VERIFY_WRITE entirely. Please see the patch:
> http://lists.infradead.org/pipermail/linux-mtd/2012-August/043189.html
>   
> This patch removes the CONFIG_MTD_NAND_VERIFY_WRITE in the defconfigs.
> 
> 
> Signed-off-by: Huang Shijie 

Pushed to l2-mtd.git, thanks!

-- 
Best Regards,
Artem Bityutskiy


signature.asc
Description: This is a digitally signed message part
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/2] dt/misc: add bindings documentation for ifm camera sensor interface

2012-08-24 Thread Anatolij Gustschin
IFM O2D cameras use special sensor bus interface glue-logic to
connect camera sensors to mpc5200 LocalPlus bus. Add device tree
bindings documentation for it.

Signed-off-by: Anatolij Gustschin 
---
 Documentation/devicetree/bindings/misc/ifm-csi.txt |   41 
 1 files changed, 41 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/ifm-csi.txt

diff --git a/Documentation/devicetree/bindings/misc/ifm-csi.txt 
b/Documentation/devicetree/bindings/misc/ifm-csi.txt
new file mode 100644
index 000..5bdfffb
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/ifm-csi.txt
@@ -0,0 +1,41 @@
+IFM camera sensor interface on mpc5200 LocalPlus bus
+
+Required properties:
+- compatible: "ifm,o2d-csi"
+- reg: specifies sensor chip select number and associated address range
+- interrupts: external interrupt line number and interrupt sense mode
+  of the interrupt line signaling frame valid events
+- gpios: three gpio-specifiers for "capture", "reset" and "master enable"
+  GPIOs (strictly in this order).
+- ifm,csi-clk-handle: the phandle to a node in the DT describing the sensor
+  clock generator. This node is usually a general purpose timer controller.
+- ifm,csi-addr-bus-width: address bus width (valid values are 16, 24, 25)
+- ifm,csi-data-bus-width: data bus width (valid values are 8 and 16)
+- ifm,csi-wait-cycles: sensor bus wait cycles
+
+Optional properties:
+- ifm,csi-byte-swap: if this property is present, the byte swapping on
+  the bus will be enabled.
+
+Example:
+
+   csi@3,0 {
+   compatible = "ifm,o2d-csi";
+   reg = <3 0 0x0010>; /* CS 3, 1 MiB range */
+   interrupts = <1 1 2>;   /* IRQ1, edge falling */
+
+   ifm,csi-clk-handle = <&timer7>;
+   gpios = <&gpio_simple 23 0  /* image_capture */
+&gpio_simple 26 0  /* image_reset */
+&gpio_simple 29 0>;/* image_master_en */
+
+   ifm,csi-addr-bus-width = <24>;
+   ifm,csi-data-bus-width = <8>;
+   ifm,csi-wait-cycles = <0>;
+   };
+
+The base address of the used chip select is specified in the
+ranges property of the parent localbus node, for example:
+
+   ranges = <0 0 0xff00 0x0100
+ 3 0 0xe300 0x0010>;
-- 
1.7.1

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/2] powerpc/mpc5200: add dts files for ifm camera machines

2012-08-24 Thread Anatolij Gustschin
Add common o2d dtsi file to reuse it for other configurations.
Add machine compatible string to mpc5200 simple platform file.
Add dts files for O2D, O2I, O2MNT, O2DNT2, O2D300 and O3DNT boards.

Signed-off-by: Anatolij Gustschin 
---
 arch/powerpc/boot/dts/o2d.dts|   33 ++
 arch/powerpc/boot/dts/o2d.dtsi   |  139 ++
 arch/powerpc/boot/dts/o2d300.dts |   52 ++
 arch/powerpc/boot/dts/o2dnt2.dts |   48 +
 arch/powerpc/boot/dts/o2i.dts|   33 ++
 arch/powerpc/boot/dts/o2mnt.dts  |   33 ++
 arch/powerpc/boot/dts/o3dnt.dts  |   48 +
 arch/powerpc/platforms/52xx/mpc5200_simple.c |1 +
 8 files changed, 387 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/o2d.dts
 create mode 100644 arch/powerpc/boot/dts/o2d.dtsi
 create mode 100644 arch/powerpc/boot/dts/o2d300.dts
 create mode 100644 arch/powerpc/boot/dts/o2dnt2.dts
 create mode 100644 arch/powerpc/boot/dts/o2i.dts
 create mode 100644 arch/powerpc/boot/dts/o2mnt.dts
 create mode 100644 arch/powerpc/boot/dts/o3dnt.dts

diff --git a/arch/powerpc/boot/dts/o2d.dts b/arch/powerpc/boot/dts/o2d.dts
new file mode 100644
index 000..460064b
--- /dev/null
+++ b/arch/powerpc/boot/dts/o2d.dts
@@ -0,0 +1,33 @@
+/*
+ * O2D Device Tree Source
+ *
+ * Copyright (C) 2012 DENX Software Engineering
+ * Anatolij Gustschin 
+ *
+ * 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/ "o2d.dtsi"
+
+/ {
+   model = "ifm,o2d";
+   compatible = "ifm,o2d";
+
+   localbus {
+   flash@0,0 {
+   partition@6 {
+   label = "kernel";
+   reg = <0x0006 0x0026>;
+   read-only;
+   };
+   /* o2d specific partitions */
+partition@2c {
+label = "o2d user defined";
+reg = <0x002c 0x00d4>;
+};
+   };
+   };
+};
diff --git a/arch/powerpc/boot/dts/o2d.dtsi b/arch/powerpc/boot/dts/o2d.dtsi
new file mode 100644
index 000..3444eb8
--- /dev/null
+++ b/arch/powerpc/boot/dts/o2d.dtsi
@@ -0,0 +1,139 @@
+/*
+ * O2D base Device Tree Source
+ *
+ * Copyright (C) 2012 DENX Software Engineering
+ * Anatolij Gustschin 
+ *
+ * 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/ "mpc5200b.dtsi"
+
+/ {
+   model = "ifm,o2d";
+   compatible = "ifm,o2d";
+
+   memory {
+   reg = <0x 0x0400>;  // 64MB
+   };
+
+   soc5200@f000 {
+
+   gpio_simple: gpio@b00 {
+   };
+
+   timer@600 { // General Purpose Timer
+   #gpio-cells = <2>;
+   gpio-controller;
+   fsl,has-wdt;
+   fsl,wdt-on-boot = <0>;
+   };
+
+   timer@610 {
+   #gpio-cells = <2>;
+   gpio-controller;
+   };
+
+   timer7: timer@670 {
+   };
+
+   rtc@800 {
+   status = "disabled";
+   };
+
+   psc@2000 {  // PSC1
+   compatible = 
"fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   cell-index = <0>;
+
+   spidev@0 {
+   compatible = "spidev";
+   spi-max-frequency = <25>;
+   reg = <0>;
+   };
+   };
+
+   psc@2200 {  // PSC2
+   status = "disabled";
+   };
+
+   psc@2400 {  // PSC3
+   status = "disabled";
+   };
+
+   psc@2600 {  // PSC4
+   compatible = 
"fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
+   };
+
+   psc@2800 {  // PSC5
+   compatible = 
"fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
+   };
+
+   psc@2c00 {  // PSC6
+   status = "disabled";
+   };
+
+   ethernet@3000 {
+   phy-handle = <&phy0>;
+   };

Re: [PATCH] rapidio/tsi721: modify mport name assignment

2012-08-24 Thread Andrew Morton
On Tue, 21 Aug 2012 10:23:54 -0400
Alexandre Bounine  wrote:

> Modify mport device name assignment to provide clear reference to devices
> in systems with multiple Tsi721 bridges.
> 
> This patch is applicable to kernel versions starting from v3.2.

This seems to imply that you think the patch should be backported into
earlier kernels.  But no reason for doing this was provided.

> --- a/drivers/rapidio/devices/tsi721.c
> +++ b/drivers/rapidio/devices/tsi721.c
> @@ -2165,7 +2165,8 @@ static int __devinit tsi721_setup_mport(struct 
> tsi721_device *priv)
>   rio_init_dbell_res(&mport->riores[RIO_DOORBELL_RESOURCE], 0, 0x);
>   rio_init_mbox_res(&mport->riores[RIO_INB_MBOX_RESOURCE], 0, 3);
>   rio_init_mbox_res(&mport->riores[RIO_OUTB_MBOX_RESOURCE], 0, 3);
> - strcpy(mport->name, "Tsi721 mport");
> + snprintf(mport->name, RIO_MAX_MPORT_NAME, "%s(%s)",
> +  dev_driver_string(&pdev->dev), dev_name(&pdev->dev));

And it's a non-back-compatible change to a userspace-visible interface!
As such we'd need extraordinary justification to merge it into
*future* kernels, let alone backport it.

Please, do provide much better changelogging than this.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] rapidio: apply RX/TX enable to active switch ports only

2012-08-24 Thread Andrew Morton
On Tue, 21 Aug 2012 10:23:55 -0400
Alexandre Bounine  wrote:

> Modify RIO enumeration to apply RX/TX enable operations only to active
> switch ports. This will leave inactive ports in condition consistent with
> their state.

It's unclear (to me) what the effects of this are.  Does it fix some
user-visible malfunction?  Or is it just some nice-to-have thing?  Or
what?

> This patch is applicable to kernel versions starting from v2.6.35.

Is that a recommendation that such a backport be performed?  If so,
please provide the reasoning.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] powerpc: Make sure IPI handlers see data written by IPI senders

2012-08-24 Thread Paul Mackerras
We have been observing hangs, both in KVM guest vcpus and more
generally, where a process that is woken doesn't properly wake up and
continue to run, but instead sticks in TASK_WAKING state.  This
happens because the update of rq->wake_list in ttwu_queue_remote()
is not ordered with the update of ipi_message in
smp_muxed_ipi_message_pass(), and the reading of rq->wake_list in
scheduler_ipi() is not ordered with the reading of ipi_message in
smp_ipi_demux().  Thus it is possible for the IPI receiver not to see
the updated rq->wake_list and therefore conclude that there is nothing
for it to do.

In order to make sure that anything done before calling
smp_send_reschedule() is ordered before anything done in the resulting
call to scheduler_ipi(), this adds barriers in
smp_muxed_message_pass() and smp_ipi_demux().  The barrier in
smp_muxed_message_pass() is a full barrier to ensure that there is a
full ordering between the smp_send_reschedule() caller and
scheduler_ipi().  In smp_ipi_demux(), we use xchg() rather than
xchg_local() because xchg() includes release and acquire barriers.
Using xchg() rather than xchg_local() makes sense given that
ipi_message is not just accessed locally.

These changes made no measurable difference to the speed of IPIs as
measured using a simple ping-pong latency test across two CPUs on
different cores of a POWER7 machine.

The analysis of the reason why processes were not waking up properly
is due to Milton Miller.

Cc: sta...@vger.kernel.org
Reported-by: Milton Miller 
Signed-off-by: Paul Mackerras 
---
 arch/powerpc/kernel/smp.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index e292ff2..ca1040a 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -197,8 +197,15 @@ void smp_muxed_ipi_message_pass(int cpu, int msg)
struct cpu_messages *info = &per_cpu(ipi_message, cpu);
char *message = (char *)&info->messages;
 
+   /*
+* Order previous accesses before accesses in the IPI handler.
+*/
+   smp_mb();
message[msg] = 1;
-   mb();
+   /*
+* Order setting of message before IPI.
+*/
+   smp_wmb();
smp_ops->cause_ipi(cpu, info->data);
 }
 
@@ -210,7 +217,7 @@ irqreturn_t smp_ipi_demux(void)
mb();   /* order any irq clear */
 
do {
-   all = xchg_local(&info->messages, 0);
+   all = xchg(&info->messages, 0);
 
 #ifdef __BIG_ENDIAN
if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNCTION)))
-- 
1.7.10.rc3.219.g53414

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev