30 Dec, 2020

1 commit

  • [ Upstream commit 45fe7befe0db5e61cd3c846315f0ac48541e8445 ]

    Functions that are annotated __exit are discarded for built-in drivers,
    but the .remove callback in a device driver must still be kept around
    to allow bind/unbind operations.

    There is now a linker warning for the discarded symbol references:

    `tmc_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-tmc-core.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-tmc-core.o
    `tpiu_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-tpiu.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-tpiu.o
    `etb_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-etb10.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-etb10.o
    `static_funnel_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-funnel.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-funnel.o
    `dynamic_funnel_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-funnel.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-funnel.o
    `static_replicator_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-replicator.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-replicator.o
    `dynamic_replicator_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-replicator.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-replicator.o
    `catu_remove' referenced in section `.data' of drivers/hwtracing/coresight/coresight-catu.o: defined in discarded section `.exit.text' of drivers/hwtracing/coresight/coresight-catu.o

    Remove all those annotations.

    Fixes: 8b0cf82677d1 ("coresight: stm: Allow to build coresight-stm as a module")
    Reviewed-by: Stephen Boyd
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201208182651.1597945-3-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Arnd Bergmann
     

26 Dec, 2020

9 commits

  • commit 60c519c5d3629c21ba356782434d5b612d312de4 upstream.

    TRCVIPCSSCTLR is not present if the TRCIDR4.NUMPC > 0. Thus we
    should only access the register if it is present, preventing
    any undesired behavior.

    Cc: stable@vger.kernel.org
    Signed-off-by: Suzuki K Poulose
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201127175256.1092685-8-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     
  • commit 6288b4ceca868eac4bf729532f8d845e3ecbed98 upstream.

    TRCPROCSELR is not implemented if the TRCIDR3.NUMPROC == 0. Skip
    accessing the register in such cases.

    Cc: stable@vger.kernel.org
    Cc: Mathieu Poirier
    Cc: Mike Leach
    Signed-off-by: Suzuki K Poulose
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201127175256.1092685-7-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     
  • commit f2603b22e3d2dcffd8b0736e5c68df497af6bc84 upstream.

    The TRCCIDCTLR1 is only implemented if TRCIDR4.NUMCIDC > 4.
    Don't touch the register if it is not implemented.

    Cc: stable@vger.kernel.org
    Cc: Mathieu Poirier
    Cc: Mike Leach
    Signed-off-by: Suzuki K Poulose
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201127175256.1092685-5-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     
  • commit 93dd64404cbe63b0afba371acd8db36e84b286c7 upstream.

    TRCVMIDCTRL1 is only implemented only if the TRCIDR4.NUMVMIDC > 4.
    We must not touch the register otherwise.

    Cc: stable@vger.kernel.org
    Cc: Mathieu Poirier
    Cc: Mike Leach
    Signed-off-by: Suzuki K Poulose
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201127175256.1092685-4-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     
  • commit ac0f82b1b4956e348a6b2de8104308144ffb6ef7 upstream.

    There is a bug on the systems supporting to skip power up
    (qcom,skip-power-up) where setting LPOVERRIDE bit(low-power
    state override behaviour) will result in CPU hangs/lockups
    even on the implementations which supports it. So skip
    setting the LPOVERRIDE bit for such platforms.

    Fixes: 02510a5aa78d ("coresight: etm4x: Add support to skip trace unit power up")
    Cc: stable@vger.kernel.org
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Sai Prakash Ranjan
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201127175256.1092685-2-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Sai Prakash Ranjan
     
  • commit 22b2beaa7f166f550424cbb3b988aeaa7ef0425a upstream.

    There was a report of NULL pointer dereference in ETF enable
    path for perf CS mode with PID monitoring. It is almost 100%
    reproducible when the process to monitor is something very
    active such as chrome and with ETF as the sink, not ETR.

    But code path shows that ETB has a similar path as ETF, so
    there could be possible NULL pointer dereference crash in
    ETB as well. Currently in a bid to find the pid, the owner
    is dereferenced via task_pid_nr() call in etb_enable_perf()
    and with owner being NULL, we can get a NULL pointer
    dereference, so have a similar fix as ETF where we cache PID
    in alloc_buffer() callback which is called as the part of
    etm_setup_aux().

    Fixes: 75d7dbd38824 ("coresight: etb10: Add support for CPU-wide trace scenarios")
    Cc: stable@vger.kernel.org
    Signed-off-by: Sai Prakash Ranjan
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201127175256.1092685-11-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Sai Prakash Ranjan
     
  • commit 83be0b84fe846edf0c722fefe225482d5f0d7395 upstream.

    When the ETR is used in perf mode with a larger buffer (configured
    via sysfs or the default size of 1M) than the perf aux buffer size,
    we end up inserting the barrier packet at the wrong offset, while
    moving the offset forward. i.e, instead of the "new moved offset",
    we insert it at the current hardware buffer offset. These packets
    will not be visible as they are never copied and could lead to
    corruption in the trace decoding side, as the decoder is not aware
    that it needs to reset the decoding.

    Fixes: ec13c78d7b45 ("coresight: tmc-etr: Add barrier packets when moving offset forward")
    Cc: Mathieu Poirier
    Cc: stable@vger.kernel.org
    Reported-by: Al Grant
    Tested-by: Mike Leach
    Signed-off-by: Suzuki K Poulose
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201208182651.1597945-2-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     
  • commit 1cc573d5754e92372a7e30e35468644f8811e1a4 upstream.

    alloc_pages_node() return should be checked before calling
    dma_map_page() to make sure that valid page is mapped or
    else it can lead to aborts as below:

    Unable to handle kernel paging request at virtual address ffffffc008000000
    Mem abort info:
    ...
    pc : __dma_inv_area+0x40/0x58
    lr : dma_direct_map_page+0xd8/0x1c8

    Call trace:
    __dma_inv_area
    tmc_pages_alloc
    tmc_alloc_data_pages
    tmc_alloc_sg_table
    tmc_init_etr_sg_table
    tmc_alloc_etr_buf
    tmc_enable_etr_sink_sysfs
    tmc_enable_etr_sink
    coresight_enable_path
    coresight_enable
    enable_source_store
    dev_attr_store
    sysfs_kf_write

    Fixes: 99443ea19e8b ("coresight: Add generic TMC sg table framework")
    Cc: stable@vger.kernel.org
    Reviewed-by: Suzuki K Poulose
    Signed-off-by: Mao Jinlong
    Signed-off-by: Sai Prakash Ranjan
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201127175256.1092685-13-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Mao Jinlong
     
  • commit 868663dd5d69fef05bfb004f91da5c30e9b93461 upstream.

    There was a report of NULL pointer dereference in ETF enable
    path for perf CS mode with PID monitoring. It is almost 100%
    reproducible when the process to monitor is something very
    active such as chrome and with ETF as the sink and not ETR.
    Currently in a bid to find the pid, the owner is dereferenced
    via task_pid_nr() call in tmc_enable_etf_sink_perf() and with
    owner being NULL, we get a NULL pointer dereference.

    Looking at the ETR and other places in the kernel, ETF and the
    ETB are the only places trying to dereference the task(owner)
    in tmc_enable_etf_sink_perf() which is also called from the
    sched_in path as in the call trace. Owner(task) is NULL even
    in the case of ETR in tmc_enable_etr_sink_perf(), but since we
    cache the PID in alloc_buffer() callback and it is done as part
    of etm_setup_aux() when allocating buffer for ETR sink, we never
    dereference this NULL pointer and we are safe. So lets do the
    same thing with ETF and cache the PID to which the cs_buffer
    belongs in tmc_alloc_etf_buffer() as done for ETR. This will
    also remove the unnecessary function calls(task_pid_nr()) since
    we are caching the PID.

    Easily reproducible running below:

    perf record -e cs_etm/@tmc_etf0/ -N -p

    Unable to handle kernel NULL pointer dereference at virtual address 0000000000000548
    Mem abort info:
    ESR = 0x96000006
    EC = 0x25: DABT (current EL), IL = 32 bits
    SET = 0, FnV = 0
    EA = 0, S1PTW = 0
    Data abort info:
    ISV = 0, ISS = 0x00000006
    CM = 0, WnR = 0
    ...
    Call trace:
    tmc_enable_etf_sink+0xe4/0x280
    coresight_enable_path+0x168/0x1fc
    etm_event_start+0x8c/0xf8
    etm_event_add+0x38/0x54
    event_sched_in+0x194/0x2ac
    group_sched_in+0x54/0x12c
    flexible_sched_in+0xd8/0x120
    visit_groups_merge+0x100/0x16c
    ctx_flexible_sched_in+0x50/0x74
    ctx_sched_in+0xa4/0xa8
    perf_event_sched_in+0x60/0x6c
    perf_event_context_sched_in+0x98/0xe0
    __perf_event_task_sched_in+0x5c/0xd8
    finish_task_switch+0x184/0x1cc
    schedule_tail+0x20/0xec
    ret_from_fork+0x4/0x18

    Fixes: 880af782c6e8 ("coresight: tmc-etf: Add support for CPU-wide trace scenarios")
    Cc: stable@vger.kernel.org
    Signed-off-by: Sai Prakash Ranjan
    Signed-off-by: Mathieu Poirier
    Link: https://lore.kernel.org/r/20201127175256.1092685-10-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Sai Prakash Ranjan
     

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

22 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