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

This commit is contained in:
qctecmdr 2019-12-18 06:33:53 -08:00 • committed by Gerrit - the friendly Code Review server
commit 6b00a3be41
2 changed files with 27 additions and 3 deletions

View file

@ -29,6 +29,7 @@
#include <linux/perf_event.h>
#include <linux/pm_runtime.h>
#include <linux/stm.h>
#include <linux/nvmem-consumer.h>
#include "coresight-ost.h"
#include "coresight-priv.h"
@ -75,8 +76,10 @@
/* Reserve the first 10 channels for kernel usage */
#define STM_CHANNEL_OFFSET 0
DEFINE_CORESIGHT_DEVLIST(stm_devs, "stm");
#define APPS_NIDEN_SHIFT 17
#define APPS_DBGEN_SHIFT 16
DEFINE_CORESIGHT_DEVLIST(stm_devs, "stm");
static int boot_nr_channel;
/*
@ -363,6 +366,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;
@ -851,6 +857,13 @@ static void stm_init_generic_data(struct stm_drvdata *drvdata,
drvdata->stm.set_options = stm_generic_set_options;
}
static bool is_apps_debug_disabled(u32 val)
{
val &= BIT(APPS_NIDEN_SHIFT);
return val == 0;
}
static int stm_probe(struct amba_device *adev, const struct amba_id *id)
{
int ret;
@ -862,6 +875,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
struct resource *res = &adev->res;
struct resource ch_res;
size_t bitmap_size;
uint32_t val;
struct coresight_desc desc = { 0 };
desc.name = coresight_alloc_device_name(&stm_devs, dev);
@ -895,6 +909,13 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
return PTR_ERR(base);
drvdata->chs.base = base;
ret = nvmem_cell_read_u32(&adev->dev, "debug_fuse", &val);
if (!ret)
drvdata->master_enable = !is_apps_debug_disabled(val);
else
drvdata->master_enable = true;
drvdata->write_bytes = stm_fundamental_data_size(drvdata);
if (boot_nr_channel)
@ -948,8 +969,9 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
pm_runtime_put(&adev->dev);
dev_info(&drvdata->csdev->dev, "%s initialized\n",
(char *)coresight_get_uci_data(id));
dev_info(dev, "%s initialized with master %s\n",
(char *)coresight_get_uci_data(id),
drvdata->master_enable ? "Enabled" : "Disabled");
return 0;
stm_unregister:

View file

@ -83,6 +83,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;