firefly-linux-kernel-4.4.55.git
12 years agopowerpc: Fix wrong divisor in usecs_to_cputime
Andreas Schwab [Fri, 9 Dec 2011 11:35:08 +0000 (11:35 +0000)]
powerpc: Fix wrong divisor in usecs_to_cputime

Commit d57af9b (taskstats: use real microsecond granularity for CPU times)
renamed msecs_to_cputime to usecs_to_cputime, but failed to update all
numbers on the way.  This causes nonsensical cpu idle/iowait values to be
displayed in /proc/stat (the only user of usecs_to_cputime so far).

This also renames __cputime_msec_factor to __cputime_usec_factor, adapting
its value and using it directly in cputime_to_usecs instead of doing two
multiplications.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Acked-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mm: Fix section mismatch for read_n_cells
David Rientjes [Thu, 8 Dec 2011 12:46:37 +0000 (12:46 +0000)]
powerpc/mm: Fix section mismatch for read_n_cells

read_n_cells() cannot be marked as .devinit.text since it is referenced
from two functions that are not in that section: of_get_lmb_size() and
hot_add_drconf_scn_to_nid().

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mm: Fix section mismatch for mark_reserved_regions_for_nid
David Rientjes [Thu, 8 Dec 2011 12:33:29 +0000 (12:33 +0000)]
powerpc/mm: Fix section mismatch for mark_reserved_regions_for_nid

mark_reserved_regions_for_nid() is only called from do_init_bootmem(),
which is in .init.text, so it must be in the same section to avoid a
section mismatch warning.

Reported-by: Subrata Modak <subrata@linux.vnet.ibm.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Add __SANE_USERSPACE_TYPES__ to asm/types.h for LL64
Matt Evans [Wed, 7 Dec 2011 20:57:09 +0000 (20:57 +0000)]
powerpc: Add __SANE_USERSPACE_TYPES__ to asm/types.h for LL64

PPC64 uses long long for u64 in the kernel, but powerpc's asm/types.h
prevents 64-bit userland from seeing this definition, instead defaulting
to u64 == long in userspace.  Some user programs (e.g. kvmtool) may actually
want LL64, so this patch adds a check for __SANE_USERSPACE_TYPES__ so that,
if defined, int-ll64.h is included instead.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: POWER7 optimised copy_to_user/copy_from_user using VMX
Anton Blanchard [Wed, 7 Dec 2011 20:11:45 +0000 (20:11 +0000)]
powerpc: POWER7 optimised copy_to_user/copy_from_user using VMX

Implement a POWER7 optimised copy_to_user/copy_from_user using VMX.
For large aligned copies this new loop is over 10% faster, and for
large unaligned copies it is over 200% faster.

If we take a fault we fall back to the old version, this keeps
things relatively simple and easy to verify.

On POWER7 unaligned stores rarely slow down - they only flush when
a store crosses a 4KB page boundary. Furthermore this flush is
handled completely in hardware and should be 20-30 cycles.

Unaligned loads on the other hand flush much more often - whenever
crossing a 128 byte cache line, or a 32 byte sector if either sector
is an L1 miss.

Considering this information we really want to get the loads aligned
and not worry about the alignment of the stores. Microbenchmarks
confirm that this approach is much faster than the current unaligned
copy loop that uses shifts and rotates to ensure both loads and
stores are aligned.

We also want to try and do the stores in cacheline aligned, cacheline
sized chunks. If the store queue is unable to merge an entire
cacheline of stores then the L2 cache will have to do a
read/modify/write. Even worse, we will serialise this with the stores
in the next iteration of the copy loop since both iterations hit
the same cacheline.

Based on this, the new loop does the following things:

1 - 127 bytes
Get the source 8 byte aligned and use 8 byte loads and stores. Pretty
boring and similar to how the current loop works.

128 - 4095 bytes
Get the source 8 byte aligned and use 8 byte loads and stores,
1 cacheline at a time. We aren't doing the stores in cacheline
aligned chunks so we will potentially serialise once per cacheline.
Even so it is much better than the loop we have today.

4096 - bytes
If both source and destination have the same alignment get them both
16 byte aligned, then get the destination cacheline aligned. Do
cacheline sized loads and stores using VMX.

If source and destination do not have the same alignment, we get the
destination cacheline aligned, and use permute to do aligned loads.

In both cases the VMX loop should be optimal - we always do aligned
loads and stores and are always doing stores in cacheline aligned,
cacheline sized chunks.

To be able to use VMX we must be careful about interrupts and
sleeping. We don't use the VMX loop when in an interrupt (which should
be rare anyway) and we wrap the VMX loop in disable/enable_pagefault
and fall back to the existing copy_tofrom_user loop if we do need to
sleep.

The VMX breakpoint of 4096 bytes was chosen using this microbenchmark:

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

Since we are using VMX and there is a cost to saving and restoring
the user VMX state there are two broad cases we need to benchmark:

- Best case - userspace never uses VMX

- Worst case - userspace always uses VMX

In reality a userspace process will sit somewhere between these two
extremes. Since we need to test both aligned and unaligned copies we
end up with 4 combinations. The point at which the VMX loop begins to
win is:

0% VMX
aligned 2048 bytes
unaligned 2048 bytes

100% VMX
aligned 16384 bytes
unaligned 8192 bytes

Considering this is a microbenchmark, the data is hot in cache and
the VMX loop has better store queue merging properties we set the
breakpoint to 4096 bytes, a little below the unaligned breakpoints.

Some future optimisations we can look at:

- Looking at the perf data, a significant part of the cost when a
  task is always using VMX is the extra exception we take to restore
  the VMX state. As such we should do something similar to the x86
  optimisation that restores FPU state for heavy users. ie:

        /*
         * If the task has used fpu the last 5 timeslices, just do a full
         * restore of the math state immediately to avoid the trap; the
         * chances of needing FPU soon are obviously high now
         */
        preload_fpu = tsk_used_math(next_p) && next_p->fpu_counter > 5;

  and

        /*
         * fpu_counter contains the number of consecutive context switches
         * that the FPU is used. If this is over a threshold, the lazy fpu
         * saving becomes unlazy to save the trap. This is an unsigned char
         * so that after 256 times the counter wraps and the behavior turns
         * lazy again; this to deal with bursty apps that only use FPU for
         * a short time
         */

- We could create a paca bit to mirror the VMX enabled MSR bit and check
  that first, avoiding multiple calls to calling enable_kernel_altivec.
  That should help with iovec based system calls like readv.

- We could have two VMX breakpoints, one for when we know the user VMX
  state is loaded into the registers and one when it isn't. This could
  be a second bit in the paca so we can calculate the break points quickly.

