coresight: Fix issue where a source device's helpers aren't disabled
[ Upstream commit f68bbe4dcfa303164922bc331d2e8d38ed2d4f23 ] The linked commit reverts the change that accidentally used some sysfs enable/disable functions from Perf which broke the refcounting, but it also removes the fact that the sysfs disable function disabled the helpers. Add a new wrapper function that does both which is used by both Perf and sysfs, and label the sysfs disable function appropriately. The naming of all of the functions will be tidied up later to avoid this happening again. Fixes: 287e82cf69aa ("coresight: Fix crash when Perf and sysfs modes are used concurrently") Signed-off-by: James Clark <james.clark@arm.com> Link: https://lore.kernel.org/r/20240129154050.569566-2-james.clark@arm.com Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e23d162e4d
commit
b7bcc2c269
|
@ -441,8 +441,26 @@ static void coresight_disable_helpers(struct coresight_device *csdev)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to call source_ops(csdev)->disable and also disable the
|
||||
* helpers.
|
||||
*
|
||||
* There is an imbalance between coresight_enable_path() and
|
||||
* coresight_disable_path(). Enabling also enables the source's helpers as part
|
||||
* of the path, but disabling always skips the first item in the path (which is
|
||||
* the source), so sources and their helpers don't get disabled as part of that
|
||||
* function and we need the extra step here.
|
||||
*/
|
||||
void coresight_disable_source(struct coresight_device *csdev, void *data)
|
||||
{
|
||||
if (source_ops(csdev)->disable)
|
||||
source_ops(csdev)->disable(csdev, data);
|
||||
coresight_disable_helpers(csdev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(coresight_disable_source);
|
||||
|
||||
/**
|
||||
* coresight_disable_source - Drop the reference count by 1 and disable
|
||||
* coresight_disable_source_sysfs - Drop the reference count by 1 and disable
|
||||
* the device if there are no users left.
|
||||
*
|
||||
* @csdev: The coresight device to disable
|
||||
|
@ -451,17 +469,15 @@ static void coresight_disable_helpers(struct coresight_device *csdev)
|
|||
*
|
||||
* Returns true if the device has been disabled.
|
||||
*/
|
||||
bool coresight_disable_source(struct coresight_device *csdev, void *data)
|
||||
static bool coresight_disable_source_sysfs(struct coresight_device *csdev,
|
||||
void *data)
|
||||
{
|
||||
if (atomic_dec_return(&csdev->refcnt) == 0) {
|
||||
if (source_ops(csdev)->disable)
|
||||
source_ops(csdev)->disable(csdev, data);
|
||||
coresight_disable_helpers(csdev);
|
||||
coresight_disable_source(csdev, data);
|
||||
csdev->enable = false;
|
||||
}
|
||||
return !csdev->enable;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(coresight_disable_source);
|
||||
|
||||
/*
|
||||
* coresight_disable_path_from : Disable components in the given path beyond
|
||||
|
@ -1202,7 +1218,7 @@ void coresight_disable(struct coresight_device *csdev)
|
|||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (!csdev->enable || !coresight_disable_source(csdev, NULL))
|
||||
if (!csdev->enable || !coresight_disable_source_sysfs(csdev, NULL))
|
||||
goto out;
|
||||
|
||||
switch (csdev->subtype.source_subtype) {
|
||||
|
|
|
@ -587,7 +587,7 @@ static void etm_event_stop(struct perf_event *event, int mode)
|
|||
return;
|
||||
|
||||
/* stop tracer */
|
||||
source_ops(csdev)->disable(csdev, event);
|
||||
coresight_disable_source(csdev, event);
|
||||
|
||||
/* tell the core */
|
||||
event->hw.state = PERF_HES_STOPPED;
|
||||
|
|
|
@ -233,6 +233,6 @@ void coresight_set_percpu_sink(int cpu, struct coresight_device *csdev);
|
|||
struct coresight_device *coresight_get_percpu_sink(int cpu);
|
||||
int coresight_enable_source(struct coresight_device *csdev, enum cs_mode mode,
|
||||
void *data);
|
||||
bool coresight_disable_source(struct coresight_device *csdev, void *data);
|
||||
void coresight_disable_source(struct coresight_device *csdev, void *data);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue