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

Commit 353326b0 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "coresight: byte-cntr: Add support for streaming interface for ETR"

parents e8c3884e e0002420
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1086,8 +1086,10 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
	if (free_buf)
		tmc_etr_free_sysfs_buf(free_buf);

	mutex_unlock(&drvdata->mem_lock);
	if (drvdata->out_mode == TMC_ETR_OUT_MODE_MEM)
		tmc_etr_byte_cntr_start(drvdata->byte_cntr);

	mutex_unlock(&drvdata->mem_lock);
	if (!ret)
		dev_info(drvdata->dev, "TMC-ETR enabled\n");

@@ -1135,6 +1137,10 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev)
	}

	spin_unlock_irqrestore(&drvdata->spinlock, flags);

	if (drvdata->out_mode == TMC_ETR_OUT_MODE_MEM)
		tmc_etr_byte_cntr_stop(drvdata->byte_cntr);

	mutex_unlock(&drvdata->mem_lock);
	dev_info(drvdata->dev, "TMC-ETR disabled\n");
}
@@ -1180,6 +1186,11 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata)
		goto out;
	}

	if (drvdata->byte_cntr && drvdata->byte_cntr->enable) {
		ret = -EINVAL;
		goto out;
	}

	/* Disable the TMC if need be */
	if (drvdata->mode == CS_MODE_SYSFS)
		tmc_etr_disable_hw(drvdata);
+39 −0
Original line number Diff line number Diff line
@@ -402,6 +402,42 @@ static ssize_t available_out_modes_show(struct device *dev,
}
static DEVICE_ATTR_RO(available_out_modes);

static ssize_t block_size_show(struct device *dev,
			     struct device_attribute *attr,
			     char *buf)
{
	struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
	uint32_t val = 0;

	if (drvdata->byte_cntr)
		val = drvdata->byte_cntr->block_size;

	return scnprintf(buf, PAGE_SIZE, "%d\n",
			val);
}

static ssize_t block_size_store(struct device *dev,
			      struct device_attribute *attr,
			      const char *buf,
			      size_t size)
{
	struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
	unsigned long val;

	if (kstrtoul(buf, 0, &val))
		return -EINVAL;

	if (!drvdata->byte_cntr)
		return -EINVAL;

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

	return size;
}
static DEVICE_ATTR_RW(block_size);

static struct attribute *coresight_tmc_etf_attrs[] = {
	&dev_attr_trigger_cntr.attr,
	&dev_attr_buffer_size.attr,
@@ -413,6 +449,7 @@ static struct attribute *coresight_tmc_etr_attrs[] = {
	&dev_attr_buffer_size.attr,
	&dev_attr_out_mode.attr,
	&dev_attr_available_out_modes.attr,
	&dev_attr_block_size.attr,
	NULL,
};

@@ -590,6 +627,8 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
		ret = tmc_etr_setup_caps(drvdata, devid, id->data);
		if (ret)
			goto out;

		drvdata->byte_cntr = byte_cntr_init(adev, drvdata);
	}

	drvdata->csdev = coresight_register(&desc);
+5 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
#include <linux/of_address.h>
#include <linux/amba/bus.h>

#include "coresight-byte-cntr.h"

#define TMC_RSZ			0x004
#define TMC_STS			0x00c
#define TMC_RRD			0x010
@@ -221,6 +223,7 @@ struct tmc_drvdata {
	const char		*csr_name;
	bool			enable;
	enum tmc_etr_out_mode	out_mode;
	struct byte_cntr	*byte_cntr;
};

struct etr_buf_operations {
@@ -283,6 +286,8 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata);
int tmc_read_unprepare_etr(struct tmc_drvdata *drvdata);
void tmc_etr_enable_hw(struct tmc_drvdata *drvdata);
void tmc_etr_disable_hw(struct tmc_drvdata *drvdata);
extern struct byte_cntr *byte_cntr_init(struct amba_device *adev,
					struct tmc_drvdata *drvdata);
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);