Re: [PATCH 2/2] powerpc: use spin loop primitives in some functions

2017-07-02 Thread kbuild test robot
Hi Nicholas,

[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.12-rc7 next-20170630]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Michael-Ellerman/powerpc-64-implement-spin-loop-primitives/20170630-210421
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-ppc6xx_defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc 

All error/warnings (new ones prefixed by >>):

   In file included from arch/powerpc/include/asm/io.h:32:0,
from arch/powerpc/include/asm/book3s/32/pgtable.h:95,
from arch/powerpc/include/asm/book3s/pgtable.h:7,
from arch/powerpc/include/asm/pgtable.h:16,
from include/linux/mm.h:70,
from drivers/soc/fsl/qe/qe.c:23:
   drivers/soc/fsl/qe/qe.c: In function 'qe_issue_cmd':
>> arch/powerpc/include/asm/delay.h:67:3: error: implicit declaration of 
>> function 'spin_begin' [-Werror=implicit-function-declaration]
  spin_begin();  \
  ^
>> drivers/soc/fsl/qe/qe.c:142:8: note: in expansion of macro 
>> 'spin_event_timeout'
 ret = spin_event_timeout((in_be32(_immr->cp.cecr) & QE_CR_FLG) == 0,
   ^~
>> arch/powerpc/include/asm/delay.h:70:4: error: implicit declaration of 
>> function 'spin_cpu_relax' [-Werror=implicit-function-declaration]
   spin_cpu_relax();  \
   ^
>> drivers/soc/fsl/qe/qe.c:142:8: note: in expansion of macro 
>> 'spin_event_timeout'
 ret = spin_event_timeout((in_be32(_immr->cp.cecr) & QE_CR_FLG) == 0,
   ^~
>> arch/powerpc/include/asm/delay.h:71:3: error: implicit declaration of 
>> function 'spin_end' [-Werror=implicit-function-declaration]
  spin_end();\
  ^
>> drivers/soc/fsl/qe/qe.c:142:8: note: in expansion of macro 
>> 'spin_event_timeout'
 ret = spin_event_timeout((in_be32(_immr->cp.cecr) & QE_CR_FLG) == 0,
   ^~
   cc1: some warnings being treated as errors
--
   In file included from arch/powerpc/include/asm/io.h:32:0,
from arch/powerpc/include/asm/book3s/32/pgtable.h:95,
from arch/powerpc/include/asm/book3s/pgtable.h:7,
from arch/powerpc/include/asm/pgtable.h:16,
from include/linux/mm.h:70,
from drivers/soc//fsl/qe/qe.c:23:
   drivers/soc//fsl/qe/qe.c: In function 'qe_issue_cmd':
>> arch/powerpc/include/asm/delay.h:67:3: error: implicit declaration of 
>> function 'spin_begin' [-Werror=implicit-function-declaration]
  spin_begin();  \
  ^
   drivers/soc//fsl/qe/qe.c:142:8: note: in expansion of macro 
'spin_event_timeout'
 ret = spin_event_timeout((in_be32(_immr->cp.cecr) & QE_CR_FLG) == 0,
   ^~
>> arch/powerpc/include/asm/delay.h:70:4: error: implicit declaration of 
>> function 'spin_cpu_relax' [-Werror=implicit-function-declaration]
   spin_cpu_relax();  \
   ^
   drivers/soc//fsl/qe/qe.c:142:8: note: in expansion of macro 
'spin_event_timeout'
 ret = spin_event_timeout((in_be32(_immr->cp.cecr) & QE_CR_FLG) == 0,
   ^~
>> arch/powerpc/include/asm/delay.h:71:3: error: implicit declaration of 
>> function 'spin_end' [-Werror=implicit-function-declaration]
  spin_end();\
  ^
   drivers/soc//fsl/qe/qe.c:142:8: note: in expansion of macro 
'spin_event_timeout'
 ret = spin_event_timeout((in_be32(_immr->cp.cecr) & QE_CR_FLG) == 0,
   ^~
   cc1: some warnings being treated as errors

vim +/spin_begin +67 arch/powerpc/include/asm/delay.h

61  
   \
62  if (delay) {
   \
63  while (!(__ret = (condition)) &&
   \
64  (tb_ticks_since(__start) <= __loops))   
   \
65  udelay(delay);  
   \
66  } else {
   \
  > 67  spin_begin();   
   \
68  while (!(__ret = (condition)) &&
   \
69 

[PATCH 2/2] powerpc: use spin loop primitives in some functions

2017-06-28 Thread Michael Ellerman
From: Nicholas Piggin 

Use the different spin loop primitives in some simple powerpc
spin loops, including those which will spin as a common case.

This will help to test the spin loop primitives before more
conversions are done.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/delay.h | 15 +++
 arch/powerpc/kernel/smp.c|  3 +--
 arch/powerpc/kernel/time.c   |  6 --
 arch/powerpc/mm/hash_native_64.c |  4 +++-
 4 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/include/asm/delay.h b/arch/powerpc/include/asm/delay.h
index 52e4d54da2a9..b028788bd55d 100644
--- a/arch/powerpc/include/asm/delay.h
+++ b/arch/powerpc/include/asm/delay.h
@@ -58,11 +58,18 @@ extern void udelay(unsigned long usecs);
typeof(condition) __ret;   \
unsigned long __loops = tb_ticks_per_usec * timeout;   \
unsigned long __start = get_tbl(); \
-   while (!(__ret = (condition)) && (tb_ticks_since(__start) <= __loops)) \
-   if (delay) \
+   
\
+   if (delay) {   \
+   while (!(__ret = (condition)) &&   \
+   (tb_ticks_since(__start) <= __loops))  \
udelay(delay); \
-   else   \
-   cpu_relax();   \
+   } else {   \
+   spin_begin();  \
+   while (!(__ret = (condition)) &&   \
+   (tb_ticks_since(__start) <= __loops))  \
+   spin_cpu_relax();  \
+   spin_end();\
+   }  \
if (!__ret)\
__ret = (condition);   \
__ret; \
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 418019728efa..67d89b4e777c 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -767,8 +767,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
smp_ops->give_timebase();
 
/* Wait until cpu puts itself in the online & active maps */
-   while (!cpu_online(cpu))
-   cpu_relax();
+   spin_until_cond(cpu_online(cpu));
 
return 0;
 }
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 0cc0dad905d5..e75844d76992 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -442,6 +442,7 @@ void __delay(unsigned long loops)
unsigned long start;
int diff;
 
+   spin_begin();
if (__USE_RTC()) {
start = get_rtcl();
do {
@@ -449,13 +450,14 @@ void __delay(unsigned long loops)
diff = get_rtcl() - start;
if (diff < 0)
diff += 10;
+   spin_cpu_relax();
} while (diff < loops);
} else {
start = get_tbl();
while (get_tbl() - start < loops)
-   HMT_low();
-   HMT_medium();
+   spin_cpu_relax();
}
+   spin_end();
 }
 EXPORT_SYMBOL(__delay);
 
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index bdaac28193f7..ad0ba1da1b79 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -184,8 +184,10 @@ static inline void native_lock_hpte(struct hash_pte *hptep)
while (1) {
if (!test_and_set_bit_lock(HPTE_LOCK_BIT, word))
break;
+   spin_begin();
while(test_bit(HPTE_LOCK_BIT, word))
-   cpu_relax();
+   spin_cpu_relax();
+   spin_end();
}
 }
 
-- 
2.7.4