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

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

Merge "coresight: stm: STM master side access control"

parents 8da4f03b 487fd24f
Loading
Loading
Loading
Loading
+36 −1
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@
/* Reserve the first 10 channels for kernel usage */
#define STM_CHANNEL_OFFSET		0

#define APPS_NIDEN_SHIFT			17
#define APPS_DBGEN_SHIFT			16

static int boot_nr_channel;

/*
@@ -357,6 +360,9 @@ static ssize_t notrace stm_generic_packet(struct stm_data *stm_data,
	if (!(drvdata && local_read(&drvdata->mode)))
		return -EACCES;

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

	if (channel >= drvdata->numsp)
		return -EINVAL;

@@ -772,6 +778,17 @@ static void stm_init_generic_data(struct stm_drvdata *drvdata)
	drvdata->stm.set_options = stm_generic_set_options;
}

static bool is_apps_debug_disabled(struct stm_drvdata *drvdata)
{
	u32 val;

	val = readl_relaxed(drvdata->debug_status_chs.base);

	val &= BIT(APPS_NIDEN_SHIFT);

	return val == 0;
}

static int stm_probe(struct amba_device *adev, const struct amba_id *id)
{
	int ret;
@@ -782,6 +799,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
	struct stm_drvdata *drvdata;
	struct resource *res = &adev->res;
	struct resource ch_res;
	struct resource debug_ch_res;
	size_t res_size, bitmap_size;
	struct coresight_desc desc = { 0 };
	struct device_node *np = adev->dev.of_node;
@@ -820,6 +838,22 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
		return PTR_ERR(base);
	drvdata->chs.base = base;

	ret = stm_get_resource_byname(np, "stm-debug-status", &debug_ch_res);
	/*
	 * By default, master enable is true, means not controlled
	 * by debug status register
	 */
	if (!ret) {
		drvdata->debug_status_chs.phys = debug_ch_res.start;
		base = devm_ioremap_resource(dev, &debug_ch_res);
		if (!IS_ERR(base)) {
			drvdata->debug_status_chs.base = base;
			drvdata->master_enable =
				!is_apps_debug_disabled(drvdata);
		}
	} else
		drvdata->master_enable = true;

	drvdata->write_bytes = stm_fundamental_data_size(drvdata);

	if (boot_nr_channel) {
@@ -868,7 +902,8 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)

	pm_runtime_put(&adev->dev);

	dev_info(dev, "%s initialized\n", (char *)id->data);
	dev_info(dev, "%s initialized with master %s\n", (char *)id->data,
		       drvdata->master_enable ? "Enabled" : "Disabled");
	return 0;

stm_unregister:
+2 −0
Original line number Diff line number Diff line
@@ -84,6 +84,8 @@ struct stm_drvdata {
	spinlock_t		spinlock;
	struct channel_space	chs;
	bool			enable;
	struct channel_space	debug_status_chs;
	bool			master_enable;
	DECLARE_BITMAP(entities, OST_ENTITY_MAX);
	struct stm_data		stm;
	local_t			mode;