Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 32157725 authored by Yabin Cui's avatar Yabin Cui
Browse files

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
455328b1772a190e27fe7ef3a2416dfee6234317.
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: a06ae860 ("coresight: add CoreSight core layer framework")
Signed-off-by: default avatarYabin Cui <yabinc@google.com>
Signed-off-by: default avatarMathieu 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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>

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


 char-misc-next)

Bug: 140266694
Change-Id: I59a1a36c3e4771a57910f6f437fd2ce5f3cfab6e
Signed-off-by: default avatarYabin Cui <yabinc@google.com>
parent 685792cb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment