Commit Graph

793113 Commits

Author SHA1 Message Date
Yabin Cui
321577251c BACKPORT:FROMGIT: coresight: Serialize enabling/disabling a link device.
Backport: coresight-dynamic-replicator.c and coresight-replicator.c has
been merged upstream into coresight-replicator.c, in commit
455328b177.
So backport the change to both of the files.

When tracing etm data of multiple threads on multiple cpus through perf
interface, some link devices are shared between paths of different cpus.
It creates race conditions when different cpus wants to enable/disable
the same link device at the same time.

Example 1:
Two cpus want to enable different ports of a coresight funnel, thus
calling the funnel enable operation at the same time. But the funnel
enable operation isn't reentrantable.

Example 2:
For an enabled coresight dynamic replicator with refcnt=1, one cpu wants
to disable it, while another cpu wants to enable it. Ideally we still have
an enabled replicator with refcnt=1 at the end. But in reality the result
is uncertain.

Since coresight devices claim themselves when enabled for self-hosted
usage, the race conditions above usually make the link devices not usable
after many cycles.

To fix the race conditions, this patch uses spinlocks to serialize
enabling/disabling link devices.

Fixes: a06ae8609b ("coresight: add CoreSight core layer framework")
Signed-off-by: Yabin Cui <yabinc@google.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: stable <stable@vger.kernel.org> # 5.3
Link: https://lore.kernel.org/r/20191104181251.26732-14-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry picked from commit edda32dabe
 git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 char-misc-next)

Bug: 140266694
Change-Id: I59a1a36c3e4771a57910f6f437fd2ce5f3cfab6e
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-07 16:21:21 -08:00
Mathieu Poirier
685792cbaa UPSTREAM: coresight: tmc-etr: Add barrier packets when moving offset forward
(Upstream commit ec13c78d7b).

This patch adds barrier packets in the trace stream when the offset in the
data buffer needs to be moved forward.  Otherwise the decoder isn't aware
of the break in the stream and can't synchronise itself with the trace
data.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Yabin Cui <yabinc@google.com>
Reviewed-by: Leo Yan <leo.yan@linaro.org>
Link: https://lore.kernel.org/r/20190829202842.580-18-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I3d89e6267d8ca2397391ded7647cc379cd90d8d0
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-07 14:58:45 -08:00
Mathieu Poirier
319acdbf1d UPSTREAM: coresight: tmc-etr: Decouple buffer sync and barrier packet insertion
(Upstream commit 3507d231a4).

If less space is available in the perf ring buffer than the ETR buffer,
barrier packets inserted in the trace stream by tmc_sync_etr_buf() are
skipped over when the head of the buffer is moved forward, resulting in
traces that can't be decoded.

This patch decouples the process of syncing ETR buffers and the addition
of barrier packets in order to perform the latter once the offset in the
trace buffer has been properly computed.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Leo Yan <leo.yan@linaro.org>
Link: https://lore.kernel.org/r/20190829202842.580-17-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I2ecf6cdb2cde8180adc4ccd06e7916c89416c629
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-07 14:58:45 -08:00
Mathieu Poirier
91aa752e9c UPSTREAM: coresight: tmc: Make memory width mask computation into a function
(Upstream commit 00bb485ce7).

Make the computation of a memory mask representing the width of the memory
bus into a function so that it can be re-used by the ETR driver.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Leo Yan <leo.yan@linaro.org>
Link: https://lore.kernel.org/r/20190829202842.580-16-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I99aff4c3c8c8daedbaf83934805318000db68e5c
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-07 14:58:45 -08:00
Yabin Cui
935e04e485 UPSTREAM: coresight: tmc-etr: Fix perf_data check
(Upstream commit bbedcb91cc).

When tracing etm data of multiple threads on multiple cpus through
perf interface, each cpu has a unique etr_perf_buffer while sharing
the same etr device. There is no guarantee that the last cpu starts
etm tracing also stops last. This makes perf_data check fail.

Fix it by checking etr_buf instead of etr_perf_buffer.
Also move the code setting and clearing perf_buf to more suitable
places.

Fixes: 3147da92a8 ("coresight: tmc-etr: Allocate and free ETR memory buffers for CPU-wide scenarios")
Signed-off-by: Yabin Cui <yabinc@google.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20190829202842.580-15-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I609f3349492fb287387e320dc7b3de1aa50bf5e6
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-07 14:58:45 -08:00
Yabin Cui
c3595fdc72 UPSTREAM: coresight: tmc-etr: Fix updating buffer in not-snapshot mode.
(Upstream commit 13af88f312).

TMC etr always copies all available data to perf aux buffer, which
may exceed the available space in perf aux buffer. It isn't suitable
for not-snapshot mode, because:
1) It may overwrite previously written data.
2) It may make the perf_event_mmap_page->aux_head report having more
or less data than the reality.

So change to only copy the latest data fitting the available space in
perf aux buffer.

Signed-off-by: Yabin Cui <yabinc@google.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20190829202842.580-14-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Idcdd505c77637d0dc3329a1d145ddca20ca895da
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-07 14:58:45 -08:00
Suzuki K Poulose
f071d3702c UPSTREAM: coresight: tmc-etr: Check if non-secure access is enabled
(Upstream commit 8a4bc4f195).

CoreSight TMC-ETR must have the non-secure invasive debug access
enabled for use by self-hosted tracing. Without it, there is no
point in enabling the ETR. So, let us check it in the TMC_AUTHSTATUS
register and fail the probe if it is disabled.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20190829202842.580-7-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I6f72e88ccf4175bfebb0e237bca63ec59ccc35f8
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:04 -08:00
Suzuki K Poulose
c24fff6d66 UPSTREAM: coresight: tmc-etr: Handle memory errors
(Upstream commit f52ff9b7d6).

We have so far ignored the memory errors, assuming that we have perfect
hardware and driver. Let us handle the memory errors reported by the
TMC ETR in status and truncate the buffer.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
[Removed ASCII smiley face from changelog]
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20190829202842.580-6-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I601b80ac95d1ce524506255d06bed7bafa21a83f
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:04 -08:00
Suzuki K Poulose
ea6e516f2a BACKPORT: coresight: etr_buf: Consolidate refcount initialization
Backport: dev_dbg() in context code is different from upstream.

(Upstream commit 5774a34fc8).

We now use refcounts for the etr_buf users. Let us initialize it
while we allocate it.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20190829202842.580-5-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I05801ffd675b1b9996e7c0e624828eb46f6bebcf
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:04 -08:00
Suzuki K Poulose
5cc6b6ffab UPSTREAM: coresight: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute
(Upstream commit 5511c0c309).

While running the linux-next with CONFIG_DEBUG_LOCKS_ALLOC enabled,
I get the following splat.

BUG: key ffffcb5636929298 has not been registered!
------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(1)
WARNING: CPU: 1 PID: 53 at kernel/locking/lockdep.c:3669 lockdep_init_map+0x164/0x1f0
CPU: 1 PID: 53 Comm: kworker/1:1 Tainted: G        W         5.2.0-next-20190712-00015-g00ad4634222e-dirty #603
Workqueue: events amba_deferred_retry_func
pstate: 60c00005 (nZCv daif +PAN +UAO)
pc : lockdep_init_map+0x164/0x1f0
lr : lockdep_init_map+0x164/0x1f0

[ trimmed ]

Call trace:
lockdep_init_map+0x164/0x1f0
__kernfs_create_file+0x9c/0x158
sysfs_add_file_mode_ns+0xa8/0x1d0
sysfs_add_file_to_group+0x88/0xd8
etm_perf_add_symlink_sink+0xcc/0x138
coresight_register+0x110/0x280
tmc_probe+0x160/0x420

[ trimmed ]

---[ end trace ab4cc669615ba1b0 ]---

Fix this by initialising the dynamically allocated attribute properly.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Fixes: bb8e370bdc ("coresight: perf: Add "sinks" group to PMU directory")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
[Fixed a typograhic error in the changelog]
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20190801172323.18359-2-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Ida7a22d65313791d1b36d14bfaf3ae7a2d9e8e97
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:04 -08:00
Mathieu Poirier
9814e4dfde UPSTREAM: coresight: Use coresight device names for sinks in PMU attribute
(Upstream commit 6887cfa075).

Move to using the coresight device name instead of the parent
device name for SINK attribute for PMU.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Ied117c17cd4ef9f0ebe6826689e73d2479a2cab0
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:04 -08:00
Suzuki K Poulose
2e9ed22ec8 UPSTREAM: coresight: tmc-etr: alloc_perf_buf: Do not call smp_processor_id from preemptible
(Upstream commit 3a8710392d).

