LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] kbuild and powerpc patches for new Kconfig language
From: Nicholas Piggin @ 2018-05-10  5:16 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Nicholas Piggin, Masahiro Yamada, linuxppc-dev

I came back to these patches and I think I have solved the remaining
problems -- it now builds with 64-bit big and little endian (using a
le toolchain), and also 32-bit big using 64le toolchain. There might
be some build failures still left, but it seems to be in much better
shape now.

Reviews would be welcome. I don't quite know how it should be merged,
maybe via the kbuild tree after acks from powerpc maintainer. We can
decide that after it gets more testing and review.

Thanks,
Nick

Nicholas Piggin (5):
  powerpc/kbuild: set default generic machine type for 32-bit compile
  powerpc/kbuild: remove CROSS32 defines from top level powerpc Makefile
  kbuild: call cc-option with the current set of KBUILD_CFLAGS
  powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
  powerpc/kbuild: move -mprofile-kernel check to Kconfig

 arch/powerpc/Kconfig                          | 16 +------
 arch/powerpc/Makefile                         | 46 +++++++------------
 arch/powerpc/boot/Makefile                    | 16 +++++--
 arch/powerpc/kernel/vdso32/Makefile           | 15 ++++--
 .../tools/gcc-check-mprofile-kernel.sh        |  4 +-
 scripts/Kbuild.include                        |  8 ++--
 scripts/recordmcount.pl                       |  8 ++++
 7 files changed, 54 insertions(+), 59 deletions(-)

-- 
2.17.0

^ permalink raw reply

* Re: powerpc/pseries: Fix CONFIG_NUMA=n build
From: Michael Ellerman @ 2018-05-10  4:06 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: mwb
In-Reply-To: <20180509145818.17254-1-mpe@ellerman.id.au>

On Wed, 2018-05-09 at 14:58:18 UTC, Michael Ellerman wrote:
> The build is failing with CONFIG_NUMA=n and some compiler versions:
> 
>   arch/powerpc/platforms/pseries/hotplug-cpu.o: In function `dlpar_online_cpu':
>   hotplug-cpu.c:(.text+0x12c): undefined reference to `timed_topology_update'
>   arch/powerpc/platforms/pseries/hotplug-cpu.o: In function `dlpar_cpu_remove':
>   hotplug-cpu.c:(.text+0x400): undefined reference to `timed_topology_update'
> 
> Fix it by moving the empty version of timed_topology_update() into the
> existing #ifdef block, which has the right guard of SPLPAR && NUMA.
> 
> Fixes: cee5405da402 ("powerpc/hotplug: Improve responsiveness of hotplug change")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/6c0a8f6b5a45ac892a763b6299bd3c

cheers

^ permalink raw reply

* Re: [PATCH] powerpc/kbuild: set generic machine type for compile with 64-bit toolchain
From: Nicholas Piggin @ 2018-05-10  1:33 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <20180510002637.3069-1-npiggin@gmail.com>

Bad title, should be set generic machine type for 32-bit compile with
64-bit toolchain

On Thu, 10 May 2018 10:26:37 +1000
Nicholas Piggin <npiggin@gmail.com> wrote:

> The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
> kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
> powerpc machine type and scheduling model. 32-bit platforms and CPUs
> can override this with -mcpu= options that come later on the command
> line.
> 
> This fixes a lot of build failures due to incompatible assembly when
> compiling 32-bit kernel with 64-bit toolchain.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  arch/powerpc/Makefile | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 95813df90801..aa6464c81a9f 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -24,6 +24,12 @@ ifeq ($(HAS_BIARCH),y)
>  ifeq ($(CROSS32_COMPILE),)
>  CROSS32CC	:= $(CC) -m32
>  KBUILD_ARFLAGS	+= --target=elf32-powerpc
> +
> +# These options will be overridden by any -mcpu option that comes
> +# later on the command line, but they are needed to set a sane
> +# 32-bit cpu target for the 64-bit cross compiler.
> +KBUILD_CFLAGS		+= -mcpu=powerpc
> +KBUILD_AFLAGS		+= -mcpu=powerpc
>  endif
>  endif
>  

^ permalink raw reply

* Re: [PATCH 2/2] powerpc/64: change softe to irqmask in show_regs and xmon
From: Balbir Singh @ 2018-05-10  1:17 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: open list:LINUX FOR POWERPC (32-BIT AND 64-BIT),
	Madhavan Srinivasan
In-Reply-To: <20180510010424.16854-2-npiggin@gmail.com>

On Thu, May 10, 2018 at 11:04 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> When the soft enabled flag was changed to a soft disable mask, xmon
> and register dump code was not updated to reflect that, which is
> confusing ('SOFTE: 1' previously meant interrupts were soft enabled,
> currently it means the opposite, the general interrupt type has been
> disabled).
>
> Fix this by using the name irqmask, and printing it in hex.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>

Acked-by: Balbir Singh <bsingharora@gmail.com>

^ permalink raw reply

* [PATCH 2/2] powerpc/64: change softe to irqmask in show_regs and xmon
From: Nicholas Piggin @ 2018-05-10  1:04 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin, Madhavan Srinivasan
In-Reply-To: <20180510010424.16854-1-npiggin@gmail.com>

When the soft enabled flag was changed to a soft disable mask, xmon
and register dump code was not updated to reflect that, which is
confusing ('SOFTE: 1' previously meant interrupts were soft enabled,
currently it means the opposite, the general interrupt type has been
disabled).

Fix this by using the name irqmask, and printing it in hex.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/process.c | 2 +-
 arch/powerpc/xmon/xmon.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 1237f13fed51..52b1c379d618 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1437,7 +1437,7 @@ void show_regs(struct pt_regs * regs)
 		pr_cont("DAR: "REG" DSISR: %08lx ", regs->dar, regs->dsisr);
 #endif
 #ifdef CONFIG_PPC64
-	pr_cont("SOFTE: %ld ", regs->softe);
+	pr_cont("IRQMASK: %lx ", regs->softe);
 #endif
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 	if (MSR_TM_ACTIVE(regs->msr))
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index a0842f1ff72c..05f648a55fa3 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1636,7 +1636,7 @@ static void excprint(struct pt_regs *fp)
 
 	printf("  current = 0x%lx\n", current);
 #ifdef CONFIG_PPC64
