@@ -1178,7 +1178,11 @@ static struct etr_buf *tmc_etr_get_sysfs_buffer(struct coresight_device *csdev)
*/
spin_lock_irqsave(&drvdata->spinlock, flags);
sysfs_buf = READ_ONCE(drvdata->sysfs_buf);
- if (!sysfs_buf || (sysfs_buf->size != drvdata->size)) {
+
+ /* Don't reallocate the buffer if it's already in use */
+ if (!sysfs_buf ||
+ ((sysfs_buf->size != drvdata->size) &&
+ coresight_get_mode(csdev) != CS_MODE_SYSFS)) {
spin_unlock_irqrestore(&drvdata->spinlock, flags);
/* Allocate memory with the locks released */