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

Commit d42a5b11 authored by Tingwei Zhang's avatar Tingwei Zhang
Browse files

coresight: tmc: migrate byte counter to new tmc framework



TMC ETR has moved to new way to allocate and read memory.
Change byte counter to use new interface. This patch also
fixes block_size is not correct issue in byte counter.

Change-Id: I842f653cadefacb96eeea0bef9003df3a3331523
Signed-off-by: default avatarTingwei Zhang <tingwei@codeaurora.org>
parent bdd918fd
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 *
 * Description: CoreSight Trace Memory Controller driver
 */
@@ -20,21 +20,17 @@ static struct tmc_drvdata *tmcdrvdata;
static void tmc_etr_read_bytes(struct byte_cntr *byte_cntr_data, loff_t *ppos,
			       size_t bytes, size_t *len, char **bufp)
{
	struct etr_flat_buf *flat_buf = tmcdrvdata->etr_buf->private;

	if (*bufp >= (char *)(flat_buf->vaddr + tmcdrvdata->size))
		*bufp = flat_buf->vaddr;
	struct etr_buf *etr_buf = tmcdrvdata->etr_buf;
	size_t actual;

	if (*len >= bytes)
		*len = bytes;
	else if (((uint32_t)*ppos % bytes) + *len > bytes)
		*len = bytes - ((uint32_t)*ppos % bytes);

	if ((*bufp + *len) > (char *)(flat_buf->vaddr +
		tmcdrvdata->size))
		*len = (char *)(flat_buf->vaddr + tmcdrvdata->size) -
			*bufp;
	if (*len == bytes || (*len + (uint32_t)*ppos) % bytes == 0)
	actual = tmc_etr_buf_get_data(etr_buf, *ppos, *len, bufp);
	*len = actual;
	if (actual == bytes || (actual + (uint32_t)*ppos) % bytes == 0)
		atomic_dec(&byte_cntr_data->irq_cnt);
}

@@ -76,8 +72,6 @@ static ssize_t tmc_etr_byte_cntr_read(struct file *fp, char __user *data,
	if (!byte_cntr_data->read_active)
		goto err0;

	bufp = (char *)(tmcdrvdata->buf + *ppos);

	if (byte_cntr_data->enable) {
		if (!atomic_read(&byte_cntr_data->irq_cnt)) {
			mutex_unlock(&byte_cntr_data->byte_cntr_lock);
+1 −1
Original line number Diff line number Diff line
@@ -853,7 +853,7 @@ void tmc_free_etr_buf(struct etr_buf *etr_buf)
 * Returns: The size of the linear data available @pos, with *bufpp
 * updated to point to the buffer.
 */
static ssize_t tmc_etr_buf_get_data(struct etr_buf *etr_buf,
ssize_t tmc_etr_buf_get_data(struct etr_buf *etr_buf,
				    u64 offset, size_t len, char **bufpp)
{
	/* Adjust the length to limit this transaction to end of buffer */
+6 −1
Original line number Diff line number Diff line
@@ -453,8 +453,13 @@ static ssize_t block_size_store(struct device *dev,
	if (!drvdata->byte_cntr)
		return -EINVAL;

	if (val && val < 4096) {
		pr_err("Assign minimum block size of 4096 bytes\n");
		return -EINVAL;
	}

	mutex_lock(&drvdata->byte_cntr->byte_cntr_lock);
	drvdata->byte_cntr->block_size = val * 8;
	drvdata->byte_cntr->block_size = val;
	mutex_unlock(&drvdata->byte_cntr->byte_cntr_lock);

	return size;
+2 −1
Original line number Diff line number Diff line
@@ -322,7 +322,8 @@ extern struct byte_cntr *byte_cntr_init(struct amba_device *adev,
extern const struct coresight_ops tmc_etr_cs_ops;
ssize_t tmc_etr_get_sysfs_trace(struct tmc_drvdata *drvdata,
				loff_t pos, size_t len, char **bufpp);

ssize_t tmc_etr_buf_get_data(struct etr_buf *etr_buf,
				u64 offset, size_t len, char **bufpp);

#define TMC_REG_PAIR(name, lo_off, hi_off)				\
static inline u64							\