aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2017-04-03 16:43:16 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2017-04-03 16:43:16 +1000
commit855991d76bf17da7fb320d1c0c4dc74931914879 (patch)
treea0fdfe9e04f6fba08a244607b7ed3a20af9b683f
parent6becba85263691beb239b4e2af4e364925e305f4 (diff)
parentc749b99b9adefa6291977edef2349e5ea3a0a56a (diff)
Merge remote-tracking branch 'coresight/next'
-rw-r--r--drivers/hwtracing/coresight/coresight-etb10.c2
-rw-r--r--drivers/hwtracing/coresight/coresight-etm-perf.c2
-rw-r--r--drivers/hwtracing/coresight/coresight-etm3x-sysfs.c80
-rw-r--r--drivers/hwtracing/coresight/coresight-funnel.c4
-rw-r--r--drivers/hwtracing/coresight/coresight-stm.c2
-rw-r--r--drivers/hwtracing/coresight/coresight-tmc.c2
-rw-r--r--drivers/hwtracing/coresight/coresight.c34
-rw-r--r--drivers/hwtracing/coresight/of_coresight.c2
8 files changed, 78 insertions, 50 deletions
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index 979ea6ec7902..ac4cec7b1329 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -587,7 +587,7 @@ static ssize_t trigger_cntr_show(struct device *dev,
struct etb_drvdata *drvdata = dev_get_drvdata(dev->parent);
unsigned long val = drvdata->trigger_cntr;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t trigger_cntr_store(struct device *dev,
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 288a423c1b27..c59aa71dd332 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -466,7 +466,7 @@ int etm_perf_symlink(struct coresight_device *csdev, bool link)
struct device *pmu_dev = etm_pmu.dev;
struct device *cs_dev = &csdev->dev;
- sprintf(entry, "cpu%d", cpu);
+ scnprintf(entry, PAGE_SIZE, "cpu%d", cpu);
if (!etm_perf_up)
return -EPROBE_DEFER;
diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
index ca98ad13bb8c..62acf07d604b 100644
--- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
@@ -27,7 +27,7 @@ static ssize_t nr_addr_cmp_show(struct device *dev,
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
val = drvdata->nr_addr_cmp;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static DEVICE_ATTR_RO(nr_addr_cmp);
@@ -37,7 +37,7 @@ static ssize_t nr_cntr_show(struct device *dev,
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
val = drvdata->nr_cntr;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static DEVICE_ATTR_RO(nr_cntr);
@@ -48,7 +48,7 @@ static ssize_t nr_ctxid_cmp_show(struct device *dev,
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
val = drvdata->nr_ctxid_cmp;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static DEVICE_ATTR_RO(nr_ctxid_cmp);
@@ -68,7 +68,7 @@ static ssize_t etmsr_show(struct device *dev,
spin_unlock_irqrestore(&drvdata->spinlock, flags);
pm_runtime_put(drvdata->dev);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static DEVICE_ATTR_RO(etmsr);
@@ -110,7 +110,7 @@ static ssize_t mode_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->mode;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t mode_store(struct device *dev,
@@ -195,7 +195,7 @@ static ssize_t trigger_event_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->trigger_event;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t trigger_event_store(struct device *dev,
@@ -225,7 +225,7 @@ static ssize_t enable_event_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->enable_event;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t enable_event_store(struct device *dev,
@@ -255,7 +255,7 @@ static ssize_t fifofull_level_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->fifofull_level;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t fifofull_level_store(struct device *dev,
@@ -285,7 +285,7 @@ static ssize_t addr_idx_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->addr_idx;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t addr_idx_store(struct device *dev,
@@ -335,7 +335,7 @@ static ssize_t addr_single_show(struct device *dev,
val = config->addr_val[idx];
spin_unlock(&drvdata->spinlock);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t addr_single_store(struct device *dev,
@@ -394,7 +394,7 @@ static ssize_t addr_range_show(struct device *dev,
val2 = config->addr_val[idx + 1];
spin_unlock(&drvdata->spinlock);
- return sprintf(buf, "%#lx %#lx\n", val1, val2);
+ return scnprintf(buf, PAGE_SIZE, "%#lx %#lx\n", val1, val2);
}
static ssize_t addr_range_store(struct device *dev,
@@ -456,7 +456,7 @@ static ssize_t addr_start_show(struct device *dev,
val = config->addr_val[idx];
spin_unlock(&drvdata->spinlock);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t addr_start_store(struct device *dev,
@@ -510,7 +510,7 @@ static ssize_t addr_stop_show(struct device *dev,
val = config->addr_val[idx];
spin_unlock(&drvdata->spinlock);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t addr_stop_store(struct device *dev,
@@ -556,7 +556,7 @@ static ssize_t addr_acctype_show(struct device *dev,
val = config->addr_acctype[config->addr_idx];
spin_unlock(&drvdata->spinlock);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t addr_acctype_store(struct device *dev,
@@ -588,7 +588,7 @@ static ssize_t cntr_idx_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->cntr_idx;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t cntr_idx_store(struct device *dev,
@@ -629,7 +629,7 @@ static ssize_t cntr_rld_val_show(struct device *dev,
val = config->cntr_rld_val[config->cntr_idx];
spin_unlock(&drvdata->spinlock);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t cntr_rld_val_store(struct device *dev,
@@ -664,7 +664,7 @@ static ssize_t cntr_event_show(struct device *dev,
val = config->cntr_event[config->cntr_idx];
spin_unlock(&drvdata->spinlock);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t cntr_event_store(struct device *dev,
@@ -699,7 +699,7 @@ static ssize_t cntr_rld_event_show(struct device *dev,
val = config->cntr_rld_event[config->cntr_idx];
spin_unlock(&drvdata->spinlock);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t cntr_rld_event_store(struct device *dev,
@@ -730,19 +730,29 @@ static ssize_t cntr_val_show(struct device *dev,
u32 val;
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct etm_config *config = &drvdata->config;
+ int buf_size = PAGE_SIZE;
if (!local_read(&drvdata->mode)) {
spin_lock(&drvdata->spinlock);
- for (i = 0; i < drvdata->nr_cntr; i++)
- ret += sprintf(buf, "counter %d: %x\n",
- i, config->cntr_val[i]);
+ for (i = 0; i < drvdata->nr_cntr; i++) {
+ ret += scnprintf(&buf[ret], buf_size,
+ "counter %d: %x\n",
+ i, config->cntr_val[i]);
+ buf_size -= ret;
+ if (buf_size <= 0)
+ break;
+ }
spin_unlock(&drvdata->spinlock);
return ret;
}
for (i = 0; i < drvdata->nr_cntr; i++) {
val = etm_readl(drvdata, ETMCNTVRn(i));
- ret += sprintf(buf, "counter %d: %x\n", i, val);
+ ret += scnprintf(&buf[ret], buf_size,
+ "counter %d: %x\n", i, val);
+ buf_size -= ret;
+ if (buf_size <= 0)
+ break;
}
return ret;
@@ -777,7 +787,7 @@ static ssize_t seq_12_event_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->seq_12_event;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t seq_12_event_store(struct device *dev,
@@ -806,7 +816,7 @@ static ssize_t seq_21_event_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->seq_21_event;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t seq_21_event_store(struct device *dev,
@@ -835,7 +845,7 @@ static ssize_t seq_23_event_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->seq_23_event;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t seq_23_event_store(struct device *dev,
@@ -864,7 +874,7 @@ static ssize_t seq_31_event_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->seq_31_event;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t seq_31_event_store(struct device *dev,
@@ -893,7 +903,7 @@ static ssize_t seq_32_event_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->seq_32_event;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t seq_32_event_store(struct device *dev,
@@ -922,7 +932,7 @@ static ssize_t seq_13_event_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->seq_13_event;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t seq_13_event_store(struct device *dev,
@@ -965,7 +975,7 @@ static ssize_t seq_curr_state_show(struct device *dev,
spin_unlock_irqrestore(&drvdata->spinlock, flags);
pm_runtime_put(drvdata->dev);
out:
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t seq_curr_state_store(struct device *dev,
@@ -998,7 +1008,7 @@ static ssize_t ctxid_idx_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->ctxid_idx;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t ctxid_idx_store(struct device *dev,
@@ -1040,7 +1050,7 @@ static ssize_t ctxid_pid_show(struct device *dev,
val = config->ctxid_vpid[config->ctxid_idx];
spin_unlock(&drvdata->spinlock);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t ctxid_pid_store(struct device *dev,
@@ -1075,7 +1085,7 @@ static ssize_t ctxid_mask_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->ctxid_mask;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t ctxid_mask_store(struct device *dev,
@@ -1104,7 +1114,7 @@ static ssize_t sync_freq_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->sync_freq;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t sync_freq_store(struct device *dev,
@@ -1133,7 +1143,7 @@ static ssize_t timestamp_event_show(struct device *dev,
struct etm_config *config = &drvdata->config;
val = config->timestamp_event;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t timestamp_event_store(struct device *dev,
@@ -1174,7 +1184,7 @@ static ssize_t traceid_show(struct device *dev,
val = etm_get_trace_id(drvdata);
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t traceid_store(struct device *dev,
diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index 860fe6ef5632..30cfd5c12b71 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -114,7 +114,7 @@ static ssize_t priority_show(struct device *dev,
struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent);
unsigned long val = drvdata->priority;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t priority_store(struct device *dev,
@@ -157,7 +157,7 @@ static ssize_t funnel_ctrl_show(struct device *dev,
pm_runtime_put(drvdata->dev);
- return sprintf(buf, "%#x\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#x\n", val);
}
static DEVICE_ATTR_RO(funnel_ctrl);
diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
index 93fc26f01bab..70b3eee7f4dd 100644
--- a/drivers/hwtracing/coresight/coresight-stm.c
+++ b/drivers/hwtracing/coresight/coresight-stm.c
@@ -614,7 +614,7 @@ static ssize_t traceid_show(struct device *dev,
struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent);
val = drvdata->traceid;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t traceid_store(struct device *dev,
diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c
index d8517d2a968c..1a660f014c6c 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.c
+++ b/drivers/hwtracing/coresight/coresight-tmc.c
@@ -253,7 +253,7 @@ static ssize_t trigger_cntr_show(struct device *dev,
struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
unsigned long val = drvdata->trigger_cntr;
- return sprintf(buf, "%#lx\n", val);
+ return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
}
static ssize_t trigger_cntr_store(struct device *dev,
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index 0c37356e417c..6a0202b7384f 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -253,14 +253,22 @@ static int coresight_enable_source(struct coresight_device *csdev, u32 mode)
return 0;
}
-static void coresight_disable_source(struct coresight_device *csdev)
+/**
+ * coresight_disable_source - Drop the reference count by 1 and disable
+ * the device if there are no users left.
+ *
+ * @csdev - The coresight device to disable
+ *
+ * Returns true if the device has been disabled.
+ */
+static bool coresight_disable_source(struct coresight_device *csdev)
{
if (atomic_dec_return(csdev->refcnt) == 0) {
- if (source_ops(csdev)->disable) {
+ if (source_ops(csdev)->disable)
source_ops(csdev)->disable(csdev, NULL);
- csdev->enable = false;
- }
+ csdev->enable = false;
}
+ return !csdev->enable;
}
void coresight_disable_path(struct list_head *path)
@@ -550,6 +558,9 @@ int coresight_enable(struct coresight_device *csdev)
int cpu, ret = 0;
struct coresight_device *sink;
struct list_head *path;
+ enum coresight_dev_subtype_source subtype;
+
+ subtype = csdev->subtype.source_subtype;
mutex_lock(&coresight_mutex);
@@ -557,8 +568,16 @@ int coresight_enable(struct coresight_device *csdev)
if (ret)
goto out;
- if (csdev->enable)
+ if (csdev->enable) {
+ /*
+ * There could be multiple applications driving the software
+ * source. So keep the refcount for each such user when the
+ * source is already enabled.
+ */
+ if (subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE)
+ atomic_inc(csdev->refcnt);
goto out;
+ }
/*
* Search for a valid sink for this session but don't reset the
@@ -585,7 +604,7 @@ int coresight_enable(struct coresight_device *csdev)
if (ret)
goto err_source;
- switch (csdev->subtype.source_subtype) {
+ switch (subtype) {
case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC:
/*
* When working from sysFS it is important to keep track
@@ -629,7 +648,7 @@ void coresight_disable(struct coresight_device *csdev)
if (ret)
goto out;
- if (!csdev->enable)
+ if (!csdev->enable || !coresight_disable_source(csdev))
goto out;
switch (csdev->subtype.source_subtype) {
@@ -647,7 +666,6 @@ void coresight_disable(struct coresight_device *csdev)
break;
}
- coresight_disable_source(csdev);
coresight_disable_path(path);
coresight_release_path(path);
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 629e031b7456..09142e99e915 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -149,7 +149,7 @@ struct coresight_platform_data *of_get_coresight_platform_data(
continue;
/* The local out port number */
- pdata->outports[i] = endpoint.id;
+ pdata->outports[i] = endpoint.port;
/*
* Get a handle on the remote port and parent