@@ -519,7 +519,12 @@ static int etm_enable_sysfs(struct coresight_device *csdev)
struct etm_enable_arg arg = { };
int ret;
- spin_lock(&drvdata->spinlock);
+ cpus_read_lock();
+
+ if (cpu_is_offline(drvdata->cpu)) {
+ ret = -ENODEV;
+ goto unlock_sysfs_enable;
+ }
/* sysfs needs to allocate and set a trace ID */
ret = etm_read_alloc_trace_id(drvdata);
@@ -530,23 +535,19 @@ static int etm_enable_sysfs(struct coresight_device *csdev)
* Configure the ETM only if the CPU is online. If it isn't online
* hw configuration will take place on the local CPU during bring up.
*/
- if (cpu_online(drvdata->cpu)) {
- arg.drvdata = drvdata;
- ret = smp_call_function_single(drvdata->cpu,
- etm_enable_hw_smp_call, &arg, 1);
- if (!ret)
- ret = arg.rc;
- if (!ret)
- drvdata->sticky_enable = true;
- } else {
- ret = -ENODEV;
- }
+ arg.drvdata = drvdata;
+ ret = smp_call_function_single(drvdata->cpu,
+ etm_enable_hw_smp_call, &arg, 1);
+ if (!ret)
+ ret = arg.rc;
+ if (!ret)
+ drvdata->sticky_enable = true;
if (ret)
etm_release_trace_id(drvdata);
unlock_enable_sysfs:
- spin_unlock(&drvdata->spinlock);
+ cpus_read_unlock();
if (!ret)
dev_dbg(&csdev->dev, "ETM tracing enabled\n");
@@ -646,7 +647,6 @@ static void etm_disable_sysfs(struct coresight_device *csdev)
* DYING hotplug callback is serviced by the ETM driver.
*/
cpus_read_lock();
- spin_lock(&drvdata->spinlock);
/*
* Executing etm_disable_hw on the cpu whose ETM is being disabled
@@ -654,7 +654,6 @@ static void etm_disable_sysfs(struct coresight_device *csdev)
*/
smp_call_function_single(drvdata->cpu, etm_disable_hw, drvdata, 1);
- spin_unlock(&drvdata->spinlock);
cpus_read_unlock();
/*
@@ -722,7 +721,6 @@ static int etm_starting_cpu(unsigned int cpu)
if (!etmdrvdata[cpu])
return 0;
- spin_lock(&etmdrvdata[cpu]->spinlock);
if (!etmdrvdata[cpu]->os_unlock) {
etm_os_unlock(etmdrvdata[cpu]);
etmdrvdata[cpu]->os_unlock = true;
@@ -730,7 +728,6 @@ static int etm_starting_cpu(unsigned int cpu)
if (coresight_get_mode(etmdrvdata[cpu]->csdev))
etm_enable_hw(etmdrvdata[cpu]);
- spin_unlock(&etmdrvdata[cpu]->spinlock);
return 0;
}
@@ -739,10 +736,8 @@ static int etm_dying_cpu(unsigned int cpu)
if (!etmdrvdata[cpu])
return 0;
- spin_lock(&etmdrvdata[cpu]->spinlock);
if (coresight_get_mode(etmdrvdata[cpu]->csdev))
etm_disable_hw(etmdrvdata[cpu]);
- spin_unlock(&etmdrvdata[cpu]->spinlock);
return 0;
}
Remove redundant usage of drvdata->spinlock in etm_starting/dying_cpu() by preventing cpu hotplug while enabling etm3x via sysfs since - perf and sysfs enable method are serialized by csdev->mode - etm_starting/dying_cpu() aren't called concurrently with etm_enable_perf/sysfs() because they're called in cpu offline status. - while etm_enable_sysfs(), config isn't changed since csdev->mode is not DISABLED. Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com> --- .../coresight/coresight-etm3x-core.c | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-)