[Nouveau] [PATCH v3 7/7] nouveau/debugfs: add interface for current load
Karol Herbst
karolherbst at gmail.com
Mon Jun 5 20:35:44 UTC 2017
output of the file will be something like that:
core, mem, vid, pci
0xfd, 0x15, 0x00, 0xa2
v2: relayout the debugfs file
v3: rework the struct holding load values
Signed-off-by: Karol Herbst <karolherbst at gmail.com>
---
drm/nouveau/include/nvif/device.h | 1 +
drm/nouveau/include/nvkm/subdev/pmu.h | 8 ++++++++
drm/nouveau/nouveau_debugfs.c | 27 +++++++++++++++++++++++++++
drm/nouveau/nvkm/subdev/pmu/base.c | 8 ++++++++
drm/nouveau/nvkm/subdev/pmu/gf100.c | 1 +
drm/nouveau/nvkm/subdev/pmu/gf119.c | 1 +
drm/nouveau/nvkm/subdev/pmu/gk104.c | 1 +
drm/nouveau/nvkm/subdev/pmu/gk110.c | 1 +
drm/nouveau/nvkm/subdev/pmu/gk208.c | 1 +
drm/nouveau/nvkm/subdev/pmu/gm107.c | 1 +
drm/nouveau/nvkm/subdev/pmu/gt215.c | 18 ++++++++++++++++++
drm/nouveau/nvkm/subdev/pmu/priv.h | 3 +++
12 files changed, 71 insertions(+)
diff --git a/drm/nouveau/include/nvif/device.h b/drm/nouveau/include/nvif/device.h
index bcb98171..2b9f725f 100644
--- a/drm/nouveau/include/nvif/device.h
+++ b/drm/nouveau/include/nvif/device.h
@@ -65,6 +65,7 @@ u64 nvif_device_time(struct nvif_device *);
#define nvxx_iccsense(a) nvxx_device(a)->iccsense
#define nvxx_therm(a) nvxx_device(a)->therm
#define nvxx_volt(a) nvxx_device(a)->volt
+#define nvxx_pmu(a) nvxx_device(a)->pmu
#include <core/device.h>
#include <engine/fifo.h>
diff --git a/drm/nouveau/include/nvkm/subdev/pmu.h b/drm/nouveau/include/nvkm/subdev/pmu.h
index b29570eb..d450b805 100644
--- a/drm/nouveau/include/nvkm/subdev/pmu.h
+++ b/drm/nouveau/include/nvkm/subdev/pmu.h
@@ -35,6 +35,10 @@ enum nvkm_pmu_counter_slot {
NVKM_PMU_COUNTER_SLOT_LAST = 8, // we support up to 8 slots for now
};
+struct nvkm_pmu_counter_data {
+ u8 data[NVKM_PMU_COUNTER_SLOT_LAST];
+};
+
int nvkm_pmu_send(struct nvkm_pmu *, u32 reply[2], u32 process,
u32 message, u32 data0, u32 data1);
void nvkm_pmu_pgob(struct nvkm_pmu *, bool enable);
@@ -63,4 +67,8 @@ void nvkm_memx_train(struct nvkm_memx *);
int nvkm_memx_train_result(struct nvkm_pmu *, u32 *, int);
void nvkm_memx_block(struct nvkm_memx *);
void nvkm_memx_unblock(struct nvkm_memx *);
+
+/* interface to PERF process running on PMU */
+int nvkm_pmu_get_perf_data(struct nvkm_pmu *pmu,
+ struct nvkm_pmu_counter_data *data);
#endif
diff --git a/drm/nouveau/nouveau_debugfs.c b/drm/nouveau/nouveau_debugfs.c
index fd64dfdc..24200abb 100644
--- a/drm/nouveau/nouveau_debugfs.c
+++ b/drm/nouveau/nouveau_debugfs.c
@@ -31,6 +31,8 @@
#include <linux/debugfs.h>
#include <nvif/class.h>
#include <nvif/if0001.h>
+#include <nvkm/subdev/pmu.h>
+
#include "nouveau_debugfs.h"
#include "nouveau_drv.h"
@@ -180,8 +182,33 @@ static const struct file_operations nouveau_pstate_fops = {
.write = nouveau_debugfs_pstate_set,
};
+static int
+nouveau_debugfs_current_load(struct seq_file *m, void *data)
+{
+ struct drm_info_node *node = (struct drm_info_node *) m->private;
+ struct nouveau_drm *drm = nouveau_drm(node->minor->dev);
+ struct nvkm_pmu *pmu = nvxx_pmu(&drm->client.device);
+ struct nvkm_pmu_counter_data counter_data;
+
+ if (!pm_runtime_suspended(drm->dev->dev)) {
+ int ret = nvkm_pmu_get_perf_data(pmu, &counter_data);
+
+ if (ret < 0)
+ return ret;
+ }
+
+ seq_puts(m, "core, mem, vid, pci\n");
+ seq_printf(m, "0x%2.2x, 0x%2.2x, 0x%2.2x, 0x%2.2x\n",
+ counter_data.data[NVKM_PMU_COUNTER_SLOT_CORE],
+ counter_data.data[NVKM_PMU_COUNTER_SLOT_MEMORY],
+ counter_data.data[NVKM_PMU_COUNTER_SLOT_VIDEO],
+ counter_data.data[NVKM_PMU_COUNTER_SLOT_PCIE]);
+ return 0;
+}
+
static struct drm_info_list nouveau_debugfs_list[] = {
{ "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL },
+ { "current_load", nouveau_debugfs_current_load, 0, NULL },
};
#define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)
diff --git a/drm/nouveau/nvkm/subdev/pmu/base.c b/drm/nouveau/nvkm/subdev/pmu/base.c
index 3306f9fe..ed525f30 100644
--- a/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -49,6 +49,14 @@ nvkm_pmu_send(struct nvkm_pmu *pmu, u32 reply[2],
return pmu->func->send(pmu, reply, process, message, data0, data1);
}
+int
+nvkm_pmu_get_perf_data(struct nvkm_pmu *pmu, struct nvkm_pmu_counter_data *data)
+{
+ if (!pmu || !pmu->func->get_perf_data)
+ return -ENODEV;
+ return pmu->func->get_perf_data(pmu, data);
+}
+
static void
nvkm_pmu_intr(struct nvkm_subdev *subdev)
{
diff --git a/drm/nouveau/nvkm/subdev/pmu/gf100.c b/drm/nouveau/nvkm/subdev/pmu/gf100.c
index 14c3dd26..1c4986cb 100644
--- a/drm/nouveau/nvkm/subdev/pmu/gf100.c
+++ b/drm/nouveau/nvkm/subdev/pmu/gf100.c
@@ -37,6 +37,7 @@ gf100_pmu = {
.intr = gt215_pmu_intr,
.send = gt215_pmu_send,
.recv = gt215_pmu_recv,
+ .get_perf_data = gt215_pmu_get_perf_data,
};
int
diff --git a/drm/nouveau/nvkm/subdev/pmu/gf119.c b/drm/nouveau/nvkm/subdev/pmu/gf119.c
index 9cf0279c..49d8fb22 100644
--- a/drm/nouveau/nvkm/subdev/pmu/gf119.c
+++ b/drm/nouveau/nvkm/subdev/pmu/gf119.c
@@ -37,6 +37,7 @@ gf119_pmu = {
.intr = gt215_pmu_intr,
.send = gt215_pmu_send,
.recv = gt215_pmu_recv,
+ .get_perf_data = gt215_pmu_get_perf_data,
};
int
diff --git a/drm/nouveau/nvkm/subdev/pmu/gk104.c b/drm/nouveau/nvkm/subdev/pmu/gk104.c
index cbf1d30d..7ae36a78 100644
--- a/drm/nouveau/nvkm/subdev/pmu/gk104.c
+++ b/drm/nouveau/nvkm/subdev/pmu/gk104.c
@@ -117,6 +117,7 @@ gk104_pmu = {
.send = gt215_pmu_send,
.recv = gt215_pmu_recv,
.pgob = gk104_pmu_pgob,
+ .get_perf_data = gt215_pmu_get_perf_data,
};
int
diff --git a/drm/nouveau/nvkm/subdev/pmu/gk110.c b/drm/nouveau/nvkm/subdev/pmu/gk110.c
index f7ea4975..84001c27 100644
--- a/drm/nouveau/nvkm/subdev/pmu/gk110.c
+++ b/drm/nouveau/nvkm/subdev/pmu/gk110.c
@@ -96,6 +96,7 @@ gk110_pmu = {
.send = gt215_pmu_send,
.recv = gt215_pmu_recv,
.pgob = gk110_pmu_pgob,
+ .get_perf_data = gt215_pmu_get_perf_data,
};
int
diff --git a/drm/nouveau/nvkm/subdev/pmu/gk208.c b/drm/nouveau/nvkm/subdev/pmu/gk208.c
index 252c3c1f..f2d743e6 100644
--- a/drm/nouveau/nvkm/subdev/pmu/gk208.c
+++ b/drm/nouveau/nvkm/subdev/pmu/gk208.c
@@ -38,6 +38,7 @@ gk208_pmu = {
.send = gt215_pmu_send,
.recv = gt215_pmu_recv,
.pgob = gk110_pmu_pgob,
+ .get_perf_data = gt215_pmu_get_perf_data,
};
int
diff --git a/drm/nouveau/nvkm/subdev/pmu/gm107.c b/drm/nouveau/nvkm/subdev/pmu/gm107.c
index b2917ec9..f0a964ff 100644
--- a/drm/nouveau/nvkm/subdev/pmu/gm107.c
+++ b/drm/nouveau/nvkm/subdev/pmu/gm107.c
@@ -39,6 +39,7 @@ gm107_pmu = {
.intr = gt215_pmu_intr,
.send = gt215_pmu_send,
.recv = gt215_pmu_recv,
+ .get_perf_data = gt215_pmu_get_perf_data,
};
int
diff --git a/drm/nouveau/nvkm/subdev/pmu/gt215.c b/drm/nouveau/nvkm/subdev/pmu/gt215.c
index b7053cf7..6550e5e7 100644
--- a/drm/nouveau/nvkm/subdev/pmu/gt215.c
+++ b/drm/nouveau/nvkm/subdev/pmu/gt215.c
@@ -69,6 +69,23 @@ gt215_setup_pmu_counters(struct nvkm_pmu *pmu)
}
int
+gt215_pmu_get_perf_data(struct nvkm_pmu *pmu,
+ struct nvkm_pmu_counter_data *data)
+{
+ int ret;
+ union {
+ u32 *raw;
+ u8 *slots;
+ } d;
+
+ d.slots = data->data;
+ ret = nvkm_pmu_send(pmu, d.raw, PROC_PERF, PERF_MSG_GET_SLOTS, 0, 0);
+ if (ret < 0)
+ return ret;
+ return 0;
+}
+
+int
gt215_pmu_send(struct nvkm_pmu *pmu, u32 reply[2],
u32 process, u32 message, u32 data0, u32 data1)
{
@@ -291,6 +308,7 @@ gt215_pmu = {
.intr = gt215_pmu_intr,
.send = gt215_pmu_send,
.recv = gt215_pmu_recv,
+ .get_perf_data = gt215_pmu_get_perf_data,
};
int
diff --git a/drm/nouveau/nvkm/subdev/pmu/priv.h b/drm/nouveau/nvkm/subdev/pmu/priv.h
index b66629bc..7bc15478 100644
--- a/drm/nouveau/nvkm/subdev/pmu/priv.h
+++ b/drm/nouveau/nvkm/subdev/pmu/priv.h
@@ -30,6 +30,7 @@ struct nvkm_pmu_func {
u32 message, u32 data0, u32 data1);
void (*recv)(struct nvkm_pmu *);
void (*pgob)(struct nvkm_pmu *, bool);
+ int (*get_perf_data)(struct nvkm_pmu *, struct nvkm_pmu_counter_data *);
};
void gt215_pmu_reset(struct nvkm_pmu *);
@@ -38,6 +39,8 @@ void gt215_pmu_fini(struct nvkm_pmu *);
void gt215_pmu_intr(struct nvkm_pmu *);
void gt215_pmu_recv(struct nvkm_pmu *);
int gt215_pmu_send(struct nvkm_pmu *, u32[2], u32, u32, u32, u32);
+int gt215_pmu_get_perf_data(struct nvkm_pmu *pmu,
+ struct nvkm_pmu_counter_data *data);
void gk110_pmu_pgob(struct nvkm_pmu *, bool);
#endif
--
2.13.0
More information about the Nouveau
mailing list