Skip to contentSkip to conversation

WARNING: debugfs_remove(NULL) is safe this check is probably not required

PATCH New Fengguang Wu 1 participant 1 message Aug 5, 2013 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 51fe86b2.cvi+AglnfevlFCOz%[email protected]

#1 lore raw

PATCH 15/15 WARNING: debugfs_remove(NULL) is safe this check is probably not required

Hi Rob,

FYI, there are new warnings show up in

tree:   git://people.freedesktop.org/~robclark/linux drm-next
head:   72b17e21c5965bd0da5e56d96a4776e508cbd79e
commit: 72b17e21c5965bd0da5e56d96a4776e508cbd79e [15/15] WIP: drm/msm: add perf logging debugfs

scripts/checkpatch.pl 0001-WIP-drm-msm-add-perf-logging-debugfs.patch

ERROR: do not use C99 // comments
#565: drivers/gpu/drm/msm/msm_perf.c:170:
+priv->perf = perf; // XXX this isn't really good..

ERROR: do not use C99 // comments
#616: drivers/gpu/drm/msm/msm_perf.c:221:
+// priv->perf = perf;

WARNING: debugfs_remove(NULL) is safe this check is probably not required #651: drivers/gpu/drm/msm/msm_perf.c:256:
+ if (perf->ent)
+ debugfs_remove(perf->ent);

---
0-DAY kernel build testing backend Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation

Quoted 1 line

From 72b17e21c5965bd0da5e56d96a4776e508cbd79e Mon Sep 17 00:00:00 2001

From: Rob Clark <[email protected]>
Date: Sat, 3 Aug 2013 12:43:25 -0400
Subject: [PATCH] WIP: drm/msm: add perf logging debugfs

---
 drivers/gpu/drm/msm/Makefile            |    1 +
 drivers/gpu/drm/msm/adreno/a3xx_gpu.c   |   20 ++-
 drivers/gpu/drm/msm/adreno/adreno_gpu.c |    4 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.h |    2 -
 drivers/gpu/drm/msm/msm_drv.c           |   15 +-
 drivers/gpu/drm/msm/msm_drv.h           |    4 +
 drivers/gpu/drm/msm/msm_gpu.c           |  110 +++++++++++++
 drivers/gpu/drm/msm/msm_gpu.h           |   33 ++++
 drivers/gpu/drm/msm/msm_perf.c          |  270 +++++++++++++++++++++++++++++++
 9 files changed, 448 insertions(+), 11 deletions(-)
 create mode 100644 drivers/gpu/drm/msm/msm_perf.c
drivers/gpu/drm/msm/Makefile +1 -0
index f945179..a19c731 100644
@@ -23,6 +23,7 @@ msm-y := \
 	msm_gem.o \
 	msm_gem_submit.o \
 	msm_gpu.o \
+	msm_perf.o \
 	msm_rd.o \
 	msm_ringbuffer.o
 
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +15 -5
index 13d61bb..2e2950f 100644
@@ -174,11 +174,11 @@ static int a3xx_hw_init(struct msm_gpu *gpu)
 	/* Turn on performance counters: */
 	gpu_write(gpu, REG_A3XX_RBBM_PERFCTR_CTL, 0x01);
 
-	/* Set SP perfcounter 7 to count SP_FS_FULL_ALU_INSTRUCTIONS
-	 * we will use this to augment our hang detection:
-	 */
-	gpu_write(gpu, REG_A3XX_SP_PERFCOUNTER7_SELECT,
-			SP_FS_FULL_ALU_INSTRUCTIONS);
+	/* Enable the perfcntrs that we use.. */
+	for (i = 0; i < gpu->num_perfcntrs; i++) {
+		const struct msm_gpu_perfcntr *perfcntr = &gpu->perfcntrs[i];
+		gpu_write(gpu, perfcntr->select_reg, perfcntr->select_val);
+	}
 
 	gpu_write(gpu, REG_A3XX_RBBM_INT_0_MASK, A3XX_INT0_MASK);
 
