linux/drivers/hwtracing/coresight
Tingwei Zhang 984f37efa3 coresight: cti: Write regsiters directly in cti_enable_hw()
Deadlock as below is triggered by one CPU holds drvdata->spinlock
and calls cti_enable_hw(). Smp_call_function_single() is called
in cti_enable_hw() and tries to let another CPU write CTI registers.
That CPU is trying to get drvdata->spinlock in cti_cpu_pm_notify()
and doesn't response to IPI from smp_call_function_single().

[  988.335937] CPU: 6 PID: 10258 Comm: sh Tainted: G        W    L
5.8.0-rc6-mainline-16783-gc38daa79b26b-dirty #1
[  988.346364] Hardware name: Thundercomm Dragonboard 845c (DT)
[  988.352073] pstate: 20400005 (nzCv daif +PAN -UAO BTYPE=--)
[  988.357689] pc : smp_call_function_single+0x158/0x1b8
[  988.362782] lr : smp_call_function_single+0x124/0x1b8
...
[  988.451638] Call trace:
[  988.454119]  smp_call_function_single+0x158/0x1b8
[  988.458866]  cti_enable+0xb4/0xf8 [coresight_cti]
[  988.463618]  coresight_control_assoc_ectdev+0x6c/0x128 [coresight]
[  988.469855]  coresight_enable+0x1f0/0x364 [coresight]
[  988.474957]  enable_source_store+0x5c/0x9c [coresight]
[  988.480140]  dev_attr_store+0x14/0x28
[  988.483839]  sysfs_kf_write+0x38/0x4c
[  988.487532]  kernfs_fop_write+0x1c0/0x2b0
[  988.491585]  vfs_write+0xfc/0x300
[  988.494931]  ksys_write+0x78/0xe0
[  988.498283]  __arm64_sys_write+0x18/0x20
[  988.502240]  el0_svc_common+0x98/0x160
[  988.506024]  do_el0_svc+0x78/0x80
[  988.509377]  el0_sync_handler+0xd4/0x270
[  988.513337]  el0_sync+0x164/0x180

This change write CTI registers directly in cti_enable_hw().
Config->hw_powered has been checked to be true with spinlock holded.
CTI is powered and can be programmed until spinlock is released.

Fixes: 6a0953ce7d ("coresight: cti: Add CPU idle pm notifer to CTI devices")
Signed-off-by: Tingwei Zhang <tingwei@codeaurora.org>
[Re-ordered variable declaration]
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20200916191737.4001561-10-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-17 18:46:04 +02:00
..
coresight-catu.c coresight: catu: Use CS_AMBA_ID macro for id table 2020-07-21 15:48:38 +02:00
coresight-catu.h coresight: catu: Cleanup device specific data 2019-06-19 20:29:14 +02:00
coresight-cpu-debug.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
coresight-cti-platform.c Char/Misc driver patches for 5.8-rc1 2020-06-07 10:59:32 -07:00
coresight-cti-sysfs.c coresight: Include required headers in C files 2020-05-19 16:31:18 +02:00
coresight-cti.c coresight: cti: Write regsiters directly in cti_enable_hw() 2020-09-17 18:46:04 +02:00
coresight-cti.h coresight: Include required headers in C files 2020-05-19 16:31:18 +02:00
coresight-etb10.c coresight: etb10: Make coresight_etb_groups static 2020-05-19 16:31:16 +02:00
coresight-etm3x-sysfs.c coresight: etm: Clean up device specific data 2019-06-19 20:29:14 +02:00
coresight-etm3x.c coresight: Initialize arg in sparse friendly way 2020-05-19 16:31:17 +02:00
coresight-etm4x-sysfs.c coresight: etm4x: Fix issues within reset interface of sysfs 2020-09-17 18:46:04 +02:00
coresight-etm4x.c coresight: etm4x: Ensure default perf settings filter user/kernel 2020-09-17 18:46:04 +02:00
coresight-etm4x.h coresight: etm4x: Ensure default perf settings filter user/kernel 2020-09-17 18:46:04 +02: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: etm: perf: Add default sink selection to etm perf 2020-07-21 15:48:40 +02:00
coresight-etm-perf.h coresight: perf: Add "sinks" group to PMU directory 2019-02-08 12:27:36 +01:00
coresight-etm.h coresight: etm: Clean up device specific data 2019-06-19 20:29:14 +02:00
coresight-funnel.c coresight: funnel: Fix missing spin_lock_init() 2019-11-19 19:18:15 +01:00
coresight-platform.c coresight: fix offset by one error in counting ports 2020-09-17 18:46:04 +02:00
coresight-priv.h coresight: Add default sink selection to CoreSight base 2020-07-21 15:48:40 +02:00
coresight-replicator.c coresight: replicator: Reset replicator if context is lost 2020-07-21 15:48:38 +02:00
coresight-stm.c coresight: stm: Support marked packet 2020-09-17 18:46:04 +02:00
coresight-sysfs.c coresight: Expose device connections via sysfs 2020-05-19 16:31:15 +02:00
coresight-tmc-etf.c coresight: tmc: Fix TMC mode read in tmc_read_unprepare_etb() 2020-07-21 15:48:39 +02:00
coresight-tmc-etr.c coresight: tmc: Add shutdown callback for TMC ETR 2020-07-21 15:48:39 +02:00
coresight-tmc.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
coresight-tmc.h coresight: tmc: Add shutdown callback for TMC ETR 2020-07-21 15:48:39 +02:00
coresight-tpiu.c coresight: Use platform agnostic names 2019-06-20 07:56:13 +02:00
coresight.c coresight: Add default sink selection to CoreSight base 2020-07-21 15:48:40 +02:00
Kconfig docs: fix broken references to text files 2020-04-20 15:35:59 -06:00
Makefile coresight: Add generic sysfs link creation functions 2020-05-19 16:31:15 +02:00