-	printf("  paca    = 0x%lx\t softe: %d\t irq_happened: 0x%02x\n",
+	printf("  paca    = 0x%lx\t irqmask: 0x%02x\t irq_happened: 0x%02x\n",
 	       local_paca, local_paca->irq_soft_mask, local_paca->irq_happened);
 #endif
 	if (current) {
-- 
2.17.0

^ permalink raw reply related

* [PATCH 1/2] powerpc/pmu/fsl: fix is_nmi test for irq mask change
From: Nicholas Piggin @ 2018-05-10  1:04 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin, Madhavan Srinivasan

When soft enabled was changed to irq disabled mask, this test missed
being converted (although the equivalent book3s test was converted).

The PMU drivers consider it an NMI when they take a PMI while general
interrupts are disabled. This change restores that behaviour.

Fixes: 01417c6cc7 ("powerpc/64: Change soft_enabled from flag to bitmask")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/perf/core-fsl-emb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/core-fsl-emb.c b/arch/powerpc/perf/core-fsl-emb.c
index 85f1d18e5fd3..ba485844d506 100644
--- a/arch/powerpc/perf/core-fsl-emb.c
+++ b/arch/powerpc/perf/core-fsl-emb.c
@@ -42,7 +42,7 @@ static DEFINE_MUTEX(pmc_reserve_mutex);
 static inline int perf_intr_is_nmi(struct pt_regs *regs)
 {
 #ifdef __powerpc64__
-	return !regs->softe;
+	return (regs->softe & IRQS_DISABLED);
 #else
 	return 0;
 #endif
-- 
2.17.0

^ permalink raw reply related

* Re: linux-next: manual merge of the powerpc tree with the powerpc-fixes tree
From: Michael Ellerman @ 2018-05-10  0:45 UTC (permalink / raw)
  To: Stephen Rothwell, Benjamin Herrenschmidt, PowerPC
  Cc: Linux-Next Mailing List, Linux Kernel Mailing List, Naveen N. Rao
In-Reply-To: <20180510101703.57ffb774@canb.auug.org.au>

Stephen Rothwell <sfr@canb.auug.org.au> writes:

> Hi all,
>
> Today's linux-next merge of the powerpc tree got a conflict in:
>
>   arch/powerpc/include/asm/ftrace.h
>
> between commit:
>
>   edf6a2dfe388 ("powerpc/trace/syscalls: Update syscall name matching logic to account for ppc_ prefix")
>
> from the powerpc-fixes tree and commit:
>
>   c3e59d778403 ("powerpc64/ftrace: Rearrange #ifdef sections in ftrace.h")
>
> from the powerpc tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
>
> Michael, I think the version in your merge branch is not quite right ...

Yep.

Don't do merges after midnight kids.

I've pushed a fixed version, which I think matches yours.

I'll resolve it in my next when I merge my fixes & next later in the
cycle.

cheers

^ permalink raw reply

* [PATCH] powerpc/kbuild: set generic machine type for compile with 64-bit toolchain
From: Nicholas Piggin @ 2018-05-10  0:26 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
powerpc machine type and scheduling model. 32-bit platforms and CPUs
can override this with -mcpu= options that come later on the command
line.

This fixes a lot of build failures due to incompatible assembly when
compiling 32-bit kernel with 64-bit toolchain.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 95813df90801..aa6464c81a9f 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -24,6 +24,12 @@ ifeq ($(HAS_BIARCH),y)
 ifeq ($(CROSS32_COMPILE),)
 CROSS32CC	:= $(CC) -m32
 KBUILD_ARFLAGS	+= --target=elf32-powerpc
+
+# These options will be overridden by any -mcpu option that comes
+# later on the command line, but they are needed to set a sane
+# 32-bit cpu target for the 64-bit cross compiler.
+KBUILD_CFLAGS		+= -mcpu=powerpc
+KBUILD_AFLAGS		+= -mcpu=powerpc
 endif
 endif
 
-- 
2.17.0

^ permalink raw reply related

* linux-next: manual merge of the powerpc tree with the powerpc-fixes tree
From: Stephen Rothwell @ 2018-05-10  0:17 UTC (permalink / raw)
  To: Michael Ellerman, Benjamin Herrenschmidt, PowerPC
  Cc: Linux-Next Mailing List, Linux Kernel Mailing List, Naveen N. Rao

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

Hi all,

Today's linux-next merge of the powerpc tree got a conflict in:

  arch/powerpc/include/asm/ftrace.h

between commit:

  edf6a2dfe388 ("powerpc/trace/syscalls: Update syscall name matching logic to account for ppc_ prefix")

from the powerpc-fixes tree and commit:

  c3e59d778403 ("powerpc64/ftrace: Rearrange #ifdef sections in ftrace.h")

from the powerpc tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

Michael, I think the version in your merge branch is not quite right ...
-- 
Cheers,
Stephen Rothwell

diff --cc arch/powerpc/include/asm/ftrace.h
index b2dabd06659d,fc3a2203c566..000000000000
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@@ -66,35 -62,39 +62,54 @@@ struct dyn_arch_ftrace 
  #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
  #define ARCH_SUPPORTS_FTRACE_OPS 1
  #endif
- #endif
+ #endif /* CONFIG_FUNCTION_TRACER */
  
- #if defined(CONFIG_FTRACE_SYSCALLS) && !defined(__ASSEMBLY__)
+ #ifndef __ASSEMBLY__
 -#if defined(CONFIG_FTRACE_SYSCALLS) && defined(PPC64_ELF_ABI_v1)
++#if defined(CONFIG_FTRACE_SYSCALLS)
 +/*
 + * Some syscall entry functions on powerpc start with "ppc_" (fork and clone,
 + * for instance) or ppc32_/ppc64_. We should also match the sys_ variant with
 + * those.
 + */
  #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
 +#ifdef PPC64_ELF_ABI_v1
  static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
  {
 -	/*
 -	 * Compare the symbol name with the system call name. Skip the .sys or .SyS
 -	 * prefix from the symbol name and the sys prefix from the system call name and
 -	 * just match the rest. This is only needed on ppc64 since symbol names on
 -	 * 32bit do not start with a period so the generic function will work.
 -	 */
 -	return !strcmp(sym + 4, name + 3);
 +	/* We need to skip past the initial dot, and the __se_sys alias */
 +	return !strcmp(sym + 1, name) ||
 +		(!strncmp(sym, ".__se_sys", 9) && !strcmp(sym + 6, name)) ||
 +		(!strncmp(sym, ".ppc_", 5) && !strcmp(sym + 5, name + 4)) ||
 +		(!strncmp(sym, ".ppc32_", 7) && !strcmp(sym + 7, name + 4)) ||
 +		(!strncmp(sym, ".ppc64_", 7) && !strcmp(sym + 7, name + 4));
  }
 -#endif /* CONFIG_FTRACE_SYSCALLS && PPC64_ELF_ABI_v1 */
 +#else
 +static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
 +{
 +	return !strcmp(sym, name) ||
 +		(!strncmp(sym, "__se_sys", 8) && !strcmp(sym + 5, name)) ||
 +		(!strncmp(sym, "ppc_", 4) && !strcmp(sym + 4, name + 4)) ||
 +		(!strncmp(sym, "ppc32_", 6) && !strcmp(sym + 6, name + 4)) ||
 +		(!strncmp(sym, "ppc64_", 6) && !strcmp(sym + 6, name + 4));
 +}
- #endif
- #endif /* CONFIG_FTRACE_SYSCALLS && !__ASSEMBLY__ */
++#endif /* PPC64_ELF_ABI_v1 */
++#endif /* CONFIG_FTRACE_SYSCALLS */
+ 
+ #ifdef CONFIG_PPC64
+ #include <asm/paca.h>
+ 
+ static inline void this_cpu_disable_ftrace(void)
+ {
+ 	get_paca()->ftrace_enabled = 0;
+ }
+ 
+ static inline void this_cpu_enable_ftrace(void)
+ {
+ 	get_paca()->ftrace_enabled = 1;
+ }
+ #else /* CONFIG_PPC64 */
+ static inline void this_cpu_disable_ftrace(void) { }
+ static inline void this_cpu_enable_ftrace(void) { }
+ #endif /* CONFIG_PPC64 */
+ #endif /* !__ASSEMBLY__ */
  
  #endif /* _ASM_POWERPC_FTRACE */

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* [powerpc:merge 138/138] arch/powerpc/kernel/setup_64.c:354:2: error: implicit declaration of function 'this_cpu_enable_ftrace'; did you mean 'preempt_enable_notrace'?
From: kbuild test robot @ 2018-05-09 22:33 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: kbuild-all, linuxppc-dev

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git merge
head:   900be8ab1549359ba980cfb042a043128204a963
commit: 900be8ab1549359ba980cfb042a043128204a963 [138/138] Automatic merge of branches 'master', 'next' and 'fixes' into merge
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 900be8ab1549359ba980cfb042a043128204a963
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   In file included from include/linux/ftrace.h:21:0,
                    from arch/powerpc/include/asm/livepatch.h:23,
                    from arch/powerpc/kernel/setup_64.c:67:
   arch/powerpc/include/asm/ftrace.h:2:0: error: unterminated #ifndef
    #ifndef _ASM_POWERPC_FTRACE
    
   arch/powerpc/kernel/setup_64.c: In function 'early_setup':
>> arch/powerpc/kernel/setup_64.c:354:2: error: implicit declaration of function 'this_cpu_enable_ftrace'; did you mean 'preempt_enable_notrace'? [-Werror=implicit-function-declaration]
     this_cpu_enable_ftrace();
     ^~~~~~~~~~~~~~~~~~~~~~
     preempt_enable_notrace
   cc1: all warnings being treated as errors
--
   In file included from arch/powerpc/kernel/smp.c:62:0:
   arch/powerpc/include/asm/ftrace.h:2:0: error: unterminated #ifndef
    #ifndef _ASM_POWERPC_FTRACE
    
   arch/powerpc/kernel/smp.c: In function 'start_secondary':
>> arch/powerpc/kernel/smp.c:1071:2: error: implicit declaration of function 'this_cpu_enable_ftrace'; did you mean 'preempt_enable_notrace'? [-Werror=implicit-function-declaration]
     this_cpu_enable_ftrace();
     ^~~~~~~~~~~~~~~~~~~~~~
     preempt_enable_notrace
   arch/powerpc/kernel/smp.c: In function '__cpu_disable':
>> arch/powerpc/kernel/smp.c:1169:2: error: implicit declaration of function 'this_cpu_disable_ftrace'; did you mean 'preempt_disable_notrace'? [-Werror=implicit-function-declaration]
     this_cpu_disable_ftrace();
     ^~~~~~~~~~~~~~~~~~~~~~~
     preempt_disable_notrace
   cc1: all warnings being treated as errors
--
   In file included from include/linux/ftrace.h:21:0,
                    from arch/powerpc/kernel/machine_kexec.c:18:
   arch/powerpc/include/asm/ftrace.h:2:0: error: unterminated #ifndef
    #ifndef _ASM_POWERPC_FTRACE
    
   arch/powerpc/kernel/machine_kexec.c: In function 'machine_kexec':
>> arch/powerpc/kernel/machine_kexec.c:101:2: error: implicit declaration of function 'this_cpu_disable_ftrace'; did you mean 'preempt_disable_notrace'? [-Werror=implicit-function-declaration]
     this_cpu_disable_ftrace();
     ^~~~~~~~~~~~~~~~~~~~~~~
     preempt_disable_notrace
>> arch/powerpc/kernel/machine_kexec.c:108:2: error: implicit declaration of function 'this_cpu_enable_ftrace'; did you mean 'preempt_enable_notrace'? [-Werror=implicit-function-declaration]
     this_cpu_enable_ftrace();
     ^~~~~~~~~~~~~~~~~~~~~~
     preempt_enable_notrace
   cc1: all warnings being treated as errors
--
   In file included from include/linux/ftrace.h:21:0,
                    from include/linux/perf_event.h:48,
                    from include/linux/trace_events.h:10,
                    from include/trace/trace_events.h:20,
                    from include/trace/define_trace.h:96,
                    from arch/powerpc/kvm/trace_hv.h:500,
                    from arch/powerpc/kvm/book3s_hv.c:80:
   arch/powerpc/include/asm/ftrace.h:2:0: error: unterminated #ifndef
    #ifndef _ASM_POWERPC_FTRACE
    
   arch/powerpc/kvm/book3s_hv.c: In function 'kvmppc_run_core':
>> arch/powerpc/kvm/book3s_hv.c:2914:2: error: implicit declaration of function 'this_cpu_disable_ftrace'; did you mean 'preempt_disable_notrace'? [-Werror=implicit-function-declaration]
     this_cpu_disable_ftrace();
     ^~~~~~~~~~~~~~~~~~~~~~~
     preempt_disable_notrace
>> arch/powerpc/kvm/book3s_hv.c:2918:2: error: implicit declaration of function 'this_cpu_enable_ftrace'; did you mean 'preempt_enable_notrace'? [-Werror=implicit-function-declaration]
     this_cpu_enable_ftrace();
     ^~~~~~~~~~~~~~~~~~~~~~
     preempt_enable_notrace
   cc1: all warnings being treated as errors

vim +354 arch/powerpc/kernel/setup_64.c

c0abd0c74 Nicholas Piggin        2018-02-14  264  
40ef8cbc6 Paul Mackerras         2005-10-10  265  /*
40ef8cbc6 Paul Mackerras         2005-10-10  266   * Early initialization entry point. This is called by head.S
40ef8cbc6 Paul Mackerras         2005-10-10  267   * with MMU translation disabled. We rely on the "feature" of
40ef8cbc6 Paul Mackerras         2005-10-10  268   * the CPU that ignores the top 2 bits of the address in real
40ef8cbc6 Paul Mackerras         2005-10-10  269   * mode so we can access kernel globals normally provided we
40ef8cbc6 Paul Mackerras         2005-10-10  270   * only toy with things in the RMO region. From here, we do
95f72d1ed Yinghai Lu             2010-07-12  271   * some early parsing of the device-tree to setup out MEMBLOCK
40ef8cbc6 Paul Mackerras         2005-10-10  272   * data structures, and allocate & initialize the hash table
40ef8cbc6 Paul Mackerras         2005-10-10  273   * and segment tables so we can start running with translation
40ef8cbc6 Paul Mackerras         2005-10-10  274   * enabled.
40ef8cbc6 Paul Mackerras         2005-10-10  275   *
40ef8cbc6 Paul Mackerras         2005-10-10  276   * It is this function which will call the probe() callback of
40ef8cbc6 Paul Mackerras         2005-10-10  277   * the various platform types and copy the matching one to the
40ef8cbc6 Paul Mackerras         2005-10-10  278   * global ppc_md structure. Your platform can eventually do
40ef8cbc6 Paul Mackerras         2005-10-10  279   * some very early initializations from the probe() routine, but
40ef8cbc6 Paul Mackerras         2005-10-10  280   * this is not recommended, be very careful as, for example, the
40ef8cbc6 Paul Mackerras         2005-10-10  281   * device-tree is not accessible via normal means at this point.
40ef8cbc6 Paul Mackerras         2005-10-10  282   */
40ef8cbc6 Paul Mackerras         2005-10-10  283  
40ef8cbc6 Paul Mackerras         2005-10-10  284  void __init early_setup(unsigned long dt_ptr)
40ef8cbc6 Paul Mackerras         2005-10-10  285  {
6a7e40641 Geoff Levand           2013-02-13  286  	static __initdata struct paca_struct boot_paca;
6a7e40641 Geoff Levand           2013-02-13  287  
24d964957 Benjamin Herrenschmidt 2008-05-07  288  	/* -------- printk is _NOT_ safe to use here ! ------- */
24d964957 Benjamin Herrenschmidt 2008-05-07  289  
5a61ef74f Nicholas Piggin        2017-05-09  290  	/* Try new device tree based feature discovery ... */
5a61ef74f Nicholas Piggin        2017-05-09  291  	if (!dt_cpu_ftrs_init(__va(dt_ptr)))
5a61ef74f Nicholas Piggin        2017-05-09  292  		/* Otherwise use the old style CPU table */
974a76f51 Paul Mackerras         2006-11-10  293  		identify_cpu(0, mfspr(SPRN_PVR));
42c4aaadb Benjamin Herrenschmidt 2006-10-24  294  
33dbcf72f Michael Ellerman       2006-06-28  295  	/* Assume we're on cpu 0 for now. Don't write to the paca yet! */
1426d5a3b Michael Ellerman       2010-01-28  296  	initialise_paca(&boot_paca, 0);
1426d5a3b Michael Ellerman       2010-01-28  297  	setup_paca(&boot_paca);
25e138149 Michael Ellerman       2013-02-12  298  	fixup_boot_paca();
33dbcf72f Michael Ellerman       2006-06-28  299  
24d964957 Benjamin Herrenschmidt 2008-05-07  300  	/* -------- printk is now safe to use ------- */
24d964957 Benjamin Herrenschmidt 2008-05-07  301  
f2fd25131 Benjamin Herrenschmidt 2008-05-07  302  	/* Enable early debugging if any specified (see udbg.h) */
f2fd25131 Benjamin Herrenschmidt 2008-05-07  303  	udbg_early_init();
f2fd25131 Benjamin Herrenschmidt 2008-05-07  304  
e8222502e Benjamin Herrenschmidt 2006-03-28  305   	DBG(" -> early_setup(), dt_ptr: 0x%lx\n", dt_ptr);
40ef8cbc6 Paul Mackerras         2005-10-10  306  
40ef8cbc6 Paul Mackerras         2005-10-10  307  	/*
3c607ce2a Linas Vepstas          2007-09-07  308  	 * Do early initialization using the flattened device
3c607ce2a Linas Vepstas          2007-09-07  309  	 * tree, such as retrieving the physical memory map or
3c607ce2a Linas Vepstas          2007-09-07  310  	 * calculating/retrieving the hash table size.
40ef8cbc6 Paul Mackerras         2005-10-10  311  	 */
40ef8cbc6 Paul Mackerras         2005-10-10  312  	early_init_devtree(__va(dt_ptr));
40ef8cbc6 Paul Mackerras         2005-10-10  313  
4df20460a Anton Blanchard        2006-03-25  314  	/* Now we know the logical id of our boot cpu, setup the paca. */
4890aea65 Nicholas Piggin        2018-02-14  315  	if (boot_cpuid != 0) {
4890aea65 Nicholas Piggin        2018-02-14  316  		/* Poison paca_ptrs[0] again if it's not the boot cpu */
4890aea65 Nicholas Piggin        2018-02-14  317  		memset(&paca_ptrs[0], 0x88, sizeof(paca_ptrs[0]));
4890aea65 Nicholas Piggin        2018-02-14  318  	}
d2e60075a Nicholas Piggin        2018-02-14  319  	setup_paca(paca_ptrs[boot_cpuid]);
25e138149 Michael Ellerman       2013-02-12  320  	fixup_boot_paca();
4df20460a Anton Blanchard        2006-03-25  321  
63c254a50 Benjamin Herrenschmidt 2016-07-05  322  	/*
d3cbff1b5 Benjamin Herrenschmidt 2016-07-05  323  	 * Configure exception handlers. This include setting up trampolines
d3cbff1b5 Benjamin Herrenschmidt 2016-07-05  324  	 * if needed, setting exception endian mode, etc...
63c254a50 Benjamin Herrenschmidt 2016-07-05  325  	 */
d3cbff1b5 Benjamin Herrenschmidt 2016-07-05  326  	configure_exceptions();
0cc4746ca Michael Ellerman       2005-12-04  327  
c4bd6cb87 Benjamin Herrenschmidt 2016-07-05  328  	/* Apply all the dynamic patching */
c4bd6cb87 Benjamin Herrenschmidt 2016-07-05  329  	apply_feature_fixups();
97f6e0cc3 Benjamin Herrenschmidt 2016-08-10  330  	setup_feature_keys();
c4bd6cb87 Benjamin Herrenschmidt 2016-07-05  331  
9e8066f39 Michael Ellerman       2016-07-26  332  	/* Initialize the hash table or TLB handling */
9e8066f39 Michael Ellerman       2016-07-26  333  	early_init_mmu();
9e8066f39 Michael Ellerman       2016-07-26  334  
a944a9c40 Benjamin Herrenschmidt 2014-03-28  335  	/*
1696d0fb7 Nicholas Piggin        2017-10-24  336  	 * After firmware and early platform setup code has set things up,
1696d0fb7 Nicholas Piggin        2017-10-24  337  	 * we note the SPR values for configurable control/performance
1696d0fb7 Nicholas Piggin        2017-10-24  338  	 * registers, and use those as initial defaults.
1696d0fb7 Nicholas Piggin        2017-10-24  339  	 */
1696d0fb7 Nicholas Piggin        2017-10-24  340  	record_spr_defaults();
1696d0fb7 Nicholas Piggin        2017-10-24  341  
1696d0fb7 Nicholas Piggin        2017-10-24  342  	/*
a944a9c40 Benjamin Herrenschmidt 2014-03-28  343  	 * At this point, we can let interrupts switch to virtual mode
a944a9c40 Benjamin Herrenschmidt 2014-03-28  344  	 * (the MMU has been setup), so adjust the MSR in the PACA to
8f619b542 Benjamin Herrenschmidt 2014-03-28  345  	 * have IR and DR set and enable AIL if it exists
a944a9c40 Benjamin Herrenschmidt 2014-03-28  346  	 */
8f619b542 Benjamin Herrenschmidt 2014-03-28  347  	cpu_ready_for_interrupts();
a944a9c40 Benjamin Herrenschmidt 2014-03-28  348  
d10397863 Naveen N. Rao          2018-04-19  349  	/*
d10397863 Naveen N. Rao          2018-04-19  350  	 * We enable ftrace here, but since we only support DYNAMIC_FTRACE, it
d10397863 Naveen N. Rao          2018-04-19  351  	 * will only actually get enabled on the boot cpu much later once
d10397863 Naveen N. Rao          2018-04-19  352  	 * ftrace itself has been initialized.
d10397863 Naveen N. Rao          2018-04-19  353  	 */
d10397863 Naveen N. Rao          2018-04-19 @354  	this_cpu_enable_ftrace();
d10397863 Naveen N. Rao          2018-04-19  355  
40ef8cbc6 Paul Mackerras         2005-10-10  356  	DBG(" <- early_setup()\n");
7191b6157 Benjamin Herrenschmidt 2013-07-25  357  

:::::: The code at line 354 was first introduced by commit
:::::: d103978636c27fce216bbc8bb289981047b71bd4 powerpc64/ftrace: Delay enabling ftrace on secondary cpus

:::::: TO: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
:::::: CC: Michael Ellerman <mpe@ellerman.id.au>

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 23368 bytes --]

^ permalink raw reply

* Re: [PATCH 2/3] hwmon: (ibmpowernv): Add support to read 64 bit sensors
From: Guenter Roeck @ 2018-05-09 17:29 UTC (permalink / raw)
  To: Shilpasri G Bhat
  Cc: mpe, linux-kernel, linuxppc-dev, linux-hwmon, benh, paulus,
	jdelvare, stewart
In-Reply-To: <1525688738-9185-3-git-send-email-shilpa.bhat@linux.vnet.ibm.com>

On Mon, May 07, 2018 at 03:55:37PM +0530, Shilpasri G Bhat wrote:
> The firmware has supported for reading sensor values of size u32.
> This patch adds support to use newer firmware functions which allows
> to read the sensors of size u64.
> 
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>

Acked-by: Guenter Roeck <linux@roeck-us.net>

I won't apply for the time being since it depends on patch 1/3 which is
outside hwmon.

> ---
>  drivers/hwmon/ibmpowernv.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
> index 5ccdd0b..74d9b5a 100644
> --- a/drivers/hwmon/ibmpowernv.c
> +++ b/drivers/hwmon/ibmpowernv.c
> @@ -101,9 +101,10 @@ static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
>  	struct sensor_data *sdata = container_of(devattr, struct sensor_data,
>  						 dev_attr);
>  	ssize_t ret;
> -	u32 x;
> +	u64 x;
> +
> +	ret =  opal_get_sensor_data_u64(sdata->id, &x);
>  
> -	ret = opal_get_sensor_data(sdata->id, &x);
>  	if (ret)
>  		return ret;
>  
> @@ -114,7 +115,7 @@ static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
>  	else if (sdata->type == POWER_INPUT)
>  		x *= 1000000;
>  
> -	return sprintf(buf, "%u\n", x);
> +	return sprintf(buf, "%llu\n", x);
>  }
>  
>  static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 3/3] hwmon: (ibmpowernv) Add energy sensors
From: Guenter Roeck @ 2018-05-09 17:29 UTC (permalink / raw)
  To: Shilpasri G Bhat
  Cc: mpe, linux-kernel, linuxppc-dev, linux-hwmon, benh, paulus,
	jdelvare, stewart
In-Reply-To: <1525688738-9185-4-git-send-email-shilpa.bhat@linux.vnet.ibm.com>

On Mon, May 07, 2018 at 03:55:38PM +0530, Shilpasri G Bhat wrote:
> This patch exports the accumulated power numbers of each power
> sensor maintained by OCC.
> 
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/hwmon/ibmpowernv.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
> index 74d9b5a..0298745 100644
> --- a/drivers/hwmon/ibmpowernv.c
> +++ b/drivers/hwmon/ibmpowernv.c
> @@ -51,6 +51,7 @@ enum sensors {
>  	POWER_SUPPLY,
>  	POWER_INPUT,
>  	CURRENT,
> +	ENERGY,
>  	MAX_SENSOR_TYPE,
>  };
>  
> @@ -78,6 +79,7 @@ enum sensors {
>  	{ "in"    },
>  	{ "power" },
>  	{ "curr"  },
> +	{ "energy" },
>  };
>  
>  struct sensor_data {
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: make a few block drivers highmem safe
From: Jens Axboe @ 2018-05-09 16:26 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Ed L. Cashin, Geoff Levand, Maxim Levitsky, linux-block,
	linuxppc-dev, linux-mtd, sparclinux
In-Reply-To: <20180509135948.20329-1-hch@lst.de>

On 5/9/18 7:59 AM, Christoph Hellwig wrote:
> Hi all,
> 
> this series converts a few random block drivers to be highmem safe,
> in preparation of eventually getting rid of the block layer bounce
> buffering support.

Series looks good to me.

-- 
Jens Axboe

^ permalink raw reply

* [RFC v3 3/3] powerpc migration/memory: Associativity & memory updates
From: Michael Bringmann @ 2018-05-09 16:13 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Michael Bringmann, Nathan Fontenot, John Allen, Tyrel Datwyler,
	Thomas Falcon
In-Reply-To: <5763b190-6b8a-eccb-663a-7d35363c81c8@linux.vnet.ibm.com>

powerpc migration/memory: This patch adds more recognition for changes
to the associativity of memory blocks described by the device-tree
properties and updates local and general kernel data structures to
reflect those changes.  These differences may include:

* Evaluating 'ibm,dynamic-memory' properties when processing the
  topology of LPARS in Post Migration events.  Previous efforts
  only recognized whether a memory block's assignment had changed
  in the property.  Changes here include checking the aa_index
  values for each drc_index of the old/new LMBs and to 'readd'
  any block for which the setting has changed.

* In an LPAR migration scenario, the "ibm,associativity-lookup-arrays"
  property may change.  In the event that a row of the array differs,
  locate all assigned memory blocks with that 'aa_index' and 're-add'
  them to the system memory block data structures.  In the process of
  the 're-add', the system routines will update the corresponding entry
  for the memory in the LMB structures and any other relevant kernel
  data structures.

* Extend the previous work for the 'ibm,associativity-lookup-array'
  and 'ibm,dynamic-memory' properties to support the property
  'ibm,dynamic-memory-v2' by means of the DRMEM LMB interpretation
  code.

Signed-off-by: Michael Bringmann <mwb@linux.vnet.ibm.com>
---
Changes in RFC:
  -- Simplify code to update memory nodes during mobility checks.
  -- Reuse code from DRMEM changes to scan for LMBs when updating
     aa_index
  -- Combine common code for properties 'ibm,dynamic-memory' and
     'ibm,dynamic-memory-v2' after integrating DRMEM features.
  -- Rearrange patches to co-locate memory property-related changes.
  -- Use new paired list iterator for the drmem info arrays.
  -- Use direct calls to add/remove memory from the update drconf
     function as those operations are only intended for user DLPAR
     ops, and should not occur during Migration reconfig notifier
     changes.
  -- Correct processing bug in processing of ibm,associativity-lookup-arrays
---
 arch/powerpc/platforms/pseries/hotplug-memory.c |  172 +++++++++++++++++++----
 1 file changed, 139 insertions(+), 33 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index c1578f5..15c6f74 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -994,13 +994,29 @@ static int pseries_add_mem_node(struct device_node *np)
 	return (ret < 0) ? -EINVAL : 0;
 }
 
-static int pseries_update_drconf_memory(struct of_reconfig_data *pr)
+static void pseries_queue_memory_event(u32 drc_index, int action)
 {
-	struct of_drconf_cell_v1 *new_drmem, *old_drmem;
-	unsigned long memblock_size;
-	u32 entries;
-	__be32 *p;
-	int i, rc = -EINVAL;
+	struct pseries_hp_errorlog *hp_elog;
+
+	hp_elog = kzalloc(sizeof(*hp_elog), GFP_KERNEL);
+	if(!hp_elog)
+		return;
+
+	hp_elog->resource = PSERIES_HP_ELOG_RESOURCE_MEM;
+	hp_elog->action = action;
+	hp_elog->id_type = PSERIES_HP_ELOG_ID_DRC_INDEX;
+	hp_elog->_drc_u.drc_index = drc_index;
+
+	queue_hotplug_event(hp_elog, NULL, NULL);
+
+	kfree(hp_elog);
+}
+
+static int pseries_update_drconf_memory(struct drmem_lmb_info *new_dinfo)
+{
+	struct drmem_lmb *old_lmb, *new_lmb;
+ 	unsigned long memblock_size;
+	int rc = 0;
 
 	if (rtas_hp_event)
 		return 0;
@@ -1009,42 +1025,123 @@ static int pseries_update_drconf_memory(struct of_reconfig_data *pr)
 	if (!memblock_size)
 		return -EINVAL;
 
-	p = (__be32 *) pr->old_prop->value;
-	if (!p)
-		return -EINVAL;
+	/* Arrays should have the same size and DRC indexes */
+	for_each_pair_drmem_lmb(drmem_info, old_lmb, new_dinfo, new_lmb) {
 
-	/* The first int of the property is the number of lmb's described
-	 * by the property. This is followed by an array of of_drconf_cell
-	 * entries. Get the number of entries and skip to the array of
-	 * of_drconf_cell's.
-	 */
-	entries = be32_to_cpu(*p++);
-	old_drmem = (struct of_drconf_cell_v1 *)p;
-
-	p = (__be32 *)pr->prop->value;
-	p++;
-	new_drmem = (struct of_drconf_cell_v1 *)p;
+		if (new_lmb->drc_index != old_lmb->drc_index)
+			continue;
 
-	for (i = 0; i < entries; i++) {
-		if ((be32_to_cpu(old_drmem[i].flags) & DRCONF_MEM_ASSIGNED) &&
-		    (!(be32_to_cpu(new_drmem[i].flags) & DRCONF_MEM_ASSIGNED))) {
+		if ((old_lmb->flags & DRCONF_MEM_ASSIGNED) &&
+		    (!(new_lmb->flags & DRCONF_MEM_ASSIGNED))) {
 			rc = pseries_remove_memblock(
-				be64_to_cpu(old_drmem[i].base_addr),
-						     memblock_size);
+				old_lmb->base_addr, memblock_size);
 			break;
-		} else if ((!(be32_to_cpu(old_drmem[i].flags) &
-			    DRCONF_MEM_ASSIGNED)) &&
-			    (be32_to_cpu(new_drmem[i].flags) &
-			    DRCONF_MEM_ASSIGNED)) {
-			rc = memblock_add(be64_to_cpu(old_drmem[i].base_addr),
-					  memblock_size);
+		} else if ((!(old_lmb->flags & DRCONF_MEM_ASSIGNED)) &&
+			   (new_lmb->flags & DRCONF_MEM_ASSIGNED)) {
+			rc = memblock_add(old_lmb->base_addr,
+					memblock_size);
 			rc = (rc < 0) ? -EINVAL : 0;
 			break;
+		} else if ((old_lmb->aa_index != new_lmb->aa_index) &&
+			   (new_lmb->flags & DRCONF_MEM_ASSIGNED)) {
+			pseries_queue_memory_event(
+				new_lmb->drc_index,
+				PSERIES_HP_ELOG_ACTION_READD);
 		}
 	}
 	return rc;
 }
 
+static void pseries_update_ala_memory_aai(int aa_index)
+{
+	struct drmem_lmb *lmb;
+
+	/* Readd all LMBs which were previously using the
+	 * specified aa_index value.
+	 */
+	for_each_drmem_lmb(lmb) {
+		if ((lmb->aa_index == aa_index) &&
+			(lmb->flags & DRCONF_MEM_ASSIGNED)) {
+			pseries_queue_memory_event(lmb->drc_index,
+				PSERIES_HP_ELOG_ACTION_READD);
+		}
+	}
+}
+
+struct assoc_arrays {
+	u32 n_arrays;
+	u32 array_sz;
+	const __be32 *arrays;
+};
+
+static int pseries_update_ala_memory(struct of_reconfig_data *pr)
+{
+	struct assoc_arrays new_ala, old_ala;
+	__be32 *p;
+	int i, lim;
+
+	if (rtas_hp_event)
+		return 0;
+
+	/*
+	 * The layout of the ibm,associativity-lookup-arrays
+	 * property is a number N indicating the number of
+	 * associativity arrays, followed by a number M
+	 * indicating the size of each associativity array,
+	 * followed by a list of N associativity arrays.
+	 */
+
+	p = (__be32 *) pr->old_prop->value;
+	if (!p)
+		return -EINVAL;
+	old_ala.n_arrays = of_read_number(p++, 1);
+	old_ala.array_sz = of_read_number(p++, 1);
+	old_ala.arrays = p;
+
+	p = (__be32 *) pr->prop->value;
+	if (!p)
+		return -EINVAL;
+	new_ala.n_arrays = of_read_number(p++, 1);
+	new_ala.array_sz = of_read_number(p++, 1);
+	new_ala.arrays = p;
+
+	lim = (new_ala.n_arrays > old_ala.n_arrays) ? old_ala.n_arrays :
+			new_ala.n_arrays;
+
+	if (old_ala.array_sz == new_ala.array_sz) {
+
+		/* Reset any entries where the old and new rows
+		 * the array have changed.
+		 */
+		for (i = 0; i < lim; i++) {
+			int index = (i * new_ala.array_sz);
+
+			if (!memcmp(&old_ala.arrays[index],
+				&new_ala.arrays[index],
+				new_ala.array_sz))
+				continue;
+
+			pseries_update_ala_memory_aai(i);
+		}
+
+		/* Reset any entries representing the extra rows.
+		 * There shouldn't be any, but just in case ...
+		 */
+		for (i = lim; i < new_ala.n_arrays; i++)
+			pseries_update_ala_memory_aai(i);
+
+	} else {
+		/* Update all entries representing these rows;
+		 * as all rows have different sizes, none can
+		 * have equivalent values.
+		 */
+		for (i = 0; i < lim; i++)
+			pseries_update_ala_memory_aai(i);
+	}
+
+	return 0;
+}
+
 static int pseries_memory_notifier(struct notifier_block *nb,
 				   unsigned long action, void *data)
 {
@@ -1059,8 +1156,17 @@ static int pseries_memory_notifier(struct notifier_block *nb,
 		err = pseries_remove_mem_node(rd->dn);
 		break;
 	case OF_RECONFIG_UPDATE_PROPERTY:
-		if (!strcmp(rd->prop->name, "ibm,dynamic-memory"))
-			err = pseries_update_drconf_memory(rd);
+		if (!strcmp(rd->prop->name, "ibm,dynamic-memory") ||
+		    !strcmp(rd->prop->name, "ibm,dynamic-memory-v2")) {
+			struct drmem_lmb_info *dinfo =
+				drmem_init_lmbs(rd->prop);
+			if (!dinfo)
+				return -EINVAL;
+			err = pseries_update_drconf_memory(dinfo);
+			drmem_lmbs_free(dinfo);
+		} else if (!strcmp(rd->prop->name,
+				"ibm,associativity-lookup-arrays"))
+			err = pseries_update_ala_memory(rd);
 		break;
 	}
 	return notifier_from_errno(err);

^ permalink raw reply related

* [RFC v3 2/3] powerpc migration/cpu: Associativity & cpu changes
From: Michael Bringmann @ 2018-05-09 16:13 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Michael Bringmann, Nathan Fontenot, John Allen, Tyrel Datwyler,
	Thomas Falcon
In-Reply-To: <5763b190-6b8a-eccb-663a-7d35363c81c8@linux.vnet.ibm.com>

powerpc migration/cpu: Now apply changes to the associativity of cpus
for the topology of LPARS in Post Migration events.  Recognize more
changes to the associativity of memory blocks described by the
'cpu' properties when processing the topology of LPARS in Post Migration
events.  Previous efforts only recognized whether a memory block's
assignment had changed in the property.  Changes here include:

* Provide hotplug CPU 'readd by index' operation
* Checking for changes in cpu associativity and making 'readd' calls
  when differences are observed.
* Queue up  changes to CPU properties so that they may take place
  after all PowerPC device-tree changes have been applied i.e. after
  the device hotplug is released in the mobility code.

Signed-off-by: Michael Bringmann <mwb@linux.vnet.ibm.com>
---
Changes include:
  -- Rearrange patches to co-locate CPU property-related changes.
  -- Modify dlpar_cpu_add & dlpar_cpu_remove to skip DRC index acquire
     or release operations during the CPU readd process.
  -- Correct a bug in DRC index selection for queued operation.
---
 arch/powerpc/platforms/pseries/hotplug-cpu.c |  123 +++++++++++++++++++-------
 arch/powerpc/platforms/pseries/mobility.c    |    3 +
 2 files changed, 95 insertions(+), 31 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index a408217..23d4cb8 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -474,7 +474,7 @@ static bool valid_cpu_drc_index(struct device_node *parent, u32 drc_index)
 				&cdata);
 }
 
-static ssize_t dlpar_cpu_add(u32 drc_index)
+static ssize_t dlpar_cpu_add(u32 drc_index, bool acquire_drc)
 {
 	struct device_node *dn, *parent;
 	int rc, saved_rc;
@@ -499,19 +499,22 @@ static ssize_t dlpar_cpu_add(u32 drc_index)
 		return -EINVAL;
 	}
 
-	rc = dlpar_acquire_drc(drc_index);
-	if (rc) {
-		pr_warn("Failed to acquire DRC, rc: %d, drc index: %x\n",
-			rc, drc_index);
-		of_node_put(parent);
-		return -EINVAL;
+	if (acquire_drc) {
+		rc = dlpar_acquire_drc(drc_index);
+		if (rc) {
+			pr_warn("Failed to acquire DRC, rc: %d, drc index: %x\n",
+				rc, drc_index);
+			of_node_put(parent);
+			return -EINVAL;
+		}
 	}
 
 	dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent);
 	if (!dn) {
 		pr_warn("Failed call to configure-connector, drc index: %x\n",
 			drc_index);
-		dlpar_release_drc(drc_index);
+		if (acquire_drc)
+			dlpar_release_drc(drc_index);
 		of_node_put(parent);
 		return -EINVAL;
 	}
@@ -526,8 +529,9 @@ static ssize_t dlpar_cpu_add(u32 drc_index)
 		pr_warn("Failed to attach node %s, rc: %d, drc index: %x\n",
 			dn->name, rc, drc_index);
 
-		rc = dlpar_release_drc(drc_index);
-		if (!rc)
+		if (acquire_drc)
+			rc = dlpar_release_drc(drc_index);
+		if (!rc || acquire_drc)
 			dlpar_free_cc_nodes(dn);
 
 		return saved_rc;
@@ -540,7 +544,7 @@ static ssize_t dlpar_cpu_add(u32 drc_index)
 			dn->name, rc, drc_index);
 
 		rc = dlpar_detach_node(dn);
-		if (!rc)
+		if (!rc && acquire_drc)
 			dlpar_release_drc(drc_index);
 
 		return saved_rc;
@@ -608,12 +612,13 @@ static int dlpar_offline_cpu(struct device_node *dn)
 
 }
 
-static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index)
+static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index,
+				bool release_drc)
 {
 	int rc;
 
-	pr_debug("Attempting to remove CPU %s, drc index: %x\n",
-		 dn->name, drc_index);
+	pr_debug("Attempting to remove CPU %s, drc index: %x (%d)\n",
+		 dn->name, drc_index, release_drc);
 
 	rc = dlpar_offline_cpu(dn);
 	if (rc) {
@@ -621,12 +626,14 @@ static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index)
 		return -EINVAL;
 	}
 
-	rc = dlpar_release_drc(drc_index);
-	if (rc) {
-		pr_warn("Failed to release drc (%x) for CPU %s, rc: %d\n",
-			drc_index, dn->name, rc);
-		dlpar_online_cpu(dn);
-		return rc;
+	if (release_drc) {
+		rc = dlpar_release_drc(drc_index);
+		if (rc) {
+			pr_warn("Failed to release drc (%x) for CPU %s, rc: %d\n",
+				drc_index, dn->name, rc);
+			dlpar_online_cpu(dn);
+			return rc;
+		}
 	}
 
 	rc = dlpar_detach_node(dn);
@@ -635,7 +642,8 @@ static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index)
 
 		pr_warn("Failed to detach CPU %s, rc: %d", dn->name, rc);
 
-		rc = dlpar_acquire_drc(drc_index);
+		if (release_drc)
+			rc = dlpar_acquire_drc(drc_index);
 		if (!rc)
 			dlpar_online_cpu(dn);
 
@@ -664,7 +672,7 @@ static struct device_node *cpu_drc_index_to_dn(u32 drc_index)
 	return dn;
 }
 
-static int dlpar_cpu_remove_by_index(u32 drc_index)
+static int dlpar_cpu_remove_by_index(u32 drc_index, bool release_drc)
 {
 	struct device_node *dn;
 	int rc;
@@ -676,10 +684,30 @@ static int dlpar_cpu_remove_by_index(u32 drc_index)
 		return -ENODEV;
 	}
 
-	rc = dlpar_cpu_remove(dn, drc_index);
+	rc = dlpar_cpu_remove(dn, drc_index, release_drc);
 	of_node_put(dn);
 	return rc;
 }
+ 
+static int dlpar_cpu_readd_by_index(u32 drc_index)
+{
+	int rc = 0;
+
+	pr_info("Attempting to re-add CPU, drc index %x\n", drc_index);
+
+	rc = dlpar_cpu_remove_by_index(drc_index, false);
+	if (!rc)
+		rc = dlpar_cpu_add(drc_index, false);
+
+	if (rc)
+		pr_info("Failed to update cpu at drc_index %lx\n",
+				(unsigned long int)drc_index);
+	else
+		pr_info("CPU at drc_index %lx was updated\n",
+				(unsigned long int)drc_index);
+
+	return rc;
+}
 
 static int find_dlpar_cpus_to_remove(u32 *cpu_drcs, int cpus_to_remove)
 {
@@ -741,7 +769,7 @@ static int dlpar_cpu_remove_by_count(u32 cpus_to_remove)
 	}
 
 	for (i = 0; i < cpus_to_remove; i++) {
-		rc = dlpar_cpu_remove_by_index(cpu_drcs[i]);
+		rc = dlpar_cpu_remove_by_index(cpu_drcs[i], true);
 		if (rc)
 			break;
 
@@ -752,7 +780,7 @@ static int dlpar_cpu_remove_by_count(u32 cpus_to_remove)
 		pr_warn("CPU hot-remove failed, adding back removed CPUs\n");
 
 		for (i = 0; i < cpus_removed; i++)
-			dlpar_cpu_add(cpu_drcs[i]);
+			dlpar_cpu_add(cpu_drcs[i], true);
 
 		rc = -EINVAL;
 	} else {
@@ -843,7 +871,7 @@ static int dlpar_cpu_add_by_count(u32 cpus_to_add)
 	}
 
 	for (i = 0; i < cpus_to_add; i++) {
-		rc = dlpar_cpu_add(cpu_drcs[i]);
+		rc = dlpar_cpu_add(cpu_drcs[i], true);
 		if (rc)
 			break;
 
@@ -854,7 +882,7 @@ static int dlpar_cpu_add_by_count(u32 cpus_to_add)
 		pr_warn("CPU hot-add failed, removing any added CPUs\n");
 
 		for (i = 0; i < cpus_added; i++)
-			dlpar_cpu_remove_by_index(cpu_drcs[i]);
+			dlpar_cpu_remove_by_index(cpu_drcs[i], true);
 
 		rc = -EINVAL;
 	} else {
@@ -880,7 +908,7 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog)
 		if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT)
 			rc = dlpar_cpu_remove_by_count(count);
 		else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX)
-			rc = dlpar_cpu_remove_by_index(drc_index);
+			rc = dlpar_cpu_remove_by_index(drc_index, true);
 		else
 			rc = -EINVAL;
 		break;
@@ -888,10 +916,13 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog)
 		if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT)
 			rc = dlpar_cpu_add_by_count(count);
 		else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX)
-			rc = dlpar_cpu_add(drc_index);
+			rc = dlpar_cpu_add(drc_index, true);
 		else
 			rc = -EINVAL;
 		break;
+	case PSERIES_HP_ELOG_ACTION_READD:
+		rc = dlpar_cpu_readd_by_index(drc_index);
+		break;
 	default:
 		pr_err("Invalid action (%d) specified\n", hp_elog->action);
 		rc = -EINVAL;
@@ -913,7 +944,7 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
 	if (rc)
 		return -EINVAL;
 
-	rc = dlpar_cpu_add(drc_index);
+	rc = dlpar_cpu_add(drc_index, true);
 
 	return rc ? rc : count;
 }
@@ -934,7 +965,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count)
 		return -EINVAL;
 	}
 
-	rc = dlpar_cpu_remove(dn, drc_index);
+	rc = dlpar_cpu_remove(dn, drc_index, true);
 	of_node_put(dn);
 
 	return rc ? rc : count;
@@ -942,12 +973,38 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count)
 
 #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
 
+static int pseries_update_cpu(struct of_reconfig_data *pr)
+{
+	/* So far, we only handle the 'ibm,associativity' property,
+	 * here.
+	 */
+	struct pseries_hp_errorlog *hp_elog;
+
+        hp_elog = kzalloc(sizeof(*hp_elog), GFP_KERNEL);
+        if(!hp_elog)
+                return -ENOMEM;
+
+	hp_elog->resource = PSERIES_HP_ELOG_RESOURCE_CPU;
+	hp_elog->action = PSERIES_HP_ELOG_ACTION_READD;
+	hp_elog->id_type = PSERIES_HP_ELOG_ID_DRC_INDEX;
+	hp_elog->_drc_u.drc_index = be32_to_cpu(pr->dn->phandle);
+
+	queue_hotplug_event(hp_elog, NULL, NULL);
+
+	kfree(hp_elog);
+
+	return 0;
+}
+
 static int pseries_smp_notifier(struct notifier_block *nb,
 				unsigned long action, void *data)
 {
 	struct of_reconfig_data *rd = data;
 	int err = 0;
 
+	if (strcmp(rd->dn->type, "cpu"))
+		return notifier_from_errno(err);
+
 	switch (action) {
 	case OF_RECONFIG_ATTACH_NODE:
 		err = pseries_add_processor(rd->dn);
@@ -955,6 +1012,10 @@ static int pseries_smp_notifier(struct notifier_block *nb,
 	case OF_RECONFIG_DETACH_NODE:
 		pseries_remove_processor(rd->dn);
 		break;
+	case OF_RECONFIG_UPDATE_PROPERTY:
+		if (!strcmp(rd->prop->name, "ibm,associativity"))
+			err = pseries_update_cpu(rd);
+		break;
 	}
 	return notifier_from_errno(err);
 }
diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
index 8a8033a..6d98f84 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -283,6 +283,8 @@ int pseries_devicetree_update(s32 scope)
 	if (!rtas_buf)
 		return -ENOMEM;
 
+	lock_device_hotplug();
+
 	do {
 		rc = mobility_rtas_call(update_nodes_token, rtas_buf, scope);
 		if (rc && rc != 1)
@@ -321,6 +323,7 @@ int pseries_devicetree_update(s32 scope)
 	} while (rc == 1);
 
 	kfree(rtas_buf);
+	unlock_device_hotplug();
 	return rc;
 }
 

^ permalink raw reply related

* [RFC v3 1/3] powerpc migration/drmem: Modify DRMEM code to export more features
From: Michael Bringmann @ 2018-05-09 16:13 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Michael Bringmann, Nathan Fontenot, John Allen, Tyrel Datwyler,
	Thomas Falcon
In-Reply-To: <5763b190-6b8a-eccb-663a-7d35363c81c8@linux.vnet.ibm.com>

powerpc migration/drmem: Export many of the functions of DRMEM to
parse "ibm,dynamic-memory" and "ibm,dynamic-memory-v2" during
hotplug operations and for Post Migration events.

Also modify the DRMEM initialization code to allow it to,

* Be called after system initialization
* Provide a separate user copy of the LMB array that is produces
* Free the user copy upon request

Signed-off-by: Michael Bringmann <mwb@linux.vnet.ibm.com>
---
Changes in RFC:
  -- Separate DRMEM changes into a standalone patch
  -- Do not export excess functions.  Make exported names more explicit.
  -- Add new iterator to work through a pair of drmem_info arrays.
  -- Modify DRMEM code to replace usages of dt_root_addr_cells, and
     dt_mem_next_cell, as these are only available at first boot.
---
 arch/powerpc/include/asm/drmem.h |   10 +++++
 arch/powerpc/mm/drmem.c          |   78 +++++++++++++++++++++++++++-----------
 2 files changed, 66 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h
index ce242b9..c964b89 100644
--- a/arch/powerpc/include/asm/drmem.h
+++ b/arch/powerpc/include/asm/drmem.h
@@ -35,6 +35,13 @@ struct drmem_lmb_info {
 		&drmem_info->lmbs[0],				\
 		&drmem_info->lmbs[drmem_info->n_lmbs - 1])
 
+#define for_each_pair_drmem_lmb(dinfo1, lmb1, dinfo2, lmb2)	\
+	for ((lmb1) = (&dinfo1->lmbs[0]),			\
+	     (lmb2) = (&dinfo2->lmbs[0]);			\
+             ((lmb1) <= (&dinfo1->lmbs[dinfo1->n_lmbs - 1])) &&	\
+             ((lmb2) <= (&dinfo2->lmbs[dinfo2->n_lmbs - 1]));	\
+	     (lmb1)++, (lmb2)++)
+
 /*
  * The of_drconf_cell_v1 struct defines the layout of the LMB data
  * specified in the ibm,dynamic-memory device tree property.
@@ -94,6 +101,9 @@ void __init walk_drmem_lmbs(struct device_node *dn,
 			void (*func)(struct drmem_lmb *, const __be32 **));
 int drmem_update_dt(void);
 
+struct drmem_lmb_info* drmem_init_lmbs(struct property *prop);
+void drmem_lmbs_free(struct drmem_lmb_info *dinfo);
+
 #ifdef CONFIG_PPC_PSERIES
 void __init walk_drmem_lmbs_early(unsigned long node,
 			void (*func)(struct drmem_lmb *, const __be32 **));
diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
index 3f18036..d9b281c 100644
--- a/arch/powerpc/mm/drmem.c
+++ b/arch/powerpc/mm/drmem.c
@@ -20,6 +20,7 @@
 
 static struct drmem_lmb_info __drmem_info;
 struct drmem_lmb_info *drmem_info = &__drmem_info;
+static int n_root_addr_cells;
 
 u64 drmem_lmb_memory_max(void)
 {
@@ -193,12 +194,13 @@ int drmem_update_dt(void)
 	return rc;
 }
 
-static void __init read_drconf_v1_cell(struct drmem_lmb *lmb,
+static void read_drconf_v1_cell(struct drmem_lmb *lmb,
 				       const __be32 **prop)
 {
 	const __be32 *p = *prop;
 
-	lmb->base_addr = dt_mem_next_cell(dt_root_addr_cells, &p);
+	lmb->base_addr = of_read_number(p, n_root_addr_cells);
+	p += n_root_addr_cells;
 	lmb->drc_index = of_read_number(p++, 1);
 
 	p++; /* skip reserved field */
@@ -209,7 +211,7 @@ static void __init read_drconf_v1_cell(struct drmem_lmb *lmb,
 	*prop = p;
 }
 
-static void __init __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *usm,
+static void __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *data,
 			void (*func)(struct drmem_lmb *, const __be32 **))
 {
 	struct drmem_lmb lmb;
@@ -221,17 +223,18 @@ static void __init __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *usm,
 
 	for (i = 0; i < n_lmbs; i++) {
 		read_drconf_v1_cell(&lmb, &prop);
-		func(&lmb, &usm);
+		func(&lmb, &data);
 	}
 }
 
-static void __init read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell,
+static void read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell,
 				       const __be32 **prop)
 {
 	const __be32 *p = *prop;
 
 	dr_cell->seq_lmbs = of_read_number(p++, 1);
-	dr_cell->base_addr = dt_mem_next_cell(dt_root_addr_cells, &p);
+	dr_cell->base_addr = of_read_number(p, n_root_addr_cells);
+	p += n_root_addr_cells;
 	dr_cell->drc_index = of_read_number(p++, 1);
 	dr_cell->aa_index = of_read_number(p++, 1);
 	dr_cell->flags = of_read_number(p++, 1);
@@ -239,7 +242,7 @@ static void __init read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell,
 	*prop = p;
 }
 
-static void __init __walk_drmem_v2_lmbs(const __be32 *prop, const __be32 *usm,
+static void __walk_drmem_v2_lmbs(const __be32 *prop, const __be32 *data,
 			void (*func)(struct drmem_lmb *, const __be32 **))
 {
 	struct of_drconf_cell_v2 dr_cell;
@@ -263,7 +266,7 @@ static void __init __walk_drmem_v2_lmbs(const __be32 *prop, const __be32 *usm,
 			lmb.aa_index = dr_cell.aa_index;
 			lmb.flags = dr_cell.flags;
 
-			func(&lmb, &usm);
+			func(&lmb, &data);
 		}
 	}
 }
@@ -275,6 +278,9 @@ void __init walk_drmem_lmbs_early(unsigned long node,
 	const __be32 *prop, *usm;
 	int len;
 
+	if (n_root_addr_cells == 0)
+		n_root_addr_cells = dt_root_addr_cells;
+
 	prop = of_get_flat_dt_prop(node, "ibm,lmb-size", &len);
 	if (!prop || len < dt_root_size_cells * sizeof(__be32))
 		return;
@@ -353,24 +359,26 @@ void __init walk_drmem_lmbs(struct device_node *dn,
 	}
 }
 
-static void __init init_drmem_v1_lmbs(const __be32 *prop)
+static void init_drmem_v1_lmbs(const __be32 *prop,
+			struct drmem_lmb_info *dinfo)
 {
 	struct drmem_lmb *lmb;
 
-	drmem_info->n_lmbs = of_read_number(prop++, 1);
-	if (drmem_info->n_lmbs == 0)
+	dinfo->n_lmbs = of_read_number(prop++, 1);
+	if (dinfo->n_lmbs == 0)
 		return;
 
-	drmem_info->lmbs = kcalloc(drmem_info->n_lmbs, sizeof(*lmb),
+	dinfo->lmbs = kcalloc(dinfo->n_lmbs, sizeof(*lmb),
 				   GFP_KERNEL);
-	if (!drmem_info->lmbs)
+	if (!dinfo->lmbs)
 		return;
 
 	for_each_drmem_lmb(lmb)
 		read_drconf_v1_cell(lmb, &prop);
 }
 
-static void __init init_drmem_v2_lmbs(const __be32 *prop)
+static void init_drmem_v2_lmbs(const __be32 *prop,
+			struct drmem_lmb_info *dinfo)
 {
 	struct drmem_lmb *lmb;
 	struct of_drconf_cell_v2 dr_cell;
@@ -386,12 +394,12 @@ static void __init init_drmem_v2_lmbs(const __be32 *prop)
 	p = prop;
 	for (i = 0; i < lmb_sets; i++) {
 		read_drconf_v2_cell(&dr_cell, &p);
-		drmem_info->n_lmbs += dr_cell.seq_lmbs;
+		dinfo->n_lmbs += dr_cell.seq_lmbs;
 	}
 
-	drmem_info->lmbs = kcalloc(drmem_info->n_lmbs, sizeof(*lmb),
+	dinfo->lmbs = kcalloc(dinfo->n_lmbs, sizeof(*lmb),
 				   GFP_KERNEL);
-	if (!drmem_info->lmbs)
+	if (!dinfo->lmbs)
 		return;
 
 	/* second pass, read in the LMB information */
@@ -402,25 +410,51 @@ static void __init init_drmem_v2_lmbs(const __be32 *prop)
 		read_drconf_v2_cell(&dr_cell, &p);
 
 		for (j = 0; j < dr_cell.seq_lmbs; j++) {
-			lmb = &drmem_info->lmbs[lmb_index++];
+			lmb = &dinfo->lmbs[lmb_index++];
 
 			lmb->base_addr = dr_cell.base_addr;
-			dr_cell.base_addr += drmem_info->lmb_size;
+			dr_cell.base_addr += dinfo->lmb_size;
 
 			lmb->drc_index = dr_cell.drc_index;
 			dr_cell.drc_index++;
 
 			lmb->aa_index = dr_cell.aa_index;
-			lmb->flags = dr_cell.flags;
 		}
 	}
 }
 
+void drmem_lmbs_free(struct drmem_lmb_info *dinfo)
+{
+	if (dinfo) {
+		kfree(dinfo->lmbs);
+		kfree(dinfo);
+	}
+}
+
+struct drmem_lmb_info* drmem_init_lmbs(struct property *prop)
+{
+	struct drmem_lmb_info *dinfo;
+
+	dinfo = kzalloc(sizeof(*dinfo), GFP_KERNEL);
+	if (!dinfo)
+		return NULL;
+
+	if (!strcmp("ibm,dynamic-memory", prop->name))
+		init_drmem_v1_lmbs(prop->value, dinfo);
+	else if (!strcmp("ibm,dynamic-memory-v2", prop->name))
+		init_drmem_v2_lmbs(prop->value, dinfo);
+
+	return dinfo;
+}
+
 static int __init drmem_init(void)
 {
 	struct device_node *dn;
 	const __be32 *prop;
 
+	if (n_root_addr_cells == 0)
+		n_root_addr_cells = dt_root_addr_cells;
+
 	dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
 	if (!dn) {
 		pr_info("No dynamic reconfiguration memory found\n");
@@ -434,11 +468,11 @@ static int __init drmem_init(void)
 
 	prop = of_get_property(dn, "ibm,dynamic-memory", NULL);
 	if (prop) {
-		init_drmem_v1_lmbs(prop);
+		init_drmem_v1_lmbs(prop, drmem_info);
 	} else {
 		prop = of_get_property(dn, "ibm,dynamic-memory-v2", NULL);
 		if (prop)
-			init_drmem_v2_lmbs(prop);
+			init_drmem_v2_lmbs(prop, drmem_info);
 	}
 
 	of_node_put(dn);

^ permalink raw reply related

* [RFC v3 0/3] powerpc/hotplug: Fix affinity assoc for LPAR migration
From: Michael Bringmann @ 2018-05-09 16:12 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Michael Bringmann, Nathan Fontenot, John Allen, Tyrel Datwyler,
	Thomas Falcon

The migration of LPARs across Power systems affects many attributes
including that of the associativity of memory blocks and CPUs.  The
patches in this set execute when a system is coming up fresh upon a
migration target.  They are intended to,

* Recognize changes to the associativity of memory and CPUs recorded
  in internal data structures when compared to the latest copies in
  the device tree (e.g. ibm,dynamic-memory, ibm,dynamic-memory-v2,
  cpus),
* Recognize changes to the associativity mapping (e.g. ibm,
  associativity-lookup-arrays), locate all assigned memory blocks
  corresponding to each changed row, and readd all such blocks.
* Generate calls to other code layers to reset the data structures
  related to associativity of the CPUs and memory.
* Re-register the 'changed' entities into the target system.
  Re-registration of CPUs and memory blocks mostly entails acting as
  if they have been newly hot-added into the target system.

Signed-off-by: Michael Bringmann <mwb@linux.vnet.ibm.com>

Michael Bringmann (3):
  powerpc migration/drmem: Modify DRMEM code to export more features
  powerpc migration/cpu: Associativity & cpu changes
  powerpc migration/memory: Associativity & memory updates
---
Changes in RFC:
  -- Restructure and rearrange content of patches to co-locate
     similar or related modifications.
  -- Rename pseries_update_drconf_cpu to pseries_update_cpu
  -- Simplify code to update CPU nodes during mobility checks.
     Remove functions to generate extra HP_ELOG messages in favor
     of direct function calls to dlpar_cpu_readd_by_index, or
     dlpar_memory_readd_by_index.
  -- Revise code order in dlpar_cpu_readd_by_index() to present
     more appropriate error codes from underlying layers of the
     implementation.
  -- Add hotplug device lock around all property updates
  -- Schedule all CPU and memory changes due to device-tree updates /
     LPAR mobility as workqueue operations
  -- Export DRMEM accessor functions to parse 'ibm,dynamic-memory-v2'
  -- Export DRMEM functions to provide user copies of LMB array
  -- Compress code using DRMEM accessor functions.
  -- Split topology timer crash fix into new patch.
  -- Modify DRMEM code to replace usages of dt_root_addr_cells, and
     dt_mem_next_cell, as these are only available at first boot.
  -- Correct a bug in DRC index selection for queued operation.

^ permalink raw reply

* Re: [PATCH v3] powerpc, pkey: make protection key 0 less special
From: Michal Suchánek @ 2018-05-09 15:56 UTC (permalink / raw)
  To: Dave Hansen
  Cc: Ram Pai, fweimer, msuchanek, Thomas Gleixner, mhocko,
	Ulrich.Weigand, paulus, aneesh.kumar, bauerman, Andrew Morton,
	linuxppc-dev, Ingo Molnar
In-Reply-To: <5e7ed7d9-3fbc-7d60-9c69-bdcef6025167@intel.com>

On Wed, 9 May 2018 08:46:08 -0700
Dave Hansen <dave.hansen@intel.com> wrote:

> On 05/09/2018 08:43 AM, Michal Such=C3=A1nek wrote:
> > It seems it is somehow assumed this is key 0 but I did not find it
> > documented anywhere nor did I notice an interface for determining
> > the default key. =20
>=20
> Does the manpage not count as documentation?  :)
>=20
> "pkey 0 is used as the default key"
>=20
> https://manpages.debian.org/stretch/manpages/pkeys.7.en.html

I happened to be reading Documentation/x86/protection-keys.txt which is
much more terse. The man page is certainly clearer.

Thanks

Michal

^ permalink raw reply

* Re: [PATCH v3] powerpc, pkey: make protection key 0 less special
From: Dave Hansen @ 2018-05-09 15:46 UTC (permalink / raw)
  To: Michal Suchánek, Ram Pai
  Cc: mpe, fweimer, msuchanek, Andrew Morton, Ulrich.Weigand,
	Ingo Molnar, mhocko, paulus, aneesh.kumar, bauerman,
	Thomas Gleixner, linuxppc-dev
In-Reply-To: <20180509174335.0faab9fc@kitsune.suse.cz>

On 05/09/2018 08:43 AM, Michal Suchánek wrote:
> It seems it is somehow assumed this is key 0 but I did not find it
> documented anywhere nor did I notice an interface for determining the
> default key.

Does the manpage not count as documentation?  :)

"pkey 0 is used as the default key"

https://manpages.debian.org/stretch/manpages/pkeys.7.en.html

^ permalink raw reply

* Re: [PATCH v3] powerpc, pkey: make protection key 0 less special
From: Michal Suchánek @ 2018-05-09 15:43 UTC (permalink / raw)
  To: Ram Pai
  Cc: mpe, fweimer, msuchanek, Andrew Morton, Ulrich.Weigand,
	Ingo Molnar, mhocko, paulus, aneesh.kumar, bauerman,
	Thomas Gleixner, linuxppc-dev, Dave Hansen
In-Reply-To: <1525461778-26265-1-git-send-email-linuxram@us.ibm.com>

On Fri,  4 May 2018 12:22:58 -0700
Ram Pai <linuxram@us.ibm.com> wrote:

> Applications need the ability to associate an address-range with some
> key and latter revert to its initial default key. Pkey-0 comes close
> to providing this function but falls short, because the current
> implementation disallows applications to explicitly associate pkey-0
> to the address range.

Is there any way for the application to determine which key is the
default one associated with all address space until the application
installs its own key associations?

It seems it is somehow assumed this is key 0 but I did not find it
documented anywhere nor did I notice an interface for determining the
default key.

Thanks

Michal

> 
> Lets make pkey-0 less special and treat it almost like any other key.
> Thus it can be explicitly associated with any address range, and can
> be freed. This gives the application more flexibility and power.  The
> ability to free pkey-0 must be used responsibily, since pkey-0 is
> associated with almost all address-range by default.
> 
> Even with this change pkey-0 continues to be slightly more special
> from the following point of view.
> (a) it is implicitly allocated.
> (b) it is the default key assigned to any address-range.
> (c) its permissions cannot be modified by userspace.
> 
> NOTE: (c) is specific to powerpc only. pkey-0 is associated by default
> with all pages including kernel pages, and pkeys are also active in
> kernel mode. If any permission is denied on pkey-0, the kernel running
> in the context of the application will be unable to operate.
> 
> Tested on powerpc.
> 
> cc: Thomas Gleixner <tglx@linutronix.de>
> cc: Dave Hansen <dave.hansen@intel.com>
> cc: Michael Ellermen <mpe@ellerman.id.au>
> cc: Ingo Molnar <mingo@kernel.org>
> cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> ---
> History:
> 
> 	v3: . Corrected a comment in arch_set_user_pkey_access().
> 	    . Clarified the header, to capture the notion that
> 	      pkey-0 permissions cannot be modified by userspace on
> powerpc. -- comment from Thiago
> 
> 	v2: . mm_pkey_is_allocated() continued to treat pkey-0
> special. fixed it.
> 
>  arch/powerpc/include/asm/pkeys.h |   22 ++++++++++++++++++----
>  arch/powerpc/mm/pkeys.c          |   26 +++++++++++++++-----------
>  2 files changed, 33 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/pkeys.h
> b/arch/powerpc/include/asm/pkeys.h index 0409c80..31a6976 100644
> --- a/arch/powerpc/include/asm/pkeys.h
> +++ b/arch/powerpc/include/asm/pkeys.h
> @@ -101,10 +101,14 @@ static inline u16 pte_to_pkey_bits(u64 pteflags)
>  
>  static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int
> pkey) {
> -	/* A reserved key is never considered as 'explicitly
> allocated' */
> -	return ((pkey < arch_max_pkey()) &&
> -		!__mm_pkey_is_reserved(pkey) &&
> -		__mm_pkey_is_allocated(mm, pkey));
> +	if (pkey < 0 || pkey >= arch_max_pkey())
> +		return false;
> +
> +	/* Reserved keys are never allocated. */
> +	if (__mm_pkey_is_reserved(pkey))
> +		return false;
> +
> +	return __mm_pkey_is_allocated(mm, pkey);
>  }
>  
>  extern void __arch_activate_pkey(int pkey);
> @@ -200,6 +204,16 @@ static inline int
> arch_set_user_pkey_access(struct task_struct *tsk, int pkey, {
>  	if (static_branch_likely(&pkey_disabled))
>  		return -EINVAL;
> +
> +	/*
> +	 * userspace should not change pkey-0 permissions.
> +	 * pkey-0 is associated with every page in the kernel.
> +	 * If userspace denies any permission on pkey-0, the
> +	 * kernel cannot operate.
> +	 */
> +	if (!pkey)
> +		return init_val ? -EINVAL : 0;
> +
>  	return __arch_set_user_pkey_access(tsk, pkey, init_val);
>  }
>  
> diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c
> index 0eafdf0..d6873b4 100644
> --- a/arch/powerpc/mm/pkeys.c
> +++ b/arch/powerpc/mm/pkeys.c
> @@ -119,16 +119,21 @@ int pkey_initialize(void)
>  #else
>  	os_reserved = 0;
>  #endif
> +	/* Bits are in LE format. */
>  	initial_allocation_mask = ~0x0;
> +
> +	/* register mask is in BE format */
>  	pkey_amr_uamor_mask = ~0x0ul;
>  	pkey_iamr_mask = ~0x0ul;
> -	/*
> -	 * key 0, 1 are reserved.
> -	 * key 0 is the default key, which allows read/write/execute.
> -	 * key 1 is recommended not to be used. PowerISA(3.0) page
> 1015,
> -	 * programming note.
> -	 */
> -	for (i = 2; i < (pkeys_total - os_reserved); i++) {
> +
> +	for (i = 0; i < (pkeys_total - os_reserved); i++) {
> +		/*
> +		 * key 1 is recommended not to be used.
> +		 * PowerISA(3.0) page 1015,
> +		 */
> +		if (i == 1)
> +			continue;
> +
>  		initial_allocation_mask &= ~(0x1 << i);
>  		pkey_amr_uamor_mask &= ~(0x3ul << pkeyshift(i));
>  		pkey_iamr_mask &= ~(0x1ul << pkeyshift(i));
> @@ -142,7 +147,9 @@ void pkey_mm_init(struct mm_struct *mm)
>  {
>  	if (static_branch_likely(&pkey_disabled))
>  		return;
> -	mm_pkey_allocation_map(mm) = initial_allocation_mask;
> +
> +	/* allocate key-0 by default */
> +	mm_pkey_allocation_map(mm) = initial_allocation_mask | 0x1;
>  	/* -1 means unallocated or invalid */
>  	mm->context.execute_only_pkey = -1;
>  }
> @@ -407,9 +414,6 @@ static bool pkey_access_permitted(int pkey, bool
> write, bool execute) int pkey_shift;
>  	u64 amr;
>  
> -	if (!pkey)
> -		return true;
> -
>  	if (!is_pkey_enabled(pkey))
>  		return true;
>  

^ permalink raw reply

* Re: [PATCH 2/7] DAC960: don't use block layer bounce buffers
From: Johannes Thumshirn @ 2018-05-09 15:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Ed L. Cashin, Geoff Levand, Maxim Levitsky,
	linux-block, linuxppc-dev, linux-mtd, sparclinux
In-Reply-To: <20180509135948.20329-3-hch@lst.de>

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply

* Re: [PATCH 1/7] mtip32xx: don't use block layer bounce buffers
From: Johannes Thumshirn @ 2018-05-09 15:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Ed L. Cashin, Geoff Levand, Maxim Levitsky,
	linux-block, linuxppc-dev, linux-mtd, sparclinux
In-Reply-To: <20180509135948.20329-2-hch@lst.de>

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply

* Re: [1/2] powerpc/trace elfv1: Update syscall name matching logic
From: Michael Ellerman @ 2018-05-09 14:59 UTC (permalink / raw)
  To: Naveen N. Rao; +Cc: linuxppc-dev, Dominik Brodowski
In-Reply-To: <c50df60c9ca8309df56e0eb9a00072c154897764.1525439237.git.naveen.n.rao@linux.vnet.ibm.com>

On Fri, 2018-05-04 at 13:14:24 UTC, "Naveen N. Rao" wrote:
> On powerpc64 ABIv1, we are enabling syscall tracing for only ~20
> syscalls. This is due to commit e145242ea0df6 ("syscalls/core,
> syscalls/x86: Clean up syscall stub naming convention") which has
> changed the syscall entry wrapper prefix from "SyS" to "__se_sys".
> 
> Update the logic for ABIv1 to not just skip the initial dot, but also
> the "__se_sys" prefix.
> 
> Fixes: commit e145242ea0df6 ("syscalls/core, syscalls/x86: Clean up syscall stub naming convention")
> Reported-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>

Series applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/0b7758aaf6543b9a10c8671db559e9

cheers

^ permalink raw reply

* Re: powerpc/64: Remove unused paca->soft_enabled
From: Michael Ellerman @ 2018-05-09 14:59 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: maddy, npiggin
In-Reply-To: <20180502065754.13816-1-mpe@ellerman.id.au>

On Wed, 2018-05-02 at 06:57:54 UTC, Michael Ellerman wrote:
> In commit 4e26bc4a4ed6 ("powerpc/64: Rename soft_enabled to
> irq_soft_mask") we renamed paca->soft_enabled. But then in commit
> 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not
> virtualized") we added it back. Oops. This happened because the two
> patches were in flight at the same time and rebased vs each other
> multiple times, and we missed it in review.
> 
> Fixes: 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not virtualized")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/c4ec1f0353b342473b93637fd0c3fb

cheers

^ permalink raw reply

* [PATCH] powerpc/pseries: Fix CONFIG_NUMA=n build
From: Michael Ellerman @ 2018-05-09 14:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mwb

The build is failing with CONFIG_NUMA=n and some compiler versions:

  arch/powerpc/platforms/pseries/hotplug-cpu.o: In function `dlpar_online_cpu':
  hotplug-cpu.c:(.text+0x12c): undefined reference to `timed_topology_update'
  arch/powerpc/platforms/pseries/hotplug-cpu.o: In function `dlpar_cpu_remove':
  hotplug-cpu.c:(.text+0x400): undefined reference to `timed_topology_update'

Fix it by moving the empty version of timed_topology_update() into the
existing #ifdef block, which has the right guard of SPLPAR && NUMA.

Fixes: cee5405da402 ("powerpc/hotplug: Improve responsiveness of hotplug change")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/topology.h | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 9f421641a35c..16b077801a5f 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -91,6 +91,7 @@ extern int start_topology_update(void);
 extern int stop_topology_update(void);
 extern int prrn_is_enabled(void);
 extern int find_and_online_cpu_nid(int cpu);
+extern int timed_topology_update(int nsecs);
 #else
 static inline int start_topology_update(void)
 {
@@ -108,16 +109,12 @@ static inline int find_and_online_cpu_nid(int cpu)
 {
 	return 0;
 }
+static inline int timed_topology_update(int nsecs)
+{
+	return 0;
+}
 #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
 
-#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_NEED_MULTIPLE_NODES)
-#if defined(CONFIG_PPC_SPLPAR)
-extern int timed_topology_update(int nsecs);
-#else
-#define	timed_topology_update(nsecs)
-#endif /* CONFIG_PPC_SPLPAR */
-#endif /* CONFIG_HOTPLUG_CPU || CONFIG_NEED_MULTIPLE_NODES */
-
 #include <asm-generic/topology.h>
 
 #ifdef CONFIG_SMP
-- 
2.14.1

^ permalink raw reply related


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