LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 3/3] powerpc/perf: Fix setting of "to" addresses for BHRB
From: Michael Neuling @ 2013-05-14  4:44 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Michael Neuling, linuxppc-dev, Anshuman Khandual
In-Reply-To: <9911.1368179795@ale.ozlabs.ibm.com>

Currently we only set the "to" address in the branch stack when the CPU
explicitly gives us a value.  Unfortunately it only does this for XL form
branches (eg blr, bctr, bctar) and not I and B form branches (eg b, bc).

Fortunately if we read the instruction from memory we can extract the offset of
a branch and calculate the target address.

This adds a function power_pmu_bhrb_to() to calculate the target/to address of
the corresponding I and B form branches.  It handles branches in both user and
kernel spaces.  It also plumbs this into the perf brhb reading code.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 arch/powerpc/perf/core-book3s.c |   31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 3fdfe45..426180b 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -13,11 +13,13 @@
 #include <linux/perf_event.h>
 #include <linux/percpu.h>
 #include <linux/hardirq.h>
+#include <linux/uaccess.h>
 #include <asm/reg.h>
 #include <asm/pmc.h>
 #include <asm/machdep.h>
 #include <asm/firmware.h>
 #include <asm/ptrace.h>
+#include <asm/code-patching.h>
 
 #define BHRB_MAX_ENTRIES	32
 #define BHRB_TARGET		0x0000000000000002
@@ -362,6 +364,32 @@ void power_pmu_flush_branch_stack(void)
 	if (ppmu->bhrb_nr)
 		power_pmu_bhrb_reset();
 }
+/* Calculate the to address for a branch */
+static __u64 power_pmu_bhrb_to(u64 addr)
+{
+	unsigned int instr;
+	int ret;
+	__u64 target;
+
+	if (is_kernel_addr(addr))
+		return branch_target((unsigned int *)addr);
+
+	/* Userspace: need copy instruction here then translate it */
+	pagefault_disable();
+	ret = __get_user_inatomic(instr, (unsigned int __user *)addr);
+	if (ret) {
+		pagefault_enable();
+		return 0;
+	}
+	pagefault_enable();
+
+	target = branch_target(&instr);
+	if ((!target) || (instr & BRANCH_ABSOLUTE))
+		return target;
+
+	/* Translate relative branch target from kernel to user address */
+	return target - (unsigned long)&instr + addr;
+}
 
 /* Processing BHRB entries */
 void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw)
@@ -426,7 +454,8 @@ void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw)
 				/* Branches to immediate field 
 				   (ie I or B form) */
 				cpuhw->bhrb_entries[u_index].from = addr;
-				cpuhw->bhrb_entries[u_index].to = 0;
+				cpuhw->bhrb_entries[u_index].to =
+					power_pmu_bhrb_to(addr);
 				cpuhw->bhrb_entries[u_index].mispred = pred;
 				cpuhw->bhrb_entries[u_index].predicted = ~pred;
 			}
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 1/2] powerpc/powernv: Detect OPAL v3 API version
From: Benjamin Herrenschmidt @ 2013-05-14  5:53 UTC (permalink / raw)
  To: linuxppc-dev

Future firmwares will support that new version. We need that
to properly fix CPU starting under OPAL with kexec.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/include/asm/firmware.h    |    4 +++-
 arch/powerpc/include/asm/opal.h        |    3 ++-
 arch/powerpc/platforms/powernv/opal.c  |    6 +++++-
 arch/powerpc/platforms/powernv/setup.c |    4 +++-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h
index 0df5464..681bc03 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -52,6 +52,7 @@
 #define FW_FEATURE_BEST_ENERGY	ASM_CONST(0x0000000080000000)
 #define FW_FEATURE_TYPE1_AFFINITY ASM_CONST(0x0000000100000000)
 #define FW_FEATURE_PRRN		ASM_CONST(0x0000000200000000)
+#define FW_FEATURE_OPALv3	ASM_CONST(0x0000000400000000)
 
 #ifndef __ASSEMBLY__
 
@@ -69,7 +70,8 @@ enum {
 		FW_FEATURE_SET_MODE | FW_FEATURE_BEST_ENERGY |
 		FW_FEATURE_TYPE1_AFFINITY | FW_FEATURE_PRRN,
 	FW_FEATURE_PSERIES_ALWAYS = 0,
-	FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_OPALv2,
+	FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_OPALv2 |
+		FW_FEATURE_OPALv3,
 	FW_FEATURE_POWERNV_ALWAYS = 0,
 	FW_FEATURE_PS3_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
 	FW_FEATURE_PS3_ALWAYS = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index b2906ad..cbb9305 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -243,7 +243,8 @@ enum OpalMCE_TlbErrorType {
 
 enum OpalThreadStatus {
 	OPAL_THREAD_INACTIVE = 0x0,
-	OPAL_THREAD_STARTED = 0x1
+	OPAL_THREAD_STARTED = 0x1,
+	OPAL_THREAD_UNAVAILABLE = 0x2 /* opal-v3 */
 };
 
 enum OpalPciBusCompare {
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 27907cb..628c564 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -56,7 +56,11 @@ int __init early_init_dt_scan_opal(unsigned long node,
 		 opal.entry, entryp, entrysz);
 
 	powerpc_firmware_features |= FW_FEATURE_OPAL;
-	if (of_flat_dt_is_compatible(node, "ibm,opal-v2")) {
+	if (of_flat_dt_is_compatible(node, "ibm,opal-v3")) {
+		powerpc_firmware_features |= FW_FEATURE_OPALv2;
+		powerpc_firmware_features |= FW_FEATURE_OPALv3;
+		printk("OPAL V3 detected !\n");
+	} else if (of_flat_dt_is_compatible(node, "ibm,opal-v2")) {
 		powerpc_firmware_features |= FW_FEATURE_OPALv2;
 		printk("OPAL V2 detected !\n");
 	} else {
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index c20381c..d4459bf 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -78,7 +78,9 @@ static void pnv_show_cpuinfo(struct seq_file *m)
 	if (root)
 		model = of_get_property(root, "model", NULL);
 	seq_printf(m, "machine\t\t: PowerNV %s\n", model);
-	if (firmware_has_feature(FW_FEATURE_OPALv2))
+	if (firmware_has_feature(FW_FEATURE_OPALv3))
+		seq_printf(m, "firmware\t: OPAL v3\n");
+	else if (firmware_has_feature(FW_FEATURE_OPALv2))
 		seq_printf(m, "firmware\t: OPAL v2\n");
 	else if (firmware_has_feature(FW_FEATURE_OPAL))
 		seq_printf(m, "firmware\t: OPAL v1\n");

^ permalink raw reply related

* [PATCH 2/2] powerpc/powernv: Fix starting of secondary CPUs on OPALv2 and v3
From: Benjamin Herrenschmidt @ 2013-05-14  5:54 UTC (permalink / raw)
  To: linuxppc-dev

The current code fails to handle kexec on OPALv2. This fixes it
and adds code to improve the situation on OPALv3 where we can
query the CPU status from the firmware and decide what to do
based on that.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/platforms/powernv/smp.c |   62 ++++++++++++++++++++++++++++++----
 1 file changed, 56 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index 6a3ecca..88c9459 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -71,18 +71,68 @@ int pnv_smp_kick_cpu(int nr)
 
 	BUG_ON(nr < 0 || nr >= NR_CPUS);
 
-	/* On OPAL v2 the CPU are still spinning inside OPAL itself,
-	 * get them back now
+	/*
+	 * If we already started or OPALv2 is not supported, we just
+	 * kick the CPU via the PACA
 	 */
-	if (!paca[nr].cpu_start && firmware_has_feature(FW_FEATURE_OPALv2)) {
-		pr_devel("OPAL: Starting CPU %d (HW 0x%x)...\n", nr, pcpu);
-		rc = opal_start_cpu(pcpu, start_here);
+	if (paca[nr].cpu_start || !firmware_has_feature(FW_FEATURE_OPALv2))
+		goto kick;
+
+	/*
+	 * At this point, the CPU can either be spinning on the way in
+	 * from kexec or be inside OPAL waiting to be started for the
+	 * first time. OPAL v3 allows us to query OPAL to know if it
+	 * has the CPUs, so we do that
+	 */
+	if (firmware_has_feature(FW_FEATURE_OPALv3)) {
+		uint8_t status;
+
+		rc = opal_query_cpu_status(pcpu, &status);
 		if (rc != OPAL_SUCCESS) {
-			pr_warn("OPAL Error %ld starting CPU %d\n",
+			pr_warn("OPAL Error %ld querying CPU %d state\n",
 				rc, nr);
 			return -ENODEV;
 		}
+
+		/*
+		 * Already started, just kick it, probably coming from
+		 * kexec and spinning
+		 */
+		if (status == OPAL_THREAD_STARTED)
+			goto kick;
+
+		/*
+		 * Available/inactive, let's kick it
+		 */
+		if (status == OPAL_THREAD_INACTIVE) {
+			pr_devel("OPAL: Starting CPU %d (HW 0x%x)...\n",
+				 nr, pcpu);
+			rc = opal_start_cpu(pcpu, start_here);
+			if (rc != OPAL_SUCCESS) {
+				pr_warn("OPAL Error %ld starting CPU %d\n",
+					rc, nr);
+				return -ENODEV;
+			}
+		} else {
+			/*
+			 * An unavailable CPU (or any other unknown status)
+			 * shouldn't be started. It should also
+			 * not be in the possible map but currently it can
+			 * happen
+			 */
+			pr_devel("OPAL: CPU %d (HW 0x%x) is unavailable"
+				 " (status %d)...\n", nr, pcpu, status);
+			return -ENODEV;
+		}
+	} else {
+		/*
+		 * On OPAL v2, we just kick it and hope for the best,
+		 * we must not test the error from opal_start_cpu() or
+		 * we would fail to get CPUs from kexec.
+		 */
+		opal_start_cpu(pcpu, start_here);
 	}
+ kick:
 	return smp_generic_kick_cpu(nr);
 }
 

^ permalink raw reply related

* Re: [PATCH] powerpc: provide __bswapdi2
From: David Woodhouse @ 2013-05-14  6:59 UTC (permalink / raw)
  To: Michael Neuling; +Cc: Stephen Rothwell, viro, Linux PPC dev
In-Reply-To: <CAEjGV6yR+GSwu_CZWSLrL8q8D-AM7yi3685fq9vgjt9MN7HPTA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1235 bytes --]

On Tue, 2013-05-14 at 11:25 +1000, Michael Neuling wrote:
> 
> > So, if we are just stealing the output of gcc, why not just use the C
> > version (at least for 32 bit)?
> 
> Woodhouse: can we just do this?

Sure, if you don't mind GCC optimising the contents of your C function
by turning it into a call to libgcc's __bswapdi2() :)

OK, you might be able to do some archaeology and determine that the only
compiler that emits calls to __bswapdi2() is GCC 4.4, and furthermore
that the same compiler *doesn't* have the wit to notice that the
contents of the function are a 64-bit byteswap, so it's never going to
happen. But I don't like that approach. I'd feel I have to sacrifice a
goat *anyway*, and I don't have a spare goat.

Although now I come to explicitly explain why I did it that way... it
occurs to me that the libgcc version is just written in C, and the
compiler evidently trusts itself not to optimise that into a recursive
call. Is there a compiler switch which guarantees that, which we could
use without other unwanted side-effects?
 
-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation




[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5745 bytes --]

^ permalink raw reply

* [PATCH] powerpc: Set show_unhandled_signals to 1 by default
From: Benjamin Herrenschmidt @ 2013-05-14  7:30 UTC (permalink / raw)
  To: linuxppc-dev

Just like other architectures

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/kernel/signal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index d63b502..577a8aa 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -25,7 +25,7 @@
  * through debug.exception-trace sysctl.
  */
 
-int show_unhandled_signals = 0;
+int show_unhandled_signals = 1;
 
 /*
  * Allocate space for the signal frame

^ permalink raw reply related

* Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
From: Gu Zheng @ 2013-05-14  8:26 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Neela Syam Kolli, sparclinux@vger.kernel.org, Toshi Kani,
	Jiang Liu, Linux-Scsi, David Airlie, Greg Kroah-Hartman,
	linuxppc-dev, Linux Kernel Mailing List, James E.J. Bottomley,
	Rafael J . Wysocki, Yijing Wang, linux-pci@vger.kernel.org,
	Bjorn Helgaas, Paul Mackerras, Andrew Morton, Myron Stowe,
	David S. Miller, Jiang Liu
In-Reply-To: <CAE9FiQVKKKmZRQ8CcKCzU8Gqzwb5SjWYagVB2OZiRqbSWXVpiw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

On 05/14/2013 01:23 AM, Yinghai Lu wrote:

> On Mon, May 13, 2013 at 9:08 AM, Jiang Liu <liuj97@gmail.com> wrote:
>> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 4f0bc0a..bc075a3 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1131,6 +1131,7 @@ static void pci_release_dev(struct device *dev)
>>         struct pci_dev *pci_dev;
>>
>>         pci_dev = to_pci_dev(dev);
>> +       pci_bus_put(pci_dev->bus);
>>         pci_release_capabilities(pci_dev);
>>         pci_release_of_node(pci_dev);
>>         kfree(pci_dev);
>> @@ -1269,11 +1270,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
>>         if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
>>                 return NULL;
>>
>> -       dev = alloc_pci_dev();
>> +       dev = pci_alloc_dev(bus);
>>         if (!dev)
>>                 return NULL;
>>
>> -       dev->bus = bus;
>>         dev->devfn = devfn;
>>         dev->vendor = l & 0xffff;
>>         dev->device = (l >> 16) & 0xffff;
> 
> in pci_setup_device() fail path, it release the ref to that bus.

Yes, you're right, we need to release the bus' ref if pci_setup_device() failed.
Thanks for your correction.:)

Best regards,
Gu

> 
> Yinghai
> 



[-- Attachment #2: Convert-alloc_pci_dev-void-to-pci_alloc_dev-v3.patch --]
[-- Type: text/plain, Size: 5295 bytes --]

>From 7add6d9e70919b95be2debde2f58fc31d26c75bf Mon Sep 17 00:00:00 2001
From: Gu Zheng <guz.fnst@cn.fujitsu.com>
Date: Tue, 14 May 2013 16:11:07 +0800
Subject: [PATCH v3] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead

v3:
  Follow Yinghai's correction to release the bus' ref
  in pci_setup_device() fail path.

v2:
  Follow Bjorn's correction to move pci_bus_put() to
  pci_release_dev() instead.

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
 arch/powerpc/kernel/pci_of_scan.c |    3 +--
 arch/sparc/kernel/pci.c           |    3 +--
 drivers/char/agp/alpha-agp.c      |    2 +-
 drivers/char/agp/parisc-agp.c     |    2 +-
 drivers/pci/iov.c                 |    8 +++++---
 drivers/pci/probe.c               |    5 +++--
 drivers/scsi/megaraid.c           |    2 +-
 7 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 2a67e9b..24d01c4 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -128,7 +128,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
 	const char *type;
 	struct pci_slot *slot;
 
-	dev = alloc_pci_dev();
+	dev = pci_alloc_dev(bus);
 	if (!dev)
 		return NULL;
 	type = of_get_property(node, "device_type", NULL);
@@ -137,7 +137,6 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
 
 	pr_debug("    create device, devfn: %x, type: %s\n", devfn, type);
 
-	dev->bus = bus;
 	dev->dev.of_node = of_node_get(node);
 	dev->dev.parent = bus->bridge;
 	dev->dev.bus = &pci_bus_type;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index baf4366..e5871fb 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -254,7 +254,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
 	const char *type;
 	u32 class;
 
-	dev = alloc_pci_dev();
+	dev = pci_alloc_dev(bus);
 	if (!dev)
 		return NULL;
 
@@ -281,7 +281,6 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
 		printk("    create device, devfn: %x, type: %s\n",
 		       devfn, type);
 
-	dev->bus = bus;
 	dev->sysdata = node;
 	dev->dev.parent = bus->bridge;
 	dev->dev.bus = &pci_bus_type;
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index dd84af4..199b8e9 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -174,7 +174,7 @@ alpha_core_agp_setup(void)
 	/*
 	 * Build a fake pci_dev struct
 	 */
-	pdev = alloc_pci_dev();
+	pdev = pci_alloc_dev(NULL);
 	if (!pdev)
 		return -ENOMEM;
 	pdev->vendor = 0xffff;
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 94821ab..bf5d247 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -333,7 +333,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
 	struct agp_bridge_data *bridge;
 	int error = 0;
 
-	fake_bridge_dev = alloc_pci_dev();
+	fake_bridge_dev = pci_alloc_dev(NULL);
 	if (!fake_bridge_dev) {
 		error = -ENOMEM;
 		goto fail;
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index c93071d..2652ca0 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -75,18 +75,20 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
 	struct pci_dev *virtfn;
 	struct resource *res;
 	struct pci_sriov *iov = dev->sriov;
+	struct pci_bus *bus;
 
-	virtfn = alloc_pci_dev();
+	virtfn = pci_alloc_dev(NULL);
 	if (!virtfn)
 		return -ENOMEM;
 
 	mutex_lock(&iov->dev->sriov->lock);
-	virtfn->bus = virtfn_add_bus(dev->bus, virtfn_bus(dev, id));
-	if (!virtfn->bus) {
+	bus = virtfn_add_bus(dev->bus, virtfn_bus(dev, id));
+	if (!bus) {
 		kfree(virtfn);
 		mutex_unlock(&iov->dev->sriov->lock);
 		return -ENOMEM;
 	}
+	virtfn->bus = pci_bus_get(bus);
 	virtfn->devfn = virtfn_devfn(dev, id);
 	virtfn->vendor = dev->vendor;
 	pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 70f10fa..db8dadc 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1130,6 +1130,7 @@ static void pci_release_dev(struct device *dev)
 	struct pci_dev *pci_dev;
 
 	pci_dev = to_pci_dev(dev);
+	pci_bus_put(pci_dev->bus);
 	pci_release_capabilities(pci_dev);
 	pci_release_of_node(pci_dev);
 	kfree(pci_dev);
@@ -1263,11 +1264,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
 	if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
 		return NULL;
 
-	dev = alloc_pci_dev();
+	dev = pci_alloc_dev(bus);
 	if (!dev)
 		return NULL;
 
-	dev->bus = bus;
 	dev->devfn = devfn;
 	dev->vendor = l & 0xffff;
 	dev->device = (l >> 16) & 0xffff;
@@ -1275,6 +1275,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
 	pci_set_of_node(dev);
 
 	if (pci_setup_device(dev)) {
+		pci_bus_put(bus);
 		kfree(dev);
 		return NULL;
 	}
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 846f475f..90c95a3 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -2026,7 +2026,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
 static inline int
 make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
 {
-	*pdev = alloc_pci_dev();
+	*pdev = pci_alloc_dev(NULL);
 
 	if( *pdev == NULL ) return -1;
 
-- 
1.7.7


^ permalink raw reply related

* [PATCH] powerpc/mpc85xx: fix non-bootcpu cannot up after hibernation resume
From: Wang Dongsheng @ 2013-05-14  8:05 UTC (permalink / raw)
  To: avorontsov
  Cc: chenhui.zhao, Wang Dongsheng, rjw, paulus, scottwood, johannes,
	linuxppc-dev

This problem belongs to the core synchronization issues.
The cpu1 already updated spin_table values, but bootcore cannot get
this value in time.

After bootcpu hibiernation restore the pages. we are now running
with the kernel data of the old kernel fully restored. if we reset
the non-bootcpus that will be reset cache(tlb), the non-bootcpus
will get new address(map virtual and physical address spaces).
but bootcpu tlb cache still use boot kernel data, so we need to
invalidate the bootcpu tlb cache make it to get new main memory data.

log:
Enabling non-boot CPUs ...
smp_85xx_kick_cpu: timeout waiting for core 1 to reset
smp: failed starting cpu 1 (rc -2)
Error taking CPU1 up: -2

Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>

diff --git a/arch/powerpc/kernel/swsusp_booke.S b/arch/powerpc/kernel/swsusp_booke.S
index 11a3930..9503249 100644
--- a/arch/powerpc/kernel/swsusp_booke.S
+++ b/arch/powerpc/kernel/swsusp_booke.S
@@ -141,6 +141,19 @@ _GLOBAL(swsusp_arch_resume)
 	lis	r11,swsusp_save_area@h
 	ori	r11,r11,swsusp_save_area@l
 
+	/*
+	 * The boot core get a virtual address, when the boot process,
+	 * the virtual address corresponds to a physical address. After
+	 * hibernation resume memory snapshots, The corresponding
+	 * relationship between the virtual memory and physical memory
+	 * might change again. We need to get a new page table. So we
+	 * need to invalidate TLB after resume pages.
+	 *
+	 * Invalidations TLB Using tlbilx/tlbivax/MMUCSR0.
+	 * tlbilx used here.
+	 */
+	bl	_tlbil_all
+
 	lwz	r4,SL_SPRG0(r11)
 	mtsprg	0,r4
 	lwz	r4,SL_SPRG1(r11)
-- 
1.8.0

^ permalink raw reply related

* RE: [PATCH] powerpc/mpc85xx: fix non-bootcpu cannot up after hibernation resume
From: Wang Dongsheng-B40534 @ 2013-05-14  8:59 UTC (permalink / raw)
  To: anton.vorontsov@linaro.org
  Cc: Wood Scott-B07421, Li Yang-R58472, Zhao Chenhui-B35336,
	rjw@sisk.pl, paulus@samba.org, johannes@sipsolutions.net,
	linuxppc-dev@lists.ozlabs.org
In-Reply-To: <1368518756-9850-1-git-send-email-dongsheng.wang@freescale.com>

I send to a wrong email address "Anton Vorontsov <avorontsov@ru.mvista.com>=
"

Add Anton Vorontsov <anton.vorontsov@linaro.org> to this email.

Thanks all.

> -----Original Message-----
> From: Wang Dongsheng-B40534
> Sent: Tuesday, May 14, 2013 4:06 PM
> To: avorontsov@ru.mvista.com
> Cc: paulus@samba.org; rjw@sisk.pl; benh@kernel.crashing.org;
> johannes@sipsolutions.net; Wood Scott-B07421; Li Yang-R58472; Zhao
> Chenhui-B35336; linuxppc-dev@lists.ozlabs.org; Wang Dongsheng-B40534
> Subject: [PATCH] powerpc/mpc85xx: fix non-bootcpu cannot up after
> hibernation resume
>=20
> This problem belongs to the core synchronization issues.
> The cpu1 already updated spin_table values, but bootcore cannot get
> this value in time.
>=20
> After bootcpu hibiernation restore the pages. we are now running
> with the kernel data of the old kernel fully restored. if we reset
> the non-bootcpus that will be reset cache(tlb), the non-bootcpus
> will get new address(map virtual and physical address spaces).
> but bootcpu tlb cache still use boot kernel data, so we need to
> invalidate the bootcpu tlb cache make it to get new main memory data.
>=20
> log:
> Enabling non-boot CPUs ...
> smp_85xx_kick_cpu: timeout waiting for core 1 to reset
> smp: failed starting cpu 1 (rc -2)
> Error taking CPU1 up: -2
>=20
> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
>=20
> diff --git a/arch/powerpc/kernel/swsusp_booke.S
> b/arch/powerpc/kernel/swsusp_booke.S
> index 11a3930..9503249 100644
> --- a/arch/powerpc/kernel/swsusp_booke.S
> +++ b/arch/powerpc/kernel/swsusp_booke.S
> @@ -141,6 +141,19 @@ _GLOBAL(swsusp_arch_resume)
>  	lis	r11,swsusp_save_area@h
>  	ori	r11,r11,swsusp_save_area@l
>=20
> +	/*
> +	 * The boot core get a virtual address, when the boot process,
> +	 * the virtual address corresponds to a physical address. After
> +	 * hibernation resume memory snapshots, The corresponding
> +	 * relationship between the virtual memory and physical memory
> +	 * might change again. We need to get a new page table. So we
> +	 * need to invalidate TLB after resume pages.
> +	 *
> +	 * Invalidations TLB Using tlbilx/tlbivax/MMUCSR0.
> +	 * tlbilx used here.
> +	 */
> +	bl	_tlbil_all
> +
>  	lwz	r4,SL_SPRG0(r11)
>  	mtsprg	0,r4
>  	lwz	r4,SL_SPRG1(r11)
> --
> 1.8.0

^ permalink raw reply

* RE: [PATCH v3 1/4] powerpc/mpic: add irq_set_wake support
From: Wang Dongsheng-B40534 @ 2013-05-14  9:03 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Wood Scott-B07421, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <1368421223.19924.16.camel@pasglop>

VGhhbmtzIGJlbi4gOikNCg0KLSBkb25nc2hlbmcuDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdl
LS0tLS0NCj4gRnJvbTogQmVuamFtaW4gSGVycmVuc2NobWlkdCBbbWFpbHRvOmJlbmhAa2VybmVs
LmNyYXNoaW5nLm9yZ10NCj4gU2VudDogTW9uZGF5LCBNYXkgMTMsIDIwMTMgMTowMCBQTQ0KPiBU
bzogV2FuZyBEb25nc2hlbmctQj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2013-05-14  9:57 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linuxppc-dev, Linux Kernel list

Hi Linus !

Here are some more powerpc fixes to apply to 3.10. This is mostly bug
fixes (some of them regressions, some of them I deemed worth merging
now) along with some patches from Li Zhong hooking up the new
context tracking stuff (for the new full NO_HZ)

Cheers,
Ben.

The following changes since commit 5737789c8340620d7b542d1d4e9b197de8eb2801:

  powerpc: Make hard_irq_disable() do the right thing vs. irq tracing (2013-05-07 17:13:57 +1000)

are available in the git repository at:

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

for you to fetch changes up to e34166ad63eac4d0fa98b4c4ed7a98202a18faef:

  powerpc: Set show_unhandled_signals to 1 by default (2013-05-14 18:01:04 +1000)

----------------------------------------------------------------
Alexander Gordeev (1):
      powerpc: Fix irq_set_affinity() return values

Alistair Popple (1):
      powerpc: Add an in memory udbg console

Aneesh Kumar K.V (2):
      powerpc/mm: Use the correct mask value when looking at pgtable address
      powerpc: Fix build errors STRICT_MM_TYPECHECKS

Anton Blanchard (1):
      powerpc/kexec: Fix kexec when using VMX optimised memcpy

Benjamin Herrenschmidt (5):
      powerpc/powernv: Properly drop characters if console is closed
      powerpc/powernv: Improve kexec reliability
      powerpc/powernv: Detect OPAL v3 API version
      powerpc/powernv: Fix starting of secondary CPUs on OPALv2 and v3
      powerpc: Set show_unhandled_signals to 1 by default

David Woodhouse (1):
      powerpc: Provide __bswapdi2

Li Zhong (6):
      powerpc: Fix MAX_STACK_TRACE_ENTRIES too low warning again
      powerpc: Syscall hooks for context tracking subsystem
      powerpc: Exception hooks for context tracking subsystem
      powerpc: Exit user context on notify resume
      powerpc: Use the new schedule_user API on userspace preemption
      powerpc: select HAVE_CONTEXT_TRACKING for pSeries

Michael Ellerman (1):
      powerpc: Make CONFIG_RTAS_PROC depend on CONFIG_PROC_FS

Michael Neuling (3):
      powerpc/perf: Move BHRB code into CONFIG_PPC64 region
      powerpc/pmu: Fix order of interpreting BHRB target entries
      powerpc/perf: Fix setting of "to" addresses for BHRB

Robert Jennings (1):
      powerpc: Bring all threads online prior to migration/hibernation

Scott Wood (2):
      powerpc: hard_irq_disable(): Call trace_hardirqs_off after disabling
      powerpc/booke64: Fix kernel hangs at kernel_dbg_exc

Vasant Hegde (1):
      powerpc/rtas_flash: Fix validate_flash buffer overflow issue

 arch/powerpc/Kconfig.debug                  |   23 +++
 arch/powerpc/include/asm/context_tracking.h |   10 +
 arch/powerpc/include/asm/firmware.h         |    4 +-
 arch/powerpc/include/asm/hw_irq.h           |    5 +-
 arch/powerpc/include/asm/opal.h             |    5 +-
 arch/powerpc/include/asm/pgalloc-64.h       |    2 +-
 arch/powerpc/include/asm/pte-hash64-64k.h   |    2 +-
 arch/powerpc/include/asm/rtas.h             |    2 +
 arch/powerpc/include/asm/thread_info.h      |    7 +-
 arch/powerpc/include/asm/udbg.h             |    1 +
 arch/powerpc/kernel/entry_32.S              |    2 -
 arch/powerpc/kernel/entry_64.S              |    5 +-
 arch/powerpc/kernel/exceptions-64e.S        |    8 +-
 arch/powerpc/kernel/machine_kexec_64.c      |    4 +
 arch/powerpc/kernel/misc_32.S               |   11 ++
 arch/powerpc/kernel/misc_64.S               |   11 ++
 arch/powerpc/kernel/pci-common.c            |    5 +-
 arch/powerpc/kernel/ppc_ksyms.c             |    3 +-
 arch/powerpc/kernel/process.c               |    8 +
 arch/powerpc/kernel/ptrace.c                |    5 +
 arch/powerpc/kernel/rtas.c                  |  113 +++++++++++
 arch/powerpc/kernel/rtas_flash.c            |   10 +-
 arch/powerpc/kernel/signal.c                |    7 +-
 arch/powerpc/kernel/traps.c                 |   80 +++++---
 arch/powerpc/kernel/udbg.c                  |    3 +
 arch/powerpc/mm/fault.c                     |   41 ++--
 arch/powerpc/mm/hash_utils_64.c             |   36 +++-
 arch/powerpc/mm/init_64.c                   |    3 +-
 arch/powerpc/perf/core-book3s.c             |  280 +++++++++++++++------------
 arch/powerpc/platforms/Kconfig              |    2 +-
 arch/powerpc/platforms/powernv/opal.c       |   30 ++-
 arch/powerpc/platforms/powernv/pci-ioda.c   |    9 +
 arch/powerpc/platforms/powernv/pci.c        |   12 ++
 arch/powerpc/platforms/powernv/pci.h        |    2 +
 arch/powerpc/platforms/powernv/powernv.h    |    2 +
 arch/powerpc/platforms/powernv/setup.c      |   16 +-
 arch/powerpc/platforms/powernv/smp.c        |   62 +++++-
 arch/powerpc/platforms/pseries/Kconfig      |    1 +
 arch/powerpc/platforms/pseries/suspend.c    |   22 +++
 arch/powerpc/platforms/wsp/ics.c            |    2 +-
 arch/powerpc/sysdev/Makefile                |    2 +
 arch/powerpc/sysdev/ehv_pic.c               |    2 +-
 arch/powerpc/sysdev/mpic.c                  |    2 +-
 arch/powerpc/sysdev/udbg_memcons.c          |  105 ++++++++++
 arch/powerpc/sysdev/xics/ics-opal.c         |    2 +-
 45 files changed, 763 insertions(+), 206 deletions(-)
 create mode 100644 arch/powerpc/include/asm/context_tracking.h
 create mode 100644 arch/powerpc/sysdev/udbg_memcons.c

^ permalink raw reply

* [PATCH v1 0/2] powerpc/mpc512x: improve common platform code
From: Gerhard Sittig @ 2013-05-14 14:40 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Gerhard Sittig, agust

the first change concentrates specific details in the shared routines,
and passes all board support for the ADS, PDM, and generic boards
through the common MPC512x code (specifically the init, init early, and
setup arch routines)

the second change slightly modifies behaviour in that it moves the
restart initialization to an earlier stage in the boot process, to
prevent hangs and allow boards to reboot upon early failure


Gerhard Sittig (2):
  powerpc/mpc512x: move common code to the shared.c file
  powerpc/mpc512x: initialize board restart earlier

 arch/powerpc/include/asm/mpc5121.h            |    1 -
 arch/powerpc/platforms/512x/mpc5121_ads.c     |    6 ++----
 arch/powerpc/platforms/512x/mpc512x.h         |   11 ++---------
 arch/powerpc/platforms/512x/mpc512x_generic.c |    4 ++--
 arch/powerpc/platforms/512x/mpc512x_shared.c  |   16 ++++++++++++++--
 arch/powerpc/platforms/512x/pdm360ng.c        |    4 ++--
 6 files changed, 22 insertions(+), 20 deletions(-)

-- 
1.7.10.4

^ permalink raw reply

* [PATCH v1 1/2] powerpc/mpc512x: move common code to shared.c file
From: Gerhard Sittig @ 2013-05-14 14:40 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Gerhard Sittig, agust
In-Reply-To: <1368542454-11003-1-git-send-email-gsi@denx.de>

- implement all of the init, init early, and setup arch routines in the
  shared source file for the MPC512x PowerPC platform, and make all
  MPC512x based boards (ADS, PDM, generic) use those common routines
- remove declarations from header files for routines which aren't
  referenced from external callers any longer

this modification concentrates knowledge about the optional FSL DIU
support in one spot within the shared code, and makes all boards benefit
transparently from future improvements in the shared platform code

the change does not modify any behaviour but preserves all code paths

Signed-off-by: Gerhard Sittig <gsi@denx.de>
---
 arch/powerpc/include/asm/mpc5121.h            |    1 -
 arch/powerpc/platforms/512x/mpc5121_ads.c     |    6 ++----
 arch/powerpc/platforms/512x/mpc512x.h         |   11 ++---------
 arch/powerpc/platforms/512x/mpc512x_generic.c |    4 ++--
 arch/powerpc/platforms/512x/mpc512x_shared.c  |   14 +++++++++++++-
 arch/powerpc/platforms/512x/pdm360ng.c        |    4 ++--
 6 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/include/asm/mpc5121.h b/arch/powerpc/include/asm/mpc5121.h
index 885c040..8ae133e 100644
--- a/arch/powerpc/include/asm/mpc5121.h
+++ b/arch/powerpc/include/asm/mpc5121.h
@@ -68,6 +68,5 @@ struct mpc512x_lpc {
 };
 
 int mpc512x_cs_config(unsigned int cs, u32 val);
-int __init mpc5121_clk_init(void);
 
 #endif /* __ASM_POWERPC_MPC5121_H__ */
diff --git a/arch/powerpc/platforms/512x/mpc5121_ads.c b/arch/powerpc/platforms/512x/mpc5121_ads.c
index 0a134e0..3e90ece 100644
--- a/arch/powerpc/platforms/512x/mpc5121_ads.c
+++ b/arch/powerpc/platforms/512x/mpc5121_ads.c
@@ -43,9 +43,7 @@ static void __init mpc5121_ads_setup_arch(void)
 		mpc83xx_add_bridge(np);
 #endif
 
-#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
-	mpc512x_setup_diu();
-#endif
+	mpc512x_setup_arch();
 }
 
 static void __init mpc5121_ads_init_IRQ(void)
@@ -69,7 +67,7 @@ define_machine(mpc5121_ads) {
 	.probe			= mpc5121_ads_probe,
 	.setup_arch		= mpc5121_ads_setup_arch,
 	.init			= mpc512x_init,
-	.init_early		= mpc512x_init_diu,
+	.init_early		= mpc512x_init_early,
 	.init_IRQ		= mpc5121_ads_init_IRQ,
 	.get_irq		= ipic_get_irq,
 	.calibrate_decr		= generic_calibrate_decr,
diff --git a/arch/powerpc/platforms/512x/mpc512x.h b/arch/powerpc/platforms/512x/mpc512x.h
index 0a8e600..fdb4303 100644
--- a/arch/powerpc/platforms/512x/mpc512x.h
+++ b/arch/powerpc/platforms/512x/mpc512x.h
@@ -12,18 +12,11 @@
 #ifndef __MPC512X_H__
 #define __MPC512X_H__
 extern void __init mpc512x_init_IRQ(void);
+extern void __init mpc512x_init_early(void);
 extern void __init mpc512x_init(void);
+extern void __init mpc512x_setup_arch(void);
 extern int __init mpc5121_clk_init(void);
-void __init mpc512x_declare_of_platform_devices(void);
 extern const char *mpc512x_select_psc_compat(void);
 extern void mpc512x_restart(char *cmd);
 
-#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
-void mpc512x_init_diu(void);
-void mpc512x_setup_diu(void);
-#else
-#define mpc512x_init_diu NULL
-#define mpc512x_setup_diu NULL
-#endif
-
 #endif				/* __MPC512X_H__ */
diff --git a/arch/powerpc/platforms/512x/mpc512x_generic.c b/arch/powerpc/platforms/512x/mpc512x_generic.c
index 5fb919b..ce71408 100644
--- a/arch/powerpc/platforms/512x/mpc512x_generic.c
+++ b/arch/powerpc/platforms/512x/mpc512x_generic.c
@@ -45,8 +45,8 @@ define_machine(mpc512x_generic) {
 	.name			= "MPC512x generic",
 	.probe			= mpc512x_generic_probe,
 	.init			= mpc512x_init,
-	.init_early		= mpc512x_init_diu,
-	.setup_arch		= mpc512x_setup_diu,
+	.init_early		= mpc512x_init_early,
+	.setup_arch		= mpc512x_setup_arch,
 	.init_IRQ		= mpc512x_init_IRQ,
 	.get_irq		= ipic_get_irq,
 	.calibrate_decr		= generic_calibrate_decr,
diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
index 6eb94ab..09622d3 100644
--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
+++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
@@ -58,7 +58,7 @@ void mpc512x_restart(char *cmd)
 		;
 }
 
-#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
+#if IS_ENABLED(CONFIG_FB_FSL_DIU)
 
 struct fsl_diu_shared_fb {
 	u8		gamma[0x300];	/* 32-bit aligned! */
@@ -436,6 +436,12 @@ void __init mpc512x_psc_fifo_init(void)
 	}
 }
 
+void __init mpc512x_init_early(void)
+{
+	if (IS_ENABLED(CONFIG_FB_FSL_DIU))
+		mpc512x_init_diu();
+}
+
 void __init mpc512x_init(void)
 {
 	mpc5121_clk_init();
@@ -444,6 +450,12 @@ void __init mpc512x_init(void)
 	mpc512x_psc_fifo_init();
 }
 
+void __init mpc512x_setup_arch(void)
+{
+	if (IS_ENABLED(CONFIG_FB_FSL_DIU))
+		mpc512x_setup_diu();
+}
+
 /**
  * mpc512x_cs_config - Setup chip select configuration
  * @cs: chip select number
diff --git a/arch/powerpc/platforms/512x/pdm360ng.c b/arch/powerpc/platforms/512x/pdm360ng.c
index 0575e85..24b314d 100644
--- a/arch/powerpc/platforms/512x/pdm360ng.c
+++ b/arch/powerpc/platforms/512x/pdm360ng.c
@@ -119,9 +119,9 @@ static int __init pdm360ng_probe(void)
 define_machine(pdm360ng) {
 	.name			= "PDM360NG",
 	.probe			= pdm360ng_probe,
-	.setup_arch		= mpc512x_setup_diu,
+	.setup_arch		= mpc512x_setup_arch,
 	.init			= pdm360ng_init,
-	.init_early		= mpc512x_init_diu,
+	.init_early		= mpc512x_init_early,
 	.init_IRQ		= mpc512x_init_IRQ,
 	.get_irq		= ipic_get_irq,
 	.calibrate_decr		= generic_calibrate_decr,
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH v1 2/2] powerpc/mpc512x: initialize board restart earlier
From: Gerhard Sittig @ 2013-05-14 14:40 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Gerhard Sittig, agust
In-Reply-To: <1368542454-11003-1-git-send-email-gsi@denx.de>

move the MPC512x restart initialization from the shared init routine
to the shared init_early routine

recent problems in the proc(5) filesystem initialization led to the
situation where the platform's restart routine was invoked yet the
registers required for software reset were not yet available, which
made the board hang instead of reboot

Signed-off-by: Gerhard Sittig <gsi@denx.de>
---
 arch/powerpc/platforms/512x/mpc512x_shared.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
index 09622d3..a8b5110 100644
--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
+++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
@@ -438,6 +438,7 @@ void __init mpc512x_psc_fifo_init(void)
 
 void __init mpc512x_init_early(void)
 {
+	mpc512x_restart_init();
 	if (IS_ENABLED(CONFIG_FB_FSL_DIU))
 		mpc512x_init_diu();
 }
@@ -446,7 +447,6 @@ void __init mpc512x_init(void)
 {
 	mpc5121_clk_init();
 	mpc512x_declare_of_platform_devices();
-	mpc512x_restart_init();
 	mpc512x_psc_fifo_init();
 }
 
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
From: Liu Jiang @ 2013-05-14 14:59 UTC (permalink / raw)
  To: Gu Zheng
  Cc: Neela Syam Kolli, sparclinux@vger.kernel.org, Toshi Kani,
	Jiang Liu, Linux-Scsi, David Airlie, Myron Stowe, linuxppc-dev,
	linux-pci@vger.kernel.org, Linux Kernel Mailing List,
	James E.J. Bottomley, Rafael J . Wysocki, Yijing Wang,
	Greg Kroah-Hartman, Bjorn Helgaas, Paul Mackerras, Andrew Morton,
	Yinghai Lu, David S. Miller
In-Reply-To: <5191F53E.4000305@cn.fujitsu.com>

On 05/14/2013 04:26 PM, Gu Zheng wrote:
> On 05/14/2013 01:23 AM, Yinghai Lu wrote:
>
>> On Mon, May 13, 2013 at 9:08 AM, Jiang Liu <liuj97@gmail.com> wrote:
>>> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
>>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>>> index 4f0bc0a..bc075a3 100644
>>> --- a/drivers/pci/probe.c
>>> +++ b/drivers/pci/probe.c
>>> @@ -1131,6 +1131,7 @@ static void pci_release_dev(struct device *dev)
>>>          struct pci_dev *pci_dev;
>>>
>>>          pci_dev = to_pci_dev(dev);
>>> +       pci_bus_put(pci_dev->bus);
>>>          pci_release_capabilities(pci_dev);
>>>          pci_release_of_node(pci_dev);
>>>          kfree(pci_dev);
>>> @@ -1269,11 +1270,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
>>>          if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
>>>                  return NULL;
>>>
>>> -       dev = alloc_pci_dev();
>>> +       dev = pci_alloc_dev(bus);
>>>          if (!dev)
>>>                  return NULL;
>>>
>>> -       dev->bus = bus;
>>>          dev->devfn = devfn;
>>>          dev->vendor = l & 0xffff;
>>>          dev->device = (l >> 16) & 0xffff;
>> in pci_setup_device() fail path, it release the ref to that bus.
> Yes, you're right, we need to release the bus' ref if pci_setup_device() failed.
Hi Zheng,
     I suggest to use pci_release_dev() instead because it also needs to 
release OF related resources.
I will update it in next version.

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index bc075a3..2ac6338 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1281,7 +1281,7 @@ static struct pci_dev *pci_scan_device(struct 
pci_bus *bus
         pci_set_of_node(dev);

         if (pci_setup_device(dev)) {
-               kfree(dev);
+               pci_release_dev(&dev->dev);
                 return NULL;
         }


> hanks for your correction.:)
>
> Best regards,
> Gu
>
>> Yinghai
>>
>

^ permalink raw reply related

* Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
From: Yinghai Lu @ 2013-05-14 15:10 UTC (permalink / raw)
  To: Liu Jiang
  Cc: Neela Syam Kolli, sparclinux@vger.kernel.org, Toshi Kani,
	Jiang Liu, Linux-Scsi, David Airlie, Greg Kroah-Hartman,
	linuxppc-dev, Linux Kernel Mailing List, James E.J. Bottomley,
	Rafael J . Wysocki, Bjorn Helgaas, Yijing Wang,
	linux-pci@vger.kernel.org, Gu Zheng, Paul Mackerras,
	Andrew Morton, Myron Stowe, David S. Miller
In-Reply-To: <51925136.5050302@gmail.com>

On Tue, May 14, 2013 at 7:59 AM, Liu Jiang <liuj97@gmail.com> wrote:
> On 05/14/2013 04:26 PM, Gu Zheng wrote:
>     I suggest to use pci_release_dev() instead because it also needs to
> release OF related resources.
> I will update it in next version.
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index bc075a3..2ac6338 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1281,7 +1281,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus
> *bus
>         pci_set_of_node(dev);
>
>         if (pci_setup_device(dev)) {
> -               kfree(dev);
> +               pci_release_dev(&dev->dev);
>                 return NULL;

no, should move pci_set_of_node calling into pci_setup_device.

Yinghai

^ permalink raw reply

* [RFC PATCH v2, part 2 09/18] PCI, PPC: use hotplug-safe iterators to walk PCI buses
From: Jiang Liu @ 2013-05-14 16:51 UTC (permalink / raw)
  To: Bjorn Helgaas, Yinghai Lu
  Cc: Gavin Shan, Toshi Kani, Jiang Liu, Greg Kroah-Hartman,
	linuxppc-dev, linux-kernel, Rafael J . Wysocki, Yijing Wang,
	Bill Pemberton, linux-pci, Gu Zheng, Paul Mackerras, Myron Stowe,
	Jiang Liu
In-Reply-To: <1368550322-1045-1-git-send-email-jiang.liu@huawei.com>

Enhance PPC architecture specific code to use hotplug-safe iterators
to walk PCI buses.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Bjorn Helgaas <bhelgaas@google.com>
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Bill Pemberton <wfp5p@virginia.edu>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
---
 arch/powerpc/kernel/pci-common.c |  4 ++--
 arch/powerpc/kernel/pci_64.c     | 13 +++++--------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index fa12ae4..26fca09 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1400,7 +1400,7 @@ void __init pcibios_resource_survey(void)
 	struct pci_bus *b;
 
 	/* Allocate and assign resources */
-	list_for_each_entry(b, &pci_root_buses, node)
+	for_each_pci_root_bus(b)
 		pcibios_allocate_bus_resources(b);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
@@ -1410,7 +1410,7 @@ void __init pcibios_resource_survey(void)
 	 * bus available resources to avoid allocating things on top of them
 	 */
 	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		list_for_each_entry(b, &pci_root_buses, node)
+		for_each_pci_root_bus(b)
 			pcibios_reserve_legacy_regions(b);
 	}
 
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 51a133a..a41c6dd 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -208,7 +208,6 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 			  unsigned long in_devfn)
 {
 	struct pci_controller* hose;
-	struct list_head *ln;
 	struct pci_bus *bus = NULL;
 	struct device_node *hose_node;
 
@@ -229,18 +228,16 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 	/* That syscall isn't quite compatible with PCI domains, but it's
 	 * used on pre-domains setup. We return the first match
 	 */
-
-	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
-		bus = pci_bus_b(ln);
-		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
+	for_each_pci_root_bus(bus)
+		if (in_bus >= bus->number && in_bus <= bus->busn_res.end &&
+		    bus->dev.of_node)
 			break;
-		bus = NULL;
-	}
-	if (bus == NULL || bus->dev.of_node == NULL)
+	if (bus == NULL)
 		return -ENODEV;
 
 	hose_node = bus->dev.of_node;
 	hose = PCI_DN(hose_node)->phb;
+	pci_bus_put(bus);
 
 	switch (which) {
 	case IOBASE_BRIDGE_NUMBER:
-- 
1.8.1.2

^ permalink raw reply related

* Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
From: Liu Jiang @ 2013-05-14 16:57 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Neela Syam Kolli, sparclinux@vger.kernel.org, Toshi Kani,
	Jiang Liu, Linux-Scsi, David Airlie, Greg Kroah-Hartman,
	linuxppc-dev, Linux Kernel Mailing List, James E.J. Bottomley,
	Rafael J . Wysocki, Bjorn Helgaas, Yijing Wang,
	linux-pci@vger.kernel.org, Gu Zheng, Paul Mackerras,
	Andrew Morton, Myron Stowe, David S. Miller
In-Reply-To: <CAE9FiQWO-jR5y35kKiW0m6gVR54ZyRsBsdhP4BmFLSsDzCS3rA@mail.gmail.com>

On Tue 14 May 2013 11:10:33 PM CST, Yinghai Lu wrote:
> On Tue, May 14, 2013 at 7:59 AM, Liu Jiang <liuj97@gmail.com> wrote:
>> On 05/14/2013 04:26 PM, Gu Zheng wrote:
>>      I suggest to use pci_release_dev() instead because it also needs to
>> release OF related resources.
>> I will update it in next version.
>>
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index bc075a3..2ac6338 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1281,7 +1281,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus
>> *bus
>>          pci_set_of_node(dev);
>>
>>          if (pci_setup_device(dev)) {
>> -               kfree(dev);
>> +               pci_release_dev(&dev->dev);
>>                  return NULL;
>
> no, should move pci_set_of_node calling into pci_setup_device.
>
> Yinghai

I'm not sure whether we should call pci_set_of_node() for SR-IOV 
devices too,
any suggestions here?

^ permalink raw reply

* Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
From: Yinghai Lu @ 2013-05-14 18:52 UTC (permalink / raw)
  To: Liu Jiang
  Cc: Neela Syam Kolli, sparclinux@vger.kernel.org, Toshi Kani,
	Jiang Liu, Linux-Scsi, David Airlie, Greg Kroah-Hartman,
	linuxppc-dev, Linux Kernel Mailing List, James E.J. Bottomley,
	Rafael J . Wysocki, Bjorn Helgaas, Yijing Wang,
	linux-pci@vger.kernel.org, Gu Zheng, Paul Mackerras,
	Andrew Morton, Myron Stowe, David S. Miller
In-Reply-To: <51926CF6.1050706@gmail.com>

On Tue, May 14, 2013 at 9:57 AM, Liu Jiang <liuj97@gmail.com> wrote:
> On Tue 14 May 2013 11:10:33 PM CST, Yinghai Lu wrote:
>>
>> On Tue, May 14, 2013 at 7:59 AM, Liu Jiang <liuj97@gmail.com> wrote:
>>>
>>> On 05/14/2013 04:26 PM, Gu Zheng wrote:
>>>      I suggest to use pci_release_dev() instead because it also needs to
>>> release OF related resources.
>>> I will update it in next version.
>>>
>>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>>> index bc075a3..2ac6338 100644
>>> --- a/drivers/pci/probe.c
>>> +++ b/drivers/pci/probe.c
>>> @@ -1281,7 +1281,7 @@ static struct pci_dev *pci_scan_device(struct
>>> pci_bus
>>> *bus
>>>          pci_set_of_node(dev);
>>>
>>>          if (pci_setup_device(dev)) {
>>> -               kfree(dev);
>>> +               pci_release_dev(&dev->dev);
>>>                  return NULL;
>>
>>
>> no, should move pci_set_of_node calling into pci_setup_device.
>>
>> Yinghai
>
>
> I'm not sure whether we should call pci_set_of_node() for SR-IOV devices
> too,
> any suggestions here?

or just move down pci_set_of_node after pci_setup_device?

anyway that is another bug.

Yinghai

^ permalink raw reply

* Re: [PATCH v5, part4 31/41] mm/ppc: prepare for removing num_physpages and simplify mem_init()
From: Benjamin Herrenschmidt @ 2013-05-15  0:32 UTC (permalink / raw)
  To: Jiang Liu
  Cc: linux-arch, James Bottomley, David Howells, Jiang Liu,
	Wen Congyang, linux-mm, Mark Salter, linux-kernel, Michal Hocko,
	Minchan Kim, Paul Mackerras, Mel Gorman, David Rientjes,
	Andrew Morton, linuxppc-dev, Sergei Shtylyov, KAMEZAWA Hiroyuki,
	Jianguo Wu
In-Reply-To: <1368028298-7401-32-git-send-email-jiang.liu@huawei.com>

On Wed, 2013-05-08 at 23:51 +0800, Jiang Liu wrote:
> Prepare for removing num_physpages and simplify mem_init().

No objection, I haven't had a chance to actually build/boot test though.

BTW. A recommended way of doing so which is pretty easy even if you
don't have access to powerpc hardware nowadays is to use
qemu-system-ppc64 with -M pseries.

You can find cross compilers for the kernel on kernel.org and you can
feed qemu with some distro installer ISO.

Cheers,
Ben.

> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  arch/powerpc/mm/mem.c |   56 +++++++++++--------------------------------------
>  1 file changed, 12 insertions(+), 44 deletions(-)
> 
> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index b890245..4e24f1c 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -299,46 +299,27 @@ void __init paging_init(void)
>  
>  void __init mem_init(void)
>  {
> -#ifdef CONFIG_NEED_MULTIPLE_NODES
> -	int nid;
> -#endif
> -	pg_data_t *pgdat;
> -	unsigned long i;
> -	struct page *page;
> -	unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize;
> -
>  #ifdef CONFIG_SWIOTLB
>  	swiotlb_init(0);
>  #endif
>  
> -	num_physpages = memblock_phys_mem_size() >> PAGE_SHIFT;
>  	high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
>  
>  #ifdef CONFIG_NEED_MULTIPLE_NODES
> -        for_each_online_node(nid) {
> -		if (NODE_DATA(nid)->node_spanned_pages != 0) {
> -			printk("freeing bootmem node %d\n", nid);
> -			free_all_bootmem_node(NODE_DATA(nid));
> -		}
> +	{
> +		pg_data_t *pgdat;
> +
> +		for_each_online_pgdat(pgdat)
> +			if (pgdat->node_spanned_pages != 0) {
> +				printk("freeing bootmem node %d\n",
> +					pgdat->node_id);
> +				free_all_bootmem_node(pgdat);
> +			}
>  	}
>  #else
>  	max_mapnr = max_pfn;
>  	free_all_bootmem();
>  #endif
> -	for_each_online_pgdat(pgdat) {
> -		for (i = 0; i < pgdat->node_spanned_pages; i++) {
> -			if (!pfn_valid(pgdat->node_start_pfn + i))
> -				continue;
> -			page = pgdat_page_nr(pgdat, i);
> -			if (PageReserved(page))
> -				reservedpages++;
> -		}
> -	}
> -
> -	codesize = (unsigned long)&_sdata - (unsigned long)&_stext;
> -	datasize = (unsigned long)&_edata - (unsigned long)&_sdata;
> -	initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
> -	bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start;
>  
>  #ifdef CONFIG_HIGHMEM
>  	{
> @@ -348,13 +329,9 @@ void __init mem_init(void)
>  		for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
>  			phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT;
>  			struct page *page = pfn_to_page(pfn);
> -			if (memblock_is_reserved(paddr))
> -				continue;
> -			free_highmem_page(page);
> -			reservedpages--;
> +			if (!memblock_is_reserved(paddr))
> +				free_highmem_page(page);
>  		}
> -		printk(KERN_DEBUG "High memory: %luk\n",
> -		       totalhigh_pages << (PAGE_SHIFT-10));
>  	}
>  #endif /* CONFIG_HIGHMEM */
>  
> @@ -367,16 +344,7 @@ void __init mem_init(void)
>  		(mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) - 1;
>  #endif
>  
> -	printk(KERN_INFO "Memory: %luk/%luk available (%luk kernel code, "
> -	       "%luk reserved, %luk data, %luk bss, %luk init)\n",
> -		nr_free_pages() << (PAGE_SHIFT-10),
> -		num_physpages << (PAGE_SHIFT-10),
> -		codesize >> 10,
> -		reservedpages << (PAGE_SHIFT-10),
> -		datasize >> 10,
> -		bsssize >> 10,
> -		initsize >> 10);
> -
> +	mem_init_print_info(NULL);
>  #ifdef CONFIG_PPC32
>  	pr_info("Kernel virtual memory layout:\n");
>  	pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);

^ permalink raw reply

* Re: [RFC PATCH v2, part 2 09/18] PCI, PPC: use hotplug-safe iterators to walk PCI buses
From: Benjamin Herrenschmidt @ 2013-05-14 23:30 UTC (permalink / raw)
  To: Jiang Liu
  Cc: Toshi Kani, Jiang Liu, Myron Stowe, Greg Kroah-Hartman,
	linuxppc-dev, linux-kernel, Rafael J . Wysocki, Gu Zheng,
	Yijing Wang, Bill Pemberton, Paul Mackerras, linux-pci,
	Bjorn Helgaas, Yinghai Lu, Gavin Shan
In-Reply-To: <1368550322-1045-9-git-send-email-jiang.liu@huawei.com>

On Wed, 2013-05-15 at 00:51 +0800, Jiang Liu wrote:
> Enhance PPC architecture specific code to use hotplug-safe iterators
> to walk PCI buses.

I was about to ack it but then I saw:

> diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
> index 51a133a..a41c6dd 100644
> --- a/arch/powerpc/kernel/pci_64.c
> +++ b/arch/powerpc/kernel/pci_64.c
> @@ -208,7 +208,6 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>  			  unsigned long in_devfn)
>  {
>  	struct pci_controller* hose;
> -	struct list_head *ln;
>  	struct pci_bus *bus = NULL;
>  	struct device_node *hose_node;
>  
> @@ -229,18 +228,16 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>  	/* That syscall isn't quite compatible with PCI domains, but it's
>  	 * used on pre-domains setup. We return the first match
>  	 */
> -
> -	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
> -		bus = pci_bus_b(ln);
> -		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
> +	for_each_pci_root_bus(bus)
> +		if (in_bus >= bus->number && in_bus <= bus->busn_res.end &&
> +		    bus->dev.of_node)
>  			break;
> -		bus = NULL;
> -	}
> -	if (bus == NULL || bus->dev.of_node == NULL)
> +	if (bus == NULL)
>  		return -ENODEV;

You just removed the NULL check for the of_node field...
 
>  	hose_node = bus->dev.of_node;
>  	hose = PCI_DN(hose_node)->phb;

Which is dereferrenced here.	

> +	pci_bus_put(bus);

On the other hand, the whole thing can probably be using
pci_bus_to_host() instead.... the above code is bitrotted.

>  	switch (which) {
>  	case IOBASE_BRIDGE_NUMBER:
 
Cheeers,
Ben.

^ permalink raw reply

* [PATCH 01/22] powerpc/eeh: Enhance converting EEH dev
From: Gavin Shan @ 2013-05-15  3:34 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Gavin Shan
In-Reply-To: <1368588898-16224-1-git-send-email-shangw@linux.vnet.ibm.com>

Under some special circumstances, the EEH device doesn't have the
associated device tree node or PCI device. The patch enhances those
functions converting EEH device to device tree node or PCI device
accordingly to avoid unnecessary system crash.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/eeh.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index a80e32b4..e32c3c5 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -95,12 +95,12 @@ struct eeh_dev {
 
 static inline struct device_node *eeh_dev_to_of_node(struct eeh_dev *edev)
 {
-	return edev->dn;
+	return edev ? edev->dn : NULL;
 }
 
 static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev)
 {
-	return edev->pdev;
+	return edev ? edev->pdev : NULL;
 }
 
 /*
-- 
1.7.5.4

^ permalink raw reply related

* [PATCH v1 00/22] powerpc/eeh: Enhance converting EEH dev
From: Gavin Shan @ 2013-05-15  3:34 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Gavin Shan

Initially, the series of patches is built based on 3.10.RC1 and the patchset
doesn't intend to enable EEH functionality for PHB3 for now.

The series of patches intends to support EEH for PowerNV platform. The EEH
core already supports multiple probe methods: device tree nodes and PCI
devices. For EEH on PowerNV, we're using PCI devices to do EEH probe, which
is different from the probe type used on pSeries platform. Another point I
should mention is that the overall EEH would be split up to 3 layers: EEH
core, platform layer and I/O chip layer. It would make the EEH on PowerNV
platform can achieve more flexibility and support more I/O chips in future.
Besides, the EEH event can be produced by detecting 0xFF's from reading
PCI config or I/O registers, or from interrupts dedicated for EEH error
reporting. So we have to handle the EEH error interrupts. On the other hand,
the EEH events will be processed by EEH core like pSeries platform does.

We don't have existing utility (e.g. errinjct) to test the patchset. In order
to conduct the test, you need copy over the eeh-debug.c to PowerNV platform
directory and change the makefile accordingly. Please contact me to get the
eeh-debug.c if you want run the test case. After that, you need write P7IOC
registers explicitly to trigger frozen PE or fenced PHB explicitly as the
following example shows. The patchset has been verified on Firebird-L machine
where I have 2 Emulex ethernet card on PHB#6. I keep pinging to one of the
ethernet cards from external and then use following commands to produce frozen
PE or fenced PHB errors. Eventually, the errors can be recovered and the ethernet
card is reachable after temporary connection lost.

Trigger frozen PE:

        echo "0xD10 0x0000000002000000" > /proc/IODA/PHB6/REG
        sleep 1
        echo "0xD10 0x0000000000000000" > /proc/IODA/PHB6/REG

Trigger fenced PHB:

        echo "0xD10 0x8000000000000000" > /proc/IODA/PHB6/REG

---

arch/powerpc/include/asm/eeh.h                 |   29 ++-
arch/powerpc/include/asm/eeh_event.h           |    6 +-
arch/powerpc/include/asm/opal.h                |  110 ++++-
arch/powerpc/kernel/rtas_pci.c                 |    3 +-
arch/powerpc/platforms/powernv/Makefile        |    1 +
arch/powerpc/platforms/powernv/eeh-ioda.c      |  519 ++++++++++++++++++++++++
arch/powerpc/platforms/powernv/eeh-powernv.c   |  380 +++++++++++++++++
arch/powerpc/platforms/powernv/opal-wrappers.S |    2 +
arch/powerpc/platforms/powernv/opal.c          |    6 +
arch/powerpc/platforms/powernv/pci-err.c       |  475 ++++++++++++++++++++++
arch/powerpc/platforms/powernv/pci-ioda.c      |   17 +-
arch/powerpc/platforms/powernv/pci-p5ioc2.c    |    6 +-
arch/powerpc/platforms/powernv/pci.c           |   41 ++-
arch/powerpc/platforms/powernv/pci.h           |   22 +
arch/powerpc/platforms/pseries/eeh.c           |   61 +++-
arch/powerpc/platforms/pseries/eeh_dev.c       |   35 ++
arch/powerpc/platforms/pseries/eeh_event.c     |   12 +-
arch/powerpc/platforms/pseries/eeh_pe.c        |   31 ++-
18 files changed, 1712 insertions(+), 44 deletions(-)

Thanks,
Gavin

^ permalink raw reply

* [PATCH 04/22] powerpc/eeh: Make eeh_pe_get() public
From: Gavin Shan @ 2013-05-15  3:34 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Gavin Shan
In-Reply-To: <1368588898-16224-1-git-send-email-shangw@linux.vnet.ibm.com>

While processing EEH event interrupt from P7IOC, we need function
to retrieve the PE according to the indicated EEH device. The patch
makes function eeh_pe_get() public so that other source files can call
it for that purpose. Also, the patch fixes referring to wrong BDF
(Bus/Device/Function) address while searching PE in function
__eeh_pe_get().

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/eeh.h          |    1 +
 arch/powerpc/platforms/pseries/eeh_pe.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 4b48178..9230aa4 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -186,6 +186,7 @@ typedef void *(*eeh_traverse_func)(void *data, void *flag);
 typedef void *(*eeh_pci_traverse_func)(struct pci_dev *dev, void *flag);
 int eeh_phb_pe_create(struct pci_controller *phb);
 struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb);
+struct eeh_pe *eeh_pe_get(struct eeh_dev *edev);
 int eeh_add_to_parent_pe(struct eeh_dev *edev);
 int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe);
 void *eeh_pe_dev_traverse(struct eeh_pe *root,
diff --git a/arch/powerpc/platforms/pseries/eeh_pe.c b/arch/powerpc/platforms/pseries/eeh_pe.c
index 6e3eb43..93ed9cb 100644
--- a/arch/powerpc/platforms/pseries/eeh_pe.c
+++ b/arch/powerpc/platforms/pseries/eeh_pe.c
@@ -228,7 +228,7 @@ static void *__eeh_pe_get(void *data, void *flag)
 		return pe;
 
 	/* Try BDF address */
-	if (edev->pe_config_addr &&
+	if (edev->config_addr &&
 	   (edev->config_addr == pe->config_addr))
 		return pe;
 
@@ -246,7 +246,7 @@ static void *__eeh_pe_get(void *data, void *flag)
  * which is composed of PCI bus/device/function number, or unified
  * PE address.
  */
-static struct eeh_pe *eeh_pe_get(struct eeh_dev *edev)
+struct eeh_pe *eeh_pe_get(struct eeh_dev *edev)
 {
 	struct eeh_pe *root = eeh_phb_pe_get(edev->phb);
 	struct eeh_pe *pe;
-- 
1.7.5.4

^ permalink raw reply related

* [PATCH 05/22] powerpc/eeh: Trace PCI bus from PE
From: Gavin Shan @ 2013-05-15  3:34 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Gavin Shan
In-Reply-To: <1368588898-16224-1-git-send-email-shangw@linux.vnet.ibm.com>

There're several types of PEs can be supported for now: PHB, Bus
and Device dependent PE. For PCI bus dependent PE, tracing the
corresponding PCI bus from PE (struct eeh_pe) would make the code
more efficient. The patch also enables the retrieval of PCI bus based
on the PCI device dependent PE.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/eeh.h          |    1 +
 arch/powerpc/platforms/pseries/eeh_pe.c |   25 ++++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 9230aa4..557d82a 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -62,6 +62,7 @@ struct eeh_pe {
 	int check_count;		/* Times of ignored error	*/
 	int freeze_count;		/* Times of froze up		*/
 	int false_positives;		/* Times of reported #ff's	*/
+	struct pci_bus *bus;		/* Top PCI bus for bus PE	*/
 	struct eeh_pe *parent;		/* Parent PE			*/
 	struct list_head child_list;	/* Link PE to the child list	*/
 	struct list_head edevs;		/* Link list of EEH devices	*/
diff --git a/arch/powerpc/platforms/pseries/eeh_pe.c b/arch/powerpc/platforms/pseries/eeh_pe.c
index 93ed9cb..03f8223 100644
--- a/arch/powerpc/platforms/pseries/eeh_pe.c
+++ b/arch/powerpc/platforms/pseries/eeh_pe.c
@@ -304,6 +304,7 @@ static struct eeh_pe *eeh_pe_get_parent(struct eeh_dev *edev)
 int eeh_add_to_parent_pe(struct eeh_dev *edev)
 {
 	struct eeh_pe *pe, *parent;
+	struct eeh_dev *first_edev;
 
 	eeh_lock();
 
@@ -326,6 +327,21 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
 		pe->type = EEH_PE_BUS;
 		edev->pe = pe;
 
+		/*
+		 * For PCI bus sensitive PE, we can reset the parent
+		 * bridge in order for hot-reset. However, the PCI
+		 * devices including the associated EEH devices might
+		 * be removed when EEH core is doing recovery. So that
+		 * won't safe to retrieve the bridge through downstream
+		 * EEH device. We have to trace the parent PCI bus, then
+		 * the parent bridge explicitly.
+		 */
+		if (eeh_probe_mode_dev() && !pe->bus) {
+			first_edev = list_first_entry(&pe->edevs,
+						struct eeh_dev, list);
+			pe->bus = eeh_dev_to_pci_dev(first_edev)->bus;
+		}
+
 		/* Put the edev to PE */
 		list_add_tail(&edev->list, &pe->edevs);
 		eeh_unlock();
@@ -639,13 +655,20 @@ struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe)
 
 	if (pe->type & EEH_PE_PHB) {
 		bus = pe->phb->bus;
-	} else if (pe->type & EEH_PE_BUS) {
+	} else if (pe->type & EEH_PE_BUS ||
+		   pe->type & EEH_PE_DEVICE) {
+		if (pe->bus) {
+			bus = pe->bus;
+			goto out;
+		}
+
 		edev = list_first_entry(&pe->edevs, struct eeh_dev, list);
 		pdev = eeh_dev_to_pci_dev(edev);
 		if (pdev)
 			bus = pdev->bus;
 	}
 
+out:
 	eeh_unlock();
 
 	return bus;
-- 
1.7.5.4

^ permalink raw reply related

* [PATCH 03/22] powerpc/eeh: Make eeh_phb_pe_get() public
From: Gavin Shan @ 2013-05-15  3:34 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Gavin Shan
In-Reply-To: <1368588898-16224-1-git-send-email-shangw@linux.vnet.ibm.com>

While processing EEH event interrupt from P7IOC, we need function
to retrieve the PE according to the indicated PCI host controller
(struct pci_controller). The patch makes function eeh_phb_pe_get()
public so that other source files can call it for that purpose.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/eeh.h          |    1 +
 arch/powerpc/platforms/pseries/eeh_pe.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index eeaeab6..4b48178 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -185,6 +185,7 @@ static inline void eeh_unlock(void)
 typedef void *(*eeh_traverse_func)(void *data, void *flag);
 typedef void *(*eeh_pci_traverse_func)(struct pci_dev *dev, void *flag);
 int eeh_phb_pe_create(struct pci_controller *phb);
+struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb);
 int eeh_add_to_parent_pe(struct eeh_dev *edev);
 int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe);
 void *eeh_pe_dev_traverse(struct eeh_pe *root,
diff --git a/arch/powerpc/platforms/pseries/eeh_pe.c b/arch/powerpc/platforms/pseries/eeh_pe.c
index fe43d1a..6e3eb43 100644
--- a/arch/powerpc/platforms/pseries/eeh_pe.c
+++ b/arch/powerpc/platforms/pseries/eeh_pe.c
@@ -95,7 +95,7 @@ int eeh_phb_pe_create(struct pci_controller *phb)
  * hierarchy tree is composed of PHB PEs. The function is used
  * to retrieve the corresponding PHB PE according to the given PHB.
  */
-static struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb)
+struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb)
 {
 	struct eeh_pe *pe;
 
-- 
1.7.5.4

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox