public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
* [PATCH 0/3] coresight: next v4.11-rc4
@ 2017-03-27 17:09 Mathieu Poirier
  2017-03-27 17:09 ` [PATCH 1/3] coresight: Replace sprintf with scnprintf Mathieu Poirier
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mathieu Poirier @ 2017-03-27 17:09 UTC (permalink / raw)
  To: linux-arm-kernel

Good morning,

Just a few patches this time around - please consider for inclusion in the 4.12
cycle.  Everything applies on your 'char-misc-next' branch (57c0eabbd57e).

Thanks,
Mathieu

Mike Leach (1):
  coresight: Fixes coresight DT parse to get correct output port ID.

Olav Haugan (2):
  coresight: Replace sprintf with scnprintf
  coresight: etm3x: Correctly output counter values in sysfs node

 drivers/hwtracing/coresight/coresight-etb10.c      |  2 +-
 drivers/hwtracing/coresight/coresight-etm-perf.c   |  2 +-
 .../hwtracing/coresight/coresight-etm3x-sysfs.c    | 80 ++++++++++++----------
 drivers/hwtracing/coresight/coresight-funnel.c     |  4 +-
 drivers/hwtracing/coresight/coresight-stm.c        |  2 +-
 drivers/hwtracing/coresight/coresight-tmc.c        |  2 +-
 drivers/hwtracing/coresight/of_coresight.c         |  2 +-
 7 files changed, 52 insertions(+), 42 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] coresight: Replace sprintf with scnprintf
  2017-03-27 17:09 [PATCH 0/3] coresight: next v4.11-rc4 Mathieu Poirier
@ 2017-03-27 17:09 ` Mathieu Poirier
  2017-04-08 15:42   ` Greg KH
  2017-03-27 17:09 ` [PATCH 2/3] coresight: etm3x: Correctly output counter values in sysfs node Mathieu Poirier
  2017-03-27 17:09 ` [PATCH 3/3] coresight: Fixes coresight DT parse to get correct output port ID Mathieu Poirier
  2 siblings, 1 reply; 7+ messages in thread
From: Mathieu Poirier @ 2017-03-27 17:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Olav Haugan <ohaugan@codeaurora•org>

Replace all occurrences of sprintf with scnprintf in coresight driver for
consistency. scnprintf is also a safer alternative to sprintf.

Signed-off-by: Olav Haugan <ohaugan@codeaurora•org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro•org>
---
 drivers/hwtracing/coresight/coresight-etb10.c      |  2 +-
 drivers/hwtracing/coresight/coresight-etm-perf.c   |  2 +-
 .../hwtracing/coresight/coresight-etm3x-sysfs.c    | 66 +++++++++++-----------
 drivers/hwtracing/coresight/coresight-funnel.c     |  4 +-
 drivers/hwtracing/coresight/coresight-stm.c        |  2 +-
 drivers/hwtracing/coresight/coresight-tmc.c        |  2 +-
 6 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index d7325c6534ad..491f4da61c11 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -588,7 +588,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 26cfac3e6de7..6ddcd186c085 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -467,7 +467,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..4cbbd1313331 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,
@@ -734,7 +734,7 @@ static ssize_t cntr_val_show(struct device *dev,
 	if (!local_read(&drvdata->mode)) {
 		spin_lock(&drvdata->spinlock);
 		for (i = 0; i < drvdata->nr_cntr; i++)
-			ret += sprintf(buf, "counter %d: %x\n",
+			ret += scnprintf(buf, PAGE_SIZE, "counter %d: %x\n",
 				       i, config->cntr_val[i]);
 		spin_unlock(&drvdata->spinlock);
 		return ret;
@@ -742,7 +742,7 @@ static ssize_t cntr_val_show(struct device *dev,
 
 	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, PAGE_SIZE, "counter %d: %x\n", i, val);
 	}
 
 	return ret;
@@ -777,7 +777,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 +806,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 +835,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 +864,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 +893,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 +922,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 +965,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 +998,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 +1040,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 +1075,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 +1104,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 +1133,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 +1174,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,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] coresight: etm3x: Correctly output counter values in sysfs node
  2017-03-27 17:09 [PATCH 0/3] coresight: next v4.11-rc4 Mathieu Poirier
  2017-03-27 17:09 ` [PATCH 1/3] coresight: Replace sprintf with scnprintf Mathieu Poirier
