Re: [PATCH 4/4] perf/powerpc: Implement group_read() txn interface for 24x7 counters

2015-03-16 Thread Peter Zijlstra
On Wed, Mar 04, 2015 at 12:35:08AM -0800, Sukadev Bhattiprolu wrote:
> +++ b/kernel/events/core.c
> @@ -3677,11 +3677,34 @@ u64 perf_event_read_value(struct perf_event *event, 
> u64 *enabled, u64 *running,
>  }
>  EXPORT_SYMBOL_GPL(perf_event_read_value);
>  
> +static int do_pmu_group_read(struct perf_event *leader)
> +{
> + int ret;
> + struct pmu *pmu;
> + struct perf_event *sub;
> +
> + pmu = leader->pmu;
> + pmu->start_txn(pmu, PERF_PMU_TXN_READ);
> +
> + pmu->read(leader);
> + list_for_each_entry(sub, &leader->sibling_list, group_entry)
> + pmu->read(sub);
> +
> + /*
> +  * Commit_txn submits the transaction to read all the counters
> +  * in the group _and_ updates the event count.
> +  */
> + ret = pmu->commit_txn(pmu, PERF_PMU_TXN_READ);
> +
> + return ret;
> +}
> +
>  static int perf_event_read_group(struct perf_event *event,
>  u64 read_format, char __user *buf)
>  {
>   struct perf_event *leader = event->group_leader, *sub;
>   struct perf_event_context *ctx = leader->ctx;
> + struct pmu *pmu;
>   int n = 0, size = 0, ret;
>   u64 count, enabled, running;
>   u64 values[5];
> @@ -3690,7 +3713,21 @@ static int perf_event_read_group(struct perf_event 
> *event,
>  
>   lockdep_assert_held(&ctx->mutex);
>  
> + pmu = event->pmu;
>   update = 1;
> +
> + if ((read_format & PERF_FORMAT_GROUP) &&
> + (pmu->capabilities & PERF_PMU_CAP_GROUP_READ)) {
> + ret = do_pmu_group_read(event);
> + if (ret)
> + return ret;
> + /*
> +  * ->commit_txn() would have updated the event count,
> +  * so we don't have to consult the PMU again.
> +  */
> + update = 0;
> + }
> +

Is there a down-side to always doing the txn based group read? If an
arch does not implement the read txn support it'll fall back to doing
independent read ops, but we end up doing those anyway.

That way we get less special case code.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 3/4] perf: Add 'update' parameter to perf_event_read_value()

2015-03-16 Thread Peter Zijlstra
On Wed, Mar 04, 2015 at 12:35:07AM -0800, Sukadev Bhattiprolu wrote:

>  extern u64 perf_event_read_value(struct perf_event *event,
> -  u64 *enabled, u64 *running);
> +  u64 *enabled, u64 *running, int update);
>  

I think someone recently showed that bool generates better code in some
cases. The advantage of int is that you can stuff more bits in, but then
you need to call it flags or so anyhow.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 1/4] perf: Add 'flags' parameter to pmu txn interfaces

2015-03-16 Thread Peter Zijlstra
On Wed, Mar 04, 2015 at 12:35:05AM -0800, Sukadev Bhattiprolu wrote:
> In addition to using the transaction interface to schedule events
> on a PMU, we will use it to also read a group of counters at once.
> Accordingly, add a flags parameter to the transaction interfaces.
> The flags indicate wheether the transaction is to add events to
> the PMU (PERF_PMU_TXN_ADD) or to read the events PERF_PMU_TXN_READ.
> 
> Based on input from Peter Zijlstra.
> 
> Signed-off-by: Sukadev Bhattiprolu 
> ---
>  arch/powerpc/perf/core-book3s.c  | 15 ---
>  arch/x86/kernel/cpu/perf_event.c | 15 ---
>  include/linux/perf_event.h   | 14 +++---
>  kernel/events/core.c | 26 +++---
>  4 files changed, 50 insertions(+), 20 deletions(-)

s390 and sparc also implement the txn.

# git grep "\.start_txn"
arch/powerpc/perf/core-book3s.c:.start_txn  = power_pmu_start_txn,
arch/s390/kernel/perf_cpum_cf.c:.start_txn= cpumf_pmu_start_txn,
arch/sparc/kernel/perf_event.c: .start_txn  = sparc_pmu_start_txn,
arch/x86/kernel/cpu/perf_event.c:   .start_txn  = 
x86_pmu_start_txn,

Also; you add the flag to all 3 calls; does it make sense to only pass
it to the first and save the txn type in the txn state itself? We could
add PERF_EVENT_TXN_READ for this..
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: linux panic on 4.0.0-rc4

2015-03-16 Thread Pranith Kumar
On Mon, Mar 16, 2015 at 11:18 PM, Peter Hurley  wrote:
> On 03/16/2015 11:12 PM, Pranith Kumar wrote:
>> On Mon, Mar 16, 2015 at 10:58 PM, Peter Hurley  
>> wrote:
> What is your init?

 I am using systemd from debian unstable.
>>>
>>> Do you have a stdout-path property defined in your dts to a serial
>>> console you're not actually using?
>>>
>>
>> I am using tty0 as my console. From the config which I posted, it has:
>>
>> CONFIG_CMDLINE="console=ttyS0,9600 console=tty0"
>>
>> I am not using any device tree file.
>
> Ok; there was some reported breakage on PowerMac wrt to 'stdout-path'
> changes I made, so I thought I'd check if that might have affected
> your setup as well.
>

And the painful slow bisecting did lead to that commit:

Bisecting: 0 revisions left to test after this (roughly 0 steps)
[2fa645cb2703d9b3786d850db815414dfeefa51d] of: Fix premature
bootconsole disable with 'stdout-path'

$ git show 2fa645cb2703d9b3786d850db815414dfeefa51d
commit 2fa645cb2703d9b3786d850db815414dfeefa51d
Author: Peter Hurley 
Date:   Sun Mar 1 12:21:22 2015 -0500

of: Fix premature bootconsole disable with 'stdout-path'

Support for devicetree serial consoles via 'stdout-path' causes
bootconsoles to be disabled when the vt dummy console loads, since
there is no preferred console (the preferred console is not added
until the device is probed).

Ensure there is at least a preferred console, even if never matched.


More info:

$ git bisect log
git bisect start
# bad: [06e5801b8cb3fc057d88cb4dc03c0b64b2744cda] Linux 4.0-rc4
git bisect bad 06e5801b8cb3fc057d88cb4dc03c0b64b2744cda
# good: [bfa76d49576599a4b9f9b7a71f23d73d6dcff735] Linux 3.19
git bisect good bfa76d49576599a4b9f9b7a71f23d73d6dcff735
# good: [1a67e256dbd80f47f339c4a88c34deee12489aa0] ARM: mvebu:
ISL12057 rtc chip can now wake up RN102, RN102 and RN2120
git bisect good 1a67e256dbd80f47f339c4a88c34deee12489aa0
# good: [878ba61aa98cbb97a513757800e77613f856a029] Merge tag
'soc-for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
git bisect good 878ba61aa98cbb97a513757800e77613f856a029
# good: [18a8d49973667aa016e68826eeb374788b7c63b0] Merge tag
'clk-for-linus-3.20' of
git://git.linaro.org/people/mike.turquette/linux
git bisect good 18a8d49973667aa016e68826eeb374788b7c63b0
# good: [bfda4031621b048ca634abc5f6bce1aa490ac4e5] MAINTAINERS: Add
myself as co-maintainer to the legacy support of the mvebu SoCs
git bisect good bfda4031621b048ca634abc5f6bce1aa490ac4e5
# good: [29191c7f71aa55401c83df60482417d3c511edde] Merge tag
'char-misc-4.0-rc3' of
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
git bisect good 29191c7f71aa55401c83df60482417d3c511edde
# good: [36bef88380037288d5b575ed2029de694533b1ec] Merge
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
git bisect good 36bef88380037288d5b575ed2029de694533b1ec
# bad: [3d52c5bdbe57e2b45d9cc8da930b9ab42b5198c4] Merge tag
'devicetree-fixes-for-4.0' of
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
git bisect bad 3d52c5bdbe57e2b45d9cc8da930b9ab42b5198c4
# good: [91e9134eda82b57952fdbdb0c5990a7a6609ff13] Merge tag
'pci-v4.0-fixes-2' of
git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
git bisect good 91e9134eda82b57952fdbdb0c5990a7a6609ff13
# good: [c202baf017aea0c860e53131bc55bb1af7177e76] Merge branch 'akpm'
(patches from Andrew)
git bisect good c202baf017aea0c860e53131bc55bb1af7177e76
# bad: [649022e08e4798ffb6e9b11c56ee6b2c62465d11] of/unittest: Fix the
wrong expected value in of_selftest_property_string
git bisect bad 649022e08e4798ffb6e9b11c56ee6b2c62465d11
# good: [2c192699a7050ef5bdf1e2cc95fdddfbcf524509] Merge tag
'v4.0-rc3' into HEAD
git bisect good 2c192699a7050ef5bdf1e2cc95fdddfbcf524509
# bad: [d3a891652adb82e1973348c703a597cb54e41dea] of/overlay: Remove
unused variable
git bisect bad d3a891652adb82e1973348c703a597cb54e41dea
# bad: [20aa4d8ae8d2ada8f959364ebc096b8841245456] Documentation: DT:
Renamed of-serial.txt to 8250.txt
git bisect bad 20aa4d8ae8d2ada8f959364ebc096b8841245456

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

Re: [PATCH v3 2/2] selftests/powerpc: Add a test of the switch_endian() syscall

2015-03-16 Thread Anshuman Khandual
On 03/17/2015 04:34 AM, Michael Ellerman wrote:
> On Mon, 2015-03-16 at 16:30 +0530, Anshuman Khandual wrote:
>> On 03/16/2015 12:27 PM, Michael Ellerman wrote:
>>> This adds a test of the switch_endian() syscall we added in the previous
>>> commit.
>>>
>>> We test it by calling the endian switch syscall, and then executing some
>>> code in the other endian to check everything went as expected. That code
>>> checks registers we expect to be maintained are, and then writes to
>>> stdout. If the endian switch failed to happen that code sequence will be
>>> illegal and cause the test to abort.
>>>
>>> We then switch back to the original endian, do the same checks and
>>> finally write a success message and exit(0).
>>>
>>> Signed-off-by: Michael Ellerman 
>>
>> Hey Michael,
>>
>> Did a quick test, passes on LE but seems like failing on BE.
>>
>> On LE:
>>
>> Hello wrong-endian world
>> Hello right-endian world
>> success: switch_endian_test
>>
>> on BE:
>>
>> Hello wrong-endian world (returns 176)
>>
>> The previous version of the test was passing both on LE
>> and BE (after applying the compiler trick in the assembly)
> 
> Hmm, odd. Works for me:
> 
> $ uname -a
> Linux bebuntu 4.0.0-rc3-2-g9dd2601a490a #1 SMP Fri Mar 13 15:52:11 AEDT 
> 2015 ppc64 ppc64 ppc64 GNU/Linux
> $ make
> cc -O2 -Wall -g -nostdlib -m64   -c -o check.o check.S
> objcopy -j .text --reverse-bytes=4 -O binary check.o check-reversed.o
> hexdump -v -e '/1 ".byte 0x%02X\n"' check-reversed.o > check-reversed.S
> cc -O2 -Wall -g -nostdlib -m64switch_endian_test.S check-reversed.S   -o 
> switch_endian_test
> $ ./switch_endian_test 
> Hello wrong-endian world
> Hello right-endian world
> success: switch_endian_test
> 
> 
> What are you seeing exactly?

I am running on a BE PKVM guest but compiling the test case on
a different BE machine which has newer version of the compiler.

cc (GCC) 4.8.3 20140624

cc -O2 -Wall -g -nostdlib -m64   -c -o check.o check.S
objcopy -j .text --reverse-bytes=4 -O binary check.o check-reversed.o
hexdump -v -e '/1 ".byte 0x%02X\n"' check-reversed.o > check-reversed.S
cc -O2 -Wall -g -nostdlib -m64switch_endian_test.S check-reversed.S   -o 
switch_endian_test

which looks very similar to the details you have provided above.
Running on guest or host should not make any difference.

BTW, we need to add one .gitignore file to this new test directory.

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

Changes to my -next branch

2015-03-16 Thread Benjamin Herrenschmidt
Hi folks !

My -next branch has been somewhat dormant lately. Now that we have that
new two-headed maintainership model, I'll change the way it works.

I'm going to merge patches in topic branches exclusively. One per series
and a next-misc for random other stuff.

"next" itself will just be an aggregate of these and will possibly be
rebased, nobody should work on top of next anyway. If you rely on some
work in any of the topic branches, pull *that*.

The topic branches themselves are meant to have the "don't rebase"
semantics, ie, if such a branch goes into my "nest", it means that
I intend to send it to Linus in my pull request (or via mpe) as-is. I
*might* drop the branch but that is a last-minute fuse thing that
I hope I don't have to use.

I'll start pushing things out tomorrow.

Cheers,
Ben.


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

[PATCH v2 7/7] powerpc/eeh: Remove device_node dependency

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/eeh.h|  7 ---
 arch/powerpc/include/asm/pci-bridge.h | 14 --
 arch/powerpc/kernel/eeh.c | 24 +---
 arch/powerpc/kernel/eeh_cache.c   | 25 +++--
 arch/powerpc/kernel/eeh_driver.c  | 22 --
 arch/powerpc/kernel/eeh_pe.c  | 34 +-
 arch/powerpc/kernel/pci_of_scan.c |  2 +-
 arch/powerpc/kernel/rtas_pci.c|  2 +-
 arch/powerpc/platforms/pseries/msi.c  |  6 --
 9 files changed, 55 insertions(+), 81 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 2540ad8..61912fc 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -29,7 +29,6 @@
 
 struct pci_dev;
 struct pci_bus;
-struct device_node;
 
 #ifdef CONFIG_EEH
 
@@ -136,17 +135,11 @@ struct eeh_dev {
struct eeh_pe *pe;  /* Associated PE*/
struct list_head list;  /* Form link list in the PE */
struct pci_controller *phb; /* Associated PHB   */
-   struct device_node *dn; /* Associated device node   */
struct pci_dn *pdn; /* Associated PCI device node   */
struct pci_dev *pdev;   /* Associated PCI device*/
struct pci_bus *bus;/* PCI bus for partial hotplug  */
 };
 
-static inline struct device_node *eeh_dev_to_of_node(struct eeh_dev *edev)
-{
-   return edev ? edev->dn : NULL;
-}
-
 static inline struct pci_dn *eeh_dev_to_pdn(struct eeh_dev *edev)
 {
return edev ? edev->pdn : NULL;
diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 7b74499..2c6dc2a 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -201,25 +201,11 @@ static inline int pci_device_from_OF_node(struct 
device_node *np,
 }
 
 #if defined(CONFIG_EEH)
-static inline struct eeh_dev *of_node_to_eeh_dev(struct device_node *dn)
-{
-   /*
-* For those OF nodes whose parent isn't PCI bridge, they
-* don't have PCI_DN actually. So we have to skip them for
-* any EEH operations.
-*/
-   if (!dn || !PCI_DN(dn))
-   return NULL;
-
-   return PCI_DN(dn)->edev;
-}
-
 static inline struct eeh_dev *pdn_to_eeh_dev(struct pci_dn *pdn)
 {
return pdn ? pdn->edev : NULL;
 }
 #else
-#define of_node_to_eeh_dev(x)  (NULL)
 #define pdn_to_eeh_dev(x)  (NULL)
 #endif
 
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 1fd2566..76253eb 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -418,11 +418,11 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
int ret;
int active_flags = (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
unsigned long flags;
-   struct device_node *dn;
+   struct pci_dn *pdn;
struct pci_dev *dev;
struct eeh_pe *pe, *parent_pe, *phb_pe;
int rc = 0;
-   const char *location;
+   const char *location = NULL;
 
eeh_stats.total_mmio_ffs++;
 
@@ -433,15 +433,14 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
eeh_stats.no_dn++;
return 0;
}
-   dn = eeh_dev_to_of_node(edev);
dev = eeh_dev_to_pci_dev(edev);
pe = eeh_dev_to_pe(edev);
 
/* Access to IO BARs might get this far and still not want checking. */
if (!pe) {
eeh_stats.ignored_check++;
-   pr_debug("EEH: Ignored check for %s %s\n",
-   eeh_pci_name(dev), dn->full_name);
+   pr_debug("EEH: Ignored check for %s\n",
+   eeh_pci_name(dev));
return 0;
}
 
@@ -477,10 +476,13 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
if (pe->state & EEH_PE_ISOLATED) {
pe->check_count++;
if (pe->check_count % EEH_MAX_FAILS == 0) {
-   location = of_get_property(dn, "ibm,loc-code", NULL);
+   pdn = eeh_dev_to_pdn(edev);
+   if (pdn->node)
+   location = of_get_property(pdn->node, 
"ibm,loc-code", NULL);
printk(KERN_ERR "EEH: %d reads ignored for recovering 
device at "
"location=%s driver=%s pci addr=%s\n",
-   pe->check_count, location,
+   pe->check_count,
+   location ? location : "unknown",
eeh_driver_name(dev), eeh_pc

[PATCH v2 5/7] powerpc/eeh: Do probe on pci_dn

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/eeh.h   |  11 +-
 arch/powerpc/kernel/eeh.c|  63 
 arch/powerpc/kernel/of_platform.c|   2 +-
 arch/powerpc/kernel/pci-hotplug.c|   2 +-
 arch/powerpc/platforms/powernv/eeh-powernv.c | 146 ---
 arch/powerpc/platforms/pseries/eeh_pseries.c |  82 ++-
 arch/powerpc/platforms/pseries/pci_dlpar.c   |   2 +-
 drivers/pci/hotplug/rpadlpar_core.c  |   2 +-
 8 files changed, 172 insertions(+), 138 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index bb24172..eefff1f 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -206,8 +206,7 @@ struct eeh_ops {
char *name;
int (*init)(void);
int (*post_init)(void);
-   void* (*of_probe)(struct device_node *dn, void *flag);
-   int (*dev_probe)(struct pci_dev *dev, void *flag);
+   void* (*probe)(struct pci_dn *pdn, void *data);
int (*set_option)(struct eeh_pe *pe, int option);
int (*get_pe_addr)(struct eeh_pe *pe);
int (*get_state)(struct eeh_pe *pe, int *state);
@@ -286,8 +285,8 @@ int __exit eeh_ops_unregister(const char *name);
 int eeh_check_failure(const volatile void __iomem *token);
 int eeh_dev_check_failure(struct eeh_dev *edev);
 void eeh_addr_cache_build(void);
-void eeh_add_device_early(struct device_node *);
-void eeh_add_device_tree_early(struct device_node *);
+void eeh_add_device_early(struct pci_dn *);
+void eeh_add_device_tree_early(struct pci_dn *);
 void eeh_add_device_late(struct pci_dev *);
 void eeh_add_device_tree_late(struct pci_bus *);
 void eeh_add_sysfs_files(struct pci_bus *);
@@ -345,9 +344,9 @@ static inline int eeh_check_failure(const volatile void 
__iomem *token)
 
 static inline void eeh_addr_cache_build(void) { }
 
-static inline void eeh_add_device_early(struct device_node *dn) { }
+static inline void eeh_add_device_early(struct pci_dn *pdn) { }
 
-static inline void eeh_add_device_tree_early(struct device_node *dn) { }
+static inline void eeh_add_device_tree_early(struct pci_dn *pdn) { }
 
 static inline void eeh_add_device_late(struct pci_dev *dev) { }
 
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 19a897c..9504c2f 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -969,7 +969,7 @@ static struct notifier_block eeh_reboot_nb = {
 int eeh_init(void)
 {
struct pci_controller *hose, *tmp;
-   struct device_node *phb;
+   struct pci_dn *pdn;
static int cnt = 0;
int ret = 0;
 
@@ -1004,20 +1004,9 @@ int eeh_init(void)
return ret;
 
/* Enable EEH for all adapters */
-   if (eeh_has_flag(EEH_PROBE_MODE_DEVTREE)) {
-   list_for_each_entry_safe(hose, tmp,
-   &hose_list, list_node) {
-   phb = hose->dn;
-   traverse_pci_devices(phb, eeh_ops->of_probe, NULL);
-   }
-   } else if (eeh_has_flag(EEH_PROBE_MODE_DEV)) {
-   list_for_each_entry_safe(hose, tmp,
-   &hose_list, list_node)
-   pci_walk_bus(hose->bus, eeh_ops->dev_probe, NULL);
-   } else {
-   pr_warn("%s: Invalid probe mode %x",
-   __func__, eeh_subsystem_flags);
-   return -EINVAL;
+   list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
+   pdn = hose->pci_data;
+   traverse_pci_dn(pdn, eeh_ops->probe, NULL);
}
 
/*
@@ -1043,7 +1032,7 @@ core_initcall_sync(eeh_init);
 
 /**
  * eeh_add_device_early - Enable EEH for the indicated device_node
- * @dn: device node for which to set up EEH
+ * @pdn: PCI device node for which to set up EEH
  *
  * This routine must be used to perform EEH initialization for PCI
  * devices that were added after system boot (e.g. hotplug, dlpar).
@@ -1053,44 +1042,41 @@ core_initcall_sync(eeh_init);
  * on the CEC architecture, type of the device, on earlier boot
  * command-line arguments & etc.
  */
-void eeh_add_device_early(struct device_node *dn)
+void eeh_add_device_early(struct pci_dn *pdn)
 {
struct pci_controller *phb;
+   struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
 
-   /*
-* If we're doing EEH probe based on PCI device, we
-* would delay the probe until late stage because
-* the PCI device isn't available this moment.
-  

[PATCH v2 6/7] powerpc/eeh: Replace device_node with pci_dn in eeh_ops

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/eeh.h   |  6 +-
 arch/powerpc/kernel/eeh.c| 40 --
 arch/powerpc/kernel/eeh_pe.c | 82 ++--
 arch/powerpc/platforms/powernv/eeh-powernv.c | 40 ++
 arch/powerpc/platforms/pseries/eeh_pseries.c | 16 ++
 5 files changed, 87 insertions(+), 97 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index eefff1f..2540ad8 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -216,10 +216,10 @@ struct eeh_ops {
int (*configure_bridge)(struct eeh_pe *pe);
int (*err_inject)(struct eeh_pe *pe, int type, int func,
  unsigned long addr, unsigned long mask);
-   int (*read_config)(struct device_node *dn, int where, int size, u32 
*val);
-   int (*write_config)(struct device_node *dn, int where, int size, u32 
val);
+   int (*read_config)(struct pci_dn *pdn, int where, int size, u32 *val);
+   int (*write_config)(struct pci_dn *pdn, int where, int size, u32 val);
int (*next_error)(struct eeh_pe **pe);
-   int (*restore_config)(struct device_node *dn);
+   int (*restore_config)(struct pci_dn *pdn);
 };
 
 extern int eeh_subsystem_flags;
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 9504c2f..1fd2566 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -164,30 +164,34 @@ __setup("eeh=", eeh_setup);
  */
 static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len)
 {
-   struct device_node *dn = eeh_dev_to_of_node(edev);
+   struct pci_dn *pdn = eeh_dev_to_pdn(edev);
u32 cfg;
int cap, i;
int n = 0, l = 0;
char buffer[128];
 
-   n += scnprintf(buf+n, len-n, "%s\n", dn->full_name);
-   pr_warn("EEH: of node=%s\n", dn->full_name);
+   n += scnprintf(buf+n, len-n, "%04x:%02x:%02x:%01x\n",
+  edev->phb->global_number, pdn->busno,
+  PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
+   pr_warn("EEH: of node=%04x:%02x:%02x:%01x\n",
+   edev->phb->global_number, pdn->busno,
+   PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
 
-   eeh_ops->read_config(dn, PCI_VENDOR_ID, 4, &cfg);
+   eeh_ops->read_config(pdn, PCI_VENDOR_ID, 4, &cfg);
n += scnprintf(buf+n, len-n, "dev/vend:%08x\n", cfg);
pr_warn("EEH: PCI device/vendor: %08x\n", cfg);
 
-   eeh_ops->read_config(dn, PCI_COMMAND, 4, &cfg);
+   eeh_ops->read_config(pdn, PCI_COMMAND, 4, &cfg);
n += scnprintf(buf+n, len-n, "cmd/stat:%x\n", cfg);
pr_warn("EEH: PCI cmd/status register: %08x\n", cfg);
 
/* Gather bridge-specific registers */
if (edev->mode & EEH_DEV_BRIDGE) {
-   eeh_ops->read_config(dn, PCI_SEC_STATUS, 2, &cfg);
+   eeh_ops->read_config(pdn, PCI_SEC_STATUS, 2, &cfg);
n += scnprintf(buf+n, len-n, "sec stat:%x\n", cfg);
pr_warn("EEH: Bridge secondary status: %04x\n", cfg);
 
-   eeh_ops->read_config(dn, PCI_BRIDGE_CONTROL, 2, &cfg);
+   eeh_ops->read_config(pdn, PCI_BRIDGE_CONTROL, 2, &cfg);
n += scnprintf(buf+n, len-n, "brdg ctl:%x\n", cfg);
pr_warn("EEH: Bridge control: %04x\n", cfg);
}
@@ -195,11 +199,11 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char 
*buf, size_t len)
/* Dump out the PCI-X command and status regs */
cap = edev->pcix_cap;
if (cap) {
-   eeh_ops->read_config(dn, cap, 4, &cfg);
+   eeh_ops->read_config(pdn, cap, 4, &cfg);
n += scnprintf(buf+n, len-n, "pcix-cmd:%x\n", cfg);
pr_warn("EEH: PCI-X cmd: %08x\n", cfg);
 
-   eeh_ops->read_config(dn, cap+4, 4, &cfg);
+   eeh_ops->read_config(pdn, cap+4, 4, &cfg);
n += scnprintf(buf+n, len-n, "pcix-stat:%x\n", cfg);
pr_warn("EEH: PCI-X status: %08x\n", cfg);
}
@@ -211,7 +215,7 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char 
*buf, size_t len)
pr_warn("EEH: PCI-E capabilities and status follow:\n");
 
for (i=0; i<=8; i++) {
-   eeh_ops->read_config(dn, cap+4*i, 4, &cfg);
+   eeh_ops->read_config(pdn, cap+4*i, 4, &cfg);
n += scnprintf(buf+n, len-n, "%02x:%x\n", 4*i, cfg);
 
if ((i % 4) == 0) {
@@ -238,7 +242,7 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char 
*buf, size_t len)
pr_warn("EEH: PCI-E AER capability register set follows:\n");
 
for (i=0; i<=13; i++) {
-   eeh

[PATCH v2 2/7] powerpc/powernv: Use pci_dn, not device_node, in PCI config accessor

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/platforms/powernv/eeh-powernv.c | 14 +-
 arch/powerpc/platforms/powernv/pci.c | 69 +++-
 arch/powerpc/platforms/powernv/pci.h |  4 +-
 3 files changed, 40 insertions(+), 47 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c 
b/arch/powerpc/platforms/powernv/eeh-powernv.c
index ede6906..8eac8c5 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -1038,21 +1038,31 @@ static inline bool pnv_eeh_cfg_blocked(struct 
device_node *dn)
 static int pnv_eeh_read_config(struct device_node *dn,
   int where, int size, u32 *val)
 {
+   struct pci_dn *pdn = PCI_DN(dn);
+
+   if (!pdn)
+   return PCIBIOS_DEVICE_NOT_FOUND;
+
if (pnv_eeh_cfg_blocked(dn)) {
*val = 0x;
return PCIBIOS_SET_FAILED;
}
 
-   return pnv_pci_cfg_read(dn, where, size, val);
+   return pnv_pci_cfg_read(pdn, where, size, val);
 }
 
 static int pnv_eeh_write_config(struct device_node *dn,
int where, int size, u32 val)
 {
+   struct pci_dn *pdn = PCI_DN(dn);
+
+   if (!pdn)
+   return PCIBIOS_DEVICE_NOT_FOUND;
+
if (pnv_eeh_cfg_blocked(dn))
return PCIBIOS_SET_FAILED;
 
-   return pnv_pci_cfg_write(dn, where, size, val);
+   return pnv_pci_cfg_write(pdn, where, size, val);
 }
 
 static void pnv_eeh_dump_hub_diag_common(struct OpalIoP7IOCErrorData *data)
diff --git a/arch/powerpc/platforms/powernv/pci.c 
b/arch/powerpc/platforms/powernv/pci.c
index 54323d6..946aa3d 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -366,9 +366,9 @@ static void pnv_pci_handle_eeh_config(struct pnv_phb *phb, 
u32 pe_no)
spin_unlock_irqrestore(&phb->lock, flags);
 }
 
-static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
-struct device_node *dn)
+static void pnv_pci_config_check_eeh(struct pci_dn *pdn)
 {
+   struct pnv_phb *phb = pdn->phb->private_data;
u8  fstate;
__be16  pcierr;
int pe_no;
@@ -379,7 +379,7 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
 * setup that yet. So all ER errors should be mapped to
 * reserved PE.
 */
-   pe_no = PCI_DN(dn)->pe_number;
+   pe_no = pdn->pe_number;
if (pe_no == IODA_INVALID_PE) {
if (phb->type == PNV_PHB_P5IOC2)
pe_no = 0;
@@ -407,8 +407,7 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
}
 
cfg_dbg(" -> EEH check, bdfn=%04x PE#%d fstate=%x\n",
-   (PCI_DN(dn)->busno << 8) | (PCI_DN(dn)->devfn),
-   pe_no, fstate);
+   (pdn->busno << 8) | (pdn->devfn), pe_no, fstate);
 
/* Clear the frozen state if applicable */
if (fstate == OPAL_EEH_STOPPED_MMIO_FREEZE ||
@@ -425,10 +424,9 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
}
 }
 
-int pnv_pci_cfg_read(struct device_node *dn,
+int pnv_pci_cfg_read(struct pci_dn *pdn,
 int where, int size, u32 *val)
 {
-   struct pci_dn *pdn = PCI_DN(dn);
struct pnv_phb *phb = pdn->phb->private_data;
u32 bdfn = (pdn->busno << 8) | pdn->devfn;
s64 rc;
@@ -462,10 +460,9 @@ int pnv_pci_cfg_read(struct device_node *dn,
return PCIBIOS_SUCCESSFUL;
 }
 
-int pnv_pci_cfg_write(struct device_node *dn,
+int pnv_pci_cfg_write(struct pci_dn *pdn,
  int where, int size, u32 val)
 {
-   struct pci_dn *pdn = PCI_DN(dn);
struct pnv_phb *phb = pdn->phb->private_data;
u32 bdfn = (pdn->busno << 8) | pdn->devfn;
 
@@ -489,18 +486,17 @@ int pnv_pci_cfg_write(struct device_node *dn,
 }
 
 #if CONFIG_EEH
-static bool pnv_pci_cfg_check(struct pci_controller *hose,
- struct device_node *dn)
+static bool pnv_pci_cfg_check(struct pci_dn *pdn)
 {
struct eeh_dev *edev = NULL;
-   struct pnv_phb *phb = hose->private_data;
+   struct pnv_phb *phb = pdn->phb->private_data;
 
/* EEH not enabled ? */
if (!(phb->flags & PNV_PHB_FLAG_EEH))
return true;
 
/* PE reset or device removed ? */
-   edev = of_node_to_eeh_dev(dn);
+   edev = pdn->edev;
if (edev) {
if (edev->pe &&
(edev->pe->state & EEH_PE_CFG_BLOCKED))
@@ -513,8 +509,7 @@ static bool pnv_pci_cfg_check(struct pci_controller *hose,
return true;
 }
 #else
-static inline pnv_pci_cfg_check(struct pci_controller *hose,
-   struct device_node *dn)
+static inl

[PATCH v2 3/7] powerpc/pci: Trace more information from pci_dn

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/pci-bridge.h |  3 +++
 arch/powerpc/kernel/pci_dn.c  | 10 ++
 2 files changed, 13 insertions(+)

diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 706710b..01b730a 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -159,6 +159,9 @@ struct pci_dn {
 
int busno;  /* pci bus number */
int devfn;  /* pci device and function number */
+   int vendor_id;  /* Vendor ID */
+   int device_id;  /* Device ID */
+   int class_code; /* Device class code */
 
struct  pci_dn *parent;
struct  pci_controller *phb;/* for pci devices */
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index 0ab2dad..d139f72f 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -166,6 +166,15 @@ void *update_dn_pci_info(struct device_node *dn, void 
*data)
pdn->devfn = (addr >> 8) & 0xff;
}
 
+   /* vendor/device IDs and class code */
+   regs = of_get_property(dn, "vendor-id", NULL);
+   pdn->vendor_id = regs ? of_read_number(regs, 1) : 0;
+   regs = of_get_property(dn, "device-id", NULL);
+   pdn->device_id = regs ? of_read_number(regs, 1) : 0;
+   regs = of_get_property(dn, "class-code", NULL);
+   pdn->class_code = regs ? of_read_number(regs, 1) : 0;
+
+   /* Extended config space */
pdn->pci_ext_config_space = (type && of_read_number(type, 1) == 1);
 
/* Attach to parent node */
@@ -255,6 +264,7 @@ void pci_devs_phb_init_dynamic(struct pci_controller *phb)
pdn = dn->data;
if (pdn) {
pdn->devfn = pdn->busno = -1;
+   pdn->vendor_id = pdn->device_id = pdn->class_code = 0;
pdn->phb = phb;
phb->pci_data = pdn;
}
-- 
1.8.3.2

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

[PATCH v2 4/7] powerpc/eeh: Create eeh_dev from pci_dn instead of device_node

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/eeh.h | 10 +++--
 arch/powerpc/include/asm/pci-bridge.h  |  8 ++-
 arch/powerpc/include/asm/ppc-pci.h |  3 +++
 arch/powerpc/kernel/eeh_dev.c  | 14 ++--
 arch/powerpc/kernel/pci_dn.c   | 40 ++
 arch/powerpc/platforms/pseries/setup.c |  2 +-
 6 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 55abfd0..bb24172 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -137,6 +137,7 @@ struct eeh_dev {
struct list_head list;  /* Form link list in the PE */
struct pci_controller *phb; /* Associated PHB   */
struct device_node *dn; /* Associated device node   */
+   struct pci_dn *pdn; /* Associated PCI device node   */
struct pci_dev *pdev;   /* Associated PCI device*/
struct pci_bus *bus;/* PCI bus for partial hotplug  */
 };
@@ -146,6 +147,11 @@ static inline struct device_node 
*eeh_dev_to_of_node(struct eeh_dev *edev)
return edev ? edev->dn : NULL;
 }
 
+static inline struct pci_dn *eeh_dev_to_pdn(struct eeh_dev *edev)
+{
+   return edev ? edev->pdn : NULL;
+}
+
 static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev)
 {
return edev ? edev->pdev : NULL;
@@ -272,7 +278,7 @@ void eeh_pe_restore_bars(struct eeh_pe *pe);
 const char *eeh_pe_loc_get(struct eeh_pe *pe);
 struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe);
 
-void *eeh_dev_init(struct device_node *dn, void *data);
+void *eeh_dev_init(struct pci_dn *pdn, void *data);
 void eeh_dev_phb_init_dynamic(struct pci_controller *phb);
 int eeh_init(void);
 int __init eeh_ops_register(struct eeh_ops *ops);
@@ -323,7 +329,7 @@ static inline int eeh_init(void)
return 0;
 }
 
-static inline void *eeh_dev_init(struct device_node *dn, void *data)
+static inline void *eeh_dev_init(struct pci_dn *pdn, void *data)
 {
return NULL;
 }
diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 01b730a..7b74499 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -213,8 +213,14 @@ static inline struct eeh_dev *of_node_to_eeh_dev(struct 
device_node *dn)
 
return PCI_DN(dn)->edev;
 }
+
+static inline struct eeh_dev *pdn_to_eeh_dev(struct pci_dn *pdn)
+{
+   return pdn ? pdn->edev : NULL;
+}
 #else
-#define of_node_to_eeh_dev(x) (NULL)
+#define of_node_to_eeh_dev(x)  (NULL)
+#define pdn_to_eeh_dev(x)  (NULL)
 #endif
 
 /** Find the bus corresponding to the indicated device node */
diff --git a/arch/powerpc/include/asm/ppc-pci.h 
b/arch/powerpc/include/asm/ppc-pci.h
index db1e2b8..eef127e 100644
--- a/arch/powerpc/include/asm/ppc-pci.h
+++ b/arch/powerpc/include/asm/ppc-pci.h
@@ -36,6 +36,9 @@ struct device_node;
 typedef void *(*traverse_func)(struct device_node *me, void *data);
 void *traverse_pci_devices(struct device_node *start, traverse_func pre,
void *data);
+void *traverse_pci_dn(struct pci_dn *root,
+ void *(*fn)(struct pci_dn *, void *),
+ void *data);
 
 extern void pci_devs_phb_init(void);
 extern void pci_devs_phb_init_dynamic(struct pci_controller *phb);
diff --git a/arch/powerpc/kernel/eeh_dev.c b/arch/powerpc/kernel/eeh_dev.c
index e5274ee..aabba94 100644
--- a/arch/powerpc/kernel/eeh_dev.c
+++ b/arch/powerpc/kernel/eeh_dev.c
@@ -43,13 +43,13 @@
 
 /**
  * eeh_dev_init - Create EEH device according to OF node
- * @dn: device node
+ * @pdn: PCI device node
  * @data: PHB
  *
  * It will create EEH device according to the given OF node. The function
  * might be called by PCI emunation, DR, PHB hotplug.
  */
-void *eeh_dev_init(struct device_node *dn, void *data)
+void *eeh_dev_init(struct pci_dn *pdn, void *data)
 {
struct pci_controller *phb = data;
struct eeh_dev *edev;
@@ -63,8 +63,8 @@ void *eeh_dev_init(struct device_node *dn, void *data)
}
 
/* Associate EEH device with OF node */
-   PCI_DN(dn)->edev = edev;
-   edev->dn  = dn;
+   pdn->edev = edev;
+   edev->pdn = pdn;
edev->phb = phb;
INIT_LIST_HEAD(&edev->list);
 
@@ -80,16 +80,16 @@ void *eeh_dev_init(struct device_node *dn, void *data)
  */
 void eeh_dev_phb_init_dynamic(struct pci_controller *phb)
 {
-   struct device_node *dn = phb->dn;
+   struct pci_dn *root = phb->pci_data;
 
/* EEH PE for PHB */
eeh_phb_pe_create(phb);
 
/* EEH device for PHB */
-   eeh_dev_init(dn, phb);
+   eeh_dev_init(root, phb);
 

[PATCH v2 1/7] powerpc/pci: Refactor pci_dn

2015-03-16 Thread Gavin Shan
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 
---
v2: Put SRIOV related logic into separate patch. "struct pci_controller"
and "struct dev_archdata" dereferences "struct pci_dn *pci_data",
not "void *firmware_data".
---
 arch/powerpc/include/asm/device.h |   6 ++
 arch/powerpc/include/asm/pci-bridge.h |  11 ++-
 arch/powerpc/kernel/pci_dn.c  | 130 --
 3 files changed, 141 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/device.h 
b/arch/powerpc/include/asm/device.h
index 38faede..9f1371b 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -8,6 +8,9 @@
 
 struct dma_map_ops;
 struct device_node;
+#ifdef CONFIG_PPC64
+struct pci_dn;
+#endif
 
 /*
  * Arch extensions to struct device.
@@ -34,6 +37,9 @@ struct dev_archdata {
 #ifdef CONFIG_SWIOTLB
dma_addr_t  max_direct_dma_addr;
 #endif
+#ifdef CONFIG_PPC64
+   struct pci_dn   *pci_data;
+#endif
 #ifdef CONFIG_EEH
struct eeh_dev  *edev;
 #endif
diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 546d036..706710b 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -89,6 +89,7 @@ struct pci_controller {
 
 #ifdef CONFIG_PPC64
unsigned long buid;
+   struct pci_dn *pci_data;
 #endif /* CONFIG_PPC64 */
 
void *private_data;
@@ -154,9 +155,12 @@ static inline int isa_vaddr_is_ioport(void __iomem 
*address)
 struct iommu_table;
 
 struct pci_dn {
+   int flags;
+
int busno;  /* pci bus number */
int devfn;  /* pci device and function number */
 
+   struct  pci_dn *parent;
struct  pci_controller *phb;/* for pci devices */
struct  iommu_table *iommu_table;   /* for phb's or bridges */
struct  device_node *node;  /* back-pointer to the device_node */
@@ -171,14 +175,17 @@ struct pci_dn {
 #ifdef CONFIG_PPC_POWERNV
int pe_number;
 #endif
+   struct list_head child_list;
+   struct list_head list;
 };
 
 /* Get the pointer to a device_node's pci_dn */
 #define PCI_DN(dn) ((struct pci_dn *) (dn)->data)
 
+extern struct pci_dn *pci_get_pdn_by_devfn(struct pci_bus *bus,
+  int devfn);
 extern struct pci_dn *pci_get_pdn(struct pci_dev *pdev);
-
-extern void * update_dn_pci_info(struct device_node *dn, void *data);
+extern void *update_dn_pci_info(struct device_node *dn, void *data);
 
 static inline int pci_device_from_OF_node(struct device_node *np,
  u8 *bus, u8 *devfn)
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index 83df307..0ab2dad 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -32,12 +32,108 @@
 #include 
 #include 
 
+/*
+ * The function is used to find the firmware data of one
+ * specific PCI device, which is attached to the indicated
+ * PCI bus. For VFs, their firmware data is linked to that
+ * one of PF's bridge. For other devices, their firmware
+ * data is linked to that of their bridge.
+ */
+static struct pci_dn *pci_bus_to_pdn(struct pci_bus *bus)
+{
+   struct pci_bus *pbus;
+   struct device_node *dn;
+   struct pci_dn *pdn;
+
+   /*
+* We probably have virtual bus which doesn't
+* have associated bridge.
+*/
+   pbus = bus;
+   while (pbus) {
+   if (pci_is_root_bus(pbus) || pbus->self)
+   break;
+
+   pbus = pbus->parent;
+   }
+
+   /*
+* Except virtual bus, all PCI buses should
+* have device nodes.
+*/
+   dn = pci_bus_to_OF_node(pbus);
+   pdn = dn ? PCI_DN(dn) : NULL;
+
+   return pdn;
+}
+
+struct pci_dn *pci_get_pdn_by_devfn(struct pci_bus *bus,
+   int devfn)
+{
+   struct device_node *dn = NULL;
+   struct pci_dn *parent, *pdn;
+   struct pci_dev *pdev = NULL;
+
+   /* Fast path: fetch

[PATCH v2 0/7] powerpc/eeh: Refactor to use pci_dn

2015-03-16 Thread Gavin Shan
powerpc/eeh: Refactor to use pci_dn

Currently, EEH depends on device_node or pci_dev heavily. Unfortunately,
SRIOV VFs are supported depending on pci_dn heavily, which is conflicting
with EEH implementation. In order for better support EEH on SRIOV VF, the
EEH is better to be changed a bit to depend on pci_dn, which is exactly
what the patchset does.

The patchset is expected to merged after the patchset "EEH cleanup to
remove chip layer for PowerNV", before "SRIOV patchset". The first two
patches are extracted from SRIOV patchset to make this patchset
self-contained.

Changelog
=
v1 -> v2:
* Remove SRIOV PF/VFs related logics in pci_dn.c and the flag for
  VF's pci_dn in pci-bridge.h;
* Dereference "struct pci_dn *pci_data", not "void *firmware_data"
  from "struct dev_archdata" and "struct pci_controller";
* Move changes to eeh_restore_dev_state() from PATCH[7/7] to
  PATCH[6/7] to avoid build error caused by PATCH[6/7];

Gavin Shan (7):
  powerpc/pci: Refactor pci_dn
  powerpc/powernv: Use pci_dn, not device_node, in PCI config accessor
  powerpc/pci: Trace more information from pci_dn
  powerpc/eeh: Create eeh_dev from pci_dn instead of device_node
  powerpc/eeh: Do probe on pci_dn
  powerpc/eeh: Replace device_node with pci_dn in eeh_ops
  powerpc/eeh: Remove device_node dependency

 arch/powerpc/include/asm/device.h|   6 +
 arch/powerpc/include/asm/eeh.h   |  28 ++--
 arch/powerpc/include/asm/pci-bridge.h|  28 ++--
 arch/powerpc/include/asm/ppc-pci.h   |   3 +
 arch/powerpc/kernel/eeh.c| 127 --
 arch/powerpc/kernel/eeh_cache.c  |  25 ++--
 arch/powerpc/kernel/eeh_dev.c|  14 +-
 arch/powerpc/kernel/eeh_driver.c |  22 ---
 arch/powerpc/kernel/eeh_pe.c | 116 +---
 arch/powerpc/kernel/of_platform.c|   2 +-
 arch/powerpc/kernel/pci-hotplug.c|   2 +-
 arch/powerpc/kernel/pci_dn.c | 180 -
 arch/powerpc/kernel/pci_of_scan.c|   2 +-
 arch/powerpc/kernel/rtas_pci.c   |   2 +-
 arch/powerpc/platforms/powernv/eeh-powernv.c | 192 +++
 arch/powerpc/platforms/powernv/pci.c |  69 --
 arch/powerpc/platforms/powernv/pci.h |   4 +-
 arch/powerpc/platforms/pseries/eeh_pseries.c |  98 +-
 arch/powerpc/platforms/pseries/msi.c |   6 +-
 arch/powerpc/platforms/pseries/pci_dlpar.c   |   2 +-
 arch/powerpc/platforms/pseries/setup.c   |   2 +-
 drivers/pci/hotplug/rpadlpar_core.c  |   2 +-
 22 files changed, 563 insertions(+), 369 deletions(-)

-- 
1.8.3.2

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

Re: [PATCH 0/7] powerpc/eeh: Refactor to use pci_dn

2015-03-16 Thread Gavin Shan
On Tue, Mar 17, 2015 at 12:37:17PM +1100, Gavin Shan wrote:

Please ignore this and v2 with more changes according to Ben's comments
is on the way.

Thanks,
Gavin

>Currently, EEH depends on device_node or pci_dev heavily. Unfortunately,
>SRIOV VFs are supported depending on pci_dn heavily, which is conflicting
>with EEH implementation. In order for better support EEH on SRIOV VF, the
>EEH is better to be changed a bit to depend on pci_dn, which is exactly
>what the patchset does.
>
>The patchset is expected to merged after the patchset "EEH cleanup to
>remove chip layer for PowerNV", before "SRIOV patchset". The first two
>patches are extracted from SRIOV patchset to make this patchset
>self-contained.
>
>Gavin Shan (7):
>  powerpc/pci: Refactor pci_dn
>  powerpc/powernv: Use pci_dn, not device_node, in PCI config accessor
>  powerpc/pci: Trace more information from pci_dn
>  powerpc/eeh: Create eeh_dev from pci_dn instead of device_node
>  powerpc/eeh: Do probe on pci_dn
>  powerpc/eeh: Replace device_node with pci_dn in eeh_ops
>  powerpc/eeh: Remove device_node dependency
>
> arch/powerpc/include/asm/device.h|   3 +
> arch/powerpc/include/asm/eeh.h   |  28 ++-
> arch/powerpc/include/asm/pci-bridge.h|  31 +--
> arch/powerpc/include/asm/ppc-pci.h   |   3 +
> arch/powerpc/kernel/eeh.c| 127 +---
> arch/powerpc/kernel/eeh_cache.c  |  25 +--
> arch/powerpc/kernel/eeh_dev.c|  14 +-
> arch/powerpc/kernel/eeh_driver.c |  22 --
> arch/powerpc/kernel/eeh_pe.c | 116 ++-
> arch/powerpc/kernel/of_platform.c|   2 +-
> arch/powerpc/kernel/pci-hotplug.c|   2 +-
> arch/powerpc/kernel/pci_dn.c | 295 ++-
> arch/powerpc/kernel/pci_of_scan.c|   2 +-
> arch/powerpc/kernel/rtas_pci.c   |   2 +-
> arch/powerpc/platforms/powernv/eeh-powernv.c | 192 -
> arch/powerpc/platforms/powernv/pci-ioda.c|  16 ++
> arch/powerpc/platforms/powernv/pci.c |  69 +++
> arch/powerpc/platforms/powernv/pci.h |   4 +-
> arch/powerpc/platforms/pseries/eeh_pseries.c |  98 -
> arch/powerpc/platforms/pseries/msi.c |   6 +-
> arch/powerpc/platforms/pseries/pci_dlpar.c   |   2 +-
> arch/powerpc/platforms/pseries/setup.c   |   2 +-
> drivers/pci/hotplug/rpadlpar_core.c  |   2 +-
> 23 files changed, 694 insertions(+), 369 deletions(-)
>
>-- 
>1.8.3.2
>

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

[PATCH v4 5/5] selftests/powerpc: Add test for VPHN

2015-03-16 Thread Michael Ellerman
From: Greg Kurz 

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 
[mpe: Rework harness logic and rename to test-vphn]
Signed-off-by: Michael Ellerman 
---

I reworked this a little bit, let me know if it looks OK to you.

I renamed the test to test-vphn, and I changed the test loop to only call the
harness once, but report all the individual test results as well.


 tools/testing/selftests/powerpc/Makefile |   2 +-
 tools/testing/selftests/powerpc/utils.h  |   1 +
 tools/testing/selftests/powerpc/vphn/.gitignore  |   1 +
 tools/testing/selftests/powerpc/vphn/Makefile|  13 +
 tools/testing/selftests/powerpc/vphn/test-vphn.c | 410 +++
 tools/testing/selftests/powerpc/vphn/vphn.c  |   1 +
 tools/testing/selftests/powerpc/vphn/vphn.h  |   1 +
 7 files changed, 428 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/powerpc/vphn/.gitignore
 create mode 100644 tools/testing/selftests/powerpc/vphn/Makefile
 create mode 100644 tools/testing/selftests/powerpc/vphn/test-vphn.c
 create mode 12 tools/testing/selftests/powerpc/vphn/vphn.c
 create mode 12 tools/testing/selftests/powerpc/vphn/vphn.h

diff --git a/tools/testing/selftests/powerpc/Makefile 
b/tools/testing/selftests/powerpc/Makefile
index 1d5e7ad2c460..476b8dd9275f 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -13,7 +13,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror 
-DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR
 
 export CC CFLAGS
 
-TARGETS = pmu copyloops mm tm primitives stringloops
+TARGETS = pmu copyloops mm tm primitives stringloops vphn
 
 endif
 
diff --git a/tools/testing/selftests/powerpc/utils.h 
b/tools/testing/selftests/powerpc/utils.h
index a93777ae0684..2ec455e37792 100644
--- a/tools/testing/selftests/powerpc/utils.h
+++ b/tools/testing/selftests/powerpc/utils.h
@@ -15,6 +15,7 @@ typedef   signed long long s64;
 
 /* Just for familiarity */
 typedef uint32_t u32;
+typedef uint16_t u16;
 typedef uint8_t u8;
 
 
diff --git a/tools/testing/selftests/powerpc/vphn/.gitignore 
b/tools/testing/selftests/powerpc/vphn/.gitignore
new file mode 100644
index ..dd3039a0f638
--- /dev/null
+++ b/tools/testing/selftests/powerpc/vphn/.gitignore
@@ -0,0 +1 @@
+parse-vphn
diff --git a/tools/testing/selftests/powerpc/vphn/Makefile 
b/tools/testing/selftests/powerpc/vphn/Makefile
new file mode 100644
index ..4bce3ca9d140
--- /dev/null
+++ b/tools/testing/selftests/powerpc/vphn/Makefile
@@ -0,0 +1,13 @@
+PROG := test-vphn
+
+all: $(PROG)
+
+$(PROG): ../harness.c
+
+run_tests: all
+   ./$(PROG)
+
+clean:
+   rm -f $(PROG)
+
+.PHONY: all run_tests clean
diff --git a/tools/testing/selftests/powerpc/vphn/test-vphn.c 
b/tools/testing/selftests/powerpc/vphn/test-vphn.c
new file mode 100644
index ..5742f6876b25
--- /dev/null
+++ b/tools/testing/selftests/powerpc/vphn/test-vphn.c
@@ -0,0 +1,410 @@
+#include 
+#include 
+#include "utils.h"
+#include "subunit.h"
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define cpu_to_be32(x) bswap_32(x)
+#define be32_to_cpu(x) bswap_32(x)
+#define be16_to_cpup(x)bswap_16(*x)
+#define cpu_to_be64(x) bswap_64(x)
+#else
+#define cpu_to_be32(x) (x)
+#define be32_to_cpu(x) (x)
+#define be16_to_cpup(x)(*x)
+#define cpu_to_be64(x) (x)
+#endif
+
+#include "vphn.c"
+
+static struct test {
+   char *descr;
+   long input[VPHN_REGISTER_COUNT];
+   u32 expected[VPHN_ASSOC_BUFSIZE];
+} all_tests[] = {
+   {
+   "vphn: no data",
+   {
+   0x,
+   0x,
+   0x,
+   0x,
+   0x,
+   0x,
+   },
+   {
+   0x
+   }
+   },
+   {
+   "vphn: 1 x 16-bit value",
+   {
+   0x8001,
+   0x,
+   0x,
+   0x,
+   0x,
+   0x,
+   },
+   {
+   0x0001,
+   0x0001
+   }
+   },
+   {
+   "vphn: 2 x 16-bit values",
+   {
+   0x80018002,
+   0x,
+   0xf

[PATCH RFC v2] powerpc/powernv: Introduce kernel param to control fastsleep workaround behavior

2015-03-16 Thread Shreyas B. Prabhu
Fastsleep is one of the idle state which cpuidle subsystem currently
uses on power8 machines. In this state L2 cache is brought down to a
threshold voltage. Therefore when the core is in fastsleep, the
communication between L2 and L3 needs to be fenced. But there is a bug
in the current power8 chips surrounding this fencing. OPAL provides an
interface to workaround this bug, and in the current implementation,
every time before a core enters fastsleep OPAL call is made to 'apply'
the workarond and when the core wakes up from fastsleep OPAL call is
made to 'undo' the workaround. These OPAL calls account for roughly
4000 cycles everytime the core has to enter or wakeup from fastsleep.
The other alternative is to apply this workaround once at boot, and not
undo it at all. While this would quicken fastsleep entry/wakeup path,
downside is, any correctable error detected in L2 directory will result
in a checkstop.

This patch adds a new kernel paramerter
pnv_fastsleep_workaround_once, which can be used to override
the default behavior and apply the workaround once at boot and not undo
it.

Signed-off-by: Shreyas B. Prabhu 
CC: Michael Ellerman 
CC: Paul Mackerras 
CC: Benjamin Herrenschmidt 
CC: linuxppc-dev@lists.ozlabs.org
---
Changes in v2:
--
Accurately describes the downside of running workaround always applied.

 Documentation/kernel-parameters.txt|  4 +++
 arch/powerpc/include/asm/opal.h|  8 +
 arch/powerpc/platforms/powernv/opal-wrappers.S |  1 +
 arch/powerpc/platforms/powernv/setup.c | 45 +-
 4 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index bfcb1a6..006863b 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2857,6 +2857,10 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
autoconfiguration.
Ranges are in pairs (memory base and size).
 
+   pnv_fastsleep_workaround_once=
+   [BUGS=ppc64] Tells kernel to apply fastsleep workaround
+   once at boot.
+
ports=  [IP_VS_FTP] IPVS ftp helper module
Default is 21.
Up to 8 (IP_VS_APP_MAX_PORTS) ports
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 9ee0a30..8bea8fc 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -180,6 +180,13 @@ struct opal_sg_list {
 #define OPAL_PM_WINKLE_ENABLED 0x0004
 #define OPAL_PM_SLEEP_ENABLED_ER1  0x0008
 
+/*
+ * OPAL_CONFIG_CPU_IDLE_STATE parameters
+ */
+#define OPAL_CONFIG_IDLE_FASTSLEEP 1
+#define OPAL_CONFIG_IDLE_UNDO  0
+#define OPAL_CONFIG_IDLE_APPLY 1
+
 #ifndef __ASSEMBLY__
 
 #include 
@@ -924,6 +931,7 @@ int64_t opal_handle_hmi(void);
 int64_t opal_register_dump_region(uint32_t id, uint64_t start, uint64_t end);
 int64_t opal_unregister_dump_region(uint32_t id);
 int64_t opal_slw_set_reg(uint64_t cpu_pir, uint64_t sprn, uint64_t val);
+int64_t opal_config_cpu_idle_state(uint64_t state, uint64_t flag);
 int64_t opal_pci_set_phb_cxl_mode(uint64_t phb_id, uint64_t mode, uint64_t 
pe_number);
 int64_t opal_ipmi_send(uint64_t interface, struct opal_ipmi_msg *msg,
uint64_t msg_len);
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S 
b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 0509bca..84a20bb 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -283,6 +283,7 @@ OPAL_CALL(opal_sensor_read, 
OPAL_SENSOR_READ);
 OPAL_CALL(opal_get_param,  OPAL_GET_PARAM);
 OPAL_CALL(opal_set_param,  OPAL_SET_PARAM);
 OPAL_CALL(opal_handle_hmi, OPAL_HANDLE_HMI);
+OPAL_CALL(opal_config_cpu_idle_state,  OPAL_CONFIG_CPU_IDLE_STATE);
 OPAL_CALL(opal_slw_set_reg,OPAL_SLW_SET_REG);
 OPAL_CALL(opal_register_dump_region,   OPAL_REGISTER_DUMP_REGION);
 OPAL_CALL(opal_unregister_dump_region, OPAL_UNREGISTER_DUMP_REGION);
diff --git a/arch/powerpc/platforms/powernv/setup.c 
b/arch/powerpc/platforms/powernv/setup.c
index d2de7d5..21dde6c 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -405,6 +406,20 @@ u32 pnv_get_supported_cpuidle_states(void)
 }
 EXPORT_SYMBOL_GPL(pnv_get_supported_cpuidle_states);
 
+u8 pnv_apply_fastsleep_workaround_once;
+
+static int __init pnv_fastsleep_workaround_once(char *str)
+{
+   pnv_apply_fastsleep_workaround_once = 1;
+   return 0;
+}
+early_param("pnv_fastsleep_workaround_once", pnv_fastsleep_workaround_once);
+
+static void __init pnv_fastsleep_workaround_apply(void *info)
+{

Re: linux panic on 4.0.0-rc4

2015-03-16 Thread Peter Hurley
On 03/16/2015 11:12 PM, Pranith Kumar wrote:
> On Mon, Mar 16, 2015 at 10:58 PM, Peter Hurley  
> wrote:
 What is your init?
>>>
>>> I am using systemd from debian unstable.
>>
>> Do you have a stdout-path property defined in your dts to a serial
>> console you're not actually using?
>>
> 
> I am using tty0 as my console. From the config which I posted, it has:
> 
> CONFIG_CMDLINE="console=ttyS0,9600 console=tty0"
> 
> I am not using any device tree file.

Ok; there was some reported breakage on PowerMac wrt to 'stdout-path'
changes I made, so I thought I'd check if that might have affected
your setup as well.

Regards,
Peter Hurley

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

Re: linux panic on 4.0.0-rc4

2015-03-16 Thread Pranith Kumar
On Mon, Mar 16, 2015 at 10:58 PM, Peter Hurley  wrote:
>>> What is your init?
>>
>> I am using systemd from debian unstable.
>
> Do you have a stdout-path property defined in your dts to a serial
> console you're not actually using?
>

I am using tty0 as my console. From the config which I posted, it has:

CONFIG_CMDLINE="console=ttyS0,9600 console=tty0"

I am not using any device tree file.
-- 
Pranith
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH kernel v6 26/29] vfio: powerpc/spapr: Define v2 IOMMU

2015-03-16 Thread Alexey Kardashevskiy

On 03/17/2015 06:45 AM, Alex Williamson wrote:

On Fri, 2015-03-13 at 19:07 +1100, Alexey Kardashevskiy wrote:

The existing IOMMU requires VFIO_IOMMU_ENABLE call to enable actual use
of the container (i.e. call DMA map/unmap) and this is where we check
the rlimit for locked pages. It assumes that only as much memory
as a default DMA window can be mapped. Every DMA map/unmap request will
do pinning/unpinning of physical pages.

New IOMMU will split physical pages pinning and TCE table update.
It will require guest pages to be registered first and consequent
map/unmap requests to work only with pre-registered memory.
For the default single window case this means that the entire guest
(instead of 2GB) needs to be pinned before using VFIO.
However when a huge DMA window is added, no additional pinning will be
required, otherwise it would be guest RAM + 2GB.

This advertises v2 SPAPR TCE IOMMU and restricts what the userspace
can do with v1 or v2 IOMMUs.

Signed-off-by: Alexey Kardashevskiy 
---
Changes:
v6:
* enforced limitations imposed by the SPAPR TCE IOMMU version
---
  drivers/vfio/vfio_iommu_spapr_tce.c | 18 +-
  include/uapi/linux/vfio.h   |  2 ++
  2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c 
b/drivers/vfio/vfio_iommu_spapr_tce.c
index 9d240b4..e191438 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -95,6 +95,7 @@ struct tce_container {
bool enabled;
unsigned long locked_pages;
struct list_head mem_list;
+   bool v2;
  };

  struct tce_memory {
@@ -398,7 +399,7 @@ static void *tce_iommu_open(unsigned long arg)
  {
struct tce_container *container;

-   if (arg != VFIO_SPAPR_TCE_IOMMU) {
+   if ((arg != VFIO_SPAPR_TCE_IOMMU) && (arg != VFIO_SPAPR_TCE_v2_IOMMU)) {
pr_err("tce_vfio: Wrong IOMMU type\n");
return ERR_PTR(-EINVAL);
}
@@ -410,6 +411,8 @@ static void *tce_iommu_open(unsigned long arg)
mutex_init(&container->lock);
INIT_LIST_HEAD_RCU(&container->mem_list);

+   container->v2 = arg == VFIO_SPAPR_TCE_v2_IOMMU;
+
return container;
  }

@@ -580,6 +583,7 @@ static long tce_iommu_ioctl(void *iommu_data,
case VFIO_CHECK_EXTENSION:
switch (arg) {
case VFIO_SPAPR_TCE_IOMMU:
+   case VFIO_SPAPR_TCE_v2_IOMMU:
ret = 1;
break;
default:
@@ -719,6 +723,9 @@ static long tce_iommu_ioctl(void *iommu_data,
case VFIO_IOMMU_SPAPR_REGISTER_MEMORY: {
struct vfio_iommu_spapr_register_memory param;

+   if (!container->v2)
+   return -EPERM;
+
minsz = offsetofend(struct vfio_iommu_spapr_register_memory,
size);

@@ -741,6 +748,9 @@ static long tce_iommu_ioctl(void *iommu_data,
case VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY: {
struct vfio_iommu_spapr_register_memory param;

+   if (!container->v2)
+   return -EPERM;
+
minsz = offsetofend(struct vfio_iommu_spapr_register_memory,
size);

@@ -761,6 +771,9 @@ static long tce_iommu_ioctl(void *iommu_data,
return 0;
}
case VFIO_IOMMU_ENABLE:
+   if (container->v2)
+   return -EPERM;
+
mutex_lock(&container->lock);
ret = tce_iommu_enable(container);
mutex_unlock(&container->lock);
@@ -768,6 +781,9 @@ static long tce_iommu_ioctl(void *iommu_data,


case VFIO_IOMMU_DISABLE:
+   if (container->v2)
+   return -EPERM;
+
mutex_lock(&container->lock);
tce_iommu_disable(container);
mutex_unlock(&container->lock);



I wouldn't have guessed; nothing in the documentation suggests these
ioctls are deprecated in v2 (ie. please document).  If the ioctl doesn't
exist for the IOMMU type, why not simply break and let it fall out at
-ENOTTY?  Same for the above, v1 would have previously returned -ENOTTY
for those ioctls, why change to -EPERM?



Good points. I'll fix them and merge this patch to "vfio: powerpc/spapr: 
Register memory" as this is where it actually belongs to. Agree?



Thanks for the review!


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

Re: linux panic on 4.0.0-rc4

2015-03-16 Thread Peter Hurley
On 03/16/2015 10:02 PM, Pranith Kumar wrote:
> On Mon, Mar 16, 2015 at 7:22 PM, Michael Ellerman  wrote:
>>
>> The log shows that init is being killed, that's what's causing the panic.
>>
>> The exitcode of init is 0x200, which due to the vagaries of UNIX is I think 
>> an
>> "exit status" of 2 in the common usage.
>>
>> But it suggests that your init is just exiting for some reason?
>>
> 
> Yeah, seems like that. Not sure why though. git bisect seems to be the
> only option.
> 
>> What is your init?
> 
> I am using systemd from debian unstable.

Do you have a stdout-path property defined in your dts to a serial
console you're not actually using?


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

Re: [PATCH kernel v6 29/29] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-03-16 Thread Alex Williamson
On Tue, 2015-03-17 at 12:02 +1100, Alexey Kardashevskiy wrote:
> On 03/17/2015 06:38 AM, Alex Williamson wrote:
> > On Fri, 2015-03-13 at 19:07 +1100, Alexey Kardashevskiy wrote:
> >> This adds create/remove window ioctls to create and remove DMA windows.
> >> sPAPR defines a Dynamic DMA windows capability which allows
> >> para-virtualized guests to create additional DMA windows on a PCI bus.
> >> The existing linux kernels use this new window to map the entire guest
> >> memory and switch to the direct DMA operations saving time on map/unmap
> >> requests which would normally happen in a big amounts.
> >>
> >> This adds 2 ioctl handlers - VFIO_IOMMU_SPAPR_TCE_CREATE and
> >> VFIO_IOMMU_SPAPR_TCE_REMOVE - to create and remove windows.
> >> Up to 2 windows are supported now by the hardware and by this driver.
> >>
> >> This changes VFIO_IOMMU_SPAPR_TCE_GET_INFO handler to return additional
> >> information such as a number of supported windows and maximum number
> >> levels of TCE tables.
> >>
> >> DDW is added as a capability, not as a SPAPR TCE IOMMU v2 unique feature
> >> as we still want to support v2 on platforms which cannot do DDW for
> >> the sake of TCE acceleration in KVM (coming soon).
> >>
> >> Signed-off-by: Alexey Kardashevskiy 
> >> ---
> >> Changes:
> >> v6:
> >> * added explicit VFIO_IOMMU_INFO_DDW flag to vfio_iommu_spapr_tce_info,
> >> it used to be page mask flags from platform code
> >> * added explicit pgsizes field
> >> * added cleanup if tce_iommu_create_window() failed in a middle
> >> * added checks for callbacks in tce_iommu_create_window and remove those
> >> from tce_iommu_remove_window when it is too late to test anyway
> >> * spapr_tce_find_free_table returns sensible error code now
> >> * updated description of VFIO_IOMMU_SPAPR_TCE_CREATE/
> >> VFIO_IOMMU_SPAPR_TCE_REMOVE
> >>
> >> v4:
> >> * moved code to tce_iommu_create_window()/tce_iommu_remove_window()
> >> helpers
> >> * added docs
> >> ---
> >>   Documentation/vfio.txt  |  19 
> >>   arch/powerpc/include/asm/iommu.h|   2 +-
> >>   drivers/vfio/vfio_iommu_spapr_tce.c | 206 
> >> +++-
> >>   include/uapi/linux/vfio.h   |  41 ++-
> >>   4 files changed, 265 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/Documentation/vfio.txt b/Documentation/vfio.txt
> >> index 791e85c..61ce393 100644
> >> --- a/Documentation/vfio.txt
> >> +++ b/Documentation/vfio.txt
> >> @@ -446,6 +446,25 @@ the memory block.
> >>   The user space is not expected to call these often and the block 
> >> descriptors
> >>   are stored in a linked list in the kernel.
> >>
> >> +6) sPAPR specification allows guests to have an ddditional DMA window(s) 
> >> on
> >
> >
> > s/ddditional/additional/
> >
> >> +a PCI bus with a variable page size. Two ioctls have been added to support
> >> +this: VFIO_IOMMU_SPAPR_TCE_CREATE and VFIO_IOMMU_SPAPR_TCE_REMOVE.
> >> +The platform has to support the functionality or error will be returned to
> >> +the userspace. The existing hardware supports up to 2 DMA windows, one is
> >> +2GB long, uses 4K pages and called "default 32bit window"; the other can
> >> +be as big as entire RAM, use different page size, it is optional - guests
> >> +create those in run-time if the guest driver supports 64bit DMA.
> >> +
> >> +VFIO_IOMMU_SPAPR_TCE_CREATE receives a page shift, a DMA window size and
> >> +a number of TCE table levels (if a TCE table is going to be big enough and
> >> +the kernel may not be able to allocate enough of physicall contiguous 
> >> memory).
> >
> > s/physicall/physically/
> >
> >> +It creates a new window in the available slot and returns the bus address 
> >> where
> >> +the new window starts. Due to hardware limitation, the user space cannot 
> >> choose
> >> +the location of DMA windows.
> >> +
> >> +VFIO_IOMMU_SPAPR_TCE_REMOVE receives the bus start address of the window
> >> +and removes it.
> >> +
> >>   
> >> ---
> >>
> >>   [1] VFIO was originally an acronym for "Virtual Function I/O" in its
> >> diff --git a/arch/powerpc/include/asm/iommu.h 
> >> b/arch/powerpc/include/asm/iommu.h
> >> index 13145a2..bac02bf 100644
> >> --- a/arch/powerpc/include/asm/iommu.h
> >> +++ b/arch/powerpc/include/asm/iommu.h
> >> @@ -138,7 +138,7 @@ extern void iommu_free_table(struct iommu_table *tbl, 
> >> const char *node_name);
> >>   extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
> >>int nid);
> >>
> >> -#define IOMMU_TABLE_GROUP_MAX_TABLES  1
> >> +#define IOMMU_TABLE_GROUP_MAX_TABLES  2
> >>
> >>   struct iommu_table_group;
> >>
> >> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c 
> >> b/drivers/vfio/vfio_iommu_spapr_tce.c
> >> index d94116b..0129a4f 100644
> >> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> >> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> >> @@ -600,11 +600,137 @@ static long tce_iommu_build

Re: [9/9] powerpc/hv-24x7: Add missing put_cpu_var()

2015-03-16 Thread Michael Ellerman
On Tue, 2015-17-02 at 22:00:34 UTC, Sukadev Bhattiprolu wrote:
> Add missing put_cpu_var() for 24x7 requests.

When did it go missing? I assume in upstream, in which case this should be a
separate patch which I could merge for 4.0.

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

Re: [8/9] powerpc/hv-24x7: Break up single_24x7_request

2015-03-16 Thread Michael Ellerman
On Tue, 2015-17-02 at 22:00:33 UTC, Sukadev Bhattiprolu wrote:
> Break up the function single_24x7_request() into smaller functions.
> This would later enable us to "prepare" a multi-event request
> buffer and then submit a single hcall for several events.

This looks fine, though the names are a bit laboured.
> 
> diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
> index 3c36694..fde6211 100644
> --- a/arch/powerpc/perf/hv-24x7.c
> +++ b/arch/powerpc/perf/hv-24x7.c
> @@ -1001,6 +1001,44 @@ static void log_24x7_hcall(struct 
> hv_24x7_request_buffer *request_buffer,
>  }
>  
>  /*
> + * Start the process for a new H_GET_24x7_DATA hcall.
> + */
> +static void start_24x7_get_data(struct hv_24x7_request_buffer 
> *request_buffer,
> + struct hv_24x7_data_result_buffer *result_buffer)
> +{

Just init_24x7_request() ?

> +
> + memset(request_buffer, 0, 4096);
> + memset(result_buffer, 0, 4096);
> +
> + request_buffer->interface_version = HV_24X7_IF_VERSION_CURRENT;
> + /* memset above set request_buffer->num_requests to 0 */
> +}
> +
> +/*
> + * Commit (i.e perform) the H_GET_24x7_DATA hcall using the data collected
> + * by 'start_24x7_get_data()' and 'add_event_to_24x7_request()'.
> + */
> +static int commit_24x7_get_data(struct hv_24x7_request_buffer 
> *request_buffer,
> + struct hv_24x7_data_result_buffer *result_buffer)
> +{

It don't like "commit" that is a loaded term.

Just make_24x7_request() perhaps?


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

Re: [6/9] powerpc/hv-24x7: Define add_event_to_24x7_request()

2015-03-16 Thread Michael Ellerman
On Tue, 2015-17-02 at 22:00:31 UTC, Sukadev Bhattiprolu wrote:
> Move code that maps a perf_event to a 24x7 request buffer into a
> separate function, add_event_to_24x7_request().
> 
> diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
> index e78b127..76c649a 100644
> --- a/arch/powerpc/perf/hv-24x7.c
> +++ b/arch/powerpc/perf/hv-24x7.c
> @@ -1052,7 +1077,6 @@ static unsigned long single_24x7_request(struct 
> perf_event *event, u64 *count)
>   }
>  
>   resb = &result_buffer->results[0];
> -
>   *count = be64_to_cpu(resb->elements[0].element_data[0]);
>  out:
>   return ret;
> @@ -1150,6 +1174,7 @@ static void h_24x7_event_read(struct perf_event *event)
>  {
>   s64 prev;
>   u64 now;
> +
>   now = h_24x7_get_value(event);
>   prev = local64_xchg(&event->hw.prev_count, now);
>   local64_add(now - prev, &event->count);

I'm a fan of whitespace for readability in cases like this, but do it as a
separate patch.

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

Re: [3/9] powerpc/hv-24x7: Drop event_24x7_request()

2015-03-16 Thread Michael Ellerman
On Tue, 2015-17-02 at 22:00:28 UTC, Sukadev Bhattiprolu wrote:
> The function event_24x7_request() is essentially a wrapper to the
> function single_24x7_request() and can be dropped to simplify code.
> 
> diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
> index 7856e38..c189e75 100644
> --- a/arch/powerpc/perf/hv-24x7.c
> +++ b/arch/powerpc/perf/hv-24x7.c
> @@ -1004,17 +1004,22 @@ static unsigned long single_24x7_request(u8 domain, 
> u32 offset, u16 ix,
>   memset(request_buffer, 0, 4096);
>   memset(result_buffer, 0, 4096);
>  
> + if (is_physical_domain(event_get_domain(event)))
> + idx = event_get_core(event);
> + else
> + idx = event_get_vcpu(event);
> +
>   request_buffer->interface_version = HV_24X7_IF_VERSION_CURRENT;
>   request_buffer->num_requests = 1;
>  
>   req = &request_buffer->requests[0];
>  
> - req->performance_domain = domain;
> + req->performance_domain = event_get_domain(event);
>   req->data_size = cpu_to_be16(8);
> - req->data_offset = cpu_to_be32(offset);
> - req->starting_lpar_ix = cpu_to_be16(lpar),
> + req->data_offset = cpu_to_be32(event_get_offset(event));
> + req->starting_lpar_ix = cpu_to_be16(event_get_lpar(event)),
>   req->max_num_lpars = cpu_to_be16(1);
> - req->starting_ix = cpu_to_be16(ix);
> + req->starting_ix = cpu_to_be16(idx);
>   req->max_ix = cpu_to_be16(1);
>  
>   /*
> @@ -1029,7 +1034,9 @@ static unsigned long single_24x7_request(u8 domain, u32 
> offset, u16 ix,
>   if (ret) {
>   pr_notice_ratelimited("hcall failed: %d %#x %#x %d => "
>   "0x%lx (%ld) detail=0x%x failing ix=%x\n",
> - domain, offset, ix, lpar, ret, ret,
> + (int)event_get_domain(event),
> + (unsigned int)event_get_offset(event),
> + idx, (int)event_get_lpar(event), ret, ret,

It seems more natural here to print the req->performance_domain etc. rather
then re-extracting them from the event?

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

Re: linux panic on 4.0.0-rc4

2015-03-16 Thread Pranith Kumar
On Mon, Mar 16, 2015 at 7:22 PM, Michael Ellerman  wrote:
>
> The log shows that init is being killed, that's what's causing the panic.
>
> The exitcode of init is 0x200, which due to the vagaries of UNIX is I think an
> "exit status" of 2 in the common usage.
>
> But it suggests that your init is just exiting for some reason?
>

Yeah, seems like that. Not sure why though. git bisect seems to be the
only option.

> What is your init?

I am using systemd from debian unstable.

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

[PATCH 5/7] powerpc/eeh: Do probe on pci_dn

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/eeh.h   |  11 +-
 arch/powerpc/kernel/eeh.c|  63 
 arch/powerpc/kernel/of_platform.c|   2 +-
 arch/powerpc/kernel/pci-hotplug.c|   2 +-
 arch/powerpc/platforms/powernv/eeh-powernv.c | 146 ---
 arch/powerpc/platforms/pseries/eeh_pseries.c |  82 ++-
 arch/powerpc/platforms/pseries/pci_dlpar.c   |   2 +-
 drivers/pci/hotplug/rpadlpar_core.c  |   2 +-
 8 files changed, 172 insertions(+), 138 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index bb24172..eefff1f 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -206,8 +206,7 @@ struct eeh_ops {
char *name;
int (*init)(void);
int (*post_init)(void);
-   void* (*of_probe)(struct device_node *dn, void *flag);
-   int (*dev_probe)(struct pci_dev *dev, void *flag);
+   void* (*probe)(struct pci_dn *pdn, void *data);
int (*set_option)(struct eeh_pe *pe, int option);
int (*get_pe_addr)(struct eeh_pe *pe);
int (*get_state)(struct eeh_pe *pe, int *state);
@@ -286,8 +285,8 @@ int __exit eeh_ops_unregister(const char *name);
 int eeh_check_failure(const volatile void __iomem *token);
 int eeh_dev_check_failure(struct eeh_dev *edev);
 void eeh_addr_cache_build(void);
-void eeh_add_device_early(struct device_node *);
-void eeh_add_device_tree_early(struct device_node *);
+void eeh_add_device_early(struct pci_dn *);
+void eeh_add_device_tree_early(struct pci_dn *);
 void eeh_add_device_late(struct pci_dev *);
 void eeh_add_device_tree_late(struct pci_bus *);
 void eeh_add_sysfs_files(struct pci_bus *);
@@ -345,9 +344,9 @@ static inline int eeh_check_failure(const volatile void 
__iomem *token)
 
 static inline void eeh_addr_cache_build(void) { }
 
-static inline void eeh_add_device_early(struct device_node *dn) { }
+static inline void eeh_add_device_early(struct pci_dn *pdn) { }
 
-static inline void eeh_add_device_tree_early(struct device_node *dn) { }
+static inline void eeh_add_device_tree_early(struct pci_dn *pdn) { }
 
 static inline void eeh_add_device_late(struct pci_dev *dev) { }
 
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 19a897c..1743b54 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -969,7 +969,7 @@ static struct notifier_block eeh_reboot_nb = {
 int eeh_init(void)
 {
struct pci_controller *hose, *tmp;
-   struct device_node *phb;
+   struct pci_dn *pdn;
static int cnt = 0;
int ret = 0;
 
@@ -1004,20 +1004,9 @@ int eeh_init(void)
return ret;
 
/* Enable EEH for all adapters */
-   if (eeh_has_flag(EEH_PROBE_MODE_DEVTREE)) {
-   list_for_each_entry_safe(hose, tmp,
-   &hose_list, list_node) {
-   phb = hose->dn;
-   traverse_pci_devices(phb, eeh_ops->of_probe, NULL);
-   }
-   } else if (eeh_has_flag(EEH_PROBE_MODE_DEV)) {
-   list_for_each_entry_safe(hose, tmp,
-   &hose_list, list_node)
-   pci_walk_bus(hose->bus, eeh_ops->dev_probe, NULL);
-   } else {
-   pr_warn("%s: Invalid probe mode %x",
-   __func__, eeh_subsystem_flags);
-   return -EINVAL;
+   list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
+   pdn = hose->firmware_data;
+   traverse_pci_dn(pdn, eeh_ops->probe, NULL);
}
 
/*
@@ -1043,7 +1032,7 @@ core_initcall_sync(eeh_init);
 
 /**
  * eeh_add_device_early - Enable EEH for the indicated device_node
- * @dn: device node for which to set up EEH
+ * @pdn: PCI device node for which to set up EEH
  *
  * This routine must be used to perform EEH initialization for PCI
  * devices that were added after system boot (e.g. hotplug, dlpar).
@@ -1053,44 +1042,41 @@ core_initcall_sync(eeh_init);
  * on the CEC architecture, type of the device, on earlier boot
  * command-line arguments & etc.
  */
-void eeh_add_device_early(struct device_node *dn)
+void eeh_add_device_early(struct pci_dn *pdn)
 {
struct pci_controller *phb;
+   struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
 
-   /*
-* If we're doing EEH probe based on PCI device, we
-* would delay the probe until late stage because
-* the PCI device isn't available this moment.
- 

[PATCH 3/7] powerpc/pci: Trace more information from pci_dn

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/pci-bridge.h |  3 +++
 arch/powerpc/kernel/pci_dn.c  | 10 ++
 2 files changed, 13 insertions(+)

diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 513f8f2..2ab6c4a 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -160,6 +160,9 @@ struct pci_dn {
 
int busno;  /* pci bus number */
int devfn;  /* pci device and function number */
+   int vendor_id;  /* Vendor ID */
+   int device_id;  /* Device ID */
+   int class_code; /* Device class code */
 
struct  pci_dn *parent;
struct  pci_controller *phb;/* for pci devices */
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index f3a1a81..c990275 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -281,6 +281,15 @@ void *update_dn_pci_info(struct device_node *dn, void 
*data)
pdn->devfn = (addr >> 8) & 0xff;
}
 
+   /* vendor/device IDs and class code */
+   regs = of_get_property(dn, "vendor-id", NULL);
+   pdn->vendor_id = regs ? of_read_number(regs, 1) : 0;
+   regs = of_get_property(dn, "device-id", NULL);
+   pdn->device_id = regs ? of_read_number(regs, 1) : 0;
+   regs = of_get_property(dn, "class-code", NULL);
+   pdn->class_code = regs ? of_read_number(regs, 1) : 0;
+
+   /* Extended config space */
pdn->pci_ext_config_space = (type && of_read_number(type, 1) == 1);
 
/* Attach to parent node */
@@ -370,6 +379,7 @@ void pci_devs_phb_init_dynamic(struct pci_controller *phb)
pdn = dn->data;
if (pdn) {
pdn->devfn = pdn->busno = -1;
+   pdn->vendor_id = pdn->device_id = pdn->class_code = 0;
pdn->phb = phb;
phb->firmware_data = pdn;
}
-- 
1.8.3.2

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

[PATCH 6/7] powerpc/eeh: Replace device_node with pci_dn in eeh_ops

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/eeh.h   |  6 +-
 arch/powerpc/kernel/eeh.c| 34 +++-
 arch/powerpc/kernel/eeh_pe.c | 82 ++--
 arch/powerpc/platforms/powernv/eeh-powernv.c | 40 ++
 arch/powerpc/platforms/pseries/eeh_pseries.c | 16 ++
 5 files changed, 84 insertions(+), 94 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index eefff1f..2540ad8 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -216,10 +216,10 @@ struct eeh_ops {
int (*configure_bridge)(struct eeh_pe *pe);
int (*err_inject)(struct eeh_pe *pe, int type, int func,
  unsigned long addr, unsigned long mask);
-   int (*read_config)(struct device_node *dn, int where, int size, u32 
*val);
-   int (*write_config)(struct device_node *dn, int where, int size, u32 
val);
+   int (*read_config)(struct pci_dn *pdn, int where, int size, u32 *val);
+   int (*write_config)(struct pci_dn *pdn, int where, int size, u32 val);
int (*next_error)(struct eeh_pe **pe);
-   int (*restore_config)(struct device_node *dn);
+   int (*restore_config)(struct pci_dn *pdn);
 };
 
 extern int eeh_subsystem_flags;
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 1743b54..6f9ec77 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -164,30 +164,34 @@ __setup("eeh=", eeh_setup);
  */
 static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len)
 {
-   struct device_node *dn = eeh_dev_to_of_node(edev);
+   struct pci_dn *pdn = eeh_dev_to_pdn(edev);
u32 cfg;
int cap, i;
int n = 0, l = 0;
char buffer[128];
 
-   n += scnprintf(buf+n, len-n, "%s\n", dn->full_name);
-   pr_warn("EEH: of node=%s\n", dn->full_name);
+   n += scnprintf(buf+n, len-n, "%04x:%02x:%02x:%01x\n",
+  edev->phb->global_number, pdn->busno,
+  PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
+   pr_warn("EEH: of node=%04x:%02x:%02x:%01x\n",
+   edev->phb->global_number, pdn->busno,
+   PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
 
-   eeh_ops->read_config(dn, PCI_VENDOR_ID, 4, &cfg);
+   eeh_ops->read_config(pdn, PCI_VENDOR_ID, 4, &cfg);
n += scnprintf(buf+n, len-n, "dev/vend:%08x\n", cfg);
pr_warn("EEH: PCI device/vendor: %08x\n", cfg);
 
-   eeh_ops->read_config(dn, PCI_COMMAND, 4, &cfg);
+   eeh_ops->read_config(pdn, PCI_COMMAND, 4, &cfg);
n += scnprintf(buf+n, len-n, "cmd/stat:%x\n", cfg);
pr_warn("EEH: PCI cmd/status register: %08x\n", cfg);
 
/* Gather bridge-specific registers */
if (edev->mode & EEH_DEV_BRIDGE) {
-   eeh_ops->read_config(dn, PCI_SEC_STATUS, 2, &cfg);
+   eeh_ops->read_config(pdn, PCI_SEC_STATUS, 2, &cfg);
n += scnprintf(buf+n, len-n, "sec stat:%x\n", cfg);
pr_warn("EEH: Bridge secondary status: %04x\n", cfg);
 
-   eeh_ops->read_config(dn, PCI_BRIDGE_CONTROL, 2, &cfg);
+   eeh_ops->read_config(pdn, PCI_BRIDGE_CONTROL, 2, &cfg);
n += scnprintf(buf+n, len-n, "brdg ctl:%x\n", cfg);
pr_warn("EEH: Bridge control: %04x\n", cfg);
}
@@ -195,11 +199,11 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char 
*buf, size_t len)
/* Dump out the PCI-X command and status regs */
cap = edev->pcix_cap;
if (cap) {
-   eeh_ops->read_config(dn, cap, 4, &cfg);
+   eeh_ops->read_config(pdn, cap, 4, &cfg);
n += scnprintf(buf+n, len-n, "pcix-cmd:%x\n", cfg);
pr_warn("EEH: PCI-X cmd: %08x\n", cfg);
 
-   eeh_ops->read_config(dn, cap+4, 4, &cfg);
+   eeh_ops->read_config(pdn, cap+4, 4, &cfg);
n += scnprintf(buf+n, len-n, "pcix-stat:%x\n", cfg);
pr_warn("EEH: PCI-X status: %08x\n", cfg);
}
@@ -211,7 +215,7 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char 
*buf, size_t len)
pr_warn("EEH: PCI-E capabilities and status follow:\n");
 
for (i=0; i<=8; i++) {
-   eeh_ops->read_config(dn, cap+4*i, 4, &cfg);
+   eeh_ops->read_config(pdn, cap+4*i, 4, &cfg);
n += scnprintf(buf+n, len-n, "%02x:%x\n", 4*i, cfg);
 
if ((i % 4) == 0) {
@@ -238,7 +242,7 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char 
*buf, size_t len)
pr_warn("EEH: PCI-E AER capability register set follows:\n");
 
for (i=0; i<=13; i++) {
-   eeh_o

[PATCH 2/7] powerpc/powernv: Use pci_dn, not device_node, in PCI config accessor

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/platforms/powernv/eeh-powernv.c | 14 +-
 arch/powerpc/platforms/powernv/pci.c | 69 +++-
 arch/powerpc/platforms/powernv/pci.h |  4 +-
 3 files changed, 40 insertions(+), 47 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c 
b/arch/powerpc/platforms/powernv/eeh-powernv.c
index ede6906..8eac8c5 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -1038,21 +1038,31 @@ static inline bool pnv_eeh_cfg_blocked(struct 
device_node *dn)
 static int pnv_eeh_read_config(struct device_node *dn,
   int where, int size, u32 *val)
 {
+   struct pci_dn *pdn = PCI_DN(dn);
+
+   if (!pdn)
+   return PCIBIOS_DEVICE_NOT_FOUND;
+
if (pnv_eeh_cfg_blocked(dn)) {
*val = 0x;
return PCIBIOS_SET_FAILED;
}
 
-   return pnv_pci_cfg_read(dn, where, size, val);
+   return pnv_pci_cfg_read(pdn, where, size, val);
 }
 
 static int pnv_eeh_write_config(struct device_node *dn,
int where, int size, u32 val)
 {
+   struct pci_dn *pdn = PCI_DN(dn);
+
+   if (!pdn)
+   return PCIBIOS_DEVICE_NOT_FOUND;
+
if (pnv_eeh_cfg_blocked(dn))
return PCIBIOS_SET_FAILED;
 
-   return pnv_pci_cfg_write(dn, where, size, val);
+   return pnv_pci_cfg_write(pdn, where, size, val);
 }
 
 static void pnv_eeh_dump_hub_diag_common(struct OpalIoP7IOCErrorData *data)
diff --git a/arch/powerpc/platforms/powernv/pci.c 
b/arch/powerpc/platforms/powernv/pci.c
index 54323d6..946aa3d 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -366,9 +366,9 @@ static void pnv_pci_handle_eeh_config(struct pnv_phb *phb, 
u32 pe_no)
spin_unlock_irqrestore(&phb->lock, flags);
 }
 
-static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
-struct device_node *dn)
+static void pnv_pci_config_check_eeh(struct pci_dn *pdn)
 {
+   struct pnv_phb *phb = pdn->phb->private_data;
u8  fstate;
__be16  pcierr;
int pe_no;
@@ -379,7 +379,7 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
 * setup that yet. So all ER errors should be mapped to
 * reserved PE.
 */
-   pe_no = PCI_DN(dn)->pe_number;
+   pe_no = pdn->pe_number;
if (pe_no == IODA_INVALID_PE) {
if (phb->type == PNV_PHB_P5IOC2)
pe_no = 0;
@@ -407,8 +407,7 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
}
 
cfg_dbg(" -> EEH check, bdfn=%04x PE#%d fstate=%x\n",
-   (PCI_DN(dn)->busno << 8) | (PCI_DN(dn)->devfn),
-   pe_no, fstate);
+   (pdn->busno << 8) | (pdn->devfn), pe_no, fstate);
 
/* Clear the frozen state if applicable */
if (fstate == OPAL_EEH_STOPPED_MMIO_FREEZE ||
@@ -425,10 +424,9 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
}
 }
 
-int pnv_pci_cfg_read(struct device_node *dn,
+int pnv_pci_cfg_read(struct pci_dn *pdn,
 int where, int size, u32 *val)
 {
-   struct pci_dn *pdn = PCI_DN(dn);
struct pnv_phb *phb = pdn->phb->private_data;
u32 bdfn = (pdn->busno << 8) | pdn->devfn;
s64 rc;
@@ -462,10 +460,9 @@ int pnv_pci_cfg_read(struct device_node *dn,
return PCIBIOS_SUCCESSFUL;
 }
 
-int pnv_pci_cfg_write(struct device_node *dn,
+int pnv_pci_cfg_write(struct pci_dn *pdn,
  int where, int size, u32 val)
 {
-   struct pci_dn *pdn = PCI_DN(dn);
struct pnv_phb *phb = pdn->phb->private_data;
u32 bdfn = (pdn->busno << 8) | pdn->devfn;
 
@@ -489,18 +486,17 @@ int pnv_pci_cfg_write(struct device_node *dn,
 }
 
 #if CONFIG_EEH
-static bool pnv_pci_cfg_check(struct pci_controller *hose,
- struct device_node *dn)
+static bool pnv_pci_cfg_check(struct pci_dn *pdn)
 {
struct eeh_dev *edev = NULL;
-   struct pnv_phb *phb = hose->private_data;
+   struct pnv_phb *phb = pdn->phb->private_data;
 
/* EEH not enabled ? */
if (!(phb->flags & PNV_PHB_FLAG_EEH))
return true;
 
/* PE reset or device removed ? */
-   edev = of_node_to_eeh_dev(dn);
+   edev = pdn->edev;
if (edev) {
if (edev->pe &&
(edev->pe->state & EEH_PE_CFG_BLOCKED))
@@ -513,8 +509,7 @@ static bool pnv_pci_cfg_check(struct pci_controller *hose,
return true;
 }
 #else
-static inline pnv_pci_cfg_check(struct pci_controller *hose,
-   struct device_node *dn)
+static inl

[PATCH 0/7] powerpc/eeh: Refactor to use pci_dn

2015-03-16 Thread Gavin Shan
Currently, EEH depends on device_node or pci_dev heavily. Unfortunately,
SRIOV VFs are supported depending on pci_dn heavily, which is conflicting
with EEH implementation. In order for better support EEH on SRIOV VF, the
EEH is better to be changed a bit to depend on pci_dn, which is exactly
what the patchset does.

The patchset is expected to merged after the patchset "EEH cleanup to
remove chip layer for PowerNV", before "SRIOV patchset". The first two
patches are extracted from SRIOV patchset to make this patchset
self-contained.

Gavin Shan (7):
  powerpc/pci: Refactor pci_dn
  powerpc/powernv: Use pci_dn, not device_node, in PCI config accessor
  powerpc/pci: Trace more information from pci_dn
  powerpc/eeh: Create eeh_dev from pci_dn instead of device_node
  powerpc/eeh: Do probe on pci_dn
  powerpc/eeh: Replace device_node with pci_dn in eeh_ops
  powerpc/eeh: Remove device_node dependency

 arch/powerpc/include/asm/device.h|   3 +
 arch/powerpc/include/asm/eeh.h   |  28 ++-
 arch/powerpc/include/asm/pci-bridge.h|  31 +--
 arch/powerpc/include/asm/ppc-pci.h   |   3 +
 arch/powerpc/kernel/eeh.c| 127 +---
 arch/powerpc/kernel/eeh_cache.c  |  25 +--
 arch/powerpc/kernel/eeh_dev.c|  14 +-
 arch/powerpc/kernel/eeh_driver.c |  22 --
 arch/powerpc/kernel/eeh_pe.c | 116 ++-
 arch/powerpc/kernel/of_platform.c|   2 +-
 arch/powerpc/kernel/pci-hotplug.c|   2 +-
 arch/powerpc/kernel/pci_dn.c | 295 ++-
 arch/powerpc/kernel/pci_of_scan.c|   2 +-
 arch/powerpc/kernel/rtas_pci.c   |   2 +-
 arch/powerpc/platforms/powernv/eeh-powernv.c | 192 -
 arch/powerpc/platforms/powernv/pci-ioda.c|  16 ++
 arch/powerpc/platforms/powernv/pci.c |  69 +++
 arch/powerpc/platforms/powernv/pci.h |   4 +-
 arch/powerpc/platforms/pseries/eeh_pseries.c |  98 -
 arch/powerpc/platforms/pseries/msi.c |   6 +-
 arch/powerpc/platforms/pseries/pci_dlpar.c   |   2 +-
 arch/powerpc/platforms/pseries/setup.c   |   2 +-
 drivers/pci/hotplug/rpadlpar_core.c  |   2 +-
 23 files changed, 694 insertions(+), 369 deletions(-)

-- 
1.8.3.2

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

[PATCH 1/7] powerpc/pci: Refactor pci_dn

2015-03-16 Thread Gavin Shan
pci_dn is the extension of PCI device node and is created from device node.
Unfortunately, VFs are enabled dynamically by PF's driver and they don't
have corresponding device nodes, and pci_dn.  Refactor pci_dn to support
VFs:

   * pci_dn is organized as a hierarchy tree.  VF's pci_dn is put
 to the child list of pci_dn of PF's bridge.  pci_dn of other device
 put to the child list of pci_dn of its upstream bridge.

   * VF's pci_dn is expected to be created dynamically when PF
 enabling VFs.  VF's pci_dn will be destroyed when PF disabling VFs.
 pci_dn of other device is still created from device node as before.

   * For one particular PCI device (VF or not), its pci_dn can be
 found from pdev->dev.archdata.firmware_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: add ifdef around add_one_dev_pci_info(), use dev_printk()]
Signed-off-by: Gavin Shan 
---
 arch/powerpc/include/asm/device.h |   3 +
 arch/powerpc/include/asm/pci-bridge.h |  14 +-
 arch/powerpc/kernel/pci_dn.c  | 245 +-
 arch/powerpc/platforms/powernv/pci-ioda.c |  16 ++
 4 files changed, 272 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/device.h 
b/arch/powerpc/include/asm/device.h
index 38faede..29992cd 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -34,6 +34,9 @@ struct dev_archdata {
 #ifdef CONFIG_SWIOTLB
dma_addr_t  max_direct_dma_addr;
 #endif
+#ifdef CONFIG_PPC64
+   void*firmware_data;
+#endif
 #ifdef CONFIG_EEH
struct eeh_dev  *edev;
 #endif
diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 546d036..513f8f2 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -89,6 +89,7 @@ struct pci_controller {
 
 #ifdef CONFIG_PPC64
unsigned long buid;
+   void *firmware_data;
 #endif /* CONFIG_PPC64 */
 
void *private_data;
@@ -154,9 +155,13 @@ static inline int isa_vaddr_is_ioport(void __iomem 
*address)
 struct iommu_table;
 
 struct pci_dn {
+   int flags;
+#define PCI_DN_FLAG_IOV_VF 0x01
+
int busno;  /* pci bus number */
int devfn;  /* pci device and function number */
 
+   struct  pci_dn *parent;
struct  pci_controller *phb;/* for pci devices */
struct  iommu_table *iommu_table;   /* for phb's or bridges */
struct  device_node *node;  /* back-pointer to the device_node */
@@ -171,14 +176,19 @@ struct pci_dn {
 #ifdef CONFIG_PPC_POWERNV
int pe_number;
 #endif
+   struct list_head child_list;
+   struct list_head list;
 };
 
 /* Get the pointer to a device_node's pci_dn */
 #define PCI_DN(dn) ((struct pci_dn *) (dn)->data)
 
+extern struct pci_dn *pci_get_pdn_by_devfn(struct pci_bus *bus,
+  int devfn);
 extern struct pci_dn *pci_get_pdn(struct pci_dev *pdev);
-
-extern void * update_dn_pci_info(struct device_node *dn, void *data);
+extern struct pci_dn *add_dev_pci_info(struct pci_dev *pdev);
+extern void remove_dev_pci_info(struct pci_dev *pdev);
+extern void *update_dn_pci_info(struct device_node *dn, void *data);
 
 static inline int pci_device_from_OF_node(struct device_node *np,
  u8 *bus, u8 *devfn)
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index 83df307..f3a1a81 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -32,12 +32,223 @@
 #include 
 #include 
 
+/*
+ * The function is used to find the firmware data of one
+ * specific PCI device, which is attached to the indicated
+ * PCI bus. For VFs, their firmware data is linked to that
+ * one of PF's bridge. For other devices, their firmware
+ * data is linked to that of their bridge.
+ */
+static struct pci_dn *pci_bus_to_pdn(struct pci_bus *bus)
+{
+   struct pci_bus *pbus;
+   struct device_node *dn;
+   struct pci_dn *pdn;
+
+   /*
+* We probably have virtual bus which doesn't
+* have associated bridge.
+*/
+   pbus = bus;
+   while (pbus) {
+   if (pci_is_root_bus(pbus) || pbus->self)
+   break;
+
+   pbus = pbus->parent;
+   }
+
+   /*
+* Except virtual bus, all PCI buses should
+* have device nodes.
+*/
+   dn = pci_bus_to_OF_node(pbus);
+   pdn = dn ? PCI_DN(dn) : NULL;
+
+   return pdn;
+}
+
+struct pci_dn *pci_get_pdn_by_devfn(struct pci_bus *bus,
+   int devfn)
+{
+   struct device_node *dn = NULL;
+   struct pci_dn *parent, *pdn;
+   struct pci_dev *pdev = NULL;
+
+   /* Fast path: fetch from PCI device */
+  

[PATCH 7/7] powerpc/eeh: Remove device_node dependency

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/eeh.h|  7 ---
 arch/powerpc/include/asm/pci-bridge.h | 14 --
 arch/powerpc/kernel/eeh.c | 30 --
 arch/powerpc/kernel/eeh_cache.c   | 25 +++--
 arch/powerpc/kernel/eeh_driver.c  | 22 --
 arch/powerpc/kernel/eeh_pe.c  | 34 +-
 arch/powerpc/kernel/pci_of_scan.c |  2 +-
 arch/powerpc/kernel/rtas_pci.c|  2 +-
 arch/powerpc/platforms/pseries/msi.c  |  6 --
 9 files changed, 58 insertions(+), 84 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 2540ad8..61912fc 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -29,7 +29,6 @@
 
 struct pci_dev;
 struct pci_bus;
-struct device_node;
 
 #ifdef CONFIG_EEH
 
@@ -136,17 +135,11 @@ struct eeh_dev {
struct eeh_pe *pe;  /* Associated PE*/
struct list_head list;  /* Form link list in the PE */
struct pci_controller *phb; /* Associated PHB   */
-   struct device_node *dn; /* Associated device node   */
struct pci_dn *pdn; /* Associated PCI device node   */
struct pci_dev *pdev;   /* Associated PCI device*/
struct pci_bus *bus;/* PCI bus for partial hotplug  */
 };
 
-static inline struct device_node *eeh_dev_to_of_node(struct eeh_dev *edev)
-{
-   return edev ? edev->dn : NULL;
-}
-
 static inline struct pci_dn *eeh_dev_to_pdn(struct eeh_dev *edev)
 {
return edev ? edev->pdn : NULL;
diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 23558bc..c480a14 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -204,25 +204,11 @@ static inline int pci_device_from_OF_node(struct 
device_node *np,
 }
 
 #if defined(CONFIG_EEH)
-static inline struct eeh_dev *of_node_to_eeh_dev(struct device_node *dn)
-{
-   /*
-* For those OF nodes whose parent isn't PCI bridge, they
-* don't have PCI_DN actually. So we have to skip them for
-* any EEH operations.
-*/
-   if (!dn || !PCI_DN(dn))
-   return NULL;
-
-   return PCI_DN(dn)->edev;
-}
-
 static inline struct eeh_dev *pdn_to_eeh_dev(struct pci_dn *pdn)
 {
return pdn ? pdn->edev : NULL;
 }
 #else
-#define of_node_to_eeh_dev(x)  (NULL)
 #define pdn_to_eeh_dev(x)  (NULL)
 #endif
 
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 6f9ec77..7a47183 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -418,11 +418,11 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
int ret;
int active_flags = (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
unsigned long flags;
-   struct device_node *dn;
+   struct pci_dn *pdn;
struct pci_dev *dev;
struct eeh_pe *pe, *parent_pe, *phb_pe;
int rc = 0;
-   const char *location;
+   const char *location = NULL;
 
eeh_stats.total_mmio_ffs++;
 
@@ -433,15 +433,14 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
eeh_stats.no_dn++;
return 0;
}
-   dn = eeh_dev_to_of_node(edev);
dev = eeh_dev_to_pci_dev(edev);
pe = eeh_dev_to_pe(edev);
 
/* Access to IO BARs might get this far and still not want checking. */
if (!pe) {
eeh_stats.ignored_check++;
-   pr_debug("EEH: Ignored check for %s %s\n",
-   eeh_pci_name(dev), dn->full_name);
+   pr_debug("EEH: Ignored check for %s\n",
+   eeh_pci_name(dev));
return 0;
}
 
@@ -477,10 +476,13 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
if (pe->state & EEH_PE_ISOLATED) {
pe->check_count++;
if (pe->check_count % EEH_MAX_FAILS == 0) {
-   location = of_get_property(dn, "ibm,loc-code", NULL);
+   pdn = eeh_dev_to_pdn(edev);
+   if (pdn->node)
+   location = of_get_property(pdn->node, 
"ibm,loc-code", NULL);
printk(KERN_ERR "EEH: %d reads ignored for recovering 
device at "
"location=%s driver=%s pci addr=%s\n",
-   pe->check_count, location,
+   pe->check_count,
+   location ? location : "unknown",
eeh_driver_name(dev), 

[PATCH 4/7] powerpc/eeh: Create eeh_dev from pci_dn instead of device_node

2015-03-16 Thread Gavin Shan
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 
---
 arch/powerpc/include/asm/eeh.h | 10 +++--
 arch/powerpc/include/asm/pci-bridge.h  |  8 ++-
 arch/powerpc/include/asm/ppc-pci.h |  3 +++
 arch/powerpc/kernel/eeh_dev.c  | 14 ++--
 arch/powerpc/kernel/pci_dn.c   | 40 ++
 arch/powerpc/platforms/pseries/setup.c |  2 +-
 6 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 55abfd0..bb24172 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -137,6 +137,7 @@ struct eeh_dev {
struct list_head list;  /* Form link list in the PE */
struct pci_controller *phb; /* Associated PHB   */
struct device_node *dn; /* Associated device node   */
+   struct pci_dn *pdn; /* Associated PCI device node   */
struct pci_dev *pdev;   /* Associated PCI device*/
struct pci_bus *bus;/* PCI bus for partial hotplug  */
 };
@@ -146,6 +147,11 @@ static inline struct device_node 
*eeh_dev_to_of_node(struct eeh_dev *edev)
return edev ? edev->dn : NULL;
 }
 
+static inline struct pci_dn *eeh_dev_to_pdn(struct eeh_dev *edev)
+{
+   return edev ? edev->pdn : NULL;
+}
+
 static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev)
 {
return edev ? edev->pdev : NULL;
@@ -272,7 +278,7 @@ void eeh_pe_restore_bars(struct eeh_pe *pe);
 const char *eeh_pe_loc_get(struct eeh_pe *pe);
 struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe);
 
-void *eeh_dev_init(struct device_node *dn, void *data);
+void *eeh_dev_init(struct pci_dn *pdn, void *data);
 void eeh_dev_phb_init_dynamic(struct pci_controller *phb);
 int eeh_init(void);
 int __init eeh_ops_register(struct eeh_ops *ops);
@@ -323,7 +329,7 @@ static inline int eeh_init(void)
return 0;
 }
 
-static inline void *eeh_dev_init(struct device_node *dn, void *data)
+static inline void *eeh_dev_init(struct pci_dn *pdn, void *data)
 {
return NULL;
 }
diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 2ab6c4a..23558bc 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -216,8 +216,14 @@ static inline struct eeh_dev *of_node_to_eeh_dev(struct 
device_node *dn)
 
return PCI_DN(dn)->edev;
 }
+
+static inline struct eeh_dev *pdn_to_eeh_dev(struct pci_dn *pdn)
+{
+   return pdn ? pdn->edev : NULL;
+}
 #else
-#define of_node_to_eeh_dev(x) (NULL)
+#define of_node_to_eeh_dev(x)  (NULL)
+#define pdn_to_eeh_dev(x)  (NULL)
 #endif
 
 /** Find the bus corresponding to the indicated device node */
diff --git a/arch/powerpc/include/asm/ppc-pci.h 
b/arch/powerpc/include/asm/ppc-pci.h
index db1e2b8..eef127e 100644
--- a/arch/powerpc/include/asm/ppc-pci.h
+++ b/arch/powerpc/include/asm/ppc-pci.h
@@ -36,6 +36,9 @@ struct device_node;
 typedef void *(*traverse_func)(struct device_node *me, void *data);
 void *traverse_pci_devices(struct device_node *start, traverse_func pre,
void *data);
+void *traverse_pci_dn(struct pci_dn *root,
+ void *(*fn)(struct pci_dn *, void *),
+ void *data);
 
 extern void pci_devs_phb_init(void);
 extern void pci_devs_phb_init_dynamic(struct pci_controller *phb);
diff --git a/arch/powerpc/kernel/eeh_dev.c b/arch/powerpc/kernel/eeh_dev.c
index e5274ee..9acfba9 100644
--- a/arch/powerpc/kernel/eeh_dev.c
+++ b/arch/powerpc/kernel/eeh_dev.c
@@ -43,13 +43,13 @@
 
 /**
  * eeh_dev_init - Create EEH device according to OF node
- * @dn: device node
+ * @pdn: PCI device node
  * @data: PHB
  *
  * It will create EEH device according to the given OF node. The function
  * might be called by PCI emunation, DR, PHB hotplug.
  */
-void *eeh_dev_init(struct device_node *dn, void *data)
+void *eeh_dev_init(struct pci_dn *pdn, void *data)
 {
struct pci_controller *phb = data;
struct eeh_dev *edev;
@@ -63,8 +63,8 @@ void *eeh_dev_init(struct device_node *dn, void *data)
}
 
/* Associate EEH device with OF node */
-   PCI_DN(dn)->edev = edev;
-   edev->dn  = dn;
+   pdn->edev = edev;
+   edev->pdn = pdn;
edev->phb = phb;
INIT_LIST_HEAD(&edev->list);
 
@@ -80,16 +80,16 @@ void *eeh_dev_init(struct device_node *dn, void *data)
  */
 void eeh_dev_phb_init_dynamic(struct pci_controller *phb)
 {
-   struct device_node *dn = phb->dn;
+   struct pci_dn *root = phb->firmware_data;
 
/* EEH PE for PHB */
eeh_phb_pe_create(phb);
 
/* EEH device for PHB */
-   eeh_dev_init(dn, phb);
+   eeh_dev_init(root, ph

Re: [PATCH kernel v6 29/29] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-03-16 Thread Alexey Kardashevskiy

On 03/17/2015 06:38 AM, Alex Williamson wrote:

On Fri, 2015-03-13 at 19:07 +1100, Alexey Kardashevskiy wrote:

This adds create/remove window ioctls to create and remove DMA windows.
sPAPR defines a Dynamic DMA windows capability which allows
para-virtualized guests to create additional DMA windows on a PCI bus.
The existing linux kernels use this new window to map the entire guest
memory and switch to the direct DMA operations saving time on map/unmap
requests which would normally happen in a big amounts.

This adds 2 ioctl handlers - VFIO_IOMMU_SPAPR_TCE_CREATE and
VFIO_IOMMU_SPAPR_TCE_REMOVE - to create and remove windows.
Up to 2 windows are supported now by the hardware and by this driver.

This changes VFIO_IOMMU_SPAPR_TCE_GET_INFO handler to return additional
information such as a number of supported windows and maximum number
levels of TCE tables.

DDW is added as a capability, not as a SPAPR TCE IOMMU v2 unique feature
as we still want to support v2 on platforms which cannot do DDW for
the sake of TCE acceleration in KVM (coming soon).

Signed-off-by: Alexey Kardashevskiy 
---
Changes:
v6:
* added explicit VFIO_IOMMU_INFO_DDW flag to vfio_iommu_spapr_tce_info,
it used to be page mask flags from platform code
* added explicit pgsizes field
* added cleanup if tce_iommu_create_window() failed in a middle
* added checks for callbacks in tce_iommu_create_window and remove those
from tce_iommu_remove_window when it is too late to test anyway
* spapr_tce_find_free_table returns sensible error code now
* updated description of VFIO_IOMMU_SPAPR_TCE_CREATE/
VFIO_IOMMU_SPAPR_TCE_REMOVE

v4:
* moved code to tce_iommu_create_window()/tce_iommu_remove_window()
helpers
* added docs
---
  Documentation/vfio.txt  |  19 
  arch/powerpc/include/asm/iommu.h|   2 +-
  drivers/vfio/vfio_iommu_spapr_tce.c | 206 +++-
  include/uapi/linux/vfio.h   |  41 ++-
  4 files changed, 265 insertions(+), 3 deletions(-)

diff --git a/Documentation/vfio.txt b/Documentation/vfio.txt
index 791e85c..61ce393 100644
--- a/Documentation/vfio.txt
+++ b/Documentation/vfio.txt
@@ -446,6 +446,25 @@ the memory block.
  The user space is not expected to call these often and the block descriptors
  are stored in a linked list in the kernel.

+6) sPAPR specification allows guests to have an ddditional DMA window(s) on



s/ddditional/additional/


+a PCI bus with a variable page size. Two ioctls have been added to support
+this: VFIO_IOMMU_SPAPR_TCE_CREATE and VFIO_IOMMU_SPAPR_TCE_REMOVE.
+The platform has to support the functionality or error will be returned to
+the userspace. The existing hardware supports up to 2 DMA windows, one is
+2GB long, uses 4K pages and called "default 32bit window"; the other can
+be as big as entire RAM, use different page size, it is optional - guests
+create those in run-time if the guest driver supports 64bit DMA.
+
+VFIO_IOMMU_SPAPR_TCE_CREATE receives a page shift, a DMA window size and
+a number of TCE table levels (if a TCE table is going to be big enough and
+the kernel may not be able to allocate enough of physicall contiguous memory).


s/physicall/physically/


+It creates a new window in the available slot and returns the bus address where
+the new window starts. Due to hardware limitation, the user space cannot choose
+the location of DMA windows.
+
+VFIO_IOMMU_SPAPR_TCE_REMOVE receives the bus start address of the window
+and removes it.
+
  
---

  [1] VFIO was originally an acronym for "Virtual Function I/O" in its
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index 13145a2..bac02bf 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -138,7 +138,7 @@ extern void iommu_free_table(struct iommu_table *tbl, const 
char *node_name);
  extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
int nid);

-#define IOMMU_TABLE_GROUP_MAX_TABLES   1
+#define IOMMU_TABLE_GROUP_MAX_TABLES   2

  struct iommu_table_group;

diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c 
b/drivers/vfio/vfio_iommu_spapr_tce.c
index d94116b..0129a4f 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -600,11 +600,137 @@ static long tce_iommu_build(struct tce_container 
*container,
return ret;
  }

+static int spapr_tce_find_free_table(struct tce_container *container)
+{
+   int i;
+
+   for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i) {
+   struct iommu_table *tbl = &container->tables[i];
+
+   if (!tbl->it_size)
+   return i;
+   }
+
+   return -ENOSPC;
+}
+
+static long tce_iommu_create_window(struct tce_container *container,
+   __u32 page_shift, __u64 window_size, __u32 levels,
+   __u64 *start_addr)
+{
+   struct tce_iommu_gro

Re: [PATCH v2 5/5] crypto: talitos: Add software backlog queue handling

2015-03-16 Thread Kim Phillips
On Mon, 16 Mar 2015 12:02:51 +0200
Horia Geantă  wrote:

> On 3/4/2015 2:23 AM, Kim Phillips wrote:
> > Only potential problem is getting the crypto API to set the GFP_DMA
> > flag in the allocation request, but presumably a
> > CRYPTO_TFM_REQ_DMA crt_flag can be made to handle that.
> 
> Seems there are quite a few places that do not use the
> {aead,ablkcipher_ahash}_request_alloc() API to allocate crypto requests.
> Among them, IPsec and dm-crypt.
> I've looked at the code and I don't think it can be converted to use
> crypto API.

why not?

> This means that the CRYPTO_TFM_REQ_DMA would be visible to all of these
> places. Some of the maintainers do not agree, as you've seen.

would modifying the crypto API to either have a different
*_request_alloc() API, and/or adding calls to negotiate the GFP mask
between crypto users and drivers, e.g., get/set_gfp_mask, work?

> An alternative would be for talitos to use the page allocator to get 1 /
> 2 pages at probe time (4 channels x 32 entries/channel x 64B/descriptor
> = 8 kB), dma_map_page the area and manage it internally for talitos_desc
> hw descriptors.
> What do you think?

There's a comment in esp_alloc_tmp(): "Use spare space in skb for
this where possible," which is ideally where we'd want to be (esp.
because that memory could already be DMA-able).  Your above
suggestion would be in the opposite direction of that.

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

Re: [2/9] powerpc/hv24x7: Remove unnecessary parameter

2015-03-16 Thread Michael Ellerman
On Tue, 2015-17-02 at 22:00:27 UTC, Sukadev Bhattiprolu wrote:
> Use pr_notice_ratelimited() to log error messages and remove
> the 'success_expected' parameter.

I don't understand how this is equivalent?

The current code uses success_expected to indicate that once it's done the
request once and found that it works, it then expects the request to continue
working, and if it doesn't then that is an error.

Using pr_ratelimited() will do the opposite, ie. the first failure will print a
message, but that may not really indicate an error, it may just be a badly
configured request.

Or at least that's how I understand it, please convince me I'm wrong :)

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

Re: linux panic on 4.0.0-rc4

2015-03-16 Thread Michael Ellerman
On Mon, 2015-03-16 at 09:30 -0400, Pranith Kumar wrote:
> On Mon, Mar 16, 2015 at 4:16 AM, Michael Ellerman  wrote:
> > On Mon, 2015-03-16 at 01:34 -0400, Pranith Kumar wrote:
> >> On Mon, Mar 16, 2015 at 1:11 AM, Pranith Kumar  
> >> wrote:
> >> > Hello,
> >> >
> >> > I have a power mac mini 32-bit system.
> >> >
> >> ...
> >> > You can see the panic message here: http://imgur.com/s1lH15g. (there
> >> > is no log and I have no serial console).
> >>
> >> There was some debug code in there when it hit. The actual hang seems
> >> to be in printk_late_init(). It does not return from this. May be this
> >> is a hint?
> >
> > That is where the boot consoles get disabled and it switches to the "real"
> > console. It suggests that the system is not "hung" there but you just lost
> > output.
> >
> > Try booting with "keep_bootcon" ?
> 
> I tried this and got to the same place as in the first mail:
> http://imgur.com/s1lH15g
> 
> There is a kernel panic with the message printed. Any more suggestions
> to how to debug this?

The log shows that init is being killed, that's what's causing the panic.

The exitcode of init is 0x200, which due to the vagaries of UNIX is I think an
"exit status" of 2 in the common usage.

But it suggests that your init is just exiting for some reason?

What is your init?

cheers


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

Re: [PATCH v3 2/2] selftests/powerpc: Add a test of the switch_endian() syscall

2015-03-16 Thread Michael Ellerman
On Mon, 2015-03-16 at 16:30 +0530, Anshuman Khandual wrote:
> On 03/16/2015 12:27 PM, Michael Ellerman wrote:
> > This adds a test of the switch_endian() syscall we added in the previous
> > commit.
> > 
> > We test it by calling the endian switch syscall, and then executing some
> > code in the other endian to check everything went as expected. That code
> > checks registers we expect to be maintained are, and then writes to
> > stdout. If the endian switch failed to happen that code sequence will be
> > illegal and cause the test to abort.
> > 
> > We then switch back to the original endian, do the same checks and
> > finally write a success message and exit(0).
> > 
> > Signed-off-by: Michael Ellerman 
> 
> Hey Michael,
> 
> Did a quick test, passes on LE but seems like failing on BE.
> 
> On LE:
> 
> Hello wrong-endian world
> Hello right-endian world
> success: switch_endian_test
> 
> on BE:
> 
> Hello wrong-endian world (returns 176)
> 
> The previous version of the test was passing both on LE
> and BE (after applying the compiler trick in the assembly)

Hmm, odd. Works for me:

$ uname -a
Linux bebuntu 4.0.0-rc3-2-g9dd2601a490a #1 SMP Fri Mar 13 15:52:11 AEDT 
2015 ppc64 ppc64 ppc64 GNU/Linux
$ make
cc -O2 -Wall -g -nostdlib -m64   -c -o check.o check.S
objcopy -j .text --reverse-bytes=4 -O binary check.o check-reversed.o
hexdump -v -e '/1 ".byte 0x%02X\n"' check-reversed.o > check-reversed.S
cc -O2 -Wall -g -nostdlib -m64switch_endian_test.S check-reversed.S   -o 
switch_endian_test
$ ./switch_endian_test 
Hello wrong-endian world
Hello right-endian world
success: switch_endian_test


What are you seeing exactly?

cheers


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

Re: [PATCH 05/35 linux-next] tty: constify of_device_id array

2015-03-16 Thread Peter Korsgaard
> "Fabian" == Fabian Frederick  writes:

 > of_device_id is always used as const.
 > (See driver.of_match_table and open firmware functions)

 > Signed-off-by: Fabian Frederick 
 > ---

For this:

>  drivers/tty/serial/uartlite.c   | 2 +-

Acked-by: Peter Korsgaard 

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

Re: [PATCH kernel v6 26/29] vfio: powerpc/spapr: Define v2 IOMMU

2015-03-16 Thread Alex Williamson
On Fri, 2015-03-13 at 19:07 +1100, Alexey Kardashevskiy wrote:
> The existing IOMMU requires VFIO_IOMMU_ENABLE call to enable actual use
> of the container (i.e. call DMA map/unmap) and this is where we check
> the rlimit for locked pages. It assumes that only as much memory
> as a default DMA window can be mapped. Every DMA map/unmap request will
> do pinning/unpinning of physical pages.
> 
> New IOMMU will split physical pages pinning and TCE table update.
> It will require guest pages to be registered first and consequent
> map/unmap requests to work only with pre-registered memory.
> For the default single window case this means that the entire guest
> (instead of 2GB) needs to be pinned before using VFIO.
> However when a huge DMA window is added, no additional pinning will be
> required, otherwise it would be guest RAM + 2GB.
> 
> This advertises v2 SPAPR TCE IOMMU and restricts what the userspace
> can do with v1 or v2 IOMMUs.
> 
> Signed-off-by: Alexey Kardashevskiy 
> ---
> Changes:
> v6:
> * enforced limitations imposed by the SPAPR TCE IOMMU version
> ---
>  drivers/vfio/vfio_iommu_spapr_tce.c | 18 +-
>  include/uapi/linux/vfio.h   |  2 ++
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c 
> b/drivers/vfio/vfio_iommu_spapr_tce.c
> index 9d240b4..e191438 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -95,6 +95,7 @@ struct tce_container {
>   bool enabled;
>   unsigned long locked_pages;
>   struct list_head mem_list;
> + bool v2;
>  };
>  
>  struct tce_memory {
> @@ -398,7 +399,7 @@ static void *tce_iommu_open(unsigned long arg)
>  {
>   struct tce_container *container;
>  
> - if (arg != VFIO_SPAPR_TCE_IOMMU) {
> + if ((arg != VFIO_SPAPR_TCE_IOMMU) && (arg != VFIO_SPAPR_TCE_v2_IOMMU)) {
>   pr_err("tce_vfio: Wrong IOMMU type\n");
>   return ERR_PTR(-EINVAL);
>   }
> @@ -410,6 +411,8 @@ static void *tce_iommu_open(unsigned long arg)
>   mutex_init(&container->lock);
>   INIT_LIST_HEAD_RCU(&container->mem_list);
>  
> + container->v2 = arg == VFIO_SPAPR_TCE_v2_IOMMU;
> +
>   return container;
>  }
>  
> @@ -580,6 +583,7 @@ static long tce_iommu_ioctl(void *iommu_data,
>   case VFIO_CHECK_EXTENSION:
>   switch (arg) {
>   case VFIO_SPAPR_TCE_IOMMU:
> + case VFIO_SPAPR_TCE_v2_IOMMU:
>   ret = 1;
>   break;
>   default:
> @@ -719,6 +723,9 @@ static long tce_iommu_ioctl(void *iommu_data,
>   case VFIO_IOMMU_SPAPR_REGISTER_MEMORY: {
>   struct vfio_iommu_spapr_register_memory param;
>  
> + if (!container->v2)
> + return -EPERM;
> +
>   minsz = offsetofend(struct vfio_iommu_spapr_register_memory,
>   size);
>  
> @@ -741,6 +748,9 @@ static long tce_iommu_ioctl(void *iommu_data,
>   case VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY: {
>   struct vfio_iommu_spapr_register_memory param;
>  
> + if (!container->v2)
> + return -EPERM;
> +
>   minsz = offsetofend(struct vfio_iommu_spapr_register_memory,
>   size);
>  
> @@ -761,6 +771,9 @@ static long tce_iommu_ioctl(void *iommu_data,
>   return 0;
>   }
>   case VFIO_IOMMU_ENABLE:
> + if (container->v2)
> + return -EPERM;
> +
>   mutex_lock(&container->lock);
>   ret = tce_iommu_enable(container);
>   mutex_unlock(&container->lock);
> @@ -768,6 +781,9 @@ static long tce_iommu_ioctl(void *iommu_data,
>  
> 
>   case VFIO_IOMMU_DISABLE:
> + if (container->v2)
> + return -EPERM;
> +
>   mutex_lock(&container->lock);
>   tce_iommu_disable(container);
>   mutex_unlock(&container->lock);


I wouldn't have guessed; nothing in the documentation suggests these
ioctls are deprecated in v2 (ie. please document).  If the ioctl doesn't
exist for the IOMMU type, why not simply break and let it fall out at
-ENOTTY?  Same for the above, v1 would have previously returned -ENOTTY
for those ioctls, why change to -EPERM?


> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> index b17e120..fbc5286 100644
> --- a/include/uapi/linux/vfio.h
> +++ b/include/uapi/linux/vfio.h
> @@ -36,6 +36,8 @@
>  /* Two-stage IOMMU */
>  #define VFIO_TYPE1_NESTING_IOMMU 6   /* Implies v2 */
>  
> +#define VFIO_SPAPR_TCE_v2_IOMMU  7
> +
>  /*
>   * The IOCTL interface is designed for extensibility by embedding the
>   * structure length (argsz) and flags into structures passed between



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

Re: [PATCH kernel v6 29/29] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-03-16 Thread Alex Williamson
On Fri, 2015-03-13 at 19:07 +1100, Alexey Kardashevskiy wrote:
> This adds create/remove window ioctls to create and remove DMA windows.
> sPAPR defines a Dynamic DMA windows capability which allows
> para-virtualized guests to create additional DMA windows on a PCI bus.
> The existing linux kernels use this new window to map the entire guest
> memory and switch to the direct DMA operations saving time on map/unmap
> requests which would normally happen in a big amounts.
> 
> This adds 2 ioctl handlers - VFIO_IOMMU_SPAPR_TCE_CREATE and
> VFIO_IOMMU_SPAPR_TCE_REMOVE - to create and remove windows.
> Up to 2 windows are supported now by the hardware and by this driver.
> 
> This changes VFIO_IOMMU_SPAPR_TCE_GET_INFO handler to return additional
> information such as a number of supported windows and maximum number
> levels of TCE tables.
> 
> DDW is added as a capability, not as a SPAPR TCE IOMMU v2 unique feature
> as we still want to support v2 on platforms which cannot do DDW for
> the sake of TCE acceleration in KVM (coming soon).
> 
> Signed-off-by: Alexey Kardashevskiy 
> ---
> Changes:
> v6:
> * added explicit VFIO_IOMMU_INFO_DDW flag to vfio_iommu_spapr_tce_info,
> it used to be page mask flags from platform code
> * added explicit pgsizes field
> * added cleanup if tce_iommu_create_window() failed in a middle
> * added checks for callbacks in tce_iommu_create_window and remove those
> from tce_iommu_remove_window when it is too late to test anyway
> * spapr_tce_find_free_table returns sensible error code now
> * updated description of VFIO_IOMMU_SPAPR_TCE_CREATE/
> VFIO_IOMMU_SPAPR_TCE_REMOVE
> 
> v4:
> * moved code to tce_iommu_create_window()/tce_iommu_remove_window()
> helpers
> * added docs
> ---
>  Documentation/vfio.txt  |  19 
>  arch/powerpc/include/asm/iommu.h|   2 +-
>  drivers/vfio/vfio_iommu_spapr_tce.c | 206 
> +++-
>  include/uapi/linux/vfio.h   |  41 ++-
>  4 files changed, 265 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/vfio.txt b/Documentation/vfio.txt
> index 791e85c..61ce393 100644
> --- a/Documentation/vfio.txt
> +++ b/Documentation/vfio.txt
> @@ -446,6 +446,25 @@ the memory block.
>  The user space is not expected to call these often and the block descriptors
>  are stored in a linked list in the kernel.
>  
> +6) sPAPR specification allows guests to have an ddditional DMA window(s) on


s/ddditional/additional/

> +a PCI bus with a variable page size. Two ioctls have been added to support
> +this: VFIO_IOMMU_SPAPR_TCE_CREATE and VFIO_IOMMU_SPAPR_TCE_REMOVE.
> +The platform has to support the functionality or error will be returned to
> +the userspace. The existing hardware supports up to 2 DMA windows, one is
> +2GB long, uses 4K pages and called "default 32bit window"; the other can
> +be as big as entire RAM, use different page size, it is optional - guests
> +create those in run-time if the guest driver supports 64bit DMA.
> +
> +VFIO_IOMMU_SPAPR_TCE_CREATE receives a page shift, a DMA window size and
> +a number of TCE table levels (if a TCE table is going to be big enough and
> +the kernel may not be able to allocate enough of physicall contiguous 
> memory).

s/physicall/physically/

> +It creates a new window in the available slot and returns the bus address 
> where
> +the new window starts. Due to hardware limitation, the user space cannot 
> choose
> +the location of DMA windows.
> +
> +VFIO_IOMMU_SPAPR_TCE_REMOVE receives the bus start address of the window
> +and removes it.
> +
>  
> ---
>  
>  [1] VFIO was originally an acronym for "Virtual Function I/O" in its
> diff --git a/arch/powerpc/include/asm/iommu.h 
> b/arch/powerpc/include/asm/iommu.h
> index 13145a2..bac02bf 100644
> --- a/arch/powerpc/include/asm/iommu.h
> +++ b/arch/powerpc/include/asm/iommu.h
> @@ -138,7 +138,7 @@ extern void iommu_free_table(struct iommu_table *tbl, 
> const char *node_name);
>  extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
>   int nid);
>  
> -#define IOMMU_TABLE_GROUP_MAX_TABLES 1
> +#define IOMMU_TABLE_GROUP_MAX_TABLES 2
>  
>  struct iommu_table_group;
>  
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c 
> b/drivers/vfio/vfio_iommu_spapr_tce.c
> index d94116b..0129a4f 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -600,11 +600,137 @@ static long tce_iommu_build(struct tce_container 
> *container,
>   return ret;
>  }
>  
> +static int spapr_tce_find_free_table(struct tce_container *container)
> +{
> + int i;
> +
> + for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i) {
> + struct iommu_table *tbl = &container->tables[i];
> +
> + if (!tbl->it_size)
> + return i;
> + }
> +
> + return -ENOSPC;
> +}
> +
> +static long tce_iommu_create_window(struc

Re: [PATCH 05/35 linux-next] tty: constify of_device_id array

2015-03-16 Thread Timur Tabi

On 03/16/2015 02:17 PM, Fabian Frederick wrote:

of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

Signed-off-by: Fabian Frederick


...


  drivers/tty/serial/ucc_uart.c   | 2 +-


For this driver:

Acked-by: Timur Tabi 

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

[PATCH 18/35 linux-next] macintosh: constify of_device_id array

2015-03-16 Thread Fabian Frederick
of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

Signed-off-by: Fabian Frederick 
---
 drivers/macintosh/mediabay.c   | 2 +-
 drivers/macintosh/rack-meter.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
index d98e566..2ddbe87 100644
--- a/drivers/macintosh/mediabay.c
+++ b/drivers/macintosh/mediabay.c
@@ -707,7 +707,7 @@ static const struct mb_ops keylargo_mb_ops = {
  * Therefore we do it all by polling the media bay once each tick.
  */
 
-static struct of_device_id media_bay_match[] =
+static const struct of_device_id media_bay_match[] =
 {
{
.name   = "media-bay",
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
index 4192901..4585f70 100644
--- a/drivers/macintosh/rack-meter.c
+++ b/drivers/macintosh/rack-meter.c
@@ -578,7 +578,7 @@ static int rackmeter_shutdown(struct macio_dev* mdev)
return 0;
 }
 
-static struct of_device_id rackmeter_match[] = {
+static const struct of_device_id rackmeter_match[] = {
{ .name = "i2s" },
{ }
 };
-- 
2.1.0

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

[PATCH 07/35 linux-next] char: constify of_device_id array

2015-03-16 Thread Fabian Frederick
of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

Signed-off-by: Fabian Frederick 
---
 drivers/char/hw_random/pasemi-rng.c  | 2 +-
 drivers/char/hw_random/powernv-rng.c | 2 +-
 drivers/char/hw_random/ppc4xx-rng.c  | 2 +-
 drivers/char/ipmi/ipmi_si_intf.c | 4 ++--
 drivers/char/xillybus/xillybus_of.c  | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/char/hw_random/pasemi-rng.c 
b/drivers/char/hw_random/pasemi-rng.c
index 3eb7bdd..51cb1d5 100644
--- a/drivers/char/hw_random/pasemi-rng.c
+++ b/drivers/char/hw_random/pasemi-rng.c
@@ -133,7 +133,7 @@ static int rng_remove(struct platform_device *dev)
return 0;
 }
 
-static struct of_device_id rng_match[] = {
+static const struct of_device_id rng_match[] = {
{ .compatible  = "1682m-rng", },
{ .compatible  = "pasemi,pwrficient-rng", },
{ },
diff --git a/drivers/char/hw_random/powernv-rng.c 
b/drivers/char/hw_random/powernv-rng.c
index 3f4f632..263a5bb 100644
--- a/drivers/char/hw_random/powernv-rng.c
+++ b/drivers/char/hw_random/powernv-rng.c
@@ -61,7 +61,7 @@ static int powernv_rng_probe(struct platform_device *pdev)
return 0;
 }
 
-static struct of_device_id powernv_rng_match[] = {
+static const struct of_device_id powernv_rng_match[] = {
{ .compatible   = "ibm,power-rng",},
{},
 };
diff --git a/drivers/char/hw_random/ppc4xx-rng.c 
b/drivers/char/hw_random/ppc4xx-rng.c
index c85d31a..b2cfda0 100644
--- a/drivers/char/hw_random/ppc4xx-rng.c
+++ b/drivers/char/hw_random/ppc4xx-rng.c
@@ -123,7 +123,7 @@ static int ppc4xx_rng_remove(struct platform_device *dev)
return 0;
 }
 
-static struct of_device_id ppc4xx_rng_match[] = {
+static const struct of_device_id ppc4xx_rng_match[] = {
{ .compatible = "ppc4xx-rng", },
{ .compatible = "amcc,ppc460ex-rng", },
{ .compatible = "amcc,ppc440epx-rng", },
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 003b4c1..97cf9c2 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2664,7 +2664,7 @@ static struct pci_driver ipmi_pci_driver = {
 };
 #endif /* CONFIG_PCI */
 
-static struct of_device_id ipmi_match[];
+static const struct of_device_id ipmi_match[];
 static int ipmi_probe(struct platform_device *dev)
 {
 #ifdef CONFIG_OF
@@ -2761,7 +2761,7 @@ static int ipmi_remove(struct platform_device *dev)
return 0;
 }
 
-static struct of_device_id ipmi_match[] =
+static const struct of_device_id ipmi_match[] =
 {
{ .type = "ipmi", .compatible = "ipmi-kcs",
  .data = (void *)(unsigned long) SI_KCS },
diff --git a/drivers/char/xillybus/xillybus_of.c 
b/drivers/char/xillybus/xillybus_of.c
index 2002a3a..7818650 100644
--- a/drivers/char/xillybus/xillybus_of.c
+++ b/drivers/char/xillybus/xillybus_of.c
@@ -31,7 +31,7 @@ MODULE_LICENSE("GPL v2");
 static const char xillyname[] = "xillybus_of";
 
 /* Match table for of_platform binding */
-static struct of_device_id xillybus_of_match[] = {
+static const struct of_device_id xillybus_of_match[] = {
{ .compatible = "xillybus,xillybus-1.00.a", },
{ .compatible = "xlnx,xillybus-1.00.a", }, /* Deprecated */
{}
-- 
2.1.0

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

[PATCH 05/35 linux-next] tty: constify of_device_id array

2015-03-16 Thread Fabian Frederick
of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

Signed-off-by: Fabian Frederick 
---
 drivers/tty/serial/apbuart.c| 2 +-
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 2 +-
 drivers/tty/serial/fsl_lpuart.c | 2 +-
 drivers/tty/serial/mpc52xx_uart.c   | 2 +-
 drivers/tty/serial/mxs-auart.c  | 2 +-
 drivers/tty/serial/of_serial.c  | 4 ++--
 drivers/tty/serial/pmac_zilog.c | 2 +-
 drivers/tty/serial/pxa.c| 2 +-
 drivers/tty/serial/serial-tegra.c   | 2 +-
 drivers/tty/serial/sirfsoc_uart.c   | 2 +-
 drivers/tty/serial/st-asc.c | 2 +-
 drivers/tty/serial/uartlite.c   | 2 +-
 drivers/tty/serial/ucc_uart.c   | 2 +-
 drivers/tty/serial/xilinx_uartps.c  | 2 +-
 14 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index 4f0f95e..f3af317 100644
--- a/drivers/tty/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
@@ -572,7 +572,7 @@ static int apbuart_probe(struct platform_device *op)
return 0;
 }
 
-static struct of_device_id apbuart_match[] = {
+static const struct of_device_id apbuart_match[] = {
{
 .name = "GAISLER_APBUART",
 },
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index fddb1fd..08431ad 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1435,7 +1435,7 @@ static int cpm_uart_remove(struct platform_device *ofdev)
return uart_remove_one_port(&cpm_reg, &pinfo->port);
 }
 
-static struct of_device_id cpm_uart_match[] = {
+static const struct of_device_id cpm_uart_match[] = {
{
.compatible = "fsl,cpm1-smc-uart",
},
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index b1893f3..946273a 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -257,7 +257,7 @@ struct lpuart_port {
struct timer_list   lpuart_timer;
 };
 
-static struct of_device_id lpuart_dt_ids[] = {
+static const struct of_device_id lpuart_dt_ids[] = {
{
.compatible = "fsl,vf610-lpuart",
},
diff --git a/drivers/tty/serial/mpc52xx_uart.c 
b/drivers/tty/serial/mpc52xx_uart.c
index 3308ef2..1589f17 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -1717,7 +1717,7 @@ static struct uart_driver mpc52xx_uart_driver = {
 /* OF Platform Driver   */
 /*  */
 
-static struct of_device_id mpc52xx_uart_of_match[] = {
+static const struct of_device_id mpc52xx_uart_of_match[] = {
 #ifdef CONFIG_PPC_MPC52xx
{ .compatible = "fsl,mpc5200b-psc-uart", .data = &mpc5200b_psc_ops, },
{ .compatible = "fsl,mpc5200-psc-uart", .data = &mpc52xx_psc_ops, },
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 20a863b..f7e5825 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -176,7 +176,7 @@ static struct platform_device_id mxs_auart_devtype[] = {
 };
 MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);
 
-static struct of_device_id mxs_auart_dt_ids[] = {
+static const struct of_device_id mxs_auart_dt_ids[] = {
{
.compatible = "fsl,imx28-auart",
.data = &mxs_auart_devtype[IMX28_AUART]
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 33fb94f..d8c4eea 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -155,7 +155,7 @@ out:
 /*
  * Try to register a serial port
  */
-static struct of_device_id of_platform_serial_table[];
+static const struct of_device_id of_platform_serial_table[];
 static int of_platform_serial_probe(struct platform_device *ofdev)
 {
const struct of_device_id *match;
@@ -320,7 +320,7 @@ static SIMPLE_DEV_PM_OPS(of_serial_pm_ops, 
of_serial_suspend, of_serial_resume);
 /*
  * A few common types, add more as needed.
  */
-static struct of_device_id of_platform_serial_table[] = {
+static const struct of_device_id of_platform_serial_table[] = {
{ .compatible = "ns8250",   .data = (void *)PORT_8250, },
{ .compatible = "ns16450",  .data = (void *)PORT_16450, },
{ .compatible = "ns16550a", .data = (void *)PORT_16550A, },
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index 8f51579..e156e39 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -1846,7 +1846,7 @@ static int __init pmz_register(void)
 
 #ifdef CONFIG_PPC_PMAC
 
-static struct of_device_id pmz_match[] = 
+static const struct of_device_id pmz_match[] =
 {
{
.name   = "ch-a",
diff --git

[PATCH 04/35 linux-next] tty/hvc_opal: constify of_device_id array

2015-03-16 Thread Fabian Frederick
of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

Signed-off-by: Fabian Frederick 
---
 drivers/tty/hvc/hvc_opal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index 071551b..543b234 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -41,7 +41,7 @@
 
 static const char hvc_opal_name[] = "hvc_opal";
 
-static struct of_device_id hvc_opal_match[] = {
+static const struct of_device_id hvc_opal_match[] = {
{ .name = "serial", .compatible = "ibm,opal-console-raw" },
{ .name = "serial", .compatible = "ibm,opal-console-hvsi" },
{ },
-- 
2.1.0

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

[PATCH 00/35 linux-next] constify of_device_id array

2015-03-16 Thread Fabian Frederick
This small patchset adds const to of_device_id arrays in
drivers branch.

Fabian Frederick (35):
  ata: constify of_device_id array
  regulator: constify of_device_id array
  thermal: constify of_device_id array
  tty/hvc_opal: constify of_device_id array
  tty: constify of_device_id array
  power: constify of_device_id array
  char: constify of_device_id array
  dma: constify of_device_id array
  iio: constify of_device_id array
  misc: constify of_device_id array
  usb: gadget: constify of_device_id array
  mtd: constify of_device_id array
  w1: constify of_device_id array
  ide: pmac: constify of_device_id array
  spi: constify of_device_id array
  video: constify of_device_id array
  coresight-replicator: constify of_device_id array
  macintosh: constify of_device_id array
  virtio_mmio: constify of_device_id array
  swim3: constify of_device_id array
  mfd: constify of_device_id array
  soc: ti: constify of_device_id array
  [media]: constify of_device_id array
  Input: constify of_device_id array
  PCI: constify of_device_id array
  hwmon: constify of_device_id array
  reset: sti: constify of_device_id array
  uio: constify of_device_id array
  gpu: constify of_device_id array
  devfreq: constify of_device_id array
  EDAC: constify of_device_id array
  clk: constify of_device_id array
  mmc: constify of_device_id array
  Staging: octeon: constify of_device_id array
  pinctrl: constify of_device_id array

 drivers/ata/pata_macio.c | 2 +-
 drivers/ata/pata_mpc52xx.c   | 2 +-
 drivers/ata/pata_octeon_cf.c | 2 +-
 drivers/ata/pata_of_platform.c   | 2 +-
 drivers/ata/sata_fsl.c   | 2 +-
 drivers/ata/sata_mv.c| 2 +-
 drivers/ata/sata_rcar.c  | 2 +-
 drivers/block/swim3.c| 2 +-
 drivers/char/hw_random/pasemi-rng.c  | 2 +-
 drivers/char/hw_random/powernv-rng.c | 2 +-
 drivers/char/hw_random/ppc4xx-rng.c  | 2 +-
 drivers/char/ipmi/ipmi_si_intf.c | 4 ++--
 drivers/char/xillybus/xillybus_of.c  | 2 +-
 drivers/clk/clk-palmas.c | 2 +-
 drivers/clk/st/clkgen-fsyn.c | 2 +-
 drivers/clk/st/clkgen-mux.c  | 8 
 drivers/clk/st/clkgen-pll.c  | 4 ++--
 drivers/clk/ti/clk-dra7-atl.c| 2 +-
 drivers/clk/ti/clockdomain.c | 2 +-
 drivers/clk/versatile/clk-vexpress-osc.c | 2 +-
 drivers/coresight/coresight-replicator.c | 2 +-
 drivers/devfreq/event/exynos-ppmu.c  | 2 +-
 drivers/devfreq/tegra-devfreq.c  | 2 +-
 drivers/dma/bestcomm/bestcomm.c  | 4 ++--
 drivers/dma/k3dma.c  | 2 +-
 drivers/dma/mmp_pdma.c   | 2 +-
 drivers/dma/mmp_tdma.c   | 2 +-
 drivers/dma/mpc512x_dma.c| 2 +-
 drivers/dma/mv_xor.c | 2 +-
 drivers/dma/sirf-dma.c   | 2 +-
 drivers/dma/sun6i-dma.c  | 2 +-
 drivers/edac/highbank_mc_edac.c  | 2 +-
 drivers/edac/mpc85xx_edac.c  | 4 ++--
 drivers/edac/ppc4xx_edac.c   | 2 +-
 drivers/edac/synopsys_edac.c | 2 +-
 drivers/gpio/gpio-mpc8xxx.c  | 2 +-
 drivers/gpio/gpio-octeon.c   | 2 +-
 drivers/gpio/gpio-tz1090-pdc.c   | 2 +-
 drivers/gpio/gpio-tz1090.c   | 2 +-
 drivers/gpio/gpio-zynq.c | 2 +-
 drivers/gpu/drm/armada/armada_crtc.c | 2 +-
 drivers/gpu/drm/exynos/exynos_drm_dsi.c  | 2 +-
 drivers/gpu/drm/exynos/exynos_hdmi.c | 2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c| 2 +-
 drivers/gpu/drm/panel/panel-ld9040.c | 2 +-
 drivers/gpu/drm/panel/panel-s6e8aa0.c| 2 +-
 drivers/gpu/drm/sti/sti_dvo.c| 2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c  | 2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c  | 4 ++--
 drivers/gpu/drm/tilcdc/tilcdc_panel.c| 2 +-
 drivers/gpu/drm/tilcdc/tilcdc_slave.c| 4 ++--
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c   | 4 ++--
 drivers/gpu/host1x/dev.c | 2 +-
 drivers/gpu/host1x/mipi.c| 2 +-
 drivers/hwmon/pwm-fan.c  | 2 +-
 drivers/hwmon/vexpress.c | 2 +-
 drivers/ide/pmac.c   | 2 +-
 drivers/iio/common/ssp_sensors/ssp_dev.c | 2 +-
 drivers/input/misc/palmas-pwrbutton.c| 2 +-
 drivers/input/misc/regulator-haptic.c| 2 +-
 drivers/input/misc/tps65218-pwrbutton.c  | 2 +-
 drivers/input/touchscreen/ar1021_i2c.c   | 2 +-
 drivers/macintosh/mediabay.c | 2 +-
 drivers/macintosh/rack-meter.c   | 2 +-
 drivers/media/i2c/adv7604.c  | 2 +-
 drivers/media/platform/fsl-viu.c | 2 +-
 drivers/media/platform/soc_camera/rcar_vin.c |

Re: [PATCH 0/2] crypto: talitos: Add AES-XTS mode

2015-03-16 Thread Horia Geantă
On 3/13/2015 4:08 PM, Martin Hicks wrote:
> Hi Horia,
> 
> On Wed, Mar 11, 2015 at 11:48 AM, Horia Geantă
>  wrote:
>>
>> While here: note that xts-talitos supports only two key lengths - 256
>> and 512 bits. There are tcrypt speed tests that check also for 384-bit
>> keys (which is out-of-spec, but still...), leading to a "Key Size Error"
>> - see below (KSE bit in AESU Interrupt Status Register is set)
> 
> Ok.  I've limited the keysize to 32 or 64 bytes for AES-XTS in the
> talitos driver.
> 
> This was my first experiments with the tcrypt module.  It also brought
> up another issue related to the IV limitations of this hardware.  The
> latest patch that I have returns an error when there is a non-zero
> value in the second 8 bytes of the IV:
> 
> +   /*
> +* AES-XTS uses the first two AES Context registers for:
> +*
> +* Register 1:   Sector Number (Little Endian)
> +* Register 2:   Sector Size   (Big Endian)
> +*
> +* Whereas AES-CBC uses registers 1/2 as a 16-byte IV.
> +*/
> +   if ((ctx->desc_hdr_template &
> +(DESC_HDR_SEL0_MASK | DESC_HDR_MODE0_MASK)) ==
> +(DESC_HDR_SEL0_AESU | DESC_HDR_MODE0_AESU_XTS)) {
> +   u64 *aesctx2 = (u64 *)areq->info + 1;
> +
> +   if (*aesctx2 != 0) {
> +   dev_err(ctx->dev,
> +   "IV length limited to the first 8 bytes.");
> +   return ERR_PTR(-EINVAL);
> +   }
> +
> +   /* Fixed sized sector */
> +   *aesctx2 = cpu_to_be64(1 << SECTOR_SHIFT);
> +   }
> 
> 
> This approach causes the tcrypt tests to fail because tcrypt sets all
> 16 bytes of the IV to 0xff.  I think returning an error is the right
> approach for the talitos module, but it would be nice if tcrypt still
> worked.  Should tcrypt just set the IV bytes to 0 instead of 0xff?
> Isn't one IV just as good as another?  I think adding exceptions to
> the tcrypt code would be ugly, but maybe one should be made for XTS
> since the standard dictates that the IV should be plain or plain64?

AFAICT xts-aes standard does not mandate for plain or plain64.
The requirements are the following (below IV = tweak value, sector =
data unit):
-IV size: 16 bytes
-IV format: little endian byte array
-IV values: non-negative; consecutive IV values for consecutive sectors

In practice, an 8-byte IV should be enough to represent the sector index
even for large capacity storage devices.
However, dm-crypt has support for a user-provided iv_offset that is
added to the sector index: IV = sector_index + iv_offset.
While in most of the cases user would choose iv_offset = 0, in theory
anything is possible.

IMHO the correct approach would be to use a fallback tfm that would
handle all the requests with IVs > 8 bytes.
We can take this off-list if you prefer.

Horia


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

Re: linux panic on 4.0.0-rc4

2015-03-16 Thread Peter Hurley
On 03/16/2015 09:30 AM, Pranith Kumar wrote:
> On Mon, Mar 16, 2015 at 4:16 AM, Michael Ellerman  wrote:
>> On Mon, 2015-03-16 at 01:34 -0400, Pranith Kumar wrote:
>>> On Mon, Mar 16, 2015 at 1:11 AM, Pranith Kumar  
>>> wrote:
 Hello,

 I have a power mac mini 32-bit system.

>>> ...
 You can see the panic message here: http://imgur.com/s1lH15g. (there
 is no log and I have no serial console).
>>>
>>> There was some debug code in there when it hit. The actual hang seems
>>> to be in printk_late_init(). It does not return from this. May be this
>>> is a hint?
>>
>> That is where the boot consoles get disabled and it switches to the "real"
>> console. It suggests that the system is not "hung" there but you just lost
>> output.
>>
>> Try booting with "keep_bootcon" ?
> 
> I tried this and got to the same place as in the first mail:
> http://imgur.com/s1lH15g
> 
> There is a kernel panic with the message printed. Any more suggestions
> to how to debug this?

git bisect.

Regards,
Peter Hurley
 

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

Re: linux panic on 4.0.0-rc4

2015-03-16 Thread Pranith Kumar
On Mon, Mar 16, 2015 at 4:16 AM, Michael Ellerman  wrote:
> On Mon, 2015-03-16 at 01:34 -0400, Pranith Kumar wrote:
>> On Mon, Mar 16, 2015 at 1:11 AM, Pranith Kumar  wrote:
>> > Hello,
>> >
>> > I have a power mac mini 32-bit system.
>> >
>> ...
>> > You can see the panic message here: http://imgur.com/s1lH15g. (there
>> > is no log and I have no serial console).
>>
>> There was some debug code in there when it hit. The actual hang seems
>> to be in printk_late_init(). It does not return from this. May be this
>> is a hint?
>
> That is where the boot consoles get disabled and it switches to the "real"
> console. It suggests that the system is not "hung" there but you just lost
> output.
>
> Try booting with "keep_bootcon" ?

I tried this and got to the same place as in the first mail:
http://imgur.com/s1lH15g

There is a kernel panic with the message printed. Any more suggestions
to how to debug this?

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

[PATCH 3/3] powerpc: add ticket spinlock

2015-03-16 Thread Kevin Hao
Convert the simple spinlock to ticket-based. This is based on arm64
codes and only cover the systems which doesn't support shared
processors (a physical processor is multiplexed between several
virtual processors).

Signed-off-by: Kevin Hao 
---
 arch/powerpc/Kconfig  |  5 ++
 arch/powerpc/include/asm/spinlock.h   | 77 ++-
 arch/powerpc/include/asm/spinlock_types.h | 16 +++
 3 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 6949d6099d4c..dff19e522b2d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -306,6 +306,11 @@ config PGTABLE_LEVELS
 config PPC_HAS_LOCK_OWNER
bool
 
+config PPC_TICKET_LOCK
+   bool
+   depends on !PPC_HAS_LOCK_OWNER
+   default y
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
diff --git a/arch/powerpc/include/asm/spinlock.h 
b/arch/powerpc/include/asm/spinlock.h
index cbc9511df409..40035261d2db 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -59,7 +59,6 @@ extern void __spin_yield(arch_spinlock_t *lock);
 extern void __rw_yield(arch_rwlock_t *lock);
 extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
 #else /* CONFIG_PPC_HAS_LOCK_OWNER */
-#define LOCK_TOKEN 1
 #define WRLOCK_TOKEN   (-1)
 #define SHARED_PROCESSOR   0
 #define __spin_yield(x)barrier()
@@ -81,6 +80,77 @@ extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
 #define SYNC_IO
 #endif
 
+#ifdef CONFIG_PPC_TICKET_LOCK
+#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
+
+static inline int arch_spin_is_contended(arch_spinlock_t *lock)
+{
+   arch_spinlock_t lockval = READ_ONCE(*lock);
+
+   return (lockval.next - lockval.owner) > 1;
+}
+#define arch_spin_is_contended arch_spin_is_contended
+
+static inline int arch_spin_value_unlocked(arch_spinlock_t lock)
+{
+   return lock.owner == lock.next;
+}
+
+static inline int arch_spin_is_locked(arch_spinlock_t *lock)
+{
+   return !arch_spin_value_unlocked(READ_ONCE(*lock));
+}
+
+static inline unsigned long arch_spin_trylock(arch_spinlock_t *lock)
+{
+   unsigned int tmp;
+   arch_spinlock_t lockval;
+
+   CLEAR_IO_SYNC;
+   __asm__ __volatile__ (
+"1:" PPC_LWARX(%0,0,%2,1) "\n\
+   rotlwi  %1,%0,16\n\
+   xor.%1,%1,%0\n\
+   bne-2f\n\
+   add %0,%0,%3\n\
+   stwcx.  %0,0,%2\n\
+   bne-1b\n"
+   PPC_ACQUIRE_BARRIER
+"2:"
+   : "=&r" (lockval), "=&r" (tmp)
+   : "r" (lock), "r" (1 << TICKET_SHIFT)
+   : "cr0", "memory");
+
+   return !tmp;
+}
+
+static inline void arch_spin_lock(arch_spinlock_t *lock)
+{
+   unsigned int tmp;
+   arch_spinlock_t lockval;
+
+   CLEAR_IO_SYNC;
+   __asm__ __volatile__ (
+"1:" PPC_LWARX(%0,0,%2,1) "\n\
+   add %1,%0,%4\n\
+   stwcx.  %1,0,%2\n\
+   bne-1b\n\
+   rotlwi  %1,%0,16\n\
+   cmpw%1,%0\n\
+   beq 3f\n\
+   rlwinm  %0,%0,16,16,31\n\
+2: or  1,1,1   # HMT_low\n\
+   lhz %1,0(%3)\n\
+   cmpw%1,%0\n\
+   bne 2b\n\
+   or  2,2,2   # HMT_medium\n\
+3:"
+   PPC_ACQUIRE_BARRIER
+   : "=&r" (lockval), "=&r" (tmp)
+   : "r"(lock), "r" (&lock->owner), "r" (1 << TICKET_SHIFT)
+   : "cr0", "memory");
+}
+#else
 static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock)
 {
return lock.slock == 0;
@@ -157,13 +227,18 @@ void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned 
long flags)
local_irq_restore(flags_dis);
}
 }
+#endif
 
 static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
SYNC_IO;
__asm__ __volatile__("# arch_spin_unlock\n\t"
PPC_RELEASE_BARRIER: : :"memory");
+#ifdef CONFIG_PPC_TICKET_LOCK
+   lock->owner++;
+#else
lock->slock = 0;
+#endif
 }
 
 /*
diff --git a/arch/powerpc/include/asm/spinlock_types.h 
b/arch/powerpc/include/asm/spinlock_types.h
index 2351adc4fdc4..371770f906dc 100644
--- a/arch/powerpc/include/asm/spinlock_types.h
+++ b/arch/powerpc/include/asm/spinlock_types.h
@@ -5,11 +5,27 @@
 # error "please don't include this file directly"
 #endif
 
+#ifdef CONFIG_PPC_TICKET_LOCK
+#define TICKET_SHIFT   16
+
+typedef struct {
+#ifdef __BIG_ENDIAN__
+   u16 next;
+   u16 owner;
+#else
+   u16 owner;
+   u16 next;
+#endif
+} __aligned(4) arch_spinlock_t;
+
+#define __ARCH_SPIN_LOCK_UNLOCKED  { 0, 0 }
+#else
 typedef struct {
volatile unsigned int slock;
 } arch_spinlock_t;
 
 #define __ARCH_SPIN_LOCK_UNLOCKED  { 0 }
+#endif /* CONFIG_PPC_TICKET_LOCK */
 
 typedef struct {
volatile signed int lock;
-- 
2.1.0

___
L

[PATCH 2/3] powerpc: spinlock: refactor codes wrapped by PPC_HAS_LOCK_OWNER

2015-03-16 Thread Kevin Hao
Move all of them to one place. No function change.

Signed-off-by: Kevin Hao 
---
 arch/powerpc/include/asm/spinlock.h | 71 -
 1 file changed, 30 insertions(+), 41 deletions(-)

diff --git a/arch/powerpc/include/asm/spinlock.h 
b/arch/powerpc/include/asm/spinlock.h
index 38f40ea63a8c..cbc9511df409 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -30,6 +30,20 @@
 
 #define smp_mb__after_unlock_lock()smp_mb()  /* Full ordering for lock. */
 
+/*
+ * On a system with shared processors (that is, where a physical
+ * processor is multiplexed between several virtual processors),
+ * there is no point spinning on a lock if the holder of the lock
+ * isn't currently scheduled on a physical processor.  Instead
+ * we detect this situation and ask the hypervisor to give the
+ * rest of our timeslice to the lock holder.
+ *
+ * So that we can tell which virtual processor is holding a lock,
+ * we put 0x8000 | smp_processor_id() in the lock when it is
+ * held.  Conveniently, we have a word in the paca that holds this
+ * value.
+ */
+
 #ifdef CONFIG_PPC_HAS_LOCK_OWNER
 /* use 0x80yy when locked, where yy == CPU number */
 #ifdef __BIG_ENDIAN__
@@ -37,9 +51,22 @@
 #else
 #define LOCK_TOKEN (*(u32 *)(&get_paca()->paca_index))
 #endif
-#else
-#define LOCK_TOKEN 1
-#endif
+#define WRLOCK_TOKEN   LOCK_TOKEN  /* it's negative */
+
+/* We only yield to the hypervisor if we are in shared processor mode */
+#define SHARED_PROCESSOR (lppaca_shared_proc(local_paca->lppaca_ptr))
+extern void __spin_yield(arch_spinlock_t *lock);
+extern void __rw_yield(arch_rwlock_t *lock);
+extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
+#else /* CONFIG_PPC_HAS_LOCK_OWNER */
+#define LOCK_TOKEN 1
+#define WRLOCK_TOKEN   (-1)
+#define SHARED_PROCESSOR   0
+#define __spin_yield(x)barrier()
+#define __rw_yield(x)  barrier()
+#define arch_spin_unlock_wait(lock) \
+   do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0)
+#endif /* CONFIG_PPC_HAS_LOCK_OWNER */
 
 #if defined(CONFIG_PPC64) && defined(CONFIG_SMP)
 #define CLEAR_IO_SYNC  (get_paca()->io_sync = 0)
@@ -95,31 +122,6 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
return __arch_spin_trylock(lock) == 0;
 }
 
-/*
- * On a system with shared processors (that is, where a physical
- * processor is multiplexed between several virtual processors),
- * there is no point spinning on a lock if the holder of the lock
- * isn't currently scheduled on a physical processor.  Instead
- * we detect this situation and ask the hypervisor to give the
- * rest of our timeslice to the lock holder.
- *
- * So that we can tell which virtual processor is holding a lock,
- * we put 0x8000 | smp_processor_id() in the lock when it is
- * held.  Conveniently, we have a word in the paca that holds this
- * value.
- */
-
-#if defined(CONFIG_PPC_HAS_LOCK_OWNER)
-/* We only yield to the hypervisor if we are in shared processor mode */
-#define SHARED_PROCESSOR (lppaca_shared_proc(local_paca->lppaca_ptr))
-extern void __spin_yield(arch_spinlock_t *lock);
-extern void __rw_yield(arch_rwlock_t *lock);
-#else /* SPLPAR */
-#define __spin_yield(x)barrier()
-#define __rw_yield(x)  barrier()
-#define SHARED_PROCESSOR   0
-#endif
-
 static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
CLEAR_IO_SYNC;
@@ -164,13 +166,6 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock)
lock->slock = 0;
 }
 
-#ifdef CONFIG_PPC_HAS_LOCK_OWNER
-extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
-#else
-#define arch_spin_unlock_wait(lock) \
-   do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0)
-#endif
-
 /*
  * Read-write spinlocks, allowing multiple readers
  * but only one writer.
@@ -191,12 +186,6 @@ extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
 #define __DO_SIGN_EXTEND
 #endif
 
-#ifdef CONFIG_PPC_HAS_LOCK_OWNER
-#define WRLOCK_TOKEN   LOCK_TOKEN  /* it's negative */
-#else
-#define WRLOCK_TOKEN   (-1)
-#endif
-
 /*
  * This returns the old value in the lock + 1,
  * so we got a read lock if the return value is > 0.
-- 
2.1.0

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

[PATCH 1/3] powerpc: introduce PPC_HAS_LOCK_OWNER

2015-03-16 Thread Kevin Hao
On a system with shared processors (a physical processor is multiplexed
between several virtual processors), we encode the lock owner into the
lock token in order to avoid unnecessarily spinning on a lock if the
lock holder isn't currently scheduled on a physical processor.

In the current kernel, we unconditionally encode the lock owner into
the lock token for all the ppc64 platforms no matter it is a shared
processor or not. This introduces a new kernel option to distinguish
the platforms which need this hack.

Signed-off-by: Kevin Hao 
---
 arch/powerpc/Kconfig   |  3 +++
 arch/powerpc/include/asm/spinlock.h| 12 
 arch/powerpc/lib/locks.c   |  4 ++--
 arch/powerpc/platforms/pseries/Kconfig |  1 +
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 9b780e0d2c18..6949d6099d4c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -303,6 +303,9 @@ config PGTABLE_LEVELS
default 3 if PPC_64K_PAGES
default 4
 
+config PPC_HAS_LOCK_OWNER
+   bool
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
diff --git a/arch/powerpc/include/asm/spinlock.h 
b/arch/powerpc/include/asm/spinlock.h
index 4dbe072eecbe..38f40ea63a8c 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -30,7 +30,7 @@
 
 #define smp_mb__after_unlock_lock()smp_mb()  /* Full ordering for lock. */
 
-#ifdef CONFIG_PPC64
+#ifdef CONFIG_PPC_HAS_LOCK_OWNER
 /* use 0x80yy when locked, where yy == CPU number */
 #ifdef __BIG_ENDIAN__
 #define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
@@ -109,7 +109,7 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
  * value.
  */
 
-#if defined(CONFIG_PPC_SPLPAR)
+#if defined(CONFIG_PPC_HAS_LOCK_OWNER)
 /* We only yield to the hypervisor if we are in shared processor mode */
 #define SHARED_PROCESSOR (lppaca_shared_proc(local_paca->lppaca_ptr))
 extern void __spin_yield(arch_spinlock_t *lock);
@@ -164,7 +164,7 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock)
lock->slock = 0;
 }
 
-#ifdef CONFIG_PPC64
+#ifdef CONFIG_PPC_HAS_LOCK_OWNER
 extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
 #else
 #define arch_spin_unlock_wait(lock) \
@@ -187,9 +187,13 @@ extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
 
 #ifdef CONFIG_PPC64
 #define __DO_SIGN_EXTEND   "extsw  %0,%0\n"
-#define WRLOCK_TOKEN   LOCK_TOKEN  /* it's negative */
 #else
 #define __DO_SIGN_EXTEND
+#endif
+
+#ifdef CONFIG_PPC_HAS_LOCK_OWNER
+#define WRLOCK_TOKEN   LOCK_TOKEN  /* it's negative */
+#else
 #define WRLOCK_TOKEN   (-1)
 #endif
 
diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
index 170a0346f756..66513b3e9b0e 100644
--- a/arch/powerpc/lib/locks.c
+++ b/arch/powerpc/lib/locks.c
@@ -19,7 +19,7 @@
 #include 
 
 /* waiting for a spinlock... */
-#if defined(CONFIG_PPC_SPLPAR)
+#if defined(CONFIG_PPC_HAS_LOCK_OWNER)
 #include 
 #include 
 
@@ -66,7 +66,6 @@ void __rw_yield(arch_rwlock_t *rw)
plpar_hcall_norets(H_CONFER,
get_hard_smp_processor_id(holder_cpu), yield_count);
 }
-#endif
 
 void arch_spin_unlock_wait(arch_spinlock_t *lock)
 {
@@ -83,3 +82,4 @@ void arch_spin_unlock_wait(arch_spinlock_t *lock)
 }
 
 EXPORT_SYMBOL(arch_spin_unlock_wait);
+#endif
diff --git a/arch/powerpc/platforms/pseries/Kconfig 
b/arch/powerpc/platforms/pseries/Kconfig
index a758a9c3bbba..5402fcc30c3e 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -27,6 +27,7 @@ config PPC_PSERIES
 config PPC_SPLPAR
depends on PPC_PSERIES
bool "Support for shared-processor logical partitions"
+   select PPC_HAS_LOCK_OWNER
default n
help
  Enabling this option will make the kernel run more efficiently
-- 
2.1.0

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

[PATCH 0/3] powerpc: add ticket spinlock

2015-03-16 Thread Kevin Hao
Hi,

This patch series convert the simple spinlock to ticket-based spinlock for the
platforms without shared processors. I have run the following command ten times
on a t4240rdb board (12 dual-threaded cpus):
./perf bench sched messaging -g 100

Before  After
Averaged total time [sec]:  2.623   2.479 

We can see a ~5% performance enhancing. I also run the following command ten
times on a p1020rdb board (2 cpus):
./perf bench sched messaging -g 20 

Before  After
Averaged total time [sec]:  3.139   3.144 

So the overhead for the 2 cpus platform is also trivial. 


Kevin Hao (3):
  powerpc: introduce PPC_HAS_LOCK_OWNER
  powerpc: spinlock: refactor codes wrapped by PPC_HAS_LOCK_OWNER
  powerpc: add ticket spinlock

 arch/powerpc/Kconfig  |   8 ++
 arch/powerpc/include/asm/spinlock.h   | 144 ++
 arch/powerpc/include/asm/spinlock_types.h |  16 
 arch/powerpc/lib/locks.c  |   4 +-
 arch/powerpc/platforms/pseries/Kconfig|   1 +
 5 files changed, 133 insertions(+), 40 deletions(-)

-- 
2.1.0

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

Re: [PATCH v3 2/2] selftests/powerpc: Add a test of the switch_endian() syscall

2015-03-16 Thread Anshuman Khandual
On 03/16/2015 12:27 PM, Michael Ellerman wrote:
> This adds a test of the switch_endian() syscall we added in the previous
> commit.
> 
> We test it by calling the endian switch syscall, and then executing some
> code in the other endian to check everything went as expected. That code
> checks registers we expect to be maintained are, and then writes to
> stdout. If the endian switch failed to happen that code sequence will be
> illegal and cause the test to abort.
> 
> We then switch back to the original endian, do the same checks and
> finally write a success message and exit(0).
> 
> Signed-off-by: Michael Ellerman 

Hey Michael,

Did a quick test, passes on LE but seems like failing on BE.

On LE:

Hello wrong-endian world
Hello right-endian world
success: switch_endian_test


on BE:

Hello wrong-endian world (returns 176)

The previous version of the test was passing both on LE
and BE (after applying the compiler trick in the assembly)

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

Re: [PATCH v2 5/5] crypto: talitos: Add software backlog queue handling

2015-03-16 Thread Horia Geantă
On 3/4/2015 2:23 AM, Kim Phillips wrote:
> Only potential problem is getting the crypto API to set the GFP_DMA
> flag in the allocation request, but presumably a
> CRYPTO_TFM_REQ_DMA crt_flag can be made to handle that.

Seems there are quite a few places that do not use the
{aead,ablkcipher_ahash}_request_alloc() API to allocate crypto requests.
Among them, IPsec and dm-crypt.
I've looked at the code and I don't think it can be converted to use
crypto API.

This means that the CRYPTO_TFM_REQ_DMA would be visible to all of these
places. Some of the maintainers do not agree, as you've seen.

An alternative would be for talitos to use the page allocator to get 1 /
2 pages at probe time (4 channels x 32 entries/channel x 64B/descriptor
= 8 kB), dma_map_page the area and manage it internally for talitos_desc
hw descriptors.
What do you think?

Thanks,
Horia


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

Re: linux panic on 4.0.0-rc4

2015-03-16 Thread Michael Ellerman
On Mon, 2015-03-16 at 01:34 -0400, Pranith Kumar wrote:
> On Mon, Mar 16, 2015 at 1:11 AM, Pranith Kumar  wrote:
> > Hello,
> >
> > I have a power mac mini 32-bit system.
> >
> ...
> > You can see the panic message here: http://imgur.com/s1lH15g. (there
> > is no log and I have no serial console).
> 
> There was some debug code in there when it hit. The actual hang seems
> to be in printk_late_init(). It does not return from this. May be this
> is a hint?

That is where the boot consoles get disabled and it switches to the "real"
console. It suggests that the system is not "hung" there but you just lost
output.

Try booting with "keep_bootcon" ?

If that doesn't help try booting with "udbg-immortal".

cheers


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

[PATCH v2 2/2] drivers/vfio: Support EEH error injection

2015-03-16 Thread Gavin Shan
The patch adds one more EEH sub-command (VFIO_EEH_PE_INJECT_ERR)
to inject the specified EEH error, which is represented by
(struct vfio_eeh_pe_err), to the indicated PE for testing purpose.

Signed-off-by: Gavin Shan 
---
v2: Put additional arguments for error injection to union
---
 Documentation/vfio.txt| 12 
 drivers/vfio/vfio_spapr_eeh.c | 10 ++
 include/uapi/linux/vfio.h | 36 +++-
 3 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/Documentation/vfio.txt b/Documentation/vfio.txt
index 96978ec..c6e11a3 100644
--- a/Documentation/vfio.txt
+++ b/Documentation/vfio.txt
@@ -385,6 +385,18 @@ The code flow from the example above should be slightly 
changed:
 

 
+   /* Inject EEH error, which is expected to be caused by 32-bits
+* config load.
+*/
+   pe_op.op = VFIO_EEH_PE_INJECT_ERR;
+   pe_op.err.type = VFIO_EEH_ERR_TYPE_32;
+   pe_op.err.func = VFIO_EEH_ERR_FUNC_LD_CFG_ADDR;
+   pe_op.err.addr = 0ul;
+   pe_op.err.mask = 0ul;
+   ioctl(container, VFIO_EEH_PE_OP, &pe_op);
+
+   
+
/* When 0xFF's returned from reading PCI config space or IO BARs
 * of the PCI device. Check the PE's state to see if that has been
 * frozen.
diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c
index 5fa42db..25ca634 100644
--- a/drivers/vfio/vfio_spapr_eeh.c
+++ b/drivers/vfio/vfio_spapr_eeh.c
@@ -85,6 +85,16 @@ long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
case VFIO_EEH_PE_CONFIGURE:
ret = eeh_pe_configure(pe);
break;
+   case VFIO_EEH_PE_INJECT_ERR:
+   if (op.argsz < sizeof(struct vfio_eeh_pe_op))
+   return -EINVAL;
+   if (copy_from_user(&op, (void __user *)arg,
+  sizeof(struct vfio_eeh_pe_op)))
+   return -EFAULT;
+
+   ret = eeh_pe_inject_err(pe, op.err.type, op.err.func,
+   op.err.addr, op.err.mask);
+   break;
default:
ret = -EINVAL;
}
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 82889c3..f68e962 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -468,12 +468,23 @@ struct vfio_iommu_spapr_tce_info {
  * - unfreeze IO/DMA for frozen PE;
  * - read PE state;
  * - reset PE;
- * - configure PE.
+ * - configure PE;
+ * - inject EEH error.
  */
+struct vfio_eeh_pe_err {
+   __u32 type;
+   __u32 func;
+   __u64 addr;
+   __u64 mask;
+};
+
 struct vfio_eeh_pe_op {
__u32 argsz;
__u32 flags;
__u32 op;
+   union {
+   struct vfio_eeh_pe_err err;
+   };
 };
 
 #define VFIO_EEH_PE_DISABLE0   /* Disable EEH functionality */
@@ -490,6 +501,29 @@ struct vfio_eeh_pe_op {
 #define VFIO_EEH_PE_RESET_HOT  6   /* Assert hot reset  */
 #define VFIO_EEH_PE_RESET_FUNDAMENTAL  7   /* Assert fundamental reset  */
 #define VFIO_EEH_PE_CONFIGURE  8   /* PE configuration  */
+#define VFIO_EEH_PE_INJECT_ERR 9   /* Inject EEH error  */
+#define  VFIO_EEH_ERR_TYPE_32  0   /* 32-bits EEH error type*/
+#define  VFIO_EEH_ERR_TYPE_64  1   /* 64-bits EEH error type*/
+#define  VFIO_EEH_ERR_FUNC_LD_MEM_ADDR 0   /* Memory load  */
+#define  VFIO_EEH_ERR_FUNC_LD_MEM_DATA 1
+#define  VFIO_EEH_ERR_FUNC_LD_IO_ADDR  2   /* IO load  */
+#define  VFIO_EEH_ERR_FUNC_LD_IO_DATA  3
+#define  VFIO_EEH_ERR_FUNC_LD_CFG_ADDR 4   /* Config load  */
+#define  VFIO_EEH_ERR_FUNC_LD_CFG_DATA 5
+#define  VFIO_EEH_ERR_FUNC_ST_MEM_ADDR 6   /* Memory store */
+#define  VFIO_EEH_ERR_FUNC_ST_MEM_DATA 7
+#define  VFIO_EEH_ERR_FUNC_ST_IO_ADDR  8   /* IO store */
+#define  VFIO_EEH_ERR_FUNC_ST_IO_DATA  9
+#define  VFIO_EEH_ERR_FUNC_ST_CFG_ADDR 10  /* Config store */
+#define  VFIO_EEH_ERR_FUNC_ST_CFG_DATA 11
+#define  VFIO_EEH_ERR_FUNC_DMA_RD_ADDR 12  /* DMA read */
+#define  VFIO_EEH_ERR_FUNC_DMA_RD_DATA 13
+#define  VFIO_EEH_ERR_FUNC_DMA_RD_MASTER   14
+#define  VFIO_EEH_ERR_FUNC_DMA_RD_TARGET   15
+#define  VFIO_EEH_ERR_FUNC_DMA_WR_ADDR 16  /* DMA write*/
+#define  VFIO_EEH_ERR_FUNC_DMA_WR_DATA 17
+#define  VFIO_EEH_ERR_FUNC_DMA_WR_MASTER   18
+#define  VFIO_EEH_ERR_FUNC_DMA_WR_TARGET   19
 
 #define VFIO_EEH_PE_OP _IO(VFIO_TYPE, VFIO_BASE + 21)
 
-- 
1.8.3.2

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

[PATCH v2 1/2] powerpc/eeh: Introduce eeh_pe_inject_err()

2015-03-16 Thread Gavin Shan
The patch defines PCI error types and functions in eeh.h and
exports function eeh_pe_inject_err(), which will be called by
VFIO driver to inject the specified PCI error to the indicated
PE for testing purpose.

Signed-off-by: Gavin Shan 
---
v2: Use EEH_ERR_FUNC_{MIN,MAX} to validate PCI error function
---
 arch/powerpc/include/asm/eeh.h | 26 ++
 arch/powerpc/kernel/eeh.c  | 40 
 2 files changed, 66 insertions(+)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 55abfd0..44366fa 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -195,6 +195,30 @@ enum {
 #define EEH_RESET_FUNDAMENTAL  3   /* Fundamental reset*/
 #define EEH_LOG_TEMP   1   /* EEH temporary error log  */
 #define EEH_LOG_PERM   2   /* EEH permanent error log  */
+#define EEH_ERR_TYPE_320   /* 32-bits PCI error
*/
+#define EEH_ERR_TYPE_641   /* 64-bits PCI error
*/
+#define EEH_ERR_FUNC_MIN   0
+#define EEH_ERR_FUNC_LD_MEM_ADDR   0   /* Memory load  */
+#define EEH_ERR_FUNC_LD_MEM_DATA   1
+#define EEH_ERR_FUNC_LD_IO_ADDR2   /* IO load  */
+#define EEH_ERR_FUNC_LD_IO_DATA3
+#define EEH_ERR_FUNC_LD_CFG_ADDR   4   /* Config load  */
+#define EEH_ERR_FUNC_LD_CFG_DATA   5
+#define EEH_ERR_FUNC_ST_MEM_ADDR   6   /* Memory store */
+#define EEH_ERR_FUNC_ST_MEM_DATA   7
+#define EEH_ERR_FUNC_ST_IO_ADDR8   /* IO store */
+#define EEH_ERR_FUNC_ST_IO_DATA9
+#define EEH_ERR_FUNC_ST_CFG_ADDR   10  /* Config store */
+#define EEH_ERR_FUNC_ST_CFG_DATA   11
+#define EEH_ERR_FUNC_DMA_RD_ADDR   12  /* DMA read */
+#define EEH_ERR_FUNC_DMA_RD_DATA   13
+#define EEH_ERR_FUNC_DMA_RD_MASTER 14
+#define EEH_ERR_FUNC_DMA_RD_TARGET 15
+#define EEH_ERR_FUNC_DMA_WR_ADDR   16  /* DMA write*/
+#define EEH_ERR_FUNC_DMA_WR_DATA   17
+#define EEH_ERR_FUNC_DMA_WR_MASTER 18
+#define EEH_ERR_FUNC_DMA_WR_TARGET 19
+#define EEH_ERR_FUNC_MAX   19
 
 struct eeh_ops {
char *name;
@@ -295,6 +319,8 @@ int eeh_pe_set_option(struct eeh_pe *pe, int option);
 int eeh_pe_get_state(struct eeh_pe *pe);
 int eeh_pe_reset(struct eeh_pe *pe, int option);
 int eeh_pe_configure(struct eeh_pe *pe);
+int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
+ unsigned long addr, unsigned long mask);
 
 /**
  * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 19a897c..55083e5 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1651,6 +1651,46 @@ int eeh_pe_configure(struct eeh_pe *pe)
 }
 EXPORT_SYMBOL_GPL(eeh_pe_configure);
 
+/**
+ * eeh_pe_inject_err - Injecting the specified PCI error to the indicated PE
+ * @pe: the indicated PE
+ * @type: error type
+ * @function: error function
+ * @addr: address
+ * @mask: address mask
+ *
+ * The routine is called to inject the specified PCI error, which
+ * is determined by @type and @function, to the indicated PE for
+ * testing purpose.
+ */
+int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
+ unsigned long addr, unsigned long mask)
+{
+   /* Invalid PE ? */
+   if (!pe)
+   return -ENODEV;
+
+   /* Unsupported operation ? */
+   if (!eeh_ops || !eeh_ops->err_inject)
+   return -ENOENT;
+
+   /* Check on PCI error type */
+   switch (type) {
+   case EEH_ERR_TYPE_32:
+   case EEH_ERR_TYPE_64:
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   /* Check on PCI error function */
+   if (func < EEH_ERR_FUNC_MIN || func > EEH_ERR_FUNC_MAX)
+   return -EINVAL;
+
+   return eeh_ops->err_inject(pe, type, func, addr, mask);
+}
+EXPORT_SYMBOL_GPL(eeh_pe_inject_err);
+
 static int proc_eeh_show(struct seq_file *m, void *v)
 {
if (!eeh_enabled()) {
-- 
1.8.3.2

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