[perf core] c5dfd78eb7: BUG: unable to handle kernel NULL pointer dereference at 00000c40

2016-06-24 Thread kernel test robot
perf core: Allow setting up max frame stack depth via sysctl
# first bad commit: [c5dfd78eb79851e278b7973031b9ca363da87a7e] perf core: Allow 
setting up max frame stack depth via sysctl
git bisect good c2a218c63ba36946aca5943c0c8ebd3a42e3dc4b  # 08:06910+  
0  perf bench: Remove one more die() call
# extra tests with CONFIG_DEBUG_INFO_REDUCED
git bisect  bad c5dfd78eb79851e278b7973031b9ca363da87a7e  # 08:10  0-  
3  perf core: Allow setting up max frame stack depth via sysctl
# extra tests on HEAD of linux-devel/devel-hourly-2016062414
git bisect  bad e8d665056895dafedd7882bfe250ff6cf7dfbc0d  # 08:10  0- 
53  0day head guard for 'devel-hourly-2016062414'
# extra tests on tree/branch linus/master
git bisect  bad 63c04ee7d3b7c8d8e2726cb7c5f8a5f6fcc1e3b2  # 08:22  0-  
3  Merge tag 'upstream-4.7-rc5' of git://git.infradead.org/linux-ubifs
# extra tests on tree/branch linus/master
git bisect  bad 63c04ee7d3b7c8d8e2726cb7c5f8a5f6fcc1e3b2  # 08:23  0-  
5  Merge tag 'upstream-4.7-rc5' of git://git.infradead.org/linux-ubifs
# extra tests on tree/branch linux-next/master
git bisect  bad 2cf991dfda8b36d2878c249bcdf492366ec24c19  # 08:29 14-  
1  Add linux-next specific files for 20160624


This script may reproduce the error.


#!/bin/bash

kernel=$1
initrd=quantal-core-i386.cgz

wget --no-clobber 
https://github.com/fengguang/reproduce-kernel-bug/raw/master/initrd/$initrd

kvm=(
qemu-system-x86_64
-enable-kvm
-cpu kvm64
-kernel $kernel
-initrd $initrd
-m 300
-smp 2
-device e1000,netdev=net0
-netdev user,id=net0
-boot order=nc
-no-reboot
-watchdog i6300esb
-rtc base=localtime
-serial stdio
-display none
-monitor null 
)

append=(
hung_task_panic=1
earlyprintk=ttyS0,115200
systemd.log_level=err
debug
apic=debug
sysrq_always_enabled
rcupdate.rcu_cpu_stall_timeout=100
panic=-1
softlockup_panic=1
nmi_watchdog=panic
oops=panic
load_ramdisk=2
prompt_ramdisk=0
console=ttyS0,115200
console=tty0
vga=normal
root=/dev/ram0
rw
drbd.minor_count=8
)

"${kvm[@]}" --append "${append[*]}"


---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/lkp  Intel Corporation


dmesg-quantal-kbuild-53:20160625075710:i386-randconfig-h0-06242012:4.6.0-rc4-00181-gc5dfd78:1.gz
Description: application/gzip
#
# Automatically generated file; DO NOT EDIT.
# Linux/i386 4.6.0-rc4 Kernel Configuration
#
# CONFIG_64BIT is not set
CONFIG_X86_32=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf32-i386"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/i386_defconfig"
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_MMU=y
CONFIG_ARCH_MMAP_RND_BITS_MIN=8
CONFIG_ARCH_MMAP_RND_BITS_MAX=16
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_ARCH_HAS_CPU_RELAX=y
CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
CONFIG_HAVE_SETUP_PER_CPU_AREA=y
CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_X86_32_SMP=y
CONFIG_X86_32_LAZY_GS=y
CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-ecx -fcall-saved-edx"
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_DEBUG_RODATA=y
CONFIG_PGTABLE_LEVELS=2
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_CONSTRUCTORS=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y

#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
# CONFIG_COMPILE_TEST is not set
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
# CONFIG_KERNEL_GZIP is not set
CONFIG_KERNEL_BZIP2=y
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
# CONFIG_SYSVIPC is not set
# CONFIG_POSIX_MQUEUE is not set
# CONFIG_CROSS_MEMORY_ATTACH is not set
CONFIG_FHANDLE=y
# CONFIG_USELIB is not set
# CONFIG_AUDIT is not set
CONFIG_HAVE_ARCH_AUDITSYS

Re: [PATCH v3] of: fix memory leak related to safe_name()

2016-06-24 Thread Rob Herring
On Fri, Jun 17, 2016 at 2:51 AM, Mathieu Malaterre
 wrote:
> v3 tested here multiple times ! memleak is now gone.
>
> Tested-by: Mathieu Malaterre 
>
> Thanks
>
> On Thu, Jun 16, 2016 at 7:51 PM, Frank Rowand  wrote:
>> From: Frank Rowand 
>>
>> Fix a memory leak resulting from memory allocation in safe_name().
>> This patch fixes all call sites of safe_name().

Applied, thanks.

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

Re: [PATCH v2] cpuidle: Fix last_residency division

2016-06-24 Thread Arnd Bergmann
On Friday, June 24, 2016 9:31:35 PM CEST Shreyas B Prabhu wrote:
> > If those functions are called less often than cpuidle_enter_state(),
> > we could just move the division there. Since the divisor is constant,
> > do_div() can convert it into a multiply and shift, or we could use
> > your the code you suggest above, or use a 32-bit division most of
> > the time:
> > 
> >   if (diff <= UINT_MAX)
> >   diff_32 = (u32)diff / NSECS_PER_USEC;
> >   else
> >   diff_32 = div_u64(diff, NSECS_PER_USEC;
> > 
> > which gcc itself will turn into a multiplication or series of
> > shifts on CPUs on which that is faster.
> >
> I'm not sure which division method of the three suggested here to use.
> Does anyone have a strong preference?
> 

It depends on how accurate we want it and how long we expect
the times to be. The optimization for the 4.2 second cutoff
for doing a 32-bit division only makes sense if the majority
of the sleep times are below that.

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

[PATCH] powerpc/fadump: trivial fix of spelling mistake, clean up message

2016-06-24 Thread Colin King
From: Colin Ian King 

trivial fix to spelling mistake "rgistration" and minor clean up
of the printk error message

Signed-off-by: Colin Ian King 
---
 arch/powerpc/kernel/fadump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 3cb3b02a..0358f5b 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -1010,7 +1010,7 @@ static int fadump_invalidate_dump(struct 
fadump_mem_struct *fdm)
 
if (rc) {
printk(KERN_ERR "Failed to invalidate firmware-assisted dump "
-   "rgistration. unexpected error(%d).\n", rc);
+   "registration. Unexpected error (%d).\n", rc);
return rc;
}
fw_dump.dump_active = 0;
-- 
2.8.1

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

Re: [v2,1/2] refactor code parsing size based on memory range

2016-06-24 Thread Hari Bathini



On 06/24/2016 10:56 AM, Michael Ellerman wrote:

On Wed, 2016-22-06 at 19:25:26 UTC, Hari Bathini wrote:

Currently, crashkernel parameter supports the below syntax to parse size
based on memory range:

crashkernel=:[,:,...]

While such parsing is implemented for crashkernel parameter, it applies to
other parameters with similar syntax. So, move this code to a more generic
place for code reuse.

Cc: Eric Biederman 
Cc: Vivek Goyal 
Cc: Rusty Russell 
Cc: ke...@lists.infradead.org
Signed-off-by: Hari Bathini 

Hari, it's not immediately clear that this makes no change to the logic in the
kexec code. Can you reply with a longer change log explaining why the old & new
logic is the same for kexec.



Hi Michael,

Please consider this changelog for this patch:

--
crashkernel parameter supports different syntaxes to specify the amount
of memory to be reserved for kdump kernel. Below is one of the supported
syntaxes that needs parsing to find the memory size to reserve, based on
memory range:

crashkernel=:[,:,...]

While such parsing is implemented for crashkernel parameter, it applies to
other parameters, like fadump_reserve_mem, which could use similar syntax.
So, to reuse code, moving the code that checks if the parameter syntax is as
above and also the code that parses memory size to reserve, for this syntax.
While the code is moved to kernel/params.c file, there is no change in logic
for crashkernel parameter parsing as the moved code is invoked with function
calls at appropriate places.
--

Thanks
Hari





diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 94aa10f..72f55e5 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -436,6 +436,11 @@ extern char *get_options(const char *str, int nints, int 
*ints);
  extern unsigned long long memparse(const char *ptr, char **retptr);
  extern bool parse_option_str(const char *str, const char *option);
  
+extern bool __init is_param_range_based(const char *cmdline);

+extern unsigned long long __init parse_mem_range_size(const char *param,
+ char **str,
+ unsigned long long 
system_ram);
+
  extern int core_kernel_text(unsigned long addr);
  extern int core_kernel_data(unsigned long addr);
  extern int __kernel_text_address(unsigned long addr);
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 56b3ed0..d43f5cc 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -1083,59 +1083,9 @@ static int __init parse_crashkernel_mem(char *cmdline,
char *cur = cmdline, *tmp;
  
  	/* for each entry of the comma-separated list */

-   do {
-   unsigned long long start, end = ULLONG_MAX, size;
-
-   /* get the start of the range */
-   start = memparse(cur, );
-   if (cur == tmp) {
-   pr_warn("crashkernel: Memory value expected\n");
-   return -EINVAL;
-   }
-   cur = tmp;
-   if (*cur != '-') {
-   pr_warn("crashkernel: '-' expected\n");
-   return -EINVAL;
-   }
-   cur++;
-
-   /* if no ':' is here, than we read the end */
-   if (*cur != ':') {
-   end = memparse(cur, );
-   if (cur == tmp) {
-   pr_warn("crashkernel: Memory value expected\n");
-   return -EINVAL;
-   }
-   cur = tmp;
-   if (end <= start) {
-   pr_warn("crashkernel: end <= start\n");
-   return -EINVAL;
-   }
-   }
-
-   if (*cur != ':') {
-   pr_warn("crashkernel: ':' expected\n");
-   return -EINVAL;
-   }
-   cur++;
-
-   size = memparse(cur, );
-   if (cur == tmp) {
-   pr_warn("Memory value expected\n");
-   return -EINVAL;
-   }
-   cur = tmp;
-   if (size >= system_ram) {
-   pr_warn("crashkernel: invalid size\n");
-   return -EINVAL;
-   }
-
-   /* match ? */
-   if (system_ram >= start && system_ram < end) {
-   *crash_size = size;
-   break;
-   }
-   } while (*cur++ == ',');
+   *crash_size = parse_mem_range_size("crashkernel", , system_ram);
+   if (cur == cmdline)
+   return -EINVAL;
  
  	if (*crash_size > 0) {

while (*cur && *cur != ' ' && *cur != '@')
@@ -1272,7 +1222,6 @@ static int __init __parse_crashkernel(char *cmdline,
   

Re: [PATCH v2] cpuidle: Fix last_residency division

2016-06-24 Thread Shreyas B Prabhu


On 06/24/2016 03:41 PM, Arnd Bergmann wrote:
> On Friday, June 24, 2016 9:00:48 AM CEST David Laight wrote:
>> The intent of the >> 10 was probably to avoid an expensive 64bit divide.
>> So maybe something like:
>> diff = time_end - time_start;
>> if (diff >= INT_MAX/2)
>> diff_32 = INT_MAX/2/1000;
>> else
>> diff_32 = diff;
>> diff_32 += diff_32 >> 6;
>> diff_32 >>= 10;
>> }
>>
>> Adding an extra 1/32 makes the division by be something slightly below 1000.
> 
> Why not change the definition of the time to nanoseconds and update
> the users accordingly?
> 
> I see that cpuidle_enter_state() writes to the last_residency value,
> and it is read in three places: ladder_select_state(), menu_update()
> and show_state_time() (for sysfs).
> 

Updating show_state_time() to convert ns to us gets bit messy since
show_state_##_name which is used for disable, usage and time simply
returns state_usage->_name. And state_usage->time updation happens in
cpuidle_enter_state() itself.

> If those functions are called less often than cpuidle_enter_state(),
> we could just move the division there. Since the divisor is constant,
> do_div() can convert it into a multiply and shift, or we could use
> your the code you suggest above, or use a 32-bit division most of
> the time:
> 
>   if (diff <= UINT_MAX)
>   diff_32 = (u32)diff / NSECS_PER_USEC;
>   else
>   diff_32 = div_u64(diff, NSECS_PER_USEC;
> 
> which gcc itself will turn into a multiplication or series of
> shifts on CPUs on which that is faster.
>
I'm not sure which division method of the three suggested here to use.
Does anyone have a strong preference?

--Shreyas

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

[PATCH] cpufreq: powernv: Replacing pstate_id with frequency table index

2016-06-24 Thread Akshay Adiga
Refactoring code to use frequency table index instead of pstate_id.
This abstraction will make the code independent of the pstate values.

- No functional changes
- The highest frequency is at frequency table index 0 and the frequency
  decreases as the index increases.
- Macros get_index() and get_pstate() can be used for conversion between
  pstate_id and index.
- powernv_pstate_info now contains frequency table index to min, max and
  nominal frequency (instead of pstate_ids)

Signed-off-by: Akshay Adiga 
---
 drivers/cpufreq/powernv-cpufreq.c | 107 ++
 1 file changed, 61 insertions(+), 46 deletions(-)

diff --git a/drivers/cpufreq/powernv-cpufreq.c 
b/drivers/cpufreq/powernv-cpufreq.c
index b29c5c2..f6ce6f0 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -43,6 +43,7 @@
 #define PMSR_SPR_EM_DISABLE(1UL << 31)
 #define PMSR_MAX(x)((x >> 32) & 0xFF)
 
+
 #define MAX_RAMP_DOWN_TIME 5120
 /*
  * On an idle system we want the global pstate to ramp-down from max value to
@@ -124,20 +125,29 @@ static int nr_chips;
 static DEFINE_PER_CPU(struct chip *, chip_info);
 
 /*
- * Note: The set of pstates consists of contiguous integers, the
- * smallest of which is indicated by powernv_pstate_info.min, the
- * largest of which is indicated by powernv_pstate_info.max.
+ * Note: The set of pstates consists of contiguous integers,
+ *
+ * powernv_pstate_info stores the index of the frequency table
+ *  instead of pstate itself for each of the pstates referred
  *
  * The nominal pstate is the highest non-turbo pstate in this
  * platform. This is indicated by powernv_pstate_info.nominal.
  */
 static struct powernv_pstate_info {
-   int min;
-   int max;
-   int nominal;
-   int nr_pstates;
+   unsigned int min;
+   unsigned int max;
+   unsigned int nominal;
+   unsigned int nr_pstates;
 } powernv_pstate_info;
 
+/* Use following macros for conversions between pstate_id and index */
+static inline int get_pstate(unsigned int i) {
+   return powernv_freqs[i].driver_data;
+}
+static inline unsigned int get_index(int pstate) {
+   return abs(pstate - get_pstate(powernv_pstate_info.max));
+}
+
 static inline void reset_gpstates(struct cpufreq_policy *policy)
 {
struct global_pstate_info *gpstates = policy->driver_data;
@@ -208,23 +218,28 @@ static int init_powernv_pstates(void)
return -ENODEV;
}
 
+   powernv_pstate_info.nr_pstates = nr_pstates;
pr_debug("NR PStates %d\n", nr_pstates);
for (i = 0; i < nr_pstates; i++) {
u32 id = be32_to_cpu(pstate_ids[i]);
u32 freq = be32_to_cpu(pstate_freqs[i]);
 
-   pr_debug("PState id %d freq %d MHz\n", id, freq);
powernv_freqs[i].frequency = freq * 1000; /* kHz */
powernv_freqs[i].driver_data = id;
+
+   if (id == pstate_max)
+   powernv_pstate_info.max = i;
+   else if (id == pstate_nominal)
+   powernv_pstate_info.nominal = i;
+   else if (id == pstate_min)
+   powernv_pstate_info.min = i;
}
+
+   pr_info("pstate_info: min %d nominal %d max %d\n",
+   powernv_pstate_info.min, powernv_pstate_info.nominal,
+   powernv_pstate_info.max);
/* End of list marker entry */
powernv_freqs[i].frequency = CPUFREQ_TABLE_END;
-
-   powernv_pstate_info.min = pstate_min;
-   powernv_pstate_info.max = pstate_max;
-   powernv_pstate_info.nominal = pstate_nominal;
-   powernv_pstate_info.nr_pstates = nr_pstates;
-
return 0;
 }
 
@@ -233,15 +248,15 @@ static unsigned int pstate_id_to_freq(int pstate_id)
 {
int i;
 
-   i = powernv_pstate_info.max - pstate_id;
+   i = get_index(pstate_id);
if (i >= powernv_pstate_info.nr_pstates || i < 0) {
pr_warn("PState id %d outside of PState table, "
"reporting nominal id %d instead\n",
pstate_id, powernv_pstate_info.nominal);
-   i = powernv_pstate_info.max - powernv_pstate_info.nominal;
+   i = powernv_pstate_info.nominal;
}
 
-   return powernv_freqs[i].frequency;
+   return get_pstate(i);
 }
 
 /*
@@ -252,7 +267,7 @@ static ssize_t cpuinfo_nominal_freq_show(struct 
cpufreq_policy *policy,
char *buf)
 {
return sprintf(buf, "%u\n",
-   pstate_id_to_freq(powernv_pstate_info.nominal));
+   get_pstate(powernv_pstate_info.nominal));
 }
 
 struct freq_attr cpufreq_freq_attr_cpuinfo_nominal_freq =
@@ -426,7 +441,7 @@ static void set_pstate(void *data)
  */
 static inline unsigned int get_nominal_index(void)
 {
-   return powernv_pstate_info.max - powernv_pstate_info.nominal;
+   

[PATCH v2] powerpc/boot: Add OPAL console to epapr wrappers

2016-06-24 Thread Oliver O'Halloran
This patch adds an OPAL console backend to the powerpc boot wrapper so
that decompression failures inside the wrapper can be reported to the
user. This is important since it typically indicates data corruption in
the firmware and other nasty things.

Currently this only works when building a little endian kernel. When
compiling a 64 bit BE kernel the wrapper is always build 32 bit to be
compatible with some 32 bit firmwares. BE support will be added at a
later date. Another limitation of this is that only the "raw" type of
OPAL console is supported, however machines that provide a hvsi console
also provide a raw console so this is not an issue in practice.

Actually-written-by: Benjamin Herrenschmidt 
Signed-off-by: Oliver O'Halloran 
Cc: Stewart Smith 
Cc: sta...@vger.kernel.org
---
 arch/powerpc/boot/Makefile |  4 +-
 arch/powerpc/boot/opal-calls.S | 49 +++
 arch/powerpc/boot/opal.c   | 88 ++
 arch/powerpc/boot/ops.h|  1 +
 arch/powerpc/boot/ppc_asm.h|  4 ++
 arch/powerpc/boot/serial.c |  2 +
 arch/powerpc/boot/types.h  | 12 ++
 7 files changed, 158 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/boot/opal-calls.S
 create mode 100644 arch/powerpc/boot/opal.c

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 8fe78a3efc92..00cf88aa9a23 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -70,7 +70,7 @@ $(addprefix $(obj)/,$(zlib) cuboot-c2k.o gunzip_util.o 
main.o): \
 libfdt   := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c
 libfdtheader := fdt.h libfdt.h libfdt_internal.h
 
-$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o): \
+$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o): \
$(addprefix $(obj)/,$(libfdtheader))
 
 src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
@@ -78,7 +78,7 @@ src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
ns16550.c serial.c simple_alloc.c div64.S util.S \
gunzip_util.c elf_util.c $(zlib) devtree.c stdlib.c \
oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \
-   uartlite.c mpc52xx-psc.c
+   uartlite.c mpc52xx-psc.c opal.c opal-calls.S
 src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
 src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
 src-wlib-$(CONFIG_8xx) += mpc8xx.c planetcore.c fsl-soc.c
diff --git a/arch/powerpc/boot/opal-calls.S b/arch/powerpc/boot/opal-calls.S
new file mode 100644
index ..1f3c097e1552
--- /dev/null
+++ b/arch/powerpc/boot/opal-calls.S
@@ -0,0 +1,49 @@
+#include "ppc_asm.h"
+#include "../include/asm/opal-api.h"
+
+   .text
+
+#define OPAL_CALL(name, token) \
+   .globl name;\
+name:  \
+   li  r0, token;  \
+   b   opal_call;
+
+opal_call:
+   mflrr11
+   std r11,16(r1)
+   mfcrr12
+   stw r12,8(r1)
+   mr  r13,r2
+
+   /* Set opal return address */
+   ld  r11,opal_return@got(r2)
+   mtlrr11
+   mfmsr   r12
+
+   /* switch to BE when we enter OPAL */
+   li  r11,MSR_LE
+   andcr12,r12,r11
+   mtspr   SPRN_HSRR1,r12
+
+   /* load the opal call entry point and base */
+   ld  r11,opal@got(r2)
+   ld  r12,8(r11)
+   ld  r2,0(r11)
+   mtspr   SPRN_HSRR0,r12
+   hrfid
+
+opal_return:
+   FIXUP_ENDIAN
+   mr  r2,r13;
+   lwz r11,8(r1);
+   ld  r12,16(r1)
+   mtcrr11;
+   mtlrr12
+   blr
+
+OPAL_CALL(opal_console_write,  OPAL_CONSOLE_WRITE);
+OPAL_CALL(opal_console_read,   OPAL_CONSOLE_READ);
+OPAL_CALL(opal_console_write_buffer_space, 
OPAL_CONSOLE_WRITE_BUFFER_SPACE);
+OPAL_CALL(opal_poll_events,OPAL_POLL_EVENTS);
+OPAL_CALL(opal_console_flush,  OPAL_CONSOLE_FLUSH);
diff --git a/arch/powerpc/boot/opal.c b/arch/powerpc/boot/opal.c
new file mode 100644
index ..d0f54443caa9
--- /dev/null
+++ b/arch/powerpc/boot/opal.c
@@ -0,0 +1,88 @@
+#include "ops.h"
+#include "stdio.h"
+#include "io.h"
+#include 
+#include "../include/asm/opal-api.h"
+
+/* Global OPAL struct used by opal-call.S */
+struct opal {
+   u64 base;
+   u64 entry;
+} opal;
+
+static u32 opal_con_id;
+
+int64_t opal_console_write(int64_t term_number, u64 *length, const u8 *buffer);
+int64_t opal_console_read(int64_t term_number, uint64_t *length, u8 *buffer);
+int64_t opal_console_write_buffer_space(uint64_t term_number, uint64_t 
*length);
+int64_t opal_console_flush(uint64_t term_number);
+int64_t opal_poll_events(uint64_t *outstanding_event_mask);
+
+static int opal_con_open(void)
+{
+  

Re: [PATCH] powerpc/boot: Add OPAL console to epapr wrappers

2016-06-24 Thread oliver
It would appear I did. Oh well, shouldn't have been in such a rush to
get to the pub.

On Fri, Jun 24, 2016 at 9:57 PM, Benjamin Herrenschmidt
 wrote:
> On Fri, 2016-06-24 at 17:41 +1000, Oliver O'Halloran wrote:
>> This patch adds an OPAL console backend to the powerpc boot wrapper
>> so
>> that decompression failures inside the wrapper can be reported to the
>> user. This is important since it typically indicates data corruption
>> in
>> the firmware and other nasty things.
>>
>> Currently this only works when building a little endian kernel. When
>> compiling a 64 bit BE kernel the wrapper is always build 32 bit to be
>> compatible with some 32 bit firmwares. BE support will be added at a
>> later date. Another limitation of this is that only the "raw" type of
>> OPAL console is supported, however machines that provide a hvsi
>> console
>> also provide a raw console so this is not an issue in practice.
>
> You forgot to git-add the new files ?
>
> Cheers,
> Ben.
>
>> Actually-written-by: Benjamin Herrenschmidt > >
>> Signed-off-by: Oliver O'Halloran 
>> Cc: Stewart Smith 
>> Cc: sta...@vger.kernel.org
>> ---
>>  arch/powerpc/boot/Makefile  |  4 ++--
>>  arch/powerpc/boot/ops.h |  1 +
>>  arch/powerpc/boot/ppc_asm.h |  4 
>>  arch/powerpc/boot/serial.c  |  2 ++
>>  arch/powerpc/boot/types.h   | 12 
>>  5 files changed, 21 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
>> index 8fe78a3efc92..00cf88aa9a23 100644
>> --- a/arch/powerpc/boot/Makefile
>> +++ b/arch/powerpc/boot/Makefile
>> @@ -70,7 +70,7 @@ $(addprefix $(obj)/,$(zlib) cuboot-c2k.o
>> gunzip_util.o main.o): \
>>  libfdt   := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c
>> fdt_strerror.c
>>  libfdtheader := fdt.h libfdt.h libfdt_internal.h
>>
>> -$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o
>> epapr.o): \
>> +$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o
>> opal.o): \
>>   $(addprefix $(obj)/,$(libfdtheader))
>>
>>  src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
>> @@ -78,7 +78,7 @@ src-wlib-y := string.S crt0.S crtsavres.S stdio.c
>> main.c \
>>   ns16550.c serial.c simple_alloc.c div64.S util.S \
>>   gunzip_util.c elf_util.c $(zlib) devtree.c stdlib.c
>> \
>>   oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \
>> - uartlite.c mpc52xx-psc.c
>> + uartlite.c mpc52xx-psc.c opal.c opal-calls.S
>>  src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
>>  src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
>>  src-wlib-$(CONFIG_8xx) += mpc8xx.c planetcore.c fsl-soc.c
>> diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
>> index 5e75e1c5518e..e19b64ef977a 100644
>> --- a/arch/powerpc/boot/ops.h
>> +++ b/arch/powerpc/boot/ops.h
>> @@ -89,6 +89,7 @@ int mpsc_console_init(void *devp, struct
>> serial_console_data *scdp);
>>  int cpm_console_init(void *devp, struct serial_console_data *scdp);
>>  int mpc5200_psc_console_init(void *devp, struct serial_console_data
>> *scdp);
>>  int uartlite_console_init(void *devp, struct serial_console_data
>> *scdp);
>> +int opal_console_init(void *devp, struct serial_console_data *scdp);
>>  void *simple_alloc_init(char *base, unsigned long heap_size,
>>   unsigned long granularity, unsigned long
>> max_allocs);
>>  extern void flush_cache(void *, unsigned long);
>> diff --git a/arch/powerpc/boot/ppc_asm.h
>> b/arch/powerpc/boot/ppc_asm.h
>> index 35ea60c1f070..b03373d8b386 100644
>> --- a/arch/powerpc/boot/ppc_asm.h
>> +++ b/arch/powerpc/boot/ppc_asm.h
>> @@ -61,6 +61,10 @@
>>
>>  #define SPRN_TBRL268
>>  #define SPRN_TBRU269
>> +#define SPRN_HSRR0   0x13A   /* Hypervisor Save/Restore 0
>> */
>> +#define SPRN_HSRR1   0x13B   /* Hypervisor Save/Restore 1
>> */
>> +
>> +#define MSR_LE   0x0001
>>
>>  #define FIXUP_ENDIAN
>>\
>>   tdi   0, 0, 0x48; /* Reverse endian of b . + 8
>> */ \
>> diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
>> index 167ee9433de6..e04c1e4063ae 100644
>> --- a/arch/powerpc/boot/serial.c
>> +++ b/arch/powerpc/boot/serial.c
>> @@ -132,6 +132,8 @@ int serial_console_init(void)
>>   else if (dt_is_compatible(devp, "xlnx,opb-uartlite-1.00.b")
>> ||
>>dt_is_compatible(devp, "xlnx,xps-uartlite-1.00.a"))
>>   rc = uartlite_console_init(devp, _cd);
>> + else if (dt_is_compatible(devp, "ibm,opal-console-raw"))
>> + rc = opal_console_init(devp, _cd);
>>
>>   /* Add other serial console driver calls here */
>>
>> diff --git a/arch/powerpc/boot/types.h b/arch/powerpc/boot/types.h
>> index 31393d17a9c1..cda474cd63c8 100644
>> --- a/arch/powerpc/boot/types.h
>> +++ b/arch/powerpc/boot/types.h
>> @@ -12,6 +12,18 @@ typedef short  s16;
>>  typedef int  

Re: [PATCH v2] cpuidle: Fix last_residency division

2016-06-24 Thread kbuild test robot
Hi,

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.7-rc4 next-20160623]
[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/Shreyas-B-Prabhu/cpuidle-Fix-last_residency-division/20160624-162633
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
config: arm-multi_v5_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `cpuidle_enter_state':
>> drivers/cpuidle/cpuidle.c:224: undefined reference to `__aeabi_uldivmod'

vim +224 drivers/cpuidle/cpuidle.c

   218  local_irq_enable();
   219  
   220  /*
   221   * local_clock() returns the time in nanosecond, let's
   222   * divide by 1000 to have microsecond based time.
   223   */
 > 224  diff = (time_end - time_start) / 1000;
   225  if (diff > INT_MAX)
   226  diff = INT_MAX;
   227  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc/boot: Add OPAL console to epapr wrappers

2016-06-24 Thread Benjamin Herrenschmidt
On Fri, 2016-06-24 at 17:41 +1000, Oliver O'Halloran wrote:
> This patch adds an OPAL console backend to the powerpc boot wrapper
> so
> that decompression failures inside the wrapper can be reported to the
> user. This is important since it typically indicates data corruption
> in
> the firmware and other nasty things.
> 
> Currently this only works when building a little endian kernel. When
> compiling a 64 bit BE kernel the wrapper is always build 32 bit to be
> compatible with some 32 bit firmwares. BE support will be added at a
> later date. Another limitation of this is that only the "raw" type of
> OPAL console is supported, however machines that provide a hvsi
> console
> also provide a raw console so this is not an issue in practice.

You forgot to git-add the new files ?

Cheers,
Ben.

> Actually-written-by: Benjamin Herrenschmidt  >
> Signed-off-by: Oliver O'Halloran 
> Cc: Stewart Smith 
> Cc: sta...@vger.kernel.org
> ---
>  arch/powerpc/boot/Makefile  |  4 ++--
>  arch/powerpc/boot/ops.h |  1 +
>  arch/powerpc/boot/ppc_asm.h |  4 
>  arch/powerpc/boot/serial.c  |  2 ++
>  arch/powerpc/boot/types.h   | 12 
>  5 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 8fe78a3efc92..00cf88aa9a23 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -70,7 +70,7 @@ $(addprefix $(obj)/,$(zlib) cuboot-c2k.o
> gunzip_util.o main.o): \
>  libfdt   := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c
> fdt_strerror.c
>  libfdtheader := fdt.h libfdt.h libfdt_internal.h
>  
> -$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o
> epapr.o): \
> +$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o
> opal.o): \
>   $(addprefix $(obj)/,$(libfdtheader))
>  
>  src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
> @@ -78,7 +78,7 @@ src-wlib-y := string.S crt0.S crtsavres.S stdio.c
> main.c \
>   ns16550.c serial.c simple_alloc.c div64.S util.S \
>   gunzip_util.c elf_util.c $(zlib) devtree.c stdlib.c
> \
>   oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \
> - uartlite.c mpc52xx-psc.c
> + uartlite.c mpc52xx-psc.c opal.c opal-calls.S
>  src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
>  src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
>  src-wlib-$(CONFIG_8xx) += mpc8xx.c planetcore.c fsl-soc.c
> diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
> index 5e75e1c5518e..e19b64ef977a 100644
> --- a/arch/powerpc/boot/ops.h
> +++ b/arch/powerpc/boot/ops.h
> @@ -89,6 +89,7 @@ int mpsc_console_init(void *devp, struct
> serial_console_data *scdp);
>  int cpm_console_init(void *devp, struct serial_console_data *scdp);
>  int mpc5200_psc_console_init(void *devp, struct serial_console_data
> *scdp);
>  int uartlite_console_init(void *devp, struct serial_console_data
> *scdp);
> +int opal_console_init(void *devp, struct serial_console_data *scdp);
>  void *simple_alloc_init(char *base, unsigned long heap_size,
>   unsigned long granularity, unsigned long
> max_allocs);
>  extern void flush_cache(void *, unsigned long);
> diff --git a/arch/powerpc/boot/ppc_asm.h
> b/arch/powerpc/boot/ppc_asm.h
> index 35ea60c1f070..b03373d8b386 100644
> --- a/arch/powerpc/boot/ppc_asm.h
> +++ b/arch/powerpc/boot/ppc_asm.h
> @@ -61,6 +61,10 @@
>  
>  #define SPRN_TBRL268
>  #define SPRN_TBRU269
> +#define SPRN_HSRR0   0x13A   /* Hypervisor Save/Restore 0
> */
> +#define SPRN_HSRR1   0x13B   /* Hypervisor Save/Restore 1
> */
> +
> +#define MSR_LE   0x0001
>  
>  #define FIXUP_ENDIAN 
>    \
>   tdi   0, 0, 0x48; /* Reverse endian of b . + 8  
> */ \
> diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
> index 167ee9433de6..e04c1e4063ae 100644
> --- a/arch/powerpc/boot/serial.c
> +++ b/arch/powerpc/boot/serial.c
> @@ -132,6 +132,8 @@ int serial_console_init(void)
>   else if (dt_is_compatible(devp, "xlnx,opb-uartlite-1.00.b")
> ||
>    dt_is_compatible(devp, "xlnx,xps-uartlite-1.00.a"))
>   rc = uartlite_console_init(devp, _cd);
> + else if (dt_is_compatible(devp, "ibm,opal-console-raw"))
> + rc = opal_console_init(devp, _cd);
>  
>   /* Add other serial console driver calls here */
>  
> diff --git a/arch/powerpc/boot/types.h b/arch/powerpc/boot/types.h
> index 31393d17a9c1..cda474cd63c8 100644
> --- a/arch/powerpc/boot/types.h
> +++ b/arch/powerpc/boot/types.h
> @@ -12,6 +12,18 @@ typedef short  s16;
>  typedef int  s32;
>  typedef long longs64;
>  
> +
> +/* required for opal-api.h */
> +typedef u8  uint8_t;
> +typedef u16 uint16_t;
> +typedef u32 uint32_t;
> +typedef u64 uint64_t;
> +typedef s8  int8_t;
> +typedef s16 int16_t;
> 

[PATCH/RFC] powerpc/pci: Don't try to allocate resources that will be reassigned

2016-06-24 Thread Benjamin Herrenschmidt
When we know we will reassign all resources, trying (and failing)
to allocate them initially is fairly pointless and leads to a lot
of scary messages in the kernel log

Signed-off-by: Benjamin Herrenschmidt 
---
 arch/powerpc/kernel/pci-common.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 0f7a60f..2a67b16 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1362,8 +1362,10 @@ void __init pcibios_resource_survey(void)
/* Allocate and assign resources */
list_for_each_entry(b, _root_buses, node)
pcibios_allocate_bus_resources(b);
-   pcibios_allocate_resources(0);
-   pcibios_allocate_resources(1);
+   if (!pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
+   pcibios_allocate_resources(0);
+   pcibios_allocate_resources(1);
+   }
 
/* Before we start assigning unassigned resource, we try to reserve
 * the low IO area and the VGA memory area if they intersect the


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

Re: [RFC/PATCH] powerpc/pci: Don't try to allocate resources that will be reassigned

2016-06-24 Thread Benjamin Herrenschmidt
On Wed, 2016-06-22 at 17:24 +1000, Benjamin Herrenschmidt wrote:
> When we know we will reassign all resources, trying (and failing)
> to allocate them initially is fairly pointless and leads to a lot
> of scary messages in the kernel log
> 
> Signed-off-by: Benjamin Herrenschmidt 
> --
> 
> This one probably needs testing on a few platforms but I think it's
> correct ;-)

The patch is crap, it was against one of my trees that has not the
right code in it. I'll post the real one as v2

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

Re: [PATCH v2] cpuidle: Fix last_residency division

2016-06-24 Thread kbuild test robot
Hi,

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.7-rc4 next-20160624]
[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/Shreyas-B-Prabhu/cpuidle-Fix-last_residency-division/20160624-162633
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
config: sh-sh7785lcr_32bit_defconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `cpuidle_enter_state':
>> drivers/cpuidle/cpuidle.c:242: undefined reference to `__udivdi3'

vim +242 drivers/cpuidle/cpuidle.c

56cfbf74a Colin Cross2012-05-07  236
dev->states_usage[entered_state].usage++;
56cfbf74a Colin Cross2012-05-07  237} else {
56cfbf74a Colin Cross2012-05-07  238dev->last_residency = 0;
56cfbf74a Colin Cross2012-05-07  239}
56cfbf74a Colin Cross2012-05-07  240  
56cfbf74a Colin Cross2012-05-07  241return entered_state;
56cfbf74a Colin Cross2012-05-07 @242  }
56cfbf74a Colin Cross2012-05-07  243  
56cfbf74a Colin Cross2012-05-07  244  /**
907e30f1b Daniel Lezcano 2014-03-03  245   * cpuidle_select - ask the cpuidle 
framework to choose an idle state

:: The code at line 242 was first introduced by commit
:: 56cfbf74a17c40f3a741398103c9f5d5a6806715 cpuidle: refactor out 
cpuidle_enter_state

:: TO: Colin Cross <ccr...@android.com>
:: CC: Len Brown <len.br...@intel.com>

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2] cpuidle: Fix last_residency division

2016-06-24 Thread Arnd Bergmann
On Friday, June 24, 2016 9:00:48 AM CEST David Laight wrote:
> The intent of the >> 10 was probably to avoid an expensive 64bit divide.
> So maybe something like:
> diff = time_end - time_start;
> if (diff >= INT_MAX/2)
> diff_32 = INT_MAX/2/1000;
> else
> diff_32 = diff;
> diff_32 += diff_32 >> 6;
> diff_32 >>= 10;
> }
> 
> Adding an extra 1/32 makes the division by be something slightly below 1000.

Why not change the definition of the time to nanoseconds and update
the users accordingly?

I see that cpuidle_enter_state() writes to the last_residency value,
and it is read in three places: ladder_select_state(), menu_update()
and show_state_time() (for sysfs).

If those functions are called less often than cpuidle_enter_state(),
we could just move the division there. Since the divisor is constant,
do_div() can convert it into a multiply and shift, or we could use
your the code you suggest above, or use a 32-bit division most of
the time:

if (diff <= UINT_MAX)
diff_32 = (u32)diff / NSECS_PER_USEC;
else
diff_32 = div_u64(diff, NSECS_PER_USEC;

which gcc itself will turn into a multiplication or series of
shifts on CPUs on which that is faster.

Arnd

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

Re: [PATCH v2] cpuidle: Fix last_residency division

2016-06-24 Thread Daniel Lezcano

On 06/24/2016 11:00 AM, David Laight wrote:

From: Shreyas B. Prabhu

Sent: 24 June 2016 09:24

Snooze is a poll idle state in powernv and pseries platforms. Snooze
has a timeout so that if a cpu stays in snooze for more than target
residency of the next available idle state, then it would exit thereby
giving chance to the cpuidle governor to re-evaluate and
promote the cpu to a deeper idle state. Therefore whenever snooze exits
due to this timeout, its last_residency will be target_residency of next
deeper state.

commit e93e59ce5b85 ("cpuidle: Replace ktime_get() with local_clock()")
changed the math around last_residency calculation. Specifically, while
converting last_residency value from nanoseconds to microseconds it does
right shift by 10. Due to this, in snooze timeout exit scenarios
last_residency calculated is roughly 2.3% less than target_residency of
next available state. This pattern is picked up get_typical_interval()
in the menu governor and therefore expected_interval in menu_select() is
frequently less than the target_residency of any state but snooze.

Due to this we are entering snooze at a higher rate, thereby affecting
the single thread performance.

Fix this by replacing right shift by 10 with /1000 while calculating
last_residency.

Reported-by: Anton Blanchard 
Bisected-by: Shilpasri G Bhat 
Signed-off-by: Shreyas B. Prabhu 
---
Changes in v2
=
  - Fixing it in the cpuidle core code instead of driver code.

  drivers/cpuidle/cpuidle.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index a4d0059..30d67a8 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -218,10 +218,10 @@ int cpuidle_enter_state(struct cpuidle_device *dev, 
struct cpuidle_driver *drv,
local_irq_enable();

/*
-* local_clock() returns the time in nanosecond, let's shift
-* by 10 (divide by 1024) to have microsecond based time.
+* local_clock() returns the time in nanosecond, let's
+* divide by 1000 to have microsecond based time.
 */