During a perf session we try to allocate buffers on the "node" associated
with the CPU the event is bound to. If it is not bound to a CPU, we
use the current CPU node, using smp_processor_id(). However this is unsafe
in a pre-emptible context and could generate the splats as below :

BUG: using smp_processor_id() in preemptible [00000000] code: perf/1743
caller is tmc_alloc_etr_buffer+0x1bc/0x1f0
CPU: 1 PID: 1743 Comm: perf Not tainted 5.1.0-rc6-147786-g116841e #344
Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Feb  1 2019
Call trace:
dump_backtrace+0x0/0x150
show_stack+0x14/0x20
dump_stack+0x9c/0xc4
debug_smp_processor_id+0x10c/0x110
tmc_alloc_etr_buffer+0x1bc/0x1f0
etm_setup_aux+0x1c4/0x230
rb_alloc_aux+0x1b8/0x2b8
perf_mmap+0x35c/0x478
mmap_region+0x34c/0x4f0
do_mmap+0x2d8/0x418
vm_mmap_pgoff+0xd0/0xf8
ksys_mmap_pgoff+0x88/0xf8
__arm64_sys_mmap+0x28/0x38
el0_svc_handler+0xd8/0x138
el0_svc+0x8/0xc

Use NUMA_NO_NODE hint instead of using the current node for events
not bound to CPUs.

Fixes: 22f429f19c ("coresight: etm-perf: Add support for ETR backend")
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: stable <stable@vger.kernel.org> # 4.20+
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20190620221237.3536-3-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I6c5a7343a38ce870bd89d596dddcdfcf8af9ebf8
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:04 -08:00
Suzuki K Poulose
d004072d1a UPSTREAM: coresight: tmc-etr: Do not call smp_processor_id() from preemptible
(Upstream commit 3ff44563db).

During a perf session we try to allocate buffers on the "node" associated
with the CPU the event is bound to. If it's not bound to a CPU, we use
the current CPU node, using smp_processor_id(). However this is unsafe
in a pre-emptible context and could generate the splats as below :

BUG: using smp_processor_id() in preemptible [00000000] code: perf/1743
caller is alloc_etr_buf.isra.6+0x80/0xa0
CPU: 1 PID: 1743 Comm: perf Not tainted 5.1.0-rc6-147786-g116841e #344
Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Feb  1 2019
Call trace:
dump_backtrace+0x0/0x150
show_stack+0x14/0x20
dump_stack+0x9c/0xc4
debug_smp_processor_id+0x10c/0x110
alloc_etr_buf.isra.6+0x80/0xa0
tmc_alloc_etr_buffer+0x12c/0x1f0
etm_setup_aux+0x1c4/0x230
rb_alloc_aux+0x1b8/0x2b8
perf_mmap+0x35c/0x478
mmap_region+0x34c/0x4f0
do_mmap+0x2d8/0x418
vm_mmap_pgoff+0xd0/0xf8
ksys_mmap_pgoff+0x88/0xf8
__arm64_sys_mmap+0x28/0x38
el0_svc_handler+0xd8/0x138
el0_svc+0x8/0xc

Use NUMA_NO_NODE hint instead of using the current node for events
not bound to CPUs.

Fixes: 855ab61c16 ("coresight: tmc-etr: Refactor function tmc_etr_setup_perf_buf()")
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20190620221237.3536-2-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Iddcfbe2d5415659e88a1dffc1ce6ab67078b466b
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:04 -08:00
Mathieu Poirier
a656047aed UPSTREAM: coresight: perf: Don't set the truncated flag in snapshot mode
(Upstream commit 5aafd9bf7a).

This patch avoids setting the truncated flag when operating in snapshot
mode since the trace buffer is expected to be truncated and discontinuous
from one snapshot to another.  Moreover when the truncated flag is set
the perf core stops enabling the event, waiting for user space to consume
the data.  In snapshot mode this is clearly not what we want since it
results in stale data.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I3b92c2c023e0af47f1e0d3743e8feb23e5cff212
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:04 -08:00
Mathieu Poirier
c419f1d2c8 UPSTREAM: coresight: tmc-etf: Fix snapshot mode update function
(Upstream commit 99f81eb9c5).

When working in snapshot mode function perf_aux_output_begin()
does not set the handle->size because the size is expected to be
deduced by the placement of the "head" and "old" pointers in user
space.  As such there is no point in trying to adjust the amount
of data to copy to the ring buffer.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I58ca0bb839b3da1d337517c1f5c00583deac4245
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:04 -08:00
Mathieu Poirier
77abd79a4a UPSTREAM: coresight: tmc-etr: Properly set AUX buffer head in snapshot mode
(Upstream commit 3ecb03022a).

Unify amongst sink drivers how the AUX ring buffer head is communicated
to user space.  That way the same algorithm in user space can be used to
determine where the latest data is and how much of it to access.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I2a76f700070b5748493157c895989bddb14eb2ad
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
0fefe3cd1d UPSTREAM: coresight: tmc-etr: Add support for CPU-wide trace scenarios
(Upstream commit 8d03cfd16a).

This patch adds support for CPU-wide trace scenarios by making sure that
only the sources monitoring the same process have access to a common sink.
Because the sink is shared between sources, the first source to use the
sink switches it on while the last one does the cleanup.  Any attempt to
modify the HW is overlooked for as long as more than one source is using
a sink.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I7096e7b4d105953242b9eca0ed5b040fc8b1f3bc
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
fe96748596 UPSTREAM: coresight: tmc-etr: Allocate and free ETR memory buffers for CPU-wide scenarios
(Upstream commit 3147da92a8).

This patch uses the PID of the process being traced to allocate and free
ETR memory buffers for CPU-wide scenarios.  The implementation is tailored
to handle both N:1 and 1:1 source/sink HW topologies.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Iae6466c210bf811cde152ce1c6a55b6f002d0463
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
39e1830cfc UPSTREAM: coresight: tmc-etr: Introduce the notion of IDR to ETR devices
(Upstream commit c5ff734462).

In CPU-wide scenarios with an N:1 source/sink topology, sources share
the same sink.  In order to reuse the same sink for all sources an
IDR is needed to archive events that have already been accounted for.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I09fb662438059a858e4208cbb065bee3b1181d94
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
e6bc81eab3 UPSTREAM: coresight: tmc-etr: Introduce the notion of reference counting to ETR devices
(Upstream commit 57549999b9).

This patch adds reference counting to struct etr_buf so that, in CPU-wide
trace scenarios, shared buffers can be disposed of when no longer used.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Iafb13f87406b27ac592b79f09ee69e542d014b48
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
55df09d490 UPSTREAM: coresight: tmc-etr: Introduce the notion of process ID to ETR devices
(Upstream commit ef848e463a).

In preparation to support CPU-wide trace scenarios, introduce the notion
of process ID to ETR devices.  That way events monitoring the same process
can use the same etr_buf, allowing multiple CPUs to use the same sink.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Ifed721da1237126c7196ccfd25477aa843bb8760
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
d8b599598b UPSTREAM: coresight: tmc-etr: Create per-thread buffer allocation function
(Upstream commit e553a8aef4).

Buffer allocation is different when dealing with per-thread and
CPU-wide sessions.  In preparation to support CPU-wide trace scenarios
simplify things by keeping allocation functions for both type separate.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I179e4886236b0b91ae6a03d2d8cf1275814ed5ea
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
9cb983e9e8 UPSTREAM: coresight: tmc-etr: Refactor function tmc_etr_setup_perf_buf()
(Upstream commit 855ab61c16).

Refactoring function tmc_etr_setup_perf_buf() so that it only deals
with the high level etr_perf_buffer, leaving the allocation of the
backend buffer (i.e etr_buf) to another function.

That way the backend buffer allocation function can decide if it wants
to reuse an existing buffer (CPU-wide trace scenarios) or simply create
a new one.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Ib95330a4905fbe3fc1eb3cb3c25e2f4648ba02c8
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
d8a82c60dc UPSTREAM: coresight: Communicate perf event to sink buffer allocation functions
(Upstream commit a0f08a6a9f).

Make struct perf_event available to sink buffer allocation functions in
order to use the pid they carry to allocate and free buffer memory along
with regimenting access to what source a sink can collect data for.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I977c7ccfb5d02946bc177409191d1ab4e86e41dc
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
76e72557eb UPSTREAM: coresight: perf: Refactor function free_event_data()
(Upstream commit f5200aa983).

Function free_event_data() is already busy and is bound to become
worse with the addition of CPU-wide trace scenarios.  As such spin
off a new function to strickly take care of the sink buffers.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I7ed7be5f783cb9814ab3e0d760ca3501e53dbd3d
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
f9da6dd8cb UPSTREAM: coresight: perf: Clean up function etm_setup_aux()
(Upstream commit 02d5c897a0).

