LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: thp: Fix crash on mremap
From: Aneesh Kumar K.V @ 2014-01-01  9:53 UTC (permalink / raw)
  To: benh, paulus, aarcange, kirill.shutemov
  Cc: linux-mm, linuxppc-dev, Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>

This patch fix the below crash

NIP [c00000000004cee4] .__hash_page_thp+0x2a4/0x440
LR [c0000000000439ac] .hash_page+0x18c/0x5e0
...
Call Trace:
[c000000736103c40] [00001ffffb000000] 0x1ffffb000000(unreliable)
[437908.479693] [c000000736103d50] [c0000000000439ac] .hash_page+0x18c/0x5e0
[437908.479699] [c000000736103e30] [c00000000000924c] .do_hash_page+0x4c/0x58

On ppc64 we use the pgtable for storing the hpte slot information and
store address to the pgtable at a constant offset (PTRS_PER_PMD) from
pmd. On mremap, when we switch the pmd, we need to withdraw and deposit
the pgtable again, so that we find the pgtable at PTRS_PER_PMD offset
from new pmd.

We also want to move the withdraw and deposit before the set_pmd so
that, when page fault find the pmd as trans huge we can be sure that
pgtable can be located at the offset.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
NOTE:
For other archs we would just be removing the pgtable from the list and adding it back.
I didn't find an easy way to make it not do that without lots of #ifdef around. Any
suggestion around that is welcome.

 mm/huge_memory.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 7de1bf85f683..eb2e60d9ba45 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1500,24 +1500,23 @@ int move_huge_pmd(struct vm_area_struct *vma, struct vm_area_struct *new_vma,
 	 */
 	ret = __pmd_trans_huge_lock(old_pmd, vma, &old_ptl);
 	if (ret == 1) {
+		pgtable_t pgtable;
+
 		new_ptl = pmd_lockptr(mm, new_pmd);
 		if (new_ptl != old_ptl)
 			spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);
 		pmd = pmdp_get_and_clear(mm, old_addr, old_pmd);
 		VM_BUG_ON(!pmd_none(*new_pmd));
+		/*
+		 * Archs like ppc64 use pgtable to store per pmd
+		 * specific information. So when we switch the pmd,
+		 * we should also withdraw and deposit the pgtable
+		 */
+		pgtable = pgtable_trans_huge_withdraw(mm, old_pmd);
+		pgtable_trans_huge_deposit(mm, new_pmd, pgtable);
 		set_pmd_at(mm, new_addr, new_pmd, pmd_mksoft_dirty(pmd));
-		if (new_ptl != old_ptl) {
-			pgtable_t pgtable;
-
-			/*
-			 * Move preallocated PTE page table if new_pmd is on
-			 * different PMD page table.
-			 */
-			pgtable = pgtable_trans_huge_withdraw(mm, old_pmd);
-			pgtable_trans_huge_deposit(mm, new_pmd, pgtable);
-
+		if (new_ptl != old_ptl)
 			spin_unlock(new_ptl);
-		}
 		spin_unlock(old_ptl);
 	}
 out:
-- 
1.8.3.2

^ permalink raw reply related

* [PATCH V2] time/cpuidle: Support in tick broadcast framework for archs without external clock device
From: Preeti U Murthy @ 2014-01-01  5:49 UTC (permalink / raw)
  To: peterz, fweisbec, paul.gortmaker, paulus, mingo, shangw,
	rafael.j.wysocki, galak, benh, paulmck, arnd, linux-pm, rostedt,
	michael, john.stultz, tglx, chenhui.zhao, deepthi, r58472, geoff,
	linux-kernel, srivatsa.bhat, schwidefsky, svaidy, linuxppc-dev

On some architectures, in certain CPU deep idle states the local timers stop.
An external clock device is used to wakeup these CPUs. The kernel support for the
wakeup of these CPUs is provided by the tick broadcast framework by using the
external clock device as the wakeup source.

However not all implementations of architectures provide such an external
clock device such as some PowerPC ones. This patch includes support in the
broadcast framework to handle the wakeup of the CPUs in deep idle states on such
systems by queuing a hrtimer on one of the CPUs, meant to handle the wakeup of
CPUs in deep idle states. This CPU is identified as the bc_cpu.

Each time the hrtimer expires, it is reprogrammed for the next wakeup of the
CPUs in deep idle state after handling broadcast. However when a CPU is about
to enter  deep idle state with its wakeup time earlier than the time at which
the hrtimer is currently programmed, it *becomes the new bc_cpu* and restarts
the hrtimer on itself. This way the job of doing broadcast is handed around to
the CPUs that ask for the earliest wakeup just before entering deep idle
state. This is consistent with what happens in cases where an external clock
device is present. The smp affinity of this clock device is set to the CPU
with the earliest wakeup.

The important point here is that the bc_cpu cannot enter deep idle state
since it has a hrtimer queued to wakeup the other CPUs in deep idle. Hence it
cannot have its local timer stopped. Therefore for such a CPU, the
BROADCAST_ENTER notification has to fail implying that it cannot enter deep
idle state. On architectures where an external clock device is present, all
CPUs can enter deep idle.

During hotplug of the bc_cpu, the job of doing a broadcast is assigned to the
first cpu in the broadcast mask. This newly nominated bc_cpu is woken up by
an IPI so as to queue the above mentioned hrtimer on itself.

Changes from V1:https://lkml.org/lkml/2013/12/12/687

If idle states exist when the local timers of CPUs stop and
there is no external clock device to handle their wakeups the kernel switches
the tick mode to periodic so as to prevent the CPUs from entering such idle
states altogether. Therefore include an additional check consistent
with this patch, where if an external clock device does not exist, queue a
hrtimer to handle wakeups. If this also fails, only then switch the tick mode to
periodic.

Signed-off-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
---

 include/linux/clockchips.h   |    4 -
 kernel/time/clockevents.c    |    8 +-
 kernel/time/tick-broadcast.c |  180 ++++++++++++++++++++++++++++++++++++++----
 kernel/time/tick-internal.h  |    8 +-
 4 files changed, 173 insertions(+), 27 deletions(-)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 493aa02..bbda37b 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -186,9 +186,9 @@ static inline int tick_check_broadcast_expired(void) { return 0; }
 #endif
 
 #ifdef CONFIG_GENERIC_CLOCKEVENTS
-extern void clockevents_notify(unsigned long reason, void *arg);
+extern int clockevents_notify(unsigned long reason, void *arg);
 #else
-static inline void clockevents_notify(unsigned long reason, void *arg) {}
+static inline int clockevents_notify(unsigned long reason, void *arg) {}
 #endif
 
 #else /* CONFIG_GENERIC_CLOCKEVENTS_BUILD */
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 086ad60..bbbd671 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -525,11 +525,11 @@ void clockevents_resume(void)
 /**
  * clockevents_notify - notification about relevant events
  */
-void clockevents_notify(unsigned long reason, void *arg)
+int clockevents_notify(unsigned long reason, void *arg)
 {
 	struct clock_event_device *dev, *tmp;
 	unsigned long flags;
-	int cpu;
+	int cpu, ret = 0;
 
 	raw_spin_lock_irqsave(&clockevents_lock, flags);
 
@@ -542,11 +542,12 @@ void clockevents_notify(unsigned long reason, void *arg)
 
 	case CLOCK_EVT_NOTIFY_BROADCAST_ENTER:
 	case CLOCK_EVT_NOTIFY_BROADCAST_EXIT:
-		tick_broadcast_oneshot_control(reason);
+		ret = tick_broadcast_oneshot_control(reason);
 		break;
 
 	case CLOCK_EVT_NOTIFY_CPU_DYING:
 		tick_handover_do_timer(arg);
+		tick_handover_bc_cpu(arg);
 		break;
 
 	case CLOCK_EVT_NOTIFY_SUSPEND:
@@ -585,6 +586,7 @@ void clockevents_notify(unsigned long reason, void *arg)
 		break;
 	}
 	raw_spin_unlock_irqrestore(&clockevents_lock, flags);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(clockevents_notify);
 
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 9532690..1755984 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -20,6 +20,7 @@
 #include <linux/sched.h>
 #include <linux/smp.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "tick-internal.h"
 
@@ -35,6 +36,11 @@ static cpumask_var_t tmpmask;
 static DEFINE_RAW_SPINLOCK(tick_broadcast_lock);
 static int tick_broadcast_force;
 
+static struct hrtimer *bc_hrtimer;
+static int bc_cpu = -1;
+static ktime_t bc_next_wakeup;
+static int hrtimer_initialized = 0;
+
 #ifdef CONFIG_TICK_ONESHOT
 static void tick_broadcast_clear_oneshot(int cpu);
 #else
@@ -528,6 +534,20 @@ static int tick_broadcast_set_event(struct clock_event_device *bc, int cpu,
 	return ret;
 }
 
