Re: [PATCH v3 05/19] powerpc: interrupt handler wrapper functions

2020-11-29 Thread Aneesh Kumar K.V
Nicholas Piggin  writes:

.
 +#endif
> +DECLARE_INTERRUPT_HANDLER(emulation_assist_interrupt);
> +DECLARE_INTERRUPT_HANDLER_RAW(do_slb_fault);

Can we add comments here explaining why some of these handlers need to remain 
RAW()?

> +DECLARE_INTERRUPT_HANDLER(do_bad_slb_fault);
> +DECLARE_INTERRUPT_HANDLER_RET(do_hash_fault);
> +DECLARE_INTERRUPT_HANDLER_RET(do_page_fault);
> +DECLARE_INTERRUPT_HANDLER(do_bad_page_fault);
> +
> +DECLARE_INTERRUPT_HANDLER_ASYNC(timer_interrupt);
> +DECLARE_INTERRUPT_HANDLER_NMI(performance_monitor_exception_nmi);
> +DECLARE_INTERRUPT_HANDLER_ASYNC(performance_monitor_exception_async);
> +DECLARE_INTERRUPT_HANDLER_RAW(performance_monitor_exception);

Same for this.

> +DECLARE_INTERRUPT_HANDLER(WatchdogException);
> +DECLARE_INTERRUPT_HANDLER(unknown_exception);
> +DECLARE_INTERRUPT_HANDLER_ASYNC(unknown_async_exception);
> +
> +void replay_system_reset(void);
> +void replay_soft_interrupts(void);
> +
> +#endif /* _ASM_POWERPC_INTERRUPT_H */
> diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h
> index 2f566c1a754c..335d6fd589a7 100644
> --- a/arch/powerpc/include/asm/time.h
> +++ b/arch/powerpc/include/asm/time.h
> @@ -131,6 +131,8 @@ DECLARE_PER_CPU(u64, decrementers_next_tb);
>  /* Convert timebase ticks to nanoseconds */
>  unsigned long long tb_to_ns(unsigned long long tb_ticks);
>  
> +void timer_broadcast_interrupt(void);
> +
>  /* SPLPAR */
>  void accumulate_stolen_time(void);
>  
> 

-aneesh


Re: [PATCH v3 03/19] powerpc: bad_page_fault, do_break get registers from regs

2020-11-29 Thread Aneesh Kumar K.V
Nicholas Piggin  writes:

> Similar to the previous patch this makes interrupt handler function
> types more regular so they can be wrapped with the next patch.
>
> bad_page_fault and do_break are not performance critical.
>

Reviewed-by: Aneesh Kumar K.V 

> [32s DABR code from Christophe Leroy ]
> Signed-off-by: Nicholas Piggin 
> ---
>  arch/powerpc/include/asm/bug.h |  2 +-
>  arch/powerpc/include/asm/debug.h   |  3 +--
>  arch/powerpc/kernel/entry_32.S | 18 +-
>  arch/powerpc/kernel/exceptions-64e.S   |  3 +--
>  arch/powerpc/kernel/exceptions-64s.S   |  3 +--
>  arch/powerpc/kernel/head_8xx.S |  5 ++---
>  arch/powerpc/kernel/head_book3s_32.S   |  3 +++
>  arch/powerpc/kernel/process.c  |  7 +++
>  arch/powerpc/kernel/traps.c|  2 +-
>  arch/powerpc/mm/book3s64/hash_utils.c  |  4 ++--
>  arch/powerpc/mm/book3s64/slb.c |  2 +-
>  arch/powerpc/mm/fault.c| 10 +-
>  arch/powerpc/platforms/8xx/machine_check.c |  2 +-
>  13 files changed, 23 insertions(+), 41 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
> index 897bad6b6bbb..49162faba33f 100644
> --- a/arch/powerpc/include/asm/bug.h
> +++ b/arch/powerpc/include/asm/bug.h
> @@ -113,7 +113,7 @@
>  struct pt_regs;
>  long do_page_fault(struct pt_regs *);
>  long hash__do_page_fault(struct pt_regs *);
> -extern void bad_page_fault(struct pt_regs *, unsigned long, int);
> +void bad_page_fault(struct pt_regs *, int);
>  extern void _exception(int, struct pt_regs *, int, unsigned long);
>  extern void _exception_pkey(struct pt_regs *, unsigned long, int);
>  extern void die(const char *, struct pt_regs *, long);
> diff --git a/arch/powerpc/include/asm/debug.h 
> b/arch/powerpc/include/asm/debug.h
> index ec57daf87f40..0550eceab3ca 100644
> --- a/arch/powerpc/include/asm/debug.h
> +++ b/arch/powerpc/include/asm/debug.h
> @@ -52,8 +52,7 @@ extern void do_send_trap(struct pt_regs *regs, unsigned 
> long address,
>unsigned long error_code, int brkpt);
>  #else
>  
> -extern void do_break(struct pt_regs *regs, unsigned long address,
> -  unsigned long error_code);
> +void do_break(struct pt_regs *regs);
>  #endif
>  
>  #endif /* _ASM_POWERPC_DEBUG_H */
> diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
> index 8cdc8bcde703..57b8e95ea2a0 100644
> --- a/arch/powerpc/kernel/entry_32.S
> +++ b/arch/powerpc/kernel/entry_32.S
> @@ -657,10 +657,6 @@ ppc_swapcontext:
>   .globl  handle_page_fault
>  handle_page_fault:
>   addir3,r1,STACK_FRAME_OVERHEAD
> -#ifdef CONFIG_PPC_BOOK3S_32
> - andis.  r0,r5,DSISR_DABRMATCH@h
> - bne-handle_dabr_fault
> -#endif
>   bl  do_page_fault
>   cmpwi   r3,0
>   beq+ret_from_except
> @@ -668,23 +664,11 @@ handle_page_fault:
>   lwz r0,_TRAP(r1)
>   clrrwi  r0,r0,1
>   stw r0,_TRAP(r1)
> - mr  r5,r3
> + mr  r4,r3   /* err arg for bad_page_fault */
>   addir3,r1,STACK_FRAME_OVERHEAD
> - lwz r4,_DAR(r1)
>   bl  bad_page_fault
>   b   ret_from_except_full
>  
> -#ifdef CONFIG_PPC_BOOK3S_32
> - /* We have a data breakpoint exception - handle it */
> -handle_dabr_fault:
> - SAVE_NVGPRS(r1)
> - lwz r0,_TRAP(r1)
> - clrrwi  r0,r0,1
> - stw r0,_TRAP(r1)
> - bl  do_break
> - b   ret_from_except_full
> -#endif
> -
>  /*
>   * This routine switches between two different tasks.  The process
>   * state of one is saved on its kernel stack.  Then the state
> diff --git a/arch/powerpc/kernel/exceptions-64e.S 
> b/arch/powerpc/kernel/exceptions-64e.S
> index 25fa7d5a643c..dc728bb1c89a 100644
> --- a/arch/powerpc/kernel/exceptions-64e.S
> +++ b/arch/powerpc/kernel/exceptions-64e.S
> @@ -1018,9 +1018,8 @@ storage_fault_common:
>   bne-1f
>   b   ret_from_except_lite
>  1:   bl  save_nvgprs
> - mr  r5,r3
> + mr  r4,r3
>   addir3,r1,STACK_FRAME_OVERHEAD
> - ld  r4,_DAR(r1)
>   bl  bad_page_fault
>   b   ret_from_except
>  
> diff --git a/arch/powerpc/kernel/exceptions-64s.S 
> b/arch/powerpc/kernel/exceptions-64s.S
> index 690058043b17..77b730f515c4 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -2136,8 +2136,7 @@ EXC_COMMON_BEGIN(h_data_storage_common)
>   GEN_COMMON h_data_storage
>   addir3,r1,STACK_FRAME_OVERHEAD
>  BEGIN_MMU_FTR_SECTION
> - ld  r4,_DAR(r1)
> - li  r5,SIGSEGV
> + li  r4,SIGSEGV
>   bl  bad_page_fault
>  MMU_FTR_SECTION_ELSE
>   bl  unknown_exception
> diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
> index 8acd365a2be6..71ad7ce28469 100644
> --- a/arch/powerpc/kernel/head_8xx.S
> +++ b/arch/powerpc/kernel/head_8xx.S
> @@ 

Re: [PATCH v3 02/19] powerpc: remove arguments from fault handler functions

2020-11-29 Thread Aneesh Kumar K.V
Nicholas Piggin  writes:

> Make mm fault handlers all just take the pt_regs * argument and load
> DAR/DSISR from that. Make those that return a value return long.
>
> This is done to make the function signatures match other handlers, which
> will help with a future patch to add wrappers. Explicit arguments could
> be added for performance but that would require more wrapper macro
> variants.

Reviewed-by: Aneesh Kumar K.V 
>
> Signed-off-by: Nicholas Piggin 
> ---
>  arch/powerpc/include/asm/asm-prototypes.h |  4 ++--
>  arch/powerpc/include/asm/book3s/64/mmu-hash.h |  2 +-
>  arch/powerpc/include/asm/bug.h|  4 ++--
>  arch/powerpc/kernel/exceptions-64e.S  |  2 --
>  arch/powerpc/kernel/exceptions-64s.S  | 14 ++
>  arch/powerpc/kernel/head_40x.S| 10 +-
>  arch/powerpc/kernel/head_8xx.S|  6 +++---
>  arch/powerpc/kernel/head_book3s_32.S  |  6 ++
>  arch/powerpc/kernel/head_booke.h  |  4 +---
>  arch/powerpc/mm/book3s64/hash_utils.c |  8 +---
>  arch/powerpc/mm/book3s64/slb.c| 11 +++
>  arch/powerpc/mm/fault.c   | 16 +---
>  12 files changed, 39 insertions(+), 48 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/asm-prototypes.h 
> b/arch/powerpc/include/asm/asm-prototypes.h
> index d0b832cbbec8..22c9d08fa3a4 100644
> --- a/arch/powerpc/include/asm/asm-prototypes.h
> +++ b/arch/powerpc/include/asm/asm-prototypes.h
> @@ -82,8 +82,8 @@ void kernel_bad_stack(struct pt_regs *regs);
>  void system_reset_exception(struct pt_regs *regs);
>  void machine_check_exception(struct pt_regs *regs);
>  void emulation_assist_interrupt(struct pt_regs *regs);
> -long do_slb_fault(struct pt_regs *regs, unsigned long ea);
> -void do_bad_slb_fault(struct pt_regs *regs, unsigned long ea, long err);
> +long do_slb_fault(struct pt_regs *regs);
> +void do_bad_slb_fault(struct pt_regs *regs);
>  
>  /* signals, syscalls and interrupts */
>  long sys_swapcontext(struct ucontext __user *old_ctx,
> diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h 
> b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> index bc8c91f2d26f..e843d0b193d3 100644
> --- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> +++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> @@ -453,7 +453,7 @@ static inline unsigned long hpt_hash(unsigned long vpn,
>  #define HPTE_LOCAL_UPDATE0x1
>  #define HPTE_NOHPTE_UPDATE   0x2
>  
> -int do_hash_fault(struct pt_regs *regs, unsigned long ea, unsigned long 
> dsisr);
> +long do_hash_fault(struct pt_regs *regs);
>  extern int __hash_page_4K(unsigned long ea, unsigned long access,
> unsigned long vsid, pte_t *ptep, unsigned long trap,
> unsigned long flags, int ssize, int subpage_prot);
> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
> index c0e9b7a967a8..897bad6b6bbb 100644
> --- a/arch/powerpc/include/asm/bug.h
> +++ b/arch/powerpc/include/asm/bug.h
> @@ -111,8 +111,8 @@
>  #ifndef __ASSEMBLY__
>  
>  struct pt_regs;
> -extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long);
> -int hash__do_page_fault(struct pt_regs *, unsigned long, unsigned long);
> +long do_page_fault(struct pt_regs *);
> +long hash__do_page_fault(struct pt_regs *);
>  extern void bad_page_fault(struct pt_regs *, unsigned long, int);
>  extern void _exception(int, struct pt_regs *, int, unsigned long);
>  extern void _exception_pkey(struct pt_regs *, unsigned long, int);
> diff --git a/arch/powerpc/kernel/exceptions-64e.S 
> b/arch/powerpc/kernel/exceptions-64e.S
> index f579ce46eef2..25fa7d5a643c 100644
> --- a/arch/powerpc/kernel/exceptions-64e.S
> +++ b/arch/powerpc/kernel/exceptions-64e.S
> @@ -1011,8 +1011,6 @@ storage_fault_common:
>   std r14,_DAR(r1)
>   std r15,_DSISR(r1)
>   addir3,r1,STACK_FRAME_OVERHEAD
> - mr  r4,r14
> - mr  r5,r15
>   ld  r14,PACA_EXGEN+EX_R14(r13)
>   ld  r15,PACA_EXGEN+EX_R15(r13)
>   bl  do_page_fault
> diff --git a/arch/powerpc/kernel/exceptions-64s.S 
> b/arch/powerpc/kernel/exceptions-64s.S
> index 336fa1fa39d1..690058043b17 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -1438,8 +1438,6 @@ EXC_VIRT_BEGIN(data_access, 0x4300, 0x80)
>  EXC_VIRT_END(data_access, 0x4300, 0x80)
>  EXC_COMMON_BEGIN(data_access_common)
>   GEN_COMMON data_access
> - ld  r4,_DAR(r1)
> - ld  r5,_DSISR(r1)
>   addir3,r1,STACK_FRAME_OVERHEAD
>  BEGIN_MMU_FTR_SECTION
>   bl  do_hash_fault
> @@ -1492,10 +1490,9 @@ EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80)
>  EXC_VIRT_END(data_access_slb, 0x4380, 0x80)
>  EXC_COMMON_BEGIN(data_access_slb_common)
>   GEN_COMMON data_access_slb
> - ld  r4,_DAR(r1)
> - addir3,r1,STACK_FRAME_OVERHEAD
>  BEGIN_MMU_FTR_SECTION
>   /* HPT case, do SLB 

Re: [PATCH v3 01/19] powerpc/64s: move the last of the page fault handling logic to C

2020-11-29 Thread Aneesh Kumar K.V
Nicholas Piggin  writes:

> The page fault handling still has some complex logic particularly around
> hash table handling, in asm. Implement this in C instead.
>

Reviewed-by: Aneesh Kumar K.V 

> Signed-off-by: Nicholas Piggin 
> ---
>  arch/powerpc/include/asm/book3s/64/mmu-hash.h |   1 +
>  arch/powerpc/include/asm/bug.h|   1 +
>  arch/powerpc/kernel/exceptions-64s.S  | 131 +++---
>  arch/powerpc/mm/book3s64/hash_utils.c |  77 ++
>  arch/powerpc/mm/fault.c   |  57 +++-
>  5 files changed, 127 insertions(+), 140 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h 
> b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> index 683a9c7d1b03..bc8c91f2d26f 100644
> --- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> +++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> @@ -453,6 +453,7 @@ static inline unsigned long hpt_hash(unsigned long vpn,
>  #define HPTE_LOCAL_UPDATE0x1
>  #define HPTE_NOHPTE_UPDATE   0x2
>  
> +int do_hash_fault(struct pt_regs *regs, unsigned long ea, unsigned long 
> dsisr);
>  extern int __hash_page_4K(unsigned long ea, unsigned long access,
> unsigned long vsid, pte_t *ptep, unsigned long trap,
> unsigned long flags, int ssize, int subpage_prot);
> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
> index 338f36cd9934..c0e9b7a967a8 100644
> --- a/arch/powerpc/include/asm/bug.h
> +++ b/arch/powerpc/include/asm/bug.h
> @@ -112,6 +112,7 @@
>  
>  struct pt_regs;
>  extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long);
> +int hash__do_page_fault(struct pt_regs *, unsigned long, unsigned long);
>  extern void bad_page_fault(struct pt_regs *, unsigned long, int);
>  extern void _exception(int, struct pt_regs *, int, unsigned long);
>  extern void _exception_pkey(struct pt_regs *, unsigned long, int);
> diff --git a/arch/powerpc/kernel/exceptions-64s.S 
> b/arch/powerpc/kernel/exceptions-64s.S
> index 4d01f09ecf80..336fa1fa39d1 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -1401,14 +1401,15 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
>   *
>   * Handling:
>   * - Hash MMU
> - *   Go to do_hash_page first to see if the HPT can be filled from an entry 
> in
> - *   the Linux page table. Hash faults can hit in kernel mode in a fairly
> + *   Go to do_hash_fault, which attempts to fill the HPT from an entry in the
> + *   Linux page table. Hash faults can hit in kernel mode in a fairly
>   *   arbitrary state (e.g., interrupts disabled, locks held) when accessing
>   *   "non-bolted" regions, e.g., vmalloc space. However these should always 
> be
> - *   backed by Linux page tables.
> + *   backed by Linux page table entries.
>   *
> - *   If none is found, do a Linux page fault. Linux page faults can happen in
> - *   kernel mode due to user copy operations of course.
> + *   If no entry is found the Linux page fault handler is invoked (by
> + *   do_hash_fault). Linux page faults can happen in kernel mode due to user
> + *   copy operations of course.
>   *
>   *   KVM: The KVM HDSI handler may perform a load with MSR[DR]=1 in guest
>   *   MMU context, which may cause a DSI in the host, which must go to the
> @@ -1439,13 +1440,17 @@ EXC_COMMON_BEGIN(data_access_common)
>   GEN_COMMON data_access
>   ld  r4,_DAR(r1)
>   ld  r5,_DSISR(r1)
> + addir3,r1,STACK_FRAME_OVERHEAD
>  BEGIN_MMU_FTR_SECTION
> - ld  r6,_MSR(r1)
> - li  r3,0x300
> - b   do_hash_page/* Try to handle as hpte fault */
> + bl  do_hash_fault
>  MMU_FTR_SECTION_ELSE
> - b   handle_page_fault
> + bl  do_page_fault
>  ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
> +cmpdir3,0
> + beq+interrupt_return
> + /* We need to restore NVGPRS */
> + REST_NVGPRS(r1)
> + b   interrupt_return
>  
>   GEN_KVM data_access
>  
> @@ -1540,13 +1545,17 @@ EXC_COMMON_BEGIN(instruction_access_common)
>   GEN_COMMON instruction_access
>   ld  r4,_DAR(r1)
>   ld  r5,_DSISR(r1)
> + addir3,r1,STACK_FRAME_OVERHEAD
>  BEGIN_MMU_FTR_SECTION
> - ld  r6,_MSR(r1)
> - li  r3,0x400
> - b   do_hash_page/* Try to handle as hpte fault */
> + bl  do_hash_fault
>  MMU_FTR_SECTION_ELSE
> - b   handle_page_fault
> + bl  do_page_fault
>  ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
> +cmpdir3,0
> + beq+interrupt_return
> + /* We need to restore NVGPRS */
> + REST_NVGPRS(r1)
> + b   interrupt_return
>  
>   GEN_KVM instruction_access
>  
> @@ -3202,99 +3211,3 @@ disable_machine_check:
>   RFI_TO_KERNEL
>  1:   mtlrr0
>   blr
> -
> -/*
> - * Hash table stuff
> - */
> - .balign IFETCH_ALIGN_BYTES
> -do_hash_page:
> -#ifdef 

Re: [PATCH 2/3] powerpc/pseries/hotplug-cpu: fix memleak in dlpar_cpu_add_by_count

2020-11-29 Thread Qinglang Miao




在 2020/11/30 9:51, Michael Ellerman 写道:

Qinglang Miao  writes:

kfree(cpu_drcs) should be called when it fails to perform
of_find_node_by_path("/cpus") in dlpar_cpu_add_by_count,
otherwise there would be a memleak.

In fact, the patch a0ff72f9f5a7 ought to remove kfree in
find_dlpar_cpus_to_add rather than dlpar_cpu_add_by_count.
I guess there might be a mistake when apply that one.

Fixes: a0ff72f9f5a7 ("powerpc/pseries/hotplug-cpu: Remove double free in error 
path")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
  arch/powerpc/platforms/pseries/hotplug-cpu.c | 1 +
  1 file changed, 1 insertion(+)


This is already fixed in my next by:

   a40fdaf1420d ("Revert "powerpc/pseries/hotplug-cpu: Remove double free in error 
path"")

cheers'Revert' sounds resonable to this one, glad to know that.


diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c 
b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index f2837e33b..4bb1c9f2b 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -743,6 +743,7 @@ static int dlpar_cpu_add_by_count(u32 cpus_to_add)
parent = of_find_node_by_path("/cpus");
if (!parent) {
pr_warn("Could not find CPU root node in device tree\n");
+   kfree(cpu_drcs);
return -1;
}
  
--

2.23.0

.



Re: [PATCH] powerpc: Allow relative pointers in bug table entries

2020-11-29 Thread Christophe Leroy




Le 30/11/2020 à 02:50, Jordan Niethe a écrit :

On Mon, Nov 30, 2020 at 12:42 PM Michael Ellerman  wrote:


Christophe Leroy  writes:

Le 27/11/2020 à 04:02, Jordan Niethe a écrit :

This enables GENERIC_BUG_RELATIVE_POINTERS on Power so that 32-bit
offsets are stored in the bug entries rather than 64-bit pointers.

Signed-off-by: Jordan Niethe 
---
   arch/powerpc/Kconfig   |  4 
   arch/powerpc/include/asm/bug.h | 37 --
   arch/powerpc/xmon/xmon.c   | 17 ++--
   3 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e9f13fe08492..294108e0e5c6 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -311,6 +311,10 @@ config GENERIC_BUG
  default y
  depends on BUG

+config GENERIC_BUG_RELATIVE_POINTERS
+def_bool y
+depends on GENERIC_BUG
+
   config SYS_SUPPORTS_APM_EMULATION
  default y if PMAC_APM_EMU
  bool
diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index 338f36cd9934..d03d834042a1 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -12,7 +12,11 @@
   #ifdef CONFIG_DEBUG_BUGVERBOSE
   .macro EMIT_BUG_ENTRY addr,file,line,flags
   .section __bug_table,"aw"
+#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS


As far as I understand, as soon as CONFIG_BUG is selected, GENERIC_BUG is 
automatically selected so
GENERIC_BUG_RELATIVE_POINTERS is selected as well. Therefore this #ifndef is 
never possible.


Yeah.

There is one place in the generic code that has an ifndef 
CONFIG_GENERIC_BUG_RELATIVE_POINTERS
but that's because it has to support arches that don't select it.

In the arch code we know that it's enabled, so there should be no need
for any ifdefs.

For 32bit, pointers are 4 bytes anyway so it would be pointless to
store a displacement, so won't we need some ifdefs for that?


I'd say it the other way round:

For 32bit, pointers are 4 bytes anyway so it would be pointless to
make it different from 64bit.

We are definitely not on a performance critical path when dealing with bug entries, so I think it is 
better to keep a common code for PPC32 and PPC64.


Christophe


Re: [PATCH 1/8] powerpc/64s/powernv: Fix memory corruption when saving SLB entries on MCE

2020-11-29 Thread Mahesh J Salgaonkar
On 2020-11-28 17:07:21 Sat, Nicholas Piggin wrote:
> This can be hit by an HPT guest running on an HPT host and bring down
> the host, so it's quite important to fix.
> 
> Fixes: 7290f3b3d3e66 ("powerpc/64s/powernv: machine check dump SLB contents")
> Signed-off-by: Nicholas Piggin 
> ---
>  arch/powerpc/platforms/powernv/setup.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/setup.c 
> b/arch/powerpc/platforms/powernv/setup.c
> index 46115231a3b2..4426a109ec2f 100644
> --- a/arch/powerpc/platforms/powernv/setup.c
> +++ b/arch/powerpc/platforms/powernv/setup.c
> @@ -211,11 +211,16 @@ static void __init pnv_init(void)
>   add_preferred_console("hvc", 0, NULL);
>  
>   if (!radix_enabled()) {
> + size_t size = sizeof(struct slb_entry) * mmu_slb_size;

Acked-by: Mahesh Salgaonkar 

Thanks,
-Mahesh.


>   int i;
>  
>   /* Allocate per cpu area to save old slb contents during MCE */
> - for_each_possible_cpu(i)
> - paca_ptrs[i]->mce_faulty_slbs = 
> memblock_alloc_node(mmu_slb_size, 
> __alignof__(*paca_ptrs[i]->mce_faulty_slbs), cpu_to_node(i));
> + for_each_possible_cpu(i) {
> + paca_ptrs[i]->mce_faulty_slbs =
> + memblock_alloc_node(size,
> + __alignof__(struct slb_entry),
> + cpu_to_node(i));
> + }
>   }
>  }
>  
> -- 
> 2.23.0
> 

-- 
Mahesh J Salgaonkar


[PATCH] powerpc/xmon: Fix build failure for 8xx

2020-11-29 Thread Ravi Bangoria
With CONFIG_PPC_8xx and CONFIG_XMON set, kernel build fails with

  arch/powerpc/xmon/xmon.c:1379:12: error: 'find_free_data_bpt' defined
  but not used [-Werror=unused-function]

Fix it by enclosing find_free_data_bpt() inside #ifndef CONFIG_PPC_8xx.

Reported-by: kernel test robot 
Fixes: 30df74d67d48 ("powerpc/watchpoint/xmon: Support 2nd DAWR")
Signed-off-by: Ravi Bangoria 
---
 arch/powerpc/xmon/xmon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 55c43a6c9111..5559edf36756 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1383,6 +1383,7 @@ static long check_bp_loc(unsigned long addr)
return 1;
 }
 
+#ifndef CONFIG_PPC_8xx
 static int find_free_data_bpt(void)
 {
int i;
@@ -1394,6 +1395,7 @@ static int find_free_data_bpt(void)
printf("Couldn't find free breakpoint register\n");
return -1;
 }
+#endif
 
 static void print_data_bpts(void)
 {
-- 
2.17.1



Re: [RFC PATCH] KVM: PPC: Book3S HV: Remove support for running HPT guest on RPT host without mixed mode support

2020-11-29 Thread Michael Ellerman
Nicholas Piggin  writes:
> This reverts much of commit c01015091a770 ("KVM: PPC: Book3S HV: Run HPT
> guests on POWER9 radix hosts"), which was required to run HPT guests on
> RPT hosts on early POWER9 CPUs without support for "mixed mode", which
> meant the host could not run with MMU on while guests were running.

Would be worth mentioning which CPU versions. 

Looking at the code it seems like it's P9N < 2.2 and P9C < 1.1.

> This code has some corner case bugs, e.g., when the guest hits a machine
> check or HMI the primary locks up waiting for secondaries to switch LPCR
> to host, which they never do. This could all be fixed in software, but
> most CPUs in production have mixed mode support, and those that don't
> are believed to be all in installations that don't use this capability.
> So simplify things and remove support.

Key detail being, AFAICS, you retain enough code to detect that we're in
that configuration and cleanly return an error, rather than crashing or
anything horrible.

Otherwise looks good to me.

cheers

> diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h 
> b/arch/powerpc/include/asm/kvm_book3s_asm.h
> index 078f4648ea27..b6d31bff5209 100644
> --- a/arch/powerpc/include/asm/kvm_book3s_asm.h
> +++ b/arch/powerpc/include/asm/kvm_book3s_asm.h
> @@ -74,16 +74,6 @@ struct kvm_split_mode {
>   u8  do_nap;
>   u8  napped[MAX_SMT_THREADS];
>   struct kvmppc_vcore *vc[MAX_SUBCORES];
> - /* Bits for changing lpcr on P9 */
> - unsigned long   lpcr_req;
> - unsigned long   lpidr_req;
> - unsigned long   host_lpcr;
> - u32 do_set;
> - u32 do_restore;
> - union {
> - u32 allphases;
> - u8  phase[4];
> - } lpcr_sync;
>  };
>  
>  /*
> @@ -110,7 +100,6 @@ struct kvmppc_host_state {
>   u8 hwthread_state;
>   u8 host_ipi;
>   u8 ptid;/* thread number within subcore when split */
> - u8 tid; /* thread number within whole core */
>   u8 fake_suspend;
>   struct kvm_vcpu *kvm_vcpu;
>   struct kvmppc_vcore *kvm_vcore;
> diff --git a/arch/powerpc/kernel/asm-offsets.c 
> b/arch/powerpc/kernel/asm-offsets.c
> index c2722ff36e98..21496ea09bf1 100644
> --- a/arch/powerpc/kernel/asm-offsets.c
> +++ b/arch/powerpc/kernel/asm-offsets.c
> @@ -690,7 +690,6 @@ int main(void)
>   HSTATE_FIELD(HSTATE_SAVED_XIRR, saved_xirr);
>   HSTATE_FIELD(HSTATE_HOST_IPI, host_ipi);
>   HSTATE_FIELD(HSTATE_PTID, ptid);
> - HSTATE_FIELD(HSTATE_TID, tid);
>   HSTATE_FIELD(HSTATE_FAKE_SUSPEND, fake_suspend);
>   HSTATE_FIELD(HSTATE_MMCR0, host_mmcr[0]);
>   HSTATE_FIELD(HSTATE_MMCR1, host_mmcr[1]);
> @@ -720,8 +719,6 @@ int main(void)
>   OFFSET(KVM_SPLIT_LDBAR, kvm_split_mode, ldbar);
>   OFFSET(KVM_SPLIT_DO_NAP, kvm_split_mode, do_nap);
>   OFFSET(KVM_SPLIT_NAPPED, kvm_split_mode, napped);
> - OFFSET(KVM_SPLIT_DO_SET, kvm_split_mode, do_set);
> - OFFSET(KVM_SPLIT_DO_RESTORE, kvm_split_mode, do_restore);
>  #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
>  
>  #ifdef CONFIG_PPC_BOOK3S_64
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index c94f9595133d..86b78f8e3dde 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -134,7 +134,7 @@ static inline bool nesting_enabled(struct kvm *kvm)
>  }
>  
>  /* If set, the threads on each CPU core have to be in the same MMU mode */
> -static bool no_mixing_hpt_and_radix;
> +static bool no_mixing_hpt_and_radix __read_mostly;
>  
>  static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu);
>  
> @@ -2855,11 +2855,6 @@ static bool can_dynamic_split(struct kvmppc_vcore *vc, 
> struct core_info *cip)
>   if (one_vm_per_core && vc->kvm != cip->vc[0]->kvm)
>   return false;
>  
> - /* Some POWER9 chips require all threads to be in the same MMU mode */
> - if (no_mixing_hpt_and_radix &&
> - kvm_is_radix(vc->kvm) != kvm_is_radix(cip->vc[0]->kvm))
> - return false;
> -
>   if (n_threads < cip->max_subcore_threads)
>   n_threads = cip->max_subcore_threads;
>   if (!subcore_config_ok(cip->n_subcores + 1, n_threads))
> @@ -2898,6 +2893,9 @@ static void prepare_threads(struct kvmppc_vcore *vc)
>   for_each_runnable_thread(i, vcpu, vc) {
>   if (signal_pending(vcpu->arch.run_task))
>   vcpu->arch.ret = -EINTR;
> + else if (no_mixing_hpt_and_radix &&
> +  kvm_is_radix(vc->kvm) != radix_enabled())
> + vcpu->arch.ret = -EINVAL;
>   else if (vcpu->arch.vpa.update_pending ||
>vcpu->arch.slb_shadow.update_pending ||
>vcpu->arch.dtl.update_pending)
> @@ -3103,7 +3101,6 @@ static noinline void kvmppc_run_core(struct 
> kvmppc_vcore *vc)
>   int controlled_threads;
>   int trap;
>   bool is_power8;
> - 

Re: [PATCH 2/3] powerpc/pseries/hotplug-cpu: fix memleak in dlpar_cpu_add_by_count

2020-11-29 Thread Michael Ellerman
Qinglang Miao  writes:
> kfree(cpu_drcs) should be called when it fails to perform
> of_find_node_by_path("/cpus") in dlpar_cpu_add_by_count,
> otherwise there would be a memleak.
>
> In fact, the patch a0ff72f9f5a7 ought to remove kfree in
> find_dlpar_cpus_to_add rather than dlpar_cpu_add_by_count.
> I guess there might be a mistake when apply that one.
>
> Fixes: a0ff72f9f5a7 ("powerpc/pseries/hotplug-cpu: Remove double free in 
> error path")
> Reported-by: Hulk Robot 
> Signed-off-by: Qinglang Miao 
> ---
>  arch/powerpc/platforms/pseries/hotplug-cpu.c | 1 +
>  1 file changed, 1 insertion(+)

This is already fixed in my next by:

  a40fdaf1420d ("Revert "powerpc/pseries/hotplug-cpu: Remove double free in 
error path"")

cheers

> diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c 
> b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> index f2837e33b..4bb1c9f2b 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> @@ -743,6 +743,7 @@ static int dlpar_cpu_add_by_count(u32 cpus_to_add)
>   parent = of_find_node_by_path("/cpus");
>   if (!parent) {
>   pr_warn("Could not find CPU root node in device tree\n");
> + kfree(cpu_drcs);
>   return -1;
>   }
>  
> -- 
> 2.23.0


Re: [PATCH] powerpc: Allow relative pointers in bug table entries

2020-11-29 Thread Jordan Niethe
On Mon, Nov 30, 2020 at 12:42 PM Michael Ellerman  wrote:
>
> Christophe Leroy  writes:
> > Le 27/11/2020 à 04:02, Jordan Niethe a écrit :
> >> This enables GENERIC_BUG_RELATIVE_POINTERS on Power so that 32-bit
> >> offsets are stored in the bug entries rather than 64-bit pointers.
> >>
> >> Signed-off-by: Jordan Niethe 
> >> ---
> >>   arch/powerpc/Kconfig   |  4 
> >>   arch/powerpc/include/asm/bug.h | 37 --
> >>   arch/powerpc/xmon/xmon.c   | 17 ++--
> >>   3 files changed, 54 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> >> index e9f13fe08492..294108e0e5c6 100644
> >> --- a/arch/powerpc/Kconfig
> >> +++ b/arch/powerpc/Kconfig
> >> @@ -311,6 +311,10 @@ config GENERIC_BUG
> >>  default y
> >>  depends on BUG
> >>
> >> +config GENERIC_BUG_RELATIVE_POINTERS
> >> +def_bool y
> >> +depends on GENERIC_BUG
> >> +
> >>   config SYS_SUPPORTS_APM_EMULATION
> >>  default y if PMAC_APM_EMU
> >>  bool
> >> diff --git a/arch/powerpc/include/asm/bug.h 
> >> b/arch/powerpc/include/asm/bug.h
> >> index 338f36cd9934..d03d834042a1 100644
> >> --- a/arch/powerpc/include/asm/bug.h
> >> +++ b/arch/powerpc/include/asm/bug.h
> >> @@ -12,7 +12,11 @@
> >>   #ifdef CONFIG_DEBUG_BUGVERBOSE
> >>   .macro EMIT_BUG_ENTRY addr,file,line,flags
> >>   .section __bug_table,"aw"
> >> +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> >
> > As far as I understand, as soon as CONFIG_BUG is selected, GENERIC_BUG is 
> > automatically selected so
> > GENERIC_BUG_RELATIVE_POINTERS is selected as well. Therefore this #ifndef 
> > is never possible.
>
> Yeah.
>
> There is one place in the generic code that has an ifndef 
> CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> but that's because it has to support arches that don't select it.
>
> In the arch code we know that it's enabled, so there should be no need
> for any ifdefs.
For 32bit, pointers are 4 bytes anyway so it would be pointless to
store a displacement, so won't we need some ifdefs for that?
>
> cheers


[Bug 204789] Boot failure with more than 256G of memory on Power9 with 4K pages & Hash MMU

2020-11-29 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=204789

--- Comment #14 from Michael Ellerman (mich...@ellerman.id.au) ---
The fix is:
  7746406baa3b ("powerpc/book3s64/hash/4k: Support large linear mapping range
with 4K")

-- 
You are receiving this mail because:
You are watching the assignee of the bug.

Re: [PATCH] powerpc: Allow relative pointers in bug table entries

2020-11-29 Thread Michael Ellerman
Christophe Leroy  writes:
> Le 27/11/2020 à 04:02, Jordan Niethe a écrit :
>> This enables GENERIC_BUG_RELATIVE_POINTERS on Power so that 32-bit
>> offsets are stored in the bug entries rather than 64-bit pointers.
>> 
>> Signed-off-by: Jordan Niethe 
>> ---
>>   arch/powerpc/Kconfig   |  4 
>>   arch/powerpc/include/asm/bug.h | 37 --
>>   arch/powerpc/xmon/xmon.c   | 17 ++--
>>   3 files changed, 54 insertions(+), 4 deletions(-)
>> 
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index e9f13fe08492..294108e0e5c6 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -311,6 +311,10 @@ config GENERIC_BUG
>>  default y
>>  depends on BUG
>>   
>> +config GENERIC_BUG_RELATIVE_POINTERS
>> +def_bool y
>> +depends on GENERIC_BUG
>> +
>>   config SYS_SUPPORTS_APM_EMULATION
>>  default y if PMAC_APM_EMU
>>  bool
>> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
>> index 338f36cd9934..d03d834042a1 100644
>> --- a/arch/powerpc/include/asm/bug.h
>> +++ b/arch/powerpc/include/asm/bug.h
>> @@ -12,7 +12,11 @@
>>   #ifdef CONFIG_DEBUG_BUGVERBOSE
>>   .macro EMIT_BUG_ENTRY addr,file,line,flags
>>   .section __bug_table,"aw"
>> +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
>
> As far as I understand, as soon as CONFIG_BUG is selected, GENERIC_BUG is 
> automatically selected so 
> GENERIC_BUG_RELATIVE_POINTERS is selected as well. Therefore this #ifndef is 
> never possible.

Yeah.

There is one place in the generic code that has an ifndef 
CONFIG_GENERIC_BUG_RELATIVE_POINTERS
but that's because it has to support arches that don't select it.

In the arch code we know that it's enabled, so there should be no need
for any ifdefs.

cheers


[Bug 209869] Kernel 5.10-rc1 fails to boot on a PowerMac G4 3,6 at an early stage

2020-11-29 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=209869

Michael Ellerman (mich...@ellerman.id.au) changed:

   What|Removed |Added

 Status|RESOLVED|CLOSED

--- Comment #15 from Michael Ellerman (mich...@ellerman.id.au) ---
And the fix is in mainline as of v5.10-rc6.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.

Re: [PATCH] powerpc: Allow relative pointers in bug table entries

2020-11-29 Thread Jordan Niethe
On Sun, Nov 29, 2020 at 6:00 AM Christophe Leroy
 wrote:
>
>
>
> Le 27/11/2020 à 04:02, Jordan Niethe a écrit :
> > This enables GENERIC_BUG_RELATIVE_POINTERS on Power so that 32-bit
> > offsets are stored in the bug entries rather than 64-bit pointers.
> >
> > Signed-off-by: Jordan Niethe 
> > ---
> >   arch/powerpc/Kconfig   |  4 
> >   arch/powerpc/include/asm/bug.h | 37 --
> >   arch/powerpc/xmon/xmon.c   | 17 ++--
> >   3 files changed, 54 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index e9f13fe08492..294108e0e5c6 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -311,6 +311,10 @@ config GENERIC_BUG
> >   default y
> >   depends on BUG
> >
> > +config GENERIC_BUG_RELATIVE_POINTERS
> > + def_bool y
> > + depends on GENERIC_BUG
> > +
> >   config SYS_SUPPORTS_APM_EMULATION
> >   default y if PMAC_APM_EMU
> >   bool
> > diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
> > index 338f36cd9934..d03d834042a1 100644
> > --- a/arch/powerpc/include/asm/bug.h
> > +++ b/arch/powerpc/include/asm/bug.h
> > @@ -12,7 +12,11 @@
> >   #ifdef CONFIG_DEBUG_BUGVERBOSE
> >   .macro EMIT_BUG_ENTRY addr,file,line,flags
> >.section __bug_table,"aw"
> > +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
>
> As far as I understand, as soon as CONFIG_BUG is selected, GENERIC_BUG is 
> automatically selected so
> GENERIC_BUG_RELATIVE_POINTERS is selected as well. Therefore this #ifndef is 
> never possible.
Thanks, you are right. I'll fix that up.
>
> >   5001:PPC_LONG \addr, 5002f
> > +#else
> > +5001: .4byte \addr - 5001b, 5002f - 5001b
> > +#endif /* CONFIG_GENERIC_BUG_RELATIVE_POINTERS */
> >.short \line, \flags
> >.org 5001b+BUG_ENTRY_SIZE
> >.previous
> > @@ -23,7 +27,11 @@
> >   #else
> >   .macro EMIT_BUG_ENTRY addr,file,line,flags
> >.section __bug_table,"aw"
> > +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
>
> Same
>
> >   5001:PPC_LONG \addr
> > +#else
> > +5001: .4byte \addr - 5001b
> > +#endif /* CONFIG_GENERIC_BUG_RELATIVE_POINTERS */
> >.short \flags
> >.org 5001b+BUG_ENTRY_SIZE
> >.previous
> > @@ -34,20 +42,45 @@
> >   /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and
> >  sizeof(struct bug_entry), respectively */
> >   #ifdef CONFIG_DEBUG_BUGVERBOSE
> > +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
>
> Same
>
> >   #define _EMIT_BUG_ENTRY \
> >   ".section __bug_table,\"aw\"\n" \
> >   "2:\t" PPC_LONG "1b, %0\n"  \
> >   "\t.short %1, %2\n" \
> >   ".org 2b+%3\n"  \
> >   ".previous\n"
> > -#else
> > +
> > +#else /* relative pointers */
> > +
> > +#define _EMIT_BUG_ENTRY  \
> > + ".section __bug_table,\"aw\"\n" \
> > + "2:\t.4byte 1b - 2b, %0 - 2b\n" \
> > + "\t.short %1, %2\n" \
> > + ".org 2b+%3\n"  \
> > + ".previous\n"
> > +#endif /* relative pointers */
> > +
> > +#else /* verbose */
> > +
> > +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
>
> Same
>
> >   #define _EMIT_BUG_ENTRY \
> >   ".section __bug_table,\"aw\"\n" \
> >   "2:\t" PPC_LONG "1b\n"  \
> >   "\t.short %2\n" \
> >   ".org 2b+%3\n"  \
> >   ".previous\n"
> > -#endif
> > +
> > +#else /* relative pointers */
> > +
> > +#define _EMIT_BUG_ENTRY  \
> > + ".section __bug_table,\"aw\"\n" \
> > + "2:\t.4byte 1b - 2b\n"  \
> > + "\t.short %2\n" \
> > + ".org 2b+%3\n"  \
> > + ".previous\n"
> > +
> > +#endif /* relative pointers */
> > +#endif /* verbose */
> >
> >   #define BUG_ENTRY(insn, flags, ...) \
> >   __asm__ __volatile__(   \
> > diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> > index 55c43a6c9111..5f7cf7e95767 100644
> > --- a/arch/powerpc/xmon/xmon.c
> > +++ b/arch/powerpc/xmon/xmon.c
> > @@ -1731,6 +1731,9 @@ static void print_bug_trap(struct pt_regs *regs)
> >   #ifdef CONFIG_BUG
> >   const struct bug_entry *bug;
> >   unsigned long addr;
> > +#ifdef CONFIG_DEBUG_BUGVERBOSE
> > + char *file;
> > +#endif
> >
> >   if (regs->msr & MSR_PR)
> >   return; /* not in kernel */
> > @@ -1744,10 +1747,20 @@ static void print_bug_trap(struct pt_regs *regs)
> >   return;
> >
> >   #ifdef CONFIG_DEBUG_BUGVERBOSE
> > +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
>
> Same
>
> > + file = bug->file;
> > +#else /* relative pointers */
> > + file = (char *)bug + bug->file_disp;
> > +#endif 

Re: [PATCH] powerpc: fix the allyesconfig build

2020-11-29 Thread Yunsheng Lin
On 2020/11/29 3:36, Jakub Kicinski wrote:
> On Sat, 28 Nov 2020 16:20:54 +1100 Stephen Rothwell wrote:
>> On Fri, 27 Nov 2020 17:56:42 -0800 Jakub Kicinski  wrote:
>>>
>>> What's the offending structure in hisilicon? I'd rather have a look
>>> packing structs with pointers in 'em sounds questionable.
>>>
>>> I only see these two:
>>>
>>> $ git grep packed drivers/net/ethernet/hisilicon/
>>> drivers/net/ethernet/hisilicon/hns/hnae.h:struct __packed hnae_desc {
>>> drivers/net/ethernet/hisilicon/hns3/hns3_enet.h:struct __packed hns3_desc { 
>>>  
>>
>> struct hclge_dbg_reg_type_info which is 28 bytes long due to the
>> included struct struct hclge_dbg_reg_common_msg (which is 12 bytes
>> long).  They are surrounded by #pragma pack(1)/pack().
>>
>> This forces the 2 pointers in each second array element of
>> hclge_dbg_reg_info[] to be 4 byte aligned (where pointers are 8 bytes
>> long on PPC64).
> 
> Ah! Thanks, I don't see a reason for these to be packed. 
> Looks  like an accident, there is no reason to pack anything 
> past struct hclge_dbg_reg_common_msg AFAICT.
> 
> Huawei folks, would you mind sending a fix if the analysis is correct?

Yes, will send a patch to fix that. Thanks for the analysis.

> .
> 


[PATCH] powerpc/64: Fix an EMIT_BUG_ENTRY in head_64.S

2020-11-29 Thread Jordan Niethe
Commit 63ce271b5e37 ("powerpc/prom: convert PROM_BUG() to standard
trap") added an EMIT_BUG_ENTRY for the trap after the branch to
start_kernel(). The EMIT_BUG_ENTRY was for the address "0b", however the
trap was not labeled with "0". Hence the address used for bug is in
relative_toc() where the previous "0" label is. Label the trap as "0" so
the correct address is used.

Fixes: 63ce271b5e37 ("powerpc/prom: convert PROM_BUG() to standard trap")
Signed-off-by: Jordan Niethe 
---
 arch/powerpc/kernel/head_64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 3bae6286c17c..f63d01c78398 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -995,7 +995,7 @@ start_here_common:
bl  start_kernel
 
/* Not reached */
-   trap
+0: trap
EMIT_BUG_ENTRY 0b, __FILE__, __LINE__, 0
.previous
 
-- 
2.17.1



[net-next PATCH] net: freescale: ucc_geth: remove unused SKB_ALLOC_TIMEOUT

2020-11-29 Thread Chris Packham
This was added in commit ce973b141dfa ("[PATCH] Freescale QE UCC gigabit
ethernet driver") but doesn't appear to have been used. Remove it now.

Signed-off-by: Chris Packham 
---
 drivers/net/ethernet/freescale/ucc_geth.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/ucc_geth.h 
b/drivers/net/ethernet/freescale/ucc_geth.h
index 3fe903972195..1a9bdf66a7d8 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.h
+++ b/drivers/net/ethernet/freescale/ucc_geth.h
@@ -882,7 +882,6 @@ struct ucc_geth_hardware_statistics {
   addresses */
 
 #define TX_TIMEOUT  (1*HZ)
-#define SKB_ALLOC_TIMEOUT   10
 #define PHY_INIT_TIMEOUT10
 #define PHY_CHANGE_TIME 2
 
-- 
2.29.2



[PATCH v6 5/5] PCI: xgene: Removed unused ".bus_shift" initialisers from pci-xgene.c

2020-11-29 Thread Krzysztof Wilczyński
Removed unused ".bus_shift" initialisers from pci-xgene.c as
xgene_pcie_map_bus() did not use these.

Suggested-by: Bjorn Helgaas 
Signed-off-by: Krzysztof Wilczyński 
---
 drivers/pci/controller/pci-xgene.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/pci/controller/pci-xgene.c 
b/drivers/pci/controller/pci-xgene.c
index 8e0db84f089d..85e7c98265e8 100644
--- a/drivers/pci/controller/pci-xgene.c
+++ b/drivers/pci/controller/pci-xgene.c
@@ -257,7 +257,6 @@ static int xgene_v1_pcie_ecam_init(struct pci_config_window 
*cfg)
 }
 
 const struct pci_ecam_ops xgene_v1_pcie_ecam_ops = {
-   .bus_shift  = 16,
.init   = xgene_v1_pcie_ecam_init,
.pci_ops= {
.map_bus= xgene_pcie_map_bus,
@@ -272,7 +271,6 @@ static int xgene_v2_pcie_ecam_init(struct pci_config_window 
*cfg)
 }
 
 const struct pci_ecam_ops xgene_v2_pcie_ecam_ops = {
-   .bus_shift  = 16,
.init   = xgene_v2_pcie_ecam_init,
.pci_ops= {
.map_bus= xgene_pcie_map_bus,
-- 
2.29.2



[PATCH v6 4/5] PCI: vmd: Update type of the __iomem pointers

2020-11-29 Thread Krzysztof Wilczyński
Use "void __iomem" instead "char __iomem" pointer type when working with
the accessor functions (with names like readb() or writel(), etc.) to
better match a given accessor function signature where commonly the
address pointing to an I/O memory region would be a "void __iomem"
pointer.

Related:
  https://lwn.net/Articles/102232/

Suggested-by: Bjorn Helgaas 
Signed-off-by: Krzysztof Wilczyński 
---
 drivers/pci/controller/vmd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index 1361a79bd1e7..59fa9a94860f 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -95,7 +95,7 @@ struct vmd_dev {
struct pci_dev  *dev;
 
spinlock_t  cfg_lock;
-   char __iomem*cfgbar;
+   void __iomem*cfgbar;
 
int msix_count;
struct vmd_irq_list *irqs;
@@ -326,7 +326,7 @@ static void vmd_remove_irq_domain(struct vmd_dev *vmd)
}
 }
 
-static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus,
+static void __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus,
  unsigned int devfn, int reg, int len)
 {
unsigned int busnr_ecam = bus->number - vmd->busn_start;
@@ -346,7 +346,7 @@ static int vmd_pci_read(struct pci_bus *bus, unsigned int 
devfn, int reg,
int len, u32 *value)
 {
struct vmd_dev *vmd = vmd_from_bus(bus);
-   char __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len);
+   void __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len);
unsigned long flags;
int ret = 0;
 
@@ -381,7 +381,7 @@ static int vmd_pci_write(struct pci_bus *bus, unsigned int 
devfn, int reg,
 int len, u32 value)
 {
struct vmd_dev *vmd = vmd_from_bus(bus);
-   char __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len);
+   void __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len);
unsigned long flags;
int ret = 0;
 
-- 
2.29.2



[PATCH v6 3/5] PCI: iproc: Convert to use the new ECAM constants

2020-11-29 Thread Krzysztof Wilczyński
Change interface of the function iproc_pcie_map_ep_cfg_reg() so that use
of PCI_SLOT() and PCI_FUNC() macros and most of the local ECAM-specific
constants can be dropped, and the new PCIE_ECAM_OFFSET() macro can be
used instead.  Use the ALIGN_DOWN() macro to ensure that PCI Express
ECAM offset is always 32 bit aligned.

Suggested-by: Bjorn Helgaas 
Signed-off-by: Krzysztof Wilczyński 
---
 drivers/pci/controller/pcie-iproc.c | 31 -
 1 file changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/pci/controller/pcie-iproc.c 
b/drivers/pci/controller/pcie-iproc.c
index 905e93808243..503662380ff8 100644
--- a/drivers/pci/controller/pcie-iproc.c
+++ b/drivers/pci/controller/pcie-iproc.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -39,16 +40,8 @@
 
 #define CFG_IND_ADDR_MASK  0x1ffc
 
-#define CFG_ADDR_BUS_NUM_SHIFT 20
-#define CFG_ADDR_BUS_NUM_MASK  0x0ff0
-#define CFG_ADDR_DEV_NUM_SHIFT 15
-#define CFG_ADDR_DEV_NUM_MASK  0x000f8000
-#define CFG_ADDR_FUNC_NUM_SHIFT12
-#define CFG_ADDR_FUNC_NUM_MASK 0x7000
-#define CFG_ADDR_REG_NUM_SHIFT 2
 #define CFG_ADDR_REG_NUM_MASK  0x0ffc
-#define CFG_ADDR_CFG_TYPE_SHIFT0
-#define CFG_ADDR_CFG_TYPE_MASK 0x0003
+#define CFG_ADDR_CFG_TYPE_11
 
 #define SYS_RC_INTX_MASK   0xf
 
@@ -459,19 +452,15 @@ static inline void iproc_pcie_apb_err_disable(struct 
pci_bus *bus,
 
 static void __iomem *iproc_pcie_map_ep_cfg_reg(struct iproc_pcie *pcie,
   unsigned int busno,
-  unsigned int slot,
-  unsigned int fn,
+  unsigned int devfn,
   int where)
 {
u16 offset;
u32 val;
 
/* EP device access */
-   val = (busno << CFG_ADDR_BUS_NUM_SHIFT) |
-   (slot << CFG_ADDR_DEV_NUM_SHIFT) |
-   (fn << CFG_ADDR_FUNC_NUM_SHIFT) |
-   (where & CFG_ADDR_REG_NUM_MASK) |
-   (1 & CFG_ADDR_CFG_TYPE_MASK);
+   val = ALIGN_DOWN(PCIE_ECAM_OFFSET(busno, devfn, where), 4) |
+   CFG_ADDR_CFG_TYPE_1;
 
iproc_pcie_write_reg(pcie, IPROC_PCIE_CFG_ADDR, val);
offset = iproc_pcie_reg_offset(pcie, IPROC_PCIE_CFG_DATA);
@@ -574,8 +563,6 @@ static int iproc_pcie_config_read(struct pci_bus *bus, 
unsigned int devfn,
  int where, int size, u32 *val)
 {
struct iproc_pcie *pcie = iproc_data(bus);
-   unsigned int slot = PCI_SLOT(devfn);
-   unsigned int fn = PCI_FUNC(devfn);
unsigned int busno = bus->number;
void __iomem *cfg_data_p;
unsigned int data;
@@ -590,7 +577,7 @@ static int iproc_pcie_config_read(struct pci_bus *bus, 
unsigned int devfn,
return ret;
}
 
-   cfg_data_p = iproc_pcie_map_ep_cfg_reg(pcie, busno, slot, fn, where);
+   cfg_data_p = iproc_pcie_map_ep_cfg_reg(pcie, busno, devfn, where);
 
if (!cfg_data_p)
return PCIBIOS_DEVICE_NOT_FOUND;
@@ -631,13 +618,11 @@ static void __iomem *iproc_pcie_map_cfg_bus(struct 
iproc_pcie *pcie,
int busno, unsigned int devfn,
int where)
 {
-   unsigned slot = PCI_SLOT(devfn);
-   unsigned fn = PCI_FUNC(devfn);
u16 offset;
 
/* root complex access */
if (busno == 0) {
-   if (slot > 0 || fn > 0)
+   if (PCIE_ECAM_DEVFN(devfn) > 0)
return NULL;
 
iproc_pcie_write_reg(pcie, IPROC_PCIE_CFG_IND_ADDR,
@@ -649,7 +634,7 @@ static void __iomem *iproc_pcie_map_cfg_bus(struct 
iproc_pcie *pcie,
return (pcie->base + offset);
}
 
-   return iproc_pcie_map_ep_cfg_reg(pcie, busno, slot, fn, where);
+   return iproc_pcie_map_ep_cfg_reg(pcie, busno, devfn, where);
 }
 
 static void __iomem *iproc_pcie_bus_map_cfg_bus(struct pci_bus *bus,
-- 
2.29.2



[PATCH v6 2/5] PCI: thunder-pem: Add constant for custom ".bus_shit" initialiser

2020-11-29 Thread Krzysztof Wilczyński
Add a custom constant for the ".bus_shit" initialiser to capture
a non-standard platform-specific ECAM bus shift value.

Standard values otherwise defined in the PCI Express Specification
are available in the include/linux/pci-ecam.h.

Suggested-by: Bjorn Helgaas 
Signed-off-by: Krzysztof Wilczyński 
---
 drivers/pci/controller/pci-thunder-pem.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pci-thunder-pem.c 
b/drivers/pci/controller/pci-thunder-pem.c
index 3f847969143e..1a3f70ac61fc 100644
--- a/drivers/pci/controller/pci-thunder-pem.c
+++ b/drivers/pci/controller/pci-thunder-pem.c
@@ -19,6 +19,15 @@
 #define PEM_CFG_WR 0x28
 #define PEM_CFG_RD 0x30
 
+/*
+ * Enhanced Configuration Access Mechanism (ECAM)
+ *
+ * N.B. This is a non-standard platform-specific ECAM bus shift value.  For
+ * standard values defined in the PCI Express Base Specification see
+ * include/linux/pci-ecam.h.
+ */
+#define THUNDER_PCIE_ECAM_BUS_SHIFT24
+
 struct thunder_pem_pci {
u32 ea_entry[3];
void __iomem*pem_reg_base;
@@ -404,7 +413,7 @@ static int thunder_pem_acpi_init(struct pci_config_window 
*cfg)
 }
 
 const struct pci_ecam_ops thunder_pem_ecam_ops = {
-   .bus_shift  = 24,
+   .bus_shift  = THUNDER_PCIE_ECAM_BUS_SHIFT,
.init   = thunder_pem_acpi_init,
.pci_ops= {
.map_bus= pci_ecam_map_bus,
@@ -441,7 +450,7 @@ static int thunder_pem_platform_init(struct 
pci_config_window *cfg)
 }
 
 static const struct pci_ecam_ops pci_thunder_pem_ops = {
-   .bus_shift  = 24,
+   .bus_shift  = THUNDER_PCIE_ECAM_BUS_SHIFT,
.init   = thunder_pem_platform_init,
.pci_ops= {
.map_bus= pci_ecam_map_bus,
-- 
2.29.2



[PATCH v6 0/5] PCI: Unify ECAM constants in native PCI Express drivers

2020-11-29 Thread Krzysztof Wilczyński
Unify ECAM-related constants into a single set of standard constants
defining memory address shift values for the byte-level address that can
be used when accessing the PCI Express Configuration Space, and then
move native PCI Express controller drivers to use newly introduced
definitions retiring any driver-specific ones.

The ECAM ("Enhanced Configuration Access Mechanism") is defined by the
PCI Express specification (see PCI Express Base Specification, Revision
5.0, Version 1.0, Section 7.2.2, p. 676), thus most hardware should
implement it the same way.

Most of the native PCI Express controller drivers define their ECAM-related
constants, many of these could be shared, or use open-coded values when
setting the ".bus_shift" field of the "struct pci_ecam_ops".

All of the newly added constants should remove ambiguity and reduce the
number of open-coded values, and also correlate more strongly with the
descriptions in the aforementioned specification (see Table 7-1
"Enhanced Configuration Address Mapping", p. 677).

Suggested-by: Bjorn Helgaas 
Signed-off-by: Krzysztof Wilczyński 

--- 
Changed in v6:
  Converted single patch into a series.
  Dropped changes related to PPC 4xx platform.
  Refactored pci_ecam_map_bus() so that bus, device function and offset
  are correctly masked, limiting offset to 4K as per the PCI Express
  Specification.  After the refactor this function will now use sensible
  defaults allowing for removal of the ".bus_shit" initialiser from all
  the users of the "ecam_ops" structure who do not use a non-standard
  ECAM bus shit values.

Changed in v5:
  Removed unused constant "PCIE_ECAM_DEV_SHIFT".
  Refactored ppc4xx_pciex_get_config_base() so that the "offset"
  parameter can be passed to so that the PCIE_ECAM_OFFSET() macro
  can be used.
  Used the ALIGN_DOWN() macro where 32 bit alignment is required
  instead using the 0xffc mask.
  Added CFG_ADDR_CFG_TYPE_1 macro to pci/controller/pcie-iproc.c to
  denote that this is a configuration type 1 address and access type.
  Refactored boundary check in pci/controller/vmd.c as used by the
  vmd_cfg_addr() function following addition of the PCIE_ECAM_OFFSET()
  macro.
  Changed the "bus->number" to simply pass the "bus" argument in the
  PCIE_ECAM_OFFSET() macro.

Changed in v4:
  Removed constants related to "CAM".
  Added more platforms and devices that can use new ECAM macros and
  constants.
  Removed unused ".bus_shift" initialisers from pci-xgene.c as
  xgene_pcie_map_bus() did not use these.

Changes in v3:
  Updated commit message wording.
  Updated regarding custom ECAM bus shift values and concerning PCI base
  configuration space access for Type 1 access.
  Refactored rockchip_pcie_rd_other_conf() and rockchip_pcie_wr_other_conf()
  and removed the "busdev" variable.
  Removed surplus "relbus" variable from nwl_pcie_map_bus() and
  xilinx_pcie_map_bus().
  Renamed the PCIE_ECAM_ADDR() macro to PCIE_ECAM_OFFSET().

Changes in v2:
  Use PCIE_ECAM_ADDR macro when computing ECAM address offset, but drop
  PCI_SLOT and PCI_FUNC macros from the PCIE_ECAM_ADDR macro in favour
  of using a single value for the device/function.

Krzysztof Wilczyński (5):
  PCI: Unify ECAM constants in native PCI Express drivers
  PCI: thunder-pem: Add constant for custom ".bus_shit" initialiser
  PCI: iproc: Convert to use the new ECAM constants
  PCI: vmd: Update type of the __iomem pointers
  PCI: xgene: Removed unused ".bus_shift" initialisers from pci-xgene.c

 drivers/pci/controller/dwc/pcie-al.c| 12 ++--
 drivers/pci/controller/dwc/pcie-hisi.c  |  2 --
 drivers/pci/controller/pci-aardvark.c   | 13 ++---
 drivers/pci/controller/pci-host-generic.c   |  1 -
 drivers/pci/controller/pci-thunder-ecam.c   |  1 -
 drivers/pci/controller/pci-thunder-pem.c| 13 +++--
 drivers/pci/controller/pci-xgene.c  |  2 --
 drivers/pci/controller/pcie-brcmstb.c   | 16 ++-
 drivers/pci/controller/pcie-iproc.c | 31 ++---
 drivers/pci/controller/pcie-rockchip-host.c | 27 +-
 drivers/pci/controller/pcie-rockchip.h  |  8 +-
 drivers/pci/controller/pcie-tango.c |  1 -
 drivers/pci/controller/pcie-xilinx-nwl.c|  9 ++
 drivers/pci/controller/pcie-xilinx.c| 11 ++--
 drivers/pci/controller/vmd.c| 19 ++---
 drivers/pci/ecam.c  | 23 ++-
 include/linux/pci-ecam.h| 27 ++
 17 files changed, 96 insertions(+), 120 deletions(-)

-- 
2.29.2



[PATCH v6 1/5] PCI: Unify ECAM constants in native PCI Express drivers

2020-11-29 Thread Krzysztof Wilczyński
Add ECAM-related constants to provide a set of standard constants
defining memory address shift values to the byte-level address that can
be used to access the PCI Express Configuration Space, and then move
native PCI Express controller drivers to use the newly introduced
definitions retiring driver-specific ones.

Refactor pci_ecam_map_bus() function to use newly added constants so
that limits to the bus, device function and offset (now limited to 4K as
per the specification) are in place to prevent the defective or
malicious caller from supplying incorrect configuration offset and thus
targeting the wrong device when accessing extended configuration space.
This refactor also allows for the ".bus_shit" initialisers to be dropped
when the user is not using a custom value as a default value will be
used as per the PCI Express Specification.

Suggested-by: Bjorn Helgaas 
Signed-off-by: Krzysztof Wilczyński 
---
 drivers/pci/controller/dwc/pcie-al.c| 12 ++---
 drivers/pci/controller/dwc/pcie-hisi.c  |  2 --
 drivers/pci/controller/pci-aardvark.c   | 13 +++---
 drivers/pci/controller/pci-host-generic.c   |  1 -
 drivers/pci/controller/pci-thunder-ecam.c   |  1 -
 drivers/pci/controller/pcie-brcmstb.c   | 16 ++--
 drivers/pci/controller/pcie-rockchip-host.c | 27 ++---
 drivers/pci/controller/pcie-rockchip.h  |  8 +-
 drivers/pci/controller/pcie-tango.c |  1 -
 drivers/pci/controller/pcie-xilinx-nwl.c|  9 ++-
 drivers/pci/controller/pcie-xilinx.c| 11 ++---
 drivers/pci/controller/vmd.c| 11 -
 drivers/pci/ecam.c  | 23 --
 include/linux/pci-ecam.h| 27 +
 14 files changed, 73 insertions(+), 89 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-al.c 
b/drivers/pci/controller/dwc/pcie-al.c
index f973fbca90cf..af9e51ab1af8 100644
--- a/drivers/pci/controller/dwc/pcie-al.c
+++ b/drivers/pci/controller/dwc/pcie-al.c
@@ -76,7 +76,6 @@ static int al_pcie_init(struct pci_config_window *cfg)
 }
 
 const struct pci_ecam_ops al_pcie_ops = {
-   .bus_shift= 20,
.init =  al_pcie_init,
.pci_ops  = {
.map_bus= al_pcie_map_bus,
@@ -138,8 +137,6 @@ struct al_pcie {
struct al_pcie_target_bus_cfg target_bus_cfg;
 };
 
-#define PCIE_ECAM_DEVFN(x) (((x) & 0xff) << 12)
-
 #define to_al_pcie(x)  dev_get_drvdata((x)->dev)
 
 static inline u32 al_pcie_controller_readl(struct al_pcie *pcie, u32 offset)
@@ -226,11 +223,6 @@ static void __iomem *al_pcie_conf_addr_map_bus(struct 
pci_bus *bus,
struct al_pcie_target_bus_cfg *target_bus_cfg = >target_bus_cfg;
unsigned int busnr_ecam = busnr & target_bus_cfg->ecam_mask;
unsigned int busnr_reg = busnr & target_bus_cfg->reg_mask;
-   void __iomem *pci_base_addr;
-
-   pci_base_addr = (void __iomem *)((uintptr_t)pp->va_cfg0_base +
-(busnr_ecam << 20) +
-PCIE_ECAM_DEVFN(devfn));
 
if (busnr_reg != target_bus_cfg->reg_val) {
dev_dbg(pcie->pci->dev, "Changing target bus busnum val from 
0x%x to 0x%x\n",
@@ -241,7 +233,7 @@ static void __iomem *al_pcie_conf_addr_map_bus(struct 
pci_bus *bus,
   target_bus_cfg->reg_mask);
}
 
-   return pci_base_addr + where;
+   return pp->va_cfg0_base + PCIE_ECAM_OFFSET(busnr_ecam, devfn, where);
 }
 
 static struct pci_ops al_child_pci_ops = {
@@ -264,7 +256,7 @@ static void al_pcie_config_prepare(struct al_pcie *pcie)
 
target_bus_cfg = >target_bus_cfg;
 
-   ecam_bus_mask = (pcie->ecam_size >> 20) - 1;
+   ecam_bus_mask = (pcie->ecam_size >> PCIE_ECAM_BUS_SHIFT) - 1;
if (ecam_bus_mask > 255) {
dev_warn(pcie->dev, "ECAM window size is larger than 256MB. 
Cutting off at 256\n");
ecam_bus_mask = 255;
diff --git a/drivers/pci/controller/dwc/pcie-hisi.c 
b/drivers/pci/controller/dwc/pcie-hisi.c
index 5ca86796d43a..8fc5960faf28 100644
--- a/drivers/pci/controller/dwc/pcie-hisi.c
+++ b/drivers/pci/controller/dwc/pcie-hisi.c
@@ -100,7 +100,6 @@ static int hisi_pcie_init(struct pci_config_window *cfg)
 }
 
 const struct pci_ecam_ops hisi_pcie_ops = {
-   .bus_shift= 20,
.init =  hisi_pcie_init,
.pci_ops  = {
.map_bus= hisi_pcie_map_bus,
@@ -135,7 +134,6 @@ static int hisi_pcie_platform_init(struct pci_config_window 
*cfg)
 }
 
 static const struct pci_ecam_ops hisi_pcie_platform_ops = {
-   .bus_shift= 20,
.init =  hisi_pcie_platform_init,
.pci_ops  = {
.map_bus= hisi_pcie_map_bus,
diff --git a/drivers/pci/controller/pci-aardvark.c 
b/drivers/pci/controller/pci-aardvark.c
index 0be485a25327..1043e54c73bd 100644
--- 

Re: [PATCH 6/8] lazy tlb: shoot lazies, a non-refcounting lazy tlb option

2020-11-29 Thread Andy Lutomirski
On Sat, Nov 28, 2020 at 7:54 PM Andy Lutomirski  wrote:
>
> On Sat, Nov 28, 2020 at 8:02 AM Nicholas Piggin  wrote:
> >
> > On big systems, the mm refcount can become highly contented when doing
> > a lot of context switching with threaded applications (particularly
> > switching between the idle thread and an application thread).
> >
> > Abandoning lazy tlb slows switching down quite a bit in the important
> > user->idle->user cases, so so instead implement a non-refcounted scheme
> > that causes __mmdrop() to IPI all CPUs in the mm_cpumask and shoot down
> > any remaining lazy ones.
> >
> > Shootdown IPIs are some concern, but they have not been observed to be
> > a big problem with this scheme (the powerpc implementation generated
> > 314 additional interrupts on a 144 CPU system during a kernel compile).
> > There are a number of strategies that could be employed to reduce IPIs
> > if they turn out to be a problem for some workload.
>
> I'm still wondering whether we can do even better.
>

Hold on a sec.. __mmput() unmaps VMAs, frees pagetables, and flushes
the TLB.  On x86, this will shoot down all lazies as long as even a
single pagetable was freed.  (Or at least it will if we don't have a
serious bug, but the code seems okay.  We'll hit pmd_free_tlb, which
sets tlb->freed_tables, which will trigger the IPI.)  So, on
architectures like x86, the shootdown approach should be free.  The
only way it ought to have any excess IPIs is if we have CPUs in
mm_cpumask() that don't need IPI to free pagetables, which could
happen on paravirt.

Can you try to figure out why you saw any increase in IPIs?  It would
be nice if we can make the new code unconditional.


Re: [PATCH 8/8] net: ethernet: ibm: ibmvnic: Fix some kernel-doc issues

2020-11-29 Thread Andrew Lunn
On Thu, Nov 26, 2020 at 01:38:53PM +, Lee Jones wrote:
> Fixes the following W=1 kernel build warning(s):
> 
>  from drivers/net/ethernet/ibm/ibmvnic.c:35:
>  inlined from ‘handle_vpd_rsp’ at drivers/net/ethernet/ibm/ibmvnic.c:4124:3:
>  drivers/net/ethernet/ibm/ibmvnic.c:1362: warning: Function parameter or 
> member 'hdr_data' not described in 'build_hdr_data'
>  drivers/net/ethernet/ibm/ibmvnic.c:1362: warning: Excess function parameter 
> 'tot_len' description in 'build_hdr_data'
>  drivers/net/ethernet/ibm/ibmvnic.c:1423: warning: Function parameter or 
> member 'hdr_data' not described in 'create_hdr_descs'
>  drivers/net/ethernet/ibm/ibmvnic.c:1423: warning: Excess function parameter 
> 'data' description in 'create_hdr_descs'
>  drivers/net/ethernet/ibm/ibmvnic.c:1474: warning: Function parameter or 
> member 'txbuff' not described in 'build_hdr_descs_arr'
>  drivers/net/ethernet/ibm/ibmvnic.c:1474: warning: Excess function parameter 
> 'skb' description in 'build_hdr_descs_arr'
>  drivers/net/ethernet/ibm/ibmvnic.c:1474: warning: Excess function parameter 
> 'subcrq' description in 'build_hdr_descs_arr'

Hi Lee

It looks like this should be squashed into the previous patch to this
file.

Andrew


Re: [PATCH 6/8] net: ethernet: toshiba: ps3_gelic_net: Fix some kernel-doc misdemeanours

2020-11-29 Thread Andrew Lunn
On Thu, Nov 26, 2020 at 01:38:51PM +, Lee Jones wrote:
> Fixes the following W=1 kernel build warning(s):
> 
>  drivers/net/ethernet/toshiba/ps3_gelic_net.c:1107: warning: Function 
> parameter or member 'irq' not described in 'gelic_card_interrupt'
>  drivers/net/ethernet/toshiba/ps3_gelic_net.c:1107: warning: Function 
> parameter or member 'ptr' not described in 'gelic_card_interrupt'
>  drivers/net/ethernet/toshiba/ps3_gelic_net.c:1407: warning: Function 
> parameter or member 'txqueue' not described in 'gelic_net_tx_timeout'
>  drivers/net/ethernet/toshiba/ps3_gelic_net.c:1439: warning: Function 
> parameter or member 'napi' not described in 'gelic_ether_setup_netdev_ops'
>  drivers/net/ethernet/toshiba/ps3_gelic_net.c:1639: warning: Function 
> parameter or member 'dev' not described in 'ps3_gelic_driver_probe'
>  drivers/net/ethernet/toshiba/ps3_gelic_net.c:1795: warning: Function 
> parameter or member 'dev' not described in 'ps3_gelic_driver_remove'
> 
> Cc: Geoff Levand 
> Cc: "David S. Miller" 
> Cc: Jakub Kicinski 
> Cc: Michael Ellerman 
> Cc: Benjamin Herrenschmidt 
> Cc: Paul Mackerras 
> Cc: Utz Bacher 
> Cc: Jens Osterkamp 
> Cc: net...@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Lee Jones 

Reviewed-by: Andrew Lunn 

Andrew


Re: [PATCH 5/8] net: ethernet: ibm: ibmvnic: Fix some kernel-doc misdemeanours

2020-11-29 Thread Andrew Lunn
Hi Lee

>  /**
>   * build_hdr_data - creates L2/L3/L4 header data buffer
> - * @hdr_field - bitfield determining needed headers
> - * @skb - socket buffer
> - * @hdr_len - array of header lengths
> - * @tot_len - total length of data
> + * @hdr_field: bitfield determining needed headers
> + * @skb: socket buffer
> + * @hdr_len: array of header lengths
> + * @tot_len: total length of data
>   *
>   * Reads hdr_field to determine which headers are needed by firmware.
>   * Builds a buffer containing these headers.  Saves individual header

The code is:

static int build_hdr_data(u8 hdr_field, struct sk_buff *skb,
  int *hdr_len, u8 *hdr_data)
{

What about hdr_data? 

>  /**
>   * create_hdr_descs - create header and header extension descriptors
> - * @hdr_field - bitfield determining needed headers
> - * @data - buffer containing header data
> - * @len - length of data buffer
> - * @hdr_len - array of individual header lengths
> - * @scrq_arr - descriptor array
> + * @hdr_field: bitfield determining needed headers
> + * @data: buffer containing header data
> + * @len: length of data buffer
> + * @hdr_len: array of individual header lengths
> + * @scrq_arr: descriptor array

static int create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len,
union sub_crq *scrq_arr)

There is no data parameter.

It looks like you just changes - to :, but did not validate the
parameters are actually correct.

   Andrew


Re: [PATCH 2/2] powerpc/ps3: make system bus's remove and shutdown callbacks return void

2020-11-29 Thread Uwe Kleine-König
Hello Michael,

On Sat, Nov 28, 2020 at 09:48:30AM +0100, Takashi Iwai wrote:
> On Thu, 26 Nov 2020 17:59:50 +0100,
> Uwe Kleine-König wrote:
> > 
> > The driver core ignores the return value of struct device_driver::remove
> > because there is only little that can be done. For the shutdown callback
> > it's ps3_system_bus_shutdown() which ignores the return value.
> > 
> > To simplify the quest to make struct device_driver::remove return void,
> > let struct ps3_system_bus_driver::remove return void, too. All users
> > already unconditionally return 0, this commit makes it obvious that
> > returning an error code is a bad idea and ensures future users behave
> > accordingly.
> > 
> > Signed-off-by: Uwe Kleine-König 
> 
> For the sound bit:
> Acked-by: Takashi Iwai 

assuming that you are the one who will apply this patch: Note that it
depends on patch 1 that Takashi already applied to his tree. So you
either have to wait untils patch 1 appears in some tree that you merge
before applying, or you have to take patch 1, too. (With Takashi
optinally dropping it then.)

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | https://www.pengutronix.de/ |


signature.asc
Description: PGP signature


Re: Kernel 5.10-rc4 doesn't boot

2020-11-29 Thread Elimar Riesebieter
Hi all,

* Christophe Leroy  [2020-11-29 08:37 +0100]:

[...]

> Try following commit: 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=01776f070ffcbf336be3bf1672bd3c589548d6c4

I can confirm that this commit patched at 5.10-rc5 made the kernel
boot again :-)

Thanks for bisecting and providing the patch!

Elimar
-- 
  The path to source is always uphill!
-unknown-