@@ -383,6 +383,13 @@ static const struct adreno_gpu_funcs funcs = {
 	},
 };
 
+static const struct msm_gpu_perfcntr perfcntrs[] = {
+	{ REG_A3XX_SP_PERFCOUNTER6_SELECT, REG_A3XX_RBBM_PERFCTR_SP_6_LO,
+			SP_ALU_ACTIVE_CYCLES, "ALUACTIVE" },
+	{ REG_A3XX_SP_PERFCOUNTER7_SELECT, REG_A3XX_RBBM_PERFCTR_SP_7_LO,
+			SP_FS_FULL_ALU_INSTRUCTIONS, "ALUFULL" },
+};
+
 struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
 {
 	struct a3xx_gpu *a3xx_gpu = NULL;
@@ -417,6 +424,9 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
 	DBG("fast_rate=%u, slow_rate=%u, bus_freq=%u",
 			gpu->fast_rate, gpu->slow_rate, gpu->bus_freq);
 
+	gpu->perfcntrs = perfcntrs;
+	gpu->num_perfcntrs = ARRAY_SIZE(perfcntrs);
+
 	ret = adreno_gpu_init(dev, pdev, &a3xx_gpu->base,
 			&funcs, config->rev);
 	if (ret)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -3
index 282163e..39a65af 100644
@@ -119,8 +119,6 @@ int adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
 	struct msm_ringbuffer *ring = gpu->rb;
 	unsigned i, ibs = 0;
 
-	adreno_gpu->last_fence = submit->fence;
-
 	for (i = 0; i < submit->nr_cmds; i++) {
 		switch (submit->cmd[i].type) {
 		case MSM_SUBMIT_CMD_IB_TARGET_BUF:
@@ -225,7 +223,7 @@ void adreno_show(struct msm_gpu *gpu, struct seq_file *m)
 			adreno_gpu->rev.patchid);
 
 	seq_printf(m, "fence:    %d/%d\n", adreno_gpu->memptrs->fence,
-			adreno_gpu->last_fence);
+			gpu->submitted_fence);
 	seq_printf(m, "rptr:     %d\n", adreno_gpu->memptrs->rptr);
 	seq_printf(m, "wptr:     %d\n", adreno_gpu->memptrs->wptr);
 	seq_printf(m, "rb wptr:  %d\n", get_wptr(gpu->rb));
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -2
index 6b49c4f..1190a70 100644
@@ -54,8 +54,6 @@ struct adreno_gpu {
 	uint32_t revn;  /* numeric revision name */
 	const struct adreno_gpu_funcs *funcs;
 
-	uint32_t last_fence;
-
 	/* firmware: */
 	const struct firmware *pm4, *pfp;
 
drivers/gpu/drm/msm/msm_drv.c +14 -1
index adcc68b..58f47a5 100644
@@ -459,12 +459,25 @@ static int msm_debugfs_init(struct drm_minor *minor)
 		return ret;
 	}
 
-	return msm_rd_debugfs_init(minor);
+	ret = msm_rd_debugfs_init(minor);
+	if (ret) {
+		dev_err(dev->dev, "could not install rd debugfs\n");
+		return ret;
+	}
+
+	ret = msm_perf_debugfs_init(minor);
+	if (ret) {
+		dev_err(dev->dev, "could not install perf debugfs\n");
+		return ret;
+	}
+
+	return 0;
 }
 
 static void msm_debugfs_cleanup(struct drm_minor *minor)
 {
 	msm_rd_debugfs_cleanup(minor);
+	msm_perf_debugfs_cleanup(minor);
 	drm_debugfs_remove_files(msm_debugfs_list,
 			ARRAY_SIZE(msm_debugfs_list), minor);
 }
drivers/gpu/drm/msm/msm_drv.h +4 -0
index c49a17e..545d1dc 100644
@@ -44,6 +44,7 @@
 struct msm_kms;
 struct msm_gpu;
 struct msm_rd_state;
+struct msm_perf_state;
 struct msm_gem_submit;
 
 #define NUM_DOMAINS 2    /* one for KMS, then one per gpu core (?) */
@@ -70,6 +71,7 @@ struct msm_drm_private {
 	wait_queue_head_t fence_event;
 
 	struct msm_rd_state *rd;
+	struct msm_perf_state *perf;
 
 	/* list of GEM objects: */
 	struct list_head inactive_list;
@@ -185,6 +187,8 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
 int msm_rd_debugfs_init(struct drm_minor *minor);
 void msm_rd_debugfs_cleanup(struct drm_minor *minor);
 void msm_rd_dump_submit(struct msm_gem_submit *submit);
+int msm_perf_debugfs_init(struct drm_minor *minor);
+void msm_perf_debugfs_cleanup(struct drm_minor *minor);
 #else
 static inline void msm_rd_dump_submit(struct msm_gem_submit *submit) {}
 #endif
drivers/gpu/drm/msm/msm_gpu.c +110 -0

140 lines not on this page · raw message

drivers/gpu/drm/msm/msm_gpu.h +33 -0
index 8d2cd6c..b537f7c 100644
@@ -25,6 +25,7 @@
 #include "msm_ringbuffer.h"
 
 struct msm_gem_submit;
+struct msm_gpu_perfcntr;
 
 /* So far, with hardware that I've seen to date, we can have:
  *  + zero, one, or two z180 2d cores
@@ -63,12 +64,26 @@ struct msm_gpu {
 	struct drm_device *dev;
 	const struct msm_gpu_funcs *funcs;
 
+	/* performance counters (hw & sw): */
+	spinlock_t perf_lock;
+	bool perfcntr_active;
+	struct {
+		bool active;
+		ktime_t time;
+	} last_sample;
+	uint32_t totaltime, activetime;    /* sw counters */
+	uint32_t last_cntrs[5];            /* hw counters */
+	const struct msm_gpu_perfcntr *perfcntrs;
+	uint32_t num_perfcntrs;
+
 	struct msm_ringbuffer *rb;
 	uint32_t rb_iova;
 
 	/* list of GEM active objects: */
 	struct list_head active_list;
 
+	uint32_t submitted_fence;
+
 	/* worker for handling active-list retiring: */
 	struct work_struct retire_work;
 
@@ -85,6 +100,19 @@ struct msm_gpu {
 	uint32_t bsc;
 };
 
+/* Perf-Counters:
+ * The select_reg and select_val are just there for the benefit of the child
+ * class that actually enables the perf counter..  but msm_gpu base class
+ * will handle sampling/displaying the counters.
+ */
+
+struct msm_gpu_perfcntr {
+	uint32_t select_reg;
+	uint32_t sample_reg;
+	uint32_t select_val;
+	const char *name;
+};
+
 static inline void gpu_write(struct msm_gpu *gpu, u32 reg, u32 data)
 {
 	msm_writel(data, gpu->mmio + (reg << 2));
@@ -98,6 +126,11 @@ static inline u32 gpu_read(struct msm_gpu *gpu, u32 reg)
 int msm_gpu_pm_suspend(struct msm_gpu *gpu);
 int msm_gpu_pm_resume(struct msm_gpu *gpu);
 
+void msm_gpu_perfcntr_start(struct msm_gpu *gpu);
+void msm_gpu_perfcntr_stop(struct msm_gpu *gpu);
+int msm_gpu_perfcntr_sample(struct msm_gpu *gpu, uint32_t *activetime,
+		uint32_t *totaltime, uint32_t ncntrs, uint32_t *cntrs);
+
 void msm_gpu_retire(struct msm_gpu *gpu);
 int msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
 		struct msm_file_private *ctx);
drivers/gpu/drm/msm/msm_perf.c new file +270 -0

270 lines not on this page · raw message

Signature · 1 line
1.7.10.4