+static void tick_broadcast_set_next_wakeup(int cpu, ktime_t expires, int force)
+{
+	struct clock_event_device *bc;
+
+	bc = tick_broadcast_device.evtdev;
+
+	if (bc) {
+		tick_broadcast_set_event(bc, cpu, expires, force);
+	} else {
+		hrtimer_start(bc_hrtimer, expires, HRTIMER_MODE_ABS_PINNED);
+		bc_cpu = cpu;
+	}
+}
+
 int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
 {
 	clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
@@ -558,15 +578,13 @@ void tick_check_oneshot_broadcast(int cpu)
 /*
  * Handle oneshot mode broadcasting
  */
-static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
+static int tick_oneshot_broadcast(void)
 {
 	struct tick_device *td;
 	ktime_t now, next_event;
 	int cpu, next_cpu = 0;
 
-	raw_spin_lock(&tick_broadcast_lock);
-again:
-	dev->next_event.tv64 = KTIME_MAX;
+	bc_next_wakeup.tv64 = KTIME_MAX;
 	next_event.tv64 = KTIME_MAX;
 	cpumask_clear(tmpmask);
 	now = ktime_get();
@@ -620,34 +638,89 @@ again:
 	 * in the event mask
 	 */
 	if (next_event.tv64 != KTIME_MAX) {
-		/*
-		 * Rearm the broadcast device. If event expired,
-		 * repeat the above
-		 */
-		if (tick_broadcast_set_event(dev, next_cpu, next_event, 0))
+		bc_next_wakeup = next_event;
+	}
+
+	return next_cpu;
+}
+
+/*
+ * Handler in oneshot mode for the external clock device
+ */
+static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
+{
+	int next_cpu;
+
+	raw_spin_lock(&tick_broadcast_lock);
+
+again:	next_cpu = tick_oneshot_broadcast();
+	/*
+	 * Rearm the broadcast device. If event expired,
+	 * repeat the above
+	 */
+	if (bc_next_wakeup.tv64 != KTIME_MAX)
+		if (tick_broadcast_set_event(dev, next_cpu, bc_next_wakeup, 0))
 			goto again;
+
+	raw_spin_unlock(&tick_broadcast_lock);
+}
+
+/*
+ * Handler in oneshot mode for the hrtimer queued when there is no external
+ * clock device.
+ */
+static enum hrtimer_restart handle_broadcast(struct hrtimer *hrtmr)
+{
+	ktime_t now, interval;
+
+	raw_spin_lock(&tick_broadcast_lock);
+	tick_oneshot_broadcast();
+
+	now = ktime_get();
+
+	if (bc_next_wakeup.tv64 != KTIME_MAX) {
+		interval = ktime_sub(bc_next_wakeup, now);
+		hrtimer_forward_now(bc_hrtimer, interval);
+		raw_spin_unlock(&tick_broadcast_lock);
+		return HRTIMER_RESTART;
 	}
 	raw_spin_unlock(&tick_broadcast_lock);
+	return HRTIMER_NORESTART;
+}
+
+/* The CPU could be asked to take over from the previous bc_cpu,
+ * if it is being hotplugged out.
+ */
+static void tick_broadcast_exit_check(int cpu)
+{
+	if (cpu == bc_cpu)
+		hrtimer_start(bc_hrtimer, bc_next_wakeup,
+				HRTIMER_MODE_ABS_PINNED);
+}
+
+static int can_enter_broadcast(int cpu)
+{
+	return cpu != bc_cpu;
 }
 
 /*
  * Powerstate information: The system enters/leaves a state, where
  * affected devices might stop
  */
-void tick_broadcast_oneshot_control(unsigned long reason)
+int tick_broadcast_oneshot_control(unsigned long reason)
 {
-	struct clock_event_device *bc, *dev;
+	struct clock_event_device *dev;
 	struct tick_device *td;
 	unsigned long flags;
 	ktime_t now;
-	int cpu;
+	int cpu, ret = 0;
 
 	/*
 	 * Periodic mode does not care about the enter/exit of power
 	 * states
 	 */
 	if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
-		return;
+		return ret;
 
 	/*
 	 * We are called with preemtion disabled from the depth of the
@@ -658,9 +731,8 @@ void tick_broadcast_oneshot_control(unsigned long reason)
 	dev = td->evtdev;
 
 	if (!(dev->features & CLOCK_EVT_FEAT_C3STOP))
-		return;
+		return ret;
 
-	bc = tick_broadcast_device.evtdev;
 
 	raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 	if (reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER) {
@@ -676,12 +748,22 @@ void tick_broadcast_oneshot_control(unsigned long reason)
 			 * woken by the IPI right away.
 			 */
 			if (!cpumask_test_cpu(cpu, tick_broadcast_force_mask) &&
-			    dev->next_event.tv64 < bc->next_event.tv64)
-				tick_broadcast_set_event(bc, cpu, dev->next_event, 1);
+			    dev->next_event.tv64 < bc_next_wakeup.tv64) {
+				bc_next_wakeup = dev->next_event;
+				tick_broadcast_set_next_wakeup(cpu, dev->next_event, 1);
+			}
+
+			if (!can_enter_broadcast(cpu)) {
+				cpumask_test_and_clear_cpu(cpu, tick_broadcast_oneshot_mask);
+				clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT);
+				ret = 1;
+			}
 		}
 	} else {
 		if (cpumask_test_and_clear_cpu(cpu, tick_broadcast_oneshot_mask)) {
 			clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT);
+
+			tick_broadcast_exit_check(cpu);
 			/*
 			 * The cpu which was handling the broadcast
 			 * timer marked this cpu in the broadcast
@@ -746,6 +828,7 @@ void tick_broadcast_oneshot_control(unsigned long reason)
 	}
 out:
 	raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+	return ret;
 }
 
 /*
@@ -821,18 +904,56 @@ void tick_broadcast_switch_to_oneshot(void)
 {
 	struct clock_event_device *bc;
 	unsigned long flags;
+	int cpu = smp_processor_id();
 
 	raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
+	bc_next_wakeup.tv64 = KTIME_MAX;
+
 	tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT;
 	bc = tick_broadcast_device.evtdev;
-	if (bc)
+	if (bc) {
 		tick_broadcast_setup_oneshot(bc);
+		bc_next_wakeup = bc->next_event;
+	} else if (hrtimer_initialized){
+
+		/*
+		 * There may be CPUs waiting for periodic broadcast. We need
+		 * to set the oneshot bits for those and program the hrtimer
+		 * to fire at the next tick period.
+ 		 */
+		cpumask_copy(tmpmask, tick_broadcast_mask);
+		cpumask_clear_cpu(cpu, tmpmask);
+		cpumask_or(tick_broadcast_oneshot_mask,
+			   tick_broadcast_oneshot_mask, tmpmask);
+
+		if (!cpumask_empty(tmpmask)) {
+			tick_broadcast_init_next_event(tmpmask,
+						       tick_next_period);
+			hrtimer_start(bc_hrtimer, tick_next_period, HRTIMER_MODE_ABS_PINNED);
+			bc_next_wakeup = tick_next_period;
+		}
+	}
 
 	raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }
 
 
+void tick_handover_bc_cpu(int *cpup)
+{
+	struct tick_device *td;
+
+	if (*cpup == bc_cpu) {
+		int cpu = cpumask_first(tick_broadcast_oneshot_mask);
+
+		bc_cpu = (cpu < nr_cpu_ids) ? cpu : -1;
+		if (bc_cpu != -1) {
+			td = &per_cpu(tick_cpu_device, bc_cpu);
+			td->evtdev->broadcast(cpumask_of(bc_cpu));
+		}
+	}
+}
+
 /*
  * Remove a dead CPU from broadcasting
  */
@@ -868,8 +989,29 @@ int tick_broadcast_oneshot_active(void)
 bool tick_broadcast_oneshot_available(void)
 {
 	struct clock_event_device *bc = tick_broadcast_device.evtdev;
+	bool ret = true;
+	unsigned long flags;
 
-	return bc ? bc->features & CLOCK_EVT_FEAT_ONESHOT : false;
+	raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
+
+	if (bc) {
+		ret = bc->features & CLOCK_EVT_FEAT_ONESHOT;
+	} else if (!hrtimer_initialized) {
+		/* An alternative to tick_broadcast_device on archs which do not have
+		 * an external device
+		 */
+		bc_hrtimer = kmalloc(sizeof(*bc_hrtimer), GFP_NOWAIT);
+		if (!bc_hrtimer) {
+			ret = false;
+			goto out;
+		}
+		hrtimer_init(bc_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
+		bc_hrtimer->function = handle_broadcast;
+		hrtimer_initialized = 1;
+	}
+
+out:	raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+	return ret;
 }
 
 #endif
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index 18e71f7..1f73032 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -46,23 +46,25 @@ extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
 extern void tick_resume_oneshot(void);
 # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
 extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
-extern void tick_broadcast_oneshot_control(unsigned long reason);
+extern int tick_broadcast_oneshot_control(unsigned long reason);
 extern void tick_broadcast_switch_to_oneshot(void);
 extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
 extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
 extern int tick_broadcast_oneshot_active(void);
 extern void tick_check_oneshot_broadcast(int cpu);
+extern void tick_handover_bc_cpu(int *cpup);
 bool tick_broadcast_oneshot_available(void);
 # else /* BROADCAST */
 static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
 {
 	BUG();
 }
-static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
+static inline int tick_broadcast_oneshot_control(unsigned long reason) { }
 static inline void tick_broadcast_switch_to_oneshot(void) { }
 static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
 static inline int tick_broadcast_oneshot_active(void) { return 0; }
 static inline void tick_check_oneshot_broadcast(int cpu) { }
+static inline void tick_handover_bc_cpu(int *cpup) {}
 static inline bool tick_broadcast_oneshot_available(void) { return true; }
 # endif /* !BROADCAST */
 
@@ -87,7 +89,7 @@ static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
 {
 	BUG();
 }
-static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
+static inline int tick_broadcast_oneshot_control(unsigned long reason) { }
 static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
 static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
 {

^ permalink raw reply related

* Re: [PATCH 1/4] powerpc/eeh: Add restore_bars operation
From: Gavin Shan @ 2014-01-01  3:29 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Gavin Shan
In-Reply-To: <1388182804.4373.17.camel@pasglop>

On Sat, Dec 28, 2013 at 09:20:04AM +1100, Benjamin Herrenschmidt wrote:
>On Wed, 2013-12-25 at 16:58 +0800, Gavin Shan wrote:
>> After reset on the specific PE or PHB, we never configure AER
>> correctly on PowerNV platform. We needn't care it on pSeries
>> platform. The patch introduces additional EEH operation eeh_ops::
>> restore_bars() so that we have chance to configure AER correctly
>> for PowerNV platform.
>
>Why call it "restore_bars" if it restores something else (in this case
>AER) ?
>
>I would call it "restore_config" instead... Also rather than adding
>the knowledge of what AER bit works or not for the device, would it
>make sense to instead have a FW call to re-init the device ?
>
>Otherwise, you introduce duplication between Linux and Firmware with
>the risk of getting out of sync...
>

Thanks for your comments, Ben. It's reasonable to have name "restore_config"
and I'll introduce a FW call in next revision as you suggested :-)

Thanks,
Gavin

>> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
>> ---
>>  arch/powerpc/include/asm/eeh.h               |    1 +
>>  arch/powerpc/kernel/eeh_pe.c                 |    3 +++
>>  arch/powerpc/platforms/pseries/eeh_pseries.c |    4 +++-
>>  3 files changed, 7 insertions(+), 1 deletion(-)
>> 
>> diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
>> index d3e5e9b..4b709bf 100644
>> --- a/arch/powerpc/include/asm/eeh.h
>> +++ b/arch/powerpc/include/asm/eeh.h
>> @@ -157,6 +157,7 @@ struct eeh_ops {
>>  	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 (*next_error)(struct eeh_pe **pe);
>> +	void (*restore_bars)(struct device_node *dn);
>>  };
>>  
>>  extern struct eeh_ops *eeh_ops;
>> diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
>> index f945053..19eb95a 100644
>> --- a/arch/powerpc/kernel/eeh_pe.c
>> +++ b/arch/powerpc/kernel/eeh_pe.c
>> @@ -737,6 +737,9 @@ static void *eeh_restore_one_device_bars(void *data, void *flag)
>>  	else
>>  		eeh_restore_device_bars(edev, dn);
>>  
>> +	if (eeh_ops->restore_bars)
>> +		eeh_ops->restore_bars(dn);
>> +
>>  	return NULL;
>>  }
>>  
>> diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c
>> index ccb633e..623adaf 100644
>> --- a/arch/powerpc/platforms/pseries/eeh_pseries.c
>> +++ b/arch/powerpc/platforms/pseries/eeh_pseries.c
>> @@ -689,7 +689,9 @@ static struct eeh_ops pseries_eeh_ops = {
>>  	.get_log		= pseries_eeh_get_log,
>>  	.configure_bridge       = pseries_eeh_configure_bridge,
>>  	.read_config		= pseries_eeh_read_config,
>> -	.write_config		= pseries_eeh_write_config
>> +	.write_config		= pseries_eeh_write_config,
>> +	.next_error		= NULL,
>> +	.restore_bars		= NULL
>>  };
>>  
>>  /**
>
>

^ permalink raw reply

* Where to post problems with linux-ppc for Freescale processors such as the p1020?
From: jeclark2006 @ 2013-12-31 20:35 UTC (permalink / raw)
  To: linuxppc-dev

As the subject says... where to post problems with ppc & linux that does not
involve 'apple' implementations.

The 'embedded' list appears to be pretty much dead.




--
View this message in context: http://linuxppc.10917.n7.nabble.com/Where-to-post-problems-with-linux-ppc-for-Freescale-processors-such-as-the-p1020-tp79016.html
Sent from the linuxppc-dev mailing list archive at Nabble.com.

^ permalink raw reply

* RE: [PATCH] ASoC: fsl_sai: Fix one bug for hardware limitation.
From: Li.Xiubo @ 2013-12-31  3:29 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, tiwai@suse.de,
	linux-kernel@vger.kernel.org, timur@tabi.org, perex@perex.cz,
	shawn.guo@linaro.org, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <20131230121520.GR31886@sirena.org.uk>

Hi Mark,

> Subject: Re: [PATCH] ASoC: fsl_sai: Fix one bug for hardware limitation.
>=20
> On Thu, Dec 26, 2013 at 10:57:22AM +0800, Xiubo Li wrote:
> > This is maybe one bug or a limitation of the hardware that the {T,R}CR2=
's
> > Synchronous Mode bits must be set as late as possible, or the SAI devic=
e
> > maybe hanged up, and there has not any explaination about this limitati=
on
> > in the SAI Data Sheet.
>=20
> If they really should be set as late as possible then I'd expect them to
> be being set in the trigger function, that's what gets called as the
> audio actually starts streaming.  This is moving it to the startup
> function which is one of the first things that happens during audio
> stream setup so presumably makes things worse.
>=20

Yes, it is.

If everything is OK, I will send another new patch later.

Thanks,

---
Best Regards,
Xiubo

^ permalink raw reply

* [PATCH] powerpc: add vr save/restore functions
From: Andreas Schwab @ 2013-12-30 14:31 UTC (permalink / raw)
  To: linuxppc-dev

GCC 4.8 now generates out-of-line vr save/restore functions when
optimizing for size.  They are needed for the raid6 altivec support.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
 arch/powerpc/lib/crtsavres.S | 186 +++++++++++++++++++++++++++++++++++++++++++
 scripts/mod/modpost.c        |   8 +-
 2 files changed, 192 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/lib/crtsavres.S b/arch/powerpc/lib/crtsavres.S
index b2c68ce..a5b30c7 100644
--- a/arch/powerpc/lib/crtsavres.S
+++ b/arch/powerpc/lib/crtsavres.S
@@ -231,6 +231,87 @@ _GLOBAL(_rest32gpr_31_x)
 	mr	1,11
 	blr
 
+#ifdef CONFIG_ALTIVEC
+/* Called with r0 pointing just beyond the end of the vector save area.  */
+
+_GLOBAL(_savevr_20)
+	li	r11,-192
+	stvx	vr20,r11,r0
+_GLOBAL(_savevr_21)
+	li	r11,-176
+	stvx	vr21,r11,r0
+_GLOBAL(_savevr_22)
+	li	r11,-160
+	stvx	vr22,r11,r0
+_GLOBAL(_savevr_23)
+	li	r11,-144
+	stvx	vr23,r11,r0
+_GLOBAL(_savevr_24)
+	li	r11,-128
+	stvx	vr24,r11,r0
+_GLOBAL(_savevr_25)
+	li	r11,-112
+	stvx	vr25,r11,r0
+_GLOBAL(_savevr_26)
+	li	r11,-96
+	stvx	vr26,r11,r0
+_GLOBAL(_savevr_27)
+	li	r11,-80
+	stvx	vr27,r11,r0
+_GLOBAL(_savevr_28)
+	li	r11,-64
+	stvx	vr28,r11,r0
+_GLOBAL(_savevr_29)
+	li	r11,-48
+	stvx	vr29,r11,r0
+_GLOBAL(_savevr_30)
+	li	r11,-32
+	stvx	vr30,r11,r0
+_GLOBAL(_savevr_31)
+	li	r11,-16
+	stvx	vr31,r11,r0
+	blr
+
+_GLOBAL(_restvr_20)
+	li	r11,-192
+	lvx	vr20,r11,r0
+_GLOBAL(_restvr_21)
+	li	r11,-176
+	lvx	vr21,r11,r0
+_GLOBAL(_restvr_22)
+	li	r11,-160
+	lvx	vr22,r11,r0
+_GLOBAL(_restvr_23)
+	li	r11,-144
+	lvx	vr23,r11,r0
+_GLOBAL(_restvr_24)
+	li	r11,-128
+	lvx	vr24,r11,r0
+_GLOBAL(_restvr_25)
+	li	r11,-112
+	lvx	vr25,r11,r0
+_GLOBAL(_restvr_26)
+	li	r11,-96
+	lvx	vr26,r11,r0
+_GLOBAL(_restvr_27)
+	li	r11,-80
+	lvx	vr27,r11,r0
+_GLOBAL(_restvr_28)
+	li	r11,-64
+	lvx	vr28,r11,r0
+_GLOBAL(_restvr_29)
+	li	r11,-48
+	lvx	vr29,r11,r0
+_GLOBAL(_restvr_30)
+	li	r11,-32
+	lvx	vr30,r11,r0
+_GLOBAL(_restvr_31)
+	li	r11,-16
+	lvx	vr31,r11,r0
+	blr
+
+#endif /* CONFIG_ALTIVEC */
+
 #else /* CONFIG_PPC64 */
 
 	.section ".text.save.restore","ax",@progbits
@@ -356,6 +437,111 @@ _restgpr0_31:
 	mtlr	r0
 	blr
 
+#ifdef CONFIG_ALTIVEC
+/* Called with r0 pointing just beyond the end of the vector save area.  */
+
+.globl	_savevr_20
+_savevr_20:
+	li	r12,-192
+	stvx	vr20,r12,r0
+.globl	_savevr_21
+_savevr_21:
+	li	r12,-176
+	stvx	vr21,r12,r0
+.globl	_savevr_22
+_savevr_22:
+	li	r12,-160
+	stvx	vr22,r12,r0
+.globl	_savevr_23
+_savevr_23:
+	li	r12,-144
+	stvx	vr23,r12,r0
+.globl	_savevr_24
+_savevr_24:
+	li	r12,-128
+	stvx	vr24,r12,r0
+.globl	_savevr_25
+_savevr_25:
+	li	r12,-112
+	stvx	vr25,r12,r0
+.globl	_savevr_26
+_savevr_26:
+	li	r12,-96
+	stvx	vr26,r12,r0
+.globl	_savevr_27
+_savevr_27:
+	li	r12,-80
+	stvx	vr27,r12,r0
+.globl	_savevr_28
+_savevr_28:
+	li	r12,-64
+	stvx	vr28,r12,r0
+.globl	_savevr_29
+_savevr_29:
+	li	r12,-48
+	stvx	vr29,r12,r0
+.globl	_savevr_30
+_savevr_30:
+	li	r12,-32
+	stvx	vr30,r12,r0
+.globl	_savevr_31
+_savevr_31:
+	li	r12,-16
+	stvx	vr31,r12,r0
+	blr
+
+.globl	_restvr_20
+_restvr_20:
+	li	r12,-192
+	lvx	vr20,r12,r0
+.globl	_restvr_21
+_restvr_21:
+	li	r12,-176
+	lvx	vr21,r12,r0
+.globl	_restvr_22
+_restvr_22:
+	li	r12,-160
+	lvx	vr22,r12,r0
+.globl	_restvr_23
+_restvr_23:
+	li	r12,-144
+	lvx	vr23,r12,r0
+.globl	_restvr_24
+_restvr_24:
+	li	r12,-128
+	lvx	vr24,r12,r0
+.globl	_restvr_25
+_restvr_25:
+	li	r12,-112
+	lvx	vr25,r12,r0
+.globl	_restvr_26
+_restvr_26:
+	li	r12,-96
+	lvx	vr26,r12,r0
+.globl	_restvr_27
+_restvr_27:
+	li	r12,-80
+	lvx	vr27,r12,r0
+.globl	_restvr_28
+_restvr_28:
+	li	r12,-64
+	lvx	vr28,r12,r0
+.globl	_restvr_29
+_restvr_29:
+	li	r12,-48
+	lvx	vr29,r12,r0
+.globl	_restvr_30
+_restvr_30:
+	li	r12,-32
+	lvx	vr30,r12,r0
+.globl	_restvr_31
+_restvr_31:
+	li	r12,-16
+	lvx	vr31,r12,r0
+	blr
+
+#endif /* CONFIG_ALTIVEC */
+
 #endif /* CONFIG_PPC64 */
 
 #endif
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 1785576..4061098 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -584,12 +584,16 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
 		if (strncmp(symname, "_restgpr_", sizeof("_restgpr_") - 1) == 0 ||
 		    strncmp(symname, "_savegpr_", sizeof("_savegpr_") - 1) == 0 ||
 		    strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 ||
-		    strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0)
+		    strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0 ||
+		    strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 ||
+		    strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0)
 			return 1;
 	if (info->hdr->e_machine == EM_PPC64)
 		/* Special register function linked on all modules during final link of .ko */
 		if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 ||
-		    strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0)
+		    strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 ||
+		    strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 ||
+		    strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0)
 			return 1;
 	/* Do not ignore this symbol */
 	return 0;
-- 
1.8.5.2

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply related

* Re: [PATCH] iommu: Add empty stub for iommu_group_get_by_id()
From: Joerg Roedel @ 2013-12-30 14:18 UTC (permalink / raw)
  To: Alexey Kardashevskiy; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <1385016074-17026-1-git-send-email-aik@ozlabs.ru>

On Thu, Nov 21, 2013 at 05:41:14PM +1100, Alexey Kardashevskiy wrote:
> Almost every function in include/linux/iommu.h has an empty stub
> but the iommu_group_get_by_id() did not get one by mistake.
> 
> This adds an empty stub for iommu_group_get_by_id() for IOMMU_API
> disabled config.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH] ASoC: fsl_sai: Add disable operation for the corresponding data channel.
From: Mark Brown @ 2013-12-30 12:17 UTC (permalink / raw)
  To: Xiubo Li
  Cc: alsa-devel, lgirdwood, tiwai, linux-kernel, timur, perex,
	shawn.guo, linuxppc-dev, b47053
In-Reply-To: <1387946404-24029-1-git-send-email-Li.Xiubo@freescale.com>

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

On Wed, Dec 25, 2013 at 12:40:04PM +0800, Xiubo Li wrote:
> Enables/Disables the corresponding data channel for tx/rx operation.
> A channel must be enabled before its FIFO is accessed, and then disable
> it when tx/rx is stopped or idle.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH] ASoC: fsl_sai: Fix one bug for hardware limitation.
From: Mark Brown @ 2013-12-30 12:15 UTC (permalink / raw)
  To: Xiubo Li
  Cc: alsa-devel, lgirdwood, tiwai, linux-kernel, timur, perex,
	shawn.guo, linuxppc-dev, b47053
In-Reply-To: <1388026642-1464-1-git-send-email-Li.Xiubo@freescale.com>

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

On Thu, Dec 26, 2013 at 10:57:22AM +0800, Xiubo Li wrote:
> This is maybe one bug or a limitation of the hardware that the {T,R}CR2's
> Synchronous Mode bits must be set as late as possible, or the SAI device
> maybe hanged up, and there has not any explaination about this limitation
> in the SAI Data Sheet.

If they really should be set as late as possible then I'd expect them to
be being set in the trigger function, that's what gets called as the
audio actually starts streaming.  This is moving it to the startup
function which is one of the first things that happens during audio
stream setup so presumably makes things worse.

Also...

> @@ -62,6 +62,7 @@ static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
>  		reg_cr2 = FSL_SAI_RCR2;
>  
>  	val_cr2 = sai_readl(sai, sai->base + reg_cr2);
> +
>  	switch (clk_id) {
>  	case FSL_SAI_CLK_BUS:
>  		val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK;
> @@ -82,6 +83,7 @@ static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
>  	default:
>  		return -EINVAL;
>  	}
> +
>  	sai_writel(sai, val_cr2, sai->base + reg_cr2);
>  
>  	return 0;

These appear to be unrelated changes - please send as a separate patch
if they're useful.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH] ASoC: fsl_sai: Move the global registers setting to _dai_probe()
From: Mark Brown @ 2013-12-30 12:01 UTC (permalink / raw)
  To: Xiubo Li
  Cc: alsa-devel, lgirdwood, tiwai, linux-kernel, timur, perex,
	shawn.guo, linuxppc-dev, b47053
In-Reply-To: <1387941614-7629-1-git-send-email-Li.Xiubo@freescale.com>

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

On Wed, Dec 25, 2013 at 11:20:14AM +0800, Xiubo Li wrote:
> Because we cannot make sure which one of _dai_fmt() and _dai_sysclk()
> will be firstly called. So move the RCSR/TCSR and TCR1/RCR1's
> initialization to _dai_probe(), and this can make sure that before any
> of {T,R}CR{1~5} register to be set the RCSR/TCSR's RE/TE bit has been
> cleared for the hareware limitation.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* [PATCH 2/2] powerpc: Add debug checks to catch invalid cpu-to-node mappings
From: Srivatsa S. Bhat @ 2013-12-30 11:36 UTC (permalink / raw)
  To: benh, paulus, nfont; +Cc: Srivatsa S. Bhat, maddy, linuxppc-dev, linux-kernel
In-Reply-To: <20131230113517.11508.7224.stgit@srivatsabhat.in.ibm.com>

There have been some weird bugs in the past where the kernel tried to associate
threads of the same core to different NUMA nodes, and things went haywire after
that point (as expected).

But unfortunately, root-causing such issues have been quite challenging, due to
the lack of appropriate debug checks in the kernel. These bugs usually lead to
some odd soft-lockups in the scheduler's build-sched-domain code in the CPU
hotplug path, which makes it very hard to trace it back to the incorrect
cpu-to-node mappings.

So add appropriate debug checks to catch such invalid cpu-to-node mappings
as early as possible.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 arch/powerpc/mm/numa.c |   26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 6847d50..4f50c6a 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -570,16 +570,38 @@ out:
 	return nid;
 }
 
+static void verify_cpu_node_mapping(int cpu, int node)
+{
+	int base, sibling, i;
+
+	/* Verify that all the threads in the core belong to the same node */
+	base = cpu_first_thread_sibling(cpu);
+
+	for (i = 0; i < threads_per_core; i++) {
+		sibling = base + i;
+
+		if (sibling == cpu || cpu_is_offline(sibling))
+			continue;
+
+		if (cpu_to_node(sibling) != node) {
+			WARN(1, "CPU thread siblings %d and %d don't belong"
+				" to the same node!\n", cpu, sibling);
+			break;
+		}
+	}
+}
+
 static int cpu_numa_callback(struct notifier_block *nfb, unsigned long action,
 			     void *hcpu)
 {
 	unsigned long lcpu = (unsigned long)hcpu;
-	int ret = NOTIFY_DONE;
+	int ret = NOTIFY_DONE, nid;
 
 	switch (action) {
 	case CPU_UP_PREPARE:
 	case CPU_UP_PREPARE_FROZEN:
-		numa_setup_cpu(lcpu);
+		nid = numa_setup_cpu(lcpu);
+		verify_cpu_node_mapping((int)lcpu, nid);
 		ret = NOTIFY_OK;
 		break;
 #ifdef CONFIG_HOTPLUG_CPU

^ permalink raw reply related

* [PATCH 1/2] powerpc: Fix the setup of CPU-to-Node mappings during CPU online
From: Srivatsa S. Bhat @ 2013-12-30 11:35 UTC (permalink / raw)
  To: benh, paulus, nfont; +Cc: Srivatsa S. Bhat, maddy, linuxppc-dev, linux-kernel

On POWER platforms, the hypervisor can notify the guest kernel about dynamic
changes in the cpu-numa associativity (VPHN topology update). Hence the
cpu-to-node mappings that we got from the firmware during boot, may no longer
be valid after such updates. This is handled using the arch_update_cpu_topology()
hook in the scheduler, and the sched-domains are rebuilt according to the new
mappings.

But unfortunately, at the moment, CPU hotplug ignores these updated mappings
and instead queries the firmware for the cpu-to-numa relationships and uses
them during CPU online. So the kernel can end up assigning wrong NUMA nodes
to CPUs during subsequent CPU hotplug online operations (after booting).

Further, a particularly problematic scenario can result from this bug:
On POWER platforms, the SMT mode can be switched between 1, 2, 4 (and even 8)
threads per core. The switch to Single-Threaded (ST) mode is performed by
offlining all except the first CPU thread in each core. Switching back to
SMT mode involves onlining those other threads back, in each core.

Now consider this scenario:

1. During boot, the kernel gets the cpu-to-node mappings from the firmware
   and assigns the CPUs to NUMA nodes appropriately, during CPU online.

2. Later on, the hypervisor updates the cpu-to-node mappings dynamically and
   communicates this update to the kernel. The kernel in turn updates its
   cpu-to-node associations and rebuilds its sched domains. Everything is
   fine so far.

3. Now, the user switches the machine from SMT to ST mode (say, by running
   ppc64_cpu --smt=1). This involves offlining all except 1 thread in each
   core.

4. The user then tries to switch back from ST to SMT mode (say, by running
   ppc64_cpu --smt=4), and this involves onlining those threads back. Since
   CPU hotplug ignores the new mappings, it queries the firmware and tries to
   associate the newly onlined sibling threads to the old NUMA nodes. This
   results in sibling threads within the same core getting associated with
   different NUMA nodes, which is incorrect.

   The scheduler's build-sched-domains code gets thoroughly confused with this
   and enters an infinite loop and causes soft-lockups, as explained in detail
   in commit 3be7db6ab (powerpc: VPHN topology change updates all siblings).


So to fix this, use the numa_cpu_lookup_table to remember the updated
cpu-to-node mappings, and use them during CPU hotplug online operations.
Further, we also need to ensure that all threads in a core are assigned to a
common NUMA node, irrespective of whether all those threads were online during
the topology update. To achieve this, we take care not to use cpu_sibling_mask()
since it is not hotplug invariant. Instead, we use cpu_first_sibling_thread()
and set up the mappings manually using the 'threads_per_core' value for that
particular platform. This helps us ensure that we don't hit this bug with any
combination of CPU hotplug and SMT mode switching.

Cc: stable@vger.kernel.org
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 arch/powerpc/include/asm/topology.h |   10 +++++
 arch/powerpc/mm/numa.c              |   70 ++++++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 89e3ef2..d0b5fca 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -22,7 +22,15 @@ struct device_node;
 
 static inline int cpu_to_node(int cpu)
 {
-	return numa_cpu_lookup_table[cpu];
+	int nid;
+
+	nid = numa_cpu_lookup_table[cpu];
+
+	/*
+	 * During early boot, the numa-cpu lookup table might not have been
+	 * setup for all CPUs yet. In such cases, default to node 0.
+	 */
+	return (nid < 0) ? 0 : nid;
 }
 
 #define parent_node(node)	(node)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 078d3e0..6847d50 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -31,6 +31,8 @@
 #include <asm/sparsemem.h>
 #include <asm/prom.h>
 #include <asm/smp.h>
+#include <asm/cputhreads.h>
+#include <asm/topology.h>
 #include <asm/firmware.h>
 #include <asm/paca.h>
 #include <asm/hvcall.h>
@@ -152,9 +154,22 @@ static void __init get_node_active_region(unsigned long pfn,
 	}
 }
 
-static void map_cpu_to_node(int cpu, int node)
+static void reset_numa_cpu_lookup_table(void)
+{
+	unsigned int cpu;
+
+	for_each_possible_cpu(cpu)
+		numa_cpu_lookup_table[cpu] = -1;
+}
+
+static void update_numa_cpu_lookup_table(unsigned int cpu, int node)
 {
 	numa_cpu_lookup_table[cpu] = node;
+}
+
+static void map_cpu_to_node(int cpu, int node)
+{
+	update_numa_cpu_lookup_table(cpu, node);
 
 	dbg("adding cpu %d to node %d\n", cpu, node);
 
@@ -522,11 +537,24 @@ static int of_drconf_to_nid_single(struct of_drconf_cell *drmem,
  */
 static int numa_setup_cpu(unsigned long lcpu)
 {
-	int nid = 0;
-	struct device_node *cpu = of_get_cpu_node(lcpu, NULL);
+	int nid;
+	struct device_node *cpu;
+
+	/*
+	 * If a valid cpu-to-node mapping is already available, use it
+	 * directly instead of querying the firmware, since it represents
+	 * the most recent mapping notified to us by the platform (eg: VPHN).
+	 */
+	if ((nid = numa_cpu_lookup_table[lcpu]) >= 0) {
+		map_cpu_to_node(lcpu, nid);
+		return nid;
+	}
+
+	cpu = of_get_cpu_node(lcpu, NULL);
 
 	if (!cpu) {
 		WARN_ON(1);
+		nid = 0;
 		goto out;
 	}
 
@@ -1067,6 +1095,7 @@ void __init do_init_bootmem(void)
 	 */
 	setup_node_to_cpumask_map();
 
+	reset_numa_cpu_lookup_table();
 	register_cpu_notifier(&ppc64_numa_nb);
 	cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
 			  (void *)(unsigned long)boot_cpuid);
@@ -1445,6 +1474,33 @@ static int update_cpu_topology(void *data)
 	return 0;
 }
 
+static int update_lookup_table(void *data)
+{
+	struct topology_update_data *update;
+
+	if (!data)
+		return -EINVAL;
+
+	/*
+	 * Upon topology update, the numa-cpu lookup table needs to be updated
+	 * for all threads in the core, including offline CPUs, to ensure that
+	 * future hotplug operations respect the cpu-to-node associativity
+	 * properly.
+	 */
+	for (update = data; update; update = update->next) {
+		int nid, base, j;
+
+		nid = update->new_nid;
+		base = cpu_first_thread_sibling(update->cpu);
+
+		for (j = 0; j < threads_per_core; j++) {
+			update_numa_cpu_lookup_table(base + j, nid);
+		}
+	}
+
+	return 0;
+}
+
 /*
  * Update the node maps and sysfs entries for each cpu whose home node
  * has changed. Returns 1 when the topology has changed, and 0 otherwise.
@@ -1513,6 +1569,14 @@ int arch_update_cpu_topology(void)
 
 	stop_machine(update_cpu_topology, &updates[0], &updated_cpus);
 
+	/*
+	 * Update the numa-cpu lookup table with the new mappings, even for
+	 * offline CPUs. It is best to perform this update from the stop-
+	 * machine context.
+	 */
+	stop_machine(update_lookup_table, &updates[0],
+					cpumask_of(raw_smp_processor_id()));
+
 	for (ud = &updates[0]; ud; ud = ud->next) {
 		unregister_cpu_under_node(ud->cpu, ud->old_nid);
 		register_cpu_under_node(ud->cpu, ud->new_nid);

^ permalink raw reply related

* Re: [PATCH -V2] POWERPC: BOOK3S: KVM: Use the saved dsisr and dar values on book3s 64
From: Alexander Graf @ 2013-12-30  9:12 UTC (permalink / raw)
  To: Aneesh Kumar K.V
  Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, paulus@samba.org,
	Aneesh Kumar K.V, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <1388383469-6411-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>



> Am 30.12.2013 um 07:04 schrieb "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet=
.ibm.com>:
>=20
> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>=20
> Although it's optional IBM POWER cpus always had DAR value set on
> alignment interrupt. So don't try to compute these values.
>=20
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
> arch/powerpc/kvm/book3s_emulate.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>=20
> diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_e=
mulate.c
> index 502a47ac4453..d8e2d079483d 100644
> --- a/arch/powerpc/kvm/book3s_emulate.c
> +++ b/arch/powerpc/kvm/book3s_emulate.c
> @@ -599,6 +599,19 @@ unprivileged:
>=20
> u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)
> {
> +#ifdef CONFIG_PPC_BOOK3S_64
> +    return vcpu->arch.fault_dsisr;

This is still wrong when you virtualize a 750 on a 970 for example.

Alex

> +#else
> +    /*
> +     * Mac OS X has some applications - namely the Finder - that require
> +     * alignment interrupts to work properly. So we need to implement the=
m.
> +
> +     * But the spec for 970 and 750 also looks different. While 750 requi=
res
> +     * the DSISR and DAR fields to reflect some instruction bits (DSISR) a=
nd
> +     * the fault address (DAR), the 970 declares this as an optional feat=
ure.
> +     * So we need to reconstruct DSISR and DAR manually.
> +     */
> +
>    u32 dsisr =3D 0;
>=20
>    /*
> @@ -637,10 +650,24 @@ u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, un=
signed int inst)
>    dsisr |=3D (inst >> 16) & 0x03ff; /* bits 22:31 */
>=20
>    return dsisr;
> +#endif
> }
>=20
> ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst)
> {
> +#ifdef CONFIG_PPC_BOOK3S_64
> +    return vcpu->arch.fault_dar;
> +#else
> +    /*
> +     * Mac OS X has some applications - namely the Finder - that require
> +     * alignment interrupts to work properly. So we need to implement the=
m.
> +
> +     * But the spec for 970 and 750 also looks different. While 750 requi=
res
> +     * the DSISR and DAR fields to reflect some instruction bits (DSISR) a=
nd
> +     * the fault address (DAR), the 970 declares this as an optional feat=
ure.
> +     * So we need to reconstruct DSISR and DAR manually.
> +     */
> +
>    ulong dar =3D 0;
>    ulong ra =3D get_ra(inst);
>    ulong rb =3D get_rb(inst);
> @@ -665,4 +692,5 @@ ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsi=
gned int inst)
>    }
>=20
>    return dar;
> +#endif
> }
> --=20
> 1.8.3.2
>=20

^ permalink raw reply

* [PATCH] block/ps3: Remove obsolete reference to MTD
From: Geert Uytterhoeven @ 2013-12-30  9:07 UTC (permalink / raw)
  To: Geoff Levand, Jim Paris
  Cc: cbe-oss-dev, Geert Uytterhoeven, linuxppc-dev, linux-kernel

The ps3vram driver is a plain block device driver since commit
f507cd22035fdadd5dbb476dd05e9e7ee21c3b84 ("ps3/block: Replace mtd/ps3vram
by block/ps3vram").

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/block/ps3vram.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
index 06a2e53e5f37..313ee641ea10 100644
--- a/drivers/block/ps3vram.c
+++ b/drivers/block/ps3vram.c
@@ -1,5 +1,5 @@
 /*
- * ps3vram - Use extra PS3 video ram as MTD block device.
+ * ps3vram - Use extra PS3 video ram as block device.
  *
  * Copyright 2009 Sony Corporation
  *
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH -V2] POWERPC: BOOK3S: KVM: Use the saved dsisr and dar values on book3s 64
From: Aneesh Kumar K.V @ 2013-12-30  6:04 UTC (permalink / raw)
  To: agraf, benh, paulus; +Cc: linuxppc-dev, kvm, kvm-ppc, Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>

Although it's optional IBM POWER cpus always had DAR value set on
alignment interrupt. So don't try to compute these values.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/kvm/book3s_emulate.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c
index 502a47ac4453..d8e2d079483d 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -599,6 +599,19 @@ unprivileged:
 
 u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)
 {
+#ifdef CONFIG_PPC_BOOK3S_64
+	return vcpu->arch.fault_dsisr;
+#else
+	/*
+	 * Mac OS X has some applications - namely the Finder - that require
+	 * alignment interrupts to work properly. So we need to implement them.
+
+	 * But the spec for 970 and 750 also looks different. While 750 requires
+	 * the DSISR and DAR fields to reflect some instruction bits (DSISR) and
+	 * the fault address (DAR), the 970 declares this as an optional feature.
+	 * So we need to reconstruct DSISR and DAR manually.
+	 */
+
 	u32 dsisr = 0;
 
 	/*
@@ -637,10 +650,24 @@ u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)
 	dsisr |= (inst >> 16) & 0x03ff; /* bits 22:31 */
 
 	return dsisr;
+#endif
 }
 
 ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst)
 {
+#ifdef CONFIG_PPC_BOOK3S_64
+	return vcpu->arch.fault_dar;
+#else
+	/*
+	 * Mac OS X has some applications - namely the Finder - that require
+	 * alignment interrupts to work properly. So we need to implement them.
+
+	 * But the spec for 970 and 750 also looks different. While 750 requires
+	 * the DSISR and DAR fields to reflect some instruction bits (DSISR) and
+	 * the fault address (DAR), the 970 declares this as an optional feature.
+	 * So we need to reconstruct DSISR and DAR manually.
+	 */
+
 	ulong dar = 0;
 	ulong ra = get_ra(inst);
 	ulong rb = get_rb(inst);
@@ -665,4 +692,5 @@ ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst)
 	}
 
 	return dar;
+#endif
 }
-- 
1.8.3.2

^ permalink raw reply related

* [git pull] Please pull powerpc.git merge branch
From: Benjamin Herrenschmidt @ 2013-12-30  4:37 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linuxppc-dev list, Linux Kernel list

Hi Linus !

Here are a few more powerpc fixes for 3.13. A bit more endian
problems found during testing of 3.13 and a few other simple fixes
and regressions fixes.

Cheers,
Ben.

The following changes since commit 803c2d2f84da9dc2619449994af34d27148ab20d:

  powerpc/powernv: Fix OPAL LPC access in Little Endian (2013-12-13 15:55:15 +1100)

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 f991db1cf1bdca43675b5d2df0af991719727029:

  Merge remote-tracking branch 'agust/merge' into merge (2013-12-30 14:48:27 +1100)

----------------------------------------------------------------

Anton Blanchard (1):
      powerpc: Align p_end

Brian W Hart (2):
      powernv/eeh: Fix possible buffer overrun in ioda_eeh_phb_diag()
      powernv/eeh: Add buffer for P7IOC hub error data

Gerhard Sittig (1):
      powerpc/512x: dts: remove misplaced IRQ spec from 'soc' node (5125)

Matteo Facchinetti (1):
      powerpc/512x: dts: disable MPC5125 usb module

Michael Neuling (1):
      powerpc: Fix bad stack check in exception entry

Olof Johansson (1):
      powerpc: Fix alignment of secondary cpu spin vars

Paul E. McKenney (1):
      powerpc: Make 64-bit non-VMX __copy_tofrom_user bi-endian

Rajesh B Prathipati (1):
      powerpc: Make unaligned accesses endian-safe for powerpc

 arch/powerpc/boot/dts/mpc5125twr.dts      |  6 +++-
 arch/powerpc/include/asm/exception-64s.h  |  2 +-
 arch/powerpc/include/asm/unaligned.h      |  7 +++-
 arch/powerpc/kernel/head_64.S             |  2 ++
 arch/powerpc/lib/copyuser_64.S            | 53 ++++++++++++++++++++++---------
 arch/powerpc/platforms/powernv/eeh-ioda.c | 20 +++---------
 arch/powerpc/platforms/powernv/pci.h      |  4 ++-
 7 files changed, 60 insertions(+), 34 deletions(-)

^ permalink raw reply

* Re: [PATCH] of/irq: Fix device_node refcount in of_irq_parse_raw()
From: Benjamin Herrenschmidt @ 2013-12-30  3:59 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree@vger.kernel.org, Linux Kernel list, Thierry Reding,
	Grant Likely, linuxppc-dev, Cédric Le Goater
In-Reply-To: <CAL_JsqJRtk+U4nA7hh9Kh2C4UgbWP6V7sYMnTpAooR_zaySZaw@mail.gmail.com>

On Sun, 2013-12-29 at 20:42 -0600, Rob Herring wrote:
> On Sun, Dec 29, 2013 at 8:37 PM, Benjamin Herrenschmidt
> <benh@kernel.crashing.org> wrote:
> 
>         On Tue, 2013-12-17 at 18:32 +0100, Cédric Le Goater wrote:
>         > Commit 2361613206e6, "of/irq: Refactor interrupt-map
>         parsing" changed
>         > the refcount on the device_node causing an error in
>         of_node_put():
>         
>         
>         Grant, Thierry, this is a regression, please send to Linus
>         ASAP...
>         
> 
> 
> I'm working on doing that right this moment.

Thanks, looks like I'm not the only trying to get some work done
today :)

Cheers,
Ben.

> 
> Rob
> 
>         Cheers,
>         Ben.
>         
>         > ERROR: Bad of_node_put() on /pci@800000020000000
>         > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc3-dirty
>         #2
>         > Call Trace:
>         > [c00000003e403500] [c0000000000144fc] .show_stack+0x7c/0x1f0
>         (unreliable)
>         > [c00000003e4035d0] [c00000000070f250] .dump_stack+0x88/0xb4
>         > [c00000003e403650] [c0000000005e8768] .of_node_release
>         +0xd8/0xf0
>         > [c00000003e4036e0] [c0000000005eeafc] .of_irq_parse_one
>         +0x10c/0x280
>         > [c00000003e4037a0] [c0000000005efd4c] .of_irq_parse_pci
>         +0x3c/0x1d0
>         > [c00000003e403840] [c000000000038240] .pcibios_setup_device
>         +0xa0/0x2e0
>         > [c00000003e403910]
>         [c0000000000398f0] .pcibios_setup_bus_devices+0x60/0xd0
>         > [c00000003e403990] [c00000000003b3a4] .__of_scan_bus
>         +0x1a4/0x2b0
>         > [c00000003e403a80] [c00000000003a62c] .pcibios_scan_phb
>         +0x30c/0x410
>         > [c00000003e403b60] [c0000000009fe430] .pcibios_init
>         +0x7c/0xd4
>         >
>         > This patch adjusts the refcount in the walk of the interrupt
>         tree.
>         > When a match is found, there is no need to increase the
>         refcount
>         > on 'out_irq->np' as 'newpar' is already holding a ref. The
>         refcount
>         > balance between 'ipar' and 'newpar' is maintained in the
>         skiplevel:
>         > goto label.
>         >
>         > This patch also removes the usage of the device_node
>         variable 'old'
>         > which seems useless after the latest changes.
>         >
>         > Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
>         > ---
>         >
>         > This patch was tested on powerpc, pseries and powernv. This
>         is a
>         > new area for me so I might have missed a path. Please take a
>         look.
>         >
>         > We could now introduce an helper routine to look for
>         #address-cells in
>         > of_irq_parse_raw(). This can be the subject of another
>         patch.
>         >
>         > Thanks,
>         >
>         > C.
>         >
>         >  drivers/of/irq.c |    5 +----
>         >  1 file changed, 1 insertion(+), 4 deletions(-)
>         >
>         > diff --git a/drivers/of/irq.c b/drivers/of/irq.c
>         > index 786b0b47fae4..27212402c532 100644
>         > --- a/drivers/of/irq.c
>         > +++ b/drivers/of/irq.c
>         > @@ -165,7 +165,6 @@ int of_irq_parse_raw(const __be32 *addr,
>         struct of_phandle_args *out_irq)
>         >               if (of_get_property(ipar,
>         "interrupt-controller", NULL) !=
>         >                               NULL) {
>         >                       pr_debug(" -> got it !\n");
>         > -                     of_node_put(old);
>         >                       return 0;
>         >               }
>         >
>         > @@ -250,8 +249,7 @@ int of_irq_parse_raw(const __be32 *addr,
>         struct of_phandle_args *out_irq)
>         >                * Successfully parsed an interrrupt-map
>         translation; copy new
>         >                * interrupt specifier into the out_irq
>         structure
>         >                */
>         > -             of_node_put(out_irq->np);
>         > -             out_irq->np = of_node_get(newpar);
>         > +             out_irq->np = newpar;
>         >
>         >               match_array = imap - newaddrsize - newintsize;
>         >               for (i = 0; i < newintsize; i++)
>         > @@ -268,7 +266,6 @@ int of_irq_parse_raw(const __be32 *addr,
>         struct of_phandle_args *out_irq)
>         >       }
>         >   fail:
>         >       of_node_put(ipar);
>         > -     of_node_put(out_irq->np);
>         >       of_node_put(newpar);
>         >
>         >       return -EINVAL;
>         
>         
>         --
>         
>         To unsubscribe from this list: send the line "unsubscribe
>         devicetree" in
>         the body of a message to majordomo@vger.kernel.org
>         More majordomo info at
>          http://vger.kernel.org/majordomo-info.html
>         
> 
> 

^ permalink raw reply

* Re: commit e38c0a1f breaks powerpc boards with uli1575 chip
From: Benjamin Herrenschmidt @ 2013-12-30  3:13 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: devicetree@vger.kernel.org, Arnd Bergmann, Dmitry Krivoschekov,
	Alexey Lugovskoy, Thierry Reding, linux-kernel, Rob Herring,
	Grant Likely, linuxppc-dev
In-Reply-To: <201312190842.02702@blacky.localdomain>

On Thu, 2013-12-19 at 08:42 +0400, Nikita Yushchenko wrote:
> No, this does not help.
> 
> I've dumped the actual content of 'range' and 'addr' at the failure
> point 
> (i.e. ar point that returns error with e38c0a1f but passes without 
> e38c0a1f ):
> 
> OF: default map, cp=0, s=10000, da=70
> range:  01 00 00 00 00 00 00 00 00 00 00 00
>  addr:  00 00 00 00 00 00 00 00 00 00 00 70

Something that has a #address-cells larger than 2, or more generally,
an address field that contains more than a single number, must have
a specific translation backend, like we have for PCI.

This is a bit annoying but originates from the original OFW stuff on
which this stuff is based where the bus node would provide the methods
for translation.

Cheers,
Ben.
 

^ permalink raw reply

* Re: [PATCH] of/irq: Fix device_node refcount in of_irq_parse_raw()
From: Rob Herring @ 2013-12-30  2:42 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: devicetree@vger.kernel.org, Linux Kernel list, Thierry Reding,
	Grant Likely, linuxppc-dev, Cédric Le Goater
In-Reply-To: <1388371049.4373.22.camel@pasglop>

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

On Sun, Dec 29, 2013 at 8:37 PM, Benjamin Herrenschmidt <
benh@kernel.crashing.org> wrote:

> On Tue, 2013-12-17 at 18:32 +0100, Cédric Le Goater wrote:
> > Commit 2361613206e6, "of/irq: Refactor interrupt-map parsing" changed
> > the refcount on the device_node causing an error in of_node_put():
>
> Grant, Thierry, this is a regression, please send to Linus ASAP...
>
>
I'm working on doing that right this moment.

Rob


> Cheers,
> Ben.
>
> > ERROR: Bad of_node_put() on /pci@800000020000000
> > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc3-dirty #2
> > Call Trace:
> > [c00000003e403500] [c0000000000144fc] .show_stack+0x7c/0x1f0 (unreliable)
> > [c00000003e4035d0] [c00000000070f250] .dump_stack+0x88/0xb4
> > [c00000003e403650] [c0000000005e8768] .of_node_release+0xd8/0xf0
> > [c00000003e4036e0] [c0000000005eeafc] .of_irq_parse_one+0x10c/0x280
> > [c00000003e4037a0] [c0000000005efd4c] .of_irq_parse_pci+0x3c/0x1d0
> > [c00000003e403840] [c000000000038240] .pcibios_setup_device+0xa0/0x2e0
> > [c00000003e403910] [c0000000000398f0]
> .pcibios_setup_bus_devices+0x60/0xd0
> > [c00000003e403990] [c00000000003b3a4] .__of_scan_bus+0x1a4/0x2b0
> > [c00000003e403a80] [c00000000003a62c] .pcibios_scan_phb+0x30c/0x410
> > [c00000003e403b60] [c0000000009fe430] .pcibios_init+0x7c/0xd4
> >
> > This patch adjusts the refcount in the walk of the interrupt tree.
> > When a match is found, there is no need to increase the refcount
> > on 'out_irq->np' as 'newpar' is already holding a ref. The refcount
> > balance between 'ipar' and 'newpar' is maintained in the skiplevel:
> > goto label.
> >
> > This patch also removes the usage of the device_node variable 'old'
> > which seems useless after the latest changes.
> >
> > Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> > ---
> >
> > This patch was tested on powerpc, pseries and powernv. This is a
> > new area for me so I might have missed a path. Please take a look.
> >
> > We could now introduce an helper routine to look for #address-cells in
> > of_irq_parse_raw(). This can be the subject of another patch.
> >
> > Thanks,
> >
> > C.
> >
> >  drivers/of/irq.c |    5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> > index 786b0b47fae4..27212402c532 100644
> > --- a/drivers/of/irq.c
> > +++ b/drivers/of/irq.c
> > @@ -165,7 +165,6 @@ int of_irq_parse_raw(const __be32 *addr, struct
> of_phandle_args *out_irq)
> >               if (of_get_property(ipar, "interrupt-controller", NULL) !=
> >                               NULL) {
> >                       pr_debug(" -> got it !\n");
> > -                     of_node_put(old);
> >                       return 0;
> >               }
> >
> > @@ -250,8 +249,7 @@ int of_irq_parse_raw(const __be32 *addr, struct
> of_phandle_args *out_irq)
> >                * Successfully parsed an interrrupt-map translation; copy
> new
> >                * interrupt specifier into the out_irq structure
> >                */
> > -             of_node_put(out_irq->np);
> > -             out_irq->np = of_node_get(newpar);
> > +             out_irq->np = newpar;
> >
> >               match_array = imap - newaddrsize - newintsize;
> >               for (i = 0; i < newintsize; i++)
> > @@ -268,7 +266,6 @@ int of_irq_parse_raw(const __be32 *addr, struct
> of_phandle_args *out_irq)
> >       }
> >   fail:
> >       of_node_put(ipar);
> > -     of_node_put(out_irq->np);
> >       of_node_put(newpar);
> >
> >       return -EINVAL;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

