Re: [PATCH V2] cpuidle/governors: Fix logic in selection of idle states

2014-01-28 Thread Daniel Lezcano

On 01/24/2014 11:21 AM, Preeti U Murthy wrote:

On 01/24/2014 02:38 PM, Daniel Lezcano wrote:

On 01/23/2014 12:15 PM, Preeti U Murthy wrote:

Hi Daniel,

Thank you for the review.


[ ... ]


---
   drivers/cpuidle/cpuidle.c  |   15 +
   drivers/cpuidle/governors/ladder.c |  101
++--
   drivers/cpuidle/governors/menu.c   |7 +-
   3 files changed, 90 insertions(+), 33 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index a55e68f..19d17e8 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -131,8 +131,9 @@ int cpuidle_idle_call(void)

   /* ask the governor for the next state */
   next_state = cpuidle_curr_governor-select(drv, dev);
+
+dev-last_residency = 0;
   if (need_resched()) {


What about if (need_resched() || next_state  0) ?


Hmm.. I feel we need to distinguish between the need_resched() scenario
and the scenario when no idle state was suitable through the trace
points at-least.


Well, I don't think so as soon as we don't care about the return value 
of cpuidle_idle_call in both cases.


The traces are following a specific format. That is if the state is -1 
(PWR_EVENT_EXIT), it means exiting the current idle state.


The idlestat tool [1] is using this traces to open - close transitions.

IMO, if the cpu is not entering idle, it should just exit without any 
idle traces.


This portion of code is a bit confusing because it is introduced by the 
menu governor updates post-poned when entering the next idle state (not 
exiting the current idle state with good reasons).


  -- Daniel

[1] http://git.linaro.org/power/idlestat.git


This could help while debugging when we could find situations where
there are no tasks to run, yet the cpu is not entering any idle state.
The traces could help clearly point that no idle state was thought
suitable by the governor. Of course there are many other means to find
this out, but this seems rather straightforward. Hence having the
condition next_state  0 between trace_cpu_idle*() would be apt IMHO.

Regards
Preeti U Murthy




-dev-last_residency = 0;
   /* give the governor an opportunity to reflect on the
outcome */
   if (cpuidle_curr_governor-reflect)
   cpuidle_curr_governor-reflect(dev, next_state);
@@ -141,6 +142,16 @@ int cpuidle_idle_call(void)
   }

   trace_cpu_idle_rcuidle(next_state, dev-cpu);
+/*
+ * NOTE: The return code should still be success, since the
verdict of
+ * this call is do not enter any idle state. It is not a failed
call
+ * due to errors.
+ */
+if (next_state  0) {
+entered_state = next_state;
+local_irq_enable();
+goto out;
+}

   broadcast = !!(drv-states[next_state].flags 
CPUIDLE_FLAG_TIMER_STOP);

@@ -156,7 +167,7 @@ int cpuidle_idle_call(void)
   if (broadcast)
   clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, dev-cpu);

-trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev-cpu);
+out:trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev-cpu);

   /* give the governor an opportunity to reflect on the outcome */
   if (cpuidle_curr_governor-reflect)





--
 http://www.linaro.org/ Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  http://www.facebook.com/pages/Linaro Facebook |
http://twitter.com/#!/linaroorg Twitter |
http://www.linaro.org/linaro-blog/ Blog

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

Re: [git pull] Please pull powerpc.git next branch

2014-01-28 Thread Olaf Hering
On Tue, Jan 28, Benjamin Herrenschmidt wrote:

 So here's my next branch for powerpc. A bit late as I was on vacation

This breaks booting on G5 11,2, the nouveau driver prints errors and as
result the kernel hangs, fans kick in. This is what I did:

# Rebase 54c0a4b..b2e448e onto 54c0a4b

I will try to bisect it.

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


Re: [PATCH V2 0/2] time/cpuidle: Support in tick broadcast framework in absence of external clock device

2014-01-28 Thread Preeti U Murthy
Hi Thomas,

I realized that the below patch is also required for this patchset.

This patch apart, I noticed that there is also one corner case which we will
need to handle. The BROADCAST_ON notifications in periodic mode
(oneshot mode is a nop).
  We will need to fail the BROADCAST_ON notification too in this case if the
CPU in question is made the stand by CPU. 

Thanks

Regards
Preeti U Murthy

-

time/cpuidle:Handle failed call to BROADCAST_ENTER on archs with 
CPUIDLE_FLAG_TIMER_STOP set

From: Preeti U Murthy pre...@linux.vnet.ibm.com

Some archs set the CPUIDLE_FLAG_TIMER_STOP flag for idle states in which the
local timers stop. The cpuidle_idle_call() currently handles such idle states
by calling into the broadcast framework so as to wakeup CPUs at their next
wakeup event. With the hrtimer mode of broadcast, the BROADCAST_ENTER call
into the broadcast frameowork can fail for archs that do not have an external
clock device to handle wakeups and the CPU in question has to thus be made
the stand by CPU. This patch handles such cases by failing the call into
cpuidle so that the arch can take some default action. The arch will certainly
not enter a similar idle state because a failed cpuidle call will also 
implicitly
indicate that the broadcast framework has not registered this CPU to be woken 
up.
Hence we are safe if we fail the cpuidle call.

In the process move the functions that trace idle statistics just before and
after the entry and exit into idle states respectively. In other
scenarios where the call to cpuidle fails, we end up not tracing idle
entry and exit since a decision on an idle state could not be taken. Similarly
when the call to broadcast framework fails, we skip tracing idle statistics
because we are in no further position to take a decision on an alternative
idle state to enter into.

Signed-off-by: Preeti U Murthy pre...@linux.vnet.ibm.com
---
 drivers/cpuidle/cpuidle.c |   38 +++---
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index a55e68f..8f42033 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -117,15 +117,19 @@ int cpuidle_idle_call(void)
 {
struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
struct cpuidle_driver *drv;
-   int next_state, entered_state;
-   bool broadcast;
+   int next_state, entered_state, ret = 0;
+   bool broadcast = false;
 
-   if (off || !initialized)
-   return -ENODEV;
+   if (off || !initialized) {
+   ret = -ENODEV;
+   goto out;
+   }
 
/* check if the device is ready */
-   if (!dev || !dev-enabled)
-   return -EBUSY;
+   if (!dev || !dev-enabled) {
+   ret = -EBUSY;
+   goto out;
+   }
 
drv = cpuidle_get_cpu_driver(dev);
 
@@ -137,15 +141,18 @@ int cpuidle_idle_call(void)
if (cpuidle_curr_governor-reflect)
cpuidle_curr_governor-reflect(dev, next_state);
local_irq_enable();
-   return 0;
+   goto out;
}
 
-   trace_cpu_idle_rcuidle(next_state, dev-cpu);
-
broadcast = !!(drv-states[next_state].flags  CPUIDLE_FLAG_TIMER_STOP);
 
-   if (broadcast)
-   clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, dev-cpu);
+   if (broadcast) {
+   ret = clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, 
dev-cpu);
+   if (ret)
+   goto out;
+   }
+
+   trace_cpu_idle_rcuidle(next_state, dev-cpu);
 
if (cpuidle_state_is_coupled(dev, drv, next_state))
entered_state = cpuidle_enter_state_coupled(dev, drv,
@@ -153,16 +160,17 @@ int cpuidle_idle_call(void)
else
entered_state = cpuidle_enter_state(dev, drv, next_state);
 
-   if (broadcast)
-   clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, dev-cpu);
-
trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev-cpu);
 
/* give the governor an opportunity to reflect on the outcome */
if (cpuidle_curr_governor-reflect)
cpuidle_curr_governor-reflect(dev, entered_state);
 
-   return 0;
+out:   if (broadcast)
+   clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, dev-cpu);
+
+
+   return ret;
 }
 
 /**

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


[PATCH] powerpc: thp: Fix crash on mremap

2014-01-28 Thread Aneesh Kumar K.V
This patch fix the below crash

NIP [c004cee4] .__hash_page_thp+0x2a4/0x440
LR [c00439ac] .hash_page+0x18c/0x5e0
...
Call Trace:
[c00736103c40] [1b00] 0x1b00(unreliable)
[437908.479693] [c00736103d50] [c00439ac] .hash_page+0x18c/0x5e0
[437908.479699] [c00736103e30] [c000924c] .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.

variant of upstream SHA1: b3084f4db3aeb991c507ca774337c7e7893ed04f
for 3.11 stable series

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/Kconfig   |  3 +++
 arch/powerpc/platforms/Kconfig.cputype |  1 +
 mm/huge_memory.c   | 12 
 3 files changed, 16 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 1feb169274fe..c5863b35d054 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -368,6 +368,9 @@ config HAVE_ARCH_TRANSPARENT_HUGEPAGE
 config HAVE_ARCH_SOFT_DIRTY
bool
 
+config ARCH_THP_MOVE_PMD_ALWAYS_WITHDRAW
+   bool
+
 config HAVE_MOD_ARCH_SPECIFIC
bool
help
diff --git a/arch/powerpc/platforms/Kconfig.cputype 
b/arch/powerpc/platforms/Kconfig.cputype
index 47d9a03dd415..d11a34be018d 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -71,6 +71,7 @@ config PPC_BOOK3S_64
select PPC_FPU
select PPC_HAVE_PMU_SUPPORT
select SYS_SUPPORTS_HUGETLBFS
+   select ARCH_THP_MOVE_PMD_ALWAYS_WITHDRAW
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if PPC_64K_PAGES
 
 config PPC_BOOK3E_64
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 12acb0ba7991..beaa7cc9de75 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1461,8 +1461,20 @@ int move_huge_pmd(struct vm_area_struct *vma, struct 
vm_area_struct *new_vma,
 
ret = __pmd_trans_huge_lock(old_pmd, vma);
if (ret == 1) {
+#ifdef CONFIG_ARCH_THP_MOVE_PMD_ALWAYS_WITHDRAW
+   pgtable_t pgtable;
+#endif
pmd = pmdp_get_and_clear(mm, old_addr, old_pmd);
VM_BUG_ON(!pmd_none(*new_pmd));
+#ifdef CONFIG_ARCH_THP_MOVE_PMD_ALWAYS_WITHDRAW
+   /*
+* 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);
+#endif
set_pmd_at(mm, new_addr, new_pmd, pmd_mksoft_dirty(pmd));
spin_unlock(mm-page_table_lock);
}
-- 
1.8.5.3

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


[PATCH] powerpc: thp: Fix crash on mremap

2014-01-28 Thread Aneesh Kumar K.V
This patch fix the below crash

NIP [c004cee4] .__hash_page_thp+0x2a4/0x440
LR [c00439ac] .hash_page+0x18c/0x5e0
...
Call Trace:
[c00736103c40] [1b00] 0x1b00(unreliable)
[437908.479693] [c00736103d50] [c00439ac] .hash_page+0x18c/0x5e0
[437908.479699] [c00736103e30] [c000924c] .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.

variant of upstream SHA1: b3084f4db3aeb991c507ca774337c7e7893ed04f
for 3.12 stable series

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/Kconfig   |  3 +++
 arch/powerpc/platforms/Kconfig.cputype |  1 +
 mm/huge_memory.c   | 12 
 3 files changed, 16 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index af2cc6eabcc7..bca9e7a18bd2 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -365,6 +365,9 @@ config HAVE_ARCH_TRANSPARENT_HUGEPAGE
 config HAVE_ARCH_SOFT_DIRTY
bool
 
+config ARCH_THP_MOVE_PMD_ALWAYS_WITHDRAW
+   bool
+
 config HAVE_MOD_ARCH_SPECIFIC
bool
help
diff --git a/arch/powerpc/platforms/Kconfig.cputype 
b/arch/powerpc/platforms/Kconfig.cputype
index 6704e2e20e6b..0225011231ea 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -71,6 +71,7 @@ config PPC_BOOK3S_64
select PPC_FPU
select PPC_HAVE_PMU_SUPPORT
select SYS_SUPPORTS_HUGETLBFS
+   select ARCH_THP_MOVE_PMD_ALWAYS_WITHDRAW
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if PPC_64K_PAGES
 
 config PPC_BOOK3E_64
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 292a266e0d42..89b7a647f1cb 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1474,8 +1474,20 @@ int move_huge_pmd(struct vm_area_struct *vma, struct 
vm_area_struct *new_vma,
 
ret = __pmd_trans_huge_lock(old_pmd, vma);
if (ret == 1) {
+#ifdef CONFIG_ARCH_THP_MOVE_PMD_ALWAYS_WITHDRAW
+   pgtable_t pgtable;
+#endif
pmd = pmdp_get_and_clear(mm, old_addr, old_pmd);
VM_BUG_ON(!pmd_none(*new_pmd));
+#ifdef CONFIG_ARCH_THP_MOVE_PMD_ALWAYS_WITHDRAW
+   /*
+* 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);
+#endif
set_pmd_at(mm, new_addr, new_pmd, pmd_mksoft_dirty(pmd));
spin_unlock(mm-page_table_lock);
}
-- 
1.8.5.3

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


[PATCH 2/2] Fix compile error of pgtable-ppc64.h

2014-01-28 Thread Aneesh Kumar K.V
From: Li Zhong zh...@linux.vnet.ibm.com

It seems that forward declaration couldn't work well with typedef, use
struct spinlock directly to avoiding following build errors:

In file included from include/linux/spinlock.h:81,
 from include/linux/seqlock.h:35,
 from include/linux/time.h:5,
 from include/uapi/linux/timex.h:56,
 from include/linux/timex.h:56,
 from include/linux/sched.h:17,
 from arch/powerpc/kernel/asm-offsets.c:17:
include/linux/spinlock_types.h:76: error: redefinition of typedef 'spinlock_t'
/root/linux-next/arch/powerpc/include/asm/pgtable-ppc64.h:563: note: previous 
declaration of 'spinlock_t' was here

build fix for upstream SHA1: b3084f4db3aeb991c507ca774337c7e7893ed04f
for 3.13 stable series

Signed-off-by: Li Zhong zh...@linux.vnet.ibm.com
Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/pgtable-ppc64.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h 
b/arch/powerpc/include/asm/pgtable-ppc64.h
index d27960c89a71..bc141c950b1e 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -560,9 +560,9 @@ extern void pmdp_invalidate(struct vm_area_struct *vma, 
unsigned long address,
pmd_t *pmdp);
 
 #define pmd_move_must_withdraw pmd_move_must_withdraw
-typedef struct spinlock spinlock_t;
-static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
-spinlock_t *old_pmd_ptl)
+struct spinlock;
+static inline int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl,
+struct spinlock *old_pmd_ptl)
 {
/*
 * Archs like ppc64 use pgtable to store per pmd
-- 
1.8.5.3

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


[PATCH 1/2] powerpc/thp: Fix crash on mremap

2014-01-28 Thread Aneesh Kumar K.V
This patch fix the below crash

NIP [c004cee4] .__hash_page_thp+0x2a4/0x440
LR [c00439ac] .hash_page+0x18c/0x5e0
...
Call Trace:
[c00736103c40] [1b00] 0x1b00(unreliable)
[437908.479693] [c00736103d50] [c00439ac] .hash_page+0x18c/0x5e0
[437908.479699] [c00736103e30] [c000924c] .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.

upstream SHA1: b3084f4db3aeb991c507ca774337c7e7893ed04f
for 3.13 stable series

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
Acked-by: Kirill A. Shutemov kirill.shute...@linux.intel.com
Signed-off-by: Benjamin Herrenschmidt b...@kernel.crashing.org
---
 arch/powerpc/include/asm/pgtable-ppc64.h | 14 ++
 include/asm-generic/pgtable.h| 12 
 mm/huge_memory.c | 14 +-
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h 
b/arch/powerpc/include/asm/pgtable-ppc64.h
index 4a191c472867..d27960c89a71 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -558,5 +558,19 @@ extern pgtable_t pgtable_trans_huge_withdraw(struct 
mm_struct *mm, pmd_t *pmdp);
 #define __HAVE_ARCH_PMDP_INVALIDATE
 extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
pmd_t *pmdp);
+
+#define pmd_move_must_withdraw pmd_move_must_withdraw
+typedef struct spinlock spinlock_t;
+static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
+spinlock_t *old_pmd_ptl)
+{
+   /*
+* 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
+*/
+   return true;
+}
+
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_POWERPC_PGTABLE_PPC64_H_ */
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index db0923458940..8e4f41d9af4d 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -558,6 +558,18 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp)
 }
 #endif
 
+#ifndef pmd_move_must_withdraw
+static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
+spinlock_t *old_pmd_ptl)
+{
+   /*
+* With split pmd lock we also need to move preallocated
+* PTE page table if new_pmd is on different PMD page table.
+*/
+   return new_pmd_ptl != old_pmd_ptl;
+}
+#endif
+
 /*
  * This function is meant to be used by sites walking pagetables with
  * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 95d1acb0f3d2..5d80c53b87cb 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1502,19 +1502,15 @@ int move_huge_pmd(struct vm_area_struct *vma, struct 
vm_area_struct *new_vma,
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));
-   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.
-*/
+   if (pmd_move_must_withdraw(new_ptl, old_ptl)) {
+   pgtable_t pgtable;
pgtable = pgtable_trans_huge_withdraw(mm, old_pmd);
pgtable_trans_huge_deposit(mm, new_pmd, pgtable);
-
-   spin_unlock(new_ptl);
}
+   set_pmd_at(mm, new_addr, new_pmd, pmd_mksoft_dirty(pmd));
+   if (new_ptl != old_ptl)
+   spin_unlock(new_ptl);
spin_unlock(old_ptl);
}
 out:
-- 
1.8.5.3

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


[PATCH] powerpc: don't re-issue spinlock typedef that breaks older gcc

2014-01-28 Thread Paul Gortmaker
Commit b3084f4db3aeb991c507ca774337c7e7893ed04f (powerpc/thp: Fix
crash on mremap) added a typedef struct spinlock spinlock_t;
which on gcc 4.5.2 (and possibly other versions) causes many of:

include/linux/spinlock_types.h:76:3: error: redefinition of typedef 'spinlock_t'
arch/powerpc/include/asm/pgtable-ppc64.h:563:25: note: previous declaration of 
'spinlock_t' was here
In file included from include/linux/mutex.h:15:0,
 from include/linux/notifier.h:13,
 from include/linux/pm_qos.h:8,
 from include/linux/netdevice.h:28,
 from drivers/net/wireless/ath/wil6210/wil6210.h:20,
 from drivers/net/wireless/ath/wil6210/debug.c:17:

It appears that somewhere between gcc 4.5.2 and 4.6.3 this
redefinition restriction was lifted.  Using the proper header
from within !ASSEMBLY seems to fix it up in an acceptable way.

Cc: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
Cc: Kirill A. Shutemov kirill.shute...@linux.intel.com
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Signed-off-by: Paul Gortmaker paul.gortma...@windriver.com
---

[ Note that b3084f4db3 isn't mainline yet, it is currently in
  benh/powerpc.git #merge -- but is headed there soon via:
 https://lkml.org/lkml/2014/1/27/599   ]

 arch/powerpc/include/asm/pgtable-ppc64.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h 
b/arch/powerpc/include/asm/pgtable-ppc64.h
index d27960c89a71..3b638411646a 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -111,6 +111,8 @@
 
 #ifndef __ASSEMBLY__
 
+#include linux/spinlock_types.h
+
 /*
  * This is the default implementation of various PTE accessors, it's
  * used in all cases except Book3S with 64K pages where we have a
@@ -560,7 +562,6 @@ extern void pmdp_invalidate(struct vm_area_struct *vma, 
unsigned long address,
pmd_t *pmdp);
 
 #define pmd_move_must_withdraw pmd_move_must_withdraw
-typedef struct spinlock spinlock_t;
 static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
 spinlock_t *old_pmd_ptl)
 {
-- 
1.8.5.2

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


[RFC PATCH 01/10] KVM: PPC: BOOK3S: PR: Add POWER8 support

2014-01-28 Thread Aneesh Kumar K.V
Hello,

This patch series implements PR KVM support for POWER8 platform

-aneesh

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


[RFC PATCH 01/10] KVM: PPC: BOOK3S: PR: Fix PURR and SPURR emulation

2014-01-28 Thread Aneesh Kumar K.V
We definitely don't need to emulate mtspr, because both the registers
are hypervisor resource.

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/kvm_book3s.h |  2 --
 arch/powerpc/include/asm/kvm_host.h   |  4 ++--
 arch/powerpc/kvm/book3s_emulate.c | 16 
 arch/powerpc/kvm/book3s_pr.c  | 10 ++
 4 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_book3s.h 
b/arch/powerpc/include/asm/kvm_book3s.h
index bc23b1ba7980..396448afa38b 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -83,8 +83,6 @@ struct kvmppc_vcpu_book3s {
u64 sdr1;
u64 hior;
u64 msr_mask;
-   u64 purr_offset;
-   u64 spurr_offset;
 #ifdef CONFIG_PPC_BOOK3S_32
u32 vsid_pool[VSID_POOL_SIZE];
u32 vsid_next;
diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
index 9a0cdb2c9d58..0a3785271f34 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -506,8 +506,8 @@ struct kvm_vcpu_arch {
 #ifdef CONFIG_BOOKE
u32 decar;
 #endif
-   u32 tbl;
-   u32 tbu;
+   /* Time base value when we entered the guest */
+   u64 entry_tb;
u32 tcr;
ulong tsr; /* we need to perform set/clr_bits() which requires ulong */
u32 ivor[64];
diff --git a/arch/powerpc/kvm/book3s_emulate.c 
b/arch/powerpc/kvm/book3s_emulate.c
index a7d54aa203d0..e1f1e5e16449 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -422,12 +422,6 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, 
int sprn, ulong spr_val)
(mfmsr()  MSR_HV))
vcpu-arch.hflags |= BOOK3S_HFLAG_DCBZ32;
break;
-   case SPRN_PURR:
-   to_book3s(vcpu)-purr_offset = spr_val - get_tb();
-   break;
-   case SPRN_SPURR:
-   to_book3s(vcpu)-spurr_offset = spr_val - get_tb();
-   break;
case SPRN_GQR0:
case SPRN_GQR1:
case SPRN_GQR2:
@@ -523,10 +517,16 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, 
int sprn, ulong *spr_val
*spr_val = 0;
break;
case SPRN_PURR:
-   *spr_val = get_tb() + to_book3s(vcpu)-purr_offset;
+   /*
+* On exit we would have updated purr
+*/
+   *spr_val = vcpu-arch.purr;
break;
case SPRN_SPURR:
-   *spr_val = get_tb() + to_book3s(vcpu)-purr_offset;
+   /*
+* On exit we would have updated spurr
+*/
+   *spr_val = vcpu-arch.spurr;
break;
case SPRN_GQR0:
case SPRN_GQR1:
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index fdcbabdfb709..02231f5193c2 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -115,6 +115,11 @@ void kvmppc_copy_to_svcpu(struct kvmppc_book3s_shadow_vcpu 
*svcpu,
svcpu-lr  = vcpu-arch.lr;
svcpu-pc  = vcpu-arch.pc;
svcpu-in_use = true;
+   /*
+* Now also save the current time base value. We use this
+* to find the guest purr and spurr value.
+*/
+   vcpu-arch.entry_tb = get_tb();
 }
 
 /* Copy data touched by real-mode code from shadow vcpu back to vcpu */
@@ -161,6 +166,11 @@ void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu,
 
 out:
preempt_enable();
+   /*
+* Update purr and spurr using time base
+*/
+   vcpu-arch.purr += get_tb() - vcpu-arch.entry_tb;
+   vcpu-arch.spurr += get_tb() - vcpu-arch.entry_tb;
 }
 
 static int kvmppc_core_check_requests_pr(struct kvm_vcpu *vcpu)
-- 
1.8.5.3

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


[RFC PATCH 02/10] KVM: PPC: BOOK3S: PR: Emulate virtual timebase register

2014-01-28 Thread Aneesh Kumar K.V
virtual time base register is a per vm register and need to saved
and restored on vm exit and entry. Writing to VTB is not allowed
in the privileged mode.

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/kvm_host.h |  1 +
 arch/powerpc/include/asm/reg.h  |  7 +++
 arch/powerpc/include/asm/time.h | 12 
 arch/powerpc/kvm/book3s_emulate.c   |  3 +++
 arch/powerpc/kvm/book3s_pr.c|  3 +++
 5 files changed, 26 insertions(+)

diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
index 0a3785271f34..9ebdd12e50a9 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -508,6 +508,7 @@ struct kvm_vcpu_arch {
 #endif
/* Time base value when we entered the guest */
u64 entry_tb;
+   u64 entry_vtb;
u32 tcr;
ulong tsr; /* we need to perform set/clr_bits() which requires ulong */
u32 ivor[64];
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index e789f76c9bc2..6c649355b1e9 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1161,6 +1161,13 @@
 #define mtspr(rn, v)   asm volatile(mtspr  __stringify(rn) ,%0 : \
 : r ((unsigned long)(v)) \
 : memory)
+#ifdef CONFIG_PPC_BOOK3S_64
+#define mfvtb()({unsigned long rval;   
\
+   asm volatile(mfspr %0, %1 :   \
+=r (rval) : i (SPRN_VTB)); rval;})
+#else
+#define mfvtb() BUG()
+#endif
 
 #ifdef __powerpc64__
 #if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E)
diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h
index c1f267694acb..1e89dbc665d9 100644
--- a/arch/powerpc/include/asm/time.h
+++ b/arch/powerpc/include/asm/time.h
@@ -101,6 +101,18 @@ static inline u64 get_rtc(void)
return (u64)hi * 10 + lo;
 }
 
+#ifdef CONFIG_PPC_BOOK3S_64
+static inline u64 get_vtb(void)
+{
+   return mfvtb();
+}
+#else
+static inline u64 get_vtb(void)
+{
+   return 0;
+}
+#endif
+
 #ifdef CONFIG_PPC64
 static inline u64 get_tb(void)
 {
diff --git a/arch/powerpc/kvm/book3s_emulate.c 
b/arch/powerpc/kvm/book3s_emulate.c
index e1f1e5e16449..4b58d8a90cb5 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -528,6 +528,9 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int 
sprn, ulong *spr_val
 */
*spr_val = vcpu-arch.spurr;
break;
+   case SPRN_VTB:
+   *spr_val = vcpu-arch.vtb;
+   break;
case SPRN_GQR0:
case SPRN_GQR1:
case SPRN_GQR2:
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 02231f5193c2..b5598e9cdd09 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -120,6 +120,8 @@ void kvmppc_copy_to_svcpu(struct kvmppc_book3s_shadow_vcpu 
*svcpu,
 * to find the guest purr and spurr value.
 */
vcpu-arch.entry_tb = get_tb();
+   vcpu-arch.entry_vtb = get_vtb();
+
 }
 
 /* Copy data touched by real-mode code from shadow vcpu back to vcpu */
@@ -171,6 +173,7 @@ out:
 */
vcpu-arch.purr += get_tb() - vcpu-arch.entry_tb;
vcpu-arch.spurr += get_tb() - vcpu-arch.entry_tb;
+   vcpu-arch.vtb += get_vtb() - vcpu-arch.entry_vtb;
 }
 
 static int kvmppc_core_check_requests_pr(struct kvm_vcpu *vcpu)
-- 
1.8.5.3

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


[RFC PATCH 04/10] KVM: PPC: BOOK3S: PR: Emulate Thread identification register

2014-01-28 Thread Aneesh Kumar K.V
Since PR KVM doesn't support SMT yet, we always return 0.

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

diff --git a/arch/powerpc/kvm/book3s_emulate.c 
b/arch/powerpc/kvm/book3s_emulate.c
index abe6f3057e5b..e74dda36ebea 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -561,6 +561,12 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, 
int sprn, ulong *spr_val
case SPRN_DABR:
*spr_val = 0;
break;
+   case SPRN_TIR:
+   /*
+* We don't have SMT support for PR yet, hence always return 0
+*/
+   *spr_val = 0;
+   break;
default:
 unprivileged:
printk(KERN_INFO KVM: invalid SPR read: %d\n, sprn);
-- 
1.8.5.3

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


[RFC PATCH 05/10] KVM: PPC: BOOK3S: PR: Doorbell support

2014-01-28 Thread Aneesh Kumar K.V
We don't have SMT support yet, hence we should not find a doorbell
message generated

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

diff --git a/arch/powerpc/kvm/book3s_emulate.c 
b/arch/powerpc/kvm/book3s_emulate.c
index e74dda36ebea..9cf0392e3dcf 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -28,7 +28,9 @@
 #define OP_19_XOP_RFI  50
 
 #define OP_31_XOP_MFMSR83
+#define OP_31_XOP_MSGSNDP  142
 #define OP_31_XOP_MTMSR146
+#define OP_31_XOP_MSGCLRP  174
 #define OP_31_XOP_MTMSRD   178
 #define OP_31_XOP_MTSR 210
 #define OP_31_XOP_MTSRIN   242
@@ -286,6 +288,22 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct 
kvm_vcpu *vcpu,
 
break;
}
+   case OP_31_XOP_MSGSNDP:
+   {
+   /*
+* PR KVM still don't support SMT mode. So we should
+* not see a MSGSNDP/MSGCLRP used with PR KVM
+*/
+   pr_info(KVM: MSGSNDP used in non SMT case\n);
+   emulated = EMULATE_FAIL;
+   break;
+   }
+   case OP_31_XOP_MSGCLRP:
+   {
+   pr_infoKVM: MSGCLRP used in non SMT case\n);
+   emulated = EMULATE_FAIL;
+   break;
+   }
default:
emulated = EMULATE_FAIL;
}
-- 
1.8.5.3

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


[RFC PATCH 06/10] KVM: PPC: BOOK3S: PR: Emulate DPDES register

2014-01-28 Thread Aneesh Kumar K.V
Since we don't support SMT yet, we should always find zero in
Directed privileged doorbell exception state register.

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

diff --git a/arch/powerpc/kvm/book3s_emulate.c 
b/arch/powerpc/kvm/book3s_emulate.c
index 9cf0392e3dcf..7f25adbd2590 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -585,6 +585,12 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, 
int sprn, ulong *spr_val
 */
*spr_val = 0;
break;
+   case SPRN_DPDES:
+   /*
+* We don't have SMT support for PR yet, hence always return 0
+*/
+   *spr_val = 0;
+   break;
default:
 unprivileged:
printk(KERN_INFO KVM: invalid SPR read: %d\n, sprn);
-- 
1.8.5.3

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


[RFC PATCH 08/10] KVM: PPC: BOOK3S: PR: Add support for facility unavailable interrupt

2014-01-28 Thread Aneesh Kumar K.V
At this point we allow all the supported facilities except EBB. So
forward the interrupt to guest as illegal instruction.

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/kvm_asm.h |  4 +++-
 arch/powerpc/kvm/book3s.c  |  4 
 arch/powerpc/kvm/book3s_emulate.c  | 18 ++
 arch/powerpc/kvm/book3s_pr.c   | 17 +
 4 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/kvm_asm.h 
b/arch/powerpc/include/asm/kvm_asm.h
index 1bd92fd43cfb..799244face51 100644
--- a/arch/powerpc/include/asm/kvm_asm.h
+++ b/arch/powerpc/include/asm/kvm_asm.h
@@ -99,6 +99,7 @@
 #define BOOK3S_INTERRUPT_PERFMON   0xf00
 #define BOOK3S_INTERRUPT_ALTIVEC   0xf20
 #define BOOK3S_INTERRUPT_VSX   0xf40
+#define BOOK3S_INTERRUPT_FAC_UNAVAIL0xf60
 
 #define BOOK3S_IRQPRIO_SYSTEM_RESET0
 #define BOOK3S_IRQPRIO_DATA_SEGMENT1
@@ -117,7 +118,8 @@
 #define BOOK3S_IRQPRIO_DECREMENTER 14
 #define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 15
 #define BOOK3S_IRQPRIO_EXTERNAL_LEVEL  16
-#define BOOK3S_IRQPRIO_MAX 17
+#define BOOK3S_IRQPRIO_FAC_UNAVAIL 17
+#define BOOK3S_IRQPRIO_MAX 18
 
 #define BOOK3S_HFLAG_DCBZ320x1
 #define BOOK3S_HFLAG_SLB   0x2
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index 8912608b7e1b..a9aea28c2677 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -143,6 +143,7 @@ static int kvmppc_book3s_vec2irqprio(unsigned int vec)
case 0xd00: prio = BOOK3S_IRQPRIO_DEBUG;break;
case 0xf20: prio = BOOK3S_IRQPRIO_ALTIVEC;  break;
case 0xf40: prio = BOOK3S_IRQPRIO_VSX;  break;
+   case 0xf60: prio = BOOK3S_IRQPRIO_FAC_UNAVAIL;  break;
default:prio = BOOK3S_IRQPRIO_MAX;  break;
}
 
@@ -273,6 +274,9 @@ int kvmppc_book3s_irqprio_deliver(struct kvm_vcpu *vcpu, 
unsigned int priority)
case BOOK3S_IRQPRIO_PERFORMANCE_MONITOR:
vec = BOOK3S_INTERRUPT_PERFMON;
break;
+   case BOOK3S_IRQPRIO_FAC_UNAVAIL:
+   vec = BOOK3S_INTERRUPT_FAC_UNAVAIL;
+   break;
default:
deliver = 0;
printk(KERN_ERR KVM: Unknown interrupt: 0x%x\n, priority);
diff --git a/arch/powerpc/kvm/book3s_emulate.c 
b/arch/powerpc/kvm/book3s_emulate.c
index 60d0b6b745e7..bf6b11021250 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -481,6 +481,15 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, 
int sprn, ulong spr_val)
vcpu-arch.shadow_fscr = vcpu-arch.fscr  host_fscr;
break;
}
+   case SPRN_EBBHR:
+   vcpu-arch.ebbhr = spr_val;
+   break;
+   case SPRN_EBBRR:
+   vcpu-arch.ebbrr = spr_val;
+   break;
+   case SPRN_BESCR:
+   vcpu-arch.bescr = spr_val;
+   break;
 unprivileged:
default:
printk(KERN_INFO KVM: invalid SPR write: %d\n, sprn);
@@ -607,6 +616,15 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, 
int sprn, ulong *spr_val
case SPRN_FSCR:
*spr_val = vcpu-arch.fscr;
break;
+   case SPRN_EBBHR:
+   *spr_val = vcpu-arch.ebbhr;
+   break;
+   case SPRN_EBBRR:
+   *spr_val = vcpu-arch.ebbrr;
+   break;
+   case SPRN_BESCR:
+   *spr_val = vcpu-arch.bescr;
+   break;
default:
 unprivileged:
printk(KERN_INFO KVM: invalid SPR read: %d\n, sprn);
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 51d469f8c9fd..828056ec208f 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -900,6 +900,23 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct 
kvm_vcpu *vcpu,
case BOOK3S_INTERRUPT_PERFMON:
r = RESUME_GUEST;
break;
+   case BOOK3S_INTERRUPT_FAC_UNAVAIL:
+   {
+   /*
+* Check for the facility that need to be emulated
+*/
+   ulong fscr_ic = vcpu-arch.shadow_fscr  56;
+   if (fscr_ic != FSCR_EBB_LG) {
+   /*
+* We only disable EBB facility.
+* So only emulate that.
+*/
+   kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
+   r = RESUME_GUEST;
+   break;
+   }
+   /* Fall through */
+   }
case BOOK3S_INTERRUPT_PROGRAM:
case BOOK3S_INTERRUPT_H_EMUL_ASSIST:
{
-- 
1.8.5.3

___
Linuxppc-dev mailing 

[RFC PATCH 07/10] KVM: PPC: BOOK3S: PR: Emulate facility status and control register

2014-01-28 Thread Aneesh Kumar K.V
We allow priv-mode update of this. The guest value is saved in fscr,
and the value actually used is saved in shadow_fscr. shadow_fscr
only contains values that are allowed by the host. On
facility unavailable interrupt, if the facility is allowed by fscr
but disabled in shadow_fscr we need to emulate the support. Currently
all but EBB is disabled. We still don't support performance monitoring
in PR guest.

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/kvm_book3s_asm.h |  1 +
 arch/powerpc/include/asm/kvm_host.h   |  1 +
 arch/powerpc/kernel/asm-offsets.c |  2 ++
 arch/powerpc/kvm/book3s_emulate.c | 16 
 arch/powerpc/kvm/book3s_interrupts.S  | 25 ++---
 5 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h 
b/arch/powerpc/include/asm/kvm_book3s_asm.h
index 192917d2239c..abd42523ad93 100644
--- a/arch/powerpc/include/asm/kvm_book3s_asm.h
+++ b/arch/powerpc/include/asm/kvm_book3s_asm.h
@@ -103,6 +103,7 @@ struct kvmppc_host_state {
 #ifdef CONFIG_PPC_BOOK3S_64
u64 cfar;
u64 ppr;
+   u64 host_fscr;
 #endif
 };
 
diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
index e0b13aca98e6..f4be7be14330 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -478,6 +478,7 @@ struct kvm_vcpu_arch {
ulong ppr;
ulong pspb;
ulong fscr;
+   ulong shadow_fscr;
ulong tfhar;
ulong tfiar;
ulong texasr;
diff --git a/arch/powerpc/kernel/asm-offsets.c 
b/arch/powerpc/kernel/asm-offsets.c
index 2c2227da6917..7484676b8f25 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -525,6 +525,7 @@ int main(void)
DEFINE(VCPU_CFAR, offsetof(struct kvm_vcpu, arch.cfar));
DEFINE(VCPU_PPR, offsetof(struct kvm_vcpu, arch.ppr));
DEFINE(VCPU_FSCR, offsetof(struct kvm_vcpu, arch.fscr));
+   DEFINE(VCPU_SHADOW_FSCR, offsetof(struct kvm_vcpu, arch.shadow_fscr));
DEFINE(VCPU_PSPB, offsetof(struct kvm_vcpu, arch.pspb));
DEFINE(VCPU_TFHAR, offsetof(struct kvm_vcpu, arch.tfhar));
DEFINE(VCPU_TFIAR, offsetof(struct kvm_vcpu, arch.tfiar));
@@ -626,6 +627,7 @@ int main(void)
 #ifdef CONFIG_PPC_BOOK3S_64
HSTATE_FIELD(HSTATE_CFAR, cfar);
HSTATE_FIELD(HSTATE_PPR, ppr);
+   HSTATE_FIELD(HSTATE_FSCR, host_fscr);
 #endif /* CONFIG_PPC_BOOK3S_64 */
 
 #else /* CONFIG_PPC_BOOK3S */
diff --git a/arch/powerpc/kvm/book3s_emulate.c 
b/arch/powerpc/kvm/book3s_emulate.c
index 7f25adbd2590..60d0b6b745e7 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -468,6 +468,19 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, 
int sprn, ulong spr_val)
case SPRN_MSSSR0:
case SPRN_DABR:
break;
+   case SPRN_FSCR:
+   {
+   ulong host_fscr = mfspr(SPRN_FSCR);
+   /*
+* We disable FSCR_EBB for pr guest. TAR and DSCR are always
+* enabled.
+*/
+   if (spr_val  ~(FSCR_TAR|FSCR_DSCR|FSCR_EBB))
+   pr_info(KVM: invalud FSCR value 0x%lx, spr_val);
+   vcpu-arch.fscr = spr_val  (FSCR_TAR|FSCR_DSCR);
+   vcpu-arch.shadow_fscr = vcpu-arch.fscr  host_fscr;
+   break;
+   }
 unprivileged:
default:
printk(KERN_INFO KVM: invalid SPR write: %d\n, sprn);
@@ -591,6 +604,9 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int 
sprn, ulong *spr_val
 */
*spr_val = 0;
break;
+   case SPRN_FSCR:
+   *spr_val = vcpu-arch.fscr;
+   break;
default:
 unprivileged:
printk(KERN_INFO KVM: invalid SPR read: %d\n, sprn);
diff --git a/arch/powerpc/kvm/book3s_interrupts.S 
b/arch/powerpc/kvm/book3s_interrupts.S
index f779450cb07c..fcbdf4817301 100644
--- a/arch/powerpc/kvm/book3s_interrupts.S
+++ b/arch/powerpc/kvm/book3s_interrupts.S
@@ -107,6 +107,14 @@ kvm_start_lightweight:
ld  r3, VCPU_SHARED(r4)
ld  r3, VCPU_SHARED_SPRG3(r3)
mtspr   SPRN_SPRG3, r3
+
+BEGIN_FTR_SECTION
+   mfspr r3,SPRN_FSCR
+   PPC_STL r3, HSTATE_FSCR(r13)
+
+   PPC_LL r3, VCPU_SHADOW_FSCR(r4)
+   mtspr SPRN_FSCR, r3
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 #endif /* CONFIG_PPC_BOOK3S_64 */
 
PPC_LL  r4, VCPU_SHADOW_MSR(r4) /* get shadow_msr */
@@ -148,6 +156,9 @@ kvm_start_lightweight:
bl  FUNC(kvmppc_copy_from_svcpu)
nop
 
+   /* R7 = vcpu */
+   PPC_LL  r7, GPR4(r1)
+
 #ifdef CONFIG_PPC_BOOK3S_64
/*
 * Reload kernel SPRG3 value.
@@ -155,10 +166,18 @@ kvm_start_lightweight:
 */
ld  r3, PACA_SPRG3(r13)
mtspr   SPRN_SPRG3, r3
-#endif /* 

[RFC PATCH 10/10] PPC: BOOK3S: Disable/Enable TM looking at the ibm, pa-features device tree entry

2014-01-28 Thread Aneesh Kumar K.V
Runtime disable transactional memory feature looking at pa-features
device tree entry. We need to do this so that we can run a kernel
built with TM config in PR mode. For PR guest we provide a device
tree entry with TM feature disabled in pa-features

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/powerpc/kernel/prom.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index fa0ad8aafbcc..de8c2caf1024 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -160,6 +160,11 @@ static struct ibm_pa_feature {
{CPU_FTR_NODSISRALIGN, 0, 0,1, 1, 1},
{0, MMU_FTR_CI_LARGE_PAGE, 0,   1, 2, 0},
{CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
+   /*
+* We should use CPU_FTR_TM_COMP so that if we disable TM, it won't get
+* enabled via device tree
+*/
+   {CPU_FTR_TM_COMP, 0, 0, 22, 0, 0},
 };
 
 static void __init scan_features(unsigned long node, unsigned char *ftrs,
-- 
1.8.5.3

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


[RFC PATCH 09/10] KVM: PPC: BOOK3S: PR: Ignore write to monitor mode control register

2014-01-28 Thread Aneesh Kumar K.V
We ignore write to these registers now

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

diff --git a/arch/powerpc/kvm/book3s_emulate.c 
b/arch/powerpc/kvm/book3s_emulate.c
index bf6b11021250..c0aee34ef04f 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -490,6 +490,16 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, 
int sprn, ulong spr_val)
case SPRN_BESCR:
vcpu-arch.bescr = spr_val;
break;
+   case SPRN_MMCRS:
+   break;
+   case SPRN_MMCRA:
+   break;
+   case SPRN_MMCR0:
+   break;
+   case SPRN_MMCR1:
+   break;
+   case SPRN_MMCR2:
+   break;
 unprivileged:
default:
printk(KERN_INFO KVM: invalid SPR write: %d\n, sprn);
-- 
1.8.5.3

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


[RFC PATCH 03/10] KVM: PPC: BOOK3S: PR: Emulate instruction counter

2014-01-28 Thread Aneesh Kumar K.V
Writing to IC is not allowed in the privileged mode.

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/kvm_host.h | 1 +
 arch/powerpc/kvm/book3s_emulate.c   | 3 +++
 arch/powerpc/kvm/book3s_pr.c| 2 ++
 3 files changed, 6 insertions(+)

diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
index 9ebdd12e50a9..e0b13aca98e6 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -509,6 +509,7 @@ struct kvm_vcpu_arch {
/* Time base value when we entered the guest */
u64 entry_tb;
u64 entry_vtb;
+   u64 entry_ic;
u32 tcr;
ulong tsr; /* we need to perform set/clr_bits() which requires ulong */
u32 ivor[64];
diff --git a/arch/powerpc/kvm/book3s_emulate.c 
b/arch/powerpc/kvm/book3s_emulate.c
index 4b58d8a90cb5..abe6f3057e5b 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -531,6 +531,9 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int 
sprn, ulong *spr_val
case SPRN_VTB:
*spr_val = vcpu-arch.vtb;
break;
+   case SPRN_IC:
+   *spr_val = vcpu-arch.ic;
+   break;
case SPRN_GQR0:
case SPRN_GQR1:
case SPRN_GQR2:
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index b5598e9cdd09..51d469f8c9fd 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -121,6 +121,7 @@ void kvmppc_copy_to_svcpu(struct kvmppc_book3s_shadow_vcpu 
*svcpu,
 */
vcpu-arch.entry_tb = get_tb();
vcpu-arch.entry_vtb = get_vtb();
+   vcpu-arch.entry_ic = mfspr(SPRN_IC);
 
 }
 
@@ -174,6 +175,7 @@ out:
vcpu-arch.purr += get_tb() - vcpu-arch.entry_tb;
vcpu-arch.spurr += get_tb() - vcpu-arch.entry_tb;
vcpu-arch.vtb += get_vtb() - vcpu-arch.entry_vtb;
+   vcpu-arch.ic += mfspr(SPRN_IC) - vcpu-arch.entry_ic;
 }
 
 static int kvmppc_core_check_requests_pr(struct kvm_vcpu *vcpu)
-- 
1.8.5.3

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


Re: [PATCH] powerpc: don't re-issue spinlock typedef that breaks older gcc

2014-01-28 Thread Aneesh Kumar K.V
Paul Gortmaker paul.gortma...@windriver.com writes:

 Commit b3084f4db3aeb991c507ca774337c7e7893ed04f (powerpc/thp: Fix
 crash on mremap) added a typedef struct spinlock spinlock_t;
 which on gcc 4.5.2 (and possibly other versions) causes many of:

 include/linux/spinlock_types.h:76:3: error: redefinition of typedef 
 'spinlock_t'
 arch/powerpc/include/asm/pgtable-ppc64.h:563:25: note: previous declaration 
 of 'spinlock_t' was here
 In file included from include/linux/mutex.h:15:0,
  from include/linux/notifier.h:13,
  from include/linux/pm_qos.h:8,
  from include/linux/netdevice.h:28,
  from drivers/net/wireless/ath/wil6210/wil6210.h:20,
  from drivers/net/wireless/ath/wil6210/debug.c:17:

 It appears that somewhere between gcc 4.5.2 and 4.6.3 this
 redefinition restriction was lifted.  Using the proper header
 from within !ASSEMBLY seems to fix it up in an acceptable way.

 Cc: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
 Cc: Kirill A. Shutemov kirill.shute...@linux.intel.com
 Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
 Signed-off-by: Paul Gortmaker paul.gortma...@windriver.com
 ---



http://mid.gmane.org/1389939036.3000.7.ca...@thinkpad-t5421.cn.ibm.com

This was posted earlier.



 [ Note that b3084f4db3 isn't mainline yet, it is currently in
   benh/powerpc.git #merge -- but is headed there soon via:
  https://lkml.org/lkml/2014/1/27/599   ]

  arch/powerpc/include/asm/pgtable-ppc64.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h 
 b/arch/powerpc/include/asm/pgtable-ppc64.h
 index d27960c89a71..3b638411646a 100644
 --- a/arch/powerpc/include/asm/pgtable-ppc64.h
 +++ b/arch/powerpc/include/asm/pgtable-ppc64.h
 @@ -111,6 +111,8 @@

  #ifndef __ASSEMBLY__

 +#include linux/spinlock_types.h
 +
  /*
   * This is the default implementation of various PTE accessors, it's
   * used in all cases except Book3S with 64K pages where we have a
 @@ -560,7 +562,6 @@ extern void pmdp_invalidate(struct vm_area_struct *vma, 
 unsigned long address,
   pmd_t *pmdp);

  #define pmd_move_must_withdraw pmd_move_must_withdraw
 -typedef struct spinlock spinlock_t;
  static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
spinlock_t *old_pmd_ptl)
  {
 -- 
 1.8.5.2

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


Re: [PATCH] powerpc: don't re-issue spinlock typedef that breaks older gcc

2014-01-28 Thread Paul Gortmaker
On 14-01-28 12:28 PM, Aneesh Kumar K.V wrote:
 Paul Gortmaker paul.gortma...@windriver.com writes:
 
 Commit b3084f4db3aeb991c507ca774337c7e7893ed04f (powerpc/thp: Fix
 crash on mremap) added a typedef struct spinlock spinlock_t;
 which on gcc 4.5.2 (and possibly other versions) causes many of:

 include/linux/spinlock_types.h:76:3: error: redefinition of typedef 
 'spinlock_t'
 arch/powerpc/include/asm/pgtable-ppc64.h:563:25: note: previous declaration 
 of 'spinlock_t' was here
 In file included from include/linux/mutex.h:15:0,
  from include/linux/notifier.h:13,
  from include/linux/pm_qos.h:8,
  from include/linux/netdevice.h:28,
  from drivers/net/wireless/ath/wil6210/wil6210.h:20,
  from drivers/net/wireless/ath/wil6210/debug.c:17:

 It appears that somewhere between gcc 4.5.2 and 4.6.3 this
 redefinition restriction was lifted.  Using the proper header
 from within !ASSEMBLY seems to fix it up in an acceptable way.

 Cc: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
 Cc: Kirill A. Shutemov kirill.shute...@linux.intel.com
 Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
 Signed-off-by: Paul Gortmaker paul.gortma...@windriver.com
 ---

 
 
 http://mid.gmane.org/1389939036.3000.7.ca...@thinkpad-t5421.cn.ibm.com
 
 This was posted earlier.

I see.  Well I guess Ben didn't use it since it is the same as the
temporary not-signed-off-by hack patch I posted earlier as well.

https://lkml.org/lkml/2014/1/27/584

I believe what I've posted here below to be the proper fix.

Paul.
--


 
 
 
 [ Note that b3084f4db3 isn't mainline yet, it is currently in
   benh/powerpc.git #merge -- but is headed there soon via:
  https://lkml.org/lkml/2014/1/27/599   ]

  arch/powerpc/include/asm/pgtable-ppc64.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h 
 b/arch/powerpc/include/asm/pgtable-ppc64.h
 index d27960c89a71..3b638411646a 100644
 --- a/arch/powerpc/include/asm/pgtable-ppc64.h
 +++ b/arch/powerpc/include/asm/pgtable-ppc64.h
 @@ -111,6 +111,8 @@

  #ifndef __ASSEMBLY__

 +#include linux/spinlock_types.h
 +
  /*
   * This is the default implementation of various PTE accessors, it's
   * used in all cases except Book3S with 64K pages where we have a
 @@ -560,7 +562,6 @@ extern void pmdp_invalidate(struct vm_area_struct *vma, 
 unsigned long address,
  pmd_t *pmdp);

  #define pmd_move_must_withdraw pmd_move_must_withdraw
 -typedef struct spinlock spinlock_t;
  static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
   spinlock_t *old_pmd_ptl)
  {
 -- 
 1.8.5.2
 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] powerpc: numa: Fix decimal permissions

2014-01-28 Thread Joe Perches
This should have been octal.

Signed-off-by: Joe Perches j...@perches.com
---
 arch/powerpc/mm/numa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 86a63de..30a42e2 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1785,7 +1785,7 @@ static const struct file_operations topology_ops = {
 static int topology_update_init(void)
 {
start_topology_update();
-   proc_create(powerpc/topology_updates, 644, NULL, topology_ops);
+   proc_create(powerpc/topology_updates, 0644, NULL, topology_ops);
 
return 0;
 }


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


Re: [PATCH] slub: Don't throw away partial remote slabs if there is no local memory

2014-01-28 Thread Nishanth Aravamudan
On 27.01.2014 [14:58:05 +0900], Joonsoo Kim wrote:
 On Fri, Jan 24, 2014 at 05:10:42PM -0800, Nishanth Aravamudan wrote:
  On 24.01.2014 [16:25:58 -0800], David Rientjes wrote:
   On Fri, 24 Jan 2014, Nishanth Aravamudan wrote:
   
Thank you for clarifying and providing  a test patch. I ran with this on
the system showing the original problem, configured to have 15GB of
memory.

With your patch after boot:

MemTotal:   15604736 kB
MemFree: 8768192 kB
Slab:3882560 kB
SReclaimable: 105408 kB
SUnreclaim:  3777152 kB

With Anton's patch after boot:

MemTotal:   15604736 kB
MemFree:11195008 kB
Slab:1427968 kB
SReclaimable: 109184 kB
SUnreclaim:  1318784 kB


I know that's fairly unscientific, but the numbers are reproducible. 

 
 Hello,
 
 I think that there is one mistake on David's patch although I'm not sure
 that it is the reason for this result.
 
 With David's patch, get_partial() in new_slab_objects() doesn't work
 properly, because we only change node id in !node_match() case. If we
 meet just !freelist case, we pass node id directly to
 new_slab_objects(), so we always try to allocate new slab page
 regardless existence of partial pages. We should solve it.
 
 Could you try this one?

This helps about the same as David's patch -- but I found the reason
why! ppc64 doesn't set CONFIG_HAVE_MEMORYLESS_NODES :) Expect a patch
shortly for that and one other case I found.

This patch on its own seems to help on our test system by saving around
1.5GB of slab.

Tested-by: Nishanth Aravamudan n...@linux.vnet.ibm.com
Acked-by: Nishanth Aravamudan n...@linux.vnet.ibm.com

with the caveat below.

Thanks,
Nish

 
 Thanks.
 
 --- a/mm/slub.c
 +++ b/mm/slub.c
 @@ -1698,8 +1698,10 @@ static void *get_partial(struct kmem_cache *s, gfp_t 
 flags, int node,
 struct kmem_cache_cpu *c)
  {
 void *object;
 -   int searchnode = (node == NUMA_NO_NODE) ? numa_node_id() : node;
 +   int searchnode = (node == NUMA_NO_NODE) ? numa_mem_id() : node;
 
 +   if (node != NUMA_NO_NODE  !node_present_pages(node))
 +   searchnode = numa_mem_id();

This might be clearer as:

int searchnode = node;
if (node == NUMA_NO_NODE || !node_present_pages(node))
searchnode = numa_mem_id();

 object = get_partial_node(s, get_node(s, searchnode), c, flags);
 if (object || node != NUMA_NO_NODE)
 return object;
 @@ -2278,10 +2280,14 @@ redo:
 
 if (unlikely(!node_match(page, node))) {
 stat(s, ALLOC_NODE_MISMATCH);
 -   deactivate_slab(s, page, c-freelist);
 -   c-page = NULL;
 -   c-freelist = NULL;
 -   goto new_slab;
 +   if (unlikely(!node_present_pages(node)))
 +   node = numa_mem_id();
 +   if (!node_match(page, node)) {
 +   deactivate_slab(s, page, c-freelist);
 +   c-page = NULL;
 +   c-freelist = NULL;
 +   goto new_slab;
 +   }
 }
 
 /*
 

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


[PATCH] powerpc: enable CONFIG_HAVE_MEMORYLESS_NODES

2014-01-28 Thread Nishanth Aravamudan
Anton Blanchard found an issue with an LPAR that had no memory in Node
0. Christoph Lameter recommended, as one possible solution, to use
numa_mem_id() for locality of the nearest memory node-wise. However,
numa_mem_id() [and the other related APIs] are only useful if
CONFIG_HAVE_MEMORYLESS_NODES is set. This is only the case for ia64
currently, but clearly we can have memoryless nodes on ppc64. Add the
Kconfig option and define it to be the same value as CONFIG_NUMA.

On the LPAR in question, which was very inefficiently using slabs, this
took the slab consumption at boot from roughly 7GB to roughly 4GB.

---
Ben, the only question I have wrt this change is if it's appropriate to
change it for all powerpc configs (that have NUMA on)?

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 25493a0..bb2d5fe 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -447,6 +447,9 @@ config NODES_SHIFT
default 4
depends on NEED_MULTIPLE_NODES
 
+config HAVE_MEMORYLESS_NODES
+   def_bool NUMA
+
 config ARCH_SELECT_MEMORY_MODEL
def_bool y
depends on PPC64

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


Re: [PATCH] powerpc: don't re-issue spinlock typedef that breaks older gcc

2014-01-28 Thread Aneesh Kumar K.V
Paul Gortmaker paul.gortma...@windriver.com writes:

 On 14-01-28 12:28 PM, Aneesh Kumar K.V wrote:
 Paul Gortmaker paul.gortma...@windriver.com writes:
 
 Commit b3084f4db3aeb991c507ca774337c7e7893ed04f (powerpc/thp: Fix
 crash on mremap) added a typedef struct spinlock spinlock_t;
 which on gcc 4.5.2 (and possibly other versions) causes many of:

 include/linux/spinlock_types.h:76:3: error: redefinition of typedef 
 'spinlock_t'
 arch/powerpc/include/asm/pgtable-ppc64.h:563:25: note: previous declaration 
 of 'spinlock_t' was here
 In file included from include/linux/mutex.h:15:0,
  from include/linux/notifier.h:13,
  from include/linux/pm_qos.h:8,
  from include/linux/netdevice.h:28,
  from drivers/net/wireless/ath/wil6210/wil6210.h:20,
  from drivers/net/wireless/ath/wil6210/debug.c:17:

 It appears that somewhere between gcc 4.5.2 and 4.6.3 this
 redefinition restriction was lifted.  Using the proper header
 from within !ASSEMBLY seems to fix it up in an acceptable way.

 Cc: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
 Cc: Kirill A. Shutemov kirill.shute...@linux.intel.com
 Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
 Signed-off-by: Paul Gortmaker paul.gortma...@windriver.com
 ---

 
 
 http://mid.gmane.org/1389939036.3000.7.ca...@thinkpad-t5421.cn.ibm.com
 
 This was posted earlier.

 I see.  Well I guess Ben didn't use it since it is the same as the
 temporary not-signed-off-by hack patch I posted earlier as well.

 https://lkml.org/lkml/2014/1/27/584

 I believe what I've posted here below to be the proper fix.

I had another variant which needed this

http://mid.gmane.org/1388999012-14424-1-git-send-email-aneesh.ku...@linux.vnet.ibm.com

BTW I had added the above struct spinlock; patch as the backport to
stable 3.13 series. So if we are picking another one, we may need to
update stable also

-aneesh

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


Re: [PATCH] powerpc: don't re-issue spinlock typedef that breaks older gcc

2014-01-28 Thread Paul Gortmaker
On 14-01-28 01:49 PM, Aneesh Kumar K.V wrote:
 Paul Gortmaker paul.gortma...@windriver.com writes:
 
 On 14-01-28 12:28 PM, Aneesh Kumar K.V wrote:
 Paul Gortmaker paul.gortma...@windriver.com writes:

 Commit b3084f4db3aeb991c507ca774337c7e7893ed04f (powerpc/thp: Fix
 crash on mremap) added a typedef struct spinlock spinlock_t;
 which on gcc 4.5.2 (and possibly other versions) causes many of:

 include/linux/spinlock_types.h:76:3: error: redefinition of typedef 
 'spinlock_t'
 arch/powerpc/include/asm/pgtable-ppc64.h:563:25: note: previous 
 declaration of 'spinlock_t' was here
 In file included from include/linux/mutex.h:15:0,
  from include/linux/notifier.h:13,
  from include/linux/pm_qos.h:8,
  from include/linux/netdevice.h:28,
  from drivers/net/wireless/ath/wil6210/wil6210.h:20,
  from drivers/net/wireless/ath/wil6210/debug.c:17:

 It appears that somewhere between gcc 4.5.2 and 4.6.3 this
 redefinition restriction was lifted.  Using the proper header
 from within !ASSEMBLY seems to fix it up in an acceptable way.

 Cc: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
 Cc: Kirill A. Shutemov kirill.shute...@linux.intel.com
 Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
 Signed-off-by: Paul Gortmaker paul.gortma...@windriver.com
 ---



 http://mid.gmane.org/1389939036.3000.7.ca...@thinkpad-t5421.cn.ibm.com

 This was posted earlier.

 I see.  Well I guess Ben didn't use it since it is the same as the
 temporary not-signed-off-by hack patch I posted earlier as well.

 https://lkml.org/lkml/2014/1/27/584

 I believe what I've posted here below to be the proper fix.
 
 I had another variant which needed this
 
 http://mid.gmane.org/1388999012-14424-1-git-send-email-aneesh.ku...@linux.vnet.ibm.com

What config did you use to trigger that?  I've not seen it in
allyes/allmodconfig.  I'd like us to try and fix it an alternate
way, vs. fragmenting the header into smaller and smaller
specialized chunks, if possible.

 
 BTW I had added the above struct spinlock; patch as the backport to
 stable 3.13 series. So if we are picking another one, we may need to
 update stable also

The stable tree is self-correcting ; it won't take any patches that
don't have the same commit present in mainline.  But yes, someone
will still have to _nominate_ one for stable tree consideration.

Paul.
--

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


Re: [PATCH v2 2/3] powerpc/pseries: Update dynamic cache nodes for suspend/resume operation

2014-01-28 Thread Nathan Fontenot
On 01/22/2014 01:58 PM, Tyrel Datwyler wrote:
 From: Haren Myneni hb...@us.ibm.com
 
 From: Haren Myneni hb...@us.ibm.com
 
 pHyp can change cache nodes for suspend/resume operation. The current code
 updates the device tree after all non boot CPUs are enabled. Hence, we do not
 modify the cache list based on the latest cache nodes. Also we do not remove
 cache entries for the primary CPU.
 
 This patch removes the cache list for the boot CPU, updates the device tree
 before enabling nonboot CPUs and adds cache list for the boot cpu.
 
 Signed-off-by: Haren Myneni hb...@us.ibm.com
 Signed-off-by: Tyrel Datwyler tyr...@linux.vnet.ibm.com
 ---
  arch/powerpc/include/asm/rtas.h |  4 
  arch/powerpc/kernel/rtas.c  | 17 +
  arch/powerpc/kernel/time.c  |  6 ++
  3 files changed, 27 insertions(+)
 
 diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
 index 9bd52c6..da9d733 100644
 --- a/arch/powerpc/include/asm/rtas.h
 +++ b/arch/powerpc/include/asm/rtas.h
 @@ -283,6 +283,10 @@ extern void pSeries_log_error(char *buf, unsigned int 
 err_type, int fatal);
 
  #ifdef CONFIG_PPC_PSERIES
  extern int pseries_devicetree_update(s32 scope);
 +extern void post_mobility_fixup(void);
 +extern void update_dynamic_configuration(void);
 +#else /* !CONFIG_PPC_PSERIES */
 +void update_dynamic_configuration(void) { }
  #endif
 
  #ifdef CONFIG_PPC_RTAS_DAEMON
 diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
 index 4cf674d..8249eb2 100644
 --- a/arch/powerpc/kernel/rtas.c
 +++ b/arch/powerpc/kernel/rtas.c
 @@ -43,6 +43,7 @@
  #include asm/time.h
  #include asm/mmu.h
  #include asm/topology.h
 +#include cacheinfo.h
 
  struct rtas_t rtas = {
   .lock = __ARCH_SPIN_LOCK_UNLOCKED
 @@ -972,6 +973,22 @@ out:
   free_cpumask_var(offline_mask);
   return atomic_read(data.error);
  }
 +
 +/*
 + * The device tree cache nodes can be modified during suspend/ resume.
 + * So delete all cache entries and recreate them again after the device tree
 + * update.
 + * We already deleted cache entries for notboot CPUs before suspend. So 
 delete
 + * entries for the primary CPU, recreate entries after the device tree 
 update.
 + * We can create entries for nonboot CPU when enable them later.
 + */
 +
 +void update_dynamic_configuration(void)
 +{
 + cacheinfo_cpu_offline(smp_processor_id());
 + post_mobility_fixup();
 + cacheinfo_cpu_online(smp_processor_id());
 +}
  #else /* CONFIG_PPC_PSERIES */
  int rtas_ibm_suspend_me(struct rtas_args *args)
  {
 diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
 index b3b1441..5f1ca28 100644
 --- a/arch/powerpc/kernel/time.c
 +++ b/arch/powerpc/kernel/time.c
 @@ -69,6 +69,7 @@
  #include asm/vdso_datapage.h
  #include asm/firmware.h
  #include asm/cputime.h
 +#include asm/rtas.h
 
  /* powerpc clocksource/clockevent code */
 
 @@ -592,6 +593,11 @@ void arch_suspend_enable_irqs(void)
   generic_suspend_enable_irqs();
   if (ppc_md.suspend_enable_irqs)
   ppc_md.suspend_enable_irqs();
 + /*
 +  * Update configuration which can be modified based on devicetree
 +  * changes during resume.
 +  */
 + update_dynamic_configuration();

Instead of creating this new routine update_dynamic_reconfiguration() for
pseries systems only, shouldn't we be defining ppc_md.suspend_enable_irqs
for pseries. I think this could be done in platforms/pseries/suspend.c

-Nathan

  }
  #endif
 

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


Re: [PATCH v2 1/3] powerpc/pseries: Device tree should only be updated once after suspend/migrate

2014-01-28 Thread Nathan Fontenot
On 01/22/2014 01:58 PM, Tyrel Datwyler wrote:
 From: Haren Myneni hb...@us.ibm.com
 
 From: Haren Myneni hb...@us.ibm.com
 
 The current code makes rtas calls for update-nodes, activate-firmware and then
 update-nodes again. The FW provides the same data for both update-nodes calls.
 As a result a proc entry exists error is reported for the second update while
 adding device nodes.
 
 This patch makes a single rtas call for update-nodes after activating the FW.
 It also add rtas_busy delay for the activate-firmware rtas call.
 
 Signed-off-by: Haren Myneni hb...@us.ibm.com
 Signed-off-by: Tyrel Datwyler tyr...@linux.vnet.ibm.com

Acked-by: Nathan fontenot nf...@linux.vnet.ibm.com

 ---
  arch/powerpc/platforms/pseries/mobility.c | 26 ++
  1 file changed, 10 insertions(+), 16 deletions(-)
 
 diff --git a/arch/powerpc/platforms/pseries/mobility.c 
 b/arch/powerpc/platforms/pseries/mobility.c
 index cde4e0a..bde7eba 100644
 --- a/arch/powerpc/platforms/pseries/mobility.c
 +++ b/arch/powerpc/platforms/pseries/mobility.c
 @@ -290,13 +290,6 @@ void post_mobility_fixup(void)
   int rc;
   int activate_fw_token;
 
 - rc = pseries_devicetree_update(MIGRATION_SCOPE);
 - if (rc) {
 - printk(KERN_ERR Initial post-mobility device tree update 
 -failed: %d\n, rc);
 - return;
 - }
 -
   activate_fw_token = rtas_token(ibm,activate-firmware);
   if (activate_fw_token == RTAS_UNKNOWN_SERVICE) {
   printk(KERN_ERR Could not make post-mobility 
 @@ -304,16 +297,17 @@ void post_mobility_fixup(void)
   return;
   }
 
 - rc = rtas_call(activate_fw_token, 0, 1, NULL);
 - if (!rc) {
 - rc = pseries_devicetree_update(MIGRATION_SCOPE);
 - if (rc)
 - printk(KERN_ERR Secondary post-mobility device tree 
 -update failed: %d\n, rc);
 - } else {
 + do {
 + rc = rtas_call(activate_fw_token, 0, 1, NULL);
 + } while (rtas_busy_delay(rc));
 +
 + if (rc)
   printk(KERN_ERR Post-mobility activate-fw failed: %d\n, rc);
 - return;
 - }
 +
 + rc = pseries_devicetree_update(MIGRATION_SCOPE);
 + if (rc)
 + printk(KERN_ERR Post-mobility device tree update 
 + failed: %d\n, rc);
 
   return;
  }
 

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


Re: [PATCH v2 3/3] powerpc/pseries: Report in kernel device tree update to drmgr

2014-01-28 Thread Nathan Fontenot
On 01/22/2014 01:58 PM, Tyrel Datwyler wrote:
 Traditionally it has been drmgr's responsibilty to update the device tree
 through the /proc/ppc64/ofdt interface after a suspend/resume operation.
 This patchset however has modified suspend/resume ops to preform that update
 entirely in the kernel during the resume. Therefore, a mechanism is required
 for drmgr to determine who is responsible for the update. This patch adds a
 show function to the hibernate attribute that returns 1 if the kernel
 updates the device tree after the resume and 0 if drmgr is responsible.
 
 Signed-off-by: Tyrel Datwyler tyr...@linux.vnet.ibm.com

Acked-by: Nathan Fontenot nf...@linux.vnet.ibm.com

 ---
  arch/powerpc/platforms/pseries/suspend.c | 25 -
  1 file changed, 24 insertions(+), 1 deletion(-)
 
 diff --git a/arch/powerpc/platforms/pseries/suspend.c 
 b/arch/powerpc/platforms/pseries/suspend.c
 index 16a2552..723115d 100644
 --- a/arch/powerpc/platforms/pseries/suspend.c
 +++ b/arch/powerpc/platforms/pseries/suspend.c
 @@ -174,7 +174,30 @@ out:
   return rc;
  }
 
 -static DEVICE_ATTR(hibernate, S_IWUSR, NULL, store_hibernate);
 +#define USER_DT_UPDATE   0
 +#define KERN_DT_UPDATE   1
 +
 +/**
 + * show_hibernate - Report device tree update responsibilty
 + * @dev: subsys root device
 + * @attr:device attribute struct
 + * @buf: buffer
 + *
 + * Report whether a device tree update is performed by the kernel after a
 + * resume, or if drmgr must coordinate the update from user space.
 + *
 + * Return value:
 + *   0 if drmgr is to initiate update, and 1 otherwise
 + **/
 +static ssize_t show_hibernate(struct device *dev,
 +   struct device_attribute *attr,
 +   char *buf)
 +{
 + return sprintf(buf, %d\n, KERN_DT_UPDATE);
 +}
 +
 +static DEVICE_ATTR(hibernate, S_IWUSR | S_IRUGO,
 +show_hibernate, store_hibernate);
 
  static struct bus_type suspend_subsys = {
   .name = power,
 

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


Re: [git pull] Please pull powerpc.git next branch

2014-01-28 Thread Benjamin Herrenschmidt
On Tue, 2014-01-28 at 16:03 +0100, Olaf Hering wrote:
 
 d084775738b746648d4102337163a04534a02982 is the first bad commit
 commit d084775738b746648d4102337163a04534a02982
 Author: Alistair Popple alist...@popple.id.au
 Date:   Mon Dec 9 18:17:03 2013 +1100
 
 powerpc/iommu: Update the generic code to use dynamic iommu page sizes
 
 This patch updates the generic iommu backend code to use the
 it_page_shift field to determine the iommu page size instead of
 using hardcoded values.

Interesting. This is new infrastructure but a nop in functionality, ie,
we support different page sizes for DMA but we still set it to 4k,
unless we somewhat failed to initialize something...

I'll have a look, I actually have one of those G5s here still. Thanks !

Cheers,
Ben.

 Signed-off-by: Alistair Popple alist...@popple.id.au
 Signed-off-by: Benjamin Herrenschmidt b...@kernel.crashing.org
 
 :04 04 52a8e1ca3166e3c916f8cdc1df5c1f42c76b2359 
 3d4915e416b28501ff502305bd4f76d64153dbc4 M  arch
 :04 04 e9a9020abbef5622ffa1be381e0ff845e3741fa9 
 d6fc206dd372c1a8deded826cc5de8b05f71c614 M  drivers
 
 # git bisect log
 git bisect start
 # good: [b2e448eca1a52fea181905845728ae00a138d84e] Merge branch 'ipmi' (ipmi 
 patches from Corey Minyard)
 git bisect good b2e448eca1a52fea181905845728ae00a138d84e
 # bad: [54c0a4b46150db1571d955d598cd342c9f1d9657] Merge branch 'akpm' 
 (incoming from Andrew)
 git bisect bad 54c0a4b46150db1571d955d598cd342c9f1d9657
 # good: [403227641533c4227d44d14f25c8f3676f6e7436] softirq: convert printks 
 to pr_level
 git bisect good 403227641533c4227d44d14f25c8f3676f6e7436
 # bad: [8b52312880ecbc5beb40b313600f2903c16a59ed] powerpc/p1010rdb-pa: modify 
 phy interrupt.
 git bisect bad 8b52312880ecbc5beb40b313600f2903c16a59ed
 # good: [2c49195b6aedd21ff1cd1e095fab9866fba3411b] powernv: Remove 
 get/set_rtc_time when they are not present
 git bisect good 2c49195b6aedd21ff1cd1e095fab9866fba3411b
 # bad: [a68c33f3592eef63304a5f5ab68466539ccac56c] powerpc: Fix endian issues 
 in power7/8 machine check handler
 git bisect bad a68c33f3592eef63304a5f5ab68466539ccac56c
 # good: [c34a51ce49b40b9667cd7f5cc2e40475af8b4c3d] powerpc/mm: Enable 
 _PAGE_NUMA for book3s
 git bisect good c34a51ce49b40b9667cd7f5cc2e40475af8b4c3d
 # good: [fee26f6d5d68a8815b20c32d15dd70d5384eb937] powerpc: Remove unused 
 REDBOOT Kconfig parameter
 git bisect good fee26f6d5d68a8815b20c32d15dd70d5384eb937
 # good: [3a553170d35d69bea3877bffa508489dfa6f133d] powerpc/iommu: Add 
 it_page_shift field to determine iommu page size
 git bisect good 3a553170d35d69bea3877bffa508489dfa6f133d
 # bad: [d084775738b746648d4102337163a04534a02982] powerpc/iommu: Update the 
 generic code to use dynamic iommu page sizes
 git bisect bad d084775738b746648d4102337163a04534a02982
 # first bad commit: [d084775738b746648d4102337163a04534a02982] powerpc/iommu: 
 Update the generic code to use dynamic iommu page sizes
 


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


Re: [PATCH] powerpc/sysdev: Fix a mpic section mismatch for MPC85xx

2014-01-28 Thread Christian Engelmayer
On Fri, 20 Dec 2013 00:00:41 +0100, Christian Engelmayer cenge...@gmx.at 
wrote:
 On Mon, 16 Dec 2013 11:10:53 +1100 Benjamin Herrenschmidt 
 b...@kernel.crashing.org wrote:
  On Sun, 2013-12-15 at 19:38 +0100, Christian Engelmayer wrote:
   Moved arch/powerpc/sysdev/mpic.c : smp_mpic_probe() out of the __init 
   section.
   It is referenced by arch/powerpc/platforms/85xx/smp.c : 
   smp_85xx_setup_cpu().
  
  I don't like this. The reference is not actually going to call into the
  code at all and as such is not an error, it's just a pointer comparison.
 
 That's correct. I proposed it that way because on first sight I was concerned
 that there is an address of an __init function assigned to a function pointer
 within a non __initdata struct at all that can be compared against. However,
 further usage of smp_ops-probe is currently safe of course and *_ops symbols
 within .data are whitelisted to refer to init sections.
 
  If there is no way to silence the warning, then I'd suggest to use a
  global flag, something like mpc85xx_pic_type and test that instead
  of comparing the pointers.
 
 I've seen that there is currently a patch proposed against
 
commit dc2c9c52b604f51b1416ed87ff54a1c77a1a8b5b
powerpc/85xx: Set up doorbells even with no mpic
 
 that introduced the section causing the warning:
 
http://patchwork.ozlabs.org/patch/289214/
powerpc/85xx: don't init the mpic ipi for the SoC which has doorbell 
 support
 
 This patch also removes the affected pointer comparison and if accepted would
 thus also silence this warning.

Kevin's change (powerpc/85xx: don't init the mpic ipi for the SoC which has
doorbell support) entered mainline by merge 1b17366d. I verified that the
issue is thereby solved and my patch obsolete.

   http://patchwork.ozlabs.org/patch/301402/

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


Re: [git pull] Please pull powerpc.git next branch

2014-01-28 Thread Alistair Popple
On Wed, 29 Jan 2014 07:19:55 Benjamin Herrenschmidt wrote:
 On Tue, 2014-01-28 at 16:03 +0100, Olaf Hering wrote:
  d084775738b746648d4102337163a04534a02982 is the first bad commit
  commit d084775738b746648d4102337163a04534a02982
  Author: Alistair Popple alist...@popple.id.au
  Date:   Mon Dec 9 18:17:03 2013 +1100
  
  powerpc/iommu: Update the generic code to use dynamic iommu page sizes
  
  This patch updates the generic iommu backend code to use the
  it_page_shift field to determine the iommu page size instead of
  using hardcoded values.
 
 Interesting. This is new infrastructure but a nop in functionality, ie,
 we support different page sizes for DMA but we still set it to 4k,
 unless we somewhat failed to initialize something...

Looks like I missed the dart iommu code when changing the iommu table 
initialisation. The patch below should fix it, would you mind testing it Ben? 
Thanks.

 I'll have a look, I actually have one of those G5s here still. Thanks !
 
 Cheers,
 Ben.
 

---

diff --git a/arch/powerpc/sysdev/dart_iommu.c 
b/arch/powerpc/sysdev/dart_iommu.c
index bd968a4..62c47bb 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -292,6 +292,7 @@ static void iommu_table_dart_setup(void)
iommu_table_dart.it_offset = 0;
/* it_size is in number of entries */
iommu_table_dart.it_size = dart_tablesize / sizeof(u32);
+   iommu_table_dart.it_page_shift = IOMMU_PAGE_SHIFT_4K;
 
/* Initialize the common IOMMU code */
iommu_table_dart.it_base = (unsigned long)dart_vbase;
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc/iommu: Fix initialisation of DART iommu table

2014-01-28 Thread Alistair Popple
Commit d084775738b746648d4102337163a04534a02982 switched the generic
powerpc iommu backend code to use the it_page_shift field to determine
page size. Commit 3a553170d35d69bea3877bffa508489dfa6f133d should have
initiliased this field for all platforms, however the DART iommu table
code was not updated.

This commit initialises the it_page_shift field to 4K for the DART
iommu.

Signed-off-by: Alistair Popple alist...@popple.id.au
---
 arch/powerpc/sysdev/dart_iommu.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index bd968a4..62c47bb 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -292,6 +292,7 @@ static void iommu_table_dart_setup(void)
iommu_table_dart.it_offset = 0;
/* it_size is in number of entries */
iommu_table_dart.it_size = dart_tablesize / sizeof(u32);
+   iommu_table_dart.it_page_shift = IOMMU_PAGE_SHIFT_4K;
 
/* Initialize the common IOMMU code */
iommu_table_dart.it_base = (unsigned long)dart_vbase;
-- 
1.7.10.4

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


[PATCH] powerpc: Fix 32-bit frames for signals delivered when transactional

2014-01-28 Thread Paul Mackerras
Commit d31626f70b61 (powerpc: Don't corrupt transactional state when
using FP/VMX in kernel) introduced a bug where the uc_link and uc_regs
fields of the ucontext_t that is created to hold the transactional
values of the registers in a 32-bit signal frame didn't get set
correctly.  The reason is that we now clear the MSR_TS bits in the MSR
in save_tm_user_regs(), before the code that sets uc_link and uc_regs.
To fix this, we move the setting of uc_link and uc_regs into the same
if statement that selects whether to call save_tm_user_regs() or
save_user_regs().

Signed-off-by: Paul Mackerras pau...@samba.org
---
 arch/powerpc/kernel/signal_32.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 6ce69e6..a67e00a 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -1022,29 +1022,24 @@ int handle_rt_signal32(unsigned long sig, struct 
k_sigaction *ka,
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
tm_frame = rt_sf-uc_transact.uc_mcontext;
if (MSR_TM_ACTIVE(regs-msr)) {
+   if (__put_user((unsigned long)rt_sf-uc_transact,
+  rt_sf-uc.uc_link) ||
+   __put_user((unsigned long)tm_frame,
+  rt_sf-uc_transact.uc_regs))
+   goto badframe;
if (save_tm_user_regs(regs, frame, tm_frame, sigret))
goto badframe;
}
else
 #endif
{
+   if (__put_user(0, rt_sf-uc.uc_link))
+   goto badframe;
if (save_user_regs(regs, frame, tm_frame, sigret, 1))
goto badframe;
}
regs-link = tramp;
 
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-   if (MSR_TM_ACTIVE(regs-msr)) {
-   if (__put_user((unsigned long)rt_sf-uc_transact,
-  rt_sf-uc.uc_link)
-   || __put_user((unsigned long)tm_frame, 
rt_sf-uc_transact.uc_regs))
-   goto badframe;
-   }
-   else
-#endif
-   if (__put_user(0, rt_sf-uc.uc_link))
-   goto badframe;
-
current-thread.fp_state.fpscr = 0; /* turn off all fp exceptions */
 
/* create a stack frame for the caller of the handler */
-- 
1.8.5.2

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


Re: Please pull 'next' branch of 5xxx tree

2014-01-28 Thread Benjamin Herrenschmidt
On Tue, 2014-01-28 at 17:00 +1100, Benjamin Herrenschmidt wrote:
 On Tue, 2014-01-28 at 06:46 +0100, Anatolij Gustschin wrote:
  Hi Ben !
  
  On Wed, 15 Jan 2014 22:18:59 +0100
  Anatolij Gustschin ag...@denx.de wrote:
  
   Hi Ben !
   
   please pull mpc5xxx patches for v3.14:
  
  Ping.
 
 Oops, you sent that while I was on vacation and I missed it.
 
 Next time, try to send your pull request earlier if possible, I'd like
 to have most stuff together before -rc5. I'll try to send this one to
 Linus after he has pulled my current one.

Hrm, I get a merge conflicts with spi-mpc512x-psc.c, please check that I
fixed it up properly in powerpc-next and let me know.

If it's good I'll send to Linus tomorrow.

Cheers,
Ben.




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