@ 2017-03-27 17:09 ` Mathieu Poirier
  2017-04-08 15:43   ` Greg KH
  2017-03-27 17:09 ` [PATCH 3/3] coresight: Fixes coresight DT parse to get correct output port ID Mathieu Poirier
  2 siblings, 1 reply; 7+ messages in thread
From: Mathieu Poirier @ 2017-03-27 17:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Olav Haugan <ohaugan@codeaurora•org>

cntr_val_show function does not print the intended information. It is only
printing the latest counter value. Fix this.

Signed-off-by: Olav Haugan <ohaugan@codeaurora•org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro•org>
---
 drivers/hwtracing/coresight/coresight-etm3x-sysfs.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
index 4cbbd1313331..62acf07d604b 100644
--- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
@@ -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 += scnprintf(buf, PAGE_SIZE, "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 += scnprintf(buf, PAGE_SIZE, "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;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] coresight: Fixes coresight DT parse to get correct output port ID.
  2017-03-27 17:09 [PATCH 0/3] coresight: next v4.11-rc4 Mathieu Poirier
  2017-03-27 17:09 ` [PATCH 1/3] coresight: Replace sprintf with scnprintf Mathieu Poirier
  2017-03-27 17:09 ` [PATCH 2/3] coresight: etm3x: Correctly output counter values in sysfs node Mathieu Poirier
@ 2017-03-27 17:09 ` Mathieu Poirier
  2 siblings, 0 replies; 7+ messages in thread
From: Mathieu Poirier @ 2017-03-27 17:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Mike Leach <mike.leach@linaro•org>

Corrected to get the port numbering to allow programmable replicator driver
to operate correctly.

By convention, CoreSight devices number ports, not endpoints in
the .dts files:-

port {
     reg<N>
     endpoint {
     }
}

Existing code read endpoint number - always 0x0, rather than the correct
port number.

Signed-off-by: Mike Leach <mike.leach@linaro•org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro•org>
---
 drivers/hwtracing/coresight/of_coresight.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 1/3] coresight: Replace sprintf with scnprintf
  2017-03-27 17:09 ` [PATCH 1/3] coresight: Replace sprintf with scnprintf Mathieu Poirier
@ 2017-04-08 15:42   ` Greg KH
  2017-04-24 22:26     ` Olav Haugan
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2017-04-08 15:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 27, 2017 at 11:09:31AM -0600, Mathieu Poirier wrote:
> From: Olav Haugan <ohaugan@codeaurora•org>
> 
> Replace all occurrences of sprintf with scnprintf in coresight driver for
> consistency. scnprintf is also a safer alternative to sprintf.

But it's totally pointless here :(


> 
> Signed-off-by: Olav Haugan <ohaugan@codeaurora•org>
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro•org>
> ---
>  drivers/hwtracing/coresight/coresight-etb10.c      |  2 +-
>  drivers/hwtracing/coresight/coresight-etm-perf.c   |  2 +-
>  .../hwtracing/coresight/coresight-etm3x-sysfs.c    | 66 +++++++++++-----------
>  drivers/hwtracing/coresight/coresight-funnel.c     |  4 +-
>  drivers/hwtracing/coresight/coresight-stm.c        |  2 +-
>  drivers/hwtracing/coresight/coresight-tmc.c        |  2 +-
>  6 files changed, 39 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
> index d7325c6534ad..491f4da61c11 100644
> --- a/drivers/hwtracing/coresight/coresight-etb10.c
> +++ b/drivers/hwtracing/coresight/coresight-etb10.c
> @@ -588,7 +588,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);

There is no need for this in sysfs show callbacks.  You _know_ this is a
PAGE_SIZE buffer, and that you can not overflow it with a simple number.

So don't change these types of functions for no reason please.

Same for most of this patch.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] coresight: etm3x: Correctly output counter values in sysfs node
  2017-03-27 17:09 ` [PATCH 2/3] coresight: etm3x: Correctly output counter values in sysfs node Mathieu Poirier
@ 2017-04-08 15:43   ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2017-04-08 15:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 27, 2017 at 11:09:32AM -0600, Mathieu Poirier wrote:
> From: Olav Haugan <ohaugan@codeaurora•org>
> 
> cntr_val_show function does not print the intended information. It is only
> printing the latest counter value. Fix this.
> 
> Signed-off-by: Olav Haugan <ohaugan@codeaurora•org>
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro•org>
> ---
>  drivers/hwtracing/coresight/coresight-etm3x-sysfs.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
> index 4cbbd1313331..62acf07d604b 100644
> --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
> @@ -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 += scnprintf(buf, PAGE_SIZE, "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;
> +		}

This is NOT a one-value-per-file thing.  That needs to be fixed, don't
try to make it worse here.  You are not following the proper sysfs
rules.

I can't take this, sorry.

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] coresight: Replace sprintf with scnprintf
  2017-04-08 15:42   ` Greg KH
@ 2017-04-24 22:26     ` Olav Haugan
  0 siblings, 0 replies; 7+ messages in thread
From: Olav Haugan @ 2017-04-24 22:26 UTC (permalink / raw)
  To: linux-arm-kernel

On 17-04-08 17:42:23, Greg KH wrote:
> On Mon, Mar 27, 2017 at 11:09:31AM -0600, Mathieu Poirier wrote:
> > From: Olav Haugan <ohaugan@codeaurora•org>
> > 
> > Replace all occurrences of sprintf with scnprintf in coresight driver for
> > consistency. scnprintf is also a safer alternative to sprintf.
> 
> But it's totally pointless here :(
> 

The driver is using a mix of sprintf and scnprintf. This patch is
making the usage consistent across the driver. (There is actually more scnprintf
usage than sprintf usage.) Consistency is good. What is the harm?

> > 
> > Signed-off-by: Olav Haugan <ohaugan@codeaurora•org>
> > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro•org>
> > ---
> >  drivers/hwtracing/coresight/coresight-etb10.c      |  2 +-
> >  drivers/hwtracing/coresight/coresight-etm-perf.c   |  2 +-
> >  .../hwtracing/coresight/coresight-etm3x-sysfs.c    | 66 +++++++++++-----------
> >  drivers/hwtracing/coresight/coresight-funnel.c     |  4 +-
> >  drivers/hwtracing/coresight/coresight-stm.c        |  2 +-
> >  drivers/hwtracing/coresight/coresight-tmc.c        |  2 +-
> >  6 files changed, 39 insertions(+), 39 deletions(-)
> > 
> > diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
> > index d7325c6534ad..491f4da61c11 100644
> > --- a/drivers/hwtracing/coresight/coresight-etb10.c
> > +++ b/drivers/hwtracing/coresight/coresight-etb10.c
> > @@ -588,7 +588,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);
> 
> There is no need for this in sysfs show callbacks.  You _know_ this is a
> PAGE_SIZE buffer, and that you can not overflow it with a simple number.
> 
> So don't change these types of functions for no reason please.
> 
> Same for most of this patch.
> 
> thanks,
> 
> greg k-h
> 

-- 
.Olav

The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-04-24 22:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-27 17:09 [PATCH 0/3] coresight: next v4.11-rc4 Mathieu Poirier
2017-03-27 17:09 ` [PATCH 1/3] coresight: Replace sprintf with scnprintf Mathieu Poirier
2017-04-08 15:42   ` Greg KH
2017-04-24 22:26     ` Olav Haugan
2017-03-27 17:09 ` [PATCH 2/3] coresight: etm3x: Correctly output counter values in sysfs node Mathieu Poirier
2017-04-08 15:43   ` Greg KH
2017-03-27 17:09 ` [PATCH 3/3] coresight: Fixes coresight DT parse to get correct output port ID Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox