Merge "coresight: etr: Don't allocate the new buffer when etr is enabled"

This commit is contained in:
qctecmdr 2022-10-26 09:48:14 -07:00 committed by Gerrit - the friendly Code Review server
commit 6ab101b62e

View File

@ -1249,6 +1249,22 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
struct etr_buf *sysfs_buf = NULL, *new_buf = NULL, *free_buf = NULL;
spin_lock_irqsave(&drvdata->spinlock, flags);
if (drvdata->reading || drvdata->mode == CS_MODE_PERF) {
ret = -EBUSY;
goto unlock_out;
}
/*
* In sysFS mode we can have multiple writers per sink. Since this
* sink is already enabled no memory is needed and the HW need not be
* touched, even if the buffer size has changed.
*/
if (drvdata->mode == CS_MODE_SYSFS) {
atomic_inc(csdev->refcnt);
goto unlock_out;
}
/*
* If we are enabling the ETR from disabled state, we need to make
* sure we have a buffer with the right size. The etr_buf is not reset
@ -1257,7 +1273,6 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
* buffer, provided the size matches. Any allocation has to be done
* with the lock released.
*/
spin_lock_irqsave(&drvdata->spinlock, flags);
if ((drvdata->out_mode == TMC_ETR_OUT_MODE_MEM)
|| (drvdata->out_mode == TMC_ETR_OUT_MODE_USB &&
drvdata->usb_data->usb_mode ==
@ -1280,21 +1295,6 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
}
}
if (drvdata->reading || drvdata->mode == CS_MODE_PERF) {
ret = -EBUSY;
goto unlock_out;
}
/*
* In sysFS mode we can have multiple writers per sink. Since this
* sink is already enabled no memory is needed and the HW need not be
* touched, even if the buffer size has changed.
*/
if (drvdata->mode == CS_MODE_SYSFS) {
atomic_inc(csdev->refcnt);
goto unlock_out;
}
/*
* If we don't have a buffer or it doesn't match the requested size,
* use the buffer allocated above. Otherwise reuse the existing buffer.