firefly-linux-kernel-4.4.55.git
9 years agopowerpc/powernv: Avoid explicit endian conversions while parsing device tree
Preeti U Murthy [Tue, 3 Feb 2015 06:43:44 +0000 (12:13 +0530)]
powerpc/powernv: Avoid explicit endian conversions while parsing device tree

We currently read the information about idle states from the device
tree, so as to find out the CPU idle states supported by the platform.

Use the of_property_read/count_xxx() APIs, which handle endian
conversions for us, and mean we don't need any endian annotations in the
code.

Signed-off-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agops3: Fix trivial typos in comment and debug message
Yannick Guerrini [Sat, 7 Mar 2015 12:03:36 +0000 (13:03 +0100)]
ps3: Fix trivial typos in comment and debug message

Change 'prosessor' to 'processor'
Change 'set_inteval' to 'set_interval'

Signed-off-by: Yannick Guerrini <yguerrini@tomshardware.fr>
Acked-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/mm: Free string after creating kmem cache
Yanjiang Jin [Fri, 27 Feb 2015 05:30:34 +0000 (13:30 +0800)]
powerpc/mm: Free string after creating kmem cache

kmem_cache_create()->kmem_cache_create_memcg()->kstrdup() allocates new
space and copys name's content, so it is safe to free name memory after
calling kmem_cache_create(). Else kmemleak will report the below
warning:

unreferenced object 0xc0000000f9002160 (size 16):
  comm "swapper/0", pid 0, jiffies 4294892296 (age 1386.640s)
  hex dump (first 16 bytes):
    70 67 74 61 62 6c 65 2d 32 5e 39 00 de ad be ef  pgtable-2^9.....
  backtrace:
    [<c0000000004e03ec>] .kvasprintf+0x5c/0xa0
    [<c0000000004e045c>] .kasprintf+0x2c/0x50
    [<c00000000002e36c>] .pgtable_cache_add+0xac/0x100
    [<c00000000002e3e4>] .pgtable_cache_init+0x24/0x80
    [<c000000000c6c67c>] .start_kernel+0x228/0x4c8
    [<c000000000000594>] .start_here_common+0x24/0x90

Signed-off-by: Yanjiang Jin <yanjiang.jin@windriver.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/powernv: Add OPAL message notifier unregister function
Neelesh Gupta [Wed, 11 Feb 2015 06:27:23 +0000 (11:57 +0530)]
powerpc/powernv: Add OPAL message notifier unregister function

Provide an unregister interface for the opal message notifiers
to be called when not needed like during driver unload/remove.

Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Fix the overflow of OPAL message notifiers head array
Neelesh Gupta [Wed, 11 Feb 2015 06:27:06 +0000 (11:57 +0530)]
powerpc/powernv: Fix the overflow of OPAL message notifiers head array

Fixes the condition check of incoming message type which can
otherwise shoot beyond the message notifiers head array.

Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Reviewed-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pmac: replace current->state by set_current_state()
Fabian Frederick [Fri, 20 Feb 2015 18:12:53 +0000 (19:12 +0100)]
powerpc/pmac: replace current->state by set_current_state()

Use helper functions to access current->state.
Direct assignments are prone to races and therefore buggy.

current->state = TASK_RUNNING can be replaced by __set_current_state()

Thanks to Peter Zijlstra for the exact definition of the problem.

Suggested-By: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agocpufreq/ppc: Add missing #include <asm/smp.h>
Geert Uytterhoeven [Wed, 4 Mar 2015 11:56:20 +0000 (12:56 +0100)]
cpufreq/ppc: Add missing #include <asm/smp.h>

If CONFIG_SMP=n, <linux/smp.h> does not include <asm/smp.h>, causing:

drivers/cpufreq/ppc-corenet-cpufreq.c: In function 'corenet_cpufreq_cpu_init':
drivers/cpufreq/ppc-corenet-cpufreq.c:173:3: error: implicit declaration of function 'get_hard_smp_processor_id' [-Werror=implicit-funcuresh E. Warrier" <warrier@linux.vnet.ibm.com>
X-Patchwork-Id: 443703
Message-Id: <54EE5989.7010800@linux.vnet.ibm.com>
To: linuxppc-dev@ozlabs.org
Date: Wed, 25 Feb 2015 17:23:53 -0600

Export __spin_yield so that the arch_spin_unlock() function can
be invoked from a module. This will be required for modules where
we want to take a lock that is also is acquired in hypervisor
real mode. Because we want to avoid running any lockdep code
(which may not be safe in real mode), this lock needs to be
an arch_spinlock_t instead of a normal spinlock.

Signed-off-by: Suresh Warrier <warrier@linux.vnet.ibm.com>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pmac: Fix DT refcount imbalance in pmac_pic_probe_oldstyle
Geert Uytterhoeven [Tue, 3 Mar 2015 10:02:15 +0000 (11:02 +0100)]
powerpc/pmac: Fix DT refcount imbalance in pmac_pic_probe_oldstyle

Internally, of_find_node_by_name() calls of_node_put() on its "from"
parameter, which must not be done on "master", as it's still in use, and
will be released manually later.  This may cause a zero kref refcount.

Call of_node_get() before to compensate for this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agodrivers/macintosh: Delete an unnecessary check before the function call "of_node_put"
Markus Elfring [Wed, 4 Feb 2015 20:32:27 +0000 (21:32 +0100)]
drivers/macintosh: Delete an unnecessary check before the function call "of_node_put"

The of_node_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Support OPAL requested heartbeat
Benjamin Herrenschmidt [Fri, 14 Nov 2014 05:13:50 +0000 (16:13 +1100)]
powerpc/powernv: Support OPAL requested heartbeat

If OPAL requests it, call it back via opal_poll_events() at a
regular interval. Some versions of OPAL on some machines require
this to operate some internal timeouts properly.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Check image loaded or not before calling flash
Vasant Hegde [Fri, 13 Feb 2015 09:56:33 +0000 (15:26 +0530)]
powerpc/powernv: Check image loaded or not before calling flash

Present code checks for update_flash_data in opal_flash_term_callback().
update_flash_data has been statically initialized to zero, and that
is the value of FLASH_IMG_READY. Also code update initialization happens
during subsys init.

So if reboot is issued before the subsys init stage then we endup displaying
"Flashing new firmware" message.. which may confuse end user.

This patch fixes above described issue by initializes update_flash status
to invalid state.

Reported-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc: Remove unused st_le*() and ld_le* functions
David Gibson [Tue, 3 Feb 2015 05:36:25 +0000 (16:36 +1100)]
powerpc: Remove unused st_le*() and ld_le* functions

The powerpc specific st_le*() and ld_le*() functions in
arch/powerpc/asm/swab.h no longer have any users.  They are also
misleadingly named, since they always byteswap, even on a little-endian
host.

This patch removes them.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc: Cleanup KVM emulated load/store endian handling
David Gibson [Tue, 3 Feb 2015 05:36:24 +0000 (16:36 +1100)]
powerpc: Cleanup KVM emulated load/store endian handling

Sometimes the KVM code on powerpc needs to emulate load or store
instructions from the guest, which can include both normal and byte
reversed forms.

We currently (AFAICT) handle this correctly, but some variable names are
very misleading.  In particular we use "is_bigendian" in several places to
actually mean "is the IO the same endian as the host", but we now support
little-endian powerpc hosts.  This also ties into the misleadingly named
ld_le*() and st_le*() functions, which in fact always byteswap, even on
an LE host.

This patch cleans this up by renaming to more accurate "host_swabbed", and
uses the generic swab*() functions instead of the powerpc specific and
misleadingly named ld_le*() and st_le*() functions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc: Remove arch specific byteswappers from the MXC MMC driver
David Gibson [Tue, 3 Feb 2015 05:36:23 +0000 (16:36 +1100)]
powerpc: Remove arch specific byteswappers from the MXC MMC driver

When the MXC MMUC driver is used on a Freescale MPC512x machine, it
contains some additional byteswapping code (I'm assuming this is a
workaround for a hardware defect).  This uses the ppc specific st_le32()
function, but there's no reason not to use the generic swab32() function
instead.  gcc is capable of generating the efficient ppc byte-reversing
load/store instructions without the arch-specific helper.

This patch, therefore, switches to the generic byteswap routine.

Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Sascha Hauer <kernel@pengutronix.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agomedia/bt8xx: Remove old powerpc cruft
Benjamin Herrenschmidt [Tue, 24 Mar 2015 02:32:03 +0000 (13:32 +1100)]
media/bt8xx: Remove old powerpc cruft

The powerpc arch code enables PCI_COMMAND_MEMORY (and has done so for
more than 10 years at least !) on pci_enable_device() and the hackery
on the MMIO accessor is useless as well, our writel does everything
this driver should need.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/eeh: Remove device_node dependency
Gavin Shan [Tue, 17 Mar 2015 05:15:08 +0000 (16:15 +1100)]
powerpc/eeh: Remove device_node dependency

The patch removes struct eeh_dev::dn and the corresponding helper
functions: eeh_dev_to_of_node() and of_node_to_eeh_dev(). Instead,
eeh_dev_to_pdn() and pdn_to_eeh_dev() should be used to get the
pdn, which might contain device_node on PowerNV platform.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/eeh: Replace device_node with pci_dn in eeh_ops
Gavin Shan [Tue, 17 Mar 2015 05:15:07 +0000 (16:15 +1100)]
powerpc/eeh: Replace device_node with pci_dn in eeh_ops

There are 3 EEH operations whose arguments contain device_node:
read_config(), write_config() and restore_config(). The patch
replaces device_node with pci_dn.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/eeh: Do probe on pci_dn
Gavin Shan [Tue, 17 Mar 2015 05:15:06 +0000 (16:15 +1100)]
powerpc/eeh: Do probe on pci_dn

Originally, EEH core probes on device_node or pci_dev to populate
EEH devices and PEs, which conflicts with the fact: SRIOV VFs are
usually enabled and created by PF's driver and they don't have the
corresponding device_nodes. Instead, SRIOV VFs have dynamically
created pci_dn, which can be used for EEH probe.

The patch reworks EEH probe for PowerNV and pSeries platforms to
do probing based on pci_dn, instead of pci_dev or device_node any
more.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/eeh: Create eeh_dev from pci_dn instead of device_node
Gavin Shan [Tue, 17 Mar 2015 05:15:05 +0000 (16:15 +1100)]
powerpc/eeh: Create eeh_dev from pci_dn instead of device_node

The patch adds function traverse_pci_dn(), which is similar to
traverse_pci_devices() except it takes pci_dn, not device_node
as parameter. The pci_dev.c has been reworked to create eeh_dev
from pci_dn, instead of device_node.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pci: Trace more information from pci_dn
Gavin Shan [Tue, 17 Mar 2015 05:15:04 +0000 (16:15 +1100)]
powerpc/pci: Trace more information from pci_dn

Originally, EEH probes on device_node or pci_dev and populates the
corresponding eeh_dev. In the subsequent patches, EEH will probes
on pci_dn and populates the corresponding eeh_dev. So we have to
cache some information in pci_dn, either from device_node or SRIOV
PF's enablement platform hook, to populate the eeh_dev properly.

The motivation to probe pci_dn, instead of device node or pci_dev,
to populate eeh_dev is SRIOV VFs are dynamically created and we
don't have the corresponding device nodes for them.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Use pci_dn, not device_node, in PCI config accessor
Gavin Shan [Tue, 17 Mar 2015 05:15:03 +0000 (16:15 +1100)]
powerpc/powernv: Use pci_dn, not device_node, in PCI config accessor

The PCI config accessors previously relied on device_node.  Unfortunately,
VFs don't have a corresponding device_node, so change the accessors to use
pci_dn instead.

[bhelgaas: changelog]
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pci: Refactor pci_dn
Gavin Shan [Tue, 17 Mar 2015 05:15:02 +0000 (16:15 +1100)]
powerpc/pci: Refactor pci_dn

Currently, the PCI config accessors are implemented based on device node.
Unfortunately, SRIOV VFs won't have the corresponding device nodes. pci_dn
will be used in replacement with device node for SRIOV VFs. So we have to
use pci_dn in PCI config accessors.

The patch refactors pci_dn in following aspects to make it ready to be used
in PCI config accessors as we do in subsequent patch:

   * pci_dn is organized as a hierarchy tree.  PCI device's pci_dn is
     put to the child list of pci_dn of its upstream bridge or PHB. VF's
     pci_dn will be put to the child list of pci_dn of PF's bridge.

   * For one particular PCI device (VF or not), its pci_dn can be
     found from pdev->dev.archdata.pci_data, PCI_DN(devnode), or
     parent's list.  The fast path (fetching pci_dn through PCI device
     instance) is populated during early fixup time.

[bhelgaas: changelog]
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agonet/ethernet/sfc: Don't use of_node_to_eeh_dev()
Benjamin Herrenschmidt [Mon, 23 Mar 2015 03:00:47 +0000 (14:00 +1100)]
net/ethernet/sfc: Don't use of_node_to_eeh_dev()

This is deprecated, it forces the driver to hop via the OF node
that may or may not exist, instead use pci_dev_to_eeh_dev() which
is simpler.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Shradha Shah <sshah@solarflare.com>
9 years agopowerpc: Enable power monitor feature in defconfig for supported platforms
Hongtao Jia [Thu, 12 Mar 2015 07:00:14 +0000 (15:00 +0800)]
powerpc: Enable power monitor feature in defconfig for supported platforms

Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc: Enable thermal monitor feature in defconfig for supported platforms
Hongtao Jia [Thu, 12 Mar 2015 07:00:13 +0000 (15:00 +0800)]
powerpc: Enable thermal monitor feature in defconfig for supported platforms

Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc/corenet: Enable muxing MDIO buses via FPGA
Shruti Kanetkar [Fri, 27 Feb 2015 15:59:22 +0000 (09:59 -0600)]
powerpc/corenet: Enable muxing MDIO buses via FPGA

Signed-off-by: Andy Fleming <afleming@gmail.com>
Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
Signed-off-by: Shruti Kanetkar <Kanetkar.Shruti@gmail.com>
Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc/corenet: Enable muxing MDIO buses via GPIO
Andy Fleming [Fri, 27 Feb 2015 15:57:55 +0000 (09:57 -0600)]
powerpc/corenet: Enable muxing MDIO buses via GPIO

Signed-off-by: Andy Fleming <afleming@gmail.com>
Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
Signed-off-by: Shruti Kanetkar <Kanetkar.Shruti@gmail.com>
Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc/mpc85xx: Add FSL QorIQ DPAA BMan support to device tree(s)
Kumar Gala [Fri, 27 Feb 2015 15:16:14 +0000 (09:16 -0600)]
powerpc/mpc85xx: Add FSL QorIQ DPAA BMan support to device tree(s)

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Geoff Thorpe <Geoff.Thorpe@freescale.com>
Signed-off-by: Hai-Ying Wang <Haiying.Wang@freescale.com>
Signed-off-by: Chunhe Lan <Chunhe.Lan@freescale.com>
Signed-off-by: Poonam Aggrwal <poonam.aggrwal@freescale.com>
[Emil Medve: Sync with the upstream binding]
Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc: Make corenet64_defconfig a bit more useful
Benjamin Herrenschmidt [Fri, 27 Feb 2015 03:09:37 +0000 (14:09 +1100)]
powerpc: Make corenet64_defconfig a bit more useful

CONFIG_BLK_DEV_SD, SR, ... are needed for pretty much any SATA or USB
storage device (corenet32_defconfig has them) and modern any with
systemd needs the CGROUPS gunk.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc/85xx: workaround for chips with MSI hardware errata
Hongtao Jia [Thu, 26 Feb 2015 07:23:08 +0000 (15:23 +0800)]
powerpc/85xx: workaround for chips with MSI hardware errata

The MPIC version 2.0 has a MSI errata (errata PIC1 of mpc8544), It causes
that neither MSI nor MSI-X can work fine. This is a workaround to allow
MSI-X to function properly.

Signed-off-by: Liu Shuo <soniccat.liu@gmail.com>
Signed-off-by: Li Yang <leoli@freescale.com>
Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc/mpic: Add get_version API both for internal and external use
Hongtao Jia [Wed, 10 Apr 2013 02:52:55 +0000 (10:52 +0800)]
powerpc/mpic: Add get_version API both for internal and external use

MPIC version is useful information for both mpic_alloc() and mpic_init().
The patch provide an API to get MPIC version for reusing the code.
Also, some other IP block may need MPIC version for their own use.
The API for external use is also provided.

This function had been previously added but was removed by commit
5e86bfde9cd93f2 ("powerpc/mpic: remove unused functions") due to the
lack of a user.  This function will be used by "powerpc/mpic: Add
get_version API both for internal and external use".

Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
[scottwood@freescale.com: changelog update]
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc/mpc85xx: Add FMan platform support
Igal Liberman [Wed, 18 Feb 2015 14:04:45 +0000 (16:04 +0200)]
powerpc/mpc85xx: Add FMan platform support

Get the FMan devices/sub-nodes (MAC, MDIO, etc.) auto-probed

Signed-off-by: Igal Liberman <Igal.Liberman@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc/dts: Remove B4860 emulator support
Emil Medve [Tue, 3 Feb 2015 23:16:48 +0000 (17:16 -0600)]
powerpc/dts: Remove B4860 emulator support

Probably we should have not upstreamed this in the first place

Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
9 years agopowerpc/pseries: Introduce api_version to migration sysfs interface
Tyrel Datwyler [Thu, 5 Mar 2015 02:25:38 +0000 (18:25 -0800)]
powerpc/pseries: Introduce api_version to migration sysfs interface

The /sys/kernel/mobility/migration interface was added all the way back
in 2.6.37. However, the drmgr userspace tool was never augmented to use
this interface to perfrom migrations. Instead it has continued using a
faux rtas call coupled with performing the device tree update processing
in userspace and communicating it back to the kernel via the ugly
/proc/ppc64/ofdt interface.

Up until 3.12 the device tree update code in the kernel was badly broken
and bit rotting. This code was fixed in 3.12 and is now utilized by the
kernel suspend code as of 3.15. The kernel is now better suited to
handle the post-mobility fixup of the device tree and drmgr should be
transitioned to using the sysfs migration interface.

This patch introduces the api_version sysfs file to /sys/kernel/mobility
as a means for drmgr to query the current implementation level of the
kernel migration code. This initial versioning indicates it is capable
of perfroming all current PAPR requirements for migration including the
post-mobility firmware activation and device tree update.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Cc: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/32: %pF is only for function pointers
Scott Wood [Thu, 12 Mar 2015 03:13:46 +0000 (22:13 -0500)]
powerpc/32: %pF is only for function pointers

Use %pS for actual addresses, otherwise you'll get bad output
on arches like ppc64 where %pF expects a function descriptor.  Even on
other architectures, refrain from setting a bad example that people
copy.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc: use kbuild generic-y where possible
Fabian Frederick [Wed, 11 Mar 2015 19:13:34 +0000 (20:13 +0100)]
powerpc: use kbuild generic-y where possible

Replace one line asm-generic include files declared in
arch/powerpc/include/asm/ by generic-y declaration
which creates arch/powerpc/include/generated/asm equivalent.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/powernv: Fix return value from power7_nap() et al.
Paul Mackerras [Thu, 19 Mar 2015 23:10:18 +0000 (10:10 +1100)]
powerpc/powernv: Fix return value from power7_nap() et al.

The power7_nap(), power7_sleep() and power7_winkle() functions are
called from pnv_smp_cpu_kill_self(), which expects them to return the
SRR1 value set by the hardware on wakeup, or 0 if no nap/sleep/winkle
occurred.  However, in the case where an interrupt needs to be
replayed, the logic in power7_powersave_common (the common code for
power7_nap et al.) doesn't set r3 to 0 in this case.  Instead what we
get as the return value is the selector for the type of power-saving
mode requested (1, 2 or 3).  In fact this should not affect the
operation of pnv_smp_cpu_kill_self(), but it is better to get this
correct, so this adds an instruction to set r3 to 0 in this case.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc: Spelling s/embeeded/embedded/
Geert Uytterhoeven [Wed, 18 Mar 2015 16:29:13 +0000 (17:29 +0100)]
powerpc: Spelling s/embeeded/embedded/

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc: Convert relocs_check to a shell script using grep
Stephen Rothwell [Wed, 18 Mar 2015 05:46:16 +0000 (16:46 +1100)]
powerpc: Convert relocs_check to a shell script using grep

This runs a bit faster and removes another use of perl from
the kernel build.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-By: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc: Move Power Macintosh drivers to generic byteswappers
David Gibson [Tue, 3 Feb 2015 05:36:21 +0000 (16:36 +1100)]
powerpc: Move Power Macintosh drivers to generic byteswappers

ppc has special instruction forms to efficiently load and store values
in non-native endianness.  These can be accessed via the arch-specific
{ld,st}_le{16,32}() inlines in arch/powerpc/include/asm/swab.h.

However, gcc is perfectly capable of generating the byte-reversing
load/store instructions when using the normal, generic cpu_to_le*() and
le*_to_cpu() functions eaning the arch-specific functions don't have much
point.

Worse the "le" in the names of the arch specific functions is now
misleading, because they always generate byte-reversing forms, but some
ppc machines can now run a little-endian kernel.

To start getting rid of the arch-specific forms, this patch removes them
from all the old Power Macintosh drivers, replacing them with the
generic byteswappers.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/rtas: Make timestamp related code y2038-safe
Hari Bathini [Thu, 5 Feb 2015 19:37:17 +0000 (01:07 +0530)]
powerpc/rtas: Make timestamp related code y2038-safe

While we are here, let us make timestamp related code y2038-safe.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/powernv: Add pstore support on powernv
Hari Bathini [Thu, 5 Feb 2015 19:36:52 +0000 (01:06 +0530)]
powerpc/powernv: Add pstore support on powernv

This patch extends pstore, a generic interface to platform dependent
persistent storage, support for powernv  platform to capture certain
useful information, during dying moments. Such support is already in
place for  pseries platform. This patch re-uses most of that code.

It is a common practice to compile kernels with both CONFIG_PPC_PSERIES=y
and CONFIG_PPC_POWERNV=y. The code in nvram_init_oops_partition() routine
still works as intended, as the caller is platform specific code which
passes the appropriate value for "rtas_partition_exists" parameter.
In all other places, where CONFIG_PPC_PSERIES or CONFIG_PPC_POWERNV
flag is used in this patchset, it is to reduce the kernel size in cases
where this flag is not set and doesn't have any impact logic wise.

Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopstore: Add pstore type id for PPC64 opal nvram partition
Hari Bathini [Thu, 5 Feb 2015 19:36:28 +0000 (01:06 +0530)]
pstore: Add pstore type id for PPC64 opal nvram partition

This patch adds a new PPC64 partition type to be used for opal
specific nvram partition. A new partition type is needed as none
of the existing type matches this partition type.

Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/nvram: Move generic code for nvram and pstore
Hari Bathini [Thu, 5 Feb 2015 19:36:04 +0000 (01:06 +0530)]
powerpc/nvram: Move generic code for nvram and pstore

With minor checks, we can move most of the code for nvram
under pseries to a common place to be re-used by other
powerpc platforms like powernv. This patch moves such
common code to arch/powerpc/kernel/nvram_64.c file.

Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
[mpe: Move select of ZLIB_DEFLATE to PPC64 to fix the build]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/numa: Reset node_possible_map to only node_online_map
Nishanth Aravamudan [Tue, 10 Mar 2015 23:50:59 +0000 (16:50 -0700)]
powerpc/numa: Reset node_possible_map to only node_online_map

Raghu noticed an issue with excessive memory allocation on power with a
simple cgroup test, specifically, in mem_cgroup_css_alloc ->
for_each_node -> alloc_mem_cgroup_per_zone_info(), which ends up blowing
up the kmalloc-2048 slab (to the order of 200MB for 400 cgroup
directories).

The underlying issue is that NODES_SHIFT on power is 8 (256 NUMA nodes
possible), which defines node_possible_map, which in turn defines the
value of nr_node_ids in setup_nr_node_ids and the iteration of
for_each_node.

In practice, we never see a system with 256 NUMA nodes, and in fact, we
do not support node hotplug on power in the first place, so the nodes
that are online when we come up are the nodes that will be present for
the lifetime of this kernel. So let's, at least, drop the NUMA possible
map down to the online map at runtime. This is similar to what x86 does
in its initialization routines.

mem_cgroup_css_alloc should also be fixed to only iterate over
memory-populated nodes and handle hotplug, but that is a separate
change.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Anton Blanchard <anton@samba.org>
Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/kernel: Rename copy_thread() 'arg' argument to 'kthread_arg'
Alex Dowad [Fri, 13 Mar 2015 18:14:46 +0000 (20:14 +0200)]
powerpc/kernel: Rename copy_thread() 'arg' argument to 'kthread_arg'

The 'arg' argument to copy_thread() is only ever used when forking a new
kernel thread. Hence, rename it to 'kthread_arg' for clarity.

Signed-off-by: Alex Dowad <alexinbeijing@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agoselftests/powerpc: Rename TARGETS in powerpc selftests makefile
Michael Ellerman [Wed, 18 Mar 2015 01:02:41 +0000 (12:02 +1100)]
selftests/powerpc: Rename TARGETS in powerpc selftests makefile

This patch changes the name of the make variable TARGETS, to prevent it
from colliding with a value set by the user on the command line (as they
are recommended to do by tools/testing/selftests/README.txt).

Without this patch, "make -C tools/testing/selftests TARGETS=powerpc"
will fail.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agoselftests/powerpc: Add test for VPHN
Greg Kurz [Mon, 23 Feb 2015 15:14:44 +0000 (16:14 +0100)]
selftests/powerpc: Add test for VPHN

The goal is to verify vphn_unpack_associativity() parses VPHN numbers
correctly. We feed it with a variety of input values and compare with
expected results.

PAPR+ does not say much about VPHN parsing: I came up with a list of
tests that check many simple cases and some corner ones. I wouldn't
dare to say the list is exhaustive though.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
[mpe: Rework harness logic, rename to test-vphn, add -m64]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
9 years agopowerpc/vphn: parsing code rewrite
Greg Kurz [Mon, 23 Feb 2015 15:14:37 +0000 (16:14 +0100)]
powerpc/vphn: parsing code rewrite

The current VPHN parsing logic has some flaws that this patch aims to fix:

1) when the value 0xffff is read, the value 0xffffffff gets added to the
   the output list and its element count isn't incremented. This is wrong.
   According to PAPR+ the domain identifiers are packed into a sequence
   terminated by the "reserved value of all ones". This means that 0xffff
   is a stream terminator.

2) the combination of byteswaps and casts make the code hardly readable.
   Let's parse the stream one 16-bit field at a time instead.

3) it is assumed that the hypercall returns 12 32-bit values packed into
   6 64-bit registers. According to PAPR+, the domain identifiers may be
   streamed as 16-bit values. Let's increase the number of expected numbers
   to 24.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/vphn: move VPHN parsing logic to a separate file
Greg Kurz [Mon, 23 Feb 2015 15:14:31 +0000 (16:14 +0100)]
powerpc/vphn: move VPHN parsing logic to a separate file

The goal behind this patch is to be able to write userland tests for the
VPHN parsing code.

Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/vphn: move endianness fixing to vphn_unpack_associativity()
Greg Kurz [Mon, 23 Feb 2015 15:14:25 +0000 (16:14 +0100)]
powerpc/vphn: move endianness fixing to vphn_unpack_associativity()

The first argument to vphn_unpack_associativity() is a const long *, but the
parsing code expects __be64 values actually. Let's move the endian fixing
down for consistency.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/vphn: clarify the H_HOME_NODE_ASSOCIATIVITY API
Greg Kurz [Mon, 23 Feb 2015 15:14:19 +0000 (16:14 +0100)]
powerpc/vphn: clarify the H_HOME_NODE_ASSOCIATIVITY API

The number of values returned by the H_HOME_NODE_ASSOCIATIVITY h_call deserves
to be explicitly defined, for a better understanding of the code.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc: kill PPC_OF
Kevin Hao [Thu, 12 Mar 2015 12:32:50 +0000 (20:32 +0800)]
powerpc: kill PPC_OF

We have set CONFIG_PPC_OF to always 'y' in commit 0a498d96a332
("powerpc: set CONFIG_PPC_OF=y always for ARCH=powerpc") nine years
ago. And the arch/ppc also has gone away for many years. The OF
functionality was also moved to a common place and be used by many
archs. So it does make no sense to keep such a option in the current
kernel. Just kill it.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agofbdev: kconfig: replace PPC_OF with PPC
Kevin Hao [Thu, 12 Mar 2015 12:32:49 +0000 (20:32 +0800)]
fbdev: kconfig: replace PPC_OF with PPC

The PPC_OF is a ppc specific option which is used to mean that the
firmware device tree access functions are available. Since all the
ppc platforms have a device tree, it is aways set to 'y' for ppc.
So it makes no sense to keep a such option in the current kernel.
Replace it with PPC.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agofbdev: remove the unnecessary includes of ppc specific header files
Kevin Hao [Thu, 12 Mar 2015 12:32:48 +0000 (20:32 +0800)]
fbdev: remove the unnecessary includes of ppc specific header files

In the current kernel, we don't need to include these arch specific
header files for ppc.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agofbdev: riva: remove the dependency on PPC_OF
Kevin Hao [Thu, 12 Mar 2015 12:32:47 +0000 (20:32 +0800)]
fbdev: riva: remove the dependency on PPC_OF

The OF functionality has moved to a common place and be used by many
archs. So we don't need to include the ppc arch specific header files
and depend on PPC_OF option any more. This is a preparation for
killing PPC_OF.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agofbdev: nvidia: remove the dependency on PPC_OF
Kevin Hao [Thu, 12 Mar 2015 12:32:46 +0000 (20:32 +0800)]
fbdev: nvidia: remove the dependency on PPC_OF

The OF functionality has moved to a common place and be used by many
archs. So we don't need to include the ppc arch specific header files
and depend on PPC_OF option any more. This is a preparation for
killing PPC_OF.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agofbdev: imsttfb: remove the dependency on PPC_OF
Kevin Hao [Thu, 12 Mar 2015 12:32:45 +0000 (20:32 +0800)]
fbdev: imsttfb: remove the dependency on PPC_OF

The OF functionality has moved to a common place and be used by many
archs. So we don't need to depend on PPC_OF option any more. This is
a preparation for killing PPC_OF.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agofbdev: radeon: replace PPC_OF with PPC
Kevin Hao [Thu, 12 Mar 2015 12:32:44 +0000 (20:32 +0800)]
fbdev: radeon: replace PPC_OF with PPC

The PPC_OF is a ppc specific option which is used to mean that the
firmware device tree access functions are available. Since all the
ppc platforms have a device tree, it is aways set to 'y' for ppc.
So it makes no sense to keep a such option in the current kernel.
Replace it with PPC.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agofbdev: aty128fb: replace PPC_OF with PPC
Kevin Hao [Thu, 12 Mar 2015 12:32:43 +0000 (20:32 +0800)]
fbdev: aty128fb: replace PPC_OF with PPC

The PPC_OF is a ppc specific option which is used to mean that the
firmware device tree access functions are available. Since all the
ppc platforms have a device tree, it is aways set to 'y' for ppc.
So it makes no sense to keep a such option in the current kernel.
Replace it with PPC.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agosata_svw: remove the dependency on PPC_OF
Kevin Hao [Thu, 12 Mar 2015 12:32:42 +0000 (20:32 +0800)]
sata_svw: remove the dependency on PPC_OF

The OF functionality has moved to a common place and be used by many
archs. So we don't need to include the ppc arch specific header files
and depend on PPC_OF option any more. This is a preparation for
killing PPC_OF.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/powermac: Cleaning up missing null-terminate in conjunction with strncpy
Rickard Strandqvist [Sat, 26 Jul 2014 16:45:05 +0000 (18:45 +0200)]
powerpc/powermac: Cleaning up missing null-terminate in conjunction with strncpy

Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
And removed unnecessary magic numbers.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agoselftests/powerpc: Build the copyloops with -maltivec
Michael Ellerman [Tue, 17 Mar 2015 04:16:12 +0000 (15:16 +1100)]
selftests/powerpc: Build the copyloops with -maltivec

The recent change to remove the vrX defines exposed the fact that we are
building the copyloops tests without altivec enabled. It depends on the
toolchain as to whether altivec is on by default or not, so it only
breaks on some toolchains. But we should always enable it.

Fixes: c2ce6f9f3dc0 ("powerpc: Change vrX register defines to vX to match gcc and glibc")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/via-pmu: fix OF node leak in Keylargo init
Phil Carmody [Tue, 16 Sep 2014 22:00:54 +0000 (01:00 +0300)]
powerpc/via-pmu: fix OF node leak in Keylargo init

If we of_find_node_by_name() then we must of_node_put() too.

Signed-off-by: Phil Carmody <pc+lkml@asdf.org>
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/via-pmu: fix error path in find_via_pmu()
Phil Carmody [Tue, 16 Sep 2014 22:00:53 +0000 (01:00 +0300)]
powerpc/via-pmu: fix error path in find_via_pmu()

Cleanup was not in the reverse order from the set-up, so not all
the gotos made sense, and also it was being avoided completely upon
failure of init_pmu().

Signed-off-by: Phil Carmody <pc+lkml@asdf.org>
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc: Remove duplicate cacheable_memcpy/memzero functions
Kyle Moffett [Tue, 15 Nov 2011 02:32:10 +0000 (21:32 -0500)]
powerpc: Remove duplicate cacheable_memcpy/memzero functions

These functions are only used from one place each.  If the cacheable_*
versions really are more efficient, then those changes should be
migrated into the common code instead.

NOTE: The old routines are just flat buggy on kernels that support
      hardware with different cacheline sizes.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pseries: Implement memory hotplug remove in the kernel
Nathan Fontenot [Tue, 10 Feb 2015 19:49:22 +0000 (13:49 -0600)]
powerpc/pseries: Implement memory hotplug remove in the kernel

This patch adds the ability to do memory hotplug remove in the kernel.

Currently the operation to hotplug remove memory is handled by the drmgr
command which performs the operation by performing some work in user-space
and making requests to the kernel to handle other pieces. By moving all
of the work to the kernel we can do the remove faster, and provide a common
code path to do memory hotplug for both the PowerVM and PowerKVM environments.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pseries: Implement memory hotplug add in the kernel
Nathan Fontenot [Tue, 10 Feb 2015 19:48:25 +0000 (13:48 -0600)]
powerpc/pseries: Implement memory hotplug add in the kernel

This patch adds the ability to do memory hotplug add in the kernel.

Currently the operation to hotplug add memory is handled by the drmgr
command which performs the operation by performing some work in user-space
and making requests to the kernel to handle other pieces. By moving all
of the work to the kernel we can do the add faster, and provide a common
code path to do memory hotplug for both the PowerVM and PowerKVM environments.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pseries: Create new device hotplug entry point
Nathan Fontenot [Tue, 10 Feb 2015 19:47:02 +0000 (13:47 -0600)]
powerpc/pseries: Create new device hotplug entry point

The current hotplug (or dlpar) of devices (the process is generally the
same for memory, cpu, and pci) on PowerVM systems is initiated
from the HMC, which communicates the request to the partitions through
the RSCT framework. The RSCT framework then invokes the drmgr command.
The drmgr command performs the hotplug operation by doing some pieces,
such as most of the rtas calls and device tree parsing, in userspace
and make requests to the kernel to online/offline the device, update the
device tree and add/remove the device.

For PowerKVM the approach for device hotplug is to follow what is currently
being done for pci hotplug. A hotplug request is initiated from the host.
QEMU then generates an EPOW interrupt to the guest which causes the guest
to make the rtas,check-exception call. In QEMU, the rtas,check-exception call
returns a rtas hotplug event to the guest.

Please note that the current pci hotplug path for PowerKVM involves the
kernel receiving the rtas hotplug event, passing it to rtas_errd in
userspace, and having rtas_errd invoke drmgr. The drmgr command then
handles the request as described above for PowerVM systems.

There is no need for this circuitous route, we should just handle the entire
hotplug of devices in the kernel. What I am planning is to enable this
by moving the code to handle hotplug from drmgr into the kernel to
provide a single path for handling device hotplug for both PowerVM and
PowerKVM systems. This patch provides the common iframework and entry point.
For PowerKVM a future update to the kernel rtas code will recognize rtas
hotplug events returned from rtas,check-exception calls and use the common
entry point to handle hotplug of the device.

For PowerVM systems, This patch creates /sys/kernel/dlpar that can be
used by the drmgr command to initiate hotplug requests. In order to do
this a string of the format "<resource> <action> <id_type> <id>" is
written to this file. The string consists of a resource (cpu, memory, pci,
phb), an action (add or remove), an id_type (count, drc index, drc name),
and the corresponding id. The kernel will parse the string and create a
rtas hotplug section that can be passed to the common entry point for
handling hotplug requests.

It should be noted that there is no chance of updating how we receive
hotplug (dlpar) requests from the HMC on PowerVM systems.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pseries: Declare the acquire/release drc index routines
Nathan Fontenot [Tue, 10 Feb 2015 19:45:01 +0000 (13:45 -0600)]
powerpc/pseries: Declare the acquire/release drc index routines

Add declarations for dlpar_{acquire,release}_drc(...)

They are already marked non-static but were missing a prototype/

[BenH: Added extern to be consistent with the rest of the file]

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pseries: Define rtas hotplug event sections
Nathan Fontenot [Tue, 10 Feb 2015 19:43:24 +0000 (13:43 -0600)]
powerpc/pseries: Define rtas hotplug event sections

In order to handle device hotplug in the kernel on pseries the hotplug
request will be communicated in the kernel in the form of a
rtas hotplug event. This patch adds the definition of rtas hotplug event
sections.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Remove unused file
Gavin Shan [Mon, 16 Feb 2015 03:45:48 +0000 (14:45 +1100)]
powerpc/powernv: Remove unused file

The patch removes unused file eeh-ioda.c and updates makefile
accordingly. Besides, the definition of "struct pnv_eeh_ops" and
the instances are all removed. Until now, the chip layer of EEH
implementation for PowerNV platform is removed completely.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Drop PHB operation reset()
Gavin Shan [Mon, 16 Feb 2015 03:45:47 +0000 (14:45 +1100)]
powerpc/powernv: Drop PHB operation reset()

The patch drops PHB EEH operation reset() and merges its logic to
eeh_ops::reset().

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Drop PHB operation next_error()
Gavin Shan [Mon, 16 Feb 2015 03:45:46 +0000 (14:45 +1100)]
powerpc/powernv: Drop PHB operation next_error()

The patch drops PHB EEH operation next_error() and merges its
logic to eeh_ops::next_error().

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Drop PHB operation get_state()
Gavin Shan [Mon, 16 Feb 2015 03:45:45 +0000 (14:45 +1100)]
powerpc/powernv: Drop PHB operation get_state()

The patch drops PHB EEH operation get_state() and merges its logic
to eeh_ops::get_state().

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Drop PHB operation set_option()
Gavin Shan [Mon, 16 Feb 2015 03:45:44 +0000 (14:45 +1100)]
powerpc/powernv: Drop PHB operation set_option()

The patch drops PHB EEH operation set_option() and merges its
logic to eeh_ops::set_option().

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Drop PHB operation configure_bridge()
Gavin Shan [Mon, 16 Feb 2015 03:45:43 +0000 (14:45 +1100)]
powerpc/powernv: Drop PHB operation configure_bridge()

The patch drops PHB EEH operation configure_bridge() and merges
its logic to eeh_ops::configure_bridge().

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Drop PHB operation get_log()
Gavin Shan [Mon, 16 Feb 2015 03:45:42 +0000 (14:45 +1100)]
powerpc/powernv: Drop PHB operation get_log()

The patch drops PHB operation get_log() and merges its logic to
eeh_ops::get_log().

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Drop PHB operation post_init()
Gavin Shan [Mon, 16 Feb 2015 03:45:41 +0000 (14:45 +1100)]
powerpc/powernv: Drop PHB operation post_init()

The patch drops PHB EEH operation post_init() and merge its logic
to eeh_ops::post_init().

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Drop PHB operation err_inject()
Gavin Shan [Mon, 16 Feb 2015 03:45:40 +0000 (14:45 +1100)]
powerpc/powernv: Drop PHB operation err_inject()

The patch drops PHB EEH operation err_inject() and merge its logic
to eeh_ops::err_inject().

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/powernv: Shorten EEH function names
Gavin Shan [Mon, 16 Feb 2015 03:45:39 +0000 (14:45 +1100)]
powerpc/powernv: Shorten EEH function names

The patch shortens names of EEH functions in powernv-eeh.c and no
logic change introduced by this patch.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/pci: Fix comments about ppc_md.pcibios_fixup
Gavin Shan [Fri, 13 Feb 2015 04:16:32 +0000 (15:16 +1100)]
powerpc/pci: Fix comments about ppc_md.pcibios_fixup

The patch fixes the comments about ppc_md.pcibios_fixup(), which
should be called after allocating resources.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/eeh: Enhance pcibios_set_pcie_reset_state()
Gavin Shan [Tue, 10 Feb 2015 23:20:49 +0000 (10:20 +1100)]
powerpc/eeh: Enhance pcibios_set_pcie_reset_state()

Function pcibios_set_pcie_reset_state() is possibly called by
pci_reset_function(), on which VFIO infrastructure depends to
issue reset. pcibios_set_pcie_reset_state() is issuing reset
on the parent PE of the indicated PCI device. The reset causes
state lost on all PCI devices except the indicated one as the
argument to pcibios_set_pcie_reset_state(). Also, sideband
MMIO access from guest when issuing reset would cause unexpected
EEH error.

For above two issues, the patch applies following enhancements
to pcibios_set_pcie_reset_state():

   * For all PCI devices except the indicated one, save their
     state prior to reset and restore state after that.
   * Explicitly freeze PE prior to reset and unfreeze it after
     that, in order to avoid unexpected EEH error.

Tested-by: Priya M. A <priyama2@in.ibm.com>
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 years agopowerpc/book3s: Fix flush_tlb cpu_spec hook to take a generic argument.
Mahesh Salgaonkar [Fri, 19 Dec 2014 03:11:05 +0000 (08:41 +0530)]
powerpc/book3s: Fix flush_tlb cpu_spec hook to take a generic argument.

The flush_tlb hook in cpu_spec was introduced as a generic function hook
to invalidate TLBs. But the current implementation of flush_tlb hook
takes IS (invalidation selector) as an argument which is architecture
dependent. Hence, It is not right to have a generic routine where caller
has to pass non-generic argument.

This patch fixes this and makes flush_tlb hook as high level API.

Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/boot: don't clobber r6 and r7 in epapr boot
Jeremy Kerr [Wed, 11 Feb 2015 04:55:44 +0000 (12:55 +0800)]
powerpc/boot: don't clobber r6 and r7 in epapr boot

We use r6 and r7 for epapr boot, but the current pre-C init will clobber
both of these.

This change does a simple replacement, of r6 -> r12 and r7 -> r13, so
that we hit platform init with these registers intact.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/boot: Fix stack corruption in epapr entry point
Jeremy Kerr [Wed, 11 Feb 2015 04:55:44 +0000 (12:55 +0800)]
powerpc/boot: Fix stack corruption in epapr entry point

Currently, a 64-bit little-endian zImage.epapr won't boot in epapr mode,
as we never return from platform_init.

Before entering C, we initialise our stack by setting r1 16 bytes below
the end of the _bss_stack:

  stwu r0,-16(r1) /* establish a stack frame */

However, the called function will save the caller's lr in the caller's
frame's lr save area, at -16(r1) to -32(r1).

This means that writes to the fdt variable will corrupt the saved link
register:

 0000000020c06018 l     O .bss   0000000000001000 _bss_stack
 0000000020c07018 l     O .bss   0000000000000008 fdt

We'll need at least 32 bytes in the initial stack frame, to handle the
LR save area. We bump this to 112 bytes, as that'll be the max required
by ABIv1.

Thanks to Alistair Popple for debugging help.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/boot/wrapper: use the pseries wrapper for zImage.epapr
Jeremy Kerr [Wed, 11 Feb 2015 04:55:44 +0000 (12:55 +0800)]
powerpc/boot/wrapper: use the pseries wrapper for zImage.epapr

We'll likely be entering the zImage.epapr as BE, so include the pseries
implementation of _zimage_start, which adds the endian fixup magic.

Although the endian fixup won't work on Book III-E machines starting LE,
the current entry point doesn't support LE anyway, so we shouldn't be
breaking anything.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/boot/fdt: Add little-endian support to libfdt wrappers
Jeremy Kerr [Wed, 11 Feb 2015 04:55:44 +0000 (12:55 +0800)]
powerpc/boot/fdt: Add little-endian support to libfdt wrappers

For epapr-style boot, we may be little-endian. This change implements
the proper conversion for fdt*_to_cpu and cpu_to_fdt*. We also need the
full cpu_to_* and *_to_cpu macros for this.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/boot/fdt: Use unsigned long for pointer casts
Jeremy Kerr [Wed, 11 Feb 2015 04:55:44 +0000 (12:55 +0800)]
powerpc/boot/fdt: Use unsigned long for pointer casts

Now that the wrapper supports 64-bit builds, we see warnings when
attempting to cast pointers to int. Use unsigned long instead.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/mpic: remove unused functions
Arseny Solokha [Tue, 24 Feb 2015 09:05:06 +0000 (16:05 +0700)]
powerpc/mpic: remove unused functions

Drop unused fsl_mpic_primary_get_version(), mpic_set_clk_ratio(),
mpic_set_serial_int().

  + fsl_mpic_primary_get_version() is just a safe wrapper around
fsl_mpic_get_version() for SMP configurations. While the latter is
called explicitly for handling PIC initialization and setting up error
interrupt vector depending on PIC hardware version, the former isn't
used for anything.

  + As for mpic_set_clk_ratio() and mpic_set_serial_int(), they both are
almost nine years old[1] but still have no chance to be called even from
out-of-tree modules because they both are __init and of course aren't
exported.

[1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2006-June/023867.html

Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Cc: hongtao.jia@freescale.com
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/qe: drop unused ucc_slow_poll_transmitter_now
Arseny Solokha [Tue, 24 Feb 2015 09:05:05 +0000 (16:05 +0700)]
powerpc/qe: drop unused ucc_slow_poll_transmitter_now

Drop ucc_slow_poll_transmitter_now() which has no users since its
inception in 2007 in commit 986585385131 ("[POWERPC] Add QUICC
Engine (QE) infrastructure").

Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/boot: drop planetcore_set_serial_speed
Arseny Solokha [Tue, 24 Feb 2015 09:05:03 +0000 (16:05 +0700)]
powerpc/boot: drop planetcore_set_serial_speed

Drop planetcore_set_serial_speed() which had no users since its
inception in commit fec6047047fd ("[POWERPC] bootwrapper: Add PlanetCore
firmware support") in 2007.

Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/powernv: Remove unused definitions in opal-api.h
Michael Ellerman [Tue, 17 Feb 2015 09:01:55 +0000 (20:01 +1100)]
powerpc/powernv: Remove unused definitions in opal-api.h

This removes definitions in opal-api.h that are completely unused in
Linux.

For each of these I see three possibilities, 1) we *should* be using
them in Linux and patches will arrive to do that, 2) they are not used
but should stay in the header to document the API for some important
reason, 3) they are not used and needn't be part of the API.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Stewart Smith <stewart@linux.vnet.ibm.com>
9 years agopowerpc/powernv: Move opal-api.h closer to the Skiboot version
Michael Ellerman [Tue, 17 Feb 2015 09:01:54 +0000 (20:01 +1100)]
powerpc/powernv: Move opal-api.h closer to the Skiboot version

This commit gets opal-api.h to mostly match the version in Skiboot as of
commit ea7d806ab0ba.

The exceptions are things which are not (currently) used in Linux.

Most of this is just whitespace and a few things moving around. I think
the diff is readable.

Also OpalMessageType became opal_msg_type, requiring a change in the
Linux code.

Finally Skiboot and Linux disagree on CAPI vs CXL, because CAPI means
something else in Linux. To handle that we just point the Linux wrapper,
which is named "cxl" to the OPAL token OPAL_PCI_SET_PHB_CAPI_MODE.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Stewart Smith <stewart@linux.vnet.ibm.com>
9 years agopowerpc/powernv: Move OPAL API definitions to opal-api.h
Michael Ellerman [Tue, 17 Feb 2015 09:01:53 +0000 (20:01 +1100)]
powerpc/powernv: Move OPAL API definitions to opal-api.h

We'd like to get to the stage where the OPAL API is defined in a header
that is identical between Linux and Skiboot.

As step one, split the bits that actually define the API into
opal-api.h. The Linux specific parts stay in opal.h.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Acked-by: Stewart Smith <stewart@linux.vnet.ibm.com>
9 years agopowerpc/boot: Makefile cleanup
Michal Marek [Thu, 2 Oct 2014 13:49:15 +0000 (15:49 +0200)]
powerpc/boot: Makefile cleanup

The $(image-n) variable will never exist, because unset Kconfig options
are '' and not 'n'.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc: Delete unnecessary checks before kfree()
Markus Elfring [Tue, 3 Feb 2015 12:55:53 +0000 (13:55 +0100)]
powerpc: Delete unnecessary checks before kfree()

The kfree() function tests whether its argument is NULL and then returns
immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/powernv: only call OPAL_RESEND_DUMP if firmware supports it
Stewart Smith [Thu, 12 Feb 2015 05:25:29 +0000 (16:25 +1100)]
powerpc/powernv: only call OPAL_RESEND_DUMP if firmware supports it

Not all OPAL platforms support resending system dumps, so check
that current firmware supports it first. Otherwise we get firmware
complaining:
"OPAL: Called with bad token 91 !"

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Acked-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/powernv: only call OPAL_ELOG_RESEND if firmware supports it
Stewart Smith [Thu, 12 Feb 2015 05:25:28 +0000 (16:25 +1100)]
powerpc/powernv: only call OPAL_ELOG_RESEND if firmware supports it

Otherwise firmware complains: "OPAL: Called with bad token 74 !"
as not all OPAL systems have the ability to resend error logs.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Acked-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agopowerpc/powernv: only register log if OPAL supports doing so
Stewart Smith [Thu, 12 Feb 2015 05:25:27 +0000 (16:25 +1100)]
powerpc/powernv: only register log if OPAL supports doing so

Correct use of REGISTER/UNREGISTER is to check if the token exists
before calling. If we don't we get a "OPAL: Called with bad token 101 !"
error, which is harmless but may be alarming to some.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Acked-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>