1. 25 May, 2018 3 commits
    • Michael Ellerman's avatar
      powerpc/xmon: Realign paca dump fields · 9ce53e27
      Michael Ellerman authored
      We've added some fields with longer names since we originally wrote
      this, so the fields are no longer lined up. Adjust the widths to make
      it all look nice again, eg:
      
        0:mon> dp
        paca for cpu 0x0 @ c000000001fa0000:
         possible                  = yes
         ...
         slb_shadow            [0] = 0xc000000008000000 0x400ea1b217000500
         slb_shadow            [1] = 0xd000000008000001 0x400d43642f000510
         ...
         rfi_flush_fallback_area   = c0000000fff80000   (0xcc8)
         ...
         accounting.starttime_user = 0x51582f07         (0xae8)
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      9ce53e27
    • Mathieu Malaterre's avatar
      powerpc/xmon: Add __printf annotation to xmon_printf() · e70d8f55
      Mathieu Malaterre authored
      This allows the compiler to verify the format strings vs the types of
      the arguments.
      
      Update the other prototype declarations in asm/xmon.h.
      
      Silence warnings (triggered at W=1) by adding relevant __printf
      attribute. Move #define at bottom of the file to prevent conflict with
      gcc attribute.
      
      Solves the original warning:
      
        arch/powerpc/xmon/nonstdio.c:178:2: error: function might be
        possible candidate for ‘gnu_printf’ format attribute
      
      In turn this uncovered many formatting errors in xmon.c, all fixed in
      this patch.
      Signed-off-by: default avatarMathieu Malaterre <malat@debian.org>
      [mpe: Always use px not p, fixup the 44x specific code, tweak change log]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      e70d8f55
    • Michael Ellerman's avatar
      powerpc/xmon: Specify the full format in DUMP() macro · 6671683d
      Michael Ellerman authored
      In dump_one_paca() the DUMP macro unconditionally prepends '#' to the
      printf format specifier. In most cases we're using either 'x' or 'lx'
      etc. and that is OK. But for 'p' and other formats using '#' is
      actually undefined, and once we enable printf() checking for
      xmon_printf() we will get warnings from the compiler.
      
      So just have each usage specify the full format, that way we can omit
      '#' when it's inappropriate.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: default avatarMathieu Malaterre <malat@debian.org>
      6671683d
  2. 24 May, 2018 6 commits
  3. 21 May, 2018 7 commits
  4. 18 May, 2018 6 commits
    • Michael Ellerman's avatar
      powerpc/powernv: Use __raw_[rm_]writeq_be() in npu-dma.c · c786cf76
      Michael Ellerman authored
      This allows us to squash some sparse warnings and also avoids having
      to do explicity endian conversions in the code.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: default avatarSamuel Mendoza-Jonas <sam@mendozajonas.com>
      c786cf76
    • Michael Ellerman's avatar
      powerpc/powernv: Use __raw_[rm_]writeq_be() in pci-ioda.c · 001ff2ee
      Michael Ellerman authored
      This allows us to squash some sparse warnings and also avoids having
      to do explicity endian conversions in the code.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: default avatarSamuel Mendoza-Jonas <sam@mendozajonas.com>
      001ff2ee
    • Michael Ellerman's avatar
      powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() · 8056fe28
      Michael Ellerman authored
      Add byte-swapping versions of __raw_writeq() and __raw_rm_writeq().
      
      This allows us to avoid sparse warnings caused by passing __be64 to
      __raw_writeq(), which takes unsigned long:
      
        arch/powerpc/platforms/powernv/pci-ioda.c:1981:38:
        warning: incorrect type in argument 1 (different base types)
            expected unsigned long [unsigned] v
            got restricted __be64 [usertype] <noident>
      
      It's also generally preferable to use a byte-swapping accessor rather
      than doing it by hand in the code, which is more bug prone.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: default avatarSamuel Mendoza-Jonas <sam@mendozajonas.com>
      8056fe28
    • Anju T Sudhakar's avatar
      powerpc/perf: Fix memory allocation for core-imc based on num_possible_cpus() · d2032678
      Anju T Sudhakar authored
      Currently memory is allocated for core-imc based on cpu_present_mask,
      which has bit 'cpu' set iff cpu is populated. We use (cpu number / threads
      per core) as the array index to access the memory.
      
      Under some circumstances firmware marks a CPU as GUARDed CPU and boot the
      system, until cleared of errors, these CPU's are unavailable for all
      subsequent boots. GUARDed CPUs are possible but not present from linux
      view, so it blows a hole when we assume the max length of our allocation
      is driven by our max present cpus, where as one of the cpus might be online
      and be beyond the max present cpus, due to the hole.
      So (cpu number / threads per core) value bounds the array index and leads
      to memory overflow.
      
      Call trace observed during a guard test:
      
      Faulting instruction address: 0xc000000000149f1c
      cpu 0x69: Vector: 380 (Data Access Out of Range) at [c000003fea303420]
          pc:c000000000149f1c: prefetch_freepointer+0x14/0x30
          lr:c00000000014e0f8: __kmalloc+0x1a8/0x1ac
          sp:c000003fea3036a0
         msr:9000000000009033
         dar:c9c54b2c91dbf6b7
        current = 0xc000003fea2c0000
        paca    = 0xc00000000fddd880	 softe: 3	 irq_happened: 0x01
          pid   = 1, comm = swapper/104
      Linux version 4.16.7-openpower1 (smc@smc-desktop) (gcc version 6.4.0
      (Buildroot 2018.02.1-00006-ga8d1126)) #2 SMP Fri May 4 16:44:54 PDT 2018
      enter ? for help
      call trace:
      	 __kmalloc+0x1a8/0x1ac
      	 (unreliable)
      	 init_imc_pmu+0x7f4/0xbf0
      	 opal_imc_counters_probe+0x3fc/0x43c
      	 platform_drv_probe+0x48/0x80
      	 driver_probe_device+0x22c/0x308
      	 __driver_attach+0xa0/0xd8
      	 bus_for_each_dev+0x88/0xb4
      	 driver_attach+0x2c/0x40
      	 bus_add_driver+0x1e8/0x228
      	 driver_register+0xd0/0x114
      	 __platform_driver_register+0x50/0x64
      	 opal_imc_driver_init+0x24/0x38
      	 do_one_initcall+0x150/0x15c
      	 kernel_init_freeable+0x250/0x254
      	 kernel_init+0x1c/0x150
      	 ret_from_kernel_thread+0x5c/0xc8
      
      Allocating memory for core-imc based on cpu_possible_mask, which has
      bit 'cpu' set iff cpu is populatable, will fix this issue.
      Reported-by: default avatarPridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
      Signed-off-by: default avatarAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Reviewed-by: default avatarBalbir Singh <bsingharora@gmail.com>
      Tested-by: default avatarPridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
      Fixes: 39a846db ("powerpc/perf: Add core IMC PMU support")
      Cc: stable@vger.kernel.org # v4.14+
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      d2032678
    • Colin Ian King's avatar
      powerpc/rtas: Fix spelling mistake "Discharching" -> "Discharging" · ba01b058
      Colin Ian King authored
      Trivial fix to spelling mistake in battery_charging array.
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      ba01b058
    • Finn Thain's avatar
      powerpc/lib: Fix "integer constant is too large" build failure · 20acf7fc
      Finn Thain authored
      My powerpc-linux-gnu-gcc v4.4.5 compiler can't build a 32-bit kernel
      any more:
      
      arch/powerpc/lib/sstep.c: In function 'do_popcnt':
      arch/powerpc/lib/sstep.c:1068: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c:1069: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c:1069: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c:1070: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c:1079: error: integer constant is too large for 'long' type
      arch/powerpc/lib/sstep.c: In function 'do_prty':
      arch/powerpc/lib/sstep.c:1117: error: integer constant is too large for 'long' type
      
      This file gets compiled with -std=gnu89 which means a constant can be
      given the type 'long' even if it won't fit. Fix the errors with a 'ULL'
      suffix on the relevant constants.
      
      Fixes: 2c979c48 ("powerpc/lib/sstep: Add prty instruction emulation")
      Fixes: dcbd19b4 ("powerpc/lib/sstep: Add popcnt instruction emulation")
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      20acf7fc
  5. 17 May, 2018 5 commits
    • Nicholas Piggin's avatar
      powerpc/powernv: Fix opal_event_shutdown() called with interrupts disabled · c0beffc4
      Nicholas Piggin authored
      A kernel crash in process context that calls emergency_restart from
      panic will end up calling opal_event_shutdown with interrupts disabled
      but not in interrupt. This causes a sleeping function to be called
      which gives the following warning with sysrq+c:
      
          Rebooting in 10 seconds..
          BUG: sleeping function called from invalid context at kernel/locking/mutex.c:238
          in_atomic(): 0, irqs_disabled(): 1, pid: 7669, name: bash
          CPU: 20 PID: 7669 Comm: bash Tainted: G      D W         4.17.0-rc5+ #3
          Call Trace:
          dump_stack+0xb0/0xf4 (unreliable)
          ___might_sleep+0x174/0x1a0
          mutex_lock+0x38/0xb0
          __free_irq+0x68/0x460
          free_irq+0x70/0xc0
          opal_event_shutdown+0xb4/0xf0
          opal_shutdown+0x24/0xa0
          pnv_shutdown+0x28/0x40
          machine_shutdown+0x44/0x60
          machine_restart+0x28/0x80
          emergency_restart+0x30/0x50
          panic+0x2a0/0x328
          oops_end+0x1ec/0x1f0
          bad_page_fault+0xe8/0x154
          handle_page_fault+0x34/0x38
          --- interrupt: 300 at sysrq_handle_crash+0x44/0x60
          LR = __handle_sysrq+0xfc/0x260
          flag_spec.62335+0x12b844/0x1e8db4 (unreliable)
          __handle_sysrq+0xfc/0x260
          write_sysrq_trigger+0xa8/0xb0
          proc_reg_write+0xac/0x110
          __vfs_write+0x6c/0x240
          vfs_write+0xd0/0x240
          ksys_write+0x6c/0x110
      
      Fixes: 9f0fd049 ("powerpc/powernv: Add a virtual irqchip for opal events")
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      c0beffc4
    • Christophe Leroy's avatar
      powerpc/32: Use stmw/lmw for registers save/restore in asm · a1f3ae3f
      Christophe Leroy authored
      arch/powerpc/Makefile activates -mmultiple on BE PPC32 configs
      in order to use multiple word instructions in functions entry/exit.
      
      The patch does the same for the asm parts, for consistency.
      
      On processors like the 8xx on which insn fetching is pretty slow,
      this speeds up registers save/restore.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      [mpe: PPC32 is BE only, so drop the endian checks]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a1f3ae3f
    • Christophe Leroy's avatar
      powerpc: Avoid an unnecessary test and branch in longjmp() · 24c78586
      Christophe Leroy authored
      Doing the test at exit of the function avoids an unnecessary
      test and branch inside longjmp().
      
      Semantics are unchanged.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Reviewed-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      24c78586
    • Christophe Leroy's avatar
      Revert "powerpc/64: Fix checksum folding in csum_add()" · 96f391cf
      Christophe Leroy authored
      This reverts commit 6ad966d7.
      
      That commit was pointless, because csum_add() sums two 32 bits
      values, so the sum is 0x1fffffffe at the maximum.
      And then when adding upper part (1) and lower part (0xfffffffe),
      the result is 0xffffffff which doesn't carry.
      Any lower value will not carry either.
      
      And behind the fact that this commit is useless, it also kills the
      whole purpose of having an arch specific inline csum_add()
      because the resulting code gets even worse than what is obtained
      with the generic implementation of csum_add()
      
      0000000000000240 <.csum_add>:
       240:	38 00 ff ff 	li      r0,-1
       244:	7c 84 1a 14 	add     r4,r4,r3
       248:	78 00 00 20 	clrldi  r0,r0,32
       24c:	78 89 00 22 	rldicl  r9,r4,32,32
       250:	7c 80 00 38 	and     r0,r4,r0
       254:	7c 09 02 14 	add     r0,r9,r0
       258:	78 09 00 22 	rldicl  r9,r0,32,32
       25c:	7c 00 4a 14 	add     r0,r0,r9
       260:	78 03 00 20 	clrldi  r3,r0,32
       264:	4e 80 00 20 	blr
      
      In comparison, the generic implementation of csum_add() gives:
      
      0000000000000290 <.csum_add>:
       290:	7c 63 22 14 	add     r3,r3,r4
       294:	7f 83 20 40 	cmplw   cr7,r3,r4
       298:	7c 10 10 26 	mfocrf  r0,1
       29c:	54 00 ef fe 	rlwinm  r0,r0,29,31,31
       2a0:	7c 60 1a 14 	add     r3,r0,r3
       2a4:	78 63 00 20 	clrldi  r3,r3,32
       2a8:	4e 80 00 20 	blr
      
      And the reverted implementation for PPC64 gives:
      
      0000000000000240 <.csum_add>:
       240:	7c 84 1a 14 	add     r4,r4,r3
       244:	78 80 00 22 	rldicl  r0,r4,32,32
       248:	7c 80 22 14 	add     r4,r0,r4
       24c:	78 83 00 20 	clrldi  r3,r4,32
       250:	4e 80 00 20 	blr
      
      Fixes: 6ad966d7 ("powerpc/64: Fix checksum folding in csum_add()")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Acked-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      96f391cf
    • Christophe Leroy's avatar
      powerpc: get rid of PMD_PAGE_SIZE() and _PMD_SIZE · 5279821a
      Christophe Leroy authored
      PMD_PAGE_SIZE() is nowhere used and _PMD_SIZE is only
      used by PMD_PAGE_SIZE().
      
      This patch removes them.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      5279821a
  6. 15 May, 2018 13 commits