linux-stable/arch/powerpc/perf
Michael Ellerman ad53db4acb powerpc/imc-pmu: Revert nest_init_lock to being a mutex
The recent commit 76d588dddc ("powerpc/imc-pmu: Fix use of mutex in
IRQs disabled section") fixed warnings (and possible deadlocks) in the
IMC PMU driver by converting the locking to use spinlocks.

It also converted the init-time nest_init_lock to a spinlock, even
though it's not used at runtime in IRQ disabled sections or while
holding other spinlocks.

This leads to warnings such as:

  BUG: sleeping function called from invalid context at include/linux/percpu-rwsem.h:49
  in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
  preempt_count: 1, expected: 0
  CPU: 7 PID: 1 Comm: swapper/0 Not tainted 6.2.0-rc2-14719-gf12cd06109f4-dirty #1
  Hardware name: Mambo,Simulated-System POWER9 0x4e1203 opal:v6.6.6 PowerNV
  Call Trace:
    dump_stack_lvl+0x74/0xa8 (unreliable)
    __might_resched+0x178/0x1a0
    __cpuhp_setup_state+0x64/0x1e0
    init_imc_pmu+0xe48/0x1250
    opal_imc_counters_probe+0x30c/0x6a0
    platform_probe+0x78/0x110
    really_probe+0x104/0x420
    __driver_probe_device+0xb0/0x170
    driver_probe_device+0x58/0x180
    __driver_attach+0xd8/0x250
    bus_for_each_dev+0xb4/0x140
    driver_attach+0x34/0x50
    bus_add_driver+0x1e8/0x2d0
    driver_register+0xb4/0x1c0
    __platform_driver_register+0x38/0x50
    opal_imc_driver_init+0x2c/0x40
    do_one_initcall+0x80/0x360
    kernel_init_freeable+0x310/0x3b8
    kernel_init+0x30/0x1a0
    ret_from_kernel_thread+0x5c/0x64

Fix it by converting nest_init_lock back to a mutex, so that we can call
sleeping functions while holding it. There is no interaction between
nest_init_lock and the runtime spinlocks used by the actual PMU routines.

Fixes: 76d588dddc ("powerpc/imc-pmu: Fix use of mutex in IRQs disabled section")
Tested-by: Kajol Jain<kjain@linux.ibm.com>
Reviewed-by: Kajol Jain<kjain@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230130014401.540543-1-mpe@ellerman.id.au
2023-01-31 11:24:17 +11:00
..
req-gen powerpc/hv-gpci: Fix hv_gpci event list 2022-12-02 20:39:26 +11:00
8xx-pmu.c powerpc: fix typos in comments 2022-05-05 22:12:44 +10:00
bhrb.S powerpc/64: asm use consistent global variable declaration and access 2022-09-28 19:22:12 +10:00
callchain.c powerpc: split validate_sp into two functions 2022-12-02 17:54:09 +11:00
callchain.h powerpc/64s/hash: Make hash faults work in NMI context 2022-02-24 12:46:54 +11:00
callchain_32.c powerpc: Include all arch-specific syscall prototypes 2022-09-28 19:22:08 +10:00
callchain_64.c powerpc/64s/hash: Make hash faults work in NMI context 2022-02-24 12:46:54 +11:00
core-book3s.c perf: Rewrite core context handling 2022-10-27 20:12:16 +02:00
core-fsl-emb.c powerpc/perf: move perf irq/nmi handling details into traps.c 2021-02-09 00:02:10 +11:00
e500-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
e6500-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
generic-compat-pmu.c powerpc/perf: Add support for caps under sysfs in powerpc 2022-07-18 10:39:54 +10:00
hv-24x7-catalog.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-24x7-domains.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-24x7.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
hv-24x7.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-common.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-common.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hv-gpci-requests.h powerpc/hv-gpci: Fix hv_gpci event list 2022-12-02 20:39:26 +11:00
hv-gpci.c powerpc/hv-gpci: Fix hv_gpci event list 2022-12-02 20:39:26 +11:00
hv-gpci.h powerpc/hv-gpci: Fix hv_gpci event list 2022-12-02 20:39:26 +11:00
imc-pmu.c powerpc/imc-pmu: Revert nest_init_lock to being a mutex 2023-01-31 11:24:17 +11:00
internal.h powerpc/perf: Add __init attribute to eligible functions 2021-12-23 22:33:11 +11:00
isa207-common.c powerpc/perf: Update MMCR2 to support event exclude_idle 2022-06-29 19:42:41 +10:00
isa207-common.h powerpc/perf: Update MMCR2 to support event exclude_idle 2022-06-29 19:42:41 +10:00
Makefile powerpc/perf: Fix 32bit compile 2022-04-21 23:26:47 +10:00
mpc7450-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
perf_regs.c powerpc: Use the newly added is_tsk_32bit_task() macro 2022-02-12 22:47:42 +11:00
power5+-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
power5-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
power6-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
power7-events-list.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
power7-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
power8-events-list.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
power8-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
power9-events-list.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
power9-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00
power10-events-list.h powerpc/perf: Fix cycles/instructions as PM_CYC/PM_INST_CMPL in power10 2021-10-14 21:46:45 +11:00
power10-pmu.c powerpc/perf: Include caps feature for power10 DD1 version 2022-08-01 22:21:18 +10:00
ppc970-pmu.c powerpc/perf: Use PVR rather than oprofile field to determine CPU version 2022-07-27 21:36:05 +10:00