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

Commit 5e993927 authored by muluhe's avatar muluhe Committed by Mulu He
Browse files

coresight: stm: STM master side access control



Read the debug status from DEBUG_FUSE_STATUS. QDSS master uses this value
to control the log enable status.

Change-Id: Ice64d86afb60beb5404183583132c3f289131051
Signed-off-by: default avatarmuluhe <muluhe@codeaurora.org>
parent d732694b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, 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
@@ -226,7 +226,7 @@ int stm_trace(uint32_t flags, uint8_t entity_id, uint8_t proto_id,
	struct stm_drvdata *drvdata = stmdrvdata;

	/* we don't support sizes more than 24bits (0 to 23) */
	if (!(drvdata && drvdata->enable &&
	if (!(drvdata && drvdata->enable && drvdata->master_enable &&
	      test_bit(entity_id, drvdata->entities) && size &&
	      (size < 0x1000000)))
		return 0;
+34 −2
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
 *
 * Description: CoreSight System Trace Macrocell driver
 *
@@ -79,6 +79,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;

/*
@@ -779,6 +782,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;
@@ -789,6 +803,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;
@@ -827,6 +842,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) {
@@ -875,7 +906,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
@@ -80,6 +80,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;