linux-stable/drivers/hwtracing/coresight
James Clark 6746eae4bb coresight: cti: Fix hang in cti_disable_hw()
cti_enable_hw() and cti_disable_hw() are called from an atomic context
so shouldn't use runtime PM because it can result in a sleep when
communicating with firmware.

Since commit 3c66563378 ("Revert "firmware: arm_scmi: Add clock
management to the SCMI power domain""), this causes a hang on Juno when
running the Perf Coresight tests or running this command:

  perf record -e cs_etm//u -- ls

This was also missed until the revert commit because pm_runtime_put()
was called with the wrong device until commit 692c9a499b ("coresight:
cti: Correct the parameter for pm_runtime_put")

With lock and scheduler debugging enabled the following is output:

   coresight cti_sys0: cti_enable_hw -- dev:cti_sys0  parent: 20020000.cti
   BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:1151
   in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 330, name: perf-exec
   preempt_count: 2, expected: 0
   RCU nest depth: 0, expected: 0
   INFO: lockdep is turned off.
   irq event stamp: 0
   hardirqs last  enabled at (0): [<0000000000000000>] 0x0
   hardirqs last disabled at (0): [<ffff80000822b394>] copy_process+0xa0c/0x1948
   softirqs last  enabled at (0): [<ffff80000822b394>] copy_process+0xa0c/0x1948
   softirqs last disabled at (0): [<0000000000000000>] 0x0
   CPU: 3 PID: 330 Comm: perf-exec Not tainted 6.0.0-00053-g042116d99298 #7
   Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Sep 13 2022
   Call trace:
    dump_backtrace+0x134/0x140
    show_stack+0x20/0x58
    dump_stack_lvl+0x8c/0xb8
    dump_stack+0x18/0x34
    __might_resched+0x180/0x228
    __might_sleep+0x50/0x88
    __pm_runtime_resume+0xac/0xb0
    cti_enable+0x44/0x120
    coresight_control_assoc_ectdev+0xc0/0x150
    coresight_enable_path+0xb4/0x288
    etm_event_start+0x138/0x170
    etm_event_add+0x48/0x70
    event_sched_in.isra.122+0xb4/0x280
    merge_sched_in+0x1fc/0x3d0
    visit_groups_merge.constprop.137+0x16c/0x4b0
    ctx_sched_in+0x114/0x1f0
    perf_event_sched_in+0x60/0x90
    ctx_resched+0x68/0xb0
    perf_event_exec+0x138/0x508
    begin_new_exec+0x52c/0xd40
    load_elf_binary+0x6b8/0x17d0
    bprm_execve+0x360/0x7f8
    do_execveat_common.isra.47+0x218/0x238
    __arm64_sys_execve+0x48/0x60
    invoke_syscall+0x4c/0x110
    el0_svc_common.constprop.4+0xfc/0x120
    do_el0_svc+0x34/0xc0
    el0_svc+0x40/0x98
    el0t_64_sync_handler+0x98/0xc0
    el0t_64_sync+0x170/0x174

Fix the issue by removing the runtime PM calls completely. They are not
needed here because it must have already been done when building the
path for a trace.

Fixes: 835d722ba1 ("coresight: cti: Initial CoreSight CTI Driver")
Cc: stable <stable@kernel.org>
Reported-by: Aishwarya TCV <Aishwarya.TCV@arm.com>
Reported-by: Cristian Marussi <Cristian.Marussi@arm.com>
Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: James Clark <james.clark@arm.com>
Reviewed-by: Mike Leach <mike.leach@linaro.org>
Tested-by: Mike Leach <mike.leach@linaro.org>
[ Fix build warnings ]
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20221025131032.1149459-1-suzuki.poulose@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-10-25 19:08:07 +02:00
..
coresight-catu.c coresight: Re-use same function for similar sysfs register accessors 2022-08-31 10:55:28 -06:00
coresight-catu.h coresight: Make new csdev_access offsets unsigned 2022-08-31 10:56:36 -06:00
coresight-cfg-afdo.c coresight: config: Add preloaded configurations 2021-08-18 22:33:28 +02:00
coresight-cfg-preload.c coresight: configuration: Update API to introduce load owner concept 2021-11-26 11:27:21 -07:00
coresight-cfg-preload.h coresight: config: Add preloaded configurations 2021-08-18 22:33:28 +02:00
coresight-config.c coresight: config: Add configuration and feature generic functions 2021-08-18 22:33:27 +02:00
coresight-config.h coresight: syscfg: Update load and unload operations 2022-06-29 09:35:58 -06:00
coresight-core.c coresight: Fix possible deadlock with lock dependency 2022-10-20 22:32:02 +01:00
coresight-cpu-debug.c coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier 2022-05-09 16:03:24 +01:00
coresight-cti-core.c coresight: cti: Fix hang in cti_disable_hw() 2022-10-25 19:08:07 +02:00
coresight-cti-platform.c coresight: cti: Reduce scope for the variable 'cs_fwnode' in cti_plat_create_connection() 2021-02-04 17:00:32 +01:00
coresight-cti-sysfs.c coresight: cti-sysfs: Mark coresight_cti_reg_store() as __maybe_unused 2022-09-06 14:14:33 -06:00
coresight-cti.h coresight: Include required headers in C files 2020-05-19 16:31:18 +02:00
coresight-etb10.c coresight: Re-use same function for similar sysfs register accessors 2022-08-31 10:55:28 -06:00
coresight-etm-cp14.c coresight: Moving framework and drivers to SPDX identifier 2018-05-14 16:19:59 +02:00
coresight-etm-perf.c coresight: Add config flag to enable branch broadcast 2022-07-06 16:32:08 +01:00
coresight-etm-perf.h coresight: etm-perf: Update to activate selected configuration 2021-08-18 22:33:28 +02:00
coresight-etm.h coresight: etm: Clean up device specific data 2019-06-19 20:29:14 +02:00
coresight-etm3x-core.c coresight: etm3x: Cleanup ETMTECR1 register accesses 2022-04-13 11:05:17 -06:00
coresight-etm3x-sysfs.c coresight: Re-use same function for similar sysfs register accessors 2022-08-31 10:55:28 -06:00
coresight-etm4x-cfg.c coresight: etm4x: Add complex configuration handlers to etmv4 2021-08-18 22:33:28 +02:00
coresight-etm4x-cfg.h coresight: config: Add preloaded configurations 2021-08-18 22:33:28 +02:00
coresight-etm4x-core.c arm64/sysreg: Fix a few missed conversions 2022-09-21 09:24:29 +01:00
coresight-etm4x-sysfs.c coresight: etm4x: Expose default timestamp source in sysfs 2022-08-26 13:37:52 -06:00
coresight-etm4x.h asm-generic: updates for 6.0 2022-08-05 10:07:23 -07:00
coresight-funnel.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-platform.c hwtracing: coresight: Replace acpi_bus_get_device() 2022-03-11 10:07:34 +00:00
coresight-priv.h coresight: Make new csdev_access offsets unsigned 2022-08-31 10:56:36 -06:00
coresight-replicator.c coresight: Re-use same function for similar sysfs register accessors 2022-08-31 10:55:28 -06:00
coresight-self-hosted-trace.h coresight: trbe: Prohibit trace before disabling TRBE 2021-10-27 11:45:33 -06:00
coresight-stm.c coresight: Re-use same function for similar sysfs register accessors 2022-08-31 10:55:28 -06:00
coresight-syscfg-configfs.c coresight: configfs: Allow configfs to activate configuration 2021-11-26 11:34:27 -07:00
coresight-syscfg-configfs.h coresight: configfs: Allow configfs to activate configuration 2021-11-26 11:34:27 -07:00
coresight-syscfg.c coresight: syscfg: Update load and unload operations 2022-06-29 09:35:58 -06:00
coresight-syscfg.h coresight: syscfg: Update load and unload operations 2022-06-29 09:35:58 -06:00
coresight-sysfs.c coresight: Export global symbols 2020-09-28 19:47:40 +02:00
coresight-tmc-core.c coresight: Re-use same function for similar sysfs register accessors 2022-08-31 10:55:28 -06:00
coresight-tmc-etf.c coresight: Update comments for removing cs_etm_find_snapshot() 2021-10-27 11:44:50 -06:00
coresight-tmc-etr.c coresight: tmc-etr: Speed up for bounce buffer in flat mode 2021-10-27 11:44:52 -06:00
coresight-tmc.h coresight: Make new csdev_access offsets unsigned 2022-08-31 10:56:36 -06:00
coresight-tpiu.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-trbe.c coresight: trbe: Move check for kernel page table isolation from EL0 to probe 2022-03-11 10:07:43 +00:00
coresight-trbe.h arm64/sysreg: Fix a few missed conversions 2022-09-21 09:24:29 +01:00
Kconfig coresight: trbe: fix Kconfig "its" grammar 2022-08-22 09:56:30 -06:00
Makefile coresight: syscfg: Add initial configfs support 2021-08-18 22:33:28 +02:00