From f098012c3a04abb651bca535bb69ac81fc8c1026 Mon Sep 17 00:00:00 2001 From: muluhe Date: Thu, 21 Dec 2017 18:30:35 +0800 Subject: [PATCH] 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. Migrate to nvmem API to get enable status. Change-Id: Ib7d2ab3a10198a1e6198f1e9d15ba7dafa8c00a2 Signed-off-by: muluhe Signed-off-by: Tingwei Zhang --- drivers/hwtracing/coresight/coresight-stm.c | 28 ++++++++++++++++++--- include/linux/coresight-stm.h | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 2555ff27686a..4e2cee6b45ac 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -29,6 +29,7 @@ #include #include #include +#include #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: diff --git a/include/linux/coresight-stm.h b/include/linux/coresight-stm.h index e073bdb3ab6d..7b254fc9458e 100644 --- a/include/linux/coresight-stm.h +++ b/include/linux/coresight-stm.h @@ -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;