linux-stable/arch/powerpc
Michael Ellerman 8edda487f0 powerpc/imc-pmu: Revert nest_init_lock to being a mutex
commit ad53db4acb upstream.

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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-02-22 12:50:29 +01:00
..
boot powerpc: Fix SPE Power ISA properties for e500v1 platforms 2022-10-26 13:22:45 +02:00
configs powerpc/config: Renable MTD_PHYSMAP_OF 2021-09-22 12:26:24 +02:00
crypto
include powerpc/imc-pmu: Fix use of mutex in IRQs disabled section 2023-01-18 11:42:03 +01:00
kernel exit: Add and use make_task_dead. 2023-02-06 07:52:49 +01:00
kvm KVM: PPC: Fix TCE handling for VFIO 2022-04-27 13:50:49 +02:00
lib powerpc/lib/sstep: Fix build errors with newer binutils 2022-04-15 14:18:25 +02:00
math-emu powerpc/math_emu/efp: Include module.h 2022-10-26 13:22:44 +02:00
mm powerpc/ptdump: Fix display of RW pages on FSL_BOOK3E 2022-08-25 11:17:25 +02:00
net powerpc/bpf: Emit stf barrier instruction sequences for BPF_NOSPEC 2021-11-17 09:48:49 +01:00
oprofile
perf powerpc/imc-pmu: Revert nest_init_lock to being a mutex 2023-02-22 12:50:29 +01:00
platforms powerpc/83xx/mpc832x_rdb: call platform_device_put() in error case in of_fsl_spi_probe() 2023-01-18 11:41:30 +01:00
purgatory
sysdev powerpc/xive: add missing iounmap() in error path in xive_spapr_populate_irq_data() 2023-01-18 11:41:30 +01:00
tools
xmon powerpc/xmon: Change printk() to pr_cont() 2020-12-30 11:51:39 +01:00
Kbuild
Kconfig powerpc: Fix HAVE_HARDLOCKUP_DETECTOR_ARCH build configuration 2021-05-14 09:44:26 +02:00
Kconfig.debug powerpc: iommu: fix build when neither PCI or IBMVIO is set 2021-05-14 09:44:28 +02:00
Makefile powerpc/64s: Fix GENERIC_CPU build flags for PPC970 / G5 2022-10-26 13:22:45 +02:00
Makefile.postlink