- One suggestion from Ben was to save and restore the VSX registers
  we use inline instead of using enable_kernel_altivec.

[BenH: Fixed a problem with preempt and fixed build without CONFIG_ALTIVEC]

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Use rwsem.h from generic location
Richard Kuo [Tue, 29 Nov 2011 08:28:20 +0000 (08:28 +0000)]
powerpc: Use rwsem.h from generic location

As of commit dd472da38, rwsem.h was moved into asm-generic.
This patch removes the arch file and points the build at
its new location.

Signed-off-by: Richard Kuo <rkuo@codeaurora.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agoMerge remote-tracking branch 'jwb/next' into next
Benjamin Herrenschmidt [Fri, 16 Dec 2011 00:24:25 +0000 (11:24 +1100)]
Merge remote-tracking branch 'jwb/next' into next

Conflicts:
arch/powerpc/platforms/40x/ppc40x_simple.c

12 years agopowerpc/pmac: Fix SMP kernels on pre-core99 UP machines
Benjamin Herrenschmidt [Fri, 9 Dec 2011 04:06:18 +0000 (15:06 +1100)]
powerpc/pmac: Fix SMP kernels on pre-core99 UP machines

The code for "powersurge" SMP would kick in and cause a crash
at boot due to the lack of a NULL test.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/pmac: Simplify old pmac PIC interrupt handling
Benjamin Herrenschmidt [Sun, 11 Dec 2011 23:27:41 +0000 (10:27 +1100)]
powerpc/pmac: Simplify old pmac PIC interrupt handling

In the old days, we treated all interrupts from the legacy Apple home made
interrupt controllers as level, with a trick reading the "level" register
along with the "event" register to work arounds bugs where it would
occasionally fail to latch some events.

Doing so appeared to work fine for both level and edge interrupts.

Later on, we discovered in Darwin source the magic masks that define which
interrupts are actually level and which are edge, and implemented a
different algorithm, more similar to what Apple does, that treats those
differently.

I recently discovered however that this caused problems (including loss
of interrupts) with an old Wallstreet PowerBook when trying to use the
internal modem (connected to a cascaded controller).

It looks like some interrupts are treated as edge while they are really
level and I'm starting to seriously doubt the correctness of the Darwin
code (which has other obvious bugs when you read it, so ...)

This patch reverts to our original behaviour of treating everything as
a level interrupt. It appears to solve the problems with the modem on
the Wallstreet and everything else seems to be working properly as well.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agotty/serial/pmac_zilog: Fix suspend & resume
Benjamin Herrenschmidt [Thu, 15 Dec 2011 00:13:03 +0000 (11:13 +1100)]
tty/serial/pmac_zilog: Fix suspend & resume

This patch reworks & simplifies pmac_zilog handling of suspend/resume,
essentially removing all the specific code in there and using the
generic uart helpers.

This required properly registering the tty as a child of the macio (or platform)
device, so I had to delay the registration a bit (we used to register the ports
very very early). We still register the kernel console early though.

I removed a couple of unused or useless flags as well, relying on the
core to not call us when asleep. I also removed the essentially useless
interrupt mutex, simplifying the locking a bit.

I removed some code for handling unexpected interrupt which should never
be hit and could potentially be harmful (causing us to access a register
on a powered off SCC). We diable port interrupts on close always so there
should be no need to drain data on a closed port.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agoMerge branch 'kexec' into next
Benjamin Herrenschmidt [Fri, 16 Dec 2011 00:09:21 +0000 (11:09 +1100)]
Merge branch 'kexec' into next

12 years agoMerge branch 'ps3' into next
Benjamin Herrenschmidt [Fri, 16 Dec 2011 00:09:15 +0000 (11:09 +1100)]
Merge branch 'ps3' into next

12 years agoMerge branch 'cpuidle' into next
Benjamin Herrenschmidt [Fri, 16 Dec 2011 00:09:11 +0000 (11:09 +1100)]
Merge branch 'cpuidle' into next

12 years agopowerpc/47x: Add support for the new IBM currituck platform
Tony Breeds [Wed, 30 Nov 2011 21:39:24 +0000 (21:39 +0000)]
powerpc/47x: Add support for the new IBM currituck platform

Based on original work by David 'Shaggy' Kleikamp.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc/476fpe: Add 476fpe SoC code
Tony Breeds [Wed, 30 Nov 2011 21:39:23 +0000 (21:39 +0000)]
powerpc/476fpe: Add 476fpe SoC code

Based on original work by David 'Shaggy' Kleikamp.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc/boot: Add mfdcrx
Tony Breeds [Wed, 30 Nov 2011 21:39:22 +0000 (21:39 +0000)]
powerpc/boot: Add mfdcrx

Needed for currituck support.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc/boot: Add extended precision shifts to the boot wrapper.
Tony Breeds [Wed, 30 Nov 2011 21:39:21 +0000 (21:39 +0000)]
powerpc/boot: Add extended precision shifts to the boot wrapper.

The upcomming currituck patches will need to do 64-bit shifts which will
fail with undefined symbol without this patch.

I looked at linking against libgcc but we can't guarantee that libgcc
was compiled with soft-float.  Also Using ../lib/div64.S or
../kernel/misc_32.S, this will break the build as the .o's need to be
built with different flags for the bootwrapper vs the kernel.  So for
now the easyest option is to just copy code from
arch/powerpc/kernel/misc_32.S  I don't think this code changes too often ;P

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc/44x: Removing dead CONFIG_PPC47x
Christoph Egger [Wed, 30 Nov 2011 21:39:20 +0000 (21:39 +0000)]
powerpc/44x: Removing dead CONFIG_PPC47x

CONFIG_PPC47x doesn't exist in Kconfig and no 476 processor calls this
function ppc44x_pin_tlb() as it has it's own ppc47x_pin_tlb().

This code is probably an artifact of the original 476 code that
shouldn't have made it upstream.

Signed-off-by: Christoph Egger <siccegge@cs.fau.de>
Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc/44x: pci: Setup the dma_window properties for each pci_controller
Tony Breeds [Wed, 30 Nov 2011 21:39:19 +0000 (21:39 +0000)]
powerpc/44x: pci: Setup the dma_window properties for each pci_controller

Needed if you want to use swiotlb, harmless otherwise.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc/44x: pci: Add a want_sdr flag into ppc4xx_pciex_hwops
Tony Breeds [Wed, 30 Nov 2011 21:39:18 +0000 (21:39 +0000)]
powerpc/44x: pci: Add a want_sdr flag into ppc4xx_pciex_hwops

Currituck doesn't need nor use SDR so aborting the pci setup if there is
no sdr-base would be bad.

Add a flag to ppc4xx_pciex_hwops for the backends to state if they need
SDR and then only complain and abort if they do and it's not found in
the device tree.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc/44x: pci: Use PCI_BASE_ADDRESS_MEM_PREFETCH rather than magic value.
Tony Breeds [Wed, 30 Nov 2011 21:39:17 +0000 (21:39 +0000)]
powerpc/44x: pci: Use PCI_BASE_ADDRESS_MEM_PREFETCH rather than magic value.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc: Enable squashfs as a module
Anton Blanchard [Wed, 30 Nov 2011 00:38:20 +0000 (00:38 +0000)]
powerpc: Enable squashfs as a module

Most distros use it so we may as well enable it and get regular compile
testing.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/nvram: Add spinlock to oops_to_nvram to prevent oops in compression code.
Anton Blanchard [Wed, 30 Nov 2011 15:46:45 +0000 (15:46 +0000)]
powerpc/nvram: Add spinlock to oops_to_nvram to prevent oops in compression code.

When issuing a system reset we almost always oops in the oops_to_nvram
code because multiple CPUs are using the deflate work area. Add a
spinlock to protect it.

To play it safe I'm using trylock to avoid locking up if the NVRAM
code oopses. This means we might miss multiple CPUs oopsing at exactly
the same time but I think it's best to play it safe for now. Once we
are happy with the reliability we can change it to a full spinlock.

Signed-off-by: Anton Blanchard <anton@samba.org>
Acked-by: Jim Keniston <jkenisto@us.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopmac_zilog: Fix unexpected irq
Finn Thain [Tue, 6 Dec 2011 17:49:36 +0000 (17:49 +0000)]
pmac_zilog: Fix unexpected irq

On most 68k Macs the SCC IRQ is an autovector interrupt and cannot be
masked. This can be a problem when pmac_zilog starts up.

For example, the serial debugging code in arch/m68k/kernel/head.S may be
used beforehand. It disables the SCC interrupts at the chip but doesn't
ack them. Then when a pmac_zilog port is used, the machine locks up with
"unexpected interrupt".

This can happen in pmz_shutdown() since the irq is freed before the
channel interrupts are disabled.

Fix this by clearing interrupt enable bits before the handler is
uninstalled. Also move the interrupt control bit flipping into a separate
pmz_interrupt_control() routine. Replace all instances of these operations
with calls to this routine. Omit the zssync() calls that seem to serve no
purpose.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Provide a way for KVM to indicate that NV GPR values are lost
Paul Mackerras [Mon, 5 Dec 2011 19:47:26 +0000 (19:47 +0000)]
powerpc: Provide a way for KVM to indicate that NV GPR values are lost

This fixes a problem where a CPU thread coming out of nap mode can
think it has valid values in the nonvolatile GPRs (r14 - r31) as saved
away in power7_idle, but in fact the values have been trashed because
the thread was used for KVM in the mean time.  The result is that the
thread crashes because code that called power7_idle (e.g.,
pnv_smp_cpu_kill_self()) goes to use values in registers that have
been trashed.

The bit field in SRR1 that tells whether state was lost only reflects
the most recent nap, which may not have been the nap instruction in
power7_idle.  So we need an extra PACA field to indicate that state
has been lost even if SRR1 indicates that the most recent nap didn't
lose state.  We clear this field when saving the state in power7_idle,
we set it to a non-zero value when we use the thread for KVM, and we
test it in power7_wakeup_noloss.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/powernv: Fix problems in onlining CPUs
Paul Mackerras [Mon, 5 Dec 2011 19:35:32 +0000 (19:35 +0000)]
powerpc/powernv: Fix problems in onlining CPUs

At present, on the powernv platform, if you off-line a CPU that was
online, and then try to on-line it again, the kernel generates a
warning message "OPAL Error -1 starting CPU n".  Furthermore, if the
CPU is a secondary thread that was used by KVM while it was off-line,
the CPU fails to come online.

The first problem is fixed by only calling OPAL to start the CPU the
first time it is on-lined, as indicated by the cpu_start field of its
PACA being zero.  The second problem is fixed by restoring the
cpu_start field to 1 instead of 0 when using the CPU within KVM.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/pseries: Increase minimum RMO size from 64MB to 256MB
Anton Blanchard [Sun, 4 Dec 2011 13:13:58 +0000 (13:13 +0000)]
powerpc/pseries: Increase minimum RMO size from 64MB to 256MB

The minimum RMO size field in ibm,client-architecture is currently
ignored, but a future firmware version will rectify that. Since we
always get at least 128MB of RMO right now, asking for 64MB is
likely to result in boot failures.

We should bump it to at least 128MB, but considering all the boot
issues we have on 128MB RMO boxes and all new machines have virtual
RMO, we may as well set our minimum to 256MB.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Punch a hole in /dev/mem for librtas
sukadev@linux.vnet.ibm.com [Fri, 2 Dec 2011 12:26:23 +0000 (12:26 +0000)]
powerpc: Punch a hole in /dev/mem for librtas

With CONFIG_STRICT_DEVMEM=y, user space cannot read any part of /dev/mem.
Since this breaks librtas, punch a hole in /dev/mem to allow access to the
rmo_buffer that librtas needs.

Anton Blanchard reported the problem and helped with the fix.

A quick test for this patch:

       # cat /proc/rtas/rmo_buffer
       000000000f190000 10000

       # python -c "print 0x000000000f190000 / 0x10000"
       3865

       # dd if=/dev/mem of=/tmp/foo count=1 bs=64k skip=3865
       1+0 records in
       1+0 records out
       65536 bytes (66 kB) copied, 0.000205235 s, 319 MB/s

       # dd if=/dev/mem of=/tmp/foo
       dd: reading `/dev/mem': Operation not permitted
       0+0 records in
       0+0 records out
       0 bytes (0 B) copied, 0.00022519 s, 0.0 kB/s

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Add support for OpenBlockS 600
Benjamin Herrenschmidt [Thu, 1 Dec 2011 19:35:08 +0000 (19:35 +0000)]
powerpc: Add support for OpenBlockS 600

So I've had one of these for a while and it looks like the vendor never
bothered submitting the support upstream.

This adds it using ppc40x_simple and provides a device-tree.

There are some changes to the boot wrapper because the way u-boot works
on this thing, it seems to expect a multipart image with the kernel,
initrd and dtb in it.

The USB support is missing as it needs the yet unmerged driver for
the DWC OTG part and the GPIOs may need further definition in the dts.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/ps3: Update ps3_defconfig
Geoff Levand [Tue, 29 Nov 2011 15:38:50 +0000 (15:38 +0000)]
powerpc/ps3: Update ps3_defconfig

Refresh ps3_defconfig to latest kernel sources and
change the options:

  CONFIG_PPP=m to CONFIG_PPP=n.
  CONFIG_NAMESPACES=y to CONFIG_NAMESPACES=n
  CONFIG_NUMA=y to CONFIG_NUMA=n

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/ps3: Add __init to ps3_smp_probe
Geoff Levand [Tue, 29 Nov 2011 15:38:50 +0000 (15:38 +0000)]
powerpc/ps3: Add __init to ps3_smp_probe

Add an __init annotation to the ps3_smp_probe() routine.
Fixes build warnings like these when
CONFIG_DEBUG_SECTION_MISMATCH=y:

 WARNING: Section mismatch in reference from the function .ps3_smp_probe()

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/ps3: Fix PS3 repository build warnings
Geoff Levand [Thu, 1 Dec 2011 08:58:58 +0000 (08:58 +0000)]
powerpc/ps3: Fix PS3 repository build warnings

Fix some PS3 repository.c build warnings when DEBUG is
defined. Also change most pr_debug calls to pr_devel calls.

Fixes warnings like these:

  format '%lx' expects type 'long unsigned int', but argument 7 has type 'u64'

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/ps3: Fix hcall lv1_read_repository_node
Geoff Levand [Tue, 29 Nov 2011 15:38:50 +0000 (15:38 +0000)]
powerpc/ps3: Fix hcall lv1_read_repository_node

The lv1 hcall #91 should be named lv1_read_repository_node, and
not lv1_get_repository_node_value.  Adjust the lv1 hcall table
and all calls.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/ps3: Fix hcall lv1_get_version_info
Geoff Levand [Tue, 29 Nov 2011 15:38:50 +0000 (15:38 +0000)]
powerpc/ps3: Fix hcall lv1_get_version_info

The lv1_get_version_info hcall takes 2, not 1 output
arguments.  Adjust the lv1 hcall table and all calls.

Usage:

  int lv1_get_version_info(u64 *version_number, u64 *vendor_id)

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/ps3: Fix hcall lv1_get_virtual_address_space_id_of_ppe
Geoff Levand [Tue, 29 Nov 2011 15:38:49 +0000 (15:38 +0000)]
powerpc/ps3: Fix hcall lv1_get_virtual_address_space_id_of_ppe

The lv1_get_virtual_address_space_id_of_ppe hcall takes 0, not 1 input
arguments.  Adjust the lv1 hcall table and all calls.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/ps3: Fix hcall lv1_net_stop_rx_dma
Geoff Levand [Tue, 29 Nov 2011 15:38:49 +0000 (15:38 +0000)]
powerpc/ps3: Fix hcall lv1_net_stop_rx_dma

The lv1_net_stop_tx_dma and net_stop_rx_dma hcalls take 2, not 3 input
arguments.  Adjust the lv1 hcall table and all calls.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/ps3: Interrupt code cleanup
Geoff Levand [Tue, 29 Nov 2011 15:38:49 +0000 (15:38 +0000)]
powerpc/ps3: Interrupt code cleanup

General code cleanup for PS3 interrupt.c:

 o Fill out comments for structure members.
 o Move variables ipi_debug_brk_mask and lock from struct ps3_bmp to
   struct ps3_private.
 o Fix pr_debug build errors when DEBUG is defined.
 o Convert bit operation to set_bit().
 o Convert DBG macro from pr_debug to pr_devel
 o Add new macro FAIL to replace pr_debug calls

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/kdump: Only save CPU state first time through the secondary CPU capture code
Anton Blanchard [Wed, 30 Nov 2011 00:23:17 +0000 (00:23 +0000)]
powerpc/kdump: Only save CPU state first time through the secondary CPU capture code

We might enter the secondary CPU capture code twice, eg if we have to
unstick some CPUs with a system reset. In this case we don't want to
overwrite the state on CPUs that had made it into the capture code OK,
so use the cpus_state_saved cpumask for that and make it local to
crash_ipi_callback.

For controlling progress now use atomic_t cpus_in_crash to count how
many CPUs have made it into the kdump code, and time_to_dump to tell
everyone it's time to dump.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/kdump: Delay before sending IPI on a system reset
Anton Blanchard [Wed, 30 Nov 2011 00:23:16 +0000 (00:23 +0000)]
powerpc/kdump: Delay before sending IPI on a system reset

If we enter the kdump code via system reset, wait a bit before
sending the IPI to capture all secondary CPUs. Without it we race
with the hypervisor that is issuing the system reset to each CPU.
If the IPI gets there first the system reset oops output then shows
the register state of the IPI handler which is not what we want.

I took the opportunity to add defines for all the various delays
we have. There's no need for cpu_relax when we are doing an mdelay,
so remove them too.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/xics: Reset the CPPR if H_EOI fails
Anton Blanchard [Wed, 30 Nov 2011 00:23:15 +0000 (00:23 +0000)]
powerpc/xics: Reset the CPPR if H_EOI fails

I have an intermittent kdump fail where the hypervisor fails an H_EOI.
As a result our CPPR is never reset to 0xff and we no longer accept
interrupts.

This patch calls icp_hv_set_cppr to reset the CPPR if H_EOI fails,
fixing the kdump fail.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Reduce pseries panic timeout from 180s to 10s
Anton Blanchard [Wed, 30 Nov 2011 00:23:14 +0000 (00:23 +0000)]
powerpc: Reduce pseries panic timeout from 180s to 10s

We've had a 180 second panic timeout on ppc64 for as long as I
can remember. This patch reduces it to 10 seconds on pseries for a few
reasons:

- Almost all pseries machines have a hypervisor console so panic
  output will be available in a scrollback buffer.

- The 180 seconds impacts our availability, users (other than
  kernel hackers) just want the box to come back around so it
  can continue its work.

- I spend a lot of my life staring at the 180 second panic timeout.
  Many pseries machines take minutes to power cycle, so it's quicker
  to sit through the 180 seconds than it is to power cycle.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Rework die()
Anton Blanchard [Wed, 30 Nov 2011 00:23:13 +0000 (00:23 +0000)]
powerpc: Rework die()

Our die() code was based off a very old x86 version. Update it to
mirror the current x86 code.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Cleanup crash/kexec code
Anton Blanchard [Wed, 30 Nov 2011 00:23:12 +0000 (00:23 +0000)]
powerpc: Cleanup crash/kexec code

Remove some unnecessary defines and fix some spelling mistakes.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/kdump: Use setjmp/longjmp to handle kdump and system reset recursion
Anton Blanchard [Wed, 30 Nov 2011 00:23:11 +0000 (00:23 +0000)]
powerpc/kdump: Use setjmp/longjmp to handle kdump and system reset recursion

We can handle recursion caused by system reset by reusing the crash
shutdown fault handler.

Since we don't have an OS triggerable NMI, if all CPUs don't make it
into kdump then we tell the user to issue a system reset. However if
we have a panic timeout set we cannot wait forever and must continue
the kdump.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Remove broken and complicated kdump system reset code
Anton Blanchard [Wed, 30 Nov 2011 00:23:10 +0000 (00:23 +0000)]
powerpc: Remove broken and complicated kdump system reset code

We have a lot of complicated logic that handles possible recursion between
kdump and a system reset exception. We can solve this in a much simpler
way using the same setjmp/longjmp tricks xmon does.

As a first step, this patch removes the old system reset code.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Give us time to get all oopses out before panicking
Anton Blanchard [Wed, 30 Nov 2011 00:23:09 +0000 (00:23 +0000)]
powerpc: Give us time to get all oopses out before panicking

I've been seeing truncated output when people send system reset info
to me. We should see a backtrace for every CPU, but the panic() code
takes the box down before they all make it out to the console. The
panic code runs unlocked so we also see corrupted console output.

If we are going to panic, then delay 1 second before calling into the
panic code. Move oops_exit inside the die lock and put a newline
between oopses for clarity.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/cpuidle: Handle power_save=off
Deepthi Dharwar [Wed, 30 Nov 2011 02:47:03 +0000 (02:47 +0000)]
powerpc/cpuidle: Handle power_save=off

This patch makes pseries_idle_driver not to be registered when
power_save=off kernel boot option is specified. The
cpuidle_disable variable used here is similar to
its usage on x86. If cpuidle_disable is set then
sysfs entries for cpuidle framework are not created
and the required drivers are not loaded.

Signed-off-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Signed-off-by: Trinabh Gupta <g.trinabh@gmail.com>
Signed-off-by: Arun R Bharadwaj <arun.r.bharadwaj@gmail.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/cpuidle: Enable cpuidle and directly call cpuidle_idle_call() for pSeries
Deepthi Dharwar [Wed, 30 Nov 2011 02:46:55 +0000 (02:46 +0000)]
powerpc/cpuidle: Enable cpuidle and directly call cpuidle_idle_call() for pSeries

This patch enables cpuidle for pSeries and pSeries_idle is
directly called from the idle loop. As a result of pSeries_idle, cpuidle
driver registered with cpuidle subsystem comes into action. On
failure of loading of the driver or cpuidle framework default idle
is executed as part of the function. This patch
also removes the routines pseries_shared_idle_sleep and
pseries_dedicated_idle_sleep as they are now implemented as part of
pseries_idle cpuidle driver.

Signed-off-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Signed-off-by: Trinabh Gupta <g.trinabh@gmail.com>
Signed-off-by: Arun R Bharadwaj <arun.r.bharadwaj@gmail.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/cpuidle: cpuidle driver for pSeries
Deepthi Dharwar [Wed, 30 Nov 2011 02:46:42 +0000 (02:46 +0000)]
powerpc/cpuidle: cpuidle driver for pSeries

This patch implements a back-end cpuidle driver for pSeries
based on pseries_dedicated_idle_loop and pseries_shared_idle_loop
routines.  The driver is built only if CONFIG_CPU_IDLE is set. This
cpuidle driver uses global registration of idle states and
not per-cpu.

Signed-off-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Signed-off-by: Trinabh Gupta <g.trinabh@gmail.com>
Signed-off-by: Arun R Bharadwaj <arun.r.bharadwaj@gmail.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/cpuidle: Add cpu_idle_wait() to allow switching of idle routines
Deepthi Dharwar [Wed, 30 Nov 2011 02:46:31 +0000 (02:46 +0000)]
powerpc/cpuidle: Add cpu_idle_wait() to allow switching of idle routines

This patch provides cpu_idle_wait() routine for the powerpc
platform which is required by the cpuidle subsystem. This
routine is required to change the idle handler on SMP systems.
The equivalent routine for x86 is in arch/x86/kernel/process.c
but the powerpc implementation is different.

cpuidle_disable variable is to enable/disable cpuidle
framework if power_save option is set during the boot
time.

Signed-off-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Signed-off-by: Trinabh Gupta <g.trinabh@gmail.com>
Signed-off-by: Arun R Bharadwaj <arun.r.bharadwaj@gmail.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agoMerge branch 'booke-hugetlb' into next
Benjamin Herrenschmidt [Thu, 8 Dec 2011 02:20:34 +0000 (13:20 +1100)]
Merge branch 'booke-hugetlb' into next

12 years agoMerge branch 'mpic' into next
Benjamin Herrenschmidt [Wed, 7 Dec 2011 07:22:47 +0000 (18:22 +1100)]
Merge branch 'mpic' into next

12 years agopowerpc/pci: Make pci_read_irq_line() static
Benjamin Herrenschmidt [Tue, 29 Nov 2011 20:16:25 +0000 (20:16 +0000)]
powerpc/pci: Make pci_read_irq_line() static

It's only used inside the same file where it's defined. There's
also no point exporting it anymore.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/powernv: Workaround OFW issues in prom_init.c
Benjamin Herrenschmidt [Tue, 29 Nov 2011 18:22:56 +0000 (18:22 +0000)]
powerpc/powernv: Workaround OFW issues in prom_init.c

Open Firmware on OPAL machines seems to have issues if we close
stdin and/or we try to print things after calling "quiesce" so
we avoid doing both.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/powernv: Display diag data on p7ioc EEH errors
Benjamin Herrenschmidt [Tue, 29 Nov 2011 18:22:53 +0000 (18:22 +0000)]
powerpc/powernv: Display diag data on p7ioc EEH errors

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/powernv: Update OPAL interfaces
Benjamin Herrenschmidt [Tue, 29 Nov 2011 18:22:50 +0000 (18:22 +0000)]
powerpc/powernv: Update OPAL interfaces

This adds some more interfaces for OPAL v2

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Define/use HUGETLB_NEED_PRELOAD insead of complicated #if
Becky Bruce [Tue, 29 Nov 2011 15:10:39 +0000 (15:10 +0000)]
powerpc: Define/use HUGETLB_NEED_PRELOAD insead of complicated #if

Define HUGETLB_NEED_PRELOAD in mmu-book3e.h for CONFIG_PPC64 instead
of having a much more complicated #if block.  This is easier to read
and maintain.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/book3e: Change hugetlb preload to take vma argument
Becky Bruce [Mon, 28 Nov 2011 14:43:33 +0000 (14:43 +0000)]
powerpc/book3e: Change hugetlb preload to take vma argument

This avoids an extra find_vma() and is less error-prone.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Enable hugetlb by default for corenet64 platforms
Becky Bruce [Mon, 10 Oct 2011 10:50:48 +0000 (10:50 +0000)]
powerpc: Enable hugetlb by default for corenet64 platforms

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Enable Hugetlb by default for 32-bit 85xx/corenet
Becky Bruce [Mon, 10 Oct 2011 10:50:46 +0000 (10:50 +0000)]
powerpc: Enable Hugetlb by default for 32-bit 85xx/corenet

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Kconfig updates for FSL BookE HUGETLB 64-bit
Becky Bruce [Mon, 10 Oct 2011 10:50:44 +0000 (10:50 +0000)]
powerpc: Kconfig updates for FSL BookE HUGETLB 64-bit

Allow hugetlb to be enabled on 64b FSL_BOOK3E.  No platforms enable
it by default yet.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Add gpages reservation code for 64-bit FSL BOOKE
Becky Bruce [Mon, 10 Oct 2011 10:50:43 +0000 (10:50 +0000)]
powerpc: Add gpages reservation code for 64-bit FSL BOOKE

For 64-bit FSL_BOOKE implementations, gigantic pages need to be
reserved at boot time by the memblock code based on the command line.
This adds the call that handles the reservation, and fixes some code
comments.

It also removes the previous pr_err when reserve_hugetlb_gpages
is called on a system without hugetlb enabled - the way the code is
structured, the call is unconditional and the resulting error message
spurious and confusing.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Add hugepage support to 64-bit tablewalk code for FSL_BOOK3E
Becky Bruce [Mon, 10 Oct 2011 10:50:42 +0000 (10:50 +0000)]
powerpc: Add hugepage support to 64-bit tablewalk code for FSL_BOOK3E

Before hugetlb, at each level of the table, we test for
!0 to determine if we have a valid table entry.  With hugetlb, this
compare becomes:
        < 0 is a normal entry
        0 is an invalid entry
        > 0 is huge

This works because the hugepage code pulls the top bit off the entry
(which for non-huge entries always has the top bit set) as an
indicator that we have a hugepage.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Whitespace/comment changes to tlb_low_64e.S
Becky Bruce [Mon, 10 Oct 2011 10:50:41 +0000 (10:50 +0000)]
powerpc: Whitespace/comment changes to tlb_low_64e.S

I happened to comment this code while I was digging through it;
we might as well commit that.  I also made some whitespace
changes - the existing code had a lot of unnecessary newlines
that I found annoying when I was working on my tiny laptop.

No functional changes.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: hugetlb: modify include usage for FSL BookE code
Becky Bruce [Mon, 10 Oct 2011 10:50:40 +0000 (10:50 +0000)]
powerpc: hugetlb: modify include usage for FSL BookE code

The original 32-bit hugetlb implementation used PPC64 vs PPC32 to
determine which code path to take.  However, the final hugetlb
implementation for 64-bit FSL ended up shared with the FSL
32-bit code so the actual check needs to be FSL_BOOK3E vs
everything else.  This patch changes the include protections to
reflect this.

There are also a couple of related comment fixes.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Update hugetlb huge_pte_alloc and tablewalk code for FSL BOOKE
Becky Bruce [Mon, 10 Oct 2011 10:50:39 +0000 (10:50 +0000)]
powerpc: Update hugetlb huge_pte_alloc and tablewalk code for FSL BOOKE

This updates the hugetlb page table code to handle 64-bit FSL_BOOKE.
The previous 32-bit work counted on the inner levels of the page table
collapsing.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Fix booke hugetlb preload code for PPC_MM_SLICES and 64-bit
Becky Bruce [Mon, 10 Oct 2011 10:50:38 +0000 (10:50 +0000)]
powerpc: Fix booke hugetlb preload code for PPC_MM_SLICES and 64-bit

This patch does 2 things: It corrects the code that determines the
size to write into MAS1 for the PPC_MM_SLICES case (this originally
came from David Gibson and I had incorrectly altered it), and it
changes the methodolody used to calculate the size for !PPC_MM_SLICES
to work for 64-bit as well as 32-bit.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: hugetlb: fix huge_ptep_set_access_flags return value
Becky Bruce [Mon, 10 Oct 2011 10:50:37 +0000 (10:50 +0000)]
powerpc: hugetlb: fix huge_ptep_set_access_flags return value

There was an unconditional return of "1" in the original code
from David Gibson, and I dropped it because it wasn't needed
for FSL BOOKE 32-bit.  However, not all systems (including 64-bit
FSL BOOKE) do loading of the hpte from the fault handler asm
and depend on this function returning 1, which causes a call
to update_mmu_cache() that writes an entry into the tlb.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Only define HAVE_ARCH_HUGETLB_UNMAPPED_AREA if PPC_MM_SLICES
Becky Bruce [Mon, 10 Oct 2011 10:50:36 +0000 (10:50 +0000)]
powerpc: Only define HAVE_ARCH_HUGETLB_UNMAPPED_AREA if PPC_MM_SLICES

If we don't have slices, we should be able to use the generic
hugetlb_get_unmapped_area() code

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mpic: Add in-core support for cascaded MPICs
Kyle Moffett [Fri, 2 Dec 2011 06:28:07 +0000 (06:28 +0000)]
powerpc/mpic: Add in-core support for cascaded MPICs

The Cell and PowerMac platforms use virtually identical cascaded-IRQ
setup code, so just merge it into the core.  Ideally this code would
trigger automatically when an MPIC device-node specifies an "interrupts"
property, perhaps even enabling MPIC_SECONDARY along the way.

Unfortunately, Benjamin Herrenschmidt has had bad experiences in the
past with the quality of Apple PowerMac device-trees, so to be safe we
will only try to parse out an IRQ if the MPIC_SECONDARY flag is set by
the caller.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mpic: Cache the device-tree node in "struct mpic"
Kyle Moffett [Fri, 2 Dec 2011 06:28:06 +0000 (06:28 +0000)]
powerpc/mpic: Cache the device-tree node in "struct mpic"

Store the node pointer in the MPIC during initialization so that all of
the later operational code can just reuse the cached pointer.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mpic: Put "pic-no-reset" test back into the MPIC code
Kyle Moffett [Fri, 2 Dec 2011 06:28:05 +0000 (06:28 +0000)]
powerpc/mpic: Put "pic-no-reset" test back into the MPIC code

There's not really any reason to have this one-liner in a separate
static inline function, given that all the other similar tests are
already in the alloc_mpic() code.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mpic: Don't open-code dcr_resource_start
Kyle Moffett [Fri, 2 Dec 2011 06:28:04 +0000 (06:28 +0000)]
powerpc/mpic: Don't open-code dcr_resource_start

Don't open-code the OpenFirmware "dcr-reg" property lookup trying to map
DCR resources.  This makes the code a bit easier to read.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mpic: Invert the meaning of MPIC_PRIMARY
Kyle Moffett [Fri, 2 Dec 2011 06:28:03 +0000 (06:28 +0000)]
powerpc/mpic: Invert the meaning of MPIC_PRIMARY

It turns out that there are only 2 in-tree platforms which use MPICs
which are not "primary":  IBM Cell and PowerMac.  To reduce the
complexity of the typical board setup code, invert the MPIC_PRIMARY bit
into MPIC_SECONDARY.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mpic: Search for open-pic device-tree node if NULL
Kyle Moffett [Fri, 2 Dec 2011 06:28:02 +0000 (06:28 +0000)]
powerpc/mpic: Search for open-pic device-tree node if NULL

Almost all PowerPC platforms use a standard "open-pic" device node so
the mpic_alloc() function now accepts NULL for the device-node.  This
will cause it to perform a default search with of_find_matching_node().

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mpic: Save computed phys_addr for board-specific code
Kyle Moffett [Fri, 2 Dec 2011 06:28:01 +0000 (06:28 +0000)]
powerpc/mpic: Save computed phys_addr for board-specific code

The MPIC code can already perform an automatic OF address translation
step as part of mpic_alloc(), but several boards need to use that base
address when they perform mpic_assign_isu().

The easiest solution is to save the computed physical address into the
"struct mpic" for later use by the board code.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/mpic: Assume a device-node was passed in mpic_alloc()
Kyle Moffett [Fri, 2 Dec 2011 06:28:00 +0000 (06:28 +0000)]
powerpc/mpic: Assume a device-node was passed in mpic_alloc()

All of the existing callers of mpic_alloc() pass in a non-NULL
device-node pointer, so the checks for a NULL device-node may be
removed.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Consolidate mpic_alloc() OF address translation
Kyle Moffett [Fri, 2 Dec 2011 06:27:59 +0000 (06:27 +0000)]
powerpc: Consolidate mpic_alloc() OF address translation

Instead of using the open-coded "reg" property lookup and address
translation in mpic_alloc(), directly call of_address_to_resource().
This includes various workarounds for special cases which the naive
of_address_translate() does not.

Afterwards it is possible to remove the copiously copy-pasted calls to
of_address_translate() from the 85xx/86xx/powermac platforms.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/85xx: Move mpc85xx_smp_init() decl to a new "smp.h"
Kyle Moffett [Fri, 2 Dec 2011 06:27:58 +0000 (06:27 +0000)]
powerpc/85xx: Move mpc85xx_smp_init() decl to a new "smp.h"

This removes a bunch of "extern" declarations and CONFIG_SMP ifdefs.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agoMAINTAINERS: Update PowerPC 4xx git tree
Josh Boyer [Wed, 30 Nov 2011 15:07:51 +0000 (10:07 -0500)]
MAINTAINERS: Update PowerPC 4xx git tree

Update the PowerPC 4xx git tree to a new location

Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc/40x: Add APM8018X SOC support
Tanmay Inamdar [Mon, 28 Nov 2011 21:01:41 +0000 (21:01 +0000)]
powerpc/40x: Add APM8018X SOC support

The AppliedMicro APM8018X embedded processor targets embedded applications that
require low power and a small footprint. It features a PowerPC 405 processor
core built in a 65nm low-power CMOS process with a five-stage pipeline executing
up to one instruction per cycle. The family has 128-kbytes of on-chip memory,
a 128-bit local bus and on-chip DDR2 SDRAM controller with 16-bit interface.

Signed-off-by: Tanmay Inamdar <tinamdar@apm.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
12 years agopowerpc+sparc64/mm: Remove hack in mmap randomize layout
Dan McGee [Mon, 17 Oct 2011 13:05:23 +0000 (13:05 +0000)]
powerpc+sparc64/mm: Remove hack in mmap randomize layout

Since commit 8a0a9bd4db63bc45e301, this comment in mmap_rnd() does not
hold true as the value returned by get_random_int() will in fact be

different every single call. Remove the comment and simplify the code
back to its original desired form.

This reverts commit a5adc91a4b44b5d1 which is no longer necessary and
also fixes the sparc code that copied this same adjustment.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/xics: Harden xics hypervisor backend
Anton Blanchard [Thu, 24 Nov 2011 19:39:36 +0000 (19:39 +0000)]
powerpc/xics: Harden xics hypervisor backend

During kdump stress testing I sometimes see the kdump kernel panic
with:

  Interrupt 0x306 (real) is invalid, disabling it.
  Kernel panic - not syncing: bad return code EOI - rc = -4, value=ff000306

Instead of panicing print the error message, dump the stack the first
time it happens and continue on. Add some more information to the
debug messages as well.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Decode correct MSR bits in oops output
Anton Blanchard [Thu, 24 Nov 2011 19:35:57 +0000 (19:35 +0000)]
powerpc: Decode correct MSR bits in oops output

On a 64bit book3s machine I have an oops from a system reset that
claims the book3e CE bit was set:

MSR: 8000000000021032 <ME,CE,IR,DR>  CR: 24004082  XER: 00000010

On a book3s machine system reset sets IBM bit 46 and 47 depending on
the power saving mode. Separate the definitions by type and for
completeness add the rest of the bits in.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agoarch/powerpc: Remove duplicate/redundant Altivec entries
Matthew McClintock [Tue, 7 Sep 2010 08:56:55 +0000 (08:56 +0000)]
arch/powerpc: Remove duplicate/redundant Altivec entries

In lieu of having multiple similiar lines, we can just have one
generic cpu-as line for CONFIG_ALTIVEC

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/maple: Enable access to HT Host-Bridge on Maple
Dmitry Eremin-Solenikov [Wed, 29 Jun 2011 04:17:40 +0000 (04:17 +0000)]
powerpc/maple: Enable access to HT Host-Bridge on Maple

CPC925/CPC945 use special window to access host bridge functionality of
u3-ht. Provide a way to access this device.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Implement CONFIG_STRICT_DEVMEM
sukadev@linux.vnet.ibm.com [Tue, 30 Aug 2011 09:19:17 +0000 (09:19 +0000)]
powerpc: Implement CONFIG_STRICT_DEVMEM

As described in the help text in the patch, this token restricts general
access to /dev/mem as a way of increasing the security. Specifically, access
to exclusive IOMEM and kernel RAM is denied unless CONFIG_STRICT_DEVMEM is
set to 'n'.

Implement the 'devmem_is_allowed()' interface for Powerpc. It will be
called from range_is_allowed() when userpsace attempts to access /dev/mem.

This patch is based on an earlier patch from Steve Best and with input from
Paul Mackerras and Scott Wood.

[BenH] Fixed a typo or two and removed the generic change which should
       be submitted as a separate patch

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agoMerge remote-tracking branch 'kumar/next' into next
Benjamin Herrenschmidt [Fri, 25 Nov 2011 04:25:39 +0000 (15:25 +1100)]
Merge remote-tracking branch 'kumar/next' into next

12 years agopowerpc/mpic: Remove extra semicolon.
Justin P. Mattock [Mon, 21 Nov 2011 06:43:26 +0000 (06:43 +0000)]
powerpc/mpic: Remove extra semicolon.

The patch below removes an extra semicolon.

Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
CC: linuxppc-dev@lists.ozlabs.org
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Export PIR data through sysfs
Ananth N Mavinakayanahalli [Thu, 10 Nov 2011 19:58:53 +0000 (19:58 +0000)]
powerpc: Export PIR data through sysfs

On Fri, Nov 11, 2011 at 10:17:55AM +0530, Ananth N Mavinakayanahalli wrote:
> >
> > At this rate we're going to end up with no bits left for CPU features
> > way too quickly... Especially for something we only care about once at
> > boot time.
> >
> > Wouldn't CPU_FTR_PPCAS_ARCH_V2 be a good enough test ?
>
> /me checks Cell manuals... yes, that test would be good enough. I will
> cook up a patch to use this.

Here it is...

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/powernv: PCI support for p7IOC under OPAL v2
Benjamin Herrenschmidt [Tue, 15 Nov 2011 17:29:08 +0000 (17:29 +0000)]
powerpc/powernv: PCI support for p7IOC under OPAL v2

This adds support for p7IOC (and possibly other IODA v1 IO Hubs)
using OPAL v2 interfaces.

We completely take over resource assignment and assign them using an
algorithm that hands out device BARs in a way that makes them fit in
individual segments of the M32 window of the bridge, which enables us
to assign individual PEs to devices and functions.

The current implementation gives out a PE per functions on PCIe, and a
PE for the entire bridge for PCIe to PCI-X bridges.

This can be adjusted / fine tuned later.

We also setup DMA resources (32-bit only for now) and MSIs (both 32-bit
and 64-bit MSI are supported).

The DMA allocation tries to divide the available 256M segments of the
32-bit DMA address space "fairly" among PEs. This is done using a
"weight" heuristic which assigns less value to things like OHCI USB
controllers than, for example SCSI RAID controllers. This algorithm
will probably want some fine tuning for specific devices or device
types.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/powernv: Fixup p7ioc PCIe root complex class code
Benjamin Herrenschmidt [Sun, 6 Nov 2011 18:56:00 +0000 (18:56 +0000)]
powerpc/powernv: Fixup p7ioc PCIe root complex class code

It advertises "host bridge" instead of "PCI to PCI bridge" which confuses
the Linux probe code.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/powernv: Add TCE SW invalidation support
Benjamin Herrenschmidt [Sun, 6 Nov 2011 18:55:59 +0000 (18:55 +0000)]
powerpc/powernv: Add TCE SW invalidation support

This is used for newer IO Hubs such as p7IOC.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/pci: Change how re-assigning resouces work
Benjamin Herrenschmidt [Sun, 6 Nov 2011 18:55:58 +0000 (18:55 +0000)]
powerpc/pci: Change how re-assigning resouces work

When PCI_REASSIGN_ALL_RSRC is set, we used to clear all bus resources
at the beginning of survey and re-allocate them later.

This changes it so instead, during early fixup, we mark all resources
as IORESOURCE_UNSET and move them down to be 0-based.

Later, if bus resources are still unset at the beginning of the survey,
then we clear them.

This shouldn't impact the re-assignment case on 4xx, but will enable
us to have the platform do some custom resource assignment before the
survey, by clearing individual resources IORESOURCE_UNSET bit.

Also limits the clutter in the kernel log from fixup when re-assigning
since we don't care about the offset applied to the BAR values in this
case.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/pci: Add a platform hook after probe and before resource survey
Benjamin Herrenschmidt [Sun, 6 Nov 2011 18:55:57 +0000 (18:55 +0000)]
powerpc/pci: Add a platform hook after probe and before resource survey

Some platforms need to perform resource allocation using a custom algorithm
due to HW constraints, or may want to tweak things globally below a host
bridge. For example OPAL support for IODA will need to perform a
resource allocation pass that applies IODA specific segmentation
constraints to MMIO which cannot be done simply using the kernel generic
resource management code.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Add pgprot_cached_noncoherent()
Geoff Thorpe [Thu, 27 Oct 2011 02:58:45 +0000 (02:58 +0000)]
powerpc: Add pgprot_cached_noncoherent()

This adds a pgprot combination required by some cache-enabled IO device
mappings, such as Freescale datapath (QMan and BMan) portals.

Signed-off-by: Geoff Thorpe <geoff@geoffthorpe.net>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Allow irq threading
Thomas Gleixner [Wed, 5 Oct 2011 02:30:51 +0000 (02:30 +0000)]
powerpc: Allow irq threading

All interrupts which must be non threaded are marked
IRQF_NO_THREAD. So it's safe to allow force threaded handlers.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc: Mark IPI interrupts IRQF_NO_THREAD
Thomas Gleixner [Wed, 5 Oct 2011 02:30:50 +0000 (02:30 +0000)]
powerpc: Mark IPI interrupts IRQF_NO_THREAD

IPI handlers cannot be threaded. Remove the obsolete IRQF_DISABLED
flag (see commit e58aa3d2) while at it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/wsp: Mark opb cascade handler IRQF_NO_THREAD
Thomas Gleixner [Wed, 5 Oct 2011 02:30:50 +0000 (02:30 +0000)]
powerpc/wsp: Mark opb cascade handler IRQF_NO_THREAD

Cascade handlers must run in hard interrupt context.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 years agopowerpc/85xx: Mark cascade irq IRQF_NO_THREAD
Thomas Gleixner [Wed, 5 Oct 2011 02:30:49 +0000 (02:30 +0000)]
powerpc/85xx: Mark cascade irq IRQF_NO_THREAD

Cascade interrupt must run in hard interrupt context.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>