[-- Attachment #2: Type: text/html, Size: 5511 bytes --]

^ permalink raw reply

* RE: [PATCH 1/2] powerpc/p1022ds: fix rtc compatible string
From: Dongsheng.Wang @ 2013-12-30  2:39 UTC (permalink / raw)
  To: Scott Wood, Chang-Ming.Huang@freescale.com, Roy Zang
  Cc: linuxppc-dev@lists.ozlabs.org, Dongsheng.Wang@freescale.com
In-Reply-To: <1387355964-39486-1-git-send-email-dongsheng.wang@freescale.com>

Hi Scott,

Could you apply these patches?

[1/2] powerpc/p1022ds: fix rtc compatible string, http://patchwork.ozlabs.o=
rg/patch/302741/
[2/2] powerpc/p1022ds: add a interrupt for rtc node, http://patchwork.ozlab=
s.org/patch/302742/

-Dongsheng

> -----Original Message-----
> From: Dongsheng Wang [mailto:dongsheng.wang@freescale.com]
> Sent: Wednesday, December 18, 2013 4:39 PM
> To: Wood Scott-B07421; Huang Changming-R66093; Zang Roy-R61911
> Cc: linuxppc-dev@lists.ozlabs.org; Wang Dongsheng-B40534
> Subject: [PATCH 1/2] powerpc/p1022ds: fix rtc compatible string
>=20
> From: Wang Dongsheng <dongsheng.wang@freescale.com>
>=20
> RTC Hardware(ds3232) and rtc compatible string does not match.
> Change "dallas,ds1339" to "dallas,ds3232".
>=20
> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
>=20
> diff --git a/arch/powerpc/boot/dts/p1022ds.dtsi
> b/arch/powerpc/boot/dts/p1022ds.dtsi
> index 873da35..5725058 100644
> --- a/arch/powerpc/boot/dts/p1022ds.dtsi
> +++ b/arch/powerpc/boot/dts/p1022ds.dtsi
> @@ -146,7 +146,7 @@
>  			 */
>  		};
>  		rtc@68 {
> -			compatible =3D "dallas,ds1339";
> +			compatible =3D "dallas,ds3232";
>  			reg =3D <0x68>;
>  		};
>  		adt7461@4c {
> --
> 1.8.5
>=20

^ permalink raw reply

* Re: [PATCH] of/irq: Fix device_node refcount in of_irq_parse_raw()
From: Benjamin Herrenschmidt @ 2013-12-30  2:37 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: grant.likely, devicetree, Thierry Reding, linuxppc-dev,
	Linux Kernel list
In-Reply-To: <1387301573-30502-1-git-send-email-clg@fr.ibm.com>

On Tue, 2013-12-17 at 18:32 +0100, Cédric Le Goater wrote:
> Commit 2361613206e6, "of/irq: Refactor interrupt-map parsing" changed
> the refcount on the device_node causing an error in of_node_put():

Grant, Thierry, this is a regression, please send to Linus ASAP...

Cheers,
Ben.

> ERROR: Bad of_node_put() on /pci@800000020000000
> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc3-dirty #2
> Call Trace:
> [c00000003e403500] [c0000000000144fc] .show_stack+0x7c/0x1f0 (unreliable)
> [c00000003e4035d0] [c00000000070f250] .dump_stack+0x88/0xb4
> [c00000003e403650] [c0000000005e8768] .of_node_release+0xd8/0xf0
> [c00000003e4036e0] [c0000000005eeafc] .of_irq_parse_one+0x10c/0x280
> [c00000003e4037a0] [c0000000005efd4c] .of_irq_parse_pci+0x3c/0x1d0
> [c00000003e403840] [c000000000038240] .pcibios_setup_device+0xa0/0x2e0
> [c00000003e403910] [c0000000000398f0] .pcibios_setup_bus_devices+0x60/0xd0
> [c00000003e403990] [c00000000003b3a4] .__of_scan_bus+0x1a4/0x2b0
> [c00000003e403a80] [c00000000003a62c] .pcibios_scan_phb+0x30c/0x410
> [c00000003e403b60] [c0000000009fe430] .pcibios_init+0x7c/0xd4
> 
> This patch adjusts the refcount in the walk of the interrupt tree.
> When a match is found, there is no need to increase the refcount 
> on 'out_irq->np' as 'newpar' is already holding a ref. The refcount
> balance between 'ipar' and 'newpar' is maintained in the skiplevel:
> goto label.
> 
> This patch also removes the usage of the device_node variable 'old' 
> which seems useless after the latest changes.
> 
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> ---
> 
> This patch was tested on powerpc, pseries and powernv. This is a 
> new area for me so I might have missed a path. Please take a look.
> 
> We could now introduce an helper routine to look for #address-cells in
> of_irq_parse_raw(). This can be the subject of another patch.
> 
> Thanks,
> 
> C.
> 
>  drivers/of/irq.c |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 786b0b47fae4..27212402c532 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -165,7 +165,6 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
>  		if (of_get_property(ipar, "interrupt-controller", NULL) !=
>  				NULL) {
>  			pr_debug(" -> got it !\n");
> -			of_node_put(old);
>  			return 0;
>  		}
>  
> @@ -250,8 +249,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
>  		 * Successfully parsed an interrrupt-map translation; copy new
>  		 * interrupt specifier into the out_irq structure
>  		 */
> -		of_node_put(out_irq->np);
> -		out_irq->np = of_node_get(newpar);
> +		out_irq->np = newpar;
>  
>  		match_array = imap - newaddrsize - newintsize;
>  		for (i = 0; i < newintsize; i++)
> @@ -268,7 +266,6 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
>  	}
>   fail:
>  	of_node_put(ipar);
> -	of_node_put(out_irq->np);
>  	of_node_put(newpar);
>  
>  	return -EINVAL;

^ permalink raw reply

* RE: [PATCH v6 1/4] powerpc/fsl: add E6500 PVR and SPRN_PWRMGTCR0 define
From: Dongsheng.Wang @ 2013-12-30  2:37 UTC (permalink / raw)
  To: Scott Wood, Bharat.Bhushan@freescale.com
  Cc: linuxppc-dev@lists.ozlabs.org, Dongsheng.Wang@freescale.com
In-Reply-To: <1387268222-9703-1-git-send-email-dongsheng.wang@freescale.com>

Hi Scott,

Could you apply these patches?

[v6,1/4] powerpc/fsl: add E6500 PVR and SPRN_PWRMGTCR0 define, http://patch=
work.ozlabs.org/patch/302045/
[v6,2/4] powerpc/85xx: add hardware automatically enter altivec idle state,=
 http://patchwork.ozlabs.org/patch/302046/
[v6,3/4] powerpc/85xx: add hardware automatically enter pw20 state, http://=
patchwork.ozlabs.org/patch/302047/
[v6,4/4] powerpc/85xx: add sysfs for pw20 state and altivec idle, http://pa=
tchwork.ozlabs.org/patch/302048/

-Dongsheng

> -----Original Message-----
> From: Dongsheng Wang [mailto:dongsheng.wang@freescale.com]
> Sent: Tuesday, December 17, 2013 4:17 PM
> To: Wood Scott-B07421; Bhushan Bharat-R65777
> Cc: linuxppc-dev@lists.ozlabs.org; Wang Dongsheng-B40534
> Subject: [PATCH v6 1/4] powerpc/fsl: add E6500 PVR and SPRN_PWRMGTCR0 def=
ine
>=20
> From: Wang Dongsheng <dongsheng.wang@freescale.com>
>=20
> E6500 PVR and SPRN_PWRMGTCR0 will be used in subsequent pw20/altivec
> idle patches.
>=20
> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
> ---
> *v3:
> Add bit definitions for PWRMGTCR0.
>=20
>  arch/powerpc/include/asm/reg.h       | 2 ++
>  arch/powerpc/include/asm/reg_booke.h | 9 +++++++++
>  2 files changed, 11 insertions(+)
>=20
> diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/re=
g.h
> index 64264bf..d4160ca 100644
> --- a/arch/powerpc/include/asm/reg.h
> +++ b/arch/powerpc/include/asm/reg.h
> @@ -1053,6 +1053,8 @@
>  #define PVR_8560	0x80200000
>  #define PVR_VER_E500V1	0x8020
>  #define PVR_VER_E500V2	0x8021
> +#define PVR_VER_E6500	0x8040
> +
>  /*
>   * For the 8xx processors, all of them report the same PVR family for
>   * the PowerPC core. The various versions of these processors must be
> diff --git a/arch/powerpc/include/asm/reg_booke.h
> b/arch/powerpc/include/asm/reg_booke.h
> index ed8f836..4a6457e 100644
> --- a/arch/powerpc/include/asm/reg_booke.h
> +++ b/arch/powerpc/include/asm/reg_booke.h
> @@ -170,6 +170,7 @@
>  #define SPRN_L2CSR1	0x3FA	/* L2 Data Cache Control and Status Register 1
> */
>  #define SPRN_DCCR	0x3FA	/* Data Cache Cacheability Register */
>  #define SPRN_ICCR	0x3FB	/* Instruction Cache Cacheability Register */
> +#define SPRN_PWRMGTCR0	0x3FB	/* Power management control register 0 */
>  #define SPRN_SVR	0x3FF	/* System Version Register */
>=20
>  /*
> @@ -216,6 +217,14 @@
>  #define	CCR1_DPC	0x00000100 /* Disable L1 I-Cache/D-Cache parity
> checking */
>  #define	CCR1_TCS	0x00000080 /* Timer Clock Select */
>=20
> +/* Bit definitions for PWRMGTCR0. */
> +#define PWRMGTCR0_PW20_WAIT		(1 << 14) /* PW20 state enable bit */
> +#define PWRMGTCR0_PW20_ENT_SHIFT	8
> +#define PWRMGTCR0_PW20_ENT		0x3F00
> +#define PWRMGTCR0_AV_IDLE_PD_EN		(1 << 22) /* Altivec idle enable */
> +#define PWRMGTCR0_AV_IDLE_CNT_SHIFT	16
> +#define PWRMGTCR0_AV_IDLE_CNT		0x3F0000
> +
>  /* Bit definitions for the MCSR. */
>  #define MCSR_MCS	0x80000000 /* Machine Check Summary */
>  #define MCSR_IB		0x40000000 /* Instruction PLB Error */
> --
> 1.8.0
>=20

^ permalink raw reply

* RE: [PATCH] powerpc/mpic_timer: fix the time calculation is not accurate
From: Dongsheng.Wang @ 2013-12-30  2:21 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev@lists.ozlabs.org
In-Reply-To: <1388188783.21454.27.camel@snotra.buserror.net>

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogV29vZCBTY290dC1CMDc0
MjENCj4gU2VudDogU2F0dXJkYXksIERlY2VtYmVyIDI4LCAyMDEzIDg6MDAgQU0NCj4gVG86IFdh
bmcgRG9uZ3NoZW5nLUI0MDUzNA0KPiBDYzogZ2FsYWtAa2VybmVsLmNyYXNoaW5nLm9yZzsgbGlu
dXhwcGMtZGV2QGxpc3RzLm96bGFicy5vcmcNCj4gU3ViamVjdDogUmU6IFtQQVRDSF0gcG93ZXJw
Yy9tcGljX3RpbWVyOiBmaXggdGhlIHRpbWUgY2FsY3VsYXRpb24gaXMgbm90DQo+IGFjY3VyYXRl
DQo+IA0KPiBPbiBNb24sIDIwMTMtMTItMjMgYXQgMTA6MzMgKzA4MDAsIERvbmdzaGVuZyBXYW5n
IHdyb3RlOg0KPiA+IEZyb206IFdhbmcgRG9uZ3NoZW5nIDxkb25nc2hlbmcud2FuZ0BmcmVlc2Nh
bGUuY29tPg0KPiA+DQo+ID4gV2hlbiB0aGUgdGltZXIgR1RDQ1IgdG9nZ2xlIGJpdCBpcyBpbnZl
cnRlZCwgd2UgY2FsY3VsYXRlZCB0aGUgcmVzdCBvZg0KPiA+IHRoZSB0aW1lIGlzIG5vdCBhY2N1
cmF0ZS4gU28gd2UgbmVlZCB0byBpZ25vcmUgdGhpcyBiaXQuDQo+ID4NCj4gPiBTaWduZWQtb2Zm
LWJ5OiBXYW5nIERvbmdzaGVuZyA8ZG9uZ3NoZW5nLndhbmdAZnJlZXNjYWxlLmNvbT4NCj4gPg0K
PiA+IGRpZmYgLS1naXQgYS9hcmNoL3Bvd2VycGMvc3lzZGV2L21waWNfdGltZXIuYw0KPiA+IGIv
YXJjaC9wb3dlcnBjL3N5c2Rldi9tcGljX3RpbWVyLmMNCj4gPiBpbmRleCAyMmQ3ZDU3Li4wZmI3
MGM5IDEwMDY0NA0KPiA+IC0tLSBhL2FyY2gvcG93ZXJwYy9zeXNkZXYvbXBpY190aW1lci5jDQo+
ID4gKysrIGIvYXJjaC9wb3dlcnBjL3N5c2Rldi9tcGljX3RpbWVyLmMNCj4gPiBAQCAtNDEsNiAr
NDEsNyBAQA0KPiA+ICAjZGVmaW5lIE1QSUNfVElNRVJfVENSX1JPVlJfT0ZGU0VUCTI0DQo+ID4N
Cj4gPiAgI2RlZmluZSBUSU1FUl9TVE9QCQkJMHg4MDAwMDAwMA0KPiA+ICsjZGVmaW5lIEdUQ0NS
X1RPRwkJCTB4ODAwMDAwMDANCj4gPiAgI2RlZmluZSBUSU1FUlNfUEVSX0dST1VQCQk0DQo+ID4g
ICNkZWZpbmUgTUFYX1RJQ0tTCQkJKH4wVSA+PiAxKQ0KPiA+ICAjZGVmaW5lIE1BWF9USUNLU19D
QVNDQURFCQkofjBVKQ0KPiA+IEBAIC05Niw4ICs5NywxNSBAQCBzdGF0aWMgdm9pZCBjb252ZXJ0
X3RpY2tzX3RvX3RpbWUoc3RydWN0IHRpbWVyX2dyb3VwX3ByaXYNCj4gKnByaXYsDQo+ID4gIAl0
aW1lLT50dl9zZWMgPSAoX19rZXJuZWxfdGltZV90KWRpdl91NjQodGlja3MsIHByaXYtPnRpbWVy
ZnJlcSk7DQo+ID4gIAl0bXBfc2VjID0gKHU2NCl0aW1lLT50dl9zZWMgKiAodTY0KXByaXYtPnRp
bWVyZnJlcTsNCj4gPg0KPiA+IC0JdGltZS0+dHZfdXNlYyA9IChfX2tlcm5lbF9zdXNlY29uZHNf
dCkNCj4gPiAtCQlkaXZfdTY0KCh0aWNrcyAtIHRtcF9zZWMpICogMTAwMDAwMCwgcHJpdi0+dGlt
ZXJmcmVxKTsNCj4gPiArCXRpbWUtPnR2X3VzZWMgPSAwOw0KPiA+ICsNCj4gPiArCS8qDQo+ID4g
KwkgKiBJbiBzb21lIGNhc2VzIHRtcF9zZWMgbWF5IGJlIGdyZWF0ZXIgdGhhbiB0aWNrcywgYmVj
YXVzZSBpbiB0aGUNCj4gPiArCSAqIHByb2Nlc3Mgb2YgY2FsY3VsYXRpb24gdGlja3MgYW5kIHRt
cF9zZWMgd2lsbCBiZSByb3VuZGVkLg0KPiA+ICsJICovDQo+ID4gKwlpZiAodG1wX3NlYyA8PSB0
aWNrcykNCj4gPiArCQl0aW1lLT50dl91c2VjID0gKF9fa2VybmVsX3N1c2Vjb25kc190KQ0KPiA+
ICsJCQlkaXZfdTY0KCh0aWNrcyAtIHRtcF9zZWMpICogMTAwMDAwMCwgcHJpdi0+dGltZXJmcmVx
KTsNCj4gDQo+IEkgZG9uJ3Qgc2VlIGhvdyB0aGlzIHBhcnQgb2YgdGhlIHBhdGNoIHJlbGF0ZXMg
dG8gdGhlIHBhdGNoIGRlc2NyaXB0aW9uLg0KPiANClRoYW5rcywgSSBtaXNzIHRoaXMgZGVzY3Jp
cHRpb24sIDooLg0KSSBzaG91bGQgc3BsaXQgdGhlIHBhdGNoLg0KDQotRG9uZ3NoZW5nDQoNCj4g
LVNjb3R0DQo+IA0KDQo=

^ permalink raw reply

* Re: [question] Can the execution of the atomtic operation instruction pair lwarx/stwcx be interrrupted by local HW interruptions?
From: wyang @ 2013-12-30  1:54 UTC (permalink / raw)
  To: Gavin Hu, Linuxppc-dev
In-Reply-To: <CABiPGEfmEFovARBy0rwjbDpBnVeRrmvQrxgnH+32z0RLUX3Nkw@mail.gmail.com>

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

On 12/28/2013 01:41 PM, Gavin Hu wrote:
> Hi
>
> I notice that there is a pair ppc instructions lwarx and stwcx used to 
> atomtic operation for instance, atomic_inc/atomic_dec.
>
> In some ppc manuals, they more emphasize its mechanism is that lwarx 
> can reseve the target memory address preventing other CORE from 
> modifying it.
>
> I assume that there is atomtic operation executing on the CORE0 in a 
> multicore system. In this situation, does the CORE0 disable the local 
> HW interrupt?
> Can the executing process from the beginning of lwarx and end of stwcx 
> be interrupted by HW interruptions/exceptions? Anyway, they are two 
> assembly instructions.

It should just like other arch, the processor should response any 
interrupt after the execution of a instruction, so the local HW 
interrupt is not disabled.

Thanks
Wei
>
>  Thanks a lot!
>
> "1:    lwarx    %0,0,%2        # atomic_inc\n\
>     addic    %0,%0,1\n"
> "    stwcx.    %0,0,%2 \n\
>
>
> BR
> Gavin. Hu
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev


[-- Attachment #2: Type: text/html, Size: 2655 bytes --]

^ permalink raw reply

* [PATCH 19/25]  fix error return code
From: Julia Lawall @ 2013-12-29 22:47 UTC (permalink / raw)
  To: Geoff Levand
  Cc: cbe-oss-dev, linux-scsi, kernel-janitors, linux-kernel,
	James E.J. Bottomley, linuxppc-dev
In-Reply-To: <1388357260-4843-1-git-send-email-Julia.Lawall@lip6.fr>

From: Julia Lawall <Julia.Lawall@lip6.fr>

Set the return variable to an error code as done elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}

// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
Not tested.

 drivers/scsi/ps3rom.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c
index e6e2a30..04d77ce 100644
--- a/drivers/scsi/ps3rom.c
+++ b/drivers/scsi/ps3rom.c
@@ -387,6 +387,7 @@ static int ps3rom_probe(struct ps3_system_bus_device *_dev)
 	if (!host) {
 		dev_err(&dev->sbd.core, "%s:%u: scsi_host_alloc failed\n",
 			__func__, __LINE__);
+		error = -ENOMEM;
 		goto fail_teardown;
 	}
 

^ 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