-   diff = (time_end - time_start) >> 10;
+   diff = (time_end - time_start) / 1000;


do_div ?


if (diff > INT_MAX)
diff = INT_MAX;


The intent of the >> 10 was probably to avoid an expensive 64bit divide.
So maybe something like:
diff = time_end - time_start;
if (diff >= INT_MAX/2)
diff_32 = INT_MAX/2/1000;
else
diff_32 = diff;
diff_32 += diff_32 >> 6;
diff_32 >>= 10;
}

Adding an extra 1/32 makes the division by be something slightly below 1000.




--
  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:   Facebook |
 Twitter |
 Blog

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

Re: [PATCH 1/4] kvm/ppc/book3s_hv: Change vcore element runnable_threads from linked-list to array

2016-06-24 Thread Paul Mackerras
On Wed, Jun 15, 2016 at 07:21:05PM +1000, Suraj Jitindar Singh wrote:
> The struct kvmppc_vcore is a structure used to store various information
> about a virtual core for a kvm guest. The runnable_threads element of the
> struct provides a list of all of the currently runnable vcpus on the core
> (those in the KVMPPC_VCPU_RUNNABLE state). The previous implementation of
> this list was a linked_list. The next patch requires that the list be able
> to be iterated over without holding the vcore lock.
> 
> Reimplement the runnable_threads list in the kvmppc_vcore struct as an
> array. Implement function to iterate over valid entries in the array and
> update access sites accordingly.
> 
> Signed-off-by: Suraj Jitindar Singh 

