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

Commit 4f8e6413 authored by Yuanfang Zhang's avatar Yuanfang Zhang
Browse files

coresight: byte-cntr: stop reading byte-cntr when etr is diasbled



Tmc etr buffer will be read when user runs 'cat /dev/byte-cntr'.
If tmc etr is disabled, the buffer will be released. So exit
byte-cntr-read when etr is disabled.

Change-Id: Ie1a5367a76eec11563e4a5ff36f616ae40b620f2
Signed-off-by: default avatarYuanfang Zhang <zhangyuanfang@codeaurora.org>
parent 409330d3
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -237,6 +237,7 @@ void tmc_etr_byte_cntr_stop(struct byte_cntr *byte_cntr_data)

	mutex_lock(&byte_cntr_data->byte_cntr_lock);
	byte_cntr_data->enable = false;
	byte_cntr_data->read_active = false;
	coresight_csr_set_byte_cntr(byte_cntr_data->csr, 0);
	mutex_unlock(&byte_cntr_data->byte_cntr_lock);

@@ -264,7 +265,7 @@ static int tmc_etr_byte_cntr_open(struct inode *in, struct file *fp)

	mutex_lock(&byte_cntr_data->byte_cntr_lock);

	if (!tmcdrvdata->enable || !byte_cntr_data->block_size) {
	if (!byte_cntr_data->enable || !byte_cntr_data->block_size) {
		mutex_unlock(&byte_cntr_data->byte_cntr_lock);
		return -EINVAL;
	}
@@ -277,7 +278,6 @@ static int tmc_etr_byte_cntr_open(struct inode *in, struct file *fp)

	fp->private_data = byte_cntr_data;
	nonseekable_open(in, fp);
	byte_cntr_data->enable = true;
	byte_cntr_data->read_active = true;
	mutex_unlock(&byte_cntr_data->byte_cntr_lock);

+3 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012, 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012, 2017-2019, The Linux Foundation. All rights reserved.
 *
 * Description: CoreSight Trace Memory Controller driver
 *
@@ -469,6 +469,8 @@ static ssize_t out_mode_store(struct device *dev,
		coresight_cti_unmap_trigout(drvdata->cti_flush, 3, 0);
		coresight_cti_unmap_trigin(drvdata->cti_reset, 2, 0);

		tmc_etr_byte_cntr_stop(drvdata->byte_cntr);

		drvdata->usbch = usb_qdss_open("qdss", drvdata,
					       usb_notifier);
		if (IS_ERR(drvdata->usbch)) {