30 Oct, 2020

2 commits

  • With LOCKDEP enabled, CTI driver triggers the following splat due
    to uninitialized lock class for dynamically allocated attribute
    objects.

    [ 5.372901] coresight etm0: CPU0: ETM v4.0 initialized
    [ 5.376694] coresight etm1: CPU1: ETM v4.0 initialized
    [ 5.380785] coresight etm2: CPU2: ETM v4.0 initialized
    [ 5.385851] coresight etm3: CPU3: ETM v4.0 initialized
    [ 5.389808] BUG: key ffff00000564a798 has not been registered!
    [ 5.392456] ------------[ cut here ]------------
    [ 5.398195] DEBUG_LOCKS_WARN_ON(1)
    [ 5.398233] WARNING: CPU: 1 PID: 32 at kernel/locking/lockdep.c:4623 lockdep_init_map_waits+0x14c/0x260
    [ 5.406149] Modules linked in:
    [ 5.415411] CPU: 1 PID: 32 Comm: kworker/1:1 Not tainted 5.9.0-12034-gbbe85027ce80 #51
    [ 5.418553] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
    [ 5.426453] Workqueue: events amba_deferred_retry_func
    [ 5.433299] pstate: 40000005 (nZcv daif -PAN -UAO -TCO BTYPE=--)
    [ 5.438252] pc : lockdep_init_map_waits+0x14c/0x260
    [ 5.444410] lr : lockdep_init_map_waits+0x14c/0x260
    [ 5.449007] sp : ffff800012bbb720
    ...

    [ 5.531561] Call trace:
    [ 5.536847] lockdep_init_map_waits+0x14c/0x260
    [ 5.539027] __kernfs_create_file+0xa8/0x1c8
    [ 5.543539] sysfs_add_file_mode_ns+0xd0/0x208
    [ 5.548054] internal_create_group+0x118/0x3c8
    [ 5.552307] internal_create_groups+0x58/0xb8
    [ 5.556733] sysfs_create_groups+0x2c/0x38
    [ 5.561160] device_add+0x2d8/0x768
    [ 5.565148] device_register+0x28/0x38
    [ 5.568537] coresight_register+0xf8/0x320
    [ 5.572358] cti_probe+0x1b0/0x3f0

    ...

    Fix this by initializing the attributes when they are allocated.

    Fixes: 3c5597e39812 ("coresight: cti: Add connection information to sysfs")
    Reported-by: Leo Yan
    Tested-by: Leo Yan
    Cc: Mike Leach
    Cc: Mathieu Poirier
    Signed-off-by: Suzuki K Poulose
    Cc: stable
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201029164559.1268531-2-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     
  • Commit [bb1860efc817] changed the sink handling code introducing an
    uninitialised pointer bug. This results in the default sink selection
    failing.

    Prior to commit:

    static void etm_setup_aux(...)

    struct coresight_device *sink;

    /* First get the selected sink from user space. */
    if (event->attr.config2) {
    id = (u32)event->attr.config2;
    sink = coresight_get_sink_by_id(id);
    } else {
    sink = coresight_get_enabled_sink(true);
    }

    *sink always initialised - possibly to NULL which triggers the
    automatic sink selection.

    After commit:

    static void etm_setup_aux(...)

    struct coresight_device *sink;

    /* First get the selected sink from user space. */
    if (event->attr.config2) {
    id = (u32)event->attr.config2;
    sink = coresight_get_sink_by_id(id);
    }

    *sink pointer uninitialised when not providing a sink on the perf command
    line. This breaks later checks to enable automatic sink selection.

    Fixes: bb1860efc817 ("coresight: etm: perf: Sink selection using sysfs is deprecated")
    Signed-off-by: Mike Leach
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201029164559.1268531-3-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Mike Leach
     

29 Oct, 2020

1 commit

  • When built as a loadable module, coresight now causes a warning about
    missing license information.

    WARNING: modpost: missing MODULE_LICENSE() in drivers/hwtracing/coresight/coresight.o

    Fixes: 8e264c52e1da ("coresight: core: Allow the coresight core driver to be built as a module")
    Signed-off-by: Arnd Bergmann
    Cc: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201026160205.3704789-1-arnd@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     

05 Oct, 2020

5 commits

  • This adds support for the Trace Hub in Alder Lake CPU.

    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-9-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Alexander Shishkin
     
  • This adds support for the Trace Hub in Alder Lake-S.

    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-8-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Alexander Shishkin
     
  • To avoid mixup of packets from differnt ftrace packets simultaneously,
    use different channel for packets from different CPU.

    Reviewed-by: Steven Rostedt (VMware)
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-7-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • Set flags for trace_export. Export function trace, event trace
    and trace marker to stm.

    Reviewed-by: Steven Rostedt (VMware)
    Reviewed-by: Alexander Shishkin
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-6-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • We will support copying event trace to STM. Change
    STM_SOURCE_FTRACE to depend on TRACING since we will
    support multiple tracers.

    Reviewed-by: Steven Rostedt (VMware)
    Reviewed-by: Alexander Shishkin
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-2-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     

29 Sep, 2020

25 commits

  • In commit f188b5e76aae ("coresight: etm4x: Save/restore state
    across CPU low power states"), mistakenly TRCVMIDCCTLR1 register
    value was saved in trcvmidcctlr0 state variable which is used to
    store TRCVMIDCCTLR0 register value in etm4x_cpu_save() and then
    same value is written back to both TRCVMIDCCTLR0 and TRCVMIDCCTLR1
    in etm4x_cpu_restore(). There is already a trcvmidcctlr1 state
    variable available for TRCVMIDCCTLR1, so use it.

    Fixes: f188b5e76aae ("coresight: etm4x: Save/restore state across CPU low power states")
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Sai Prakash Ranjan
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-26-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Sai Prakash Ranjan
     
  • Enhance coresight developer's efficiency to debug coresight drivers.
    - Kconfig becomes a tristate, to allow =m
    - append -core to source file name to allow module to
    be called coresight by the Makefile
    - modules can have only one init/exit, so we add the etm_perf
    register/unregister function calls to the core init/exit
    functions.
    - add a MODULE_DEVICE_TABLE for autoloading on boot

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Kim Phillips
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-25-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • Allow to build coresight-catu as modules, for ease of development.
    - Kconfig becomes a tristate, to allow =m
    - add catu_remove functions, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot

    Reviewed-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-24-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • Make etr_catu_buf_ops static. Instead of directly accessing it in
    etr_buf_ops[], add a function to let catu driver register the ops at
    runtime. Break circular dependency between tmc-etr and catu drivers.

    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Mian Yousaf Kaukab
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-23-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Mian Yousaf Kaukab
     
  • Allow to build coresight-cti as a module, for ease of development.

    - Kconfig becomes a tristate, to allow =m
    - append -core to source file name to allow module to
    be called coresight-cti by the Makefile
    - add an cti_remove function, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot
    - move cti_remove_conn_xrefs to cti_remove since all sysfs links
    have gone when system calls device_release.

    Reviewed-by Mike Leach

    Tested-by: Mike Leach
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-22-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • CTI device is enabled when associated coresight device is enabled.
    Increase the module and device reference count for CTI device
    when it's enabled. This can prevent CTI device be removed or
    module be unloaded when CTI device is enabled by an active trace
    session.

    Signed-off-by: Mike Leach
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-21-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • If associated ect device is not enabled at first place, disable
    routine should not be called. Add ect_enabled flag to check whether
    ect device is enabled. Fix the issue in below case. Ect device is
    not available when associated coresight device enabled and the
    association is established after coresight device is enabled.

    Signed-off-by: Mike Leach
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-20-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • During module unload, a coresight driver module will call back into
    the CTI driver to remove any links between the two devices.

    The current code has 2 issues:-
    1) in the CTI driver the matching code is matching to the wrong device
    so misses all the links.
    2) The callback is called too late in the unload process resulting in a
    crash.

    This fixes both the issues.

    Fixes: 177af8285b59 ("coresight: cti: Enable CTI associated with devices")
    Reported-by: Tingwei Zhang
    Acked-by: Suzuki K Poulose
    Signed-off-by: Mike Leach
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-19-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Mike Leach
     
  • CTI code to remove sysfs link to other devices on shutdown, incorrectly
    tries to remove a single ended link when these are all double ended. This
    implementation leaves elements in the link info structure undefined which
    results in a crash in recent tests for driver module unload.

    This patch corrects the link removal code.

    Fixes: 73274abb6557 ("coresight: cti: Add in sysfs links to other coresight devices")
    Reported-by: Tingwei Zhang
    Signed-off-by: Mike Leach
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-18-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Mike Leach
     
  • Add static cti_assoc_ops to coresight core driver. Let cti
    driver register the add_assoc and remove_assoc call back.
    Avoid coresight core driver to depend on cti driver.

    Tested-by: Mike Leach
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-17-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • Allow to build coresight-replicator as modules, for ease of development.

    - Kconfig becomes a tristate, to allow =m
    - combine static and dynamic replicator init into single
    module_init/exit call
    - add replicator_remove functions, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Co-developed-by: Mian Yousaf Kaukab
    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Kim Phillips
    Signed-off-by: Mian Yousaf Kaukab
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-16-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Kim Phillips
     
  • Allow to build coresight-funnel as module, for ease of development.

    - combine static and dynamic funnel init into single
    module_init/exit call
    - add funnel_remove functions, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Co-developed-by: Mian Yousaf Kaukab
    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Mian Yousaf Kaukab
    Signed-off-by: Kim Phillips
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-15-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Kim Phillips
     
  • Allow to build coresight-tmc as a module, for ease of development.

    - Kconfig becomes a tristate, to allow =m
    - append -core to source file name to allow module to
    be called coresight-tmc by the Makefile
    - add an tmc_remove function, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Kim Phillips
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-14-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Kim Phillips
     
  • Allow to build coresight-tpiu as a module, for ease of development.

    - Kconfig becomes a tristate, to allow =m
    - add a tpiu_remove function, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Reviewed-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Kim Phillips
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-13-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Kim Phillips
     
  • Allow to build coresight-etb10 as a module, for ease of development.

    - Kconfig becomes a tristate, to allow =m
    - add an etb_remove function, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Kim Phillips
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-12-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Kim Phillips
     
  • Allow to build coresight-etm4x as a module, for ease of development.

    - Kconfig becomes a tristate, to allow =m
    - append -core to source file name to allow module to
    be called coresight-etm4x by the Makefile
    - add an etm4_remove function, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot
    - delay advertising the per-cpu etmdrvdata
    - protect etmdrvdata[] by modifying it on relevant CPU

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Kim Phillips
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-11-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Kim Phillips
     
  • Allow to build coresight-etm3x as a module, for ease of development.

    - Kconfig becomes a tristate, to allow =m
    - append -core to source file name to allow module to
    be called coresight-etm3x by the Makefile
    - add an etm_remove function, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot
    - delay advertising the per-cpu etmdrvdata
    - protect etmdrvdata[] by modifying it on relevant CPU

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Reviewed-by: Mike Leach
    Signed-off-by: Kim Phillips
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-10-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Kim Phillips
     
  • When coresight_build_path() fails on all the cpus, etm_setup_aux
    calls etm_free_aux() to free allocated event_data.
    WARN_ON(cpumask_empty(mask) will be triggered since cpu mask is empty.
    Check event_data->snk_config is not NULL first to avoid this
    warning.

    Fixes: f5200aa9831f38 ("coresight: perf: Refactor function free_event_data()")
    Reviewed-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-9-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • - Kconfig becomes a tristate, to allow =m
    - add a stm_remove function, for module unload
    - add a MODULE_DEVICE_TABLE for autoloading on boot

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Kim Phillips
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-8-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • When coresight device is in an active session, driver module of
    that device should not be removed. Use try_get_module() in
    coresight_grab_device() to prevent module to be unloaded.
    Use get_device()/put_device() to protect device data
    in the middle of active session.

    Suggested-by: Suzuki K Poulose
    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-7-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • Export symbols used among coresight modules.

    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Mian Yousaf Kaukab
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-6-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Mian Yousaf Kaukab
     
  • Add coresight prefix to make it specific. It will be a export symbol.

    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Mian Yousaf Kaukab
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-5-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • Checking for ifdef CONFIG_x fails if CONFIG_x=m. Use IS_ENABLED
    that is true for both built-ins and modules, instead. Required
    when building coresight components as modules.

    Cc: Mathieu Poirier
    Cc: Leo Yan
    Cc: Alexander Shishkin
    Cc: Randy Dunlap
    Cc: Suzuki K Poulose
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Kim Phillips
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-4-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Kim Phillips
     
  • Define a MODULE_DEVICE_TABLE for cpu_debug so module can
    be auto loaded on boot.

    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-3-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • Provide name of cpu_debug module in Kconfig help section.

    Tested-by: Mike Leach
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200928163513.70169-2-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     

18 Sep, 2020

7 commits

  • The initialisation code checks TRCIDR4 to determine the number of resource
    selectors available on the system. Since ETM v 4.3, the value 0 has a
    different meaning. This patch takes into account this change.

    Signed-off-by: Mike Leach
    [Removed '.' in patch title, added stable]
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200916191737.4001561-17-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Mike Leach
     
  • The member @nr_resource represents how many resource selector pairs,
    and the pair 0 is always implemented and reserved.
    So let's multiply by 2 when resetting the selector configuration.
    And also update the validation of the input @idx.

    Cc: Mathieu Poirier
    Cc: Suzuki K Poulose
    Cc: Mike Leach
    Cc: Shaokun Zhang
    Signed-off-by: Jonathan Zhou
    [Fixed typographical error in changelog, added stable]
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200916191737.4001561-16-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Jonathan Zhou
     
  • Coresight driver assumes sink is common across all the ETMs,
    and tries to build a path between ETM and the first enabled
    sink found using bus based search. This breaks sysFS usage
    on implementations that has multiple per core sinks in
    enabled state.

    To fix this, coresight_get_enabled_sink API is updated to
    do a connection based search starting from the given source,
    instead of bus based search.
    With sink selection using sysfs depecrated for perf interface,
    provision for reset is removed as well in this API.

    Signed-off-by: Linu Cherian
    [Fixed indentation problem and removed obsolete comment]
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200916191737.4001561-15-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linu Cherian
     
  • When using the perf interface, sink selection using sysfs is
    deprecated.

    Signed-off-by: Linu Cherian
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200916191737.4001561-14-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linu Cherian
     
  • The TRCSEQEVR(3) is reserved, using '@nrseqstate - 1' instead to avoid
    accessing the reserved register.

    Fixes: f188b5e76aae ("coresight: etm4x: Save/restore state across CPU low power states")
    Cc: Mathieu Poirier
    Cc: Suzuki K Poulose
    Cc: Mike Leach
    Cc: Shaokun Zhang
    Signed-off-by: Jonathan Zhou
    [Fixed capital letter in title]
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200916191737.4001561-12-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Jonathan Zhou
     
  • If the specified/hinted sink is not reachable from a subset of the CPUs,
    we could end up unable to trace the event on those CPUs. This
    is the best effort we could do until we support 1:1 configurations.
    Fail gracefully in such cases avoiding a WARN_ON, which can be easily
    triggered by the user on certain platforms (Arm N1SDP), with the following
    trace paths :

    CPU0
    \
    -- Funnel0 --> ETF0 -->
    / \
    CPU1 \
    MainFunnel
    CPU2 /
    \ /
    -- Funnel1 --> ETF1 -->
    /
    CPU1

    $ perf record --per-thread -e cs_etm/@ETF0/u --

    could trigger the following WARNING, when the event is scheduled
    on CPU2.

    [10919.513250] ------------[ cut here ]------------
    [10919.517861] WARNING: CPU: 2 PID: 24021 at
    drivers/hwtracing/coresight/coresight-etm-perf.c:316 etm_event_start+0xf8/0x100
    ...

    [10919.564403] CPU: 2 PID: 24021 Comm: perf Not tainted 5.8.0+ #24
    [10919.570308] pstate: 80400089 (Nzcv daIf +PAN -UAO BTYPE=--)
    [10919.575865] pc : etm_event_start+0xf8/0x100
    [10919.580034] lr : etm_event_start+0x80/0x100
    [10919.584202] sp : fffffe001932f940
    [10919.587502] x29: fffffe001932f940 x28: fffffc834995f800
    [10919.592799] x27: 0000000000000000 x26: fffffe0011f3ced0
    [10919.598095] x25: fffffc837fce244c x24: fffffc837fce2448
    [10919.603391] x23: 0000000000000002 x22: fffffc8353529c00
    [10919.608688] x21: fffffc835bb31000 x20: 0000000000000000
    [10919.613984] x19: fffffc837fcdcc70 x18: 0000000000000000
    [10919.619281] x17: 0000000000000000 x16: 0000000000000000
    [10919.624577] x15: 0000000000000000 x14: 00000000000009f8
    [10919.629874] x13: 00000000000009f8 x12: 0000000000000018
    [10919.635170] x11: 0000000000000000 x10: 0000000000000000
    [10919.640467] x9 : fffffe00108cd168 x8 : 0000000000000000
    [10919.645763] x7 : 0000000000000020 x6 : 0000000000000001
    [10919.651059] x5 : 0000000000000002 x4 : 0000000000000001
    [10919.656356] x3 : 0000000000000000 x2 : 0000000000000000
    [10919.661652] x1 : fffffe836eb40000 x0 : 0000000000000000
    [10919.666949] Call trace:
    [10919.669382] etm_event_start+0xf8/0x100
    [10919.673203] etm_event_add+0x40/0x60
    [10919.676765] event_sched_in.isra.134+0xcc/0x210
    [10919.681281] merge_sched_in+0xb0/0x2a8
    [10919.685017] visit_groups_merge.constprop.140+0x15c/0x4b8
    [10919.690400] ctx_sched_in+0x15c/0x170
    [10919.694048] perf_event_sched_in+0x6c/0xa0
    [10919.698130] ctx_resched+0x60/0xa0
    [10919.701517] perf_event_exec+0x288/0x2f0
    [10919.705425] begin_new_exec+0x4c8/0xf58
    [10919.709247] load_elf_binary+0x66c/0xf30
    [10919.713155] exec_binprm+0x15c/0x450
    [10919.716716] __do_execve_file+0x508/0x748
    [10919.720711] __arm64_sys_execve+0x40/0x50
    [10919.724707] do_el0_svc+0xf4/0x1b8
    [10919.728095] el0_sync_handler+0xf8/0x124
    [10919.732003] el0_sync+0x140/0x180

    Even though we don't support using separate sinks for the ETMs yet (e.g,
    for 1:1 configurations), we should at least honor the user's choice and
    handle the limitations gracefully, by simply skipping the tracing on ETMs
    which can't reach the requested sink.

    Fixes: f9d81a657bb8 ("coresight: perf: Allow tracing on hotplugged CPUs")
    Cc: Mathieu Poirier
    Cc: Mike Leach
    Reported-by: Jeremy Linton
    Tested-by: Jeremy Linton
    Signed-off-by: Suzuki K Poulose
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200916191737.4001561-11-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     
  • 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: 6a0953ce7de9 ("coresight: cti: Add CPU idle pm notifer to CTI devices")
    Signed-off-by: Tingwei Zhang
    [Re-ordered variable declaration]
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20200916191737.4001561-10-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang