[Nouveau] [PATCH 4/4] nouveau/debugfs: add interface for current load
Karol Herbst
nouveau at karolherbst.de
Mon Feb 8 11:43:18 UTC 2016
should be moved into nvif though
Signed-off-by: Karol Herbst <nouveau at karolherbst.de>
---
drm/nouveau/include/nvif/device.h | 1 +
drm/nouveau/include/nvkm/subdev/pmu.h | 10 ++++++++++
drm/nouveau/nouveau_debugfs.c | 24 ++++++++++++++++++++++++
drm/nouveau/nvkm/subdev/pmu/base.c | 18 ++++++++++++++++++
4 files changed, 53 insertions(+)
diff --git a/drm/nouveau/include/nvif/device.h b/drm/nouveau/include/nvif/device.h
index e0ed2f4..cba6d0f 100644
--- a/drm/nouveau/include/nvif/device.h
+++ b/drm/nouveau/include/nvif/device.h
@@ -64,6 +64,7 @@ u64 nvif_device_time(struct nvif_device *);
#define nvxx_i2c(a) nvxx_device(a)->i2c
#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 e61923d..be3c60e 100644
--- a/drm/nouveau/include/nvkm/subdev/pmu.h
+++ b/drm/nouveau/include/nvkm/subdev/pmu.h
@@ -23,6 +23,13 @@ struct nvkm_pmu {
} recv;
};
+struct nvkm_pmu_load_data {
+ u8 core;
+ u8 mem;
+ u8 video;
+ u8 pcie;
+};
+
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);
@@ -48,4 +55,7 @@ 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 *, struct nvkm_pmu_load_data *);
#endif
diff --git a/drm/nouveau/nouveau_debugfs.c b/drm/nouveau/nouveau_debugfs.c
index 3d0dc19..eefaee7 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_drm.h"
@@ -180,8 +182,30 @@ 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->device);
+ struct nvkm_pmu_load_data load_data = { 0 };
+
+ if (!pm_runtime_suspended(drm->dev->dev)) {
+ int ret = nvkm_pmu_get_perf_data(pmu, &load_data);
+ if (ret < 0)
+ return ret;
+ }
+
+ seq_printf(m, "core: %x\n", load_data.core);
+ seq_printf(m, "mem: %x\n", load_data.mem);
+ seq_printf(m, "video: %x\n", load_data.video);
+ seq_printf(m, "pcie: %x\n", load_data.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 d95eb86..6594812 100644
--- a/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -140,6 +140,24 @@ nvkm_pmu_recv(struct work_struct *work)
process, message, data0, data1);
}
+#define get_counter_index(v, i) (((v) >> ((i)*8)) & 0xff)
+
+int
+nvkm_pmu_get_perf_data(struct nvkm_pmu *pmu, struct nvkm_pmu_load_data *data)
+{
+ u32 result[2];
+
+ int ret = nvkm_pmu_send(pmu, result, PROC_PERF, PERF_MSG_LOAD, 0, 0);
+ if (ret < 0)
+ return ret;
+
+ data->core = get_counter_index(result[0], 0);
+ data->video = get_counter_index(result[0], 1);
+ data->mem = get_counter_index(result[0], 2);
+ data->pcie = get_counter_index(result[0], 3);
+ return 0;
+}
+
static void
nvkm_pmu_intr(struct nvkm_subdev *subdev)
{
--
2.7.1
More information about the Nouveau
mailing list