There is no point in allocating sink memory for a trace session if
there is not a way to free it once it is no longer needed.  As such make
sure the sink API function to allocate and free memory have been
implemented before moving ahead with the establishment of a trace
session.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Ibfb1d9f2c47e4fb47091b2d9f2ca4c43acb4eb27
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
0efc646aa8 UPSTREAM: coresight: Properly address concurrency in sink::update() functions
(Upstream commit 0916447c87).

When operating in CPU-wide trace scenarios and working with an N:1
source/sink HW topology, update() functions need to be made atomic
in order to avoid racing with start and stop operations.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: If16c146cc4721acc005c7db3d88e57d38fe48ece
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
14b9467147 UPSTREAM: coresight: Properly address errors in sink::disable() functions
(Upstream commit 12dfc9e022).

When disabling a sink the reference counter ensures the operation goes
through if nobody else is using it.  As such if drvdata::mode is already
set do CS_MODE_DISABLED, it is an error and should be reported as such.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I541bfb6a7ae067b5327b8e76f700155f31b942ba
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
22611bfef6 UPSTREAM: coresight: Move reference counting inside sink drivers
(Upstream commit f973d88b75).

When operating in CPU-wide mode with an N:1 source/sink HW topology,
multiple CPUs can access a sink concurrently.  As such reference counting
needs to happen when the device's spinlock is held to avoid racing with
other operations (start(), update(), stop()), such as:

session A                               Session B
-----                                   -------

enable_sink
atomic_inc(refcount)  = 1

...

atomic_dec(refcount) = 0                enable_sink
if (refcount == 0) disable_sink
atomic_inc()

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Ia8dd776ddfb0576e62e44c556490b61defd4724c
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
7fb9382987 UPSTREAM: coresight: Adding return code to sink::disable() operation
(Upstream commit 6c817a95d8).

In preparation to handle device reference counting inside of the sink
drivers, add a return code to the sink::disable() operation so that
proper action can be taken if a sink has not been disabled.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I85b7b561b9ebd53dab55ba730af16209f4302e8e
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
3d4d5bb728 UPSTREAM: coresight: etm4x: Configure tracers to emit timestamps
(Upstream commit a54e14f810).

Configure timestamps to be emitted at regular intervals in the trace
stream to temporally correlate instructions executed on different CPUs.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Ic246074d6f89e8b3bab25d559ccfdee99c1fdc69
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:03 -08:00
Mathieu Poirier
3e93855282 UPSTREAM: coresight: etm4x: Skip selector pair 0
(Upstream commit 8013f32a1b).

Resource selector pair 0 is always implemented and reserved.  As such
it should not be explicitly programmed.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I1cb310ecc59adf849980c5cb757e8f8032f5ba35
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Mathieu Poirier
5351ad941a UPSTREAM: coresight: etm4x: Add kernel configuration for CONTEXTID
(Upstream commit 82500a810e).

Set the proper bit in the configuration register when contextID tracing
has been requested by user space.  That way PE_CONTEXT elements are
generated by the tracers when a process is installed on a CPU.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I6a36134c7c162c9e4e8efa164b31b03e373e4dae
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Mathieu Poirier
36e1605dad UPSTREAM: coresight: pmu: Adding ITRACE property to cs_etm PMU
(Upstream commit 6fcdba33ab).

Add to the capabilities the ITRACE property so that ITRACE START events
are generated when the PMU is switched on by the core.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I0531b3e2843eef4f5c594a65b699ec3988b2f4bc
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Suzuki K Poulose
cb8a9fac5e UPSTREAM: coresight: tmc: Cleanup power management
(Upstream commit 263556950f).

Drop the power only if we were successful in probing the device.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I2ee34b0d1a344255fe2d3250d5f8c0cf1ee71e2c
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Suzuki K Poulose
1e421be19d UPSTREAM: coresight: Fix freeing up the coresight connections
(Upstream commit 1b015ef28a).

With commit c2c729415b ("coresight: platform: Cleanup coresight
connection handling"), we switched to re-using coresight_connections
for the coresight_device. However, that introduced a mismatch in the
alloc/free of the connections. The allocation is made using devm_*,
while we use kfree() to release the memory when a device is released
(even though we don't support this at the moment). Fix this by leaving
it to the automatic freeing of the memory.

Fixes: c2c729415b ("coresight: platform: Cleanup coresight connection handling")
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: If5226ef45073cc1a450d3e98fc1f91f9ed86a2f4
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Suzuki K Poulose
3f2c1cc5e3 UPSTREAM: coresight: tmc: Report DMA setup failures
(Upstream commit 08be874775).

If we failed to setup the DMA mask for TMC-ETR, report the
error before failing the probe.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I4567bb57138de35f2b7383edc58a944cf9cc8098
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Arnd Bergmann
25a0dd6744 UPSTREAM: coresight: catu: fix clang build warning
(Upstream commit 59d63de076).

Clang points out a syntax error, as the etr_catu_buf_ops structure is
declared 'static' before the type is known:

In file included from drivers/hwtracing/coresight/coresight-tmc-etr.c:12:
drivers/hwtracing/coresight/coresight-catu.h:116:40: warning: tentative definition of variable with internal linkage has incomplete non-array type 'const struct etr_buf_operations' [-Wtentative-definition-incomplete-type]
static const struct etr_buf_operations etr_catu_buf_ops;
^
drivers/hwtracing/coresight/coresight-catu.h:116:21: note: forward declaration of 'struct etr_buf_operations'
static const struct etr_buf_operations etr_catu_buf_ops;

This seems worth fixing in the code, so replace pointer to the empty
constant structure with a NULL pointer. We need an extra NULL pointer
check here, but the result should be better object code otherwise,
avoiding the silly empty structure.

Fixes: 434d611cdd ("coresight: catu: Plug in CATU as a backend for ETR buffer")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
[Fixed line over 80 characters]
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I752f581e5e26c907d7ccb66669e3b582cf0502da
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Alexander Shishkin
bdc1e2cb66 UPSTREAM: perf/core: Fix the address filtering fix
(Upstream commit 52a44f83fc).

The following recent commit:

c60f83b813 ("perf, pt, coresight: Fix address filters for vmas with non-zero offset")

changes the address filtering logic to communicate filter ranges to the PMU driver
via a single address range object, instead of having the driver do the final bit of
math.

That change forgets to take into account kernel filters, which are not calculated
the same way as DSO based filters.

Fix that by passing the kernel filters the same way as file-based filters.
This doesn't require any additional changes in the drivers.

Reported-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Fixes: c60f83b813 ("perf, pt, coresight: Fix address filters for vmas with non-zero offset")
Link: https://lkml.kernel.org/r/20190329091212.29870-1-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Bug: 140266694
Change-Id: I28472be39c9ee0f1157b51014880fc66926a39e7
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Alexander Shishkin
93b9a8a987 UPSTREAM: perf, pt, coresight: Fix address filters for vmas with non-zero offset
(Upstream commit c60f83b813).

Currently, the address range calculation for file-based filters works as
long as the vma that maps the matching part of the object file starts
from offset zero into the file (vm_pgoff==0). Otherwise, the resulting
filter range would be off by vm_pgoff pages. Another related problem is
that in case of a partially matching vma, that is, a vma that matches
part of a filter region, the filter range size wouldn't be adjusted.

Fix the arithmetics around address filter range calculations, taking
into account vma offset, so that the entire calculation is done before
the filter configuration is passed to the PMU drivers instead of having
those drivers do the final bit of arithmetics.

Based on the patch by Adrian Hunter <adrian.hunter.intel.com>.

Reported-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Fixes: 375637bc52 ("perf/core: Introduce address range filtering")
Link: http://lkml.kernel.org/r/20190215115655.63469-3-alexander.shishkin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Bug: 140266694
Change-Id: I248219cff1573281196d455cf39d028b68ec17a7
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Alexander Shishkin
547690a5ac UPSTREAM: perf: Copy parent's address filter offsets on clone
(Upstream commit 18736eef12).

When a child event is allocated in the inherit_event() path, the VMA
based filter offsets are not copied from the parent, even though the
address space mapping of the new task remains the same, which leads to
no trace for the new task until exec.

Reported-by: Mansour Alharthi <malharthi9@gatech.edu>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Fixes: 375637bc52 ("perf/core: Introduce address range filtering")
Link: http://lkml.kernel.org/r/20190215115655.63469-2-alexander.shishkin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Bug: 140266694
Change-Id: I14af7095b0712ee6fc427eafc3d3486f0fc1b07c
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Mathieu Poirier
93b40c1d2e UPSTREAM: coresight: Use event attributes for sink selection
(Upstream commit b5390f4b5e).

This patch uses the information conveyed by perf_event::attr::config2
to select a sink to use for the session.  That way a sink can easily be
selected to be used by more than one source, something that isn't currently
possible with the sysfs implementation.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I417e932b72445fd304624e493429c1e785985f1d
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Mathieu Poirier
f60cc6bebb UPSTREAM: coresight: perf: Add "sinks" group to PMU directory
(Upstream commit 988036f9d3).

Add a "sinks" directory entry so that users can see all the sinks
available in the system in a single place.  Individual sink are added
as they are registered with the coresight bus.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I11a0cdefd7cb71ca7463d11e8ed7d792d90cee65
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Mathieu Poirier
3075152770 UPSTREAM: coresight: etb10: Add support for CLAIM tag
(Upstream commit acaf5a06b9).

Following in the footstep of what was done for other CoreSight devices,
add CLAIM tag support to ETB10 in order to synchronise access to the
HW between the kernel and an external agent.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I35e83a66af545abbc7ea5fa303c2086f687a1f76
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Suzuki K Poulose
cbb64784c0 UPSTREAM: coreisght: tmc: Claim device before use
(Upstream commit 4d3ebd3658).

Use CLAIM tags to make sure the device is available for use.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I3f3ea1037e956a2f6e8235494d73d9d76581749f
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Suzuki K Poulose
e718162c33 UPSTREAM: coresight: dynamic-replicator: Claim device for use
(Upstream commit 4e33d69437).

Use CLAIM protocol to make sure the device is available for use.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Iad04d371710f781287a530987b83e2c5317fd75d
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:02 -08:00
Suzuki K Poulose
289179cb38 UPSTREAM: coresight: funnel: Claim devices before use
(Upstream commit f13d7c0835).

Use the CLAIM protocol to grab the ownership of the component.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I9f5bf5e1502e03336c03db07f39ebc4379246eb3
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:01 -08:00
Suzuki K Poulose
a972dbe7fb UPSTREAM: coresight: etmx: Claim devices before use
(Upstream commit 68a147752d).

Use the CLAIM tags to grab the device for self-hosted usage.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: Ieb98a7a68560a94b4d74b62206d4b530eb2cb008
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:01 -08:00
Suzuki K Poulose
7757d73a7d UPSTREAM: coresight: Add support for CLAIM tag protocol
(Upstream commit 2478a6ae4a).

Coresight architecture defines CLAIM tags for a device to negotiate
control of the components (external agent vs self-hosted). Each device
has a pair of registers (CLAIMSET & CLAIMCLR) for managing the CLAIM
tags. However, the protocol for the CLAIM tags is IMPLEMENTATION DEFINED.
PSCI has recommendations for the use of the CLAIM tags to negotiate
controls for external agent vs self-hosted use. This patch implements
the recommended protocol by PSCI.

The claim/disclaim operations are performed from the device specific
drivers. The disadvantage is that the calls are sprinkled in each driver,
but this makes the operation much simpler.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I1956110ec9822cfd9ac279a0dcddcaf8b90b7f37
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:01 -08:00
Suzuki K Poulose
297602b19f UPSTREAM: coresight: dynamic-replicator: Handle multiple connections
(Upstream commit 30af4fb619).

When a replicator port is enabled, we block the traffic
on the other port and route all traffic to the new enabled
port. If there are two active trace sessions each targeting
the two different paths from the replicator, the second session
will disable the first session and route all the data to the
second path.
ETR
/
e.g, replicator
\
ETB

If CPU0 is operated in sysfs mode to ETR and CPU1 is operated
in perf mode to ETB, depending on the order in which the
replicator is enabled one device is blocked.

Ideally we need trace-id for the session to make the
right choice. That implies we need a trace-id allocation
logic for the coresight subsystem and use that to route
the traffic. The short term solution is to only manage
the "target port" and leave the other port untouched.
That leaves both the paths unaffected, except that some
unwanted traffic may be pushed to the paths (if the Trace-IDs
are not far enough), which is still fine and can be filtered
out while processing rather than silently blocking the data.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 140266694
Change-Id: I3804e95a76ad9b0d9d28ab0f0f36f090670d0da7
Signed-off-by: Yabin Cui <yabinc@google.com>
2019-11-06 14:05:01 -08:00