[PATCH] powerpc: secondary CPUs signal to master before setting active and online (fixes kernel BUG at kernel/smpboot.c:134!)

2014-12-08 Thread Anton Blanchard
Hi Ingo,

 At that point I thought the previous task_cpu() was somewhat ingrained
 in the scheduler and came up with the patch. If not, we could go on a
 hunt to see what else needs fixing.

I had another look. The scheduled does indeed make assumptions about the
previous task_cpu, but we have a hammer to fix it up called
select_fallback_rq.

I annotated select_fallback_rq, and did hit a case where the CPU was
not active. ppc64 patch below.

I think x86 have a similar (although harder to hit) issue. While it
does wait for the cpu_online bit to be set:

while (!cpu_online(cpu)) {
cpu_relax();
touch_nmi_watchdog();
}

The cpu_active bit is set after the cpu_online bit:

void set_cpu_online(unsigned int cpu, bool online)
{
if (online) {
cpumask_set_cpu(cpu, to_cpumask(cpu_online_bits));
cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits));

If the CPU got delayed between the two stores (eg a KVM guest had the CPU
scheduled out), then we'd end up with cpu_active unset and hit the same
issue in select_fallback_rq.

Anton
--

I have a busy ppc64le KVM box where guests sometimes hit the infamous
kernel BUG at kernel/smpboot.c:134! issue during boot:

BUG_ON(td-cpu != smp_processor_id());

Basically a per CPU hotplug thread scheduled on the wrong CPU. The oops
output confirms it:

CPU: 0
Comm: watchdog/130

The problem is that we aren't ensuring the CPU active and online bits are set
before allowing the master to continue on. The master unparks the secondary
CPUs kthreads and the scheduler looks for a CPU to run on. It calls
select_task_rq and realises the suggested CPU is not in the cpus_allowed
mask. It then ends up in select_fallback_rq, and since the active and
online bits aren't set we choose some other CPU to run on.

Cc: sta...@vger.kernel.org
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/smp.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 71e186d..d40e46e 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -700,7 +700,6 @@ void start_secondary(void *unused)
smp_store_cpu_info(cpu);
set_dec(tb_ticks_per_jiffy);
preempt_disable();
-   cpu_callin_map[cpu] = 1;
 
if (smp_ops-setup_cpu)
smp_ops-setup_cpu(cpu);
@@ -739,6 +738,14 @@ void start_secondary(void *unused)
notify_cpu_starting(cpu);
set_cpu_online(cpu, true);
 
+   /*
+* CPU must be marked active and online before we signal back to the
+* master, because the scheduler needs to see the cpu_online and
+* cpu_active bits set.
+*/
+   smp_wmb();
+   cpu_callin_map[cpu] = 1;
+
local_irq_enable();
 
cpu_startup_entry(CPUHP_ONLINE);
-- 
2.1.0

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

[PATCH] kthread: kthread_bind fails to enforce CPU affinity (fixes kernel BUG at kernel/smpboot.c:134!)

2014-12-07 Thread Anton Blanchard
I have a busy ppc64le KVM box where guests sometimes hit the infamous
kernel BUG at kernel/smpboot.c:134! issue during boot:

BUG_ON(td-cpu != smp_processor_id());

Basically a per CPU hotplug thread scheduled on the wrong CPU. The oops
output confirms it:

CPU: 0
Comm: watchdog/130

The issue is in kthread_bind where we set the cpus_allowed mask, but do
not touch task_thread_info(p)-cpu. The scheduler assumes the previously
scheduled CPU is in the cpus_allowed mask, but in this case we are
moving a thread to another CPU so it is not.

We used to call set_task_cpu which sets task_thread_info(p)-cpu (in fact
kthread_bind still has a comment suggesting this). That was removed in
e2912009fb7b (sched: Ensure set_task_cpu() is never called on blocked
tasks).

Since we cannot call set_task_cpu (the task is in a sleeping state),
just do an explicit set of task_thread_info(p)-cpu.

Fixes: e2912009fb7b (sched: Ensure set_task_cpu() is never called on blocked 
tasks)
Cc: sta...@vger.kernel.org
Signed-off-by: Anton Blanchard an...@samba.org
---
 kernel/kthread.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 10e489c..e40ab1d 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -327,13 +327,14 @@ EXPORT_SYMBOL(kthread_create_on_node);
 
 static void __kthread_bind(struct task_struct *p, unsigned int cpu, long state)
 {
-   /* Must have done schedule() in kthread() before we set_task_cpu */
+   /* Must have done schedule() in kthread() before we change affinity */
if (!wait_task_inactive(p, state)) {
WARN_ON(1);
return;
}
/* It's safe because the task is inactive. */
do_set_cpus_allowed(p, cpumask_of(cpu));
+   task_thread_info(p)-cpu = cpu;
p-flags |= PF_NO_SETAFFINITY;
 }
 
-- 
2.1.0

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

Re: [PATCH] kthread: kthread_bind fails to enforce CPU affinity (fixes kernel BUG at kernel/smpboot.c:134!)

2014-12-07 Thread Anton Blanchard

Hi Linus,

 The __set_task_cpu() function does various other things too:
 
 set_task_rq(p, cpu);
   #ifdef CONFIG_SMP
 /*
  * After -cpu is set up to a new value, task_rq_lock(p, ...)
 can be
  * successfuly executed on another CPU. We must ensure that
 updates of
  * per-task data have been completed by this moment.
  */
 smp_wmb();
 task_thread_info(p)-cpu = cpu;
 p-wake_cpu = cpu;
   #endif
 
 which makes me worry about just setting the thread_info-cpu value.
 That set_task_rq() initializes various group scheduling things, an
 dthat whole wake_cpu thing seems relevant too.

Yeah, I would definitely like the scheduler guys to weigh in on this,
especially considering how difficult it can be to hit.

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

KVM XICS bug

2014-11-30 Thread Anton Blanchard
Hi,

I've been seeing intermittent hangs when booting a KVM guest on a busy box.
Both host and guest are mainline (3.18-rc6). The backtrace looks like:

INFO: rcu_sched self-detected stall on CPU { 7}  (t=8404 jiffies g=-299 c=-300 
q=79)
Task dump for CPU 7:
swapper/7   R  running task11840 0  1 0x0804
Call Trace:
[c007fa5434a0] [c00cd684] sched_show_task+0xe4/0x160 (unreliable)
[c007fa543510] [c00fa568] rcu_dump_cpu_stacks+0xe8/0x160
[c007fa543560] [c00fe75c] rcu_check_callbacks+0x59c/0x8b0
[c007fa543680] [c0104a68] update_process_times+0x58/0xb0
[c007fa5436c0] [c0114e14] tick_periodic+0x44/0x110
[c007fa5436f0] [c0115208] tick_handle_periodic+0x38/0xc0
[c007fa543730] [c001c7cc] __timer_interrupt+0x8c/0x240
[c007fa543780] [c001ce90] timer_interrupt+0xa0/0xe0
[c007fa5437b0] [c00099f4] restore_check_irq_replay+0x54/0x70
--- interrupt: 901 at arch_local_irq_restore+0x74/0x90
LR = arch_local_irq_restore+0x74/0x90
[c007fa543aa0] [c00d1874] vtime_common_account_irq_enter+0x54/0x70 
(unreliable)
[c007fa543ac0] [c009c3d8] __do_softirq+0xd8/0x3a0
[c007fa543bb0] [c009c9f8] irq_exit+0xc8/0x110
[c007fa543be0] [c001ce94] timer_interrupt+0xa4/0xe0
[c007fa543c10] [c00099f4] restore_check_irq_replay+0x54/0x70
--- interrupt: 901 at arch_local_irq_restore+0x5c/0x90
LR = arch_local_irq_restore+0x40/0x90
[c007fa543f00] [c0097864] cpu_notify+0x34/0x80 (unreliable)
[c007fa543f20] [c003afa0] start_secondary+0x330/0x360
[c007fa543f90] [c0008b6c] start_secondary_prolog+0x10/0x14

XICS in kernel emulation is disabled (I really need to update the defconfig).

It looks like we are looping in restore_check_irq_replay, replaying 0x500
exceptions. When we call H_XIRR to ask for the IRQ, QEMU tells us it's a
spurious IRQ.

Thinking up other ways to create similar stress, I ran a big SMP guest
on one core (with taskset). With no root filesystem this will just
panic and reboot until it hits the bug:

taskset -c 0 ~/qemu/ppc64-softmmu/qemu-system-ppc64 -enable-kvm -smp 
cores=16,threads=8 -m 4G -M pseries -nographic -vga none -kernel vmlinux

It usually hits in under 5 minutes.

I took a QEMU trace (I added a tracepoint to power7_set_irq) and we can
see QEMU is trying to cancel the exception:

xics_icp_accept 0.322 pid=71614 old_xirr=0xff00 new_xirr=0xff00
power7_set_irq 2.232 pid=71614 pin=0x0 level=0x0
xics_icp_accept 0.285 pid=71614 old_xirr=0xff00 new_xirr=0xff00
power7_set_irq 21.809 pid=71614 pin=0x0 level=0x0
xics_icp_accept 0.311 pid=71614 old_xirr=0xff00 new_xirr=0xff00
power7_set_irq 2.230 pid=71614 pin=0x0 level=0x0

To me it looks like the KVM and the QEMU view of the 0x500 exception
state has got out of sync. The patch below fixes the issue for me, but
we might want to dig further to understand why the state has got out of
sync. Any ideas?

Anton
--

diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index bec82cd..cb0911f 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -60,7 +60,6 @@ void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level)
 {
 CPUState *cs = CPU(cpu);
 CPUPPCState *env = cpu-env;
-unsigned int old_pending = env-pending_interrupts;
 
 if (level) {
 env-pending_interrupts |= 1  n_IRQ;
@@ -72,11 +71,9 @@ void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level)
 }
 }
 
-if (old_pending != env-pending_interrupts) {
 #ifdef CONFIG_KVM
-kvmppc_set_interrupt(cpu, n_IRQ, level);
+kvmppc_set_interrupt(cpu, n_IRQ, level);
 #endif
-}
 
 LOG_IRQ(%s: %p n_IRQ %d level %d = pending %08 PRIx32
 req %08x\n, __func__, env, n_IRQ, level,
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] KVM: PPC: Enable in kernel XICS emulation by default

2014-11-30 Thread Anton Blanchard
The in kernel XICS emulation is faster than doing it all in QEMU
and it has got a lot of testing, so enable it by default

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kvm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
index 602eb51..f5769f1 100644
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -172,6 +172,7 @@ config KVM_XICS
depends on KVM_BOOK3S_64  !KVM_MPIC
select HAVE_KVM_IRQCHIP
select HAVE_KVM_IRQFD
+   default y
---help---
  Include support for the XICS (eXternal Interrupt Controller
  Specification) interrupt controller architecture used on
-- 
2.1.0

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

[PATCH] powerpc: 32 bit getcpu VDSO function uses 64 bit instructions

2014-11-26 Thread Anton Blanchard
I used some 64 bit instructions when adding the 32 bit getcpu VDSO
function. Fix it.

Fixes: 18ad51dd342a (powerpc: Add VDSO version of getcpu)
Cc: sta...@vger.kernel.org
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/vdso32/getcpu.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/vdso32/getcpu.S 
b/arch/powerpc/kernel/vdso32/getcpu.S
index 23eb9a9..c62be60 100644
--- a/arch/powerpc/kernel/vdso32/getcpu.S
+++ b/arch/powerpc/kernel/vdso32/getcpu.S
@@ -30,8 +30,8 @@
 V_FUNCTION_BEGIN(__kernel_getcpu)
   .cfi_startproc
mfspr   r5,SPRN_SPRG_VDSO_READ
-   cmpdi   cr0,r3,0
-   cmpdi   cr1,r4,0
+   cmpwi   cr0,r3,0
+   cmpwi   cr1,r4,0
clrlwi  r6,r5,16
rlwinm  r7,r5,16,31-15,31-0
beq cr0,1f
-- 
2.1.0

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

[PATCH] powerpc: Bad NULL pointer check in udbg_uart_getc_poll

2014-11-10 Thread Anton Blanchard
We have some code in udbg_uart_getc_poll that tries to protect
against a NULL udbg_uart_in, but gets it all wrong.

Found with the LLVM static analyzer (scan-build).

Fixes: 309257484cc1 (powerpc: Cleanup udbg_16550 and add support for LPC 
PIO-only UARTs)
Cc: sta...@vger.kernel.org
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/udbg_16550.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel/udbg_16550.c
index 6e7c492..3faf393 100644
--- a/arch/powerpc/kernel/udbg_16550.c
+++ b/arch/powerpc/kernel/udbg_16550.c
@@ -69,7 +69,9 @@ static void udbg_uart_putc(char c)
 
 static int udbg_uart_getc_poll(void)
 {
-   if (!udbg_uart_in || !(udbg_uart_in(UART_LSR)  LSR_DR))
+   if (!udbg_uart_in)
+   return -1;
+   if (!(udbg_uart_in(UART_LSR)  LSR_DR))
return udbg_uart_in(UART_RBR);
return -1;
 }
-- 
1.9.1

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

[PATCH] powerpc: Add ppc64 hard lockup detector support

2014-11-04 Thread Anton Blanchard
The hard lockup detector uses a PMU event as a periodic NMI to
detect if we are stuck (where stuck means no timer interrupts have
occurred).

Ben's rework of the ppc64 soft disable code has made ppc64 PMU
exceptions a partial NMI. They can get disabled if an external
interrupt comes in, but otherwise PMU interrupts will fire in
interrupt disabled regions.

We disable the hard lockup detector by default for a few reasons:

- It breaks userspace event based branches on POWER8.
- It is likely to produce false positives on KVM guests.
- Since PMCs can only count to 2^31, counting cycles means we might
  take multiple PMU exceptions per second per hardware thread even
  if our hard lockup timeout is 10 seconds.

It can be enabled via a boot option, or via procfs.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/Kconfig   |  2 +-
 arch/powerpc/Kconfig   |  1 +
 arch/powerpc/include/asm/nmi.h |  4 
 arch/powerpc/kernel/setup_64.c | 20 
 4 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/include/asm/nmi.h

diff --git a/arch/Kconfig b/arch/Kconfig
index 05d7a8a..a8551b0 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -32,7 +32,7 @@ config HAVE_OPROFILE
 
 config OPROFILE_NMI_TIMER
def_bool y
-   depends on PERF_EVENTS  HAVE_PERF_EVENTS_NMI
+   depends on (PERF_EVENTS  HAVE_PERF_EVENTS_NMI)  !PPC
 
 config KPROBES
bool Kprobes
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 88eace4..03791c4 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -148,6 +148,7 @@ config PPC
select HAVE_ARCH_AUDITSYSCALL
select ARCH_SUPPORTS_ATOMIC_RMW
select DCACHE_WORD_ACCESS if PPC64  CPU_LITTLE_ENDIAN
+   select HAVE_PERF_EVENTS_NMI if PPC64
 
 config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
diff --git a/arch/powerpc/include/asm/nmi.h b/arch/powerpc/include/asm/nmi.h
new file mode 100644
index 000..ff1ccb3
--- /dev/null
+++ b/arch/powerpc/include/asm/nmi.h
@@ -0,0 +1,4 @@
+#ifndef _ASM_NMI_H
+#define _ASM_NMI_H
+
+#endif /* _ASM_NMI_H */
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 1b56320..c368397 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -37,6 +37,7 @@
 #include linux/memblock.h
 #include linux/hugetlb.h
 #include linux/memory.h
+#include linux/nmi.h
 
 #include asm/io.h
 #include asm/kdump.h
@@ -781,3 +782,22 @@ unsigned long memory_block_size_bytes(void)
 struct ppc_pci_io ppc_pci_io;
 EXPORT_SYMBOL(ppc_pci_io);
 #endif
+
+#ifdef CONFIG_HARDLOCKUP_DETECTOR
+u64 hw_nmi_get_sample_period(int watchdog_thresh)
+{
+   return ppc_proc_freq * watchdog_thresh;
+}
+
+/*
+ * The hardlockup detector breaks PMU event based branches and is likely
+ * to get false positives in KVM guests, so disable it by default.
+ */
+static int __init disable_hardlockup_detector(void)
+{
+   watchdog_enable_hardlockup_detector(false);
+
+   return 0;
+}
+early_initcall(disable_hardlockup_detector);
+#endif
-- 
1.9.1

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

Re: [PATCH] powerpc: Replace cc constraint in inline assembly with cr0

2014-11-02 Thread Anton Blanchard
Hi Segher,

  Our inline assembly only clobbers the first condition register
  field, but we mark all of them as being clobbered.
 
 No, we don't.  cc has been an alias for cr0 for over twenty two and
 a half years now; it has never changed meaning.  This is an LLVM bug.

Thanks! I opened http://llvm.org/bugs/show_bug.cgi?id=21451 to track it.

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

[PATCH] powerpc/pseries: Quieten ibm,pcie-link-speed-stats warning

2014-11-02 Thread Anton Blanchard
The ibm,pcie-link-speed-stats isn't mandatory, so we shouldn't print
a high priority error message when missing. One example where we see
this is QEMU.

Reduce it to pr_debug.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/platforms/pseries/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/pci.c 
b/arch/powerpc/platforms/pseries/pci.c
index 67e4859..fe16a50 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -134,7 +134,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge 
*bridge)
of_node_put(pdn);
 
if (rc) {
-   pr_err(no ibm,pcie-link-speed-stats property\n);
+   pr_debug(no ibm,pcie-link-speed-stats property\n);
return 0;
}
 
-- 
1.9.1

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

[PATCH] powerpc/pseries: Quieten relocation on exceptions warning

2014-11-02 Thread Anton Blanchard
The H_SET_MODE hcall returns H_P2 if a function is not implemented
and all callers should handle this case.

The call to enable relocation on exceptions currently prints an error
message if the feature is not implemented. While H_SET_MODE was
first introduced on POWER8 (which has relocation on exceptions), it
has been now added on some POWER7 configurations (which does not).

Check for H_P2 and print an informational message instead.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/platforms/pseries/setup.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/setup.c 
b/arch/powerpc/platforms/pseries/setup.c
index 125c589..fcc9227 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -499,7 +499,11 @@ static void __init pSeries_setup_arch(void)
 
if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
long rc;
-   if ((rc = pSeries_enable_reloc_on_exc()) != H_SUCCESS) {
+
+   rc = pSeries_enable_reloc_on_exc();
+   if (rc == H_P2) {
+   pr_info(Relocation on exceptions not supported\n);
+   } else if (rc != H_SUCCESS) {
pr_warn(Unable to enable relocation on exceptions: 
%ld\n, rc);
}
-- 
1.9.1

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

[PATCH] powerpc: Replace cc constraint in inline assembly with cr0

2014-10-31 Thread Anton Blanchard
Our inline assembly only clobbers the first condition register field,
but we mark all of them as being clobbered.

This will cause LLVM to save and restore the non volatile condition
register fields around the inline assembly, which is completely
unnecessary. A simple example:

void foo(void)
{
asm volatile(:::cc);
}

gives:

foo:
   0:   26 00 80 7d mfcrr12
   4:   08 00 81 91 stw r12,8(r1)
   8:   08 00 61 81 lwz r11,8(r1)
   c:   20 01 72 7d mtocrf  32,r11
  10:   20 01 71 7d mtocrf  16,r11
  14:   20 81 70 7d mtocrf  8,r11
  18:   20 00 80 4e blr

Replacing cc with cr0:

foo:
   0:   20 00 80 4e blr

This patch produces no difference to a kernel built with gcc.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/atomic.h| 36 
 arch/powerpc/include/asm/bitops.h|  4 ++--
 arch/powerpc/include/asm/cmpxchg.h   | 16 +++---
 arch/powerpc/include/asm/futex.h |  2 +-
 arch/powerpc/include/asm/kvm_book3s_64.h |  2 +-
 arch/powerpc/include/asm/local.h | 12 +--
 arch/powerpc/include/asm/mutex.h |  6 +++---
 arch/powerpc/include/asm/pgtable-ppc32.h |  4 ++--
 arch/powerpc/include/asm/pgtable-ppc64.h |  4 ++--
 arch/powerpc/kvm/book3s_hv_rm_mmu.c  |  2 +-
 arch/powerpc/mm/pgtable_64.c |  4 ++--
 11 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/arch/powerpc/include/asm/atomic.h 
b/arch/powerpc/include/asm/atomic.h
index 512d278..ef2172c 100644
--- a/arch/powerpc/include/asm/atomic.h
+++ b/arch/powerpc/include/asm/atomic.h
@@ -39,7 +39,7 @@ static __inline__ void atomic_##op(int a, atomic_t *v)
\
   bne-1b\n   \
: =r (t), +m (v-counter)  \
: r (a), r (v-counter)\
-   : cc);\
+   : cr0);   \
 }  \
 
 #define ATOMIC_OP_RETURN(op, asm_op)   \
@@ -57,7 +57,7 @@ static __inline__ int atomic_##op##_return(int a, atomic_t 
*v)\
PPC_ATOMIC_EXIT_BARRIER \
: =r (t) \
: r (a), r (v-counter)\
-   : cc, memory);  \
+   : cr0, memory); \
\
return t;   \
 }
@@ -85,7 +85,7 @@ static __inline__ void atomic_inc(atomic_t *v)
bne-1b
: =r (t), +m (v-counter)
: r (v-counter)
-   : cc, xer);
+   : cr0, xer);
 }
 
 static __inline__ int atomic_inc_return(atomic_t *v)
@@ -102,7 +102,7 @@ static __inline__ int atomic_inc_return(atomic_t *v)
PPC_ATOMIC_EXIT_BARRIER
: =r (t)
: r (v-counter)
-   : cc, xer, memory);
+   : cr0, xer, memory);
 
return t;
 }
@@ -129,7 +129,7 @@ static __inline__ void atomic_dec(atomic_t *v)
bne-1b
: =r (t), +m (v-counter)
: r (v-counter)
-   : cc, xer);
+   : cr0, xer);
 }
 
 static __inline__ int atomic_dec_return(atomic_t *v)
@@ -146,7 +146,7 @@ static __inline__ int atomic_dec_return(atomic_t *v)
PPC_ATOMIC_EXIT_BARRIER
: =r (t)
: r (v-counter)
-   : cc, xer, memory);
+   : cr0, xer, memory);
 
return t;
 }
@@ -181,7 +181,7 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int 
a, int u)
 2:
: =r (t)
: r (v-counter), r (a), r (u)
-   : cc, memory);
+   : cr0, memory);
 
return t;
 }
@@ -211,7 +211,7 @@ static __inline__ int atomic_inc_not_zero(atomic_t *v)
 2:
: =r (t1), =r (t2)
: r (v-counter)
-   : cc, xer, memory);
+   : cr0, xer, memory);
 
return t1;
 }
@@ -242,7 +242,7 @@ static __inline__ int atomic_dec_if_positive(atomic_t *v)
\n\
 2:: =b (t)
: r (v-counter)
-   : cc, memory);
+   : cr0, memory);
 
return t;
 }
@@ -278,7 +278,7 @@ static __inline__ void atomic64_##op(long a, atomic64_t *v) 
\
   bne-1b\n   \
: =r (t), +m (v-counter)  \
: r (a), r (v-counter)\
-   : cc);\
+   : cr0);   \
 }
 
 #define ATOMIC64_OP_RETURN(op, asm_op) \
@@ -295,7 +295,7 @@ static __inline__ long atomic64_##op##_return

[PATCH] powerpc: do_notify_resume can be called with bad thread_info flags argument

2014-10-30 Thread Anton Blanchard
Back in 7230c5644188 (powerpc: Rework lazy-interrupt handling) we
added a call out to restore_interrupts() (written in c) before calling
do_notify_resume:

bl  restore_interrupts
addir3,r1,STACK_FRAME_OVERHEAD
bl  do_notify_resume

Unfortunately do_notify_resume takes two arguments, the second one
being the thread_info flags:

void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)

We do populate r4 (the second argument) earlier, but
restore_interrupts() is free to muck it up all it wants. My guess is
the gcc compiler gods shone down on us and its register allocator
never used r4. Sometimes, rarely, luck is on our side.

LLVM on the other hand did trample r4.

To avoid having to reload the flags, pass it through
restore_interrupts, suggested by benh.

Signed-off-by: Anton Blanchard an...@samba.org
Cc: sta...@vger.kernel.org
---
 arch/powerpc/kernel/entry_64.S | 6 ++
 arch/powerpc/kernel/irq.c  | 8 +++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 9caab69..086c566 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -659,7 +659,13 @@ _GLOBAL(ret_from_except_lite)
 3:
 #endif
bl  save_nvgprs
+   /*
+* restore_interrupts takes an argument and returns it unmodified
+* so we can get the thread_info flags into do_notify_resume.
+*/
+   mr  r3,r4
bl  restore_interrupts
+   mr  r4,r3
addir3,r1,STACK_FRAME_OVERHEAD
bl  do_notify_resume
b   ret_from_except
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 6dbae00..44b0530 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -283,16 +283,22 @@ EXPORT_SYMBOL(arch_local_irq_restore);
  * schedule() or do_signal() when returning to userspace. We do it
  * in C to avoid the burden of dealing with lockdep etc...
  *
+ * We are passed the current thread_info flags which we return. This
+ * is useful in the exception exit code where we already have loaded
+ * the flags and need to use them again after calling restore_interrupts.
+ *
  * NOTE: This is called with interrupts hard disabled but not marked
  * as such in paca-irq_happened, so we need to resync this.
  */
-void notrace restore_interrupts(void)
+unsigned long notrace restore_interrupts(unsigned long thread_info_flags)
 {
if (irqs_disabled()) {
local_paca-irq_happened |= PACA_IRQ_HARD_DIS;
local_irq_enable();
} else
__hard_irq_enable();
+
+   return thread_info_flags;
 }
 
 /*
-- 
1.9.1

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

[PATCH 1/3] powerpc: Don't use local named register variable in current_thread_info

2014-10-30 Thread Anton Blanchard
LLVM doesn't support local named register variables and is unlikely
to. current_thread_info is using one, fix it by moving it out and
calling it __current_r1().

I gave it a bit of an obscure name because we don't want anyone else
using it - they should use current_stack_pointer(). This specific
case is performance critical and we can't afford to call a function
to get it. Furthermore it isn't important to know exactly where in
the stack we are since we mask the lower bits.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/thread_info.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/thread_info.h 
b/arch/powerpc/include/asm/thread_info.h
index b034ecd..ebc4f16 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -71,13 +71,12 @@ struct thread_info {
 #define THREAD_SIZE_ORDER  (THREAD_SHIFT - PAGE_SHIFT)
 
 /* how to get the thread information struct from C */
+register unsigned long __current_r1 asm(r1);
 static inline struct thread_info *current_thread_info(void)
 {
-   register unsigned long sp asm(r1);
-
/* gcc4, at least, is smart enough to turn this into a single
 * rlwinm for ppc32 and clrrdi for ppc64 */
-   return (struct thread_info *)(sp  ~(THREAD_SIZE-1));
+   return (struct thread_info *)(__current_r1  ~(THREAD_SIZE-1));
 }
 
 #endif /* __ASSEMBLY__ */
-- 
1.9.1

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

[PATCH 2/3] powerpc: Remove double braces in alignment code.

2014-10-30 Thread Anton Blanchard
Looks like I introduced this when adding LE support.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/align.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
index 34f5552..86150fb 100644
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -908,7 +908,7 @@ int fix_alignment(struct pt_regs *regs)
flush_fp_to_thread(current);
}
 
-   if ((nb == 16)) {
+   if (nb == 16) {
if (flags  F) {
/* Special case for 16-byte FP loads and stores */
PPC_WARN_ALIGNMENT(fp_pair, regs);
-- 
1.9.1

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

[PATCH 3/3] powerpc: LLVM complains about forward declaration of struct rtas_sensors

2014-10-30 Thread Anton Blanchard
Move the declaration up to silence the warning.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/rtas-proc.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c
index 8777fb0..fb2fb3e 100644
--- a/arch/powerpc/kernel/rtas-proc.c
+++ b/arch/powerpc/kernel/rtas-proc.c
@@ -113,17 +113,6 @@
 #define SENSOR_PREFIX  ibm,sensor-
 #define cel_to_fahr(x) ((x*9/5)+32)
 
-
-/* Globals */
-static struct rtas_sensors sensors;
-static struct device_node *rtas_node = NULL;
-static unsigned long power_on_time = 0; /* Save the time the user set */
-static char progress_led[MAX_LINELENGTH];
-
-static unsigned long rtas_tone_frequency = 1000;
-static unsigned long rtas_tone_volume = 0;
-
-/* STRUCTS*** */
 struct individual_sensor {
unsigned int token;
unsigned int quant;
@@ -134,6 +123,15 @@ struct rtas_sensors {
unsigned int quant;
 };
 
+/* Globals */
+static struct rtas_sensors sensors;
+static struct device_node *rtas_node = NULL;
+static unsigned long power_on_time = 0; /* Save the time the user set */
+static char progress_led[MAX_LINELENGTH];
+
+static unsigned long rtas_tone_frequency = 1000;
+static unsigned long rtas_tone_volume = 0;
+
 /* ** */
 /* Declarations */
 static int ppc_rtas_sensors_show(struct seq_file *m, void *v);
-- 
1.9.1

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

[PATCH] powerpc/pseries: Quieten ibm,pcie-link-speed-stats warning

2014-10-30 Thread Anton Blanchard
The ibm,pcie-link-speed-stats isn't mandatory, so we shouldn't print
a high priority error message when missing. One example where we see
this is QEMU.

Reduce it to pr_info.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/platforms/pseries/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/pci.c 
b/arch/powerpc/platforms/pseries/pci.c
index 67e4859..57dd7a0 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -134,7 +134,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge 
*bridge)
of_node_put(pdn);
 
if (rc) {
-   pr_err(no ibm,pcie-link-speed-stats property\n);
+   pr_info(no ibm,pcie-link-speed-stats property\n);
return 0;
}
 
-- 
1.9.1

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

[PATCH] powerpc: do_notify_resume can be called with bad thread_info flags argument

2014-10-30 Thread Anton Blanchard
Back in 7230c5644188 (powerpc: Rework lazy-interrupt handling) we
added a call out to restore_interrupts() (written in c) before calling
do_notify_resume:

bl  restore_interrupts
addir3,r1,STACK_FRAME_OVERHEAD
bl  do_notify_resume

Unfortunately do_notify_resume takes two arguments, the second one
being the thread_info flags:

void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)

We do populate r4 (the second argument) earlier, but
restore_interrupts() is free to muck it up all it wants. My guess is
the gcc compiler gods shone down on us and its register allocator
never used r4. Sometimes, rarely, luck is on our side.

LLVM on the other hand did trample r4.

Signed-off-by: Anton Blanchard an...@samba.org
Cc: sta...@vger.kernel.org
---
 arch/powerpc/kernel/entry_64.S | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 9caab69..194e46d 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -659,7 +659,13 @@ _GLOBAL(ret_from_except_lite)
 3:
 #endif
bl  save_nvgprs
+   /*
+* Use a non volatile GPR to save and restore our thread_info flags
+* across the call to restore_interrupts.
+*/
+   mr  r30,r4
bl  restore_interrupts
+   mr  r4,r30
addir3,r1,STACK_FRAME_OVERHEAD
bl  do_notify_resume
b   ret_from_except
-- 
1.9.1

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

[PATCH] powerpc/jump_label: Use HAVE_JUMP_LABEL

2014-10-29 Thread Anton Blanchard
Commit d4fe0965e208 (powerpc/jump_label: use HAVE_JUMP_LABEL?)
missed a few conversions. Change the remaining uses of
CONFIG_JUMP_LABEL to HAVE_JUMP_LABEL.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/platforms/powernv/opal-wrappers.S | 2 +-
 arch/powerpc/platforms/pseries/hvCall.S| 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S 
b/arch/powerpc/platforms/powernv/opal-wrappers.S
index feb549a..cf7266d 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -18,7 +18,7 @@
.section.text
 
 #ifdef CONFIG_TRACEPOINTS
-#ifdef CONFIG_JUMP_LABEL
+#ifdef HAVE_JUMP_LABEL
 #define OPAL_BRANCH(LABEL) \
ARCH_STATIC_BRANCH(LABEL, opal_tracepoint_key)
 #else
diff --git a/arch/powerpc/platforms/pseries/hvCall.S 
b/arch/powerpc/platforms/pseries/hvCall.S
index 3fda3f1..ccd53f9 100644
--- a/arch/powerpc/platforms/pseries/hvCall.S
+++ b/arch/powerpc/platforms/pseries/hvCall.S
@@ -18,7 +18,7 @@

 #ifdef CONFIG_TRACEPOINTS
 
-#ifndef CONFIG_JUMP_LABEL
+#ifndef HAVE_JUMP_LABEL
.section.toc,aw
 
.globl hcall_tracepoint_refcount
@@ -78,7 +78,7 @@ hcall_tracepoint_refcount:
mr  r5,BUFREG;  \
__HCALL_INST_POSTCALL
 
-#ifdef CONFIG_JUMP_LABEL
+#ifdef HAVE_JUMP_LABEL
 #define HCALL_BRANCH(LABEL)\
ARCH_STATIC_BRANCH(LABEL, hcall_tracepoint_key)
 #else
-- 
1.9.1

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

[PATCH] powerpc: do_notify_resume can be called with bad thread_info flags argument

2014-10-29 Thread Anton Blanchard
Back in 7230c5644188 (powerpc: Rework lazy-interrupt handling) we
added a call out to restore_interrupts() (written in c) before we
call do_notify_resume:

bl  restore_interrupts
addir3,r1,STACK_FRAME_OVERHEAD
bl  do_notify_resume

Unfortunately do_notify_resume takes two arguments, the second one
being the thread_info flags:

void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)

We do populate r4 earlier, but restore_interrupts() is free to muck
it up all it wants. My guess is the gcc compiler gods shone down on
us and its register allocator never used r4. Sometimes, rarely, luck
is on our side.

Signed-off-by: Anton Blanchard an...@samba.org
Cc: sta...@vger.kernel.org
---
 arch/powerpc/kernel/entry_64.S | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 9caab69..add42d0 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -661,6 +661,13 @@ _GLOBAL(ret_from_except_lite)
bl  save_nvgprs
bl  restore_interrupts
addir3,r1,STACK_FRAME_OVERHEAD
+   /*
+* restore_interrupts() is written in c and could clobber all
+* volatile registers. We need to reload our thread_info flags
+* in r4 for do_notify_resume().
+*/
+   CURRENT_THREAD_INFO(r9, r1)
+   ld  r4,TI_FLAGS(r9)
bl  do_notify_resume
b   ret_from_except
 
-- 
1.9.1

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

Re: [PATCH 3/3] powerpc/ftrace: simplify prepare_ftrace_return

2014-10-27 Thread Anton Blanchard
Hi Segher,

 On Wed, Sep 24, 2014 at 12:33:07PM +1000, Anton Blanchard wrote:
  We are scratching our heads trying to remember details of the issue
  right now. In retrospect we should have linked the gcc bugzilla or
  gcc commit details in the kernel commit message :)
 
 There have been many GCC bugs in this area.
 
 30282 (for 32-bit)
 44199 (for 64-bit)
 52828 (for everything, and this one should finally handle things for
 good) Also a bunch of duplicates, and I'm sure I've missed some more.
 
 The original issue as far as I remember: when using a frame pointer,
 GCC would sometimes schedule the epilogue to do the stack adjust
 before restoring all regs from the stack.  Then an interrupt comes
 in, those saved regs are clobbered, kaboom.  We cannot disable the
 frame pointer because -pg forces it (although PowerPC does not need
 it).  The -mno-sched-epilog flag is a workaround: the epilogue (and
 prologue) will not be reordered by instruction scheduling.  Slow code
 is better than blowing up fast ;-)

Thanks for explaining it! It does look like the last issue wasn't
fixed until gcc 4.8. We'll drop that patch.

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

[PATCH] powerpc/pseries: Quieten relocation on exceptions warning

2014-10-19 Thread Anton Blanchard
The hypervisor returns H_P2 if relocation on exceptions are
not supported. If we get this, just print a lower priority
informational message.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/platforms/pseries/setup.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/setup.c 
b/arch/powerpc/platforms/pseries/setup.c
index 125c589..fcc9227 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -499,7 +499,11 @@ static void __init pSeries_setup_arch(void)
 
if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
long rc;
-   if ((rc = pSeries_enable_reloc_on_exc()) != H_SUCCESS) {
+
+   rc = pSeries_enable_reloc_on_exc();
+   if (rc == H_P2) {
+   pr_info(Relocation on exceptions not supported\n);
+   } else if (rc != H_SUCCESS) {
pr_warn(Unable to enable relocation on exceptions: 
%ld\n, rc);
}
-- 
1.9.1

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

[PATCH v2] powerpc: Remove ppc_md.remove_memory

2014-10-14 Thread Anton Blanchard
We have an extra level of indirection on memory hot remove which is not
matched on memory hot add. Memory hotplug is book3s only, so there is
no need for it.

This also enables means remove_memory() (ie memory hot unplug) works
on powernv.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/machdep.h  |  4 
 arch/powerpc/mm/mem.c   | 14 --
 arch/powerpc/platforms/pseries/hotplug-memory.c | 21 -
 3 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h 
b/arch/powerpc/include/asm/machdep.h
index 902ab20..327e8dd 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -294,10 +294,6 @@ struct machdep_calls {
 #ifdef CONFIG_ARCH_RANDOM
int (*get_random_long)(unsigned long *v);
 #endif
-
-#ifdef CONFIG_MEMORY_HOTREMOVE
-   int (*remove_memory)(u64, u64);
-#endif
 };
 
 extern void e500_idle(void);
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 8ebaac7..2add0b7 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -35,6 +35,7 @@
 #include linux/memblock.h
 #include linux/hugetlb.h
 #include linux/slab.h
+#include linux/vmalloc.h
 
 #include asm/pgalloc.h
 #include asm/prom.h
@@ -144,8 +145,17 @@ int arch_remove_memory(u64 start, u64 size)
 
zone = page_zone(pfn_to_page(start_pfn));
ret = __remove_pages(zone, start_pfn, nr_pages);
-   if (!ret  (ppc_md.remove_memory))
-   ret = ppc_md.remove_memory(start, size);
+   if (ret)
+   return ret;
+
+   /* Remove htab bolted mappings for this section of memory */
+   start = (unsigned long)__va(start);
+   ret = remove_section_mapping(start, start + size);
+
+   /* Ensure all vmalloc mappings are flushed in case they also
+* hit that section of memory
+*/
+   vm_unmap_aliases();
 
return ret;
 }
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c 
b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 187ecfa..d5426ec 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -12,7 +12,6 @@
 #include linux/of.h
 #include linux/of_address.h
 #include linux/memblock.h
-#include linux/vmalloc.h
 #include linux/memory.h
 #include linux/memory_hotplug.h
 
@@ -66,22 +65,6 @@ unsigned long pseries_memory_block_size(void)
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-static int pseries_remove_memory(u64 start, u64 size)
-{
-   int ret;
-
-   /* Remove htab bolted mappings for this section of memory */
-   start = (unsigned long)__va(start);
-   ret = remove_section_mapping(start, start + size);
-
-   /* Ensure all vmalloc mappings are flushed in case they also
-* hit that section of memory
-*/
-   vm_unmap_aliases();
-
-   return ret;
-}
-
 static int pseries_remove_memblock(unsigned long base, unsigned int 
memblock_size)
 {
unsigned long block_sz, start_pfn;
@@ -262,10 +245,6 @@ static int __init pseries_memory_hotplug_init(void)
if (firmware_has_feature(FW_FEATURE_LPAR))
of_reconfig_notifier_register(pseries_mem_nb);
 
-#ifdef CONFIG_MEMORY_HOTREMOVE
-   ppc_md.remove_memory = pseries_remove_memory;
-#endif
-
return 0;
 }
 machine_device_initcall(pseries, pseries_memory_hotplug_init);
-- 
1.9.1

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

Re: [PATCH 1/4] powerpc: Dynamic DMA zone limits

2014-10-13 Thread Anton Blanchard
Hi Scott,

 Platform code can call limit_zone_pfn() to set appropriate limits
 for ZONE_DMA and ZONE_DMA32, and dma_direct_alloc_coherent() will
 select a suitable zone based on a device's mask and the pfn limits
 that platform code has configured.

This patch breaks my POWER8 box:

ipr 0001:08:00.0: Using 64-bit DMA iommu bypass
ipr 0001:08:00.0: dma_direct_alloc_coherent: No suitable zone for pfn 0x1
ipr 0001:08:00.0: Couldn't allocate enough memory for device driver! 
ipr: probe of 0001:08:00.0 failed with error -12

ipr isn't setting a coherent mask, but we shouldn't care on these boxes.
Could we ignore the coherent mask or copy the dma mask to it?

Anton
--

 Signed-off-by: Scott Wood scottw...@freescale.com
 Cc: Shaohui Xie shaohui@freescale.com
 ---
  arch/powerpc/Kconfig   |  4 +++
  arch/powerpc/include/asm/pgtable.h |  3 ++
  arch/powerpc/kernel/dma.c  | 20 +
  arch/powerpc/mm/mem.c  | 61
 ++ 4 files changed, 83
 insertions(+), 5 deletions(-)
 
 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
 index 80b94b0..56dc47a 100644
 --- a/arch/powerpc/Kconfig
 +++ b/arch/powerpc/Kconfig
 @@ -286,6 +286,10 @@ config PPC_EMULATE_SSTEP
   bool
   default y if KPROBES || UPROBES || XMON || HAVE_HW_BREAKPOINT
  
 +config ZONE_DMA32
 + bool
 + default y if PPC64
 +
  source init/Kconfig
  
  source kernel/Kconfig.freezer
 diff --git a/arch/powerpc/include/asm/pgtable.h
 b/arch/powerpc/include/asm/pgtable.h index d98c1ec..6d74167 100644
 --- a/arch/powerpc/include/asm/pgtable.h
 +++ b/arch/powerpc/include/asm/pgtable.h
 @@ -4,6 +4,7 @@
  
  #ifndef __ASSEMBLY__
  #include linux/mmdebug.h
 +#include linux/mmzone.h
  #include asm/processor.h   /* For TASK_SIZE */
  #include asm/mmu.h
  #include asm/page.h
 @@ -281,6 +282,8 @@ extern unsigned long empty_zero_page[];
  
  extern pgd_t swapper_pg_dir[];
  
 +void limit_zone_pfn(enum zone_type zone, unsigned long max_pfn);
 +int dma_pfn_limit_to_zone(u64 pfn_limit);
  extern void paging_init(void);
  
  /*
 diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
 index ee78f6e..dfd99ef 100644
 --- a/arch/powerpc/kernel/dma.c
 +++ b/arch/powerpc/kernel/dma.c
 @@ -40,6 +40,26 @@ void *dma_direct_alloc_coherent(struct device
 *dev, size_t size, #else
   struct page *page;
   int node = dev_to_node(dev);
 + u64 pfn = (dev-coherent_dma_mask  PAGE_SHIFT) + 1;
 + int zone;
 +
 + zone = dma_pfn_limit_to_zone(pfn);
 + if (zone  0) {
 + dev_err(dev, %s: No suitable zone for pfn %#llx\n,
 + __func__, pfn);
 + return NULL;
 + }
 +
 + switch (zone) {
 + case ZONE_DMA:
 + flag |= GFP_DMA;
 + break;
 +#ifdef CONFIG_ZONE_DMA32
 + case ZONE_DMA32:
 + flag |= GFP_DMA32;
 + break;
 +#endif
 + };
  
   /* ignore region specifiers */
   flag  = ~(__GFP_HIGHMEM);
 diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
 index e0f7a18..3b23e17 100644
 --- a/arch/powerpc/mm/mem.c
 +++ b/arch/powerpc/mm/mem.c
 @@ -261,6 +261,54 @@ static int __init mark_nonram_nosave(void)
   return 0;
  }
  
 +static bool zone_limits_final;
 +
 +static unsigned long max_zone_pfns[MAX_NR_ZONES] = {
 + [0 ... MAX_NR_ZONES - 1] = ~0UL
 +};
 +
 +/*
 + * Restrict the specified zone and all more restrictive zones
 + * to be below the specified pfn.  May not be called after
 + * paging_init().
 + */
 +void __init limit_zone_pfn(enum zone_type zone, unsigned long
 pfn_limit) +{
 + int i;
 +
 + if (WARN_ON(zone_limits_final))
 + return;
 +
 + for (i = zone; i = 0; i--) {
 + if (max_zone_pfns[i]  pfn_limit)
 + max_zone_pfns[i] = pfn_limit;
 + }
 +}
 +
 +/*
 + * Find the least restrictive zone that is entirely below the
 + * specified pfn limit.  Returns  0 if no suitable zone is found.
 + *
 + * pfn_limit must be u64 because it can exceed 32 bits even on 32-bit
 + * systems -- the DMA limit can be higher than any possible real pfn.
 + */
 +int dma_pfn_limit_to_zone(u64 pfn_limit)
 +{
 + enum zone_type top_zone = ZONE_NORMAL;
 + int i;
 +
 +#ifdef CONFIG_HIGHMEM
 + top_zone = ZONE_HIGHMEM;
 +#endif
 +
 + for (i = top_zone; i = 0; i--) {
 + if (max_zone_pfns[i] = pfn_limit)
 + return i;
 + }
 +
 + return -EPERM;
 +}
 +
  /*
   * paging_init() sets up the page tables - in fact we've already
 done this. */
 @@ -268,7 +316,7 @@ void __init paging_init(void)
  {
   unsigned long long total_ram = memblock_phys_mem_size();
   phys_addr_t top_of_ram = memblock_end_of_DRAM();
 - unsigned long max_zone_pfns[MAX_NR_ZONES];
 + enum zone_type top_zone;
  
  #ifdef CONFIG_PPC32
   unsigned long v = __fix_to_virt(__end_of_fixed_addresses -
 1); @@ -290,13 +338,16 @@ void __init paging_init(void)
  

[PATCH 1/3] powerpc: Reimplement __get_SP() as a function not a define

2014-10-13 Thread Anton Blanchard
Li Zhong points out an issue with our current __get_SP()
implementation. If ftrace function tracing is enabled (ie -pg
profiling using _mcount) we spill a stack frame on 64bit all the
time.

If a function calls __get_SP() and later calls a function that is
tail call optimised, we will pop the stack frame and the value
returned by __get_SP() is no longer valid. An example from Li can
be found in save_stack_trace - save_context_stack:

c00432c0 .save_stack_trace:
c00432c0:   mflrr0
c00432c4:   std r0,16(r1)
c00432c8:   stdur1,-128(r1) -- stack frame for _mcount
c00432cc:   std r3,112(r1)
c00432d0:   bl  ._mcount
c00432d4:   nop

c00432d8:   mr  r4,r1 -- __get_SP()

c00432dc:   ld  r5,632(r13)
c00432e0:   ld  r3,112(r1)
c00432e4:   li  r6,1

c00432e8:   addir1,r1,128 -- pop stack frame

c00432ec:   ld  r0,16(r1)
c00432f0:   mtlrr0
c00432f4:   b   .save_context_stack -- tail call optimized

save_context_stack ends up with a stack pointer below the current
one, and it is likely to be scribbled over.

Fix this by making __get_SP() a function which returns the
callers stack frame. Also replace inline assembly which grabs
the stack pointer in save_stack_trace and show_stack with
__get_SP().

This also fixes an issue with perf_arch_fetch_caller_regs().
It currently unwinds the stack once, which will skip a
valid stack frame on a leaf function. With the __get_SP() fixes
in this patch, we never need to unwind the stack frame to get
to the first interesting frame.

We have to export __get_SP() because perf_arch_fetch_caller_regs()
(which is used in modules) calls it from a header file.

Reported-by: Li Zhong zh...@linux.vnet.ibm.com
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/perf_event.h | 2 +-
 arch/powerpc/include/asm/reg.h| 3 +--
 arch/powerpc/kernel/misc.S| 4 
 arch/powerpc/kernel/ppc_ksyms.c   | 2 ++
 arch/powerpc/kernel/process.c | 2 +-
 arch/powerpc/kernel/stacktrace.c  | 2 +-
 6 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/perf_event.h 
b/arch/powerpc/include/asm/perf_event.h
index 0bb2372..b058568 100644
--- a/arch/powerpc/include/asm/perf_event.h
+++ b/arch/powerpc/include/asm/perf_event.h
@@ -34,7 +34,7 @@
do {\
(regs)-result = 0; \
(regs)-nip = __ip; \
-   (regs)-gpr[1] = *(unsigned long *)__get_SP();  \
+   (regs)-gpr[1] = __get_SP();\
asm volatile(mfmsr %0 : =r ((regs)-msr));  \
} while (0)
 #endif
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index fe3f948..e539d7e 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1265,8 +1265,7 @@ static inline unsigned long mfvtb (void)
 
 #define proc_trap()asm volatile(trap)
 
-#define __get_SP() ({unsigned long sp; \
-   asm volatile(mr %0,1: =r (sp)); sp;})
+extern unsigned long __get_SP(void);
 
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);
diff --git a/arch/powerpc/kernel/misc.S b/arch/powerpc/kernel/misc.S
index 7ce26d4..120deb7 100644
--- a/arch/powerpc/kernel/misc.S
+++ b/arch/powerpc/kernel/misc.S
@@ -114,3 +114,7 @@ _GLOBAL(longjmp)
mtlrr0
mr  r3,r4
blr
+
+_GLOBAL(__get_SP)
+   PPC_LL  r3,0(r1)
+   blr
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index c4dfff6..9d84efb 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -41,3 +41,5 @@ EXPORT_SYMBOL(giveup_spe);
 #ifdef CONFIG_EPAPR_PARAVIRT
 EXPORT_SYMBOL(epapr_hypercall_start);
 #endif
+
+EXPORT_SYMBOL(__get_SP);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index aa1df89..3cc6439 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1545,7 +1545,7 @@ void show_stack(struct task_struct *tsk, unsigned long 
*stack)
tsk = current;
if (sp == 0) {
if (tsk == current)
-   asm(mr %0,1 : =r (sp));
+   sp = __get_SP();
else
sp = tsk-thread.ksp;
}
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 3d30ef1..7f65bae 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -50,7 +50,7 @@ void save_stack_trace(struct stack_trace *trace)
 {
unsigned long sp;
 
-   asm(mr %0,1 : =r (sp));
+   sp = __get_SP

[PATCH 2/3] powerpc: Rename __get_SP() to current_stack_pointer()

2014-10-13 Thread Anton Blanchard
Michael points out that __get_SP() is a pretty horrible
function name. Let's give it a better name.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/perf_event.h | 2 +-
 arch/powerpc/include/asm/reg.h| 2 +-
 arch/powerpc/kernel/irq.c | 2 +-
 arch/powerpc/kernel/misc.S| 2 +-
 arch/powerpc/kernel/ppc_ksyms.c   | 2 +-
 arch/powerpc/kernel/process.c | 2 +-
 arch/powerpc/kernel/stacktrace.c  | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/include/asm/perf_event.h 
b/arch/powerpc/include/asm/perf_event.h
index b058568..8bf1b63 100644
--- a/arch/powerpc/include/asm/perf_event.h
+++ b/arch/powerpc/include/asm/perf_event.h
@@ -34,7 +34,7 @@
do {\
(regs)-result = 0; \
(regs)-nip = __ip; \
-   (regs)-gpr[1] = __get_SP();\
+   (regs)-gpr[1] = current_stack_pointer();   \
asm volatile(mfmsr %0 : =r ((regs)-msr));  \
} while (0)
 #endif
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index e539d7e..c998279 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1265,7 +1265,7 @@ static inline unsigned long mfvtb (void)
 
 #define proc_trap()asm volatile(trap)
 
-extern unsigned long __get_SP(void);
+extern unsigned long current_stack_pointer(void);
 
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 8eb857f..c143835 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -466,7 +466,7 @@ static inline void check_stack_overflow(void)
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
long sp;
 
-   sp = __get_SP()  (THREAD_SIZE-1);
+   sp = current_stack_pointer()  (THREAD_SIZE-1);
 
/* check for stack overflow: is there less than 2KB free? */
if (unlikely(sp  (sizeof(struct thread_info) + 2048))) {
diff --git a/arch/powerpc/kernel/misc.S b/arch/powerpc/kernel/misc.S
index 120deb7..0d43219 100644
--- a/arch/powerpc/kernel/misc.S
+++ b/arch/powerpc/kernel/misc.S
@@ -115,6 +115,6 @@ _GLOBAL(longjmp)
mr  r3,r4
blr
 
-_GLOBAL(__get_SP)
+_GLOBAL(current_stack_pointer)
PPC_LL  r3,0(r1)
blr
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 9d84efb..202963e 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -42,4 +42,4 @@ EXPORT_SYMBOL(giveup_spe);
 EXPORT_SYMBOL(epapr_hypercall_start);
 #endif
 
-EXPORT_SYMBOL(__get_SP);
+EXPORT_SYMBOL(current_stack_pointer);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 3cc6439..923cd2d 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1545,7 +1545,7 @@ void show_stack(struct task_struct *tsk, unsigned long 
*stack)
tsk = current;
if (sp == 0) {
if (tsk == current)
-   sp = __get_SP();
+   sp = current_stack_pointer();
else
sp = tsk-thread.ksp;
}
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 7f65bae..ea43a34 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -50,7 +50,7 @@ void save_stack_trace(struct stack_trace *trace)
 {
unsigned long sp;
 
-   sp = __get_SP();
+   sp = current_stack_pointer();
 
save_context_stack(trace, sp, current, 1);
 }
-- 
1.9.1

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

[PATCH 3/3] powerpc/pseries: Use dump_stack instead of show_stack

2014-10-13 Thread Anton Blanchard
We can use the simpler dump_stack() instead of
show_stack(current, __get_SP())

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/platforms/pseries/iommu.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/iommu.c 
b/arch/powerpc/platforms/pseries/iommu.c
index de1ec54..e32e009 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -30,7 +30,6 @@
 #include linux/mm.h
 #include linux/memblock.h
 #include linux/spinlock.h
-#include linux/sched.h   /* for show_stack */
 #include linux/string.h
 #include linux/pci.h
 #include linux/dma-mapping.h
@@ -168,7 +167,7 @@ static int tce_build_pSeriesLP(struct iommu_table *tbl, 
long tcenum,
printk(\tindex   = 0x%llx\n, (u64)tbl-it_index);
printk(\ttcenum  = 0x%llx\n, (u64)tcenum);
printk(\ttce val = 0x%llx\n, tce );
-   show_stack(current, (unsigned long *)__get_SP());
+   dump_stack();
}
 
tcenum++;
@@ -257,7 +256,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table 
*tbl, long tcenum,
printk(\tindex   = 0x%llx\n, (u64)tbl-it_index);
printk(\tnpages  = 0x%llx\n, (u64)npages);
printk(\ttce[0] val = 0x%llx\n, tcep[0]);
-   show_stack(current, (unsigned long *)__get_SP());
+   dump_stack();
}
return ret;
 }
@@ -273,7 +272,7 @@ static void tce_free_pSeriesLP(struct iommu_table *tbl, 
long tcenum, long npages
printk(tce_free_pSeriesLP: plpar_tce_put failed. 
rc=%lld\n, rc);
printk(\tindex   = 0x%llx\n, (u64)tbl-it_index);
printk(\ttcenum  = 0x%llx\n, (u64)tcenum);
-   show_stack(current, (unsigned long *)__get_SP());
+   dump_stack();
}
 
tcenum++;
@@ -292,7 +291,7 @@ static void tce_freemulti_pSeriesLP(struct iommu_table 
*tbl, long tcenum, long n
printk(\trc  = %lld\n, rc);
printk(\tindex   = 0x%llx\n, (u64)tbl-it_index);
printk(\tnpages  = 0x%llx\n, (u64)npages);
-   show_stack(current, (unsigned long *)__get_SP());
+   dump_stack();
}
 }
 
@@ -307,7 +306,7 @@ static unsigned long tce_get_pSeriesLP(struct iommu_table 
*tbl, long tcenum)
printk(tce_get_pSeriesLP: plpar_tce_get failed. rc=%lld\n, 
rc);
printk(\tindex   = 0x%llx\n, (u64)tbl-it_index);
printk(\ttcenum  = 0x%llx\n, (u64)tcenum);
-   show_stack(current, (unsigned long *)__get_SP());
+   dump_stack();
}
 
return tce_ret;
-- 
1.9.1

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

[PATCH 1/2] ipr: Convert to generic DMA API

2014-10-13 Thread Anton Blanchard
Even though the ipr driver is only used on PCI, convert it
to use the generic DMA API.

Signed-off-by: Anton Blanchard an...@samba.org
---
 drivers/scsi/ipr.c | 101 +++--
 drivers/scsi/ipr.h |   2 +-
 2 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 924b0ba..3aa28bd 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -3932,8 +3932,9 @@ static int ipr_update_ioa_ucode(struct ipr_ioa_cfg 
*ioa_cfg,
return -EIO;
}
 
-   sglist-num_dma_sg = pci_map_sg(ioa_cfg-pdev, sglist-scatterlist,
-   sglist-num_sg, DMA_TO_DEVICE);
+   sglist-num_dma_sg = dma_map_sg(ioa_cfg-pdev-dev,
+   sglist-scatterlist, sglist-num_sg,
+   DMA_TO_DEVICE);
 
if (!sglist-num_dma_sg) {
spin_unlock_irqrestore(ioa_cfg-host-host_lock, lock_flags);
@@ -5575,7 +5576,7 @@ static int ipr_build_ioadl64(struct ipr_ioa_cfg *ioa_cfg,
nseg = scsi_dma_map(scsi_cmd);
if (nseg  0) {
if (printk_ratelimit())
-   dev_err(ioa_cfg-pdev-dev, pci_map_sg failed!\n);
+   dev_err(ioa_cfg-pdev-dev, scsi_dma_map failed!\n);
return -1;
}
 
@@ -5626,7 +5627,7 @@ static int ipr_build_ioadl(struct ipr_ioa_cfg *ioa_cfg,
 
nseg = scsi_dma_map(scsi_cmd);
if (nseg  0) {
-   dev_err(ioa_cfg-pdev-dev, pci_map_sg failed!\n);
+   dev_err(ioa_cfg-pdev-dev, scsi_dma_map failed!\n);
return -1;
}
 
@@ -8421,7 +8422,7 @@ static int ipr_reset_ucode_download_done(struct ipr_cmnd 
*ipr_cmd)
struct ipr_ioa_cfg *ioa_cfg = ipr_cmd-ioa_cfg;
struct ipr_sglist *sglist = ioa_cfg-ucode_sglist;
 
-   pci_unmap_sg(ioa_cfg-pdev, sglist-scatterlist,
+   dma_unmap_sg(ioa_cfg-pdev-dev, sglist-scatterlist,
 sglist-num_sg, DMA_TO_DEVICE);
 
ipr_cmd-job_step = ipr_reset_alert;
@@ -8861,7 +8862,7 @@ static void ipr_free_cmd_blks(struct ipr_ioa_cfg *ioa_cfg)
 
for (i = 0; i  IPR_NUM_CMD_BLKS; i++) {
if (ioa_cfg-ipr_cmnd_list[i])
-   pci_pool_free(ioa_cfg-ipr_cmd_pool,
+   dma_pool_free(ioa_cfg-ipr_cmd_pool,
  ioa_cfg-ipr_cmnd_list[i],
  ioa_cfg-ipr_cmnd_list_dma[i]);
 
@@ -8869,7 +8870,7 @@ static void ipr_free_cmd_blks(struct ipr_ioa_cfg *ioa_cfg)
}
 
if (ioa_cfg-ipr_cmd_pool)
-   pci_pool_destroy(ioa_cfg-ipr_cmd_pool);
+   dma_pool_destroy(ioa_cfg-ipr_cmd_pool);
 
kfree(ioa_cfg-ipr_cmnd_list);
kfree(ioa_cfg-ipr_cmnd_list_dma);
@@ -8890,25 +8891,24 @@ static void ipr_free_mem(struct ipr_ioa_cfg *ioa_cfg)
int i;
 
kfree(ioa_cfg-res_entries);
-   pci_free_consistent(ioa_cfg-pdev, sizeof(struct ipr_misc_cbs),
-   ioa_cfg-vpd_cbs, ioa_cfg-vpd_cbs_dma);
+   dma_free_coherent(ioa_cfg-pdev-dev, sizeof(struct ipr_misc_cbs),
+ ioa_cfg-vpd_cbs, ioa_cfg-vpd_cbs_dma);
ipr_free_cmd_blks(ioa_cfg);
 
for (i = 0; i  ioa_cfg-hrrq_num; i++)
-   pci_free_consistent(ioa_cfg-pdev,
-   sizeof(u32) * ioa_cfg-hrrq[i].size,
-   ioa_cfg-hrrq[i].host_rrq,
-   ioa_cfg-hrrq[i].host_rrq_dma);
+   dma_free_coherent(ioa_cfg-pdev-dev,
+ sizeof(u32) * ioa_cfg-hrrq[i].size,
+ ioa_cfg-hrrq[i].host_rrq,
+ ioa_cfg-hrrq[i].host_rrq_dma);
 
-   pci_free_consistent(ioa_cfg-pdev, ioa_cfg-cfg_table_size,
-   ioa_cfg-u.cfg_table,
-   ioa_cfg-cfg_table_dma);
+   dma_free_coherent(ioa_cfg-pdev-dev, ioa_cfg-cfg_table_size,
+ ioa_cfg-u.cfg_table, ioa_cfg-cfg_table_dma);
 
for (i = 0; i  IPR_NUM_HCAMS; i++) {
-   pci_free_consistent(ioa_cfg-pdev,
-   sizeof(struct ipr_hostrcb),
-   ioa_cfg-hostrcb[i],
-   ioa_cfg-hostrcb_dma[i]);
+   dma_free_coherent(ioa_cfg-pdev-dev,
+ sizeof(struct ipr_hostrcb),
+ ioa_cfg-hostrcb[i],
+ ioa_cfg-hostrcb_dma[i]);
}
 
ipr_free_dump(ioa_cfg);
@@ -8969,7 +8969,7 @@ static int ipr_alloc_cmd_blks(struct ipr_ioa_cfg *ioa_cfg)
dma_addr_t dma_addr;
int i, entries_each_hrrq, hrrq_id = 0;
 
-   ioa_cfg-ipr_cmd_pool = pci_pool_create(IPR_NAME, ioa_cfg-pdev,
+   ioa_cfg-ipr_cmd_pool = dma_pool_create(IPR_NAME

[PATCH 2/2] ipr: set coherent DMA mask

2014-10-13 Thread Anton Blanchard
Use dma_set_mask_and_coherent() to set both the DMA and coherent
DMA mask.

Signed-off-by: Anton Blanchard an...@samba.org
---
 drivers/scsi/ipr.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 3aa28bd..15f4575 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -9611,16 +9611,17 @@ static int ipr_probe_ioa(struct pci_dev *pdev,
ipr_init_regs(ioa_cfg);
 
if (ioa_cfg-sis64) {
-   rc = dma_set_mask(pdev-dev, DMA_BIT_MASK(64));
+   rc = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(64));
if (rc  0) {
-   dev_dbg(pdev-dev, Failed to set 64 bit PCI DMA 
mask\n);
-   rc = dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
+   dev_dbg(pdev-dev, Failed to set 64 bit DMA mask\n);
+   rc = dma_set_mask_and_coherent(pdev-dev,
+  DMA_BIT_MASK(32));
}
} else
-   rc = dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
+   rc = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
 
if (rc  0) {
-   dev_err(pdev-dev, Failed to set PCI DMA mask\n);
+   dev_err(pdev-dev, Failed to set DMA mask\n);
goto cleanup_nomem;
}
 
-- 
1.9.1

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

[PATCH] powerpc: sync pseries_le_defconfig with pseries_defconfig

2014-10-13 Thread Anton Blanchard
Now KVM is working on LE, enable it. Also enable transarent
hugepage which has already been enabled on BE.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/configs/pseries_le_defconfig | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/configs/pseries_le_defconfig 
b/arch/powerpc/configs/pseries_le_defconfig
index 4428ee4..96a230c 100644
--- a/arch/powerpc/configs/pseries_le_defconfig
+++ b/arch/powerpc/configs/pseries_le_defconfig
@@ -48,7 +48,6 @@ CONFIG_KEXEC=y
 CONFIG_IRQ_ALL_CPUS=y
 CONFIG_MEMORY_HOTPLUG=y
 CONFIG_MEMORY_HOTREMOVE=y
-CONFIG_CMA=y
 CONFIG_PPC_64K_PAGES=y
 CONFIG_PPC_SUBPAGE_PROT=y
 CONFIG_SCHED_SMT=y
@@ -137,6 +136,7 @@ CONFIG_NETCONSOLE=y
 CONFIG_NETPOLL_TRAP=y
 CONFIG_TUN=m
 CONFIG_VIRTIO_NET=m
+CONFIG_VHOST_NET=m
 CONFIG_VORTEX=y
 CONFIG_ACENIC=m
 CONFIG_ACENIC_OMIT_TIGON_I=y
@@ -302,4 +302,9 @@ CONFIG_CRYPTO_LZO=m
 # CONFIG_CRYPTO_ANSI_CPRNG is not set
 CONFIG_CRYPTO_DEV_NX=y
 CONFIG_CRYPTO_DEV_NX_ENCRYPT=m
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM_BOOK3S_64=m
+CONFIG_KVM_BOOK3S_64_HV=y
+CONFIG_TRANSPARENT_HUGEPAGE=y
+CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
-- 
1.9.1

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

[PATCH] powerpc: Add printk levels to setup_system output

2014-10-13 Thread Anton Blanchard
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/setup_64.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index cd07d79..4f3cfe1 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -522,36 +522,36 @@ void __init setup_system(void)
smp_release_cpus();
 #endif
 
-   printk(Starting Linux PPC64 %s\n, init_utsname()-version);
+   pr_info(Starting Linux PPC64 %s\n, init_utsname()-version);
 
-   printk(-\n);
-   printk(ppc64_pft_size= 0x%llx\n, ppc64_pft_size);
-   printk(phys_mem_size = 0x%llx\n, memblock_phys_mem_size());
+   pr_info(-\n);
+   pr_info(ppc64_pft_size= 0x%llx\n, ppc64_pft_size);
+   pr_info(phys_mem_size = 0x%llx\n, memblock_phys_mem_size());
 
if (ppc64_caches.dline_size != 0x80)
-   printk(dcache_line_size  = 0x%x\n, ppc64_caches.dline_size);
+   pr_info(dcache_line_size  = 0x%x\n, ppc64_caches.dline_size);
if (ppc64_caches.iline_size != 0x80)
-   printk(icache_line_size  = 0x%x\n, ppc64_caches.iline_size);
+   pr_info(icache_line_size  = 0x%x\n, ppc64_caches.iline_size);
 
-   printk(cpu_features  = 0x%016lx\n, cur_cpu_spec-cpu_features);
-   printk(  possible= 0x%016lx\n, CPU_FTRS_POSSIBLE);
-   printk(  always  = 0x%016lx\n, CPU_FTRS_ALWAYS);
-   printk(cpu_user_features = 0x%08x 0x%08x\n, 
cur_cpu_spec-cpu_user_features,
+   pr_info(cpu_features  = 0x%016lx\n, cur_cpu_spec-cpu_features);
+   pr_info(  possible= 0x%016lx\n, CPU_FTRS_POSSIBLE);
+   pr_info(  always  = 0x%016lx\n, CPU_FTRS_ALWAYS);
+   pr_info(cpu_user_features = 0x%08x 0x%08x\n, 
cur_cpu_spec-cpu_user_features,
cur_cpu_spec-cpu_user_features2);
-   printk(mmu_features  = 0x%08x\n, cur_cpu_spec-mmu_features);
-   printk(firmware_features = 0x%016lx\n, powerpc_firmware_features);
+   pr_info(mmu_features  = 0x%08x\n, cur_cpu_spec-mmu_features);
+   pr_info(firmware_features = 0x%016lx\n, powerpc_firmware_features);
 
 #ifdef CONFIG_PPC_STD_MMU_64
if (htab_address)
-   printk(htab_address  = 0x%p\n, htab_address);
+   pr_info(htab_address  = 0x%p\n, htab_address);
 
-   printk(htab_hash_mask= 0x%lx\n, htab_hash_mask);
+   pr_info(htab_hash_mask= 0x%lx\n, htab_hash_mask);
 #endif
 
if (PHYSICAL_START  0)
-   printk(physical_start= 0x%llx\n,
+   pr_info(physical_start= 0x%llx\n,
   (unsigned long long)PHYSICAL_START);
-   printk(-\n);
+   pr_info(-\n);
 
DBG( - setup_system()\n);
 }
-- 
1.9.1

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

[PATCH] powerpc: Use probe_kernel_address in show_instructions

2014-10-13 Thread Anton Blanchard
We really don't want to take a pagefault in show_instructions,
so use probe_kernel_address instead of __get_user.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/process.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 923cd2d..e5698f1 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -37,9 +37,9 @@
 #include linux/personality.h
 #include linux/random.h
 #include linux/hw_breakpoint.h
+#include linux/uaccess.h
 
 #include asm/pgtable.h
-#include asm/uaccess.h
 #include asm/io.h
 #include asm/processor.h
 #include asm/mmu.h
@@ -921,12 +921,8 @@ static void show_instructions(struct pt_regs *regs)
pc = (unsigned long)phys_to_virt(pc);
 #endif
 
-   /* We use __get_user here *only* to avoid an OOPS on a
-* bad address because the pc *should* only be a
-* kernel address.
-*/
if (!__kernel_text_address(pc) ||
-__get_user(instr, (unsigned int __user *)pc)) {
+probe_kernel_address((unsigned int __user *)pc, instr)) {
printk(KERN_CONT  );
} else {
if (regs-nip == pc)
-- 
1.9.1

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

[PATCH] powerpc/pci: Quieten unset I/O resource warning

2014-10-13 Thread Anton Blanchard
Newer POWER designs do not implement PCI I/O space, so we
expect to see a number of these.

Reduce the severity of the warning so it doesn't mask other
real issues.

Signed-off-by: Anton Blanchard an...@samba.org
---

Index: b/arch/powerpc/kernel/pci-common.c
===
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1460,7 +1460,7 @@ static void pcibios_setup_phb_resources(
res = hose-io_resource;
 
if (!res-flags) {
-   printk(KERN_WARNING PCI: I/O resource not set for host
+   pr_info(PCI: I/O resource not set for host
bridge %s (domain %d)\n,
   hose-dn-full_name, hose-global_number);
} else {
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc: Remove ppc_md.remove_memory

2014-10-13 Thread Anton Blanchard
We have an extra level of indirection on memory hot remove which is not
matched on memory hot add. Memory hotplug is book3s only, so there is
no need for it.

This also enables means remove_memory() (ie memory hot unplug) works
on powernv.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/machdep.h  |  4 
 arch/powerpc/mm/mem.c   | 12 ++--
 arch/powerpc/platforms/pseries/hotplug-memory.c | 21 -
 3 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h 
b/arch/powerpc/include/asm/machdep.h
index 902ab20..327e8dd 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -294,10 +294,6 @@ struct machdep_calls {
 #ifdef CONFIG_ARCH_RANDOM
int (*get_random_long)(unsigned long *v);
 #endif
-
-#ifdef CONFIG_MEMORY_HOTREMOVE
-   int (*remove_memory)(u64, u64);
-#endif
 };
 
 extern void e500_idle(void);
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 8ebaac7..b9f2e7c 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -35,6 +35,7 @@
 #include linux/memblock.h
 #include linux/hugetlb.h
 #include linux/slab.h
+#include linux/vmalloc.h
 
 #include asm/pgalloc.h
 #include asm/prom.h
@@ -144,8 +145,15 @@ int arch_remove_memory(u64 start, u64 size)
 
zone = page_zone(pfn_to_page(start_pfn));
ret = __remove_pages(zone, start_pfn, nr_pages);
-   if (!ret  (ppc_md.remove_memory))
-   ret = ppc_md.remove_memory(start, size);
+
+   start = (unsigned long)__va(start);
+   if (!ret)
+   ret = remove_section_mapping(start, start + size);
+
+   /* Ensure all vmalloc mappings are flushed in case they also
+* hit that section of memory
+*/
+   vm_unmap_aliases();
 
return ret;
 }
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c 
b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 187ecfa..d5426ec 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -12,7 +12,6 @@
 #include linux/of.h
 #include linux/of_address.h
 #include linux/memblock.h
-#include linux/vmalloc.h
 #include linux/memory.h
 #include linux/memory_hotplug.h
 
@@ -66,22 +65,6 @@ unsigned long pseries_memory_block_size(void)
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-static int pseries_remove_memory(u64 start, u64 size)
-{
-   int ret;
-
-   /* Remove htab bolted mappings for this section of memory */
-   start = (unsigned long)__va(start);
-   ret = remove_section_mapping(start, start + size);
-
-   /* Ensure all vmalloc mappings are flushed in case they also
-* hit that section of memory
-*/
-   vm_unmap_aliases();
-
-   return ret;
-}
-
 static int pseries_remove_memblock(unsigned long base, unsigned int 
memblock_size)
 {
unsigned long block_sz, start_pfn;
@@ -262,10 +245,6 @@ static int __init pseries_memory_hotplug_init(void)
if (firmware_has_feature(FW_FEATURE_LPAR))
of_reconfig_notifier_register(pseries_mem_nb);
 
-#ifdef CONFIG_MEMORY_HOTREMOVE
-   ppc_md.remove_memory = pseries_remove_memory;
-#endif
-
return 0;
 }
 machine_device_initcall(pseries, pseries_memory_hotplug_init);
-- 
1.9.1

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

[PATCH] powerpc: Remove ppc64_boot_msg

2014-10-13 Thread Anton Blanchard
ppc64_boot_msg is meant to be a boot debug aid, but
is only used in one spot. Get rid of it, and save
ourseleves a couple of lines in the kernel log
buffer.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/machdep.h | 10 --
 arch/powerpc/kernel/setup_64.c | 29 -
 2 files changed, 39 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h 
b/arch/powerpc/include/asm/machdep.h
index 327e8dd..6ac6dfd 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -341,16 +341,6 @@ extern sys_ctrler_t sys_ctrler;
 
 #endif /* CONFIG_PPC_PMAC */
 
-
-/* Functions to produce codes on the leds.
- * The SRC code should be unique for the message category and should
- * be limited to the lower 24 bits (the upper 8 are set by these funcs),
- * and (for boot  dump) should be sorted numerically in the order
- * the events occur.
- */
-/* Print a boot progress message. */
-void ppc64_boot_msg(unsigned int src, const char *msg);
-
 static inline void log_error(char *buf, unsigned int err_type, int fatal)
 {
if (ppc_md.log_error)
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 317e96a..1b56320 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -665,8 +665,6 @@ static void __init emergency_stack_init(void)
  */
 void __init setup_arch(char **cmdline_p)
 {
-   ppc64_boot_msg(0x12, Setup Arch);
-
*cmdline_p = boot_command_line;
 
/*
@@ -711,33 +709,6 @@ void __init setup_arch(char **cmdline_p)
if ((unsigned long)_stext  0x)
panic(Kernelbase not 64K-aligned (0x%lx)!\n,
  (unsigned long)_stext);
-
-   ppc64_boot_msg(0x15, Setup Done);
-}
-
-
-/* ToDo: do something useful if ppc_md is not yet setup. */
-#define PPC64_LINUX_FUNCTION 0x0f00
-#define PPC64_IPL_MESSAGE 0xc000
-#define PPC64_TERM_MESSAGE 0xb000
-
-static void ppc64_do_msg(unsigned int src, const char *msg)
-{
-   if (ppc_md.progress) {
-   char buf[128];
-
-   sprintf(buf, %08X\n, src);
-   ppc_md.progress(buf, 0);
-   snprintf(buf, 128, %s, msg);
-   ppc_md.progress(buf, 0);
-   }
-}
-
-/* Print a boot progress message. */
-void ppc64_boot_msg(unsigned int src, const char *msg)
-{
-   ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_IPL_MESSAGE|src, msg);
-   printk([boot]%04x %s\n, src, msg);
 }
 
 #ifdef CONFIG_SMP
-- 
1.9.1

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

Re: [PATCH v3] powerpc/iommu/ddw: Fix endianness

2014-10-02 Thread Anton Blanchard
Hi Alexey,

 rtas_call() accepts and returns values in CPU endianness.
 The ddw_query_response and ddw_create_response structs members are
 defined and treated as BE but as they are passed to rtas_call() as
 (u32 *) and they get byteswapped automatically, the data is
 CPU-endian. This fixes ddw_query_response and ddw_create_response
 definitions and use.
 
 of_read_number() is designed to work with device tree cells - it
 assumes the input is big-endian and returns data in CPU-endian.
 However due to the ddw_create_response struct fix, create.addr_hi/lo
 are already CPU-endian so do not byteswap them.
 
 ddw_avail is a pointer to the ibm,ddw-applicable property which
 contains 3 cells which are big-endian as it is a device tree.
 rtas_call() accepts a RTAS token in CPU-endian. This makes use of
 of_property_read_u32_array to byte swap and avoid the need for a
 number of be32_to_cpu calls.
 
 Cc: sta...@vger.kernel.org # v3.13
 Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
 Reviewed-by: Anton Blanchard an...@samba.org
 [aik: folded Anton's patch with of_property_read_u32_array]
 Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru

Thanks for updating, looks good. Could we make it clear the bug is
present in 3.13-3.17 with:

Cc: sta...@vger.kernel.org # v3.13+

Acked-by: Anton Blanchard an...@samba.org

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

[PATCH] powerpc: Rename __get_SP() to current_stack_pointer()

2014-10-01 Thread Anton Blanchard
Michael points out that __get_SP() is a pretty horrible
function name. Let's give it a better name.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/perf_event.h | 2 +-
 arch/powerpc/include/asm/reg.h| 2 +-
 arch/powerpc/kernel/irq.c | 2 +-
 arch/powerpc/kernel/misc.S| 2 +-
 arch/powerpc/kernel/process.c | 2 +-
 arch/powerpc/kernel/stacktrace.c  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/perf_event.h 
b/arch/powerpc/include/asm/perf_event.h
index 0bb2372..fc53598 100644
--- a/arch/powerpc/include/asm/perf_event.h
+++ b/arch/powerpc/include/asm/perf_event.h
@@ -34,7 +34,7 @@
do {\
(regs)-result = 0; \
(regs)-nip = __ip; \
-   (regs)-gpr[1] = *(unsigned long *)__get_SP();  \
+   (regs)-gpr[1] = *(unsigned long *)current_stack_pointer(); \
asm volatile(mfmsr %0 : =r ((regs)-msr));  \
} while (0)
 #endif
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 0f973c0..d8974b5 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1264,7 +1264,7 @@ static inline unsigned long mfvtb (void)
 
 #define proc_trap()asm volatile(trap)
 
-extern unsigned long __get_SP(void);
+extern unsigned long current_stack_pointer(void);
 
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 8eb857f..c143835 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -466,7 +466,7 @@ static inline void check_stack_overflow(void)
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
long sp;
 
-   sp = __get_SP()  (THREAD_SIZE-1);
+   sp = current_stack_pointer()  (THREAD_SIZE-1);
 
/* check for stack overflow: is there less than 2KB free? */
if (unlikely(sp  (sizeof(struct thread_info) + 2048))) {
diff --git a/arch/powerpc/kernel/misc.S b/arch/powerpc/kernel/misc.S
index 120deb7..0d43219 100644
--- a/arch/powerpc/kernel/misc.S
+++ b/arch/powerpc/kernel/misc.S
@@ -115,6 +115,6 @@ _GLOBAL(longjmp)
mr  r3,r4
blr
 
-_GLOBAL(__get_SP)
+_GLOBAL(current_stack_pointer)
PPC_LL  r3,0(r1)
blr
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 3cc6439..923cd2d 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1545,7 +1545,7 @@ void show_stack(struct task_struct *tsk, unsigned long 
*stack)
tsk = current;
if (sp == 0) {
if (tsk == current)
-   sp = __get_SP();
+   sp = current_stack_pointer();
else
sp = tsk-thread.ksp;
}
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 7f65bae..ea43a34 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -50,7 +50,7 @@ void save_stack_trace(struct stack_trace *trace)
 {
unsigned long sp;
 
-   sp = __get_SP();
+   sp = current_stack_pointer();
 
save_context_stack(trace, sp, current, 1);
 }
-- 
1.9.1



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

[PATCH v2] powerpc: Speed up clear_page by unrolling it

2014-10-01 Thread Anton Blanchard
Unroll clear_page 8 times. A simple microbenchmark which
allocates and frees a zeroed page:

for (i = 0; i  iterations; i++) {
unsigned long p = __get_free_page(GFP_KERNEL | __GFP_ZERO);
free_page(p);
}

improves 20% on POWER8.

This assumes cacheline sizes won't grow beyond 512 bytes or
page sizes wont drop below 1kB, which is unlikely, but we could
add a runtime check during early init if it makes people nervous.

Michael found that some versions of gcc produce quite bad code
(all multiplies), so we give gcc a hand by using shifts and adds.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/page_64.h | 42 --
 1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/page_64.h 
b/arch/powerpc/include/asm/page_64.h
index d0d6afb..d908a46 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -42,20 +42,40 @@
 
 typedef unsigned long pte_basic_t;
 
-static __inline__ void clear_page(void *addr)
+static inline void clear_page(void *addr)
 {
-   unsigned long lines, line_size;
-
-   line_size = ppc64_caches.dline_size;
-   lines = ppc64_caches.dlines_per_page;
-
-   __asm__ __volatile__(
+   unsigned long iterations;
+   unsigned long onex, twox, fourx, eightx;
+
+   iterations = ppc64_caches.dlines_per_page / 8;
+
+   /*
+* Some verisions of gcc use multiply instructions to
+* calculate the offsets so lets give it a hand to
+* do better.
+*/
+   onex = ppc64_caches.dline_size;
+   twox = onex  1;
+   fourx = onex  2;
+   eightx = onex  3;
+
+   asm volatile(
mtctr  %1  # clear_page\n\
-1:  dcbz   0,%0\n\
-   add %0,%0,%3\n\
+   .balign 16\n\
+1: dcbz0,%0\n\
+   dcbz%3,%0\n\
+   dcbz%4,%0\n\
+   dcbz%5,%0\n\
+   dcbz%6,%0\n\
+   dcbz%7,%0\n\
+   dcbz%8,%0\n\
+   dcbz%9,%0\n\
+   add %0,%0,%10\n\
bdnz+   1b
-: =r (addr)
-: r (lines), 0 (addr), r (line_size)
+   : =r (addr)
+   : r (iterations), 0 (addr), b (onex), b (twox),
+   b (twox+onex), b (fourx), b (fourx+onex),
+   b (twox+fourx), b (eightx-onex), r (eightx)
: ctr, memory);
 }
 
-- 
1.9.1

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

[PATCH] powerpc: Reimplement __get_SP() as a function not a define

2014-09-30 Thread Anton Blanchard
Li Zhong points out an issue with our current __get_SP()
implementation. If ftrace function tracing is enabled (ie -pg
profiling using _mcount) we spill a stack frame on 64bit all the
time.

If a function calls __get_SP() and later calls a function that is
tail call optimised, we will pop the stack frame and the value
returned by __get_SP() is no longer valid. An example from Li can
be found in save_stack_trace - save_context_stack:

c00432c0 .save_stack_trace:
c00432c0:   mflrr0
c00432c4:   std r0,16(r1)
c00432c8:   stdur1,-128(r1) -- stack frame for _mcount
c00432cc:   std r3,112(r1)
c00432d0:   bl  ._mcount
c00432d4:   nop

c00432d8:   mr  r4,r1 -- __get_SP()

c00432dc:   ld  r5,632(r13)
c00432e0:   ld  r3,112(r1)
c00432e4:   li  r6,1

c00432e8:   addir1,r1,128 -- pop stack frame

c00432ec:   ld  r0,16(r1)
c00432f0:   mtlrr0
c00432f4:   b   .save_context_stack -- tail call optimized

save_context_stack ends up with a stack pointer below the current
one, and it is likely to be scribbled over.

Fix this by making __get_SP() a function which returns the
callers stack frame. Also replace inline assembly which grabs
the stack pointer in save_stack_trace and show_stack with
__get_SP().

Reported-by: Li Zhong zh...@linux.vnet.ibm.com
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/reg.h   | 3 +--
 arch/powerpc/kernel/misc.S   | 4 
 arch/powerpc/kernel/process.c| 2 +-
 arch/powerpc/kernel/stacktrace.c | 2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 0c05059..0f973c0 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1264,8 +1264,7 @@ static inline unsigned long mfvtb (void)
 
 #define proc_trap()asm volatile(trap)
 
-#define __get_SP() ({unsigned long sp; \
-   asm volatile(mr %0,1: =r (sp)); sp;})
+extern unsigned long __get_SP(void);
 
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);
diff --git a/arch/powerpc/kernel/misc.S b/arch/powerpc/kernel/misc.S
index 7ce26d4..120deb7 100644
--- a/arch/powerpc/kernel/misc.S
+++ b/arch/powerpc/kernel/misc.S
@@ -114,3 +114,7 @@ _GLOBAL(longjmp)
mtlrr0
mr  r3,r4
blr
+
+_GLOBAL(__get_SP)
+   PPC_LL  r3,0(r1)
+   blr
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index aa1df89..3cc6439 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1545,7 +1545,7 @@ void show_stack(struct task_struct *tsk, unsigned long 
*stack)
tsk = current;
if (sp == 0) {
if (tsk == current)
-   asm(mr %0,1 : =r (sp));
+   sp = __get_SP();
else
sp = tsk-thread.ksp;
}
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 3d30ef1..7f65bae 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -50,7 +50,7 @@ void save_stack_trace(struct stack_trace *trace)
 {
unsigned long sp;
 
-   asm(mr %0,1 : =r (sp));
+   sp = __get_SP();
 
save_context_stack(trace, sp, current, 1);
 }
-- 
1.9.1

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

Re: [PATCH 10/15] powerpc/mm: Add hooks for cxl

2014-09-26 Thread Anton Blanchard

Hi Mikey,

 We only map what a user processes maps and we tear it down when the
 process is teared down (on the file descriptor release).  So I think
 we are ok.  
 
 Unless there's some lazy teardown you're alluding to that I'm missing?

I was trying to make sure things like the TLB batching code won't allow
a tlbie to be postponed until after a CAPI mapping is destroyed. It's
been ages since I looked at that part of the mm code.

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

Re: [PATCH 01/15] powerpc/cell: Move spu_handle_mm_fault() out of cell platform

2014-09-25 Thread Anton Blanchard
 From: Ian Munsie imun...@au1.ibm.com
 
 Currently spu_handle_mm_fault() is in the cell platform.
 
 This code is generically useful for other non-cell co-processors on
 powerpc.
 
 This patch moves this function out of the cell platform into
 arch/powerpc/mm so that others may use it.
 
 Signed-off-by: Ian Munsie imun...@au1.ibm.com
 Signed-off-by: Michael Neuling mi...@neuling.org

Reviewed-by: Anton Blanchard an...@samba.org

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

Re: [PATCH 02/15] powerpc/cell: Move data segment faulting code out of cell platform

2014-09-25 Thread Anton Blanchard

 From: Ian Munsie imun...@au1.ibm.com
 
 __spu_trap_data_seg() currently contains code to determine the VSID
 and ESID required for a particular EA and mm struct.
 
 This code is generically useful for other co-processors.  This moves
 the code of the cell platform so it can be used by other powerpc code.

Could we also mention:

and adds 1TB segment support.

 Signed-off-by: Ian Munsie imun...@au1.ibm.com
 Signed-off-by: Michael Neuling mi...@neuling.org

Reviewed-by: Anton Blanchard an...@samba.org

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

Re: [PATCH 10/15] powerpc/mm: Add hooks for cxl

2014-09-25 Thread Anton Blanchard
 From: Ian Munsie imun...@au1.ibm.com
 
 This add a hook into tlbie() so that we use global invalidations when
 there are cxl contexts active.
 
 Normally cxl snoops broadcast tlbie.  cxl can have TLB entries
 invalidated via MMIO, but we aren't doing that yet.  So for now we
 are just disabling local tlbies when cxl contexts are active.  In
 future we can make tlbie() local mode smarter so that it invalidates
 cxl contexts explicitly when it needs to.
 
 This also adds a hooks for when SLBs are invalidated to ensure any
 corresponding SLBs in cxl are also invalidated at the same time.
 
 Signed-off-by: Ian Munsie imun...@au1.ibm.com
 Signed-off-by: Michael Neuling mi...@neuling.org

 + use_local = local  mmu_has_feature(MMU_FTR_TLBIEL)  
 !cxl_ctx_in_use();

Seems reasonable until we can get the MMIO based optimisation in.

Will all CAPI cached translations be invalidated before we finish using
a CAPI context? And conversely, could CAPI cache any translations when a
context isn't active? I'm mostly concerned that we can't have a
situation where badly behaving userspace could result in a stale
translation.

   spu_flush_all_slbs(mm);
  #endif
 + cxl_slbia(mm);

   spu_flush_all_slbs(mm);
  #endif
 + cxl_slbia(mm);

   spu_flush_all_slbs(mm);
  #endif
 + cxl_slbia(mm);

   spu_flush_all_slbs(mm);
  #endif
 + cxl_slbia(mm);

Should we combine the SPU vs CXL callouts into something common -
perhaps copro_flush_all_slbs()?

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

Re: [PATCH 09/15] powerpc/opal: Add PHB to cxl mode call

2014-09-25 Thread Anton Blanchard
 From: Ian Munsie imun...@au1.ibm.com
 
 This adds the OPAL call to change a PHB into cxl mode.
 
 Signed-off-by: Ian Munsie imun...@au1.ibm.com
 Signed-off-by: Michael Neuling mi...@neuling.org

Reviewed-by: Anton Blanchard an...@samba.org
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 1/3] powerpc: Simplify do_sigbus

2014-09-24 Thread Anton Blanchard
Exit out early for a kernel fault, avoiding indenting of
most of the function.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/mm/fault.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 51ab9e7..abc8c81 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -120,16 +120,16 @@ static int do_sigbus(struct pt_regs *regs, unsigned long 
address)
 
up_read(current-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;
-   info.si_addr = (void __user *)address;
-   force_sig_info(SIGBUS, info, current);
-   return MM_FAULT_RETURN;
-   }
-   return MM_FAULT_ERR(SIGBUS);
+   if (!user_mode(regs))
+   return MM_FAULT_ERR(SIGBUS);
+
+   current-thread.trap_nr = BUS_ADRERR;
+   info.si_signo = SIGBUS;
+   info.si_errno = 0;
+   info.si_code = BUS_ADRERR;
+   info.si_addr = (void __user *)address;
+   force_sig_info(SIGBUS, info, current);
+   return MM_FAULT_RETURN;
 }
 
 static int mm_fault_error(struct pt_regs *regs, unsigned long addr, int fault)
-- 
1.9.1

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

[PATCH 2/3] powerpc: Add VM_FAULT_HWPOISON handling to powerpc page fault handler

2014-09-24 Thread Anton Blanchard
do_page_fault was missing knowledge of HWPOISON, and we would oops
if userspace tried to access a poisoned page:

kernel BUG at arch/powerpc/mm/fault.c:180!

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/mm/fault.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index abc8c81..588b6cc 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -114,7 +114,8 @@ static int store_updates_sp(struct pt_regs *regs)
 #define MM_FAULT_CONTINUE  -1
 #define MM_FAULT_ERR(sig)  (sig)
 
-static int do_sigbus(struct pt_regs *regs, unsigned long address)
+static int do_sigbus(struct pt_regs *regs, unsigned long address,
+unsigned int fault)
 {
siginfo_t info;
 
@@ -128,6 +129,13 @@ static int do_sigbus(struct pt_regs *regs, unsigned long 
address)
info.si_errno = 0;
info.si_code = BUS_ADRERR;
info.si_addr = (void __user *)address;
+#ifdef CONFIG_MEMORY_FAILURE
+   if (fault  (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
+   pr_err(MCE: Killing %s:%d due to hardware memory corruption 
fault at %lx\n,
+   current-comm, current-pid, address);
+   info.si_code = BUS_MCEERR_AR;
+   }
+#endif
force_sig_info(SIGBUS, info, current);
return MM_FAULT_RETURN;
 }
@@ -170,11 +178,8 @@ static int mm_fault_error(struct pt_regs *regs, unsigned 
long addr, int fault)
return MM_FAULT_RETURN;
}
 
-   /* Bus error. x86 handles HWPOISON here, we'll add this if/when
-* we support the feature in HW
-*/
-   if (fault  VM_FAULT_SIGBUS)
-   return do_sigbus(regs, addr);
+   if (fault  (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE))
+   return do_sigbus(regs, addr, fault);
 
/* We don't understand the fault code, this is fatal */
BUG();
-- 
1.9.1

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

[PATCH 3/3] powerpc: Fill in si_addr_lsb siginfo field

2014-09-24 Thread Anton Blanchard
Fill in the si_addr_lsb siginfo field so the hwpoison code can
pass to userspace the length of memory that has been corrupted.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/mm/fault.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 588b6cc..24b3f49 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -33,6 +33,7 @@
 #include linux/magic.h
 #include linux/ratelimit.h
 #include linux/context_tracking.h
+#include linux/hugetlb.h
 
 #include asm/firmware.h
 #include asm/page.h
@@ -118,6 +119,7 @@ static int do_sigbus(struct pt_regs *regs, unsigned long 
address,
 unsigned int fault)
 {
siginfo_t info;
+   unsigned int lsb = 0;
 
up_read(current-mm-mmap_sem);
 
@@ -135,7 +137,13 @@ static int do_sigbus(struct pt_regs *regs, unsigned long 
address,
current-comm, current-pid, address);
info.si_code = BUS_MCEERR_AR;
}
+
+   if (fault  VM_FAULT_HWPOISON_LARGE)
+   lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault));
+   if (fault  VM_FAULT_HWPOISON)
+   lsb = PAGE_SHIFT;
 #endif
+   info.si_addr_lsb = lsb;
force_sig_info(SIGBUS, info, current);
return MM_FAULT_RETURN;
 }
-- 
1.9.1

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

Re: [PATCH 1/2] powerpc: Add VM_FAULT_HWPOISON handling to powerpc page fault handler

2014-09-24 Thread Anton Blanchard

Hi Stephen,

 If you had done this as 2 patches (one to remove the indent and a
 second to fix the actual problem), it would have been much easier to
 review ...

Good idea, I separated it out and resubmitted.

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

[PATCH] powerpc: Print instruction when logging unhandled exceptions

2014-09-24 Thread Anton Blanchard
It is often useful to see the instruction that caused an unhandled
exception.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/traps.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 0dc43f9..27e30c8 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -36,10 +36,10 @@
 #include linux/debugfs.h
 #include linux/ratelimit.h
 #include linux/context_tracking.h
+#include linux/uaccess.h
 
 #include asm/emulated_ops.h
 #include asm/pgtable.h
-#include asm/uaccess.h
 #include asm/io.h
 #include asm/machdep.h
 #include asm/rtas.h
@@ -242,9 +242,9 @@ void _exception(int signr, struct pt_regs *regs, int code, 
unsigned long addr)
 {
siginfo_t info;
const char fmt32[] = KERN_INFO %s[%d]: unhandled signal %d  \
-   at %08lx nip %08lx lr %08lx code %x\n;
+   at %08lx nip %08lx lr %08lx code %x insn %08x\n;
const char fmt64[] = KERN_INFO %s[%d]: unhandled signal %d  \
-   at %016lx nip %016lx lr %016lx code %x\n;
+   at %016lx nip %016lx lr %016lx code %x insn %08x\n;
 
if (!user_mode(regs)) {
die(Exception in kernel mode, regs, signr);
@@ -252,9 +252,18 @@ void _exception(int signr, struct pt_regs *regs, int code, 
unsigned long addr)
}
 
if (show_unhandled_signals  unhandled_signal(current, signr)) {
+   u32 __user *nia = (u32 __user *)regs-nip;
+   u32 insn = 0;
+
+   pagefault_disable();
+   if (!access_ok(VERIFY_READ, nia, sizeof(*nia)) ||
+   __get_user_inatomic(insn, nia))
+   insn = 0xUL;
+   pagefault_enable();
+
printk_ratelimited(regs-msr  MSR_64BIT ? fmt64 : fmt32,
   current-comm, current-pid, signr,
-  addr, regs-nip, regs-link, code);
+  addr, regs-nip, regs-link, code, insn);
}
 
if (arch_irqs_disabled()  !arch_irq_disabled_regs(regs))
-- 
1.9.1

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

Re: [PATCH v2] powerpc/iommu/ddw: Fix endianness

2014-09-23 Thread Anton Blanchard

Hi Alexey,

 ddw_avail is a pointer to the ibm,ddw-applicable property which
 contains 3 cells which are big-endian as it is a device tree.
 rtas_call() accepts a RTAS token in CPU-endian. This converts RTAS
 tokens from big-endian to CPU-endian. Since every token is used once
 till guest is rebooted, there is no much sense in caching RTAS tokens
 in CPU-endian.

I see a few sparse endian warnings with this. This patch (that applies
on top of yours) uses of_property_read_u32_array to byte swap and avoid
the need for a number of be32_to_cpu calls.

Can you verify this works and then fold it into yours? Also mark it for
inclusion in stable v3.13+.

You can add:

Reviewed-by: Anton Blanchard an...@samba.org

Thanks!
Anton

Index: b/arch/powerpc/platforms/pseries/iommu.c
===
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -725,16 +725,18 @@ static void remove_ddw(struct device_nod
 {
struct dynamic_dma_window_prop *dwp;
struct property *win64;
-   const u32 *ddw_avail;
+   u32 ddw_avail[3];
u64 liobn;
-   int len, ret = 0;
+   int ret = 0;
+
+   ret = of_property_read_u32_array(np, ibm,ddw-applicable,
+ddw_avail[0], 3);
 
-   ddw_avail = of_get_property(np, ibm,ddw-applicable, len);
win64 = of_find_property(np, DIRECT64_PROPNAME, NULL);
if (!win64)
return;
 
-   if (!ddw_avail || len  3 * sizeof(u32) || win64-length  sizeof(*dwp))
+   if (ret || win64-length  sizeof(*dwp))
goto delprop;
 
dwp = win64-value;
@@ -750,7 +752,7 @@ static void remove_ddw(struct device_nod
pr_debug(%s successfully cleared tces in window.\n,
 np-full_name);
 
-   ret = rtas_call(be32_to_cpu(ddw_avail[2]), 1, 1, NULL, liobn);
+   ret = rtas_call(ddw_avail[2], 1, 1, NULL, liobn);
if (ret)
pr_warning(%s: failed to remove direct window: rtas returned 
%d to ibm,remove-pe-dma-window(%x) %llx\n,
@@ -841,7 +843,7 @@ static int query_ddw(struct pci_dev *dev
cfg_addr = edev-pe_config_addr;
buid = edev-phb-buid;
 
-   ret = rtas_call(be32_to_cpu(ddw_avail[0]), 3, 5, (u32 *)query,
+   ret = rtas_call(ddw_avail[0], 3, 5, (u32 *)query,
  cfg_addr, BUID_HI(buid), BUID_LO(buid));
dev_info(dev-dev, ibm,query-pe-dma-windows(%x) %x %x %x
 returned %d\n, ddw_avail[0], cfg_addr, BUID_HI(buid),
@@ -872,7 +874,7 @@ static int create_ddw(struct pci_dev *de
 
do {
/* extra outputs are LIOBN and dma-addr (hi, lo) */
-   ret = rtas_call(be32_to_cpu(ddw_avail[1]), 5, 4, (u32 *)create,
+   ret = rtas_call(ddw_avail[1], 5, 4, (u32 *)create,
cfg_addr, BUID_HI(buid), BUID_LO(buid),
page_shift, window_shift);
} while (rtas_busy_delay(ret));
@@ -911,7 +913,7 @@ static u64 enable_ddw(struct pci_dev *de
int page_shift;
u64 dma_addr, max_addr;
struct device_node *dn;
-   const u32 *uninitialized_var(ddw_avail);
+   u32 ddw_avail[3];
struct direct_window *window;
struct property *win64;
struct dynamic_dma_window_prop *ddwprop;
@@ -943,8 +945,9 @@ static u64 enable_ddw(struct pci_dev *de
 * for the given node in that order.
 * the property is actually in the parent, not the PE
 */
-   ddw_avail = of_get_property(pdn, ibm,ddw-applicable, len);
-   if (!ddw_avail || len  3 * sizeof(u32))
+   ret = of_property_read_u32_array(pdn, ibm,ddw-applicable,
+ddw_avail[0], 3);
+   if (ret)
goto out_failed;
 
/*
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 1/2] powerpc: Add VM_FAULT_HWPOISON handling to powerpc page fault handler

2014-09-23 Thread Anton Blanchard
do_page_fault was missing knowledge of HWPOISON, and we would oops
if userspace tried to access a poisoned page:

kernel BUG at arch/powerpc/mm/fault.c:180!

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/mm/fault.c | 36 +---
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 51ab9e7..c3728c1 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -114,22 +114,31 @@ static int store_updates_sp(struct pt_regs *regs)
 #define MM_FAULT_CONTINUE  -1
 #define MM_FAULT_ERR(sig)  (sig)
 
-static int do_sigbus(struct pt_regs *regs, unsigned long address)
+static int do_sigbus(struct pt_regs *regs, unsigned long address,
+unsigned int fault)
 {
siginfo_t info;
 
up_read(current-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;
-   info.si_addr = (void __user *)address;
-   force_sig_info(SIGBUS, info, current);
-   return MM_FAULT_RETURN;
+   if (!user_mode(regs))
+   return MM_FAULT_ERR(SIGBUS);
+
+   current-thread.trap_nr = BUS_ADRERR;
+   info.si_signo = SIGBUS;
+   info.si_errno = 0;
+   info.si_code = BUS_ADRERR;
+   info.si_addr = (void __user *)address;
+
+#ifdef CONFIG_MEMORY_FAILURE
+   if (fault  (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
+   pr_err(MCE: Killing %s:%d due to hardware memory corruption 
fault at %lx\n,
+   current-comm, current-pid, address);
+   info.si_code = BUS_MCEERR_AR;
}
-   return MM_FAULT_ERR(SIGBUS);
+#endif
+   force_sig_info(SIGBUS, info, current);
+   return MM_FAULT_RETURN;
 }
 
 static int mm_fault_error(struct pt_regs *regs, unsigned long addr, int fault)
@@ -170,11 +179,8 @@ static int mm_fault_error(struct pt_regs *regs, unsigned 
long addr, int fault)
return MM_FAULT_RETURN;
}
 
-   /* Bus error. x86 handles HWPOISON here, we'll add this if/when
-* we support the feature in HW
-*/
-   if (fault  VM_FAULT_SIGBUS)
-   return do_sigbus(regs, addr);
+   if (fault  (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE))
+   return do_sigbus(regs, addr, fault);
 
/* We don't understand the fault code, this is fatal */
BUG();
-- 
1.9.1

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

[PATCH 2/2] powerpc: Fill in si_addr_lsb siginfo field

2014-09-23 Thread Anton Blanchard
Fill in the si_addr_lsb siginfo field so the hwpoison code can
pass to userspace the length of memory that has been corrupted.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/mm/fault.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index c3728c1..3b16c58 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -33,6 +33,7 @@
 #include linux/magic.h
 #include linux/ratelimit.h
 #include linux/context_tracking.h
+#include linux/hugetlb.h
 
 #include asm/firmware.h
 #include asm/page.h
@@ -118,6 +119,7 @@ static int do_sigbus(struct pt_regs *regs, unsigned long 
address,
 unsigned int fault)
 {
siginfo_t info;
+   unsigned int lsb = 0;
 
up_read(current-mm-mmap_sem);
 
@@ -136,7 +138,13 @@ static int do_sigbus(struct pt_regs *regs, unsigned long 
address,
current-comm, current-pid, address);
info.si_code = BUS_MCEERR_AR;
}
+
+   if (fault  VM_FAULT_HWPOISON_LARGE)
+   lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault));
+   if (fault  VM_FAULT_HWPOISON)
+   lsb = PAGE_SHIFT;
 #endif
+   info.si_addr_lsb = lsb;
force_sig_info(SIGBUS, info, current);
return MM_FAULT_RETURN;
 }
-- 
1.9.1

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

Re: [PATCH 3/3] powerpc/ftrace: simplify prepare_ftrace_return

2014-09-23 Thread Anton Blanchard

Hi Steve,

  This could be broken from the earlier patches, I haven't run just
  this test. I probably should on them.
 
 I went back and tested, and it breaks under the first patch.

Thanks for testing. It looks like some toolchains have issues
other than the -fno-no-omit-frame-pointer one, and -mno-sched-epilog
works around it.

I'll drop that patch and respin.

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

Re: [PATCH 3/3] powerpc/ftrace: simplify prepare_ftrace_return

2014-09-23 Thread Anton Blanchard
Hi Ben,

  I'll drop that patch and respin.
 
 Or maybe do a toolchain check / or enable it in LE ?

We are scratching our heads trying to remember details of the issue
right now. In retrospect we should have linked the gcc bugzilla or
gcc commit details in the kernel commit message :)

Steve: what gcc version are you building with?

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

[PATCH 0/3] DCACHE_WORD_ACCESS support for ppc64le

2014-09-18 Thread Anton Blanchard
This series adds an optimised version of word-at-a-time.h for ppc64le.
It uses the cmpb instruction which compares each byte in two 64 bit
values and for each matching byte places 0xff in the target and 0x00
otherwise.

The intermediate functions diverge a bit from what might have been 
intended (eg create_zero_mask returns the number of bits to the NULL),
but it makes find_zero and zero_bytemask simpler:

static inline unsigned long has_zero(unsigned long a, unsigned long *bits, 
const struct word_at_a_time *c)
{
unsigned long ret;
unsigned long zero = 0;

asm(cmpb %0,%1,%2 : =r (ret) : r (a), r (zero));
*bits = ret;

return ret;
}

static inline unsigned long prep_zero_mask(unsigned long a, unsigned long bits, 
const struct word_at_a_time *c)
{
return bits;
}

/* Alan Modra's little-endian strlen tail for 64-bit */
static inline unsigned long create_zero_mask(unsigned long bits)
{
unsigned long leading_zero_bits;
long trailing_zero_bit_mask;

asm(addi   %1,%2,-1\n\t
andc   %1,%1,%2\n\t
popcntd%0,%1
: =r (leading_zero_bits), =r (trailing_zero_bit_mask)
: r (bits));

return leading_zero_bits;
}

static inline unsigned long find_zero(unsigned long mask)
{
return mask  3;
}

/* This assumes that we never ask for an all 1s bitmask */
static inline unsigned long zero_bytemask(unsigned long mask)
{
return (1UL  mask) - 1;
}

Anton Blanchard (3):
  powerpc: Implement load_unaligned_zeropad
  powerpc: ppc64le optimised word at a time
  powerpc: Enable DCACHE_WORD_ACCESS on ppc64le

 arch/powerpc/Kconfig  |   1 +
 arch/powerpc/include/asm/word-at-a-time.h | 101 +-
 2 files changed, 88 insertions(+), 14 deletions(-)

-- 
1.9.1

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

[PATCH 1/3] powerpc: Implement load_unaligned_zeropad

2014-09-18 Thread Anton Blanchard
Implement a bi-arch and bi-endian version of load_unaligned_zeropad.

Since the fallback case is so rare, a userspace test harness was used
to test this on ppc64le, ppc64 and ppc32:

http://ozlabs.org/~anton/junkcode/test_load_unaligned_zeropad.c

It uses mprotect to force a SEGV across a page boundary, and a SEGV
handler to lookup the exception tables and run the fixup routine.
It also compares the result against a normal load.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/word-at-a-time.h | 40 +++
 1 file changed, 40 insertions(+)

diff --git a/arch/powerpc/include/asm/word-at-a-time.h 
b/arch/powerpc/include/asm/word-at-a-time.h
index 9a5c928..07cc121 100644
--- a/arch/powerpc/include/asm/word-at-a-time.h
+++ b/arch/powerpc/include/asm/word-at-a-time.h
@@ -116,4 +116,44 @@ static inline unsigned long prep_zero_mask(unsigned long 
a, unsigned long bits,
 
 #endif
 
+static inline unsigned long load_unaligned_zeropad(const void *addr)
+{
+   unsigned long ret, offset, tmp;
+
+   asm(
+   1:  PPC_LL %[ret], 0(%[addr])\n
+   2:\n
+   .section .fixup,\ax\\n
+   3: 
+#ifdef __powerpc64__
+   clrrdi %[tmp], %[addr], 3\n\t
+   clrlsldi   %[offset], %[addr], 61, 3\n\t
+   ld %[ret], 0(%[tmp])\n\t
+#ifdef __BIG_ENDIAN__
+   sld%[ret], %[ret], %[offset]\n\t
+#else
+   srd%[ret], %[ret], %[offset]\n\t
+#endif
+#else
+   clrrwi %[tmp], %[addr], 2\n\t
+   clrlslwi   %[offset], %[addr], 30, 3\n\t
+   lwz%[ret], 0(%[tmp])\n\t
+#ifdef __BIG_ENDIAN__
+   slw%[ret], %[ret], %[offset]\n\t
+#else
+   srw%[ret], %[ret], %[offset]\n\t
+#endif
+#endif
+   b  2b\n
+   .previous\n
+   .section __ex_table,\a\\n\t
+   PPC_LONG_ALIGN \n\t
+   PPC_LONG 1b,3b\n
+   .previous
+   : [tmp] =b (tmp), [offset] =r (offset), [ret] =r (ret)
+   : [addr] b (addr), m (*(unsigned long *)addr));
+
+   return ret;
+}
+
 #endif /* _ASM_WORD_AT_A_TIME_H */
-- 
1.9.1

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

[PATCH 2/3] powerpc: ppc64le optimised word at a time

2014-09-18 Thread Anton Blanchard
Use cmpb which compares each byte in two 64 bit values and
for each matching byte places 0xff in the target and 0x00
otherwise.

A simple hash_name microbenchmark:

http://ozlabs.org/~anton/junkcode/hash_name_bench.c

shows this version to be 10-20% faster than running the x86
version on POWER8, depending on the length.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/word-at-a-time.h | 61 ---
 1 file changed, 47 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/include/asm/word-at-a-time.h 
b/arch/powerpc/include/asm/word-at-a-time.h
index 07cc121..7cff3de 100644
--- a/arch/powerpc/include/asm/word-at-a-time.h
+++ b/arch/powerpc/include/asm/word-at-a-time.h
@@ -42,32 +42,65 @@ static inline bool has_zero(unsigned long val, unsigned 
long *data, const struct
 
 #else
 
+#ifdef CONFIG_64BIT
+
+/* unused */
 struct word_at_a_time {
-   const unsigned long one_bits, high_bits;
 };
 
-#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
+#define WORD_AT_A_TIME_CONSTANTS { }
 
-#ifdef CONFIG_64BIT
+/* This will give us 0xff for a NULL char and 0x00 elsewhere */
+static inline unsigned long has_zero(unsigned long a, unsigned long *bits, 
const struct word_at_a_time *c)
+{
+   unsigned long ret;
+   unsigned long zero = 0;
 
-/* Alan Modra's little-endian strlen tail for 64-bit */
-#define create_zero_mask(mask) (mask)
+   asm(cmpb %0,%1,%2 : =r (ret) : r (a), r (zero));
+   *bits = ret;
 
-static inline unsigned long find_zero(unsigned long mask)
+   return ret;
+}
+
+static inline unsigned long prep_zero_mask(unsigned long a, unsigned long 
bits, const struct word_at_a_time *c)
+{
+   return bits;
+}
+
+/* Alan Modra's little-endian strlen tail for 64-bit */
+static inline unsigned long create_zero_mask(unsigned long bits)
 {
unsigned long leading_zero_bits;
long trailing_zero_bit_mask;
 
-   asm (addi %1,%2,-1\n\t
-andc %1,%1,%2\n\t
-popcntd %0,%1
-: =r (leading_zero_bits), =r (trailing_zero_bit_mask)
-: r (mask));
-   return leading_zero_bits  3;
+   asm(addi   %1,%2,-1\n\t
+   andc   %1,%1,%2\n\t
+   popcntd%0,%1
+   : =r (leading_zero_bits), =r (trailing_zero_bit_mask)
+   : r (bits));
+
+   return leading_zero_bits;
+}
+
+static inline unsigned long find_zero(unsigned long mask)
+{
+   return mask  3;
+}
+
+/* This assumes that we never ask for an all 1s bitmask */
+static inline unsigned long zero_bytemask(unsigned long mask)
+{
+   return (1UL  mask) - 1;
 }
 
 #else  /* 32-bit case */
 
+struct word_at_a_time {
+   const unsigned long one_bits, high_bits;
+};
+
+#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
+
 /*
  * This is largely generic for little-endian machines, but the
  * optimal byte mask counting is probably going to be something
@@ -96,8 +129,6 @@ static inline unsigned long find_zero(unsigned long mask)
return count_masked_bytes(mask);
 }
 
-#endif
-
 /* Return nonzero if it has a zero */
 static inline unsigned long has_zero(unsigned long a, unsigned long *bits, 
const struct word_at_a_time *c)
 {
@@ -116,6 +147,8 @@ static inline unsigned long prep_zero_mask(unsigned long a, 
unsigned long bits,
 
 #endif
 
+#endif
+
 static inline unsigned long load_unaligned_zeropad(const void *addr)
 {
unsigned long ret, offset, tmp;
-- 
1.9.1

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

[PATCH 3/3] powerpc: Enable DCACHE_WORD_ACCESS on ppc64le

2014-09-18 Thread Anton Blanchard
Enable on DCACHE_WORD_ACCESS on ppc64le. It should work on
ppc64 and ppc32 but we need to do some testing first.

A somewhat reasonable testcase used to show the performance
improvement - a repeated stat of a 33 byte filename that
doesn't exist:

 #include sys/types.h
 #include sys/stat.h
 #include unistd.h

 #define ITERATIONS 1000

 #define PATH 123456781234567812345678123456781

 int main(void)
 {
unsigned long i;
struct stat buf;

for (i = 0; i  ITERATIONS; i++)
stat(PATH, buf);

return 0;
 }

runs 27% faster on POWER8.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 90fe77a..7992f35 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -148,6 +148,7 @@ config PPC
select HAVE_ARCH_AUDITSYSCALL
select ARCH_SUPPORTS_ATOMIC_RMW
select HAVE_PERF_EVENTS_NMI if PPC64
+   select DCACHE_WORD_ACCESS if PPC64  CPU_LITTLE_ENDIAN
 
 config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
-- 
1.9.1

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

[PATCH 2/5] powerpc: Remove some old bootmem related comments

2014-09-17 Thread Anton Blanchard
Now bootmem is gone from powerpc we can remove comments mentioning it.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/prom.c   | 5 +
 arch/powerpc/kernel/rtas.c   | 4 ++--
 arch/powerpc/kvm/book3s_hv_builtin.c | 2 +-
 arch/powerpc/mm/hugetlbpage.c| 4 ++--
 arch/powerpc/mm/pgtable_64.c | 4 
 5 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 5957625..02e3e4c 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -698,10 +698,7 @@ void __init early_init_devtree(void *params)
reserve_crashkernel();
early_reserve_mem();
 
-   /*
-* Ensure that total memory size is page-aligned, because otherwise
-* mark_bootmem() gets upset.
-*/
+   /* Ensure that total memory size is page-aligned. */
limit = ALIGN(memory_limit ?: memblock_phys_mem_size(), PAGE_SIZE);
memblock_enforce_memory_limit(limit);
 
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 8b4c857..4af905e 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -1091,8 +1091,8 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
 }
 
 /*
- * Call early during boot, before mem init or bootmem, to retrieve the RTAS
- * informations from the device-tree and allocate the RMO buffer for userland
+ * Call early during boot, before mem init, to retrieve the RTAS
+ * information from the device-tree and allocate the RMO buffer for userland
  * accesses.
  */
 void __init rtas_initialize(void)
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c 
b/arch/powerpc/kvm/book3s_hv_builtin.c
index b9615ba..297dbaf 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -154,7 +154,7 @@ EXPORT_SYMBOL_GPL(kvm_release_hpt);
  * kvm_cma_reserve() - reserve area for kvm hash pagetable
  *
  * This function reserves memory from early allocator. It should be
- * called by arch specific code once the early allocator (memblock or bootmem)
+ * called by arch specific code once the memblock allocator
  * has been activated and all other subsystems have already allocated/reserved
  * memory.
  */
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 7e70ae9..5215d25 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -276,7 +276,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long 
addr, unsigned long sz
 
 #ifdef CONFIG_PPC_FSL_BOOK3E
 /* Build list of addresses of gigantic pages.  This function is used in early
- * boot before the buddy or bootmem allocator is setup.
+ * boot before the buddy allocator is setup.
  */
 void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages)
 {
@@ -399,7 +399,7 @@ void __init reserve_hugetlb_gpages(void)
 #else /* !PPC_FSL_BOOK3E */
 
 /* Build list of addresses of gigantic pages.  This function is used in early
- * boot before the buddy or bootmem allocator is setup.
+ * boot before the buddy allocator is setup.
  */
 void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages)
 {
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index cdb19ab..aa91737 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -109,10 +109,6 @@ int map_kernel_page(unsigned long ea, unsigned long pa, 
int flags)
  __pgprot(flags)));
} else {
 #ifdef CONFIG_PPC_MMU_NOHASH
-   /* Warning ! This will blow up if bootmem is not initialized
-* which our ppc64 code is keen to do that, we'll need to
-* fix it and/or be more careful
-*/
pgdp = pgd_offset_k(ea);
 #ifdef PUD_TABLE_SIZE
if (pgd_none(*pgdp)) {
-- 
1.9.1

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

[PATCH 3/5] powerpc: Remove superfluous bootmem includes

2014-09-17 Thread Anton Blanchard
Lots of places included bootmem.h even when not using bootmem.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/crash_dump.c   | 1 -
 arch/powerpc/kernel/irq.c  | 1 -
 arch/powerpc/kernel/pci_64.c   | 1 -
 arch/powerpc/kernel/rtas_pci.c | 1 -
 arch/powerpc/kernel/setup_32.c | 1 -
 arch/powerpc/kernel/vdso.c | 1 -
 arch/powerpc/kvm/book3s_hv_builtin.c   | 1 -
 arch/powerpc/mm/init_32.c  | 1 -
 arch/powerpc/mm/init_64.c  | 1 -
 arch/powerpc/mm/pgtable_64.c   | 1 -
 arch/powerpc/platforms/cell/celleb_scc_epci.c  | 1 -
 arch/powerpc/platforms/cell/celleb_scc_pciex.c | 1 -
 arch/powerpc/platforms/maple/pci.c | 1 -
 arch/powerpc/platforms/powermac/pci.c  | 1 -
 arch/powerpc/platforms/powernv/eeh-ioda.c  | 1 -
 arch/powerpc/platforms/powernv/pci.c   | 1 -
 arch/powerpc/sysdev/fsl_msi.c  | 1 -
 arch/powerpc/sysdev/ipic.c | 1 -
 arch/powerpc/sysdev/mpic.c | 1 -
 arch/powerpc/sysdev/mpic_pasemi_msi.c  | 1 -
 arch/powerpc/sysdev/mpic_u3msi.c   | 1 -
 arch/powerpc/sysdev/ppc4xx_msi.c   | 1 -
 arch/powerpc/sysdev/ppc4xx_pci.c   | 1 -
 arch/powerpc/sysdev/qe_lib/qe.c| 1 -
 arch/powerpc/sysdev/qe_lib/qe_ic.c | 1 -
 arch/powerpc/sysdev/uic.c  | 1 -
 26 files changed, 26 deletions(-)

diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 7a13f37..0bfe370 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -12,7 +12,6 @@
 #undef DEBUG
 
 #include linux/crash_dump.h
-#include linux/bootmem.h
 #include linux/memblock.h
 #include asm/code-patching.h
 #include asm/kdump.h
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 4c5891d..c47a74d 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -50,7 +50,6 @@
 #include linux/list.h
 #include linux/radix-tree.h
 #include linux/mutex.h
-#include linux/bootmem.h
 #include linux/pci.h
 #include linux/debugfs.h
 #include linux/of.h
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 155013d..ba0f2d6 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -17,7 +17,6 @@
 #include linux/pci.h
 #include linux/string.h
 #include linux/init.h
-#include linux/bootmem.h
 #include linux/export.h
 #include linux/mm.h
 #include linux/list.h
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index c168337..fe39926 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -26,7 +26,6 @@
 #include linux/pci.h
 #include linux/string.h
 #include linux/init.h
-#include linux/bootmem.h
 
 #include asm/io.h
 #include asm/pgtable.h
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index e2bc044..84dafdf 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -11,7 +11,6 @@
 #include linux/delay.h
 #include linux/initrd.h
 #include linux/tty.h
-#include linux/bootmem.h
 #include linux/seq_file.h
 #include linux/root_dev.h
 #include linux/cpu.h
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index f174351..305eb0d 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -20,7 +20,6 @@
 #include linux/user.h
 #include linux/elf.h
 #include linux/security.h
-#include linux/bootmem.h
 #include linux/memblock.h
 
 #include asm/pgtable.h
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c 
b/arch/powerpc/kvm/book3s_hv_builtin.c
index 297dbaf..6baa186 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -12,7 +12,6 @@
 #include linux/export.h
 #include linux/sched.h
 #include linux/spinlock.h
-#include linux/bootmem.h
 #include linux/init.h
 #include linux/memblock.h
 #include linux/sizes.h
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 9d1bde2..6332368 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -26,7 +26,6 @@
 #include linux/mm.h
 #include linux/stddef.h
 #include linux/init.h
-#include linux/bootmem.h
 #include linux/highmem.h
 #include linux/initrd.h
 #include linux/pagemap.h
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 3481556..10471f9 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -34,7 +34,6 @@
 #include linux/vmalloc.h
 #include linux/init.h
 #include linux/delay.h
-#include linux/bootmem.h
 #include linux/highmem.h
 #include linux/idr.h
 #include linux/nodemask.h
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index aa91737..feed47c 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -33,7 +33,6 @@
 #include linux/swap.h
 #include linux

[PATCH 5/5] powerpc: make __ffs return unsigned long

2014-09-17 Thread Anton Blanchard
I'm seeing a build warning in mm/nobootmem.c after removing
bootmem:

mm/nobootmem.c: In function '__free_pages_memory':
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types 
lacks a cast [enabled by default]
  (void) (_min1 == _min2);  \
 ^
mm/nobootmem.c:90:11: note: in expansion of macro 'min'
   order = min(MAX_ORDER - 1UL, __ffs(start));
   ^

The rest of the worlds seems to define __ffs as returning unsigned long,
so lets do that.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/bitops.h | 2 +-
 arch/powerpc/sysdev/fsl_pci.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/bitops.h 
b/arch/powerpc/include/asm/bitops.h
index bd3bd57..c633f05 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -213,7 +213,7 @@ static __inline__ unsigned long ffz(unsigned long x)
return __ilog2(x  -x);
 }
 
-static __inline__ int __ffs(unsigned long x)
+static __inline__ unsigned long __ffs(unsigned long x)
 {
return __ilog2(x  -x);
 }
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index c507767..dae96fb 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -152,7 +152,7 @@ static int setup_one_atmu(struct ccsr_pci __iomem *pci,
flags |= 0x1000; /* enable relaxed ordering */
 
for (i = 0; size  0; i++) {
-   unsigned int bits = min(ilog2(size),
+   unsigned int bits = min_t(u32, ilog2(size),
__ffs(pci_addr | phys_addr));
 
if (index + i = 5)
-- 
1.9.1

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

[PATCH 4/5] powerpc: Move sparse_init() into initmem_init

2014-09-17 Thread Anton Blanchard
We did part of sparse initialisation in setup_arch and part in
initmem_init. Put them together.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/setup_64.c | 1 -
 arch/powerpc/mm/mem.c  | 1 +
 arch/powerpc/mm/numa.c | 2 ++
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 9f8f472..8bc8f77 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -682,7 +682,6 @@ void __init setup_arch(char **cmdline_p)
emergency_stack_init();
 
initmem_init();
-   sparse_init();
 
 #ifdef CONFIG_DUMMY_CONSOLE
conswitchp = dummy_con;
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index aa067b7..abbc55d 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -195,6 +195,7 @@ void __init initmem_init(void)
 
/* XXX need to clip this if using highmem? */
sparse_memory_present_with_active_regions(0);
+   sparse_init();
 }
 
 /* mark pages that don't exist as nosave */
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 4f9c18a..52559ff 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -964,6 +964,8 @@ void __init initmem_init(void)
sparse_memory_present_with_active_regions(nid);
}
 
+   sparse_init();
+
setup_node_to_cpumask_map();
 
reset_numa_cpu_lookup_table();
-- 
1.9.1

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

[PATCH 1/3] powerpc: Remove -mno-sched-epilog workaround

2014-09-17 Thread Anton Blanchard
We added -mno-sched-epilog in commit 7563dc645853 (powerpc:
Work around gcc's -fno-omit-frame-pointer bug).

We shouldn't apply -fno-omit-frame-pointer on powerpc any more (it's
protected by CONFIG_FRAME_POINTER and CONFIG_SCHED_OMIT_FRAME_POINTER).

It's also an undocumented gcc option, so lets remove it.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/Makefile|  5 -
 arch/powerpc/kernel/Makefile | 12 ++--
 arch/powerpc/platforms/powermac/Makefile |  2 +-
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 132d9c6..c6f64e2 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -198,11 +198,6 @@ ifeq ($(CONFIG_6xx),y)
 KBUILD_CFLAGS  += -mcpu=powerpc
 endif
 
-# Work around a gcc code-gen bug with -fno-omit-frame-pointer.
-ifeq ($(CONFIG_FUNCTION_TRACER),y)
-KBUILD_CFLAGS  += -mno-sched-epilog
-endif
-
 cpu-as-$(CONFIG_4xx)   += -Wa,-m405
 cpu-as-$(CONFIG_ALTIVEC)   += -Wa,-maltivec
 cpu-as-$(CONFIG_E200)  += -Wa,-me200
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 502cf69..e14bda6 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -17,14 +17,14 @@ endif
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not trace early boot code
-CFLAGS_REMOVE_cputable.o = -pg -mno-sched-epilog
-CFLAGS_REMOVE_prom_init.o = -pg -mno-sched-epilog
-CFLAGS_REMOVE_btext.o = -pg -mno-sched-epilog
-CFLAGS_REMOVE_prom.o = -pg -mno-sched-epilog
+CFLAGS_REMOVE_cputable.o = -pg
+CFLAGS_REMOVE_prom_init.o = -pg
+CFLAGS_REMOVE_btext.o = -pg
+CFLAGS_REMOVE_prom.o = -pg
 # do not trace tracer code
-CFLAGS_REMOVE_ftrace.o = -pg -mno-sched-epilog
+CFLAGS_REMOVE_ftrace.o = -pg
 # timers used by tracing
-CFLAGS_REMOVE_time.o = -pg -mno-sched-epilog
+CFLAGS_REMOVE_time.o = -pg
 endif
 
 obj-y  := cputable.o ptrace.o syscalls.o \
diff --git a/arch/powerpc/platforms/powermac/Makefile 
b/arch/powerpc/platforms/powermac/Makefile
index 52c6ce1..e238872 100644
--- a/arch/powerpc/platforms/powermac/Makefile
+++ b/arch/powerpc/platforms/powermac/Makefile
@@ -2,7 +2,7 @@ CFLAGS_bootx_init.o += -fPIC
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not trace early boot code
-CFLAGS_REMOVE_bootx_init.o = -pg -mno-sched-epilog
+CFLAGS_REMOVE_bootx_init.o = -pg
 endif
 
 obj-y  += pic.o setup.o time.o feature.o pci.o \
-- 
1.9.1

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

[PATCH 2/3] powerpc/ftrace: Remove mod_return_to_handler

2014-09-17 Thread Anton Blanchard
mod_return_to_handler is the same as return_to_handler, except
it handles the change of the TOC (r2). Add this into
return_to_handler and remove mod_return_to_handler.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/entry_64.S | 24 +---
 arch/powerpc/kernel/ftrace.c   | 14 ++
 arch/powerpc/kernel/process.c  |  9 +
 3 files changed, 4 insertions(+), 43 deletions(-)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 5bbd1bc..955d509 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -1235,28 +1235,6 @@ _GLOBAL(ftrace_graph_caller)
 
 _GLOBAL(return_to_handler)
/* need to save return values */
-   std r4,  -24(r1)
-   std r3,  -16(r1)
-   std r31, -8(r1)
-   mr  r31, r1
-   stdur1, -112(r1)
-
-   bl  ftrace_return_to_handler
-   nop
-
-   /* return value has real return address */
-   mtlrr3
-
-   ld  r1, 0(r1)
-   ld  r4,  -24(r1)
-   ld  r3,  -16(r1)
-   ld  r31, -8(r1)
-
-   /* Jump back to real return address */
-   blr
-
-_GLOBAL(mod_return_to_handler)
-   /* need to save return values */
std r4,  -32(r1)
std r3,  -24(r1)
/* save TOC */
@@ -1266,7 +1244,7 @@ _GLOBAL(mod_return_to_handler)
stdur1, -112(r1)
 
/*
-* We are in a module using the module's TOC.
+* We might be called from a module.
 * Switch to our TOC to run inside the core kernel.
 */
ld  r2, PACATOC(r13)
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 390311c..abf7921 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -510,10 +510,6 @@ int ftrace_disable_ftrace_graph_caller(void)
 }
 #endif /* CONFIG_DYNAMIC_FTRACE */
 
-#ifdef CONFIG_PPC64
-extern void mod_return_to_handler(void);
-#endif
-
 /*
  * Hook the return address and push it in the stack of return addrs
  * in current thread info.
@@ -523,7 +519,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned 
long self_addr)
unsigned long old;
int faulted;
struct ftrace_graph_ent trace;
-   unsigned long return_hooker = (unsigned long)return_to_handler;
+   unsigned long return_hooker;
 
if (unlikely(ftrace_graph_is_dead()))
return;
@@ -531,13 +527,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned 
long self_addr)
if (unlikely(atomic_read(current-tracing_graph_pause)))
return;
 
-#ifdef CONFIG_PPC64
-   /* non core kernel code needs to save and restore the TOC */
-   if (REGION_ID(self_addr) != KERNEL_REGION_ID)
-   return_hooker = (unsigned long)mod_return_to_handler;
-#endif
-
-   return_hooker = ppc_function_entry((void *)return_hooker);
+   return_hooker = ppc_function_entry(return_to_handler);
 
/*
 * Protect against fault, even if it shouldn't
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index aa1df89..080c0b9 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1531,13 +1531,6 @@ void show_stack(struct task_struct *tsk, unsigned long 
*stack)
int curr_frame = current-curr_ret_stack;
extern void return_to_handler(void);
unsigned long rth = (unsigned long)return_to_handler;
-   unsigned long mrth = -1;
-#ifdef CONFIG_PPC64
-   extern void mod_return_to_handler(void);
-   rth = *(unsigned long *)rth;
-   mrth = (unsigned long)mod_return_to_handler;
-   mrth = *(unsigned long *)mrth;
-#endif
 #endif
 
sp = (unsigned long) stack;
@@ -1562,7 +1555,7 @@ void show_stack(struct task_struct *tsk, unsigned long 
*stack)
if (!firstframe || ip != lr) {
printk([REG] [REG] %pS, sp, ip, (void *)ip);
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-   if ((ip == rth || ip == mrth)  curr_frame = 0) {
+   if ((ip == rth)  curr_frame = 0) {
printk( (%pS),
   (void 
*)current-ret_stack[curr_frame].ret);
curr_frame--;
-- 
1.9.1

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

[PATCH 3/3] powerpc/ftrace: simplify prepare_ftrace_return

2014-09-17 Thread Anton Blanchard
Instead of passing in the stack address of the link register
to be modified, just pass in the old value and return the
new value and rely on ftrace_graph_caller to do the
modification.

This removes the exception handling around the stack update -
it isn't needed and we weren't consistent about it. Later on
we would do an unprotected modification:

   if (!ftrace_graph_entry(trace)) {
   *parent = old;

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/entry_32.S | 10 +--
 arch/powerpc/kernel/entry_64.S | 11 ++--
 arch/powerpc/kernel/ftrace.c   | 59 ++
 3 files changed, 30 insertions(+), 50 deletions(-)

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 22b45a4..ad837d8 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -1424,12 +1424,18 @@ _GLOBAL(ftrace_graph_caller)
lwz r4, 44(r1)
subir4, r4, MCOUNT_INSN_SIZE
 
-   /* get the parent address */
-   addir3, r1, 52
+   /* Grab the LR out of the caller stack frame */
+   lwz r3,52(r1)
 
bl  prepare_ftrace_return
nop
 
+/*
+ * prepare_ftrace_return gives us the address we divert to.
+ * Change the LR in the callers stack frame to this.
+ */
+   stw r3,52(r1)
+
MCOUNT_RESTORE_FRAME
/* old link register ends up in ctr reg */
bctr
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 955d509..9caab69 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -1221,13 +1221,20 @@ _GLOBAL(ftrace_graph_caller)
ld  r4, 128(r1)
subir4, r4, MCOUNT_INSN_SIZE
 
-   /* get the parent address */
+   /* Grab the LR out of the caller stack frame */
ld  r11, 112(r1)
-   addir3, r11, 16
+   ld  r3, 16(r11)
 
bl  prepare_ftrace_return
nop
 
+   /*
+* prepare_ftrace_return gives us the address we divert to.
+* Change the LR in the callers stack frame to this.
+*/
+   ld  r11, 112(r1)
+   std r3, 16(r11)
+
ld  r0, 128(r1)
mtlrr0
addir1, r1, 112
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index abf7921..d795031 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -512,67 +512,34 @@ int ftrace_disable_ftrace_graph_caller(void)
 
 /*
  * Hook the return address and push it in the stack of return addrs
- * in current thread info.
+ * in current thread info. Return the address we want to divert to.
  */
-void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
+unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip)
 {
-   unsigned long old;
-   int faulted;
struct ftrace_graph_ent trace;
unsigned long return_hooker;
 
if (unlikely(ftrace_graph_is_dead()))
-   return;
+   goto out;
 
if (unlikely(atomic_read(current-tracing_graph_pause)))
-   return;
+   goto out;
 
return_hooker = ppc_function_entry(return_to_handler);
 
-   /*
-* Protect against fault, even if it shouldn't
-* happen. This tool is too much intrusive to
-* ignore such a protection.
-*/
-   asm volatile(
-   1:  PPC_LL %[old], 0(%[parent])\n
-   2:  PPC_STL %[return_hooker], 0(%[parent])\n
-  li %[faulted], 0\n
-   3:\n
-
-   .section .fixup, \ax\\n
-   4: li %[faulted], 1\n
-  b 3b\n
-   .previous\n
-
-   .section __ex_table,\a\\n
-   PPC_LONG_ALIGN \n
-   PPC_LONG 1b,4b\n
-   PPC_LONG 2b,4b\n
-   .previous
-
-   : [old] =r (old), [faulted] =r (faulted)
-   : [parent] r (parent), [return_hooker] r (return_hooker)
-   : memory
-   );
-
-   if (unlikely(faulted)) {
-   ftrace_graph_stop();
-   WARN_ON(1);
-   return;
-   }
-
-   trace.func = self_addr;
+   trace.func = ip;
trace.depth = current-curr_ret_stack + 1;
 
/* Only trace if the calling function expects to */
-   if (!ftrace_graph_entry(trace)) {
-   *parent = old;
-   return;
-   }
+   if (!ftrace_graph_entry(trace))
+   goto out;
+
+   if (ftrace_push_return_trace(parent, ip, trace.depth, 0) == -EBUSY)
+   goto out;
 
-   if (ftrace_push_return_trace(old, self_addr, trace.depth, 0) == -EBUSY)
-   *parent = old;
+   parent = return_hooker;
+out:
+   return parent;
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
 
-- 
1.9.1

Re: [PATCH 3/5] powerpc: Remove superfluous bootmem includes

2014-09-17 Thread Anton Blanchard

Hi Emil,

 While building corenet64_smp I get this:
 
  ../arch/powerpc/mm/pgtable_64.c: In function 'early_alloc_pgtable':
  ../arch/powerpc/mm/pgtable_64.c:77:95: error: 'MAX_DMA_ADDRESS'
  undeclared (first use in this
  function) ../arch/powerpc/mm/pgtable_64.c:77:95: note: each
  undeclared identifier is reported only once for each function it
  appears in
 
 Adding '#include asm/dma.h' seems to fix it
 
 Other than that, for the entire set:
 
 Tested-by: Emil Medve emilian.me...@freescale.com

Thanks for testing! I'll respin the patch with that include added.

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

[PATCH 1/5] powerpc: Remove bootmem allocator

2014-09-17 Thread Anton Blanchard
At the moment we transition from the memblock alloctor to the bootmem
allocator. Gitting rid of the bootmem allocator removes a bunch of
complicated code (most of which I owe the dubious honour of being
responsible for writing).

Signed-off-by: Anton Blanchard an...@samba.org
Tested-by: Emil Medve emilian.me...@freescale.com
---
 arch/powerpc/Kconfig |   1 +
 arch/powerpc/include/asm/setup.h |   3 +-
 arch/powerpc/kernel/setup_32.c   |   5 +-
 arch/powerpc/kernel/setup_64.c   |   3 +-
 arch/powerpc/mm/init_32.c|   9 --
 arch/powerpc/mm/mem.c|  62 +--
 arch/powerpc/mm/numa.c   | 224 ++-
 arch/powerpc/mm/pgtable_32.c |   3 +-
 arch/powerpc/mm/pgtable_64.c |   6 +-
 9 files changed, 43 insertions(+), 273 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 90fe77a..3eeeb9d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -148,6 +148,7 @@ config PPC
select HAVE_ARCH_AUDITSYSCALL
select ARCH_SUPPORTS_ATOMIC_RMW
select HAVE_PERF_EVENTS_NMI if PPC64
+   select NO_BOOTMEM
 
 config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
index 11ba86e..fbdf18c 100644
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -8,7 +8,6 @@ extern void ppc_printk_progress(char *s, unsigned short hex);
 
 extern unsigned int rtas_data;
 extern int mem_init_done;  /* set on boot once kmalloc can be called */
-extern int init_bootmem_done;  /* set once bootmem is available */
 extern unsigned long long memory_limit;
 extern unsigned long klimit;
 extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
@@ -24,7 +23,7 @@ extern void reloc_got2(unsigned long);
 #define PTRRELOC(x)((typeof(x)) add_reloc_offset((unsigned long)(x)))
 
 void check_for_initrd(void);
-void do_init_bootmem(void);
+void initmem_init(void);
 void setup_panic(void);
 #define ARCH_PANIC_TIMEOUT 180
 
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index ea4fda6..e2bc044 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -311,9 +311,8 @@ void __init setup_arch(char **cmdline_p)
 
irqstack_early_init();
 
-   /* set up the bootmem stuff with available memory */
-   do_init_bootmem();
-   if ( ppc_md.progress ) ppc_md.progress(setup_arch: bootmem, 0x3eab);
+   initmem_init();
+   if ( ppc_md.progress ) ppc_md.progress(setup_arch: initmem, 0x3eab);
 
 #ifdef CONFIG_DUMMY_CONSOLE
conswitchp = dummy_con;
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index fa17c94..9f8f472 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -681,8 +681,7 @@ void __init setup_arch(char **cmdline_p)
exc_lvl_early_init();
emergency_stack_init();
 
-   /* set up the bootmem stuff with available memory */
-   do_init_bootmem();
+   initmem_init();
sparse_init();
 
 #ifdef CONFIG_DUMMY_CONSOLE
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index cff59f1..9d1bde2 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -195,15 +195,6 @@ void __init MMU_init(void)
memblock_set_current_limit(lowmem_end_addr);
 }
 
-/* This is only called until mem_init is done. */
-void __init *early_get_page(void)
-{
-   if (init_bootmem_done)
-   return alloc_bootmem_pages(PAGE_SIZE);
-   else
-   return __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
-}
-
 #ifdef CONFIG_8xx /* No 8xx specific .c file to put that in ... */
 void setup_initial_memory_limit(phys_addr_t first_memblock_base,
phys_addr_t first_memblock_size)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index e0f7a18..aa067b7 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -60,7 +60,6 @@
 #define CPU_FTR_NOEXECUTE  0
 #endif
 
-int init_bootmem_done;
 int mem_init_done;
 unsigned long long memory_limit;
 
@@ -180,70 +179,22 @@ walk_system_ram_range(unsigned long start_pfn, unsigned 
long nr_pages,
 }
 EXPORT_SYMBOL_GPL(walk_system_ram_range);
 
-/*
- * Initialize the bootmem system and give it all the memory we
- * have available.  If we are using highmem, we only put the
- * lowmem into the bootmem system.
- */
 #ifndef CONFIG_NEED_MULTIPLE_NODES
-void __init do_init_bootmem(void)
+void __init initmem_init(void)
 {
-   unsigned long start, bootmap_pages;
-   unsigned long total_pages;
-   struct memblock_region *reg;
-   int boot_mapsize;
-
max_low_pfn = max_pfn = memblock_end_of_DRAM()  PAGE_SHIFT;
-   total_pages = (memblock_end_of_DRAM() - memstart_addr)  PAGE_SHIFT;
+   min_low_pfn = MEMORY_START  PAGE_SHIFT;
 #ifdef CONFIG_HIGHMEM
-   total_pages = total_lowmem  PAGE_SHIFT;
max_low_pfn

[PATCH 2/5] powerpc: Remove some old bootmem related comments

2014-09-17 Thread Anton Blanchard
Now bootmem is gone from powerpc we can remove comments mentioning it.

Signed-off-by: Anton Blanchard an...@samba.org
Tested-by: Emil Medve emilian.me...@freescale.com
---
 arch/powerpc/kernel/prom.c   | 5 +
 arch/powerpc/kernel/rtas.c   | 4 ++--
 arch/powerpc/kvm/book3s_hv_builtin.c | 2 +-
 arch/powerpc/mm/hugetlbpage.c| 4 ++--
 arch/powerpc/mm/pgtable_64.c | 4 
 5 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 5957625..02e3e4c 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -698,10 +698,7 @@ void __init early_init_devtree(void *params)
reserve_crashkernel();
early_reserve_mem();
 
-   /*
-* Ensure that total memory size is page-aligned, because otherwise
-* mark_bootmem() gets upset.
-*/
+   /* Ensure that total memory size is page-aligned. */
limit = ALIGN(memory_limit ?: memblock_phys_mem_size(), PAGE_SIZE);
memblock_enforce_memory_limit(limit);
 
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 8b4c857..4af905e 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -1091,8 +1091,8 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
 }
 
 /*
- * Call early during boot, before mem init or bootmem, to retrieve the RTAS
- * informations from the device-tree and allocate the RMO buffer for userland
+ * Call early during boot, before mem init, to retrieve the RTAS
+ * information from the device-tree and allocate the RMO buffer for userland
  * accesses.
  */
 void __init rtas_initialize(void)
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c 
b/arch/powerpc/kvm/book3s_hv_builtin.c
index b9615ba..297dbaf 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -154,7 +154,7 @@ EXPORT_SYMBOL_GPL(kvm_release_hpt);
  * kvm_cma_reserve() - reserve area for kvm hash pagetable
  *
  * This function reserves memory from early allocator. It should be
- * called by arch specific code once the early allocator (memblock or bootmem)
+ * called by arch specific code once the memblock allocator
  * has been activated and all other subsystems have already allocated/reserved
  * memory.
  */
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 7e70ae9..5215d25 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -276,7 +276,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long 
addr, unsigned long sz
 
 #ifdef CONFIG_PPC_FSL_BOOK3E
 /* Build list of addresses of gigantic pages.  This function is used in early
- * boot before the buddy or bootmem allocator is setup.
+ * boot before the buddy allocator is setup.
  */
 void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages)
 {
@@ -399,7 +399,7 @@ void __init reserve_hugetlb_gpages(void)
 #else /* !PPC_FSL_BOOK3E */
 
 /* Build list of addresses of gigantic pages.  This function is used in early
- * boot before the buddy or bootmem allocator is setup.
+ * boot before the buddy allocator is setup.
  */
 void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages)
 {
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index cdb19ab..aa91737 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -109,10 +109,6 @@ int map_kernel_page(unsigned long ea, unsigned long pa, 
int flags)
  __pgprot(flags)));
} else {
 #ifdef CONFIG_PPC_MMU_NOHASH
-   /* Warning ! This will blow up if bootmem is not initialized
-* which our ppc64 code is keen to do that, we'll need to
-* fix it and/or be more careful
-*/
pgdp = pgd_offset_k(ea);
 #ifdef PUD_TABLE_SIZE
if (pgd_none(*pgdp)) {
-- 
1.9.1

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

[PATCH 3/5] powerpc: Remove superfluous bootmem includes

2014-09-17 Thread Anton Blanchard
Lots of places included bootmem.h even when not using bootmem.

Signed-off-by: Anton Blanchard an...@samba.org
Tested-by: Emil Medve emilian.me...@freescale.com
---
 arch/powerpc/kernel/crash_dump.c   | 1 -
 arch/powerpc/kernel/irq.c  | 1 -
 arch/powerpc/kernel/pci_64.c   | 1 -
 arch/powerpc/kernel/rtas_pci.c | 1 -
 arch/powerpc/kernel/setup_32.c | 1 -
 arch/powerpc/kernel/vdso.c | 1 -
 arch/powerpc/kvm/book3s_hv_builtin.c   | 1 -
 arch/powerpc/mm/init_32.c  | 1 -
 arch/powerpc/mm/init_64.c  | 1 -
 arch/powerpc/mm/pgtable_64.c   | 2 +-
 arch/powerpc/platforms/cell/celleb_scc_epci.c  | 1 -
 arch/powerpc/platforms/cell/celleb_scc_pciex.c | 1 -
 arch/powerpc/platforms/maple/pci.c | 1 -
 arch/powerpc/platforms/powermac/pci.c  | 1 -
 arch/powerpc/platforms/powernv/eeh-ioda.c  | 1 -
 arch/powerpc/platforms/powernv/pci.c   | 1 -
 arch/powerpc/sysdev/fsl_msi.c  | 1 -
 arch/powerpc/sysdev/ipic.c | 1 -
 arch/powerpc/sysdev/mpic.c | 1 -
 arch/powerpc/sysdev/mpic_pasemi_msi.c  | 1 -
 arch/powerpc/sysdev/mpic_u3msi.c   | 1 -
 arch/powerpc/sysdev/ppc4xx_msi.c   | 1 -
 arch/powerpc/sysdev/ppc4xx_pci.c   | 1 -
 arch/powerpc/sysdev/qe_lib/qe.c| 1 -
 arch/powerpc/sysdev/qe_lib/qe_ic.c | 1 -
 arch/powerpc/sysdev/uic.c  | 1 -
 26 files changed, 1 insertion(+), 26 deletions(-)

diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 7a13f37..0bfe370 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -12,7 +12,6 @@
 #undef DEBUG
 
 #include linux/crash_dump.h
-#include linux/bootmem.h
 #include linux/memblock.h
 #include asm/code-patching.h
 #include asm/kdump.h
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 4c5891d..c47a74d 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -50,7 +50,6 @@
 #include linux/list.h
 #include linux/radix-tree.h
 #include linux/mutex.h
-#include linux/bootmem.h
 #include linux/pci.h
 #include linux/debugfs.h
 #include linux/of.h
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 155013d..ba0f2d6 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -17,7 +17,6 @@
 #include linux/pci.h
 #include linux/string.h
 #include linux/init.h
-#include linux/bootmem.h
 #include linux/export.h
 #include linux/mm.h
 #include linux/list.h
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index c168337..fe39926 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -26,7 +26,6 @@
 #include linux/pci.h
 #include linux/string.h
 #include linux/init.h
-#include linux/bootmem.h
 
 #include asm/io.h
 #include asm/pgtable.h
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index e2bc044..84dafdf 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -11,7 +11,6 @@
 #include linux/delay.h
 #include linux/initrd.h
 #include linux/tty.h
-#include linux/bootmem.h
 #include linux/seq_file.h
 #include linux/root_dev.h
 #include linux/cpu.h
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index f174351..305eb0d 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -20,7 +20,6 @@
 #include linux/user.h
 #include linux/elf.h
 #include linux/security.h
-#include linux/bootmem.h
 #include linux/memblock.h
 
 #include asm/pgtable.h
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c 
b/arch/powerpc/kvm/book3s_hv_builtin.c
index 297dbaf..6baa186 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -12,7 +12,6 @@
 #include linux/export.h
 #include linux/sched.h
 #include linux/spinlock.h
-#include linux/bootmem.h
 #include linux/init.h
 #include linux/memblock.h
 #include linux/sizes.h
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 9d1bde2..6332368 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -26,7 +26,6 @@
 #include linux/mm.h
 #include linux/stddef.h
 #include linux/init.h
-#include linux/bootmem.h
 #include linux/highmem.h
 #include linux/initrd.h
 #include linux/pagemap.h
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 3481556..10471f9 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -34,7 +34,6 @@
 #include linux/vmalloc.h
 #include linux/init.h
 #include linux/delay.h
-#include linux/bootmem.h
 #include linux/highmem.h
 #include linux/idr.h
 #include linux/nodemask.h
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index aa91737..e0c7185 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm

[PATCH 4/5] powerpc: Move sparse_init() into initmem_init

2014-09-17 Thread Anton Blanchard
We did part of sparse initialisation in setup_arch and part in
initmem_init. Put them together.

Signed-off-by: Anton Blanchard an...@samba.org
Tested-by: Emil Medve emilian.me...@freescale.com
---
 arch/powerpc/kernel/setup_64.c | 1 -
 arch/powerpc/mm/mem.c  | 1 +
 arch/powerpc/mm/numa.c | 2 ++
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 9f8f472..8bc8f77 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -682,7 +682,6 @@ void __init setup_arch(char **cmdline_p)
emergency_stack_init();
 
initmem_init();
-   sparse_init();
 
 #ifdef CONFIG_DUMMY_CONSOLE
conswitchp = dummy_con;
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index aa067b7..abbc55d 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -195,6 +195,7 @@ void __init initmem_init(void)
 
/* XXX need to clip this if using highmem? */
sparse_memory_present_with_active_regions(0);
+   sparse_init();
 }
 
 /* mark pages that don't exist as nosave */
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 4f9c18a..52559ff 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -964,6 +964,8 @@ void __init initmem_init(void)
sparse_memory_present_with_active_regions(nid);
}
 
+   sparse_init();
+
setup_node_to_cpumask_map();
 
reset_numa_cpu_lookup_table();
-- 
1.9.1

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

[PATCH 5/5] powerpc: make __ffs return unsigned long

2014-09-17 Thread Anton Blanchard
I'm seeing a build warning in mm/nobootmem.c after removing
bootmem:

mm/nobootmem.c: In function '__free_pages_memory':
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types 
lacks a cast [enabled by default]
  (void) (_min1 == _min2);  \
 ^
mm/nobootmem.c:90:11: note: in expansion of macro 'min'
   order = min(MAX_ORDER - 1UL, __ffs(start));
   ^

The rest of the worlds seems to define __ffs as returning unsigned long,
so lets do that.

Signed-off-by: Anton Blanchard an...@samba.org
Tested-by: Emil Medve emilian.me...@freescale.com
---
 arch/powerpc/include/asm/bitops.h | 2 +-
 arch/powerpc/sysdev/fsl_pci.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/bitops.h 
b/arch/powerpc/include/asm/bitops.h
index bd3bd57..c633f05 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -213,7 +213,7 @@ static __inline__ unsigned long ffz(unsigned long x)
return __ilog2(x  -x);
 }
 
-static __inline__ int __ffs(unsigned long x)
+static __inline__ unsigned long __ffs(unsigned long x)
 {
return __ilog2(x  -x);
 }
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index c507767..dae96fb 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -152,7 +152,7 @@ static int setup_one_atmu(struct ccsr_pci __iomem *pci,
flags |= 0x1000; /* enable relaxed ordering */
 
for (i = 0; size  0; i++) {
-   unsigned int bits = min(ilog2(size),
+   unsigned int bits = min_t(u32, ilog2(size),
__ffs(pci_addr | phys_addr));
 
if (index + i = 5)
-- 
1.9.1

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

[PATCH 1/6] powerpc: Speed up clear_page by unrolling it

2014-09-16 Thread Anton Blanchard
Unroll clear_page 8 times. A simple microbenchmark which
allocates and frees a zeroed page:

for (i = 0; i  iterations; i++) {
unsigned long p = __get_free_page(GFP_KERNEL | __GFP_ZERO);
free_page(p);
}

improves 20% on POWER8.

This assumes cacheline sizes won't grow beyond 512 bytes and
page sizes wont drop below 1kB, which is unlikely, but we could
add a runtime check during early init if it makes people nervous.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/page_64.h | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/page_64.h 
b/arch/powerpc/include/asm/page_64.h
index d0d6afb..b6e78cb 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -51,11 +51,21 @@ static __inline__ void clear_page(void *addr)
 
__asm__ __volatile__(
mtctr  %1  # clear_page\n\
-1:  dcbz   0,%0\n\
-   add %0,%0,%3\n\
+   .balign 16\n\
+1: dcbz0,%0\n\
+   dcbz%3,%0\n\
+   dcbz%4,%0\n\
+   dcbz%5,%0\n\
+   dcbz%6,%0\n\
+   dcbz%7,%0\n\
+   dcbz%8,%0\n\
+   dcbz%9,%0\n\
+   add %0,%0,%10\n\
bdnz+   1b
-: =r (addr)
-: r (lines), 0 (addr), r (line_size)
+   : =r (addr)
+   : r (lines/8), 0 (addr), b (line_size), b (line_size*2),
+   b (line_size*3), b (line_size*4), b (line_size*5),
+   b (line_size*6), b (line_size*7), r (line_size*8)
: ctr, memory);
 }
 
-- 
1.9.1

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

[PATCH 2/6] powerpc: Use pr_fmt in module loader code

2014-09-16 Thread Anton Blanchard
Use pr_fmt to give some context to the error messages in the
module code, and convert open coded debug printk to pr_debug.

Use pr_err for error messages.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/module_32.c | 31 ++-
 arch/powerpc/kernel/module_64.c | 36 +---
 2 files changed, 31 insertions(+), 36 deletions(-)

diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
index 6cff040..c94d2e0 100644
--- a/arch/powerpc/kernel/module_32.c
+++ b/arch/powerpc/kernel/module_32.c
@@ -15,6 +15,9 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
 #include linux/module.h
 #include linux/moduleloader.h
 #include linux/elf.h
@@ -28,12 +31,6 @@
 #include linux/sort.h
 #include asm/setup.h
 
-#if 0
-#define DEBUGP printk
-#else
-#define DEBUGP(fmt , ...)
-#endif
-
 /* Count how many different relocations (different symbol, different
addend) */
 static unsigned int count_relocs(const Elf32_Rela *rela, unsigned int num)
@@ -121,8 +118,8 @@ static unsigned long get_plt_size(const Elf32_Ehdr *hdr,
continue;
 
if (sechdrs[i].sh_type == SHT_RELA) {
-   DEBUGP(Found relocations in section %u\n, i);
-   DEBUGP(Ptr: %p.  Number: %u\n,
+   pr_debug(Found relocations in section %u\n, i);
+   pr_debug(Ptr: %p.  Number: %u\n,
   (void *)hdr + sechdrs[i].sh_offset,
   sechdrs[i].sh_size / sizeof(Elf32_Rela));
 
@@ -161,7 +158,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
me-arch.core_plt_section = i;
}
if (!me-arch.core_plt_section || !me-arch.init_plt_section) {
-   printk(Module doesn't contain .plt or .init.plt sections.\n);
+   pr_err(Module doesn't contain .plt or .init.plt sections.\n);
return -ENOEXEC;
}
 
@@ -189,7 +186,7 @@ static uint32_t do_plt_call(void *location,
 {
struct ppc_plt_entry *entry;
 
-   DEBUGP(Doing plt for call to 0x%x at 0x%x\n, val, (unsigned 
int)location);
+   pr_debug(Doing plt for call to 0x%x at 0x%x\n, val, (unsigned 
int)location);
/* Init, or core PLT? */
if (location = mod-module_core
 location  mod-module_core + mod-core_size)
@@ -208,7 +205,7 @@ static uint32_t do_plt_call(void *location,
entry-jump[2] = 0x7d8903a6;/* mtctr r12 */
entry-jump[3] = 0x4e800420;/* bctr */
 
-   DEBUGP(Initialized plt for 0x%x at %p\n, val, entry);
+   pr_debug(Initialized plt for 0x%x at %p\n, val, entry);
return (uint32_t)entry;
 }
 
@@ -224,7 +221,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
uint32_t *location;
uint32_t value;
 
-   DEBUGP(Applying ADD relocate section %u to %u\n, relsec,
+   pr_debug(Applying ADD relocate section %u to %u\n, relsec,
   sechdrs[relsec].sh_info);
for (i = 0; i  sechdrs[relsec].sh_size / sizeof(*rela); i++) {
/* This is where to make the change */
@@ -268,17 +265,17 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
sechdrs, module);
 
/* Only replace bits 2 through 26 */
-   DEBUGP(REL24 value = %08X. location = %08X\n,
+   pr_debug(REL24 value = %08X. location = %08X\n,
   value, (uint32_t)location);
-   DEBUGP(Location before: %08X.\n,
+   pr_debug(Location before: %08X.\n,
   *(uint32_t *)location);
*(uint32_t *)location
= (*(uint32_t *)location  ~0x03fc)
| ((value - (uint32_t)location)
0x03fc);
-   DEBUGP(Location after: %08X.\n,
+   pr_debug(Location after: %08X.\n,
   *(uint32_t *)location);
-   DEBUGP(ie. jump to %08X+%08X = %08X\n,
+   pr_debug(ie. jump to %08X+%08X = %08X\n,
   *(uint32_t *)location  0x03fc,
   (uint32_t)location,
   (*(uint32_t *)location  0x03fc)
@@ -291,7 +288,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
break;
 
default:
-   printk(%s: unknown ADD relocation: %u\n,
+   pr_err(%s: unknown ADD relocation: %u\n,
   module-name,
   ELF32_R_TYPE(rela[i].r_info

[PATCH 4/6] powerpc: Remove ppc_md.remove_memory

2014-09-16 Thread Anton Blanchard
We have an extra level of indirection on memory hot remove which is not
matched on memory hot add. Memory hotplug is book3s only, so there is
no need for it.

This also enables means remove_memory() (ie memory hot unplug) works
on powernv.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/machdep.h  |  4 
 arch/powerpc/mm/mem.c   | 12 ++--
 arch/powerpc/platforms/pseries/hotplug-memory.c | 21 -
 3 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h 
b/arch/powerpc/include/asm/machdep.h
index 902ab20..327e8dd 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -294,10 +294,6 @@ struct machdep_calls {
 #ifdef CONFIG_ARCH_RANDOM
int (*get_random_long)(unsigned long *v);
 #endif
-
-#ifdef CONFIG_MEMORY_HOTREMOVE
-   int (*remove_memory)(u64, u64);
-#endif
 };
 
 extern void e500_idle(void);
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index e0f7a18..28b27b1 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -35,6 +35,7 @@
 #include linux/memblock.h
 #include linux/hugetlb.h
 #include linux/slab.h
+#include linux/vmalloc.h
 
 #include asm/pgalloc.h
 #include asm/prom.h
@@ -144,8 +145,15 @@ int arch_remove_memory(u64 start, u64 size)
 
zone = page_zone(pfn_to_page(start_pfn));
ret = __remove_pages(zone, start_pfn, nr_pages);
-   if (!ret  (ppc_md.remove_memory))
-   ret = ppc_md.remove_memory(start, size);
+
+   start = (unsigned long)__va(start);
+   if (!ret)
+   ret = remove_section_mapping(start, start + size);
+
+   /* Ensure all vmalloc mappings are flushed in case they also
+* hit that section of memory
+*/
+   vm_unmap_aliases();
 
return ret;
 }
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c 
b/arch/powerpc/platforms/pseries/hotplug-memory.c
index e5171f5..eee55db 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -14,7 +14,6 @@
 #include linux/of.h
 #include linux/of_address.h
 #include linux/memblock.h
-#include linux/vmalloc.h
 #include linux/memory.h
 #include linux/memory_hotplug.h
 #include linux/slab.h
@@ -121,22 +120,6 @@ static struct memory_block *lmb_to_memblock(struct 
of_drconf_cell *lmb)
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-static int pseries_remove_memory(u64 start, u64 size)
-{
-   int ret;
-
-   /* Remove htab bolted mappings for this section of memory */
-   start = (unsigned long)__va(start);
-   ret = remove_section_mapping(start, start + size);
-
-   /* Ensure all vmalloc mappings are flushed in case they also
-* hit that section of memory
-*/
-   vm_unmap_aliases();
-
-   return ret;
-}
-
 static int pseries_remove_memblock(unsigned long base, unsigned int 
memblock_size)
 {
unsigned long block_sz, start_pfn;
@@ -592,10 +575,6 @@ static int __init pseries_memory_hotplug_init(void)
if (firmware_has_feature(FW_FEATURE_LPAR))
of_reconfig_notifier_register(pseries_mem_nb);
 
-#ifdef CONFIG_MEMORY_HOTREMOVE
-   ppc_md.remove_memory = pseries_remove_memory;
-#endif
-
return 0;
 }
 machine_device_initcall(pseries, pseries_memory_hotplug_init);
-- 
1.9.1

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

[PATCH 3/6] powerpc: Remove powerpc specific cmd_line

2014-09-16 Thread Anton Blanchard
There is no need for yet another copy of the command line, just
use boot_command_line like everyone else.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/machdep.h  | 2 --
 arch/powerpc/kernel/prom.c  | 4 +---
 arch/powerpc/kernel/setup-common.c  | 2 --
 arch/powerpc/kernel/setup_32.c  | 2 +-
 arch/powerpc/kernel/setup_64.c  | 2 +-
 arch/powerpc/mm/init_32.c   | 4 ++--
 arch/powerpc/platforms/chrp/setup.c | 2 +-
 arch/powerpc/platforms/powermac/setup.c | 8 
 drivers/cpufreq/pmac32-cpufreq.c| 2 +-
 drivers/tty/hvc/hvc_vio.c   | 2 +-
 10 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h 
b/arch/powerpc/include/asm/machdep.h
index b125cea..902ab20 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -330,8 +330,6 @@ extern struct machdep_calls *machine_id;
 
 extern void probe_machine(void);
 
-extern char cmd_line[COMMAND_LINE_SIZE];
-
 #ifdef CONFIG_PPC_PMAC
 /*
  * Power macintoshes have either a CUDA, PMU or SMU controlling
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 5957625..099f27e 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -668,14 +668,12 @@ void __init early_init_devtree(void *params)
 * device-tree, including the platform type, initrd location and
 * size, TCE reserve, and more ...
 */
-   of_scan_flat_dt(early_init_dt_scan_chosen_ppc, cmd_line);
+   of_scan_flat_dt(early_init_dt_scan_chosen_ppc, boot_command_line);
 
/* Scan memory nodes and rebuild MEMBLOCKs */
of_scan_flat_dt(early_init_dt_scan_root, NULL);
of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
 
-   /* Save command line for /proc/cmdline and then parse parameters */
-   strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
parse_early_param();
 
/* make sure we've parsed cmdline for mem= before this */
diff --git a/arch/powerpc/kernel/setup-common.c 
b/arch/powerpc/kernel/setup-common.c
index c933acd..0df37f5 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -81,8 +81,6 @@ EXPORT_SYMBOL_GPL(boot_cpuid);
 
 unsigned long klimit = (unsigned long) _end;
 
-char cmd_line[COMMAND_LINE_SIZE];
-
 /*
  * This still seems to be needed... -- paulus
  */ 
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index ea4fda6..07831ed 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -268,7 +268,7 @@ static void __init exc_lvl_early_init(void)
 /* Warning, IO base is not yet inited */
 void __init setup_arch(char **cmdline_p)
 {
-   *cmdline_p = cmd_line;
+   *cmdline_p = boot_command_line;
 
/* so udelay does something sensible, assume = 1000 bogomips */
loops_per_jiffy = 5 / HZ;
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index fa17c94..a3ba9d0 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -657,7 +657,7 @@ void __init setup_arch(char **cmdline_p)
 {
ppc64_boot_msg(0x12, Setup Arch);
 
-   *cmdline_p = cmd_line;
+   *cmdline_p = boot_command_line;
 
/*
 * Set cache line size based on type of cpu as a default.
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index cff59f1..cad68ff 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -106,11 +106,11 @@ unsigned long __max_low_memory = MAX_LOW_MEM;
 void MMU_setup(void)
 {
/* Check for nobats option (used in mapin_ram). */
-   if (strstr(cmd_line, nobats)) {
+   if (strstr(boot_command_line, nobats)) {
__map_without_bats = 1;
}
 
-   if (strstr(cmd_line, noltlbs)) {
+   if (strstr(boot_command_line, noltlbs)) {
__map_without_ltlbs = 1;
}
 #ifdef CONFIG_DEBUG_PAGEALLOC
diff --git a/arch/powerpc/platforms/chrp/setup.c 
b/arch/powerpc/platforms/chrp/setup.c
index 7044fd3..5b77b19 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -258,7 +258,7 @@ static void chrp_init_early(void)
struct device_node *node;
const char *property;
 
-   if (strstr(cmd_line, console=))
+   if (strstr(boot_command_line, console=))
return;
/* find the boot console from /chosen/stdout */
if (!of_chosen)
diff --git a/arch/powerpc/platforms/powermac/setup.c 
b/arch/powerpc/platforms/powermac/setup.c
index 141f8899..b127a29 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -336,7 +336,7 @@ static void __init pmac_setup_arch(void)
 #endif
 
 #ifdef CONFIG_ADB
-   if (strstr(cmd_line, adb_sync)) {
+   if (strstr(boot_command_line, adb_sync)) {
extern int __adb_probe_sync

[PATCH 5/6] powerpc: Add printk levels to powernv platform code

2014-09-16 Thread Anton Blanchard
Add printk levels to powernv platform code, and convert to
pr_err() etc while here.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/platforms/powernv/opal-nvram.c | 2 +-
 arch/powerpc/platforms/powernv/opal.c   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-nvram.c 
b/arch/powerpc/platforms/powernv/opal-nvram.c
index acd9f7e..f9896fd 100644
--- a/arch/powerpc/platforms/powernv/opal-nvram.c
+++ b/arch/powerpc/platforms/powernv/opal-nvram.c
@@ -78,7 +78,7 @@ void __init opal_nvram_init(void)
}
nvram_size = be32_to_cpup(nbytes_p);
 
-   printk(KERN_INFO OPAL nvram setup, %u bytes\n, nvram_size);
+   pr_info(OPAL nvram setup, %u bytes\n, nvram_size);
of_node_put(np);
 
ppc_md.nvram_read = opal_nvram_read;
diff --git a/arch/powerpc/platforms/powernv/opal.c 
b/arch/powerpc/platforms/powernv/opal.c
index b44eec3..cf85ba8 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -105,12 +105,12 @@ int __init early_init_dt_scan_opal(unsigned long node,
if (of_flat_dt_is_compatible(node, ibm,opal-v3)) {
powerpc_firmware_features |= FW_FEATURE_OPALv2;
powerpc_firmware_features |= FW_FEATURE_OPALv3;
-   printk(OPAL V3 detected !\n);
+   pr_info(OPAL V3 detected !\n);
} else if (of_flat_dt_is_compatible(node, ibm,opal-v2)) {
powerpc_firmware_features |= FW_FEATURE_OPALv2;
-   printk(OPAL V2 detected !\n);
+   pr_info(OPAL V2 detected !\n);
} else {
-   printk(OPAL V1 detected !\n);
+   pr_info(OPAL V1 detected !\n);
}
 
/* Reinit all cores with the right endian */
-- 
1.9.1

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

[PATCH 6/6] powerpc: Add printk levels to powerpc code

2014-09-16 Thread Anton Blanchard
Add printk levels to some places in the powerpc port.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/pgtable-ppc32.h|  4 ++--
 arch/powerpc/include/asm/pgtable-ppc64-4k.h |  2 +-
 arch/powerpc/include/asm/pgtable-ppc64.h|  6 +++---
 arch/powerpc/kernel/irq.c   |  6 +++---
 arch/powerpc/kernel/setup-common.c  |  2 +-
 arch/powerpc/kernel/setup_64.c  | 20 ++--
 6 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h 
b/arch/powerpc/include/asm/pgtable-ppc32.h
index 622672f..945e47a 100644
--- a/arch/powerpc/include/asm/pgtable-ppc32.h
+++ b/arch/powerpc/include/asm/pgtable-ppc32.h
@@ -48,10 +48,10 @@ extern int icache_44x_need_flush;
 #define FIRST_USER_ADDRESS 0
 
 #define pte_ERROR(e) \
-   printk(%s:%d: bad pte %llx.\n, __FILE__, __LINE__, \
+   pr_err(%s:%d: bad pte %llx.\n, __FILE__, __LINE__, \
(unsigned long long)pte_val(e))
 #define pgd_ERROR(e) \
-   printk(%s:%d: bad pgd %08lx.\n, __FILE__, __LINE__, pgd_val(e))
+   pr_err(%s:%d: bad pgd %08lx.\n, __FILE__, __LINE__, pgd_val(e))
 
 /*
  * This is the bottom of the PKMAP area with HIGHMEM or an arbitrary
diff --git a/arch/powerpc/include/asm/pgtable-ppc64-4k.h 
b/arch/powerpc/include/asm/pgtable-ppc64-4k.h
index 12798c9..7b93568 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64-4k.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64-4k.h
@@ -64,7 +64,7 @@
 (((addr)  PUD_SHIFT)  (PTRS_PER_PUD - 1)))
 
 #define pud_ERROR(e) \
-   printk(%s:%d: bad pud %08lx.\n, __FILE__, __LINE__, pud_val(e))
+   pr_err(%s:%d: bad pud %08lx.\n, __FILE__, __LINE__, pud_val(e))
 
 /*
  * On all 4K setups, remap_4k_pfn() equates to remap_pfn_range() */
diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h 
b/arch/powerpc/include/asm/pgtable-ppc64.h
index 7b3d54f..ae153c4 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -328,11 +328,11 @@ static inline void __ptep_set_access_flags(pte_t *ptep, 
pte_t entry)
 #define pte_same(A,B)  (((pte_val(A) ^ pte_val(B))  ~_PAGE_HPTEFLAGS) == 0)
 
 #define pte_ERROR(e) \
-   printk(%s:%d: bad pte %08lx.\n, __FILE__, __LINE__, pte_val(e))
+   pr_err(%s:%d: bad pte %08lx.\n, __FILE__, __LINE__, pte_val(e))
 #define pmd_ERROR(e) \
-   printk(%s:%d: bad pmd %08lx.\n, __FILE__, __LINE__, pmd_val(e))
+   pr_err(%s:%d: bad pmd %08lx.\n, __FILE__, __LINE__, pmd_val(e))
 #define pgd_ERROR(e) \
-   printk(%s:%d: bad pgd %08lx.\n, __FILE__, __LINE__, pgd_val(e))
+   pr_err(%s:%d: bad pgd %08lx.\n, __FILE__, __LINE__, pgd_val(e))
 
 /* Encode and de-code a swap entry */
 #define __swp_type(entry)  (((entry).val  1)  0x3f)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 4c5891d..8eb857f 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -444,13 +444,13 @@ void migrate_irqs(void)
 
cpumask_and(mask, data-affinity, map);
if (cpumask_any(mask) = nr_cpu_ids) {
-   printk(Breaking affinity for irq %i\n, irq);
+   pr_warn(Breaking affinity for irq %i\n, irq);
cpumask_copy(mask, map);
}
if (chip-irq_set_affinity)
chip-irq_set_affinity(data, mask, true);
else if (desc-action  !(warned++))
-   printk(Cannot set affinity for irq %i\n, irq);
+   pr_err(Cannot set affinity for irq %i\n, irq);
}
 
free_cpumask_var(mask);
@@ -470,7 +470,7 @@ static inline void check_stack_overflow(void)
 
/* check for stack overflow: is there less than 2KB free? */
if (unlikely(sp  (sizeof(struct thread_info) + 2048))) {
-   printk(do_IRQ: stack overflow: %ld\n,
+   pr_err(do_IRQ: stack overflow: %ld\n,
sp - sizeof(struct thread_info));
dump_stack();
}
diff --git a/arch/powerpc/kernel/setup-common.c 
b/arch/powerpc/kernel/setup-common.c
index 0df37f5..1362cd6 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -383,7 +383,7 @@ void __init check_for_initrd(void)
initrd_start = initrd_end = 0;
 
if (initrd_start)
-   printk(Found initrd at 0x%lx:0x%lx\n, initrd_start, 
initrd_end);
+   pr_info(Found initrd at 0x%lx:0x%lx\n, initrd_start, 
initrd_end);
 
DBG( - check_for_initrd()\n);
 #endif /* CONFIG_BLK_DEV_INITRD */
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index a3ba9d0..a8c9620 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -522,26 +522,26 @@ void __init setup_system(void)
smp_release_cpus();
 #endif
 
-   printk(Starting Linux PPC64 %s\n, init_utsname()-version);
+   pr_info

[PATCH 1/5] powerpc: Remove bootmem allocator

2014-09-16 Thread Anton Blanchard
At the moment we transition from the memblock alloctor to the bootmem
allocator. Gitting rid of the bootmem allocator removes a bunch of
complicated code (most of which I owe the dubious honour of being
responsible for writing).

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/Kconfig |   1 +
 arch/powerpc/include/asm/setup.h |   3 +-
 arch/powerpc/kernel/setup_32.c   |   5 +-
 arch/powerpc/kernel/setup_64.c   |   3 +-
 arch/powerpc/mm/init_32.c|   9 --
 arch/powerpc/mm/mem.c|  62 +--
 arch/powerpc/mm/numa.c   | 224 ++-
 arch/powerpc/mm/pgtable_32.c |   3 +-
 arch/powerpc/mm/pgtable_64.c |   6 +-
 9 files changed, 43 insertions(+), 273 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 90fe77a..3eeeb9d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -148,6 +148,7 @@ config PPC
select HAVE_ARCH_AUDITSYSCALL
select ARCH_SUPPORTS_ATOMIC_RMW
select HAVE_PERF_EVENTS_NMI if PPC64
+   select NO_BOOTMEM
 
 config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
index 11ba86e..fbdf18c 100644
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -8,7 +8,6 @@ extern void ppc_printk_progress(char *s, unsigned short hex);
 
 extern unsigned int rtas_data;
 extern int mem_init_done;  /* set on boot once kmalloc can be called */
-extern int init_bootmem_done;  /* set once bootmem is available */
 extern unsigned long long memory_limit;
 extern unsigned long klimit;
 extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
@@ -24,7 +23,7 @@ extern void reloc_got2(unsigned long);
 #define PTRRELOC(x)((typeof(x)) add_reloc_offset((unsigned long)(x)))
 
 void check_for_initrd(void);
-void do_init_bootmem(void);
+void initmem_init(void);
 void setup_panic(void);
 #define ARCH_PANIC_TIMEOUT 180
 
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index ea4fda6..e2bc044 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -311,9 +311,8 @@ void __init setup_arch(char **cmdline_p)
 
irqstack_early_init();
 
-   /* set up the bootmem stuff with available memory */
-   do_init_bootmem();
-   if ( ppc_md.progress ) ppc_md.progress(setup_arch: bootmem, 0x3eab);
+   initmem_init();
+   if ( ppc_md.progress ) ppc_md.progress(setup_arch: initmem, 0x3eab);
 
 #ifdef CONFIG_DUMMY_CONSOLE
conswitchp = dummy_con;
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index fa17c94..9f8f472 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -681,8 +681,7 @@ void __init setup_arch(char **cmdline_p)
exc_lvl_early_init();
emergency_stack_init();
 
-   /* set up the bootmem stuff with available memory */
-   do_init_bootmem();
+   initmem_init();
sparse_init();
 
 #ifdef CONFIG_DUMMY_CONSOLE
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index cff59f1..9d1bde2 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -195,15 +195,6 @@ void __init MMU_init(void)
memblock_set_current_limit(lowmem_end_addr);
 }
 
-/* This is only called until mem_init is done. */
-void __init *early_get_page(void)
-{
-   if (init_bootmem_done)
-   return alloc_bootmem_pages(PAGE_SIZE);
-   else
-   return __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
-}
-
 #ifdef CONFIG_8xx /* No 8xx specific .c file to put that in ... */
 void setup_initial_memory_limit(phys_addr_t first_memblock_base,
phys_addr_t first_memblock_size)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index e0f7a18..aa067b7 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -60,7 +60,6 @@
 #define CPU_FTR_NOEXECUTE  0
 #endif
 
-int init_bootmem_done;
 int mem_init_done;
 unsigned long long memory_limit;
 
@@ -180,70 +179,22 @@ walk_system_ram_range(unsigned long start_pfn, unsigned 
long nr_pages,
 }
 EXPORT_SYMBOL_GPL(walk_system_ram_range);
 
-/*
- * Initialize the bootmem system and give it all the memory we
- * have available.  If we are using highmem, we only put the
- * lowmem into the bootmem system.
- */
 #ifndef CONFIG_NEED_MULTIPLE_NODES
-void __init do_init_bootmem(void)
+void __init initmem_init(void)
 {
-   unsigned long start, bootmap_pages;
-   unsigned long total_pages;
-   struct memblock_region *reg;
-   int boot_mapsize;
-
max_low_pfn = max_pfn = memblock_end_of_DRAM()  PAGE_SHIFT;
-   total_pages = (memblock_end_of_DRAM() - memstart_addr)  PAGE_SHIFT;
+   min_low_pfn = MEMORY_START  PAGE_SHIFT;
 #ifdef CONFIG_HIGHMEM
-   total_pages = total_lowmem  PAGE_SHIFT;
max_low_pfn = lowmem_end_addr  PAGE_SHIFT;
 #endif

[PATCH 1/2] powerpc: Add POWER8 CPU selection

2014-09-15 Thread Anton Blanchard
This allows the user to build a kernel targeted at POWER8
(ie gcc -mcpu=power8).

Signed-off-by: Anton Blanchard an...@samba.org
---

Index: b/arch/powerpc/Makefile
===
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -135,6 +135,7 @@ CFLAGS-$(CONFIG_POWER4_CPU) += $(call cc
 CFLAGS-$(CONFIG_POWER5_CPU) += $(call cc-option,-mcpu=power5)
 CFLAGS-$(CONFIG_POWER6_CPU) += $(call cc-option,-mcpu=power6)
 CFLAGS-$(CONFIG_POWER7_CPU) += $(call cc-option,-mcpu=power7)
+CFLAGS-$(CONFIG_POWER8_CPU) += $(call cc-option,-mcpu=power8)
 
 # Altivec option not allowed with e500mc64 in GCC.
 ifeq ($(CONFIG_ALTIVEC),y)
Index: b/arch/powerpc/platforms/Kconfig.cputype
===
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -117,6 +117,10 @@ config POWER7_CPU
bool POWER7
depends on PPC_BOOK3S_64
 
+config POWER8_CPU
+   bool POWER8
+   depends on PPC_BOOK3S_64
+
 config E5500_CPU
bool Freescale e5500
depends on E500
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/2] powerpc: Use CONFIG_ARCH_HAS_FAST_MULTIPLIER

2014-09-15 Thread Anton Blanchard
I ran some tests to compare hash_64 using shifts and multiplies.
The results:

POWER6: ~2x slower
POWER7: ~2x faster
POWER8: ~2x faster

Now we have a proper config option, select
CONFIG_ARCH_HAS_FAST_MULTIPLIER on POWER7 and POWER8.

Signed-off-by: Anton Blanchard an...@samba.org
---

Index: b/arch/powerpc/platforms/Kconfig.cputype
===
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -116,10 +116,12 @@ config POWER6_CPU
 config POWER7_CPU
bool POWER7
depends on PPC_BOOK3S_64
+   select ARCH_HAS_FAST_MULTIPLIER
 
 config POWER8_CPU
bool POWER8
depends on PPC_BOOK3S_64
+   select ARCH_HAS_FAST_MULTIPLIER
 
 config E5500_CPU
bool Freescale e5500
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 6/6] powerpc: Separate ppc32 symbol exports into ppc_ksyms_32.c

2014-09-11 Thread Anton Blanchard
Hi Stephen,

 You removed export.h ...
 
  +EXPORT_SYMBOL(flush_dcache_range);
  +EXPORT_SYMBOL(flush_icache_range);
 
 But still use EXPORT_SYMBOL ...

Thanks, fixed!

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

Re: [PATCH 4/4] powerpc: Move htab_remove_mapping function prototype into header file

2014-09-11 Thread Anton Blanchard

Hi Stephen,

 Please be consistent about extern use (unless this file is already
 inconsistent, I guess).  (I know that the current trend is to remove
 extern in header files - I just happen to disagree with that
 trend. :-))

Good idea, fixed this for the next rev.

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

[PATCH] powerpc/perf: Fix ABIv2 kernel backtraces

2014-08-25 Thread Anton Blanchard
ABIv2 kernels are failing to backtrace through the kernel. An example:

39.30%  readseek2_proce  [kernel.kallsyms][k] find_get_entry
 
|
--- find_get_entry
   __GI___libc_read

The problem is in valid_next_sp() where we check that the new stack
pointer is at least STACK_FRAME_OVERHEAD below the previous one.

ABIv1 has a minimum stack frame size of 112 bytes consisting of 48 bytes
and 64 bytes of parameter save area. ABIv2 changes that to 32 bytes
with no paramter save area.

STACK_FRAME_OVERHEAD is in theory the minimum stack frame size,
but we over 240 uses of it, some of which assume that it includes
space for the parameter area.

We need to work through all our stack defines and rationalise them
but let's fix perf now by creating STACK_FRAME_MIN_SIZE and using
in valid_next_sp(). This fixes the issue:

30.64%  readseek2_proce  [kernel.kallsyms][k] find_get_entry
  
|
--- find_get_entry
   pagecache_get_page
   generic_file_read_iter
   new_sync_read
   vfs_read
   sys_read
   syscall_exit
   __GI___libc_read

Cc: sta...@vger.kernel.org # 3.16+
Reported-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
Signed-off-by: Anton Blanchard an...@samba.org
---

Index: b/arch/powerpc/include/asm/ptrace.h
===
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -47,6 +47,12 @@
 STACK_FRAME_OVERHEAD + KERNEL_REDZONE_SIZE)
 #define STACK_FRAME_MARKER 12
 
+#if defined(_CALL_ELF)  _CALL_ELF == 2
+#define STACK_FRAME_MIN_SIZE   32
+#else
+#define STACK_FRAME_MIN_SIZE   STACK_FRAME_OVERHEAD
+#endif
+
 /* Size of dummy stack frame allocated when calling signal handler. */
 #define __SIGNAL_FRAMESIZE 128
 #define __SIGNAL_FRAMESIZE32   64
@@ -60,6 +66,7 @@
 #define STACK_FRAME_REGS_MARKERASM_CONST(0x72656773)
 #define STACK_INT_FRAME_SIZE   (sizeof(struct pt_regs) + STACK_FRAME_OVERHEAD)
 #define STACK_FRAME_MARKER 2
+#define STACK_FRAME_MIN_SIZE   STACK_FRAME_OVERHEAD
 
 /* Size of stack frame allocated when calling signal handler. */
 #define __SIGNAL_FRAMESIZE 64
Index: b/arch/powerpc/perf/callchain.c
===
--- a/arch/powerpc/perf/callchain.c
+++ b/arch/powerpc/perf/callchain.c
@@ -35,7 +35,7 @@ static int valid_next_sp(unsigned long s
return 0;   /* must be 16-byte aligned */
if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD))
return 0;
-   if (sp = prev_sp + STACK_FRAME_OVERHEAD)
+   if (sp = prev_sp + STACK_FRAME_MIN_SIZE)
return 1;
/*
 * sp could decrease when we jump off an interrupt stack
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] ibmveth: Fix endian issues with rx_no_buffer statistic

2014-08-21 Thread Anton Blanchard
Hidden away in the last 8 bytes of the buffer_list page is a solitary
statistic. It needs to be byte swapped or else ethtool -S will
produce numbers that terrify the user.

Since we do this in multiple places, create a helper function with a
comment explaining what is going on.

Signed-off-by: Anton Blanchard an...@samba.org
Cc: sta...@vger.kernel.org
---

Index: b/drivers/net/ethernet/ibm/ibmveth.c
===
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -292,6 +292,18 @@ failure:
atomic_add(buffers_added, (pool-available));
 }
 
+/*
+ * The final 8 bytes of the buffer list is a counter of frames dropped
+ * because there was not a buffer in the buffer list capable of holding
+ * the frame.
+ */
+static void ibmveth_update_rx_no_buffer(struct ibmveth_adapter *adapter)
+{
+   __be64 *p = adapter-buffer_list_addr + 4096 - 8;
+
+   adapter-rx_no_buffer = be64_to_cpup(p);
+}
+
 /* replenish routine */
 static void ibmveth_replenish_task(struct ibmveth_adapter *adapter)
 {
@@ -307,8 +319,7 @@ static void ibmveth_replenish_task(struc
ibmveth_replenish_buffer_pool(adapter, pool);
}
 
-   adapter-rx_no_buffer = *(u64 *)(((char*)adapter-buffer_list_addr) +
-   4096 - 8);
+   ibmveth_update_rx_no_buffer(adapter);
 }
 
 /* empty and free ana buffer pool - also used to do cleanup in error paths */
@@ -698,8 +709,7 @@ static int ibmveth_close(struct net_devi
 
free_irq(netdev-irq, netdev);
 
-   adapter-rx_no_buffer = *(u64 *)(((char *)adapter-buffer_list_addr) +
-   4096 - 8);
+   ibmveth_update_rx_no_buffer(adapter);
 
ibmveth_cleanup(adapter);
 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] PCI: Increase BAR size quirk for IBM ipr SAS Crocodile adapters

2014-08-20 Thread Anton Blanchard
From: Douglas Lehr dll...@us.ibm.com

The Crocodile chip occasionally comes up with 4k and 8k BAR sizes.
Due to an errata, setting the SR-IOV page size causes the physical
function BARs to expand to the system page size.  Since ppc64 uses
64k pages, when Linux tries to assign the smaller resource sizes
to the now 64k BARs the address will be truncated and the BARs will
overlap.

This quirk will force Linux to allocate the resource as a full page,
which will avoid the overlap.

Cc: sta...@vger.kernel.org 
Signed-off-by: Douglas Lehr dll...@us.ibm.com
Signed-off-by: Anton Blanchard an...@samba.org
Acked-by: Milton Miller milt...@us.ibm.com
---
 drivers/pci/quirks.c |   19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 80c2d01..45b946d 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -24,6 +24,7 @@
 #include linux/ioport.h
 #include linux/sched.h
 #include linux/ktime.h
+#include linux/mm.h
 #include asm/dma.h   /* isa_dma_bridge_buggy */
 #include pci.h
 
@@ -287,6 +288,24 @@ static void quirk_citrine(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM,PCI_DEVICE_ID_IBM_CITRINE,  
quirk_citrine);
 
+/*  On IBM Crocodile ipr SAS adapters, expand bar size to system page size. */
+static void quirk_extend_bar_to_page(struct pci_dev *dev)
+{
+   int i;
+
+   for (i = 0; i  PCI_STD_RESOURCE_END; i++) {
+   struct resource *r = dev-resource[i];
+
+   if (r-flags  IORESOURCE_MEM  resource_size(r)  PAGE_SIZE) {
+   dev_info(dev-dev, Setting Bar size to Page size);
+   r-end = PAGE_SIZE-1;
+   r-start = 0;
+   r-flags |= IORESOURCE_UNSET;
+   }
+   }
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, 0x034a, quirk_extend_bar_to_page);
+
 /*
  *  S3 868 and 968 chips report region size equal to 32M, but they decode 64M.
  *  If it's needed, re-allocate the region.
-- 
1.7.9.5

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

[PATCH 1/6] powerpc: Move adb symbol exports next to function definitions

2014-08-19 Thread Anton Blanchard
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/ppc_ksyms.c | 7 ---
 drivers/macintosh/adb.c | 5 +
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 48d17d6f..351f447 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -128,13 +128,6 @@ EXPORT_SYMBOL(smp_hw_index);
 #endif
 #endif
 
-#ifdef CONFIG_ADB
-EXPORT_SYMBOL(adb_request);
-EXPORT_SYMBOL(adb_register);
-EXPORT_SYMBOL(adb_unregister);
-EXPORT_SYMBOL(adb_poll);
-EXPORT_SYMBOL(adb_try_handler_change);
-#endif /* CONFIG_ADB */
 #ifdef CONFIG_ADB_CUDA
 EXPORT_SYMBOL(cuda_request);
 EXPORT_SYMBOL(cuda_poll);
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 9e9c567..226179b 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -411,6 +411,7 @@ adb_poll(void)
return;
adb_controller-poll();
 }
+EXPORT_SYMBOL(adb_poll);
 
 static void adb_sync_req_done(struct adb_request *req)
 {
@@ -460,6 +461,7 @@ adb_request(struct adb_request *req, void (*done)(struct 
adb_request *),
 
return rc;
 }
+EXPORT_SYMBOL(adb_request);
 
  /* Ultimately this should return the number of devices with
 the given default id.
@@ -495,6 +497,7 @@ adb_register(int default_id, int handler_id, struct adb_ids 
*ids,
mutex_unlock(adb_handler_mutex);
return ids-nids;
 }
+EXPORT_SYMBOL(adb_register);
 
 int
 adb_unregister(int index)
@@ -516,6 +519,7 @@ adb_unregister(int index)
mutex_unlock(adb_handler_mutex);
return ret;
 }
+EXPORT_SYMBOL(adb_unregister);
 
 void
 adb_input(unsigned char *buf, int nb, int autopoll)
@@ -582,6 +586,7 @@ adb_try_handler_change(int address, int new_id)
mutex_unlock(adb_handler_mutex);
return ret;
 }
+EXPORT_SYMBOL(adb_try_handler_change);
 
 int
 adb_get_infos(int address, int *original_address, int *handler_id)
-- 
1.9.1

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

[PATCH 2/6] powerpc: Move via-cuda symbol exports next to function definitions

2014-08-19 Thread Anton Blanchard
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/ppc_ksyms.c | 4 
 drivers/macintosh/via-cuda.c| 2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 351f447..521291d 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -128,10 +128,6 @@ EXPORT_SYMBOL(smp_hw_index);
 #endif
 #endif
 
-#ifdef CONFIG_ADB_CUDA
-EXPORT_SYMBOL(cuda_request);
-EXPORT_SYMBOL(cuda_poll);
-#endif /* CONFIG_ADB_CUDA */
 EXPORT_SYMBOL(to_tm);
 
 #ifdef CONFIG_PPC32
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index d61f271..bad1813 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -379,6 +379,7 @@ cuda_request(struct adb_request *req, void (*done)(struct 
adb_request *),
 req-reply_expected = 1;
 return cuda_write(req);
 }
+EXPORT_SYMBOL(cuda_request);
 
 static int
 cuda_write(struct adb_request *req)
@@ -441,6 +442,7 @@ cuda_poll(void)
 if (cuda_irq)
enable_irq(cuda_irq);
 }
+EXPORT_SYMBOL(cuda_poll);
 
 static irqreturn_t
 cuda_interrupt(int irq, void *arg)
-- 
1.9.1

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

[PATCH 3/6] powerpc: Move more symbol exports next to function definitions

2014-08-19 Thread Anton Blanchard
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/ppc_ksyms.c| 14 --
 arch/powerpc/kernel/process.c  |  2 ++
 arch/powerpc/kernel/setup-common.c |  3 +++
 arch/powerpc/kernel/time.c |  1 +
 arch/powerpc/mm/hash_utils_64.c|  1 +
 5 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 521291d..4a42a1f 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -5,7 +5,6 @@
 #include linux/elfcore.h
 #include linux/string.h
 #include linux/interrupt.h
-#include linux/screen_info.h
 #include linux/vt_kern.h
 #include linux/nvram.h
 #include linux/irq.h
@@ -96,8 +95,6 @@ EXPORT_SYMBOL(isa_mem_base);
 EXPORT_SYMBOL(pci_dram_offset);
 #endif /* CONFIG_PCI */
 
-EXPORT_SYMBOL(start_thread);
-
 #ifdef CONFIG_PPC_FPU
 EXPORT_SYMBOL(giveup_fpu);
 EXPORT_SYMBOL(load_fp_state);
@@ -109,7 +106,6 @@ EXPORT_SYMBOL(load_vr_state);
 EXPORT_SYMBOL(store_vr_state);
 #endif /* CONFIG_ALTIVEC */
 #ifdef CONFIG_VSX
-EXPORT_SYMBOL(giveup_vsx);
 EXPORT_SYMBOL_GPL(__giveup_vsx);
 #endif /* CONFIG_VSX */
 #ifdef CONFIG_SPE
@@ -128,8 +124,6 @@ EXPORT_SYMBOL(smp_hw_index);
 #endif
 #endif
 
-EXPORT_SYMBOL(to_tm);
-
 #ifdef CONFIG_PPC32
 long long __ashrdi3(long long, int);
 long long __ashldi3(long long, int);
@@ -150,10 +144,6 @@ EXPORT_SYMBOL(memmove);
 EXPORT_SYMBOL(memcmp);
 EXPORT_SYMBOL(memchr);
 
-#if defined(CONFIG_FB_VGA16_MODULE)
-EXPORT_SYMBOL(screen_info);
-#endif
-
 #ifdef CONFIG_PPC32
 EXPORT_SYMBOL(timer_interrupt);
 EXPORT_SYMBOL(tb_ticks_per_jiffy);
@@ -189,10 +179,6 @@ EXPORT_SYMBOL(__arch_hweight32);
 EXPORT_SYMBOL(__arch_hweight64);
 #endif
 
-#ifdef CONFIG_PPC_BOOK3S_64
-EXPORT_SYMBOL_GPL(mmu_psize_defs);
-#endif
-
 #ifdef CONFIG_EPAPR_PARAVIRT
 EXPORT_SYMBOL(epapr_hypercall_start);
 #endif
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index bf44ae9..aa1df89 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -228,6 +228,7 @@ void giveup_vsx(struct task_struct *tsk)
giveup_altivec_maybe_transactional(tsk);
__giveup_vsx(tsk);
 }
+EXPORT_SYMBOL(giveup_vsx);
 
 void flush_vsx_to_thread(struct task_struct *tsk)
 {
@@ -1316,6 +1317,7 @@ void start_thread(struct pt_regs *regs, unsigned long 
start, unsigned long sp)
current-thread.tm_tfiar = 0;
 #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
 }
+EXPORT_SYMBOL(start_thread);
 
 #define PR_FP_ALL_EXCEPT (PR_FP_EXC_DIV | PR_FP_EXC_OVF | PR_FP_EXC_UND \
| PR_FP_EXC_RES | PR_FP_EXC_INV)
diff --git a/arch/powerpc/kernel/setup-common.c 
b/arch/powerpc/kernel/setup-common.c
index 1b0e260..c933acd 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -94,6 +94,9 @@ struct screen_info screen_info = {
.orig_video_isVGA = 1,
.orig_video_points = 16
 };
+#if defined(CONFIG_FB_VGA16_MODULE)
+EXPORT_SYMBOL(screen_info);
+#endif
 
 /* Variables required to store legacy IO irq routing */
 int of_i8042_kbd_irq;
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 368ab37..08b 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -1024,6 +1024,7 @@ void to_tm(int tim, struct rtc_time * tm)
 */
GregorianDay(tm);
 }
+EXPORT_SYMBOL(to_tm);
 
 /*
  * Divide a 128-bit dividend by a 32-bit divisor, leaving a 128 bit
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index daee7f4..bc6cc2a 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -92,6 +92,7 @@ extern unsigned long dart_tablebase;
 
 static unsigned long _SDR1;
 struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
+EXPORT_SYMBOL_GPL(mmu_psize_defs);
 
 struct hash_pte *htab_address;
 unsigned long htab_size_bytes;
-- 
1.9.1

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

[PATCH 4/6] powerpc: Remove unused 32bit symbol exports

2014-08-19 Thread Anton Blanchard
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/ppc_ksyms.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 4a42a1f..ab4f0bc 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -45,26 +45,10 @@
 #include asm/epapr_hcalls.h
 
 #ifdef CONFIG_PPC32
-extern void transfer_to_handler(void);
-extern void do_IRQ(struct pt_regs *regs);
-extern void machine_check_exception(struct pt_regs *regs);
-extern void alignment_exception(struct pt_regs *regs);
-extern void program_check_exception(struct pt_regs *regs);
-extern void single_step_exception(struct pt_regs *regs);
-extern int sys_sigreturn(struct pt_regs *regs);
-
 EXPORT_SYMBOL(clear_pages);
 EXPORT_SYMBOL(ISA_DMA_THRESHOLD);
 EXPORT_SYMBOL(DMA_MODE_READ);
 EXPORT_SYMBOL(DMA_MODE_WRITE);
-
-EXPORT_SYMBOL(transfer_to_handler);
-EXPORT_SYMBOL(do_IRQ);
-EXPORT_SYMBOL(machine_check_exception);
-EXPORT_SYMBOL(alignment_exception);
-EXPORT_SYMBOL(program_check_exception);
-EXPORT_SYMBOL(single_step_exception);
-EXPORT_SYMBOL(sys_sigreturn);
 #endif
 
 #ifdef CONFIG_FUNCTION_TRACER
-- 
1.9.1

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

[PATCH 5/6] powerpc: Move lib symbol exports into arch/powerpc/lib/ppc_ksyms.c

2014-08-19 Thread Anton Blanchard
Move the lib symbol exports closer to their function definitions

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/ppc_ksyms.c | 32 
 arch/powerpc/lib/Makefile   |  2 +-
 arch/powerpc/lib/ppc_ksyms.c| 39 +++
 3 files changed, 40 insertions(+), 33 deletions(-)
 create mode 100644 arch/powerpc/lib/ppc_ksyms.c

diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index ab4f0bc..aba41f3 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -55,24 +55,6 @@ EXPORT_SYMBOL(DMA_MODE_WRITE);
 EXPORT_SYMBOL(_mcount);
 #endif
 
-EXPORT_SYMBOL(strcpy);
-EXPORT_SYMBOL(strncpy);
-EXPORT_SYMBOL(strcat);
-EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strcmp);
-EXPORT_SYMBOL(strncmp);
-
-#ifndef CONFIG_GENERIC_CSUM
-EXPORT_SYMBOL(csum_partial);
-EXPORT_SYMBOL(csum_partial_copy_generic);
-EXPORT_SYMBOL(ip_fast_csum);
-EXPORT_SYMBOL(csum_tcpudp_magic);
-#endif
-
-EXPORT_SYMBOL(__copy_tofrom_user);
-EXPORT_SYMBOL(__clear_user);
-EXPORT_SYMBOL(copy_page);
-
 #if defined(CONFIG_PCI)  defined(CONFIG_PPC32)
 EXPORT_SYMBOL(isa_io_base);
 EXPORT_SYMBOL(isa_mem_base);
@@ -122,17 +104,10 @@ EXPORT_SYMBOL(__cmpdi2);
 #endif
 long long __bswapdi2(long long);
 EXPORT_SYMBOL(__bswapdi2);
-EXPORT_SYMBOL(memcpy);
-EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL(memchr);
 
 #ifdef CONFIG_PPC32
 EXPORT_SYMBOL(timer_interrupt);
 EXPORT_SYMBOL(tb_ticks_per_jiffy);
-EXPORT_SYMBOL(cacheable_memcpy);
-EXPORT_SYMBOL(cacheable_memzero);
 #endif
 
 #ifdef CONFIG_PPC32
@@ -156,13 +131,6 @@ EXPORT_SYMBOL(__mfdcr);
 #endif
 EXPORT_SYMBOL(empty_zero_page);
 
-#ifdef CONFIG_PPC64
-EXPORT_SYMBOL(__arch_hweight8);
-EXPORT_SYMBOL(__arch_hweight16);
-EXPORT_SYMBOL(__arch_hweight32);
-EXPORT_SYMBOL(__arch_hweight64);
-#endif
-
 #ifdef CONFIG_EPAPR_PARAVIRT
 EXPORT_SYMBOL(epapr_hypercall_start);
 #endif
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 59fa2de..9f342f1 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -10,7 +10,7 @@ CFLAGS_REMOVE_code-patching.o = -pg
 CFLAGS_REMOVE_feature-fixups.o = -pg
 
 obj-y  := string.o alloc.o \
-  crtsavres.o
+  crtsavres.o ppc_ksyms.o
 obj-$(CONFIG_PPC32)+= div64.o copy_32.o
 obj-$(CONFIG_HAS_IOMEM)+= devres.o
 
diff --git a/arch/powerpc/lib/ppc_ksyms.c b/arch/powerpc/lib/ppc_ksyms.c
new file mode 100644
index 000..f993959
--- /dev/null
+++ b/arch/powerpc/lib/ppc_ksyms.c
@@ -0,0 +1,39 @@
+#include linux/string.h
+#include linux/uaccess.h
+#include linux/bitops.h
+#include net/checksum.h
+
+EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(memset);
+EXPORT_SYMBOL(memmove);
+EXPORT_SYMBOL(memcmp);
+EXPORT_SYMBOL(memchr);
+#ifdef CONFIG_PPC32
+EXPORT_SYMBOL(cacheable_memcpy);
+EXPORT_SYMBOL(cacheable_memzero);
+#endif
+
+EXPORT_SYMBOL(strcpy);
+EXPORT_SYMBOL(strncpy);
+EXPORT_SYMBOL(strcat);
+EXPORT_SYMBOL(strlen);
+EXPORT_SYMBOL(strcmp);
+EXPORT_SYMBOL(strncmp);
+
+#ifndef CONFIG_GENERIC_CSUM
+EXPORT_SYMBOL(csum_partial);
+EXPORT_SYMBOL(csum_partial_copy_generic);
+EXPORT_SYMBOL(ip_fast_csum);
+EXPORT_SYMBOL(csum_tcpudp_magic);
+#endif
+
+EXPORT_SYMBOL(__copy_tofrom_user);
+EXPORT_SYMBOL(__clear_user);
+EXPORT_SYMBOL(copy_page);
+
+#ifdef CONFIG_PPC64
+EXPORT_SYMBOL(__arch_hweight8);
+EXPORT_SYMBOL(__arch_hweight16);
+EXPORT_SYMBOL(__arch_hweight32);
+EXPORT_SYMBOL(__arch_hweight64);
+#endif
-- 
1.9.1

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

[PATCH 6/6] powerpc: Separate ppc32 symbol exports into ppc_ksyms_32.c

2014-08-19 Thread Anton Blanchard
Simplify things considerably by moving all the ppc32 specific
symbol exports into its own file.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/Makefile   |   3 +
 arch/powerpc/kernel/ppc_ksyms.c| 123 +
 arch/powerpc/kernel/ppc_ksyms_32.c |  61 ++
 3 files changed, 79 insertions(+), 108 deletions(-)
 create mode 100644 arch/powerpc/kernel/ppc_ksyms_32.c

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 670c312..502cf69 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -93,6 +93,9 @@ obj-$(CONFIG_PPC32)   += entry_32.o setup_32.o
 obj-$(CONFIG_PPC64)+= dma-iommu.o iommu.o
 obj-$(CONFIG_KGDB) += kgdb.o
 obj-$(CONFIG_MODULES)  += ppc_ksyms.o
+ifeq ($(CONFIG_PPC32),y)
+obj-$(CONFIG_MODULES)  += ppc_ksyms_32.o
+endif
 obj-$(CONFIG_BOOTX_TEXT)   += btext.o
 obj-$(CONFIG_SMP)  += smp.o
 obj-$(CONFIG_KPROBES)  += kprobes.o
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index aba41f3..c4dfff6 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -1,135 +1,42 @@
-#include linux/export.h
-#include linux/threads.h
-#include linux/smp.h
-#include linux/sched.h
-#include linux/elfcore.h
-#include linux/string.h
-#include linux/interrupt.h
-#include linux/vt_kern.h
-#include linux/nvram.h
-#include linux/irq.h
-#include linux/pci.h
-#include linux/delay.h
-#include linux/bitops.h
+#include linux/ftrace.h
+#include linux/mm.h
 
-#include asm/page.h
 #include asm/processor.h
-#include asm/cacheflush.h
-#include asm/uaccess.h
-#include asm/io.h
-#include linux/atomic.h
-#include asm/checksum.h
-#include asm/pgtable.h
-#include asm/tlbflush.h
-#include linux/adb.h
-#include linux/cuda.h
-#include linux/pmu.h
-#include asm/prom.h
-#include asm/pci-bridge.h
-#include asm/irq.h
-#include asm/pmac_feature.h
-#include asm/dma.h
-#include asm/machdep.h
-#include asm/hw_irq.h
-#include asm/nvram.h
-#include asm/mmu_context.h
-#include asm/backlight.h
-#include asm/time.h
-#include asm/cputable.h
-#include asm/btext.h
-#include asm/div64.h
-#include asm/signal.h
-#include asm/dcr.h
-#include asm/ftrace.h
 #include asm/switch_to.h
+#include asm/cacheflush.h
 #include asm/epapr_hcalls.h
 
-#ifdef CONFIG_PPC32
-EXPORT_SYMBOL(clear_pages);
-EXPORT_SYMBOL(ISA_DMA_THRESHOLD);
-EXPORT_SYMBOL(DMA_MODE_READ);
-EXPORT_SYMBOL(DMA_MODE_WRITE);
-#endif
+EXPORT_SYMBOL(flush_dcache_range);
+EXPORT_SYMBOL(flush_icache_range);
+
+EXPORT_SYMBOL(empty_zero_page);
+
+long long __bswapdi2(long long);
+EXPORT_SYMBOL(__bswapdi2);
 
 #ifdef CONFIG_FUNCTION_TRACER
 EXPORT_SYMBOL(_mcount);
 #endif
 
-#if defined(CONFIG_PCI)  defined(CONFIG_PPC32)
-EXPORT_SYMBOL(isa_io_base);
-EXPORT_SYMBOL(isa_mem_base);
-EXPORT_SYMBOL(pci_dram_offset);
-#endif /* CONFIG_PCI */
-
 #ifdef CONFIG_PPC_FPU
 EXPORT_SYMBOL(giveup_fpu);
 EXPORT_SYMBOL(load_fp_state);
 EXPORT_SYMBOL(store_fp_state);
 #endif
+
 #ifdef CONFIG_ALTIVEC
 EXPORT_SYMBOL(giveup_altivec);
 EXPORT_SYMBOL(load_vr_state);
 EXPORT_SYMBOL(store_vr_state);
-#endif /* CONFIG_ALTIVEC */
-#ifdef CONFIG_VSX
-EXPORT_SYMBOL_GPL(__giveup_vsx);
-#endif /* CONFIG_VSX */
-#ifdef CONFIG_SPE
-EXPORT_SYMBOL(giveup_spe);
-#endif /* CONFIG_SPE */
-
-#ifndef CONFIG_PPC64
-EXPORT_SYMBOL(flush_instruction_cache);
-#endif
-EXPORT_SYMBOL(flush_dcache_range);
-EXPORT_SYMBOL(flush_icache_range);
-
-#ifdef CONFIG_SMP
-#ifdef CONFIG_PPC32
-EXPORT_SYMBOL(smp_hw_index);
-#endif
-#endif
-
-#ifdef CONFIG_PPC32
-long long __ashrdi3(long long, int);
-long long __ashldi3(long long, int);
-long long __lshrdi3(long long, int);
-EXPORT_SYMBOL(__ashrdi3);
-EXPORT_SYMBOL(__ashldi3);
-EXPORT_SYMBOL(__lshrdi3);
-int __ucmpdi2(unsigned long long, unsigned long long);
-EXPORT_SYMBOL(__ucmpdi2);
-int __cmpdi2(long long, long long);
-EXPORT_SYMBOL(__cmpdi2);
-#endif
-long long __bswapdi2(long long);
-EXPORT_SYMBOL(__bswapdi2);
-
-#ifdef CONFIG_PPC32
-EXPORT_SYMBOL(timer_interrupt);
-EXPORT_SYMBOL(tb_ticks_per_jiffy);
 #endif
 
-#ifdef CONFIG_PPC32
-EXPORT_SYMBOL(switch_mmu_context);
+#ifdef CONFIG_VSX
+EXPORT_SYMBOL_GPL(__giveup_vsx);
 #endif
 
-#ifdef CONFIG_PPC_STD_MMU_32
-extern long mol_trampoline;
-EXPORT_SYMBOL(mol_trampoline); /* For MOL */
-EXPORT_SYMBOL(flush_hash_pages); /* For MOL */
-#ifdef CONFIG_SMP
-extern int mmu_hash_lock;
-EXPORT_SYMBOL(mmu_hash_lock); /* For MOL */
-#endif /* CONFIG_SMP */
-extern long *intercept_table;
-EXPORT_SYMBOL(intercept_table);
-#endif /* CONFIG_PPC_STD_MMU_32 */
-#ifdef CONFIG_PPC_DCR_NATIVE
-EXPORT_SYMBOL(__mtdcr);
-EXPORT_SYMBOL(__mfdcr);
+#ifdef CONFIG_SPE
+EXPORT_SYMBOL(giveup_spe);
 #endif
-EXPORT_SYMBOL(empty_zero_page);
 
 #ifdef CONFIG_EPAPR_PARAVIRT
 EXPORT_SYMBOL(epapr_hypercall_start);
diff --git a/arch/powerpc/kernel/ppc_ksyms_32.c 
b/arch/powerpc/kernel/ppc_ksyms_32.c
new file mode 100644
index 000..30ddd8a
--- /dev

[PATCH 1/4] powerpc: Make a bunch of things static

2014-08-19 Thread Anton Blanchard
Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/hw_breakpoint.c   |  2 +-
 arch/powerpc/kernel/nvram_64.c|  2 +-
 arch/powerpc/kernel/pci-common.c  |  2 +-
 arch/powerpc/kernel/pci_of_scan.c |  2 +-
 arch/powerpc/kernel/prom.c|  5 +++--
 arch/powerpc/kernel/ptrace.c  |  2 +-
 arch/powerpc/kernel/rtasd.c   |  2 +-
 arch/powerpc/kernel/time.c|  4 ++--
 arch/powerpc/lib/feature-fixups.c |  2 +-
 arch/powerpc/mm/hash_utils_64.c   |  2 +-
 arch/powerpc/mm/pgtable.c |  2 +-
 arch/powerpc/perf/core-book3s.c   | 18 +-
 arch/powerpc/platforms/powernv/eeh-ioda.c |  4 ++--
 arch/powerpc/platforms/powernv/pci-ioda.c |  6 +++---
 arch/powerpc/platforms/powernv/setup.c|  2 +-
 arch/powerpc/platforms/powernv/smp.c  |  2 +-
 arch/powerpc/platforms/pseries/dlpar.c|  4 ++--
 arch/powerpc/platforms/pseries/nvram.c| 12 +++-
 arch/powerpc/platforms/pseries/ras.c  |  2 +-
 arch/powerpc/platforms/pseries/setup.c|  2 +-
 arch/powerpc/sysdev/mpic.c|  2 +-
 arch/powerpc/sysdev/msi_bitmap.c  |  6 +++---
 22 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/arch/powerpc/kernel/hw_breakpoint.c 
b/arch/powerpc/kernel/hw_breakpoint.c
index 0bb5918..1f7d84e 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -293,7 +293,7 @@ out:
 /*
  * Handle single-step exceptions following a DABR hit.
  */
-int __kprobes single_step_dabr_instruction(struct die_args *args)
+static int __kprobes single_step_dabr_instruction(struct die_args *args)
 {
struct pt_regs *regs = args-regs;
struct perf_event *bp = NULL;
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 28b898e..34f7c9b 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -567,7 +567,7 @@ static int __init nvram_init(void)
return rc;
 }
 
-void __exit nvram_cleanup(void)
+static void __exit nvram_cleanup(void)
 {
 misc_deregister( nvram_dev );
 }
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index b2814e2..bd84771 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1140,7 +1140,7 @@ static int reparent_resources(struct resource *parent,
  * as well.
  */
 
-void pcibios_allocate_bus_resources(struct pci_bus *bus)
+static void pcibios_allocate_bus_resources(struct pci_bus *bus)
 {
struct pci_bus *b;
int i;
diff --git a/arch/powerpc/kernel/pci_of_scan.c 
b/arch/powerpc/kernel/pci_of_scan.c
index 44562aa..e6245e9 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -38,7 +38,7 @@ static u32 get_int_prop(struct device_node *np, const char 
*name, u32 def)
  * @addr0: value of 1st cell of a device tree PCI address.
  * @bridge: Set this flag if the address is from a bridge 'ranges' property
  */
-unsigned int pci_parse_of_flags(u32 addr0, int bridge)
+static unsigned int pci_parse_of_flags(u32 addr0, int bridge)
 {
unsigned int flags = 0;
 
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 1a3b105..6d8c4cb 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -386,8 +386,9 @@ static int __init early_init_dt_scan_cpus(unsigned long 
node,
return 0;
 }
 
-int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname,
-int depth, void *data)
+static int __init early_init_dt_scan_chosen_ppc(unsigned long node,
+   const char *uname,
+   int depth, void *data)
 {
const unsigned long *lprop; /* All these set by kernel, so no need to 
convert endian */
 
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 2e3d2bf..cdb404e 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -932,7 +932,7 @@ void ptrace_triggered(struct perf_event *bp,
 }
 #endif /* CONFIG_HAVE_HW_BREAKPOINT */
 
-int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
+static int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
   unsigned long data)
 {
 #ifdef CONFIG_HAVE_HW_BREAKPOINT
diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c
index e736387..5a2c049 100644
--- a/arch/powerpc/kernel/rtasd.c
+++ b/arch/powerpc/kernel/rtasd.c
@@ -286,7 +286,7 @@ static void prrn_work_fn(struct work_struct *work)
 
 static DECLARE_WORK(prrn_work, prrn_work_fn);
 
-void prrn_schedule_update(u32 scope)
+static void prrn_schedule_update(u32 scope)
 {
flush_work(prrn_work);
prrn_update_scope = scope;
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 368ab37..f6b3430 100644

[PATCH 2/4] powerpc: Ensure global functions include their prototype

2014-08-19 Thread Anton Blanchard
Fix a number of places where global functions were not including
their prototype. This ensures the prototype and the function match.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/kernel/smp.c   | 1 +
 arch/powerpc/mm/slice.c | 2 ++
 arch/powerpc/oprofile/backtrace.c   | 1 +
 arch/powerpc/platforms/powernv/subcore.c| 1 +
 arch/powerpc/platforms/pseries/dlpar.c  | 1 +
 arch/powerpc/platforms/pseries/hotplug-memory.c | 1 +
 arch/powerpc/platforms/pseries/pci.c| 1 +
 7 files changed, 8 insertions(+)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index a0738af..4866d5d 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -52,6 +52,7 @@
 #endif
 #include asm/vdso.h
 #include asm/debug.h
+#include asm/kexec.h
 
 #ifdef DEBUG
 #include asm/udbg.h
diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
index b0c75cc..86f6a75 100644
--- a/arch/powerpc/mm/slice.c
+++ b/arch/powerpc/mm/slice.c
@@ -30,9 +30,11 @@
 #include linux/err.h
 #include linux/spinlock.h
 #include linux/export.h
+#include linux/hugetlb.h
 #include asm/mman.h
 #include asm/mmu.h
 #include asm/spu.h
+#include asm/hugetlb.h
 
 /* some sanity checks */
 #if (PGTABLE_RANGE  43)  SLICE_MASK_SIZE
diff --git a/arch/powerpc/oprofile/backtrace.c 
b/arch/powerpc/oprofile/backtrace.c
index f75301f..6adf55f 100644
--- a/arch/powerpc/oprofile/backtrace.c
+++ b/arch/powerpc/oprofile/backtrace.c
@@ -12,6 +12,7 @@
 #include asm/processor.h
 #include asm/uaccess.h
 #include asm/compat.h
+#include asm/oprofile_impl.h
 
 #define STACK_SP(STACK)*(STACK)
 
diff --git a/arch/powerpc/platforms/powernv/subcore.c 
b/arch/powerpc/platforms/powernv/subcore.c
index 894ecb3..c87f96b 100644
--- a/arch/powerpc/platforms/powernv/subcore.c
+++ b/arch/powerpc/platforms/powernv/subcore.c
@@ -24,6 +24,7 @@
 #include asm/smp.h
 
 #include subcore.h
+#include powernv.h
 
 
 /*
diff --git a/arch/powerpc/platforms/pseries/dlpar.c 
b/arch/powerpc/platforms/pseries/dlpar.c
index d37ba4f..86f3136 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -17,6 +17,7 @@
 #include linux/slab.h
 #include linux/of.h
 #include offline_states.h
+#include pseries.h
 
 #include asm/prom.h
 #include asm/machdep.h
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c 
b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 24abc5c..6169497 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -20,6 +20,7 @@
 #include asm/machdep.h
 #include asm/prom.h
 #include asm/sparsemem.h
+#include pseries.h
 
 unsigned long pseries_memory_block_size(void)
 {
diff --git a/arch/powerpc/platforms/pseries/pci.c 
b/arch/powerpc/platforms/pseries/pci.c
index c413ec1..67e4859 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -29,6 +29,7 @@
 #include asm/pci-bridge.h
 #include asm/prom.h
 #include asm/ppc-pci.h
+#include pseries.h
 
 #if 0
 void pcibios_name_device(struct pci_dev *dev)
-- 
1.9.1

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

[PATCH 4/4] powerpc: Move htab_remove_mapping function prototype into header file

2014-08-19 Thread Anton Blanchard
A recent patch added a function prototype for htab_remove_mapping in
c code. Fix it.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/mmu-hash64.h | 2 ++
 arch/powerpc/mm/init_64.c | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/mmu-hash64.h 
b/arch/powerpc/include/asm/mmu-hash64.h
index d765144..92bc3a6 100644
--- a/arch/powerpc/include/asm/mmu-hash64.h
+++ b/arch/powerpc/include/asm/mmu-hash64.h
@@ -342,6 +342,8 @@ extern void hash_failure_debug(unsigned long ea, unsigned 
long access,
 extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
 unsigned long pstart, unsigned long prot,
 int psize, int ssize);
+int htab_remove_mapping(unsigned long vstart, unsigned long vend,
+   int psize, int ssize);
 extern void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages);
 extern void demote_segment_4k(struct mm_struct *mm, unsigned long addr);
 
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 253b4b9..3481556 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -233,9 +233,6 @@ static void __meminit vmemmap_create_mapping(unsigned long 
start,
 }
 
 #ifdef CONFIG_MEMORY_HOTPLUG
-extern int htab_remove_mapping(unsigned long vstart, unsigned long vend,
-   int psize, int ssize);
-
 static void vmemmap_remove_mapping(unsigned long start,
   unsigned long page_size)
 {
-- 
1.9.1

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

[PATCH 3/4] powerpc: Remove stale function prototypes

2014-08-19 Thread Anton Blanchard
There were a number of prototypes for functions that no longer
exist. Remove them.

Signed-off-by: Anton Blanchard an...@samba.org
---
 arch/powerpc/include/asm/bug.h   | 1 -
 arch/powerpc/include/asm/hydra.h | 1 -
 arch/powerpc/include/asm/irq.h   | 5 -
 arch/powerpc/include/asm/kexec.h | 1 -
 arch/powerpc/include/asm/page_64.h   | 1 -
 arch/powerpc/include/asm/pgtable-ppc32.h | 2 --
 arch/powerpc/include/asm/prom.h  | 2 --
 arch/powerpc/include/asm/rio.h   | 1 -
 arch/powerpc/include/asm/tsi108.h| 4 
 arch/powerpc/include/asm/udbg.h  | 1 -
 arch/powerpc/platforms/pseries/lpar.c| 2 --
 11 files changed, 21 deletions(-)

diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index 3eb53d7..3a39283 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -133,7 +133,6 @@ extern int do_page_fault(struct pt_regs *, unsigned long, 
unsigned long);
 extern void bad_page_fault(struct pt_regs *, unsigned long, int);
 extern void _exception(int, struct pt_regs *, int, unsigned long);
 extern void die(const char *, struct pt_regs *, long);
-extern void print_backtrace(unsigned long *);
 
 #endif /* !__ASSEMBLY__ */
 
diff --git a/arch/powerpc/include/asm/hydra.h b/arch/powerpc/include/asm/hydra.h
index 5b0c98bd..1cb39c9 100644
--- a/arch/powerpc/include/asm/hydra.h
+++ b/arch/powerpc/include/asm/hydra.h
@@ -95,7 +95,6 @@ extern volatile struct Hydra __iomem *Hydra;
 #define HYDRA_INT_SPARE19
 
 extern int hydra_init(void);
-extern void macio_adb_init(void);
 
 #endif /* __KERNEL__ */
 
diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index 41f13ce..e8e3a0a 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -31,11 +31,6 @@ extern atomic_t ppc_n_lost_interrupts;
 
 extern irq_hw_number_t virq_to_hw(unsigned int virq);
 
-/**
- * irq_early_init - Init irq remapping subsystem
- */
-extern void irq_early_init(void);
-
 static __inline__ int irq_canonicalize(int irq)
 {
return irq;
diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 16d7e33..19c36cb 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -81,7 +81,6 @@ extern void default_machine_crash_shutdown(struct pt_regs 
*regs);
 extern int crash_shutdown_register(crash_shutdown_t handler);
 extern int crash_shutdown_unregister(crash_shutdown_t handler);
 
-extern void machine_kexec_simple(struct kimage *image);
 extern void crash_kexec_secondary(struct pt_regs *regs);
 extern int overlaps_crashkernel(unsigned long start, unsigned long size);
 extern void reserve_crashkernel(void);
diff --git a/arch/powerpc/include/asm/page_64.h 
b/arch/powerpc/include/asm/page_64.h
index 88693ce..d0d6afb 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -104,7 +104,6 @@ extern unsigned long slice_get_unmapped_area(unsigned long 
addr,
 extern unsigned int get_slice_psize(struct mm_struct *mm,
unsigned long addr);
 
-extern void slice_init_context(struct mm_struct *mm, unsigned int psize);
 extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize);
 extern void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
  unsigned long len, unsigned int psize);
diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h 
b/arch/powerpc/include/asm/pgtable-ppc32.h
index 47edde8..622672f 100644
--- a/arch/powerpc/include/asm/pgtable-ppc32.h
+++ b/arch/powerpc/include/asm/pgtable-ppc32.h
@@ -8,8 +8,6 @@
 #include linux/threads.h
 #include asm/io.h/* For sub-arch specific PPC_PIN_SIZE */
 
-extern unsigned long va_to_phys(unsigned long address);
-extern pte_t *va_to_pte(unsigned long address);
 extern unsigned long ioremap_bot;
 
 #ifdef CONFIG_44x
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 74b79f0..7f436ba 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -76,8 +76,6 @@ void of_parse_dma_window(struct device_node *dn, const __be32 
*dma_window,
 unsigned long *busno, unsigned long *phys,
 unsigned long *size);
 
-extern void kdump_move_device_tree(void);
-
 extern void of_instantiate_rtc(void);
 
 extern int of_get_ibm_chip_id(struct device_node *np);
diff --git a/arch/powerpc/include/asm/rio.h b/arch/powerpc/include/asm/rio.h
index b1d2dec..ec800f2 100644
--- a/arch/powerpc/include/asm/rio.h
+++ b/arch/powerpc/include/asm/rio.h
@@ -13,7 +13,6 @@
 #ifndef ASM_PPC_RIO_H
 #define ASM_PPC_RIO_H
 
-extern void platform_rio_init(void);
 #ifdef CONFIG_FSL_RIO
 extern int fsl_rio_mcheck_exception(struct pt_regs *);
 #else
diff --git a/arch/powerpc/include/asm/tsi108.h 
b/arch/powerpc/include/asm/tsi108.h
index f8b6079..d531d9e 100644
--- a/arch

[PATCH 2/2] powerpc: Add ppc64 hard lockup detector support

2014-08-11 Thread Anton Blanchard
The hard lockup detector uses a PMU event as a periodic NMI to
detect if we are stuck (where stuck means no timer interrupts have
occurred).

Ben's rework of the ppc64 soft disable code has made ppc64 PMU
exceptions a partial NMI. They can get disabled if an external interrupt
comes in, but otherwise PMU interrupts will fire in interrupt disabled
regions.

I wrote a kernel module to test this patch and noticed we sometimes
missed hard lockup warnings. The RCU code detected the stall first and
issued an IPI to backtrace all CPUs. Unfortunately an IPI is an external
interrupt and that will hard disable interrupts, preventing the hard
lockup detector from going off.

If I reduced the hard lockup threshold to 5 seconds:

echo 5  /proc/sys/kernel/watchdog_thresh

Then it would beat the RCU code in detecting a stall and get a
correct backtrace out.

Another downside is that our PMCs can only count to 2^31, so even when
we ask for 10 seconds of processor cycles, we end up taking a couple
of PMU exceptions a second.

Signed-off-by: Anton Blanchard an...@samba.org
---

v2: Mikey noticed a build issue with oprofile. Since our NMI is just
the PMU hardware it doesn't make any sense for oprofile to try and
use it.

Index: b/arch/powerpc/Kconfig
===
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -145,6 +145,7 @@ config PPC
select HAVE_IRQ_EXIT_ON_IRQ_STACK
select ARCH_USE_CMPXCHG_LOCKREF if PPC64
select HAVE_ARCH_AUDITSYSCALL
+   select HAVE_PERF_EVENTS_NMI if PPC64
 
 config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
Index: b/arch/powerpc/include/asm/nmi.h
===
--- /dev/null
+++ b/arch/powerpc/include/asm/nmi.h
@@ -0,0 +1,4 @@
+#ifndef _ASM_NMI_H
+#define _ASM_NMI_H
+
+#endif /* _ASM_NMI_H */
Index: b/arch/powerpc/kernel/setup_64.c
===
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -800,3 +800,10 @@ unsigned long memory_block_size_bytes(vo
 struct ppc_pci_io ppc_pci_io;
 EXPORT_SYMBOL(ppc_pci_io);
 #endif
+
+#ifdef CONFIG_HARDLOCKUP_DETECTOR
+u64 hw_nmi_get_sample_period(int watchdog_thresh)
+{
+   return ppc_proc_freq * watchdog_thresh;
+}
+#endif
Index: b/arch/Kconfig
===
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -32,7 +32,7 @@ config HAVE_OPROFILE
 
 config OPROFILE_NMI_TIMER
def_bool y
-   depends on PERF_EVENTS  HAVE_PERF_EVENTS_NMI
+   depends on (PERF_EVENTS  HAVE_PERF_EVENTS_NMI)  !PPC
 
 config KPROBES
bool Kprobes

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

[PATCH] powerpc: Remove ppc_md.remove_memory

2014-08-07 Thread Anton Blanchard
We have an extra level of indirection on memory hot remove which is not
matched on memory hot add. Memory hotplug is book3s only, so there is
no need for it.

This also enables means remove_memory() (ie memory hot unplug) works
on powernv.

Signed-off-by: Anton Blanchard an...@samba.org
---

Index: b/arch/powerpc/include/asm/machdep.h
===
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -294,10 +294,6 @@ struct machdep_calls {
 #ifdef CONFIG_ARCH_RANDOM
int (*get_random_long)(unsigned long *v);
 #endif
-
-#ifdef CONFIG_MEMORY_HOTREMOVE
-   int (*remove_memory)(u64, u64);
-#endif
 };
 
 extern void e500_idle(void);
Index: b/arch/powerpc/mm/mem.c
===
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -35,6 +35,7 @@
 #include linux/memblock.h
 #include linux/hugetlb.h
 #include linux/slab.h
+#include linux/vmalloc.h
 
 #include asm/pgalloc.h
 #include asm/prom.h
@@ -143,8 +144,15 @@ int arch_remove_memory(u64 start, u64 si
 
zone = page_zone(pfn_to_page(start_pfn));
ret = __remove_pages(zone, start_pfn, nr_pages);
-   if (!ret  (ppc_md.remove_memory))
-   ret = ppc_md.remove_memory(start, size);
+
+   start = (unsigned long)__va(start);
+   if (!ret)
+   ret = remove_section_mapping(start, start + size);
+
+   /* Ensure all vmalloc mappings are flushed in case they also
+* hit that section of memory
+*/
+   vm_unmap_aliases();
 
return ret;
 }
Index: b/arch/powerpc/platforms/pseries/hotplug-memory.c
===
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -12,7 +12,6 @@
 #include linux/of.h
 #include linux/of_address.h
 #include linux/memblock.h
-#include linux/vmalloc.h
 #include linux/memory.h
 #include linux/memory_hotplug.h
 
@@ -65,22 +64,6 @@ unsigned long pseries_memory_block_size(
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-static int pseries_remove_memory(u64 start, u64 size)
-{
-   int ret;
-
-   /* Remove htab bolted mappings for this section of memory */
-   start = (unsigned long)__va(start);
-   ret = remove_section_mapping(start, start + size);
-
-   /* Ensure all vmalloc mappings are flushed in case they also
-* hit that section of memory
-*/
-   vm_unmap_aliases();
-
-   return ret;
-}
-
 static int pseries_remove_memblock(unsigned long base, unsigned int 
memblock_size)
 {
unsigned long block_sz, start_pfn;
@@ -259,10 +242,6 @@ static int __init pseries_memory_hotplug
if (firmware_has_feature(FW_FEATURE_LPAR))
of_reconfig_notifier_register(pseries_mem_nb);
 
-#ifdef CONFIG_MEMORY_HOTREMOVE
-   ppc_md.remove_memory = pseries_remove_memory;
-#endif
-
return 0;
 }
 machine_device_initcall(pseries, pseries_memory_hotplug_init);
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc: Move htab_remove_mapping function prototype into header file

2014-08-07 Thread Anton Blanchard
A recent patch added a function prototype for htab_remove_mapping in
c code. Fix it.

Signed-off-by: Anton Blanchard an...@samba.org
---

diff --git a/arch/powerpc/include/asm/mmu-hash64.h 
b/arch/powerpc/include/asm/mmu-hash64.h
index d765144..92bc3a6 100644
--- a/arch/powerpc/include/asm/mmu-hash64.h
+++ b/arch/powerpc/include/asm/mmu-hash64.h
@@ -342,6 +342,8 @@ extern void hash_failure_debug(unsigned long ea, unsigned 
long access,
 extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
 unsigned long pstart, unsigned long prot,
 int psize, int ssize);
+int htab_remove_mapping(unsigned long vstart, unsigned long vend,
+   int psize, int ssize);
 extern void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages);
 extern void demote_segment_4k(struct mm_struct *mm, unsigned long addr);
 
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 253b4b9..3481556 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -233,9 +233,6 @@ static void __meminit vmemmap_create_mapping(unsigned long 
start,
 }
 
 #ifdef CONFIG_MEMORY_HOTPLUG
-extern int htab_remove_mapping(unsigned long vstart, unsigned long vend,
-   int psize, int ssize);
-
 static void vmemmap_remove_mapping(unsigned long start,
   unsigned long page_size)
 {
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 1/5] powerpc: Remove bootmem allocator

2014-08-05 Thread Anton Blanchard
At the moment we transition from the memblock alloctor to the bootmem
allocator. Removing the bootmem allocator removes a bunch of complicated
code (most of which I owe the dubious honour of being responsible for
writing).

Signed-off-by: Anton Blanchard an...@samba.org
---

Index: b/arch/powerpc/Kconfig
===
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -145,6 +145,7 @@ config PPC
select HAVE_IRQ_EXIT_ON_IRQ_STACK
select ARCH_USE_CMPXCHG_LOCKREF if PPC64
select HAVE_ARCH_AUDITSYSCALL
+   select NO_BOOTMEM
 
 config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
Index: b/arch/powerpc/include/asm/setup.h
===
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -8,7 +8,6 @@ extern void ppc_printk_progress(char *s,
 
 extern unsigned int rtas_data;
 extern int mem_init_done;  /* set on boot once kmalloc can be called */
-extern int init_bootmem_done;  /* set once bootmem is available */
 extern unsigned long long memory_limit;
 extern unsigned long klimit;
 extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
@@ -24,7 +23,7 @@ extern void reloc_got2(unsigned long);
 #define PTRRELOC(x)((typeof(x)) add_reloc_offset((unsigned long)(x)))
 
 void check_for_initrd(void);
-void do_init_bootmem(void);
+void initmem_init(void);
 void setup_panic(void);
 #define ARCH_PANIC_TIMEOUT 180
 
Index: b/arch/powerpc/kernel/setup_32.c
===
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -311,9 +311,8 @@ void __init setup_arch(char **cmdline_p)
 
irqstack_early_init();
 
-   /* set up the bootmem stuff with available memory */
-   do_init_bootmem();
-   if ( ppc_md.progress ) ppc_md.progress(setup_arch: bootmem, 0x3eab);
+   initmem_init();
+   if ( ppc_md.progress ) ppc_md.progress(setup_arch: initmem, 0x3eab);
 
 #ifdef CONFIG_DUMMY_CONSOLE
conswitchp = dummy_con;
Index: b/arch/powerpc/kernel/setup_64.c
===
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -677,8 +677,7 @@ void __init setup_arch(char **cmdline_p)
exc_lvl_early_init();
emergency_stack_init();
 
-   /* set up the bootmem stuff with available memory */
-   do_init_bootmem();
+   initmem_init();
sparse_init();
 
 #ifdef CONFIG_DUMMY_CONSOLE
Index: b/arch/powerpc/mm/init_32.c
===
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -195,15 +195,6 @@ void __init MMU_init(void)
memblock_set_current_limit(lowmem_end_addr);
 }
 
-/* This is only called until mem_init is done. */
-void __init *early_get_page(void)
-{
-   if (init_bootmem_done)
-   return alloc_bootmem_pages(PAGE_SIZE);
-   else
-   return __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
-}
-
 #ifdef CONFIG_8xx /* No 8xx specific .c file to put that in ... */
 void setup_initial_memory_limit(phys_addr_t first_memblock_base,
phys_addr_t first_memblock_size)
Index: b/arch/powerpc/mm/mem.c
===
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -60,7 +60,6 @@
 #define CPU_FTR_NOEXECUTE  0
 #endif
 
-int init_bootmem_done;
 int mem_init_done;
 unsigned long long memory_limit;
 
@@ -179,70 +178,22 @@ walk_system_ram_range(unsigned long star
 }
 EXPORT_SYMBOL_GPL(walk_system_ram_range);
 
-/*
- * Initialize the bootmem system and give it all the memory we
- * have available.  If we are using highmem, we only put the
- * lowmem into the bootmem system.
- */
 #ifndef CONFIG_NEED_MULTIPLE_NODES
-void __init do_init_bootmem(void)
+void __init initmem_init(void)
 {
-   unsigned long start, bootmap_pages;
-   unsigned long total_pages;
-   struct memblock_region *reg;
-   int boot_mapsize;
-
max_low_pfn = max_pfn = memblock_end_of_DRAM()  PAGE_SHIFT;
-   total_pages = (memblock_end_of_DRAM() - memstart_addr)  PAGE_SHIFT;
+   min_low_pfn = MEMORY_START  PAGE_SHIFT;
 #ifdef CONFIG_HIGHMEM
-   total_pages = total_lowmem  PAGE_SHIFT;
max_low_pfn = lowmem_end_addr  PAGE_SHIFT;
 #endif
 
-   /*
-* Find an area to use for the bootmem bitmap.  Calculate the size of
-* bitmap required as (Total Memory) / PAGE_SIZE / BITS_PER_BYTE.
-* Add 1 additional page in case the address isn't page-aligned.
-*/
-   bootmap_pages = bootmem_bootmap_pages(total_pages);
-
-   start = memblock_alloc(bootmap_pages  PAGE_SHIFT, PAGE_SIZE);
-
-   min_low_pfn = MEMORY_START  PAGE_SHIFT;
-   boot_mapsize = init_bootmem_node(NODE_DATA(0), start  PAGE_SHIFT, 
min_low_pfn

[PATCH 2/5] powerpc: Remove some old bootmem related comments

2014-08-05 Thread Anton Blanchard
Now bootmem is gone from powerpc we can remove comments mentioning it.

Signed-off-by: Anton Blanchard an...@samba.org
---

Index: b/arch/powerpc/kernel/prom.c
===
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -695,10 +695,7 @@ void __init early_init_devtree(void *par
reserve_crashkernel();
early_reserve_mem();
 
-   /*
-* Ensure that total memory size is page-aligned, because otherwise
-* mark_bootmem() gets upset.
-*/
+   /* Ensure that total memory size is page-aligned. */
limit = ALIGN(memory_limit ?: memblock_phys_mem_size(), PAGE_SIZE);
memblock_enforce_memory_limit(limit);
 
Index: b/arch/powerpc/kernel/rtas.c
===
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -1091,8 +1091,8 @@ asmlinkage int ppc_rtas(struct rtas_args
 }
 
 /*
- * Call early during boot, before mem init or bootmem, to retrieve the RTAS
- * informations from the device-tree and allocate the RMO buffer for userland
+ * Call early during boot, before mem init, to retrieve the RTAS
+ * information from the device-tree and allocate the RMO buffer for userland
  * accesses.
  */
 void __init rtas_initialize(void)
Index: b/arch/powerpc/mm/pgtable_64.c
===
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -106,10 +106,6 @@ int map_kernel_page(unsigned long ea, un
  __pgprot(flags)));
} else {
 #ifdef CONFIG_PPC_MMU_NOHASH
-   /* Warning ! This will blow up if bootmem is not initialized
-* which our ppc64 code is keen to do that, we'll need to
-* fix it and/or be more careful
-*/
pgdp = pgd_offset_k(ea);
 #ifdef PUD_TABLE_SIZE
if (pgd_none(*pgdp)) {
Index: b/arch/powerpc/kvm/book3s_hv_builtin.c
===
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -148,7 +148,7 @@ EXPORT_SYMBOL_GPL(kvm_release_hpt);
  * kvm_cma_reserve() - reserve area for kvm hash pagetable
  *
  * This function reserves memory from early allocator. It should be
- * called by arch specific code once the early allocator (memblock or bootmem)
+ * called by arch specific code once the memblock allocator
  * has been activated and all other subsystems have already allocated/reserved
  * memory.
  */
Index: b/arch/powerpc/kvm/book3s_hv_cma.c
===
--- a/arch/powerpc/kvm/book3s_hv_cma.c
+++ b/arch/powerpc/kvm/book3s_hv_cma.c
@@ -42,7 +42,7 @@ static struct kvm_cma kvm_cma_area;
  * @alignment:  Alignment for the contiguous memory area
  *
  * This function reserves memory for kvm cma area. It should be
- * called by arch code when early allocator (memblock or bootmem)
+ * called by arch code when the memblock allocator
  * is still activate.
  */
 long __init kvm_cma_declare_contiguous(phys_addr_t size, phys_addr_t alignment)
Index: b/arch/powerpc/mm/hugetlbpage.c
===
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -276,7 +276,7 @@ pte_t *huge_pte_alloc(struct mm_struct *
 
 #ifdef CONFIG_PPC_FSL_BOOK3E
 /* Build list of addresses of gigantic pages.  This function is used in early
- * boot before the buddy or bootmem allocator is setup.
+ * boot before the buddy allocator is setup.
  */
 void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages)
 {
@@ -399,7 +399,7 @@ void __init reserve_hugetlb_gpages(void)
 #else /* !PPC_FSL_BOOK3E */
 
 /* Build list of addresses of gigantic pages.  This function is used in early
- * boot before the buddy or bootmem allocator is setup.
+ * boot before the buddy allocator is setup.
  */
 void add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages)
 {
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

<    1   2   3   4   5   6   7   8   9   10   >