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

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

Merge "coresight: tmc: Avoid reading tmc node before it being enabled"

parents e0c9ebac 9f229822
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1455,8 +1455,10 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev)
		coresight_cti_unmap_trigin(drvdata->cti_reset, 2, 0);
		coresight_cti_unmap_trigout(drvdata->cti_flush, 3, 0);
		/* Free memory outside the spinlock if need be */
		if (drvdata->etr_buf)
		if (drvdata->etr_buf) {
			tmc_etr_free_sysfs_buf(drvdata->etr_buf);
			drvdata->etr_buf = NULL;
		}
	}
out:
	mutex_unlock(&drvdata->mem_lock);
+3 −0
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ static int tmc_read_prepare(struct tmc_drvdata *drvdata)
{
	int ret = 0;

	if (!drvdata->enable)
		return -EPERM;

	switch (drvdata->config_type) {
	case TMC_CONFIG_TYPE_ETB:
	case TMC_CONFIG_TYPE_ETF:
+60 −32
Original line number Diff line number Diff line
@@ -211,10 +211,12 @@ static int coresight_enable_link(struct coresight_device *csdev,
	if (atomic_inc_return(&csdev->refcnt[refport]) == 1) {
		if (link_ops(csdev)->enable) {
			ret = link_ops(csdev)->enable(csdev, inport, outport);
			if (ret)
			if (ret) {
				atomic_dec(&csdev->refcnt[refport]);
				return ret;
			}
		}
	}

	csdev->enable = true;

@@ -302,13 +304,12 @@ static bool coresight_disable_source(struct coresight_device *csdev)
	return !csdev->enable;
}

void coresight_disable_path(struct list_head *path)
static void coresight_disable_list_node(struct list_head *path,
					struct coresight_node *nd)
{
	u32 type;
	struct coresight_node *nd;
	struct coresight_device *csdev, *parent, *child;

	list_for_each_entry(nd, path, link) {
	csdev = nd->csdev;
	type = csdev->type;

@@ -339,6 +340,31 @@ void coresight_disable_path(struct list_head *path)
		break;
	}
}

/**
 * During enabling path, if it is failed, then only those enabled
 * devices need to be disabled. This function is to disable devices
 * which is enabled before the failed device.
 *
 * @path the head of the list
 * @nd the failed device node
 */
static void coresight_disable_previous_devs(struct list_head *path,
					struct coresight_node *nd)
{

	list_for_each_entry_continue(nd, path, link) {
		coresight_disable_list_node(path, nd);
	}
}

void coresight_disable_path(struct list_head *path)
{
	struct coresight_node *nd;

	list_for_each_entry(nd, path, link) {
		coresight_disable_list_node(path, nd);
	}
}

int coresight_enable_path(struct list_head *path, u32 mode)
@@ -388,7 +414,7 @@ int coresight_enable_path(struct list_head *path, u32 mode)
out:
	return ret;
err:
	coresight_disable_path(path);
	coresight_disable_previous_devs(path, nd);
	goto out;
}

@@ -838,6 +864,7 @@ static ssize_t enable_source_store(struct device *dev,
		if (ret)
			return ret;
	} else {
		atomic_set(csdev->refcnt, 1);
		coresight_disable(csdev);
	}

@@ -1072,6 +1099,7 @@ static ssize_t reset_source_sink_store(struct bus_type *bus,
		csdev = coresight_get_source(cspath->path);
		if (!csdev)
			continue;
		atomic_set(csdev->refcnt, 1);
		__coresight_disable(csdev);
	}