Unfortunately I get a compile error when compiling for either a 32-bit
powerpc config (e.g. pmac32_defconfig with KVM turned on) or a Book E
config.  The error is:

In file included from /home/paulus/kernel/kvm/include/linux/kvm_host.h:36:0,
 from 
/home/paulus/kernel/kvm/arch/powerpc/kernel/asm-offsets.c:54:
/home/paulus/kernel/kvm/arch/powerpc/include/asm/kvm_host.h:299:36: error: 
‘MAX_SMT_THREADS’ undeclared here (not in a function)
  struct kvm_vcpu *runnable_threads[MAX_SMT_THREADS];
^
/home/paulus/kernel/kvm/./Kbuild:81: recipe for target 
'arch/powerpc/kernel/asm-offsets.s' failed

You are using MAX_SMT_THREADS in kvm_host.h, but it is defined in
kvm_book3s_asm.h, which gets included by asm-offsets.c after it
include kvm_host.h.  I don't think we can just make kvm_host.h include
book3s.h.  The best solution might be to move the definition of struct
kvmppc_vcore to kvm_book3s.h.

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

Re: [PATCH] powerpc/boot: Add OPAL console to epapr wrappers

2016-06-24 Thread kbuild test robot
Hi,

[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.7-rc4 next-20160624]
[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/Oliver-O-Halloran/powerpc-boot-Add-OPAL-console-to-epapr-wrappers/20160624-154411
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/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 errors (new ones prefixed by >>):

>> make[2]: *** No rule to make target 'arch/powerpc/boot/opal-calls.S', needed 
>> by 'arch/powerpc/boot/opal-calls.o'.
>> make[2]: *** No rule to make target 'arch/powerpc/boot/opal.c', needed by 
>> 'arch/powerpc/boot/opal.o'.
   make[2]: Target 'arch/powerpc/boot/zImage' not remade because of errors.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2] cpuidle: Fix last_residency division

2016-06-24 Thread kbuild test robot
Hi,

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.7-rc4 next-20160624]
[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/Shreyas-B-Prabhu/cpuidle-Fix-last_residency-division/20160624-162633
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
config: i386-defconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `cpuidle_enter_state':
>> (.text+0x31e0d2): undefined reference to `__udivdi3'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 1/2] Powernv: Remove the usage of PACAR1 from opal wrappers

2016-06-24 Thread Paul Mackerras
On Sun, May 15, 2016 at 09:44:13AM +0530, Mahesh J Salgaonkar wrote:
> From: Mahesh Salgaonkar 
> 
> OPAL_CALL wrapper code sticks the r1 (stack pointer) into PACAR1 purely
> for debugging purpose only. The power7_wakeup* functions relies on stack
> pointer saved in PACAR1. Any opal call made using opal wrapper (directly
> or in-directly) before we fall through power7_wakeup*, then it ends up
> replacing r1 in PACAR1(r13) leading to kernel panic. So far we don't see
> any issues because we have never made any opal calls using OPAL wrapper
> before power7_wakeup*. But the subsequent HMI patch would need to invoke
> C calls during cpu wakeup/idle path that in-directly makes opal call using
> opal wrapper. This patch facilitates the subsequent HMI patch by removing
> usage of PACAR1 from opal call wrapper.
> 
> Signed-off-by: Mahesh Salgaonkar 
> Acked-by: Michael Ellerman 

Thanks, both patches applied to my kvm-ppc-next branch at
git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git.

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

RE: [PATCH v2] cpuidle: Fix last_residency division

2016-06-24 Thread David Laight
From: Shreyas B. Prabhu
> Sent: 24 June 2016 09:24
>
> Snooze is a poll idle state in powernv and pseries platforms. Snooze
> has a timeout so that if a cpu stays in snooze for more than target
> residency of the next available idle state, then it would exit thereby
> giving chance to the cpuidle governor to re-evaluate and
> promote the cpu to a deeper idle state. Therefore whenever snooze exits
> due to this timeout, its last_residency will be target_residency of next
> deeper state.
> 
> commit e93e59ce5b85 ("cpuidle: Replace ktime_get() with local_clock()")
> changed the math around last_residency calculation. Specifically, while
> converting last_residency value from nanoseconds to microseconds it does
> right shift by 10. Due to this, in snooze timeout exit scenarios
> last_residency calculated is roughly 2.3% less than target_residency of
> next available state. This pattern is picked up get_typical_interval()
> in the menu governor and therefore expected_interval in menu_select() is
> frequently less than the target_residency of any state but snooze.
> 
> Due to this we are entering snooze at a higher rate, thereby affecting
> the single thread performance.
> 
> Fix this by replacing right shift by 10 with /1000 while calculating
> last_residency.
> 
> Reported-by: Anton Blanchard 
> Bisected-by: Shilpasri G Bhat 
> Signed-off-by: Shreyas B. Prabhu 
> ---
> Changes in v2
> =
>  - Fixing it in the cpuidle core code instead of driver code.
> 
>  drivers/cpuidle/cpuidle.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index a4d0059..30d67a8 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -218,10 +218,10 @@ int cpuidle_enter_state(struct cpuidle_device *dev, 
> struct cpuidle_driver *drv,
>   local_irq_enable();
> 
>   /*
> -  * local_clock() returns the time in nanosecond, let's shift
> -  * by 10 (divide by 1024) to have microsecond based time.
> +  * local_clock() returns the time in nanosecond, let's
> +  * divide by 1000 to have microsecond based time.
>*/
> - diff = (time_end - time_start) >> 10;
> + diff = (time_end - time_start) / 1000;
>   if (diff > INT_MAX)
>   diff = INT_MAX;

The intent of the >> 10 was probably to avoid an expensive 64bit divide.
So maybe something like:
diff = time_end - time_start;
if (diff >= INT_MAX/2)
diff_32 = INT_MAX/2/1000;
else
diff_32 = diff;
diff_32 += diff_32 >> 6;
diff_32 >>= 10;
}

Adding an extra 1/32 makes the division by be something slightly below 1000.

David

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

[PATCH v2] cpuidle: Fix last_residency division

2016-06-24 Thread Shreyas B. Prabhu
Snooze is a poll idle state in powernv and pseries platforms. Snooze
has a timeout so that if a cpu stays in snooze for more than target
residency of the next available idle state, then it would exit thereby
giving chance to the cpuidle governor to re-evaluate and
promote the cpu to a deeper idle state. Therefore whenever snooze exits
due to this timeout, its last_residency will be target_residency of next
deeper state.

commit e93e59ce5b85 ("cpuidle: Replace ktime_get() with local_clock()")
changed the math around last_residency calculation. Specifically, while
converting last_residency value from nanoseconds to microseconds it does
right shift by 10. Due to this, in snooze timeout exit scenarios
last_residency calculated is roughly 2.3% less than target_residency of
next available state. This pattern is picked up get_typical_interval()
in the menu governor and therefore expected_interval in menu_select() is
frequently less than the target_residency of any state but snooze.

Due to this we are entering snooze at a higher rate, thereby affecting
the single thread performance.

Fix this by replacing right shift by 10 with /1000 while calculating
last_residency.

Reported-by: Anton Blanchard 
Bisected-by: Shilpasri G Bhat 
Signed-off-by: Shreyas B. Prabhu 
---
Changes in v2
=
 - Fixing it in the cpuidle core code instead of driver code.

 drivers/cpuidle/cpuidle.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index a4d0059..30d67a8 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -218,10 +218,10 @@ int cpuidle_enter_state(struct cpuidle_device *dev, 
struct cpuidle_driver *drv,
local_irq_enable();
 
/*
-* local_clock() returns the time in nanosecond, let's shift
-* by 10 (divide by 1024) to have microsecond based time.
+* local_clock() returns the time in nanosecond, let's
+* divide by 1000 to have microsecond based time.
 */
-   diff = (time_end - time_start) >> 10;
+   diff = (time_end - time_start) / 1000;
if (diff > INT_MAX)
diff = INT_MAX;
 
-- 
2.1.4

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

[PATCH] powerpc/boot: Add OPAL console to epapr wrappers

2016-06-24 Thread Oliver O'Halloran
This patch adds an OPAL console backend to the powerpc boot wrapper so
that decompression failures inside the wrapper can be reported to the
user. This is important since it typically indicates data corruption in
the firmware and other nasty things.

Currently this only works when building a little endian kernel. When
compiling a 64 bit BE kernel the wrapper is always build 32 bit to be
compatible with some 32 bit firmwares. BE support will be added at a
later date. Another limitation of this is that only the "raw" type of
OPAL console is supported, however machines that provide a hvsi console
also provide a raw console so this is not an issue in practice.

Actually-written-by: Benjamin Herrenschmidt 
Signed-off-by: Oliver O'Halloran 
Cc: Stewart Smith 
Cc: sta...@vger.kernel.org
---
 arch/powerpc/boot/Makefile  |  4 ++--
 arch/powerpc/boot/ops.h |  1 +
 arch/powerpc/boot/ppc_asm.h |  4 
 arch/powerpc/boot/serial.c  |  2 ++
 arch/powerpc/boot/types.h   | 12 
 5 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 8fe78a3efc92..00cf88aa9a23 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -70,7 +70,7 @@ $(addprefix $(obj)/,$(zlib) cuboot-c2k.o gunzip_util.o 
main.o): \
 libfdt   := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c
 libfdtheader := fdt.h libfdt.h libfdt_internal.h
 
-$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o): \
+$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o): \
$(addprefix $(obj)/,$(libfdtheader))
 
 src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
@@ -78,7 +78,7 @@ src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
ns16550.c serial.c simple_alloc.c div64.S util.S \
gunzip_util.c elf_util.c $(zlib) devtree.c stdlib.c \
oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \
-   uartlite.c mpc52xx-psc.c
+   uartlite.c mpc52xx-psc.c opal.c opal-calls.S
 src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
 src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
 src-wlib-$(CONFIG_8xx) += mpc8xx.c planetcore.c fsl-soc.c
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 5e75e1c5518e..e19b64ef977a 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -89,6 +89,7 @@ int mpsc_console_init(void *devp, struct serial_console_data 
*scdp);
 int cpm_console_init(void *devp, struct serial_console_data *scdp);
 int mpc5200_psc_console_init(void *devp, struct serial_console_data *scdp);
 int uartlite_console_init(void *devp, struct serial_console_data *scdp);
+int opal_console_init(void *devp, struct serial_console_data *scdp);
 void *simple_alloc_init(char *base, unsigned long heap_size,
unsigned long granularity, unsigned long max_allocs);
 extern void flush_cache(void *, unsigned long);
diff --git a/arch/powerpc/boot/ppc_asm.h b/arch/powerpc/boot/ppc_asm.h
index 35ea60c1f070..b03373d8b386 100644
--- a/arch/powerpc/boot/ppc_asm.h
+++ b/arch/powerpc/boot/ppc_asm.h
@@ -61,6 +61,10 @@
 
 #define SPRN_TBRL  268
 #define SPRN_TBRU  269
+#define SPRN_HSRR0 0x13A   /* Hypervisor Save/Restore 0 */
+#define SPRN_HSRR1 0x13B   /* Hypervisor Save/Restore 1 */
+
+#define MSR_LE 0x0001
 
 #define FIXUP_ENDIAN  \
tdi   0, 0, 0x48; /* Reverse endian of b . + 8  */ \
diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
index 167ee9433de6..e04c1e4063ae 100644
--- a/arch/powerpc/boot/serial.c
+++ b/arch/powerpc/boot/serial.c
@@ -132,6 +132,8 @@ int serial_console_init(void)
else if (dt_is_compatible(devp, "xlnx,opb-uartlite-1.00.b") ||
 dt_is_compatible(devp, "xlnx,xps-uartlite-1.00.a"))
rc = uartlite_console_init(devp, _cd);
+   else if (dt_is_compatible(devp, "ibm,opal-console-raw"))
+   rc = opal_console_init(devp, _cd);
 
/* Add other serial console driver calls here */
 
diff --git a/arch/powerpc/boot/types.h b/arch/powerpc/boot/types.h
index 31393d17a9c1..cda474cd63c8 100644
--- a/arch/powerpc/boot/types.h
+++ b/arch/powerpc/boot/types.h
@@ -12,6 +12,18 @@ typedef shorts16;
 typedef ints32;
 typedef long long  s64;
 
+
+/* required for opal-api.h */
+typedef u8  uint8_t;
+typedef u16 uint16_t;
+typedef u32 uint32_t;
+typedef u64 uint64_t;
+typedef s8  int8_t;
+typedef s16 int16_t;
+typedef s32 int32_t;
+typedef s64 int64_t;
+
+
 #define min(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
-- 
2.5.5

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

[RESEND v7,2/2] cxl: Add set and get private data to context struct

2016-06-24 Thread Philippe Bergheaud
From: Michael Neuling 

This provides AFU drivers a means to associate private data with a cxl
context. This is particularly intended for make the new callbacks for
driver specific events easier for AFU drivers to use, as they can easily
get back to any private data structures they may use.

Signed-off-by: Michael Neuling 
Signed-off-by: Ian Munsie 
Signed-off-by: Philippe Bergheaud 
---
No changes since v1. Added Matt Ochs reviewed-by tag.

 drivers/misc/cxl/api.c | 21 +
 drivers/misc/cxl/cxl.h |  3 +++
 include/misc/cxl.h |  7 +++
 3 files changed, 31 insertions(+)

diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index dd1988e..271bf77 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -94,6 +94,27 @@ static irq_hw_number_t cxl_find_afu_irq(struct cxl_context 
*ctx, int num)
return 0;
 }
 
+
+int cxl_set_priv(struct cxl_context *ctx, void *priv)
+{
+   if (!ctx)
+   return -EINVAL;
+
+   ctx->priv = priv;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(cxl_set_priv);
+
+void *cxl_get_priv(struct cxl_context *ctx)
+{
+   if (!ctx)
+   return ERR_PTR(-EINVAL);
+
+   return ctx->priv;
+}
+EXPORT_SYMBOL_GPL(cxl_get_priv);
+
 int cxl_allocate_afu_irqs(struct cxl_context *ctx, int num)
 {
int res;
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index b0027e6..1e56304 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -478,6 +478,9 @@ struct cxl_context {
/* Only used in PR mode */
u64 process_token;
 
+   /* driver private data */
+   void *priv;
+
unsigned long *irq_bitmap; /* Accessed from IRQ context */
struct cxl_irq_ranges irqs;
struct list_head irq_names;
diff --git a/include/misc/cxl.h b/include/misc/cxl.h
index 17419f6..b6d040f 100644
--- a/include/misc/cxl.h
+++ b/include/misc/cxl.h
@@ -86,6 +86,13 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev 
*dev);
 int cxl_release_context(struct cxl_context *ctx);
 
 /*
+ * Set and get private data associated with a context. Allows drivers to have a
+ * back pointer to some useful structure.
+ */
+int cxl_set_priv(struct cxl_context *ctx, void *priv);
+void *cxl_get_priv(struct cxl_context *ctx);
+
+/*
  * Allocate AFU interrupts for this context. num=0 will allocate the default
  * for this AFU as given in the AFU descriptor. This number doesn't include the
  * interrupt 0 (CAIA defines AFU IRQ 0 for page faults). Each interrupt to be
-- 
2.8.0

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

[PATCH] powerpc/powernv: Call opal_pci_poll() if needed

2016-06-24 Thread Gavin Shan
When issuing PHB reset, OPAL API opal_pci_poll() is called to drive
the state machine in OPAL forward. However, we needn't always call
the function under some circumstances like reset deassert.

This avoids calling opal_pci_poll() when OPAL_SUCCESS is returned
from opal_pci_reset(). Except the overhead introduced by additional
one unnecessary OPAL call, I didn't run into real issue because of
this.

Reported-by: Pridhiviraj Paidipeddi 
Signed-off-by: Gavin Shan 
---
 arch/powerpc/platforms/powernv/eeh-powernv.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c 
b/arch/powerpc/platforms/powernv/eeh-powernv.c
index 86544ea..931b305 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -763,7 +763,8 @@ int pnv_eeh_phb_reset(struct pci_controller *hose, int 
option)
 * reset followed by hot reset on root bus. So we also
 * need the PCI bus settlement delay.
 */
-   rc = pnv_eeh_poll(phb->opal_id);
+   if (rc > 0)
+   rc = pnv_eeh_poll(phb->opal_id);
if (option == EEH_RESET_DEACTIVATE) {
if (system_state < SYSTEM_RUNNING)
udelay(1000 * EEH_PE_RST_SETTLE_TIME);
@@ -806,7 +807,8 @@ static int pnv_eeh_root_reset(struct pci_controller *hose, 
int option)
goto out;
 
/* Poll state of the PHB until the request is done */
-   rc = pnv_eeh_poll(phb->opal_id);
+   if (rc > 0)
+   rc = pnv_eeh_poll(phb->opal_id);
if (option == EEH_RESET_DEACTIVATE)
msleep(EEH_PE_RST_SETTLE_TIME);
 out:
-- 
2.1.0

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

Re: [PATCH] powerpc/pci: Reduce log level of PCI I/O space warning

2016-06-24 Thread Gavin Shan
On Wed, Jun 22, 2016 at 05:23:07PM +1000, Benjamin Herrenschmidt wrote:
>If a PHB has no I/O space, there's no need to make it look like
>something bad happened, a pr_debug() is plenty enough since this
>is the case of all our modern POWER chips.
>
>Signed-off-by: Benjamin Herrenschmidt 

Reviewed-by: Gavin Shan 

>---
> arch/powerpc/kernel/pci-common.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/arch/powerpc/kernel/pci-common.c 
>b/arch/powerpc/kernel/pci-common.c
>index 2a67b16..3ab1f7b 100644
>--- a/arch/powerpc/kernel/pci-common.c
>+++ b/arch/powerpc/kernel/pci-common.c
>@@ -1487,9 +1487,9 @@ static void pcibios_setup_phb_resources(struct 
>pci_controller *hose,
>   res = >io_resource;
> 
>   if (!res->flags) {
>-  pr_info("PCI: I/O resource not set for host"
>- " bridge %s (domain %d)\n",
>- hose->dn->full_name, hose->global_number);
>+  pr_debug("PCI: I/O resource not set for host"
>+   " bridge %s (domain %d)\n",
>+   hose->dn->full_name, hose->global_number);
>   } else {
>   offset = pcibios_io_space_offset(hose);
> 
>
>
>___
>Linuxppc-dev mailing list
>Linuxppc-dev@lists.ozlabs.org
>https://lists.ozlabs.org/listinfo/linuxppc-dev

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

Re: [PATCH] powerpc/eeh: fix pr_debug()s in eeh_cache.c

2016-06-24 Thread Gavin Shan
On Fri, Jun 24, 2016 at 03:54:22PM +1000, Andrew Donnellan wrote:
>eeh_cache.c doesn't build cleanly with -DDEBUG when
>CONFIG_PHYS_ADDR_T_64BIT is set, as a couple of pr_debug()s use "%lx" for
>resource_size_t parameters.
>
>Use "%pap" instead, as it's the correct format specifier for types deriving
>from phys_addr_t.
>
>Signed-off-by: Andrew Donnellan 
>Cc: Russell Currey 
>Cc: Gavin Shan 

Reviewed-by: Gavin Shan 

>---
> arch/powerpc/kernel/eeh_cache.c | 8 
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/arch/powerpc/kernel/eeh_cache.c b/arch/powerpc/kernel/eeh_cache.c
>index ddbcfab..ceb81a4 100644
>--- a/arch/powerpc/kernel/eeh_cache.c
>+++ b/arch/powerpc/kernel/eeh_cache.c
>@@ -114,9 +114,9 @@ static void eeh_addr_cache_print(struct pci_io_addr_cache 
>*cache)
>   while (n) {
>   struct pci_io_addr_range *piar;
>   piar = rb_entry(n, struct pci_io_addr_range, rb_node);
>-  pr_debug("PCI: %s addr range %d [%lx-%lx]: %s\n",
>+  pr_debug("PCI: %s addr range %d [%pap-%pap]: %s\n",
>  (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt,
>- piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev));
>+ >addr_lo, >addr_hi, pci_name(piar->pcidev));
>   cnt++;
>   n = rb_next(n);
>   }
>@@ -159,8 +159,8 @@ eeh_addr_cache_insert(struct pci_dev *dev, resource_size_t 
>alo,
>   piar->flags = flags;
>
> #ifdef DEBUG
>-  pr_debug("PIAR: insert range=[%lx:%lx] dev=%s\n",
>-alo, ahi, pci_name(dev));
>+  pr_debug("PIAR: insert range=[%pap:%pap] dev=%s\n",
>+, , pci_name(dev));
> #endif
>
>   rb_link_node(>rb_node, parent, p);
>-- 
>Andrew Donnellan  OzLabs, ADL Canberra
>andrew.donnel...@au1.ibm.com  IBM Australia Limited
>

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