linux/drivers/hwtracing/coresight
Mike Leach 3dc228b353 coresight: cti: Fix null pointer error on CTI init before ETM
When CTI is discovered first then the function
coresight_set_assoc_ectdev_mutex() is called to set the association
between CTI and ETM device. Recent lockdep fix passes a null pointer.

This patch passes the correct pointer.

Before patch: log of boot oops sequence with CTI discovered first:

[   12.424091]  cs_system_cfg: CoreSight Configuration manager initialised
[   12.483474] coresight cti_sys0: CTI initialized
[   12.488109] coresight cti_sys1: CTI initialized
[   12.503594] coresight cti_cpu0: CTI initialized
[   12.517877] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized
[   12.523479] coresight-cpu-debug 852000.debug: Coresight debug-CPU1 initialized
[   12.529926] coresight-cpu-debug 854000.debug: Coresight debug-CPU2 initialized
[   12.541808] coresight stm0: STM32 initialized
[   12.544421] coresight-cpu-debug 856000.debug: Coresight debug-CPU3 initialized
[   12.585639] coresight cti_cpu1: CTI initialized
[   12.614028] coresight cti_cpu2: CTI initialized
[   12.631679] CSCFG registered etm0
[   12.633920] coresight etm0: CPU0: etm v4.0 initialized
[   12.656392] coresight cti_cpu3: CTI initialized

...

[   12.708383] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000348

...

[   12.755094] Internal error: Oops: 0000000096000044 [#1] SMP
[   12.761817] Modules linked in: coresight_etm4x(+) coresight_tmc coresight_cpu_debug coresight_replicator coresight_funnel coresight_cti coresight_tpiu coresight_stm coresight
[   12.767210] CPU: 3 PID: 1346 Comm: systemd-udevd Not tainted 6.1.0-rc3tid-v6tid-v6-235166-gf7f7d7a2204a-dirty #498
[   12.782827] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
[   12.793154] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   12.800010] pc : coresight_set_assoc_ectdev_mutex+0x30/0x50 [coresight]
[   12.806694] lr : coresight_set_assoc_ectdev_mutex+0x30/0x50 [coresight]

...

[   12.885064] Call trace:
[   12.892352]  coresight_set_assoc_ectdev_mutex+0x30/0x50 [coresight]
[   12.894693]  cti_add_assoc_to_csdev+0x144/0x1b0 [coresight_cti]
[   12.900943]  coresight_register+0x2c8/0x320 [coresight]
[   12.906844]  etm4_add_coresight_dev.isra.27+0x148/0x280 [coresight_etm4x]
[   12.912056]  etm4_probe+0x144/0x1c0 [coresight_etm4x]
[   12.918998]  etm4_probe_amba+0x40/0x78 [coresight_etm4x]
[   12.924032]  amba_probe+0x11c/0x1f0

After patch: similar log

[   12.444467]  cs_system_cfg: CoreSight Configuration manager initialised
[   12.456329] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized
[   12.456754] coresight-cpu-debug 852000.debug: Coresight debug-CPU1 initialized
[   12.469672] coresight-cpu-debug 854000.debug: Coresight debug-CPU2 initialized
[   12.476098] coresight-cpu-debug 856000.debug: Coresight debug-CPU3 initialized
[   12.532409] coresight stm0: STM32 initialized
[   12.533708] coresight cti_sys0: CTI initialized
[   12.539478] coresight cti_sys1: CTI initialized
[   12.550106] coresight cti_cpu0: CTI initialized
[   12.633931] coresight cti_cpu1: CTI initialized
[   12.634664] coresight cti_cpu2: CTI initialized
[   12.638090] coresight cti_cpu3: CTI initialized
[   12.721136] CSCFG registered etm0

...

[   12.762643] CSCFG registered etm1
[   12.762666] coresight etm1: CPU1: etm v4.0 initialized
[   12.776258] CSCFG registered etm2
[   12.776282] coresight etm2: CPU2: etm v4.0 initialized
[   12.784357] CSCFG registered etm3
[   12.785455] coresight etm3: CPU3: etm v4.0 initialized

Error can also be triggered by manually starting the modules using modprobe
in the following order:

root@linaro-developer:/home/linaro/cs-mods# modprobe coresight
root@linaro-developer:/home/linaro/cs-mods# modprobe coresight-cti
root@linaro-developer:/home/linaro/cs-mods# modprobe coresight-etm4x

Tested on Dragonboard DB410c
Applies to coresight/next

Fixes: 23722fb467 ("coresight: Fix possible deadlock with lock dependency")
Signed-off-by: Mike Leach <mike.leach@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20221123193818.6253-1-mike.leach@linaro.org
2022-11-28 18:29:49 +00: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 null pointer error on CTI init before ETM 2022-11-28 18:29:49 +00: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-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 coresight: etm4x: add CPU hotplug support for probing 2022-10-31 10:32:46 +00: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-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-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: remove cpuhp instance node before remove cpuhp state 2022-11-28 18:29:46 +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