Skip to contentSkip to conversation

expose global performance counters

RFC PATCH In review Samuel Pitoiset 2 participants 25 messages Jun 7, 2015 – Jun 14, 2015 5 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover expose global performance counters

Hello,

This series exposes global performance counters (PCOUNTER) to the userspace through the nvif interface by reworking most of the code related to the PM engine.

This interface will allow the userspace to control and monitor complex hardware events like the proprietary driver already does, for example with CUPTI and PerfKit.

For now, this series only exposes performance counters on NV50, but this is going to be pretty similar for other families. My plan is to submit more patches for Fermi and Kepler after this series will be reviewed.

The code of this series can be found here:

http://cgit.freedesktop.org/~hakzsam/nouveau/log/?h=nouveau_perfmon

And the corresponding libdrm branch can be found here:

http://cgit.freedesktop.org/~hakzsam/drm/log/?h=nouveau_perfmon

A full example which exposes both compute and graphics hardware events on NV50 can be found here:

http://cgit.freedesktop.org/~hakzsam/perfevent

Most of the code will be implemented in mesa once the kernel interface is going to be upstream and stable.

Below, you can find a summary of the series:

Patches 1-2: fix a bug related to the PM engine context
Patches 3-4: remove useless PMU signals and unused functions
Patches 5-6: reorganize the nvif interface to expose more stuff
Patches 7-11: expose PCOUNTER domains to the userspace
Patches 12-14: implement concept of sources (ie. multiplexers)
Patches 15-17: allow to monitor complex hardware events
Patches 18: add compute/graphics signals/sources
Patches 19-20: expose a software methods interface for controlling PM

Feel free to make a review.
Thanks in advance!

Samuel Pitoiset (20):
pm: prevent freeing the wrong engine context
pm: fix a potential race condition when creating an engine context
pm: remove pmu signals
pm: remove unused nvkm_perfsig_wrap() function
pm: reorganize the nvif interface
pm: prevent creating a perfctr object when signals are not found
pm: implement NVIF_PERFMON_V0_QUERY_DOMAIN method
pm: allow to query signals by domain
pm: change signal iter to u16
pm: use hardware signals indexes instead of user-readable names
pm: allow to monitor hardware signal index 0x00
pm: add concept of sources
pm: allow to query the number of sources for a signal
pm: implement NVIF_PERFMON_V0_QUERY_SOURCE method
pm: allow the userspace to schedule hardware counters
pm: allow to configure domains instead of simple counters
pm: allow the userspace to configure sources
pm/nv50: add compute and graphics signals/sources sw/nv50: add some private functions to factorize code sw/nv50: add and interface for controlling performance counters

 bin/nv_perfmon.c                      | 324 ++++++++++++----
 drm/nouveau/include/nvif/class.h      |  68 +++-
 drm/nouveau/include/nvif/ioctl.h      |   5 +-
 drm/nouveau/include/nvkm/engine/pm.h  |   6 +-
 drm/nouveau/nvkm/engine/device/nv50.c |   2 +-
 drm/nouveau/nvkm/engine/pm/Kbuild     |   2 +-
 drm/nouveau/nvkm/engine/pm/base.c     | 685 +++++++++++++++++++++++++---------
 drm/nouveau/nvkm/engine/pm/daemon.c   | 108 ------
 drm/nouveau/nvkm/engine/pm/g84.c      | 101 ++++-
 drm/nouveau/nvkm/engine/pm/gf100.c    |  13 +-
 drm/nouveau/nvkm/engine/pm/gk104.c    |   6 -
 drm/nouveau/nvkm/engine/pm/gk110.c    |   4 -
 drm/nouveau/nvkm/engine/pm/gt200.c    | 163 ++++++++
 drm/nouveau/nvkm/engine/pm/gt215.c    | 104 ++++--
 drm/nouveau/nvkm/engine/pm/nv40.c     |   8 +-
 drm/nouveau/nvkm/engine/pm/nv50.c     | 136 ++++++-
 drm/nouveau/nvkm/engine/pm/priv.h     |  53 ++-
 drm/nouveau/nvkm/engine/sw/nv50.c     | 216 ++++++++++-
 drm/nouveau/nvkm/engine/sw/nv50.h     |   6 +
 19 files changed, 1561 insertions(+), 449 deletions(-)
 delete mode 100644 drm/nouveau/nvkm/engine/pm/daemon.c
 create mode 100644 drm/nouveau/nvkm/engine/pm/gt200.c
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#2 lore raw

RFC PATCH 1/20 pm: prevent freeing the wrong engine context

In reply to a message not in the archive

This fixes a crash when multiple PM engine contexts are created.

---
 drm/nouveau/nvkm/engine/pm/base.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drm/nouveau/nvkm/engine/pm/base.c +5 -2
index 2006c44..274457c 100644
@@ -332,9 +332,12 @@ static void
 nvkm_perfctx_dtor(struct nvkm_object *object)
 {
 	struct nvkm_pm *ppm = (void *)object->engine;
+	struct nvkm_perfctx *ctx = (void *)object;
+
 	mutex_lock(&nv_subdev(ppm)->mutex);
-	nvkm_engctx_destroy(&ppm->context->base);
-	ppm->context = NULL;
+	nvkm_engctx_destroy(&ctx->base);
+	if (ppm->context == ctx)
+		ppm->context = NULL;
 	mutex_unlock(&nv_subdev(ppm)->mutex);
 }
 
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#3 lore raw

RFC PATCH 2/20 pm: fix a potential race condition when creating an engine context

In reply to a message not in the archive

There is always the possiblity that the ppm->context pointer would get partially updated and accidentally would equal ctx. This would allow two contexts to co-exist, which is not acceptable. Moving the test to the critical section takes care of this problem.

---
 drm/nouveau/nvkm/engine/pm/base.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drm/nouveau/nvkm/engine/pm/base.c +3 -4
index 274457c..4cf36a3 100644
@@ -358,12 +358,11 @@ nvkm_perfctx_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 	mutex_lock(&nv_subdev(ppm)->mutex);
 	if (ppm->context == NULL)
 		ppm->context = ctx;
-	mutex_unlock(&nv_subdev(ppm)->mutex);
-
 	if (ctx != ppm->context)
-		return -EBUSY;
+		ret = -EBUSY;
+	mutex_unlock(&nv_subdev(ppm)->mutex);
 
-	return 0;
+	return ret;
 }
 
 struct nvkm_oclass
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#4 lore raw

RFC PATCH 3/20 pm: remove pmu signals

In reply to a message not in the archive

PDAEMON signals don't have to be exposed by the perfmon engine.

---
 drm/nouveau/include/nvkm/engine/pm.h |   4 --
 drm/nouveau/nvkm/engine/pm/Kbuild    |   1 -
 drm/nouveau/nvkm/engine/pm/daemon.c  | 108 -----------------------------------
 drm/nouveau/nvkm/engine/pm/gf100.c   |   5 --
 drm/nouveau/nvkm/engine/pm/gk104.c   |   6 --
 drm/nouveau/nvkm/engine/pm/gk110.c   |   4 --
 drm/nouveau/nvkm/engine/pm/gt215.c   |  20 +------
 drm/nouveau/nvkm/engine/pm/priv.h    |   4 --
 8 files changed, 1 insertion(+), 151 deletions(-)
 delete mode 100644 drm/nouveau/nvkm/engine/pm/daemon.c
drm/nouveau/include/nvkm/engine/pm.h +0 -4
index 93181bb..6c2d057 100644
@@ -12,10 +12,6 @@ struct nvkm_pm {
 
 	struct list_head domains;
 	u32 sequence;
-
-	/*XXX: temp for daemon backend */
-	u32 pwr[8];
-	u32 last;
 };
 
 static inline struct nvkm_pm *
drm/nouveau/nvkm/engine/pm/Kbuild +0 -1
index 413b609..c5ee8d5 100644
@@ -1,5 +1,4 @@
 nvkm-y += nvkm/engine/pm/base.o
-nvkm-y += nvkm/engine/pm/daemon.o
 nvkm-y += nvkm/engine/pm/nv40.o
 nvkm-y += nvkm/engine/pm/nv50.o
 nvkm-y += nvkm/engine/pm/g84.o
drm/nouveau/nvkm/engine/pm/daemon.c deleted +0 -108

108 lines not on this page · raw message

drm/nouveau/nvkm/engine/pm/gf100.c +0 -5
index 008fed7..69303b5 100644
@@ -111,10 +111,6 @@ gf100_pm_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 	if (ret)
 		return ret;
 
-	ret = nvkm_perfdom_new(&priv->base, "pwr", 0, 0, 0, 0, gf100_pm_pwr);
-	if (ret)
-		return ret;
-
 	/* HUB */
 	ret = nvkm_perfdom_new(&priv->base, "hub", 0, 0x1b0000, 0, 0x200,
 			       gf100_pm_hub);
@@ -143,7 +139,6 @@ gf100_pm_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 
 	nv_engine(priv)->cclass = &nvkm_pm_cclass;
 	nv_engine(priv)->sclass =  nvkm_pm_sclass;
-	priv->base.last = 7;
 	return 0;
 }
 
drm/nouveau/nvkm/engine/pm/gk104.c +0 -6
index 75b9ff3..3565f29 100644
@@ -99,11 +99,6 @@ gk104_pm_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 	if (ret)
 		return ret;
 
-	/* PDAEMON */
-	ret = nvkm_perfdom_new(&priv->base, "pwr", 0, 0, 0, 0, gk104_pm_pwr);
-	if (ret)
-		return ret;
-
 	/* HUB */
 	ret = nvkm_perfdom_new(&priv->base, "hub", 0, 0x1b0000, 0, 0x200,
 			       gk104_pm_hub);
@@ -132,7 +127,6 @@ gk104_pm_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 
 	nv_engine(priv)->cclass = &nvkm_pm_cclass;
 	nv_engine(priv)->sclass =  nvkm_pm_sclass;
-	priv->base.last = 7;
 	return 0;
 }
 
drm/nouveau/nvkm/engine/pm/gk110.c +0 -4
index 6820176..8373cd8 100644
@@ -36,10 +36,6 @@ gk110_pm_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 	if (ret)
 		return ret;
 
-	ret = nvkm_perfdom_new(&priv->base, "pwr", 0, 0, 0, 0, gk104_pm_pwr);
-	if (ret)
-		return ret;
-
 	nv_engine(priv)->cclass = &nvkm_pm_cclass;
 	nv_engine(priv)->sclass =  nvkm_pm_sclass;
 	return 0;
drm/nouveau/nvkm/engine/pm/gt215.c +1 -19
index d065bfc..ab69ab5 100644
@@ -52,29 +52,11 @@ gt215_pm[] = {
 	{}
 };
 
-static int
-gt215_pm_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
-	      struct nvkm_oclass *oclass, void *data, u32 size,
-	      struct nvkm_object **object)
-{
-	int ret = nv40_pm_ctor(parent, engine, oclass, data, size, object);
-	if (ret == 0) {
-		struct nv40_pm_priv *priv = (void *)*object;
-		ret = nvkm_perfdom_new(&priv->base, "pwr", 0, 0, 0, 0,
-				       gt215_pm_pwr);
-		if (ret)
-			return ret;
-
-		priv->base.last = 3;
-	}
-	return ret;
-}
-
 struct nvkm_oclass *
 gt215_pm_oclass = &(struct nv40_pm_oclass) {
 	.base.handle = NV_ENGINE(PM, 0xa3),
 	.base.ofuncs = &(struct nvkm_ofuncs) {
-		.ctor = gt215_pm_ctor,
+		.ctor = nv40_pm_ctor,
 		.dtor = _nvkm_pm_dtor,
 		.init = _nvkm_pm_init,
 		.fini = _nvkm_pm_fini,
drm/nouveau/nvkm/engine/pm/priv.h +0 -4
index 1e6eff2..95796c7 100644
@@ -41,10 +41,6 @@ struct nvkm_specdom {
 	const struct nvkm_funcdom *func;
 };
 
-extern const struct nvkm_specdom gt215_pm_pwr[];
-extern const struct nvkm_specdom gf100_pm_pwr[];
-extern const struct nvkm_specdom gk104_pm_pwr[];
-
 struct nvkm_perfdom {
 	struct list_head head;
 	struct list_head list;
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#5 lore raw

RFC PATCH 4/20 pm: remove unused nvkm_perfsig_wrap() function

In reply to a message not in the archive
---
 drm/nouveau/nvkm/engine/pm/base.c | 20 --------------------
 drm/nouveau/nvkm/engine/pm/priv.h |  4 ----
 2 files changed, 24 deletions(-)
drm/nouveau/nvkm/engine/pm/base.c +0 -20
index 4cf36a3..7b07e8b 100644
@@ -79,26 +79,6 @@ nvkm_perfsig_find(struct nvkm_pm *ppm, const char *name, u32 size,
 	return nvkm_perfsig_find_(dom, name, size);
 }
 
-struct nvkm_perfctr *
-nvkm_perfsig_wrap(struct nvkm_pm *ppm, const char *name,
-		  struct nvkm_perfdom **pdom)
-{
-	struct nvkm_perfsig *sig;
-	struct nvkm_perfctr *ctr;
-
-	sig = nvkm_perfsig_find(ppm, name, strlen(name), pdom);
-	if (!sig)
-		return NULL;
-
-	ctr = kzalloc(sizeof(*ctr), GFP_KERNEL);
-	if (ctr) {
-		ctr->signal[0] = sig;
-		ctr->logic_op = 0xaaaa;
-	}
-
-	return ctr;
-}
-
 /*******************************************************************************
  * Perfmon object classes
  ******************************************************************************/
drm/nouveau/nvkm/engine/pm/priv.h +0 -4
index 95796c7..06a6e60 100644
@@ -31,10 +31,6 @@ struct nvkm_perfsig {
 	const char *name;
 };
 
-struct nvkm_perfdom;
-struct nvkm_perfctr *
-nvkm_perfsig_wrap(struct nvkm_pm *, const char *, struct nvkm_perfdom **);
-
 struct nvkm_specdom {
 	u16 signal_nr;
 	const struct nvkm_specsig *signal;
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#6 lore raw

RFC PATCH 5/20 pm: reorganize the nvif interface

In reply to a message not in the archive

This commit introduces the NVIF_IOCTL_NEW_V0_PERFMON class which will be used in order to query domains, signals and sources. This separates the querying and the counting interface.

---
 bin/nv_perfmon.c                  | 12 ++++++------
 drm/nouveau/include/nvif/class.h  | 26 ++++++++++++++++----------
 drm/nouveau/include/nvif/ioctl.h  |  5 +++--
 drm/nouveau/nvkm/engine/pm/base.c | 38 ++++++++++++++++++++++++++++++++------
 4 files changed, 57 insertions(+), 24 deletions(-)
bin/nv_perfmon.c +6 -6
index a8c5838..30a3138 100644
@@ -600,7 +600,7 @@ main(int argc, char **argv)
 	const char *cfg = NULL;
 	const char *dbg = "error";
 	u64 dev = ~0ULL;
-	struct nvif_perfctr_query_v0 args = {};
+	struct nvif_perfmon_query_signal_v0 args = {};
 	struct nvif_client *client;
 	struct nvif_object object;
 	int ret, c, k;
@@ -644,15 +644,14 @@ main(int argc, char **argv)
 	}
 
 	ret = nvif_object_init(nvif_object(device), NULL, 0xdeadbeef,
-			       NVIF_IOCTL_NEW_V0_PERFCTR,
-			       &(struct nvif_perfctr_v0) {
-			       }, sizeof(struct nvif_perfctr_v0), &object);
+			       NVIF_IOCTL_NEW_V0_PERFMON, NULL, 0, &object);
 	assert(ret == 0);
 	do {
 		u32 prev_iter = args.iter;
 
 		args.name[0] = '\0';
-		ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY, &args, sizeof(args));
+		ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
+				&args, sizeof(args));
 		assert(ret == 0);
 
 		if (prev_iter) {
@@ -663,7 +662,8 @@ main(int argc, char **argv)
 			args.iter = prev_iter;
 			strncpy(signals[nr_signals - 1], args.name,
 				sizeof(args.name));
-			ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY, &args, sizeof(args));
+			ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
+					&args, sizeof(args));
 			assert(ret == 0);
 		}
 	} while (args.iter != 0xffffffff);
drm/nouveau/include/nvif/class.h +16 -10
index 64f8b2f..11935a0 100644
@@ -251,6 +251,20 @@ struct gf110_dma_v0 {
  * perfmon
  ******************************************************************************/
 
+#define NVIF_PERFMON_V0_QUERY_SIGNAL                                       0x00
+
+struct nvif_perfmon_query_signal_v0 {
+	__u8  version;
+	__u8  pad01[3];
+	__u32 iter;
+	char  name[64];
+};
+
+
+/*******************************************************************************
+ * perfctr
+ ******************************************************************************/
+
 struct nvif_perfctr_v0 {
 	__u8  version;
 	__u8  pad01[1];
@@ -259,16 +273,8 @@ struct nvif_perfctr_v0 {
 	char  name[4][64];
 };
 
-#define NVIF_PERFCTR_V0_QUERY                                              0x00
-#define NVIF_PERFCTR_V0_SAMPLE                                             0x01
-#define NVIF_PERFCTR_V0_READ                                               0x02
-
-struct nvif_perfctr_query_v0 {
-	__u8  version;
-	__u8  pad01[3];
-	__u32 iter;
-	char  name[64];
-};
+#define NVIF_PERFCTR_V0_SAMPLE                                             0x00
+#define NVIF_PERFCTR_V0_READ                                               0x01
 
 struct nvif_perfctr_sample {
 };
drm/nouveau/include/nvif/ioctl.h +3 -2
index 4cd8e32..517cd27 100644
@@ -49,8 +49,9 @@ struct nvif_ioctl_new_v0 {
 	__u64 token;
 	__u32 handle;
 /* these class numbers are made up by us, and not nvidia-assigned */
-#define NVIF_IOCTL_NEW_V0_PERFCTR                                    0x0000ffff
-#define NVIF_IOCTL_NEW_V0_CONTROL                                    0x0000fffe
+#define NVIF_IOCTL_NEW_V0_PERFMON                                    0x0000ffff
+#define NVIF_IOCTL_NEW_V0_PERFCTR                                    0x0000fffe
+#define NVIF_IOCTL_NEW_V0_CONTROL                                    0x0000fffd
 	__u32 oclass;
 	__u8  data[];		/* class data (class.h) */
 };
drm/nouveau/nvkm/engine/pm/base.c +32 -6
index 7b07e8b..cb88170 100644
@@ -83,10 +83,10 @@ nvkm_perfsig_find(struct nvkm_pm *ppm, const char *name, u32 size,
  * Perfmon object classes
  ******************************************************************************/
 static int
-nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
+nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data, u32 size)
 {
 	union {
-		struct nvif_perfctr_query_v0 v0;
+		struct nvif_perfmon_query_signal_v0 v0;
 	} *args = data;
 	struct nvkm_device *device = nv_device(object);
 	struct nvkm_pm *ppm = (void *)object->engine;
@@ -97,9 +97,9 @@ nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
 	int tmp = 0, di, si;
 	int ret;
 
-	nv_ioctl(object, "perfctr query size %d\n", size);
+	nv_ioctl(object, "perfmon query signal size %d\n", size);
 	if (nvif_unpack(args->v0, 0, 0, false)) {
-		nv_ioctl(object, "perfctr query vers %d iter %08x\n",
+		nv_ioctl(object, "perfmon query signal vers %d iter %08x\n",
 			 args->v0.version, args->v0.iter);
 		di = (args->v0.iter & 0xff000000) >> 24;
 		si = (args->v0.iter & 0x00ffffff) - 1;
@@ -142,6 +142,30 @@ nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
 }
 
 static int
+nvkm_perfmon_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
+{
+	switch (mthd) {
+	case NVIF_PERFMON_V0_QUERY_SIGNAL:
+		return nvkm_perfmon_mthd_query_signal(object, data, size);
+	default:
+		break;
+	}
+	return -EINVAL;
+}
+
+static struct nvkm_ofuncs
+nvkm_perfmon_ofuncs = {
+	.ctor = _nvkm_object_ctor,
+	.dtor = nvkm_object_destroy,
+	.init = nvkm_object_init,
+	.fini = nvkm_object_fini,
+	.mthd = nvkm_perfmon_mthd,
+};
+
+/*******************************************************************************
+ * Perfctr object classes
+ ******************************************************************************/
+static int
 nvkm_perfctr_sample(struct nvkm_object *object, void *data, u32 size)
 {
 	union {
@@ -221,8 +245,6 @@ static int
 nvkm_perfctr_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 {
 	switch (mthd) {
-	case NVIF_PERFCTR_V0_QUERY:
-		return nvkm_perfctr_query(object, data, size);
 	case NVIF_PERFCTR_V0_SAMPLE:
 		return nvkm_perfctr_sample(object, data, size);
 	case NVIF_PERFCTR_V0_READ:
@@ -299,6 +321,10 @@ nvkm_perfctr_ofuncs = {
 
 struct nvkm_oclass
 nvkm_pm_sclass[] = {
+	{
+	  .handle = NVIF_IOCTL_NEW_V0_PERFMON,
+	  .ofuncs = &nvkm_perfmon_ofuncs,
+	},
 	{ .handle = NVIF_IOCTL_NEW_V0_PERFCTR,
 	  .ofuncs = &nvkm_perfctr_ofuncs,
 	},
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#15 lore raw

RFC PATCH 6/20 pm: prevent creating a perfctr object when signals are not found

In reply to a message not in the archive

Since a new class has been introduced to query signals, we can now return an error when the userspace wants to monitor unknown signals.

---
 drm/nouveau/nvkm/engine/pm/base.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drm/nouveau/nvkm/engine/pm/base.c +4 -2
index cb88170..2f85147 100644
@@ -294,6 +294,9 @@ nvkm_perfctr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 			return -EINVAL;
 	}
 
+	if (!dom)
+		return -EINVAL;
+
 	ret = nvkm_object_create(parent, engine, oclass, 0, &ctr);
 	*pobject = nv_object(ctr);
 	if (ret)
@@ -305,8 +308,7 @@ nvkm_perfctr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 	ctr->signal[1] = sig[1];
 	ctr->signal[2] = sig[2];
 	ctr->signal[3] = sig[3];
-	if (dom)
-		list_add_tail(&ctr->head, &dom->list);
+	list_add_tail(&ctr->head, &dom->list);
 	return 0;
 }
 
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#16 lore raw

RFC PATCH 7/20 pm: implement NVIF_PERFMON_V0_QUERY_DOMAIN method

In reply to a message not in the archive

This allows to query the number of available domains, including the number of hardware counter and the number of signals per domain.

---
 drm/nouveau/include/nvif/class.h  | 11 ++++-
 drm/nouveau/nvkm/engine/pm/base.c | 86 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+), 1 deletion(-)
drm/nouveau/include/nvif/class.h +10 -1
index 11935a0..0b28929 100644
@@ -251,7 +251,16 @@ struct gf110_dma_v0 {
  * perfmon
  ******************************************************************************/
 
-#define NVIF_PERFMON_V0_QUERY_SIGNAL                                       0x00
+#define NVIF_PERFMON_V0_QUERY_DOMAIN                                       0x00
+#define NVIF_PERFMON_V0_QUERY_SIGNAL                                       0x01
+
+struct nvif_perfmon_query_domain_v0 {
+	__u8  version;
+	__u8  id;
+	__u8  counter_nr;
+	__u8  iter;
+	__u32 signal_nr;
+};
 
 struct nvif_perfmon_query_signal_v0 {
 	__u8  version;
drm/nouveau/nvkm/engine/pm/base.c +86 -0

104 lines not on this page · raw message

Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#17 lore raw

RFC PATCH 8/20 pm: allow to query signals by domain

In reply to a message not in the archive

This will allow to configure performance counters with hardware signal indexes instead of user-readable names in an upcoming patch.

---
 bin/nv_perfmon.c                  | 185 ++++++++++++++++++++++++++++----------
 drm/nouveau/include/nvif/class.h  |   3 +-
 drm/nouveau/nvkm/engine/pm/base.c |  36 +++-----
 3 files changed, 150 insertions(+), 74 deletions(-)
bin/nv_perfmon.c +136 -49
index 30a3138..958520e 100644
@@ -36,8 +36,7 @@
 #include <sys/time.h>
 
 static struct nvif_device *device;
-static char **signals;
-static int nr_signals;
+static int nr_signals; /* number of signals for all domains */
 
 #define SEC_US  1000000
 #define REFRESH_PERIOD SEC_US
@@ -247,6 +246,17 @@ ui_menu_win = {
  *
  ******************************************************************************/
 
+struct ui_perfmon_dom {
+	struct list_head head;
+	struct list_head list;
+	u8 id;
+};
+
+struct ui_perfmon_sig {
+	struct list_head head;
+	char *name;
+};
+
 struct ui_main {
 	struct list_head head;
 	u32 handle;
@@ -258,6 +268,7 @@ struct ui_main {
 };
 
 static struct list_head ui_main_list = LIST_HEAD_INIT(ui_main_list);
+static struct list_head ui_doms_list = LIST_HEAD_INIT(ui_doms_list);
 static u32 ui_main_handle = 0xc0000000;
 
 static void
@@ -269,32 +280,134 @@ ui_main_remove(struct ui_main *item)
 }
 
 static void
+ui_perfmon_query_signals(struct nvif_object *perfmon,
+			 struct ui_perfmon_dom *dom)
+{
+	struct nvif_perfmon_query_signal_v0 args = {};
+	struct ui_perfmon_sig *sig;
+	int ret;
+
+	args.domain = dom->id;
+	do {
+		u32 prev_iter = args.iter;
+
+		args.name[0] = '\0';
+		ret = nvif_mthd(perfmon, NVIF_PERFMON_V0_QUERY_SIGNAL,
+				&args, sizeof(args));
+		assert(ret == 0);
+
+		if (prev_iter) {
+			nr_signals++;
+			sig = calloc(1, sizeof(*sig));
+			sig->name = malloc(sizeof(args.name));
+			strncpy(sig->name, args.name, sizeof(args.name));
+			list_add_tail(&sig->head, &dom->list);
+
+			args.iter = prev_iter;
+			ret = nvif_mthd(perfmon, NVIF_PERFMON_V0_QUERY_SIGNAL,
+					&args, sizeof(args));
+			assert(ret == 0);
+		}
+	} while (args.iter != 0xffffffff);
+}
+
+static void
+ui_perfmon_query_domains(struct nvif_object *perfmon)
+{
+	struct nvif_perfmon_query_domain_v0 args = {};
+	struct ui_perfmon_dom *dom;
+	int ret;
+
+	assert(ret == 0);
+	do {
+		u8 prev_iter = args.iter;
+
+		ret = nvif_mthd(perfmon, NVIF_PERFMON_V0_QUERY_DOMAIN,
+				&args, sizeof(args));
+		assert(ret == 0);
+
+		if (prev_iter) {
+			dom = calloc(1, sizeof(*dom));
+			dom->id = args.id;
+			INIT_LIST_HEAD(&dom->list);
+			list_add_tail(&dom->head, &ui_doms_list);
+
+			args.iter = prev_iter;
+			ret = nvif_mthd(perfmon, NVIF_PERFMON_V0_QUERY_DOMAIN,
+					&args, sizeof(args));
+			assert(ret == 0);
+
+			/* query available signals for the domain */
+			ui_perfmon_query_signals(perfmon, dom);
+		}
+	} while (args.iter != 0xff);
+}
+
+static void
+ui_perfmon_init(void)
+{
+	struct nvif_object perfmon;
+	int ret;
+
+	ret = nvif_object_init(nvif_object(device), NULL, 0xdeadbeef,
+			       NVIF_IOCTL_NEW_V0_PERFMON, NULL, 0, &perfmon);
+	assert(ret == 0);
+
+	/* query available domains for the device */
+	ui_perfmon_query_domains(&perfmon);
+
+	nvif_object_fini(&perfmon);
+}
+
+static void
+ui_perfmon_fini(void)
+{
+	struct ui_perfmon_dom *dom, *next_dom;
+	struct ui_perfmon_sig *sig, *next_sig;
+
+	list_for_each_entry_safe(dom, next_dom, &ui_doms_list, head) {
+		list_for_each_entry_safe(sig, next_sig, &dom->list, head) {
+			list_del(&sig->head);
+			free(sig->name);
+			free(sig);
+		}
+		list_del(&dom->head);
+		free(dom);
+	}
+}
+
+static void
 ui_main_select(void)
 {
 	struct ui_main *item, *temp;
-	int ret, i;
+	struct ui_perfmon_dom *dom;
+	struct ui_perfmon_sig *sig;
+	int ret;
 
 	list_for_each_entry_safe(item, temp, &ui_main_list, head) {
 		ui_main_remove(item);
 	}
 
-	for (i = 0; i < nr_signals; i++) {
-		struct nvif_perfctr_v0 args = {
-			.logic_op = 0xaaaa,
-		};
+	list_for_each_entry(dom, &ui_doms_list, head) {
+		list_for_each_entry(sig, &dom->list, head) {
+			struct nvif_perfctr_v0 args = {
+				.logic_op = 0xaaaa,
+			};
 
-		item = calloc(1, sizeof(*item));
-		item->handle = ui_main_handle++;
-		item->name = signals[i];
-		item->incr = 0;
+			item = calloc(1, sizeof(*item));
+			item->handle = ui_main_handle++;
+			item->name = sig->name;
 
-		strncpy(args.name[0], item->name, sizeof(args.name[0]));
+			strncpy(args.name[0], item->name, sizeof(args.name[0]));
 
-		ret = nvif_object_init(nvif_object(device), NULL, item->handle,
-				       NVIF_IOCTL_NEW_V0_PERFCTR, &args,
-				       sizeof(args), &item->object);
-		assert(ret == 0);
-		list_add_tail(&item->head, &ui_main_list);
+			ret = nvif_object_init(nvif_object(device), NULL,
+					       item->handle,
+					       NVIF_IOCTL_NEW_V0_PERFCTR,
+					       &args, sizeof(args),
+					       &item->object);
+			assert(ret == 0);
+			list_add_tail(&item->head, &ui_main_list);
+		}
 	}
 }
 
@@ -314,12 +427,14 @@ ui_main_alarm_handler(int signal)
 		if (!sampled) {
 			struct nvif_perfctr_sample args = {};
 
-			ret = nvif_mthd(&item->object, NVIF_PERFCTR_V0_SAMPLE, &args, sizeof(args));
+			ret = nvif_mthd(&item->object, NVIF_PERFCTR_V0_SAMPLE,
+					&args, sizeof(args));
 			assert(ret == 0);
 			sampled = true;
 		}
 
-		ret = nvif_mthd(&item->object, NVIF_PERFCTR_V0_READ, &args, sizeof(args));
+		ret = nvif_mthd(&item->object, NVIF_PERFCTR_V0_READ,
+				&args, sizeof(args));
 		assert(ret == 0 || ret == -EAGAIN);
 
 		if (ret == 0) {
@@ -600,9 +715,7 @@ main(int argc, char **argv)
 	const char *cfg = NULL;
 	const char *dbg = "error";
 	u64 dev = ~0ULL;
-	struct nvif_perfmon_query_signal_v0 args = {};
 	struct nvif_client *client;
-	struct nvif_object object;
 	int ret, c, k;
 	int scan = 0;
 
@@ -643,31 +756,7 @@ main(int argc, char **argv)
 		return 1;
 	}
 
-	ret = nvif_object_init(nvif_object(device), NULL, 0xdeadbeef,
-			       NVIF_IOCTL_NEW_V0_PERFMON, NULL, 0, &object);
-	assert(ret == 0);
-	do {
-		u32 prev_iter = args.iter;
-
-		args.name[0] = '\0';
-		ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
-				&args, sizeof(args));
-		assert(ret == 0);
-
-		if (prev_iter) {
-			nr_signals++;
-			signals = realloc(signals, nr_signals * sizeof(char*));
-			signals[nr_signals - 1] = malloc(sizeof(args.name));
-
-			args.iter = prev_iter;
-			strncpy(signals[nr_signals - 1], args.name,
-				sizeof(args.name));
-			ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
-					&args, sizeof(args));
-			assert(ret == 0);
-		}
-	} while (args.iter != 0xffffffff);
-	nvif_object_fini(&object);
+	ui_perfmon_init();
 
 	initscr();
 	keypad(stdscr, TRUE);
@@ -696,10 +785,8 @@ main(int argc, char **argv)
 
 	ui_destroy();
 	endwin();
+	ui_perfmon_fini();
 
-	while (nr_signals--)
-		free(signals[nr_signals]);
-	free(signals);
 	nvif_device_ref(NULL, &device);
 	return 0;
 }
drm/nouveau/include/nvif/class.h +2 -1
index 0b28929..cf2af89 100644
@@ -264,7 +264,8 @@ struct nvif_perfmon_query_domain_v0 {
 
 struct nvif_perfmon_query_signal_v0 {
 	__u8  version;
-	__u8  pad01[3];
+	__u8  domain;
+	__u8  pad02[2];
 	__u32 iter;
 	char  name[64];
 };
drm/nouveau/nvkm/engine/pm/base.c +12 -24
index 3d9bcbc..d61beff 100644
@@ -174,29 +174,22 @@ nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data, u32 size)
 	} *args = data;
 	struct nvkm_device *device = nv_device(object);
 	struct nvkm_pm *ppm = (void *)object->engine;
-	struct nvkm_perfdom *dom = NULL, *chk;
+	struct nvkm_perfdom *dom;
 	const bool all = nvkm_boolopt(device->cfgopt, "NvPmShowAll", false);
 	const bool raw = nvkm_boolopt(device->cfgopt, "NvPmUnnamed", all);
 	const char *name;
-	int tmp = 0, di, si;
-	int ret;
+	int ret, si;
 
 	nv_ioctl(object, "perfmon query signal size %d\n", size);
 	if (nvif_unpack(args->v0, 0, 0, false)) {
-		nv_ioctl(object, "perfmon query signal vers %d iter %08x\n",
-			 args->v0.version, args->v0.iter);
-		di = (args->v0.iter & 0xff000000) >> 24;
-		si = (args->v0.iter & 0x00ffffff) - 1;
+		nv_ioctl(object,
+			 "perfmon query signal vers %d dom %d iter %08x\n",
+			 args->v0.version, args->v0.domain, args->v0.iter);
+		si = (args->v0.iter & 0xffffffff) - 1;
 	} else
 		return ret;
 
-	list_for_each_entry(chk, &ppm->domains, head) {
-		if (tmp++ == di) {
-			dom = chk;
-			break;
-		}
-	}
-
+	dom = nvkm_perfdom_find(ppm, args->v0.domain);
 	if (dom == NULL || si >= (int)dom->signal_nr)
 		return -EINVAL;
 
@@ -209,17 +202,12 @@ nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data, u32 size)
 		}
 	}
 
-	do {
-		while (++si < dom->signal_nr) {
-			if (all || dom->signal[si].name) {
-				args->v0.iter = (di << 24) | ++si;
-				return 0;
-			}
+	while (++si < dom->signal_nr) {
+		if (all || dom->signal[si].name) {
+			args->v0.iter = ++si;
+			return 0;
 		}
-		si = -1;
-		di = di + 1;
-		dom = list_entry(dom->head.next, typeof(*dom), head);
-	} while (&dom->head != &ppm->domains);
+	}
 
 	args->v0.iter = 0xffffffff;
 	return 0;
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#18 lore raw

RFC PATCH 9/20 pm: change signal iter to u16

In reply to a message not in the archive

16 bits is large enough to store the maximum number of signals available for one domain (i.e. 256).

---
 bin/nv_perfmon.c                  |  4 ++--
 drm/nouveau/include/nvif/class.h  |  7 ++++---
 drm/nouveau/nvkm/engine/pm/base.c | 10 +++++-----
 drm/nouveau/nvkm/engine/pm/priv.h |  2 +-
 4 files changed, 12 insertions(+), 11 deletions(-)
bin/nv_perfmon.c +2 -2
index 958520e..043d864 100644
@@ -289,7 +289,7 @@ ui_perfmon_query_signals(struct nvif_object *perfmon,
 
 	args.domain = dom->id;
 	do {
-		u32 prev_iter = args.iter;
+		u16 prev_iter = args.iter;
 
 		args.name[0] = '\0';
 		ret = nvif_mthd(perfmon, NVIF_PERFMON_V0_QUERY_SIGNAL,
@@ -308,7 +308,7 @@ ui_perfmon_query_signals(struct nvif_object *perfmon,
 					&args, sizeof(args));
 			assert(ret == 0);
 		}
-	} while (args.iter != 0xffffffff);
+	} while (args.iter != 0xffff);
 }
 
 static void
drm/nouveau/include/nvif/class.h +4 -3
index cf2af89..871247c 100644
@@ -259,14 +259,15 @@ struct nvif_perfmon_query_domain_v0 {
 	__u8  id;
 	__u8  counter_nr;
 	__u8  iter;
-	__u32 signal_nr;
+	__u16 signal_nr;
+	__u8  pad05[2];
 };
 
 struct nvif_perfmon_query_signal_v0 {
 	__u8  version;
 	__u8  domain;
-	__u8  pad02[2];
-	__u32 iter;
+	__u16 iter;
+	__u8  pad03[4];
 	char  name[64];
 };
 
drm/nouveau/nvkm/engine/pm/base.c +5 -5
index d61beff..fab0598 100644
@@ -45,10 +45,10 @@ nvkm_pm_count_perfdom(struct nvkm_pm *ppm)
 	return domain_nr;
 }
 
-static u32
+static u16
 nvkm_perfdom_count_perfsig(struct nvkm_perfdom *dom)
 {
-	u32 signal_nr = 0;
+	u16 signal_nr = 0;
 	int i;
 
 	if (dom) {
@@ -183,9 +183,9 @@ nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data, u32 size)
 	nv_ioctl(object, "perfmon query signal size %d\n", size);
 	if (nvif_unpack(args->v0, 0, 0, false)) {
 		nv_ioctl(object,
-			 "perfmon query signal vers %d dom %d iter %08x\n",
+			 "perfmon query signal vers %d dom %d iter %04x\n",
 			 args->v0.version, args->v0.domain, args->v0.iter);
-		si = (args->v0.iter & 0xffffffff) - 1;
+		si = (args->v0.iter & 0xffff) - 1;
 	} else
 		return ret;
 
@@ -209,7 +209,7 @@ nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data, u32 size)
 		}
 	}
 
-	args->v0.iter = 0xffffffff;
+	args->v0.iter = 0xffff;
 	return 0;
 }
 
drm/nouveau/nvkm/engine/pm/priv.h +1 -1
index 06a6e60..71667fc 100644
@@ -44,7 +44,7 @@ struct nvkm_perfdom {
 	char name[32];
 	u32 addr;
 	u8  quad;
-	u32 signal_nr;
+	u16 signal_nr;
 	struct nvkm_perfsig signal[];
 };
 
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#19 lore raw

RFC PATCH 10/20 pm: use hardware signals indexes instead of user-readable names

In reply to a message not in the archive
---
 bin/nv_perfmon.c                  |  6 +++--
 drm/nouveau/include/nvif/class.h  | 11 ++++++---
 drm/nouveau/nvkm/engine/pm/base.c | 52 +++++++++------------------------------
 3 files changed, 23 insertions(+), 46 deletions(-)
bin/nv_perfmon.c +4 -2
index 043d864..50c7777 100644
@@ -255,6 +255,7 @@ struct ui_perfmon_dom {
 struct ui_perfmon_sig {
 	struct list_head head;
 	char *name;
+	u8 signal;
 };
 
 struct ui_main {
@@ -299,6 +300,7 @@ ui_perfmon_query_signals(struct nvif_object *perfmon,
 		if (prev_iter) {
 			nr_signals++;
 			sig = calloc(1, sizeof(*sig));
+			sig->signal = args.signal;
 			sig->name = malloc(sizeof(args.name));
 			strncpy(sig->name, args.name, sizeof(args.name));
 			list_add_tail(&sig->head, &dom->list);
@@ -392,14 +394,14 @@ ui_main_select(void)
 		list_for_each_entry(sig, &dom->list, head) {
 			struct nvif_perfctr_v0 args = {
 				.logic_op = 0xaaaa,
+				.domain = dom->id,
 			};
 
 			item = calloc(1, sizeof(*item));
 			item->handle = ui_main_handle++;
 			item->name = sig->name;
 
-			strncpy(args.name[0], item->name, sizeof(args.name[0]));
-
+			args.signal[0] = sig->signal;
 			ret = nvif_object_init(nvif_object(device), NULL,
 					       item->handle,
 					       NVIF_IOCTL_NEW_V0_PERFCTR,
drm/nouveau/include/nvif/class.h +7 -4
index 871247c..9e4db3a 100644
@@ -267,7 +267,8 @@ struct nvif_perfmon_query_signal_v0 {
 	__u8  version;
 	__u8  domain;
 	__u16 iter;
-	__u8  pad03[4];
+	__u8  signal;
+	__u8  pad04[3];
 	char  name[64];
 };
 
@@ -278,10 +279,12 @@ struct nvif_perfmon_query_signal_v0 {
 
 struct nvif_perfctr_v0 {
 	__u8  version;
-	__u8  pad01[1];
+	__u8  domain;
+	__u8  pad02[2];
 	__u16 logic_op;
-	__u8  pad04[4];
-	char  name[4][64];
+	__u8  pad04[2];
+	__u8  signal[4];
+	__u8  pad06[4];
 };
 
 #define NVIF_PERFCTR_V0_SAMPLE                                             0x00
drm/nouveau/nvkm/engine/pm/base.c +12 -40

78 lines not on this page · raw message

Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#20 lore raw

RFC PATCH 11/20 pm: allow to monitor hardware signal index 0x00

In reply to a message not in the archive

This signal index must be always allowed even if it's not clearly defined in a domain in order to monitor a counter like 0x03020100 because it's the default value of signals.

---
 drm/nouveau/nvkm/engine/pm/base.c  | 4 ++--
 drm/nouveau/nvkm/engine/pm/gf100.c | 6 ++++--
 drm/nouveau/nvkm/engine/pm/nv40.c  | 6 ++++--
 3 files changed, 10 insertions(+), 6 deletions(-)
drm/nouveau/nvkm/engine/pm/base.c +2 -2
index 71834b9..610c0ca 100644
@@ -333,10 +333,10 @@ nvkm_perfctr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 	} else
 		return ret;
 
-	for (i = 0; i < ARRAY_SIZE(args->v0.signal) && args->v0.signal[i]; i++) {
+	for (i = 0; i < ARRAY_SIZE(args->v0.signal); i++) {
 		sig[i] = nvkm_perfsig_find(ppm, args->v0.domain,
 					   args->v0.signal[i], &dom);
-		if (!sig[i])
+		if (args->v0.signal[i] && !sig[i])
 			return -EINVAL;
 	}
 
drm/nouveau/nvkm/engine/pm/gf100.c +4 -2
index 69303b5..41350d6 100644
@@ -48,8 +48,10 @@ gf100_perfctr_init(struct nvkm_pm *ppm, struct nvkm_perfdom *dom,
 	u32 src = 0x00000000;
 	int i;
 
-	for (i = 0; i < 4 && ctr->signal[i]; i++)
-		src |= (ctr->signal[i] - dom->signal) << (i * 8);
+	for (i = 0; i < 4; i++) {
+		if (ctr->signal[i])
+			src |= (ctr->signal[i] - dom->signal) << (i * 8);
+	}
 
 	nv_wr32(priv, dom->addr + 0x09c, 0x00040002);
 	nv_wr32(priv, dom->addr + 0x100, 0x00000000);
drm/nouveau/nvkm/engine/pm/nv40.c +4 -2
index ff22f06..603874e 100644
@@ -33,8 +33,10 @@ nv40_perfctr_init(struct nvkm_pm *ppm, struct nvkm_perfdom *dom,
 	u32 src = 0x00000000;
 	int i;
 
-	for (i = 0; i < 4 && ctr->signal[i]; i++)
-		src |= (ctr->signal[i] - dom->signal) << (i * 8);
+	for (i = 0; i < 4; i++) {
+		if (ctr->signal[i])
+			src |= (ctr->signal[i] - dom->signal) << (i * 8);
+	}
 
 	nv_wr32(priv, 0x00a7c0 + dom->addr, 0x00000001);
 	nv_wr32(priv, 0x00a400 + dom->addr + (cntr->base.slot * 0x40), src);
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#21 lore raw

RFC PATCH 12/20 pm: add concept of sources

In reply to a message not in the archive

From: Samuel Pitoiset <samuel.pitoisetœgmail.com>

A source (or multiplexer) is a tuple addr+mask+shift which allows to control a block of signals. The maximum number of sources that a signal can define is arbitrary limited to 8 and this should be large enough. This patch allows to define multi-level of sources for a signal.

Each different sources are stored to a global list and will be exposed to the userspace through the nvif interface in order to avoid conflicts.

Signed-off-by Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 drm/nouveau/include/nvkm/engine/pm.h |  1 +
 drm/nouveau/nvkm/engine/pm/base.c    | 82 ++++++++++++++++++++++++++++++++++--
 drm/nouveau/nvkm/engine/pm/priv.h    | 24 +++++++++++
 3 files changed, 103 insertions(+), 4 deletions(-)
drm/nouveau/include/nvkm/engine/pm.h +1 -0
index 6c2d057..130b545 100644
@@ -11,6 +11,7 @@ struct nvkm_pm {
 	void *profile_data;
 
 	struct list_head domains;
+	struct list_head sources;
 	u32 sequence;
 };
 
drm/nouveau/nvkm/engine/pm/base.c +78 -4

116 lines not on this page · raw message

drm/nouveau/nvkm/engine/pm/priv.h +24 -0
index 71667fc..f954c98 100644
@@ -22,13 +22,37 @@ struct nvkm_perfctx {
 
 extern struct nvkm_oclass nvkm_pm_cclass;
 
+struct nvkm_specmux {
+	u32 mask;
+	u8 shift;
+	const char *name;
+	bool enable;
+};
+
+struct nvkm_specsrc {
+	u32 addr;
+	const struct nvkm_specmux *mux;
+	const char *name;
+};
+
+struct nvkm_perfsrc {
+	struct list_head head;
+	char *name;
+	u32 addr;
+	u32 mask;
+	u8 shift;
+	bool enable;
+};
+
 struct nvkm_specsig {
 	u8 signal;
 	const char *name;
+	const struct nvkm_specsrc *source;
 };
 
 struct nvkm_perfsig {
 	const char *name;
+	u8 source[8];
 };
 
 struct nvkm_specdom {
Signature · 1 line
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#22 lore raw

RFC PATCH 13/20 pm: allow to query the number of sources for a signal

In reply to a message not in the archive
---
 drm/nouveau/include/nvif/class.h  |  3 ++-
 drm/nouveau/nvkm/engine/pm/base.c | 22 +++++++++++++++++++---
 2 files changed, 21 insertions(+), 4 deletions(-)
drm/nouveau/include/nvif/class.h +2 -1
index 9e4db3a..caae193 100644
@@ -268,7 +268,8 @@ struct nvif_perfmon_query_signal_v0 {
 	__u8  domain;
 	__u16 iter;
 	__u8  signal;
-	__u8  pad04[3];
+	__u8  source_nr;
+	__u8  pad05[2];
 	char  name[64];
 };
 
drm/nouveau/nvkm/engine/pm/base.c +19 -3
index dfafefd..a9c57a2 100644
@@ -91,6 +91,18 @@ nvkm_perfsig_find(struct nvkm_pm *ppm, uint8_t di, uint8_t si,
 	return &dom->signal[si];
 }
 
+static u8
+nvkm_perfsig_count_perfsrc(struct nvkm_perfsig *sig)
+{
+	u8 source_nr = 0, i;
+
+	for (i = 0; i < ARRAY_SIZE(sig->source); i++) {
+		if (sig->source[i])
+			source_nr++;
+	}
+	return source_nr;
+}
+
 /*******************************************************************************
  * Perfmon object classes
  ******************************************************************************/
@@ -148,9 +160,9 @@ nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data, u32 size)
 	struct nvkm_device *device = nv_device(object);
 	struct nvkm_pm *ppm = (void *)object->engine;
 	struct nvkm_perfdom *dom;
+	struct nvkm_perfsig *sig;
 	const bool all = nvkm_boolopt(device->cfgopt, "NvPmShowAll", false);
 	const bool raw = nvkm_boolopt(device->cfgopt, "NvPmUnnamed", all);
-	const char *name;
 	int ret, si;
 
 	nv_ioctl(object, "perfmon query signal size %d\n", size);
@@ -167,13 +179,17 @@ nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data, u32 size)
 		return -EINVAL;
 
 	if (si >= 0) {
-		if (raw || !(name = dom->signal[si].name)) {
+		sig = &dom->signal[si];
+		if (raw || !sig->name) {
 			snprintf(args->v0.name, sizeof(args->v0.name),
 				 "/%s/%02x", dom->name, si);
 		} else {
-			strncpy(args->v0.name, name, sizeof(args->v0.name));
+			strncpy(args->v0.name, sig->name,
+				sizeof(args->v0.name));
 		}
+
 		args->v0.signal = si;
+		args->v0.source_nr = nvkm_perfsig_count_perfsrc(sig);
 	}
 
 	while (++si < dom->signal_nr) {
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#23 lore raw

RFC PATCH 14/20 pm: implement NVIF_PERFMON_V0_QUERY_SOURCE method

In reply to a message not in the archive

This allows to query the ID, the mask and the user-readable name of sources for each signal.

---
 drm/nouveau/include/nvif/class.h  | 12 ++++++
 drm/nouveau/nvkm/engine/pm/base.c | 77 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+)
drm/nouveau/include/nvif/class.h +12 -0
index caae193..d85fb0d 100644
@@ -253,6 +253,7 @@ struct gf110_dma_v0 {
 
 #define NVIF_PERFMON_V0_QUERY_DOMAIN                                       0x00
 #define NVIF_PERFMON_V0_QUERY_SIGNAL                                       0x01
+#define NVIF_PERFMON_V0_QUERY_SOURCE                                       0x02
 
 struct nvif_perfmon_query_domain_v0 {
 	__u8  version;
@@ -273,6 +274,17 @@ struct nvif_perfmon_query_signal_v0 {
 	char  name[64];
 };
 
+struct nvif_perfmon_query_source_v0 {
+	__u8  version;
+	__u8  domain;
+	__u8  signal;
+	__u8  iter;
+	__u8  pad04[4];
+	__u32 source;
+	__u32 mask;
+	char  name[64];
+};
+
 
 /*******************************************************************************
  * perfctr
drm/nouveau/nvkm/engine/pm/base.c +77 -0

95 lines not on this page · raw message

Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#24 lore raw

RFC PATCH 15/20 pm: allow the userspace to schedule hardware counters

In reply to a message not in the archive

This adds a new method NVIF_PERFCTR_V0_INIT which starts a batch of hardware counters for sampling. This will allow the userspace to start a monitoring session using the INIT method and to stop it with SAMPLE, for example before and after a frame is rendered.

This commit temporarily breaks nv_perfmon but this is going to be fixed with the upcoming patch.

---
 drm/nouveau/include/nvif/class.h  |  8 +++--
 drm/nouveau/nvkm/engine/pm/base.c | 64 +++++++++++++++++++++++++--------------
 drm/nouveau/nvkm/engine/pm/priv.h |  1 +
 3 files changed, 48 insertions(+), 25 deletions(-)
drm/nouveau/include/nvif/class.h +6 -2
index d85fb0d..528eac8 100644
@@ -300,8 +300,12 @@ struct nvif_perfctr_v0 {
 	__u8  pad06[4];
 };
 
-#define NVIF_PERFCTR_V0_SAMPLE                                             0x00
-#define NVIF_PERFCTR_V0_READ                                               0x01
+#define NVIF_PERFCTR_V0_INIT                                               0x00
+#define NVIF_PERFCTR_V0_SAMPLE                                             0x01
+#define NVIF_PERFCTR_V0_READ                                               0x02
+
+struct nvif_perfctr_init {
+};
 
 struct nvif_perfctr_sample {
 };
drm/nouveau/nvkm/engine/pm/base.c +41 -23

104 lines not on this page · raw message

drm/nouveau/nvkm/engine/pm/priv.h +1 -0
index f954c98..4ed77ff 100644
@@ -6,6 +6,7 @@ struct nvkm_perfctr {
 	struct nvkm_object base;
 	struct list_head head;
 	struct nvkm_perfsig *signal[4];
+	struct nvkm_perfdom *dom;
 	int slot;
 	u32 logic_op;
 	u32 clk;
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#25 lore raw

RFC PATCH 16/20 pm: allow to configure domains instead of simple counters

In reply to a message not in the archive

Configuring counters from the userspace require the kernel to handle some logic related to performance counters. Basically, it has to find a free slot to assign a counter, to handle extra counting modes like B4/B6 and it must return and error when it can't configure a counter.

In my opinion, the kernel should not handle all of that logic but it should only write the configuration sent by the userspace without checking anything. In other words, it should overwrite the configuration even if it's already counting and do not return any errors.

This patch allows the userspace to configure a domain instead of separate counters. This has the advantage to move all of the logic to the userspace.

---
 bin/nv_perfmon.c                   | 193 ++++++++++++++++++++++++++--------
 drm/nouveau/include/nvif/class.h   |  30 +++---
 drm/nouveau/include/nvif/ioctl.h   |   2 +-
 drm/nouveau/nvkm/engine/pm/base.c  | 208 +++++++++++++++++++++----------------
 drm/nouveau/nvkm/engine/pm/gf100.c |  10 +-
 drm/nouveau/nvkm/engine/pm/nv40.c  |  10 +-
 drm/nouveau/nvkm/engine/pm/priv.h  |  10 +-
 7 files changed, 293 insertions(+), 170 deletions(-)
bin/nv_perfmon.c +147 -46
index 50c7777..47b2fef 100644
@@ -248,7 +248,8 @@ ui_menu_win = {
 
 struct ui_perfmon_dom {
 	struct list_head head;
-	struct list_head list;
+	struct list_head signals;
+	struct list_head perfdoms;
 	u8 id;
 };
 
@@ -260,22 +261,27 @@ struct ui_perfmon_sig {
 
 struct ui_main {
 	struct list_head head;
-	u32 handle;
-	struct nvif_object object;
-	const char *name;
+	struct ui_perfmon_sig *sig;
 	u32 clk;
 	u32 ctr;
 	u64 incr;
 };
 
+struct ui_perfdom {
+	struct nvif_object object;
+	struct list_head head;
+	struct ui_main *ctr[4];
+	u32 handle;
+};
+
 static struct list_head ui_main_list = LIST_HEAD_INIT(ui_main_list);
 static struct list_head ui_doms_list = LIST_HEAD_INIT(ui_doms_list);
+static struct list_head ui_perfdom_list = LIST_HEAD_INIT(ui_perfdom_list);
 static u32 ui_main_handle = 0xc0000000;
 
 static void
 ui_main_remove(struct ui_main *item)
 {
-	nvif_object_fini(&item->object);
 	list_del(&item->head);
 	free(item);
 }
@@ -303,7 +309,7 @@ ui_perfmon_query_signals(struct nvif_object *perfmon,
 			sig->signal = args.signal;
 			sig->name = malloc(sizeof(args.name));
 			strncpy(sig->name, args.name, sizeof(args.name));
-			list_add_tail(&sig->head, &dom->list);
+			list_add_tail(&sig->head, &dom->signals);
 
 			args.iter = prev_iter;
 			ret = nvif_mthd(perfmon, NVIF_PERFMON_V0_QUERY_SIGNAL,
@@ -331,7 +337,8 @@ ui_perfmon_query_domains(struct nvif_object *perfmon)
 		if (prev_iter) {
 			dom = calloc(1, sizeof(*dom));
 			dom->id = args.id;
-			INIT_LIST_HEAD(&dom->list);
+			INIT_LIST_HEAD(&dom->signals);
+			INIT_LIST_HEAD(&dom->perfdoms);
 			list_add_tail(&dom->head, &ui_doms_list);
 
 			args.iter = prev_iter;
@@ -346,6 +353,49 @@ ui_perfmon_query_domains(struct nvif_object *perfmon)
 }
 
 static void
+ui_perfdom_init(struct ui_perfdom *dom)
+{
+	struct nvif_perfdom_init args = {};
+	int ret;
+
+	ret = nvif_mthd(&dom->object, NVIF_PERFDOM_V0_INIT,
+			&args, sizeof(args));
+	assert(ret == 0);
+}
+
+static void
+ui_perfdom_sample(struct ui_perfdom *dom)
+{
+	struct nvif_perfdom_sample args = {};
+	int ret;
+
+	ret = nvif_mthd(&dom->object, NVIF_PERFDOM_V0_SAMPLE,
+			&args, sizeof(args));
+	assert(ret == 0);
+}
+
+static void
+ui_perfdom_read(struct ui_perfdom *dom)
+{
+	struct nvif_perfdom_read_v0 args = {};
+	int ret, i;
+
+	ret = nvif_mthd(&dom->object, NVIF_PERFDOM_V0_READ,
+			&args, sizeof(args));
+	assert(ret == 0 || ret == -EAGAIN);
+
+	if (ret == 0) {
+		for (i = 0; i < 4; i++) {
+			if (!dom->ctr[i])
+				continue;
+			dom->ctr[i]->ctr   = args.ctr[i];
+			dom->ctr[i]->incr += args.ctr[i];
+			dom->ctr[i]->clk   = args.clk;
+		}
+	}
+}
+
+static void
 ui_perfmon_init(void)
 {
 	struct nvif_object perfmon;
@@ -362,17 +412,37 @@ ui_perfmon_init(void)
 }
 
 static void
+ui_perfmon_free_signals(struct ui_perfmon_dom *dom)
+{
+	struct ui_perfmon_sig *sig, *next;
+
+	list_for_each_entry_safe(sig, next, &dom->signals, head) {
+		list_del(&sig->head);
+		free(sig->name);
+		free(sig);
+	}
+}
+
+static void
+ui_perfmon_free_perfdoms(struct ui_perfmon_dom *dom)
+{
+	struct ui_perfdom *perfdom, *next;
+
+	list_for_each_entry_safe(perfdom, next, &dom->perfdoms, head) {
+		nvif_object_fini(&perfdom->object);
+		list_del(&perfdom->head);
+		free(perfdom);
+	}
+}
+
+static void
 ui_perfmon_fini(void)
 {
-	struct ui_perfmon_dom *dom, *next_dom;
-	struct ui_perfmon_sig *sig, *next_sig;
-
-	list_for_each_entry_safe(dom, next_dom, &ui_doms_list, head) {
-		list_for_each_entry_safe(sig, next_sig, &dom->list, head) {
-			list_del(&sig->head);
-			free(sig->name);
-			free(sig);
-		}
+	struct ui_perfmon_dom *dom, *next;
+
+	list_for_each_entry_safe(dom, next, &ui_doms_list, head) {
+		ui_perfmon_free_perfdoms(dom);
+		ui_perfmon_free_signals(dom);
 		list_del(&dom->head);
 		free(dom);
 	}
@@ -384,31 +454,62 @@ ui_main_select(void)
 	struct ui_main *item, *temp;
 	struct ui_perfmon_dom *dom;
 	struct ui_perfmon_sig *sig;
+	struct ui_perfdom *perfdom;
 	int ret;
+	int i;
 
 	list_for_each_entry_safe(item, temp, &ui_main_list, head) {
 		ui_main_remove(item);
 	}
 
 	list_for_each_entry(dom, &ui_doms_list, head) {
-		list_for_each_entry(sig, &dom->list, head) {
-			struct nvif_perfctr_v0 args = {
-				.logic_op = 0xaaaa,
-				.domain = dom->id,
-			};
+		list_for_each_entry(sig, &dom->signals, head) {
+			bool found = false;
 
 			item = calloc(1, sizeof(*item));
-			item->handle = ui_main_handle++;
-			item->name = sig->name;
+			item->sig = sig;
+			list_add_tail(&item->head, &ui_main_list);
+
+			/* find a slot */
+			list_for_each_entry(perfdom, &dom->perfdoms, head) {
+				for (i = 0; i < 4; i++) {
+					if (!perfdom->ctr[i]) {
+						perfdom->ctr[i] = item;
+						found = true;
+						break;
+					}
+				}
+			}
+
+			if (!found) {
+				/* no free slots, create a new perfdom */
+				perfdom = calloc(1, sizeof(*perfdom));
+				perfdom->handle = ui_main_handle++;
+				perfdom->ctr[0] = item;
+				list_add_tail(&perfdom->head, &dom->perfdoms);
+			}
+		}
+
+		/* init perfdom objects */
+		list_for_each_entry(perfdom, &dom->perfdoms, head) {
+			struct nvif_perfdom_v0 args = {};
+			int i;
+
+			args.domain = dom->id;
+			for (i = 0; i < 4; i++) {
+				struct ui_main *ctr = perfdom->ctr[i];
+				if (!ctr)
+					continue;
+				args.ctr[i].signal[0] = ctr->sig->signal;
+				args.ctr[i].logic_op  = 0xaaaa;
+			}
 
-			args.signal[0] = sig->signal;
 			ret = nvif_object_init(nvif_object(device), NULL,
-					       item->handle,
-					       NVIF_IOCTL_NEW_V0_PERFCTR,
+					       perfdom->handle,
+					       NVIF_IOCTL_NEW_V0_PERFDOM,
 					       &args, sizeof(args),
-					       &item->object);
+					       &perfdom->object);
 			assert(ret == 0);
-			list_add_tail(&item->head, &ui_main_list);
 		}
 	}
 }
@@ -416,34 +517,34 @@ ui_main_select(void)
 static void
 ui_main_alarm_handler(int signal)
 {
-	struct ui_main *item;
+	struct ui_perfmon_dom *dom;
+	struct ui_perfdom *perfdom;
 	bool sampled = false;
 
 	if (list_empty(&ui_main_list))
 		ui_main_select();
 
-	list_for_each_entry(item, &ui_main_list, head) {
-		struct nvif_perfctr_read_v0 args = {};
-		int ret;
+	list_for_each_entry(dom, &ui_doms_list, head) {
+		if (list_empty(&dom->perfdoms))
+			continue;
 
-		if (!sampled) {
-			struct nvif_perfctr_sample args = {};
+		perfdom = list_first_entry(&dom->perfdoms,
+					   typeof(*perfdom), head);
 
-			ret = nvif_mthd(&item->object, NVIF_PERFCTR_V0_SAMPLE,
-					&args, sizeof(args));
-			assert(ret == 0);
+		/* sample previous batch of counters */
+		if (!sampled) {
+			ui_perfdom_sample(perfdom);
 			sampled = true;
 		}
 
-		ret = nvif_mthd(&item->object, NVIF_PERFCTR_V0_READ,
-				&args, sizeof(args));
-		assert(ret == 0 || ret == -EAGAIN);
+		/* read previous batch of counters */
+		ui_perfdom_read(perfdom);
 
-		if (ret == 0) {
-			item->clk = args.clk;
-			item->ctr = args.ctr;
-		}
-		item->incr += item->ctr;
+		/* setup next batch of counters for sampling */
+		list_move_tail(&perfdom->head, &dom->perfdoms);
+		perfdom = list_first_entry(&dom->perfdoms,
+					   typeof(*perfdom), head);
+		ui_perfdom_init(perfdom);
 	}
 }
 
@@ -485,7 +586,7 @@ ui_main_redraw(struct ui_table *t)
 
 	y = 2;
 	list_for_each_entry_from(item, &ui_main_list, head) {
-		set_field_buffer(f[0], 0, item->name);
+		set_field_buffer(f[0], 0, item->sig->name);
 		set_field_userptr(f[0], item);
 		field_opts_on(f[0], O_VISIBLE | O_ACTIVE);
 
drm/nouveau/include/nvif/class.h +16 -14
index 528eac8..1a76a7f 100644
@@ -287,34 +287,36 @@ struct nvif_perfmon_query_source_v0 {
 
 
 /*******************************************************************************
- * perfctr
+ * perfdom
  ******************************************************************************/
 
-struct nvif_perfctr_v0 {
+struct nvif_perfdom_v0 {
 	__u8  version;
 	__u8  domain;
-	__u8  pad02[2];
-	__u16 logic_op;
-	__u8  pad04[2];
-	__u8  signal[4];
-	__u8  pad06[4];
+	__u8  mode;
+	__u8  pad03[1];
+	struct {
+		__u8  signal[4];
+		__u16 logic_op;
+	} ctr[4];
 };
 
-#define NVIF_PERFCTR_V0_INIT                                               0x00
-#define NVIF_PERFCTR_V0_SAMPLE                                             0x01
-#define NVIF_PERFCTR_V0_READ                                               0x02
+#define NVIF_PERFDOM_V0_INIT                                               0x00
+#define NVIF_PERFDOM_V0_SAMPLE                                             0x01
+#define NVIF_PERFDOM_V0_READ                                               0x02
 
-struct nvif_perfctr_init {
+struct nvif_perfdom_init {
 };
 
-struct nvif_perfctr_sample {
+struct nvif_perfdom_sample {
 };
 
-struct nvif_perfctr_read_v0 {
+struct nvif_perfdom_read_v0 {
 	__u8  version;
 	__u8  pad01[7];
-	__u32 ctr;
+	__u32 ctr[4];
 	__u32 clk;
+	__u8  pad04[4];
 };
 
 
drm/nouveau/include/nvif/ioctl.h +1 -1
index 517cd27..2eb9b89 100644
@@ -50,7 +50,7 @@ struct nvif_ioctl_new_v0 {
 	__u32 handle;
 /* these class numbers are made up by us, and not nvidia-assigned */
 #define NVIF_IOCTL_NEW_V0_PERFMON                                    0x0000ffff
-#define NVIF_IOCTL_NEW_V0_PERFCTR                                    0x0000fffe
+#define NVIF_IOCTL_NEW_V0_PERFDOM                                    0x0000fffe
 #define NVIF_IOCTL_NEW_V0_CONTROL                                    0x0000fffd
 	__u32 oclass;
 	__u8  data[];		/* class data (class.h) */
drm/nouveau/nvkm/engine/pm/base.c +116 -92

316 lines not on this page · raw message

drm/nouveau/nvkm/engine/pm/gf100.c +4 -6
index 41350d6..edab97a 100644
@@ -48,12 +48,10 @@ gf100_perfctr_init(struct nvkm_pm *ppm, struct nvkm_perfdom *dom,
 	u32 src = 0x00000000;
 	int i;
 
-	for (i = 0; i < 4; i++) {
-		if (ctr->signal[i])
-			src |= (ctr->signal[i] - dom->signal) << (i * 8);
-	}
+	for (i = 0; i < 4; i++)
+		src |= ctr->signal[i] << (i * 8);
 
-	nv_wr32(priv, dom->addr + 0x09c, 0x00040002);
+	nv_wr32(priv, dom->addr + 0x09c, 0x00040002 | (dom->mode << 3));
 	nv_wr32(priv, dom->addr + 0x100, 0x00000000);
 	nv_wr32(priv, dom->addr + 0x040 + (cntr->base.slot * 0x08), src);
 	nv_wr32(priv, dom->addr + 0x044 + (cntr->base.slot * 0x08), log);
@@ -72,7 +70,7 @@ gf100_perfctr_read(struct nvkm_pm *ppm, struct nvkm_perfdom *dom,
 	case 2: cntr->base.ctr = nv_rd32(priv, dom->addr + 0x080); break;
 	case 3: cntr->base.ctr = nv_rd32(priv, dom->addr + 0x090); break;
 	}
-	cntr->base.clk = nv_rd32(priv, dom->addr + 0x070);
+	dom->clk = nv_rd32(priv, dom->addr + 0x070);
 }
 
 static void
drm/nouveau/nvkm/engine/pm/nv40.c +4 -6
index 603874e..1c6d1ca 100644
@@ -33,12 +33,10 @@ nv40_perfctr_init(struct nvkm_pm *ppm, struct nvkm_perfdom *dom,
 	u32 src = 0x00000000;
 	int i;
 
-	for (i = 0; i < 4; i++) {
-		if (ctr->signal[i])
-			src |= (ctr->signal[i] - dom->signal) << (i * 8);
-	}
+	for (i = 0; i < 4; i++)
+		src |= ctr->signal[i] << (i * 8);
 
-	nv_wr32(priv, 0x00a7c0 + dom->addr, 0x00000001);
+	nv_wr32(priv, 0x00a7c0 + dom->addr, 0x00000001 | (dom->mode << 4));
 	nv_wr32(priv, 0x00a400 + dom->addr + (cntr->base.slot * 0x40), src);
 	nv_wr32(priv, 0x00a420 + dom->addr + (cntr->base.slot * 0x40), log);
 }
@@ -56,7 +54,7 @@ nv40_perfctr_read(struct nvkm_pm *ppm, struct nvkm_perfdom *dom,
 	case 2: cntr->base.ctr = nv_rd32(priv, 0x00a680 + dom->addr); break;
 	case 3: cntr->base.ctr = nv_rd32(priv, 0x00a740 + dom->addr); break;
 	}
-	cntr->base.clk = nv_rd32(priv, 0x00a600 + dom->addr);
+	dom->clk = nv_rd32(priv, 0x00a600 + dom->addr);
 }
 
 static void
drm/nouveau/nvkm/engine/pm/priv.h +5 -5
index 4ed77ff..38adeb7 100644
@@ -3,13 +3,10 @@
 #include <engine/pm.h>
 
 struct nvkm_perfctr {
-	struct nvkm_object base;
 	struct list_head head;
-	struct nvkm_perfsig *signal[4];
-	struct nvkm_perfdom *dom;
+	u8  signal[4];
 	int slot;
 	u32 logic_op;
-	u32 clk;
 	u32 ctr;
 };
 
@@ -63,12 +60,15 @@ struct nvkm_specdom {
 };
 
 struct nvkm_perfdom {
+	struct nvkm_object base;
 	struct list_head head;
 	struct list_head list;
 	const struct nvkm_funcdom *func;
+	struct nvkm_perfctr *ctr[4];
 	char name[32];
 	u32 addr;
-	u8  quad;
+	u8  mode;
+	u32 clk;
 	u16 signal_nr;
 	struct nvkm_perfsig signal[];
 };
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#26 lore raw

RFC PATCH 17/20 pm: allow the userspace to configure sources

In reply to a message not in the archive
Signed-off-by Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 drm/nouveau/include/nvif/class.h  |   1 +
 drm/nouveau/nvkm/engine/pm/base.c | 102 ++++++++++++++++++++++++++++++++++----
 drm/nouveau/nvkm/engine/pm/priv.h |   2 +
 3 files changed, 95 insertions(+), 10 deletions(-)
drm/nouveau/include/nvif/class.h +1 -0
index 1a76a7f..3b7f49f 100644
@@ -297,6 +297,7 @@ struct nvif_perfdom_v0 {
 	__u8  pad03[1];
 	struct {
 		__u8  signal[4];
+		__u64 source[4][8];
 		__u16 logic_op;
 	} ctr[4];
 };
drm/nouveau/nvkm/engine/pm/base.c +92 -10

165 lines not on this page · raw message

drm/nouveau/nvkm/engine/pm/priv.h +2 -0
index 38adeb7..da419c1 100644
@@ -4,7 +4,9 @@
 
 struct nvkm_perfctr {
 	struct list_head head;
+	u8 domain;
 	u8  signal[4];
+	u64 source[4][8];
 	int slot;
 	u32 logic_op;
 	u32 ctr;
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#27 lore raw

RFC PATCH 18/20 pm/nv50: add compute and graphics signals/sources

In reply to a message not in the archive

These signals and sources have been reverse engineered from NVIDIA PerfKit (Windows) and CUPTI (Linux), they will be used to build complex hardware events from the userspace.

This commit also adds a new class for GT200.

---
 drm/nouveau/include/nvkm/engine/pm.h  |   1 +
 drm/nouveau/nvkm/engine/device/nv50.c |   2 +-
 drm/nouveau/nvkm/engine/pm/Kbuild     |   1 +
 drm/nouveau/nvkm/engine/pm/g84.c      | 101 ++++++++++++++++++++-
 drm/nouveau/nvkm/engine/pm/gt200.c    | 163 ++++++++++++++++++++++++++++++++++
 drm/nouveau/nvkm/engine/pm/gt215.c    |  84 +++++++++++++++++-
 drm/nouveau/nvkm/engine/pm/nv50.c     | 136 ++++++++++++++++++++++++++--
 drm/nouveau/nvkm/engine/pm/priv.h     |   8 ++
 8 files changed, 485 insertions(+), 11 deletions(-)
 create mode 100644 drm/nouveau/nvkm/engine/pm/gt200.c
drm/nouveau/include/nvkm/engine/pm.h +1 -0
index 130b545..82f1c7f 100644
@@ -24,6 +24,7 @@ nvkm_pm(void *obj)
 extern struct nvkm_oclass *nv40_pm_oclass;
 extern struct nvkm_oclass *nv50_pm_oclass;
 extern struct nvkm_oclass *g84_pm_oclass;
+extern struct nvkm_oclass *gt200_pm_oclass;
 extern struct nvkm_oclass *gt215_pm_oclass;
 extern struct nvkm_oclass gf100_pm_oclass;
 extern struct nvkm_oclass gk104_pm_oclass;
drm/nouveau/nvkm/engine/device/nv50.c +1 -1
index 249b844..a2627ec 100644
@@ -288,7 +288,7 @@ nv50_identify(struct nvkm_device *device)
 		device->oclass[NVDEV_ENGINE_CIPHER ] = &g84_cipher_oclass;
 		device->oclass[NVDEV_ENGINE_BSP    ] = &g84_bsp_oclass;
 		device->oclass[NVDEV_ENGINE_DISP   ] =  gt200_disp_oclass;
-		device->oclass[NVDEV_ENGINE_PM     ] =  g84_pm_oclass;
+		device->oclass[NVDEV_ENGINE_PM     ] =  gt200_pm_oclass;
 		break;
 	case 0xaa:
 		device->cname = "MCP77/MCP78";
drm/nouveau/nvkm/engine/pm/Kbuild +1 -0
index c5ee8d5..cc01048 100644
@@ -2,6 +2,7 @@ nvkm-y += nvkm/engine/pm/base.o
 nvkm-y += nvkm/engine/pm/nv40.o
 nvkm-y += nvkm/engine/pm/nv50.o
 nvkm-y += nvkm/engine/pm/g84.o
+nvkm-y += nvkm/engine/pm/gt200.o
 nvkm-y += nvkm/engine/pm/gt215.o
 nvkm-y += nvkm/engine/pm/gf100.o
 nvkm-y += nvkm/engine/pm/gk104.o
drm/nouveau/nvkm/engine/pm/g84.c +99 -2

114 lines not on this page · raw message

drm/nouveau/nvkm/engine/pm/gt200.c new file +163 -0

163 lines not on this page · raw message

drm/nouveau/nvkm/engine/pm/gt215.c +82 -2

97 lines not on this page · raw message

drm/nouveau/nvkm/engine/pm/nv50.c +130 -6

152 lines not on this page · raw message

drm/nouveau/nvkm/engine/pm/priv.h +8 -0
index da419c1..5bcc739 100644
@@ -44,6 +44,14 @@ struct nvkm_perfsrc {
 	bool enable;
 };
 
+extern const struct nvkm_specsrc nv50_prop_sources[];
+extern const struct nvkm_specsrc nv50_zcull_sources[];
+extern const struct nvkm_specsrc nv50_zrop_sources[];
+extern const struct nvkm_specsrc g84_vfetch_sources[];
+extern const struct nvkm_specsrc gt200_crop_sources[];
+extern const struct nvkm_specsrc gt200_prop_sources[];
+extern const struct nvkm_specsrc gt200_tex_sources[];
+
 struct nvkm_specsig {
 	u8 signal;
 	const char *name;
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#28 lore raw

RFC PATCH 19/20 sw/nv50: add some private functions to factorize code

In reply to a message not in the archive

These functions will be also used by the interface for controlling performance counters.

---
 drm/nouveau/nvkm/engine/sw/nv50.c | 56 ++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 18 deletions(-)
drm/nouveau/nvkm/engine/sw/nv50.c +38 -18
index 401fcd7..b7c0227 100644
@@ -36,27 +36,58 @@
  ******************************************************************************/
 
 static int
-nv50_sw_mthd_dma_vblsem(struct nvkm_object *object, u32 mthd,
-			void *args, u32 size)
+nv50_priv_ctxdma_get(struct nv50_sw_chan *chan, u32 name, u32 *ctxdma)
 {
-	struct nv50_sw_chan *chan = (void *)nv_engctx(object->parent);
 	struct nvkm_fifo_chan *fifo = (void *)nv_object(chan)->parent;
 	struct nvkm_handle *handle;
 	int ret = -EINVAL;
 
-	handle = nvkm_namedb_get(nv_namedb(fifo), *(u32 *)args);
+	handle = nvkm_namedb_get(nv_namedb(fifo), name);
 	if (!handle)
 		return -ENOENT;
 
 	if (nv_iclass(handle->object, NV_GPUOBJ_CLASS)) {
 		struct nvkm_gpuobj *gpuobj = nv_gpuobj(handle->object);
-		chan->vblank.ctxdma = gpuobj->node->offset >> 4;
+		*ctxdma = gpuobj->node->offset >> 4;
 		ret = 0;
 	}
 	nvkm_namedb_put(handle);
 	return ret;
 }
 
+static void
+nv50_priv_ctxdma_flush(struct nv50_sw_chan *chan, u32 channel, u32 ctxdma)
+{
+	struct nv50_sw_priv *priv = (void *)nv_object(chan)->engine;
+	struct nvkm_bar *bar = nvkm_bar(priv);
+
+	nv_wr32(priv, 0x001704, channel);
+	nv_wr32(priv, 0x001710, 0x80000000 | ctxdma);
+	bar->flush(bar);
+}
+
+static void
+nv50_priv_ctxdma_wr32(struct nv50_sw_chan *chan, u64 offset, u32 value)
+{
+	struct nv50_sw_priv *priv = (void *)nv_object(chan)->engine;
+
+	if (nv_device(priv)->chipset == 0x50) {
+		nv_wr32(priv, 0x001570, offset);
+		nv_wr32(priv, 0x001574, value);
+	} else {
+		nv_wr32(priv, 0x060010, offset);
+		nv_wr32(priv, 0x060014, value);
+	}
+}
+
+static int
+nv50_sw_mthd_dma_vblsem(struct nvkm_object *object, u32 mthd,
+			void *args, u32 size)
+{
+	struct nv50_sw_chan *chan = (void *)nv_engctx(object->parent);
+	return nv50_priv_ctxdma_get(chan, *(u32 *)args, &chan->vblank.ctxdma);
+}
+
 static int
 nv50_sw_mthd_vblsem_offset(struct nvkm_object *object, u32 mthd,
 			   void *args, u32 size)
@@ -122,20 +153,9 @@ nv50_sw_vblsem_release(struct nvkm_notify *notify)
 {
 	struct nv50_sw_chan *chan =
 		container_of(notify, typeof(*chan), vblank.notify[notify->index]);
-	struct nv50_sw_priv *priv = (void *)nv_object(chan)->engine;
-	struct nvkm_bar *bar = nvkm_bar(priv);
-
-	nv_wr32(priv, 0x001704, chan->vblank.channel);
-	nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma);
-	bar->flush(bar);
 
-	if (nv_device(priv)->chipset == 0x50) {
-		nv_wr32(priv, 0x001570, chan->vblank.offset);
-		nv_wr32(priv, 0x001574, chan->vblank.value);
-	} else {
-		nv_wr32(priv, 0x060010, chan->vblank.offset);
-		nv_wr32(priv, 0x060014, chan->vblank.value);
-	}
+	nv50_priv_ctxdma_flush(chan, chan->vblank.channel, chan->vblank.ctxdma);
+	nv50_priv_ctxdma_wr32(chan, chan->vblank.offset, chan->vblank.value);
 
 	return NVKM_NOTIFY_DROP;
 }
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#29 lore raw

RFC PATCH 20/20 sw/nv50: add and interface for controlling performance counters

In reply to a message not in the archive

This software methods interface will allow the userspace to tie monitoring of performance counters to the command stream.

---
 drm/nouveau/nvkm/engine/sw/nv50.c | 160 ++++++++++++++++++++++++++++++++++++++
 drm/nouveau/nvkm/engine/sw/nv50.h |   6 ++
 2 files changed, 166 insertions(+)
drm/nouveau/nvkm/engine/sw/nv50.c +160 -0
index b7c0227..b5f8263 100644
@@ -29,7 +29,9 @@
 #include <engine/disp.h>
 #include <subdev/bar.h>
 
+#include <nvif/class.h>
 #include <nvif/event.h>
+#include <nvif/ioctl.h>
 
 /*******************************************************************************
  * software object classes
@@ -80,6 +82,14 @@ nv50_priv_ctxdma_wr32(struct nv50_sw_chan *chan, u64 offset, u32 value)
 	}
 }
 
+static u64
+nv50_priv_pm_get_offset(struct nv50_sw_chan *chan, u32 sequence)
+{
+	u32 max_queries = chan->pm.max_queries;
+	u32 ring_size = chan->pm.ring_size;
+	return (1 + (sequence % ring_size) * max_queries * 3) * 4;
+}
+
 static int
 nv50_sw_mthd_dma_vblsem(struct nvkm_object *object, u32 mthd,
 			void *args, u32 size)
@@ -128,13 +138,163 @@ nv50_sw_mthd_flip(struct nvkm_object *object, u32 mthd, void *args, u32 size)
 	return -EINVAL;
 }
 
+static int
+nv50_sw_mthd_dma_pm(struct nvkm_object *object, u32 mthd,
+		    void *args, u32 size)
+{
+	struct nv50_sw_chan *chan = (void *)nv_engctx(object->parent);
+	return nv50_priv_ctxdma_get(chan, *(u32 *)args, &chan->pm.ctxdma);
+}
+
+static int
+nv50_sw_mthd_pm_ring_size(struct nvkm_object *object, u32 mthd,
+			  void *args, u32 size)
+{
+	struct nv50_sw_chan *chan = (void *)nv_engctx(object->parent);
+	chan->pm.ring_size = *(u32 *)args;
+	return 0;
+}
+
+static int
+nv50_sw_mthd_pm_max_queries(struct nvkm_object *object, u32 mthd,
+			    void *args, u32 size)
+{
+	struct nv50_sw_chan *chan = (void *)nv_engctx(object->parent);
+	chan->pm.max_queries = *(u32 *)args;
+	return 0;
+}
+
+static int
+nv50_sw_mthd_pm_mthd_init(struct nvkm_object *object, u32 mthd,
+			  void *args, u32 size)
+{
+	struct nv50_sw_chan *chan = (void *)nv_engctx(object->parent);
+	struct nvkm_fifo_chan *fifo = (void *)nv_object(chan)->parent;
+	struct nvkm_handle *handle;
+	struct nvkm_object *namedb;
+	int ret = -EINVAL;
+
+	namedb = nv_object(fifo)->parent;
+	while (!nv_iclass(namedb, NV_NAMEDB_CLASS))
+		namedb = namedb->parent;
+
+	handle = nvkm_namedb_get(nv_namedb(namedb), *(u32 *)args);
+	if (!handle)
+		return -ENOENT;
+
+	if (nv_iclass(handle->object, NVIF_IOCTL_NEW_V0_PERFMON)) {
+		struct nvkm_object *object = handle->object;
+		struct nvkm_ofuncs *ofuncs = object->oclass->ofuncs;
+		struct nvif_perfdom_init args = {};
+
+		ret = ofuncs->mthd(object, NVIF_PERFDOM_V0_INIT,
+				   &args, sizeof(args));
+	}
+	nvkm_namedb_put(handle);
+	return ret;
+}
+
+static int
+nv50_sw_mthd_pm_mthd_sample(struct nvkm_object *object, u32 mthd,
+			    void *args, u32 size)
+{
+	struct nv50_sw_chan *chan = (void *)nv_engctx(object->parent);
+	struct nvkm_fifo_chan *fifo = (void *)nv_object(chan)->parent;
+	struct nvkm_handle *handle;
+	struct nvkm_object *namedb;
+	int ret = -EINVAL;
+
+	namedb = nv_object(fifo)->parent;
+	while (!nv_iclass(namedb, NV_NAMEDB_CLASS))
+		namedb = namedb->parent;
+
+	handle = nvkm_namedb_get(nv_namedb(namedb), *(u32 *)args);
+	if (!handle)
+		return -ENOENT;
+
+	if (nv_iclass(handle->object, NVIF_IOCTL_NEW_V0_PERFMON)) {
+		struct nvkm_object *object = handle->object;
+		struct nvkm_ofuncs *ofuncs = object->oclass->ofuncs;
+		struct nvif_perfdom_sample args = {};
+
+		ret = ofuncs->mthd(object, NVIF_PERFDOM_V0_SAMPLE,
+				   &args, sizeof(args));
+	}
+	nvkm_namedb_put(handle);
+	return ret;
+}
+
+static int
+nv50_sw_mthd_pm_mthd_read(struct nvkm_object *object, u32 mthd,
+			  void *args, u32 size)
+{
+	struct nv50_sw_chan *chan = (void *)nv_engctx(object->parent);
+	struct nvkm_fifo_chan *fifo = (void *)nv_object(chan)->parent;
+	struct nvkm_handle *handle;
+	struct nvkm_object *namedb;
+	u32 seq = *(u32 *)args;
+	int ret = -ENOENT;
+	u64 offset;
+	int i;
+
+	nv50_priv_ctxdma_flush(chan, chan->vblank.channel, chan->pm.ctxdma);
+	offset = nv50_priv_pm_get_offset(chan, seq);
+
+	namedb = nv_object(fifo)->parent;
+	while (!nv_iclass(namedb, NV_NAMEDB_CLASS))
+		namedb = namedb->parent;
+
+	/* XXX: Any ideas to improve this ? */
+	read_lock(&nv_namedb(namedb)->lock);
+	list_for_each_entry(handle, &nv_namedb(namedb)->list, node) {
+		struct nvif_perfdom_read_v0 args = {};
+		struct nvkm_object *object;
+		struct nvkm_ofuncs *ofuncs;
+
+		if (handle == NULL)
+			break;
+
+		if (nv_iclass(handle->object, NVIF_IOCTL_NEW_V0_PERFMON)
+		    != NVIF_IOCTL_NEW_V0_PERFMON)
+			continue;
+
+		object = handle->object;
+		ofuncs = object->oclass->ofuncs;
+		ret = ofuncs->mthd(object, NVIF_PERFDOM_V0_READ,
+				   &args, sizeof(args));
+		if (ret && ret != -EAGAIN) {
+			nv_error(object, "failed to read perfdom object: %x\n",
+				 handle->name);
+			break;
+		}
+
+		nv50_priv_ctxdma_wr32(chan, offset, handle->name);
+		for (i = 0; i < 4; i++) {
+			nv50_priv_ctxdma_wr32(chan, offset + 4 * (i + 1),
+					      args.ctr[i]);
+		}
+		nv50_priv_ctxdma_wr32(chan, offset + 20, args.clk);
+		offset += 24;
+	}
+	read_unlock(&nv_namedb(namedb)->lock);
+
+	nv50_priv_ctxdma_wr32(chan, 0x0, seq);
+	return ret;
+}
+
 static struct nvkm_omthds
 nv50_sw_omthds[] = {
 	{ 0x018c, 0x018c, nv50_sw_mthd_dma_vblsem },
+	{ 0x0190, 0x0190, nv50_sw_mthd_dma_pm },
 	{ 0x0400, 0x0400, nv50_sw_mthd_vblsem_offset },
 	{ 0x0404, 0x0404, nv50_sw_mthd_vblsem_value },
 	{ 0x0408, 0x0408, nv50_sw_mthd_vblsem_release },
 	{ 0x0500, 0x0500, nv50_sw_mthd_flip },
+	{ 0x0600, 0x0600, nv50_sw_mthd_pm_ring_size },
+	{ 0x0604, 0x0604, nv50_sw_mthd_pm_max_queries },
+	{ 0x0608, 0x0608, nv50_sw_mthd_pm_mthd_init },
+	{ 0x060c, 0x060c, nv50_sw_mthd_pm_mthd_sample },
+	{ 0x0700, 0x0700, nv50_sw_mthd_pm_mthd_read },
 	{}
 };
 
drm/nouveau/nvkm/engine/sw/nv50.h +6 -0
index d8adc11..48860d3 100644
@@ -31,6 +31,12 @@ struct nv50_sw_chan {
 		u64 offset;
 		u32 value;
 	} vblank;
+
+	struct {
+		u32 ctxdma;
+		u32 ring_size;
+		u32 max_queries;
+	} pm;
 };
 
 int  nv50_sw_context_ctor(struct nvkm_object *,
Signature · 6 lines
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#8 lore raw

Re: [PATCH RFC 05/20] pm: reorganize the nvif interface

In reply to a message not in the archive
Quoted 3 lines · Samuel Pitoiset

This commit introduces the NVIF_IOCTL_NEW_V0_PERFMON class which will be used in order to query domains, signals and sources. This separates the querying and the counting interface.

Hey Samuel,

I've merged patches 1-4 already, I've got some comments on this one, but after they're solved I'm happy to merge up to (and including) patch 18. Patches 19/20, I need to think about some more.

Quoted 100 lines
---
 bin/nv_perfmon.c                  | 12 ++++++------
 drm/nouveau/include/nvif/class.h  | 26 ++++++++++++++++----------
 drm/nouveau/include/nvif/ioctl.h  |  5 +++--
 drm/nouveau/nvkm/engine/pm/base.c | 38 ++++++++++++++++++++++++++++++++------
 4 files changed, 57 insertions(+), 24 deletions(-)
bin/nv_perfmon.c +6 -6
index a8c5838..30a3138 100644
@@ -600,7 +600,7 @@ main(int argc, char **argv)
        const char *cfg = NULL;
        const char *dbg = "error";
        u64 dev = ~0ULL;
-       struct nvif_perfctr_query_v0 args = {};
+       struct nvif_perfmon_query_signal_v0 args = {};
        struct nvif_client *client;
        struct nvif_object object;
        int ret, c, k;
@@ -644,15 +644,14 @@ main(int argc, char **argv)
        }
 
        ret = nvif_object_init(nvif_object(device), NULL, 0xdeadbeef,
-                              NVIF_IOCTL_NEW_V0_PERFCTR,
-                              &(struct nvif_perfctr_v0) {
-                              }, sizeof(struct nvif_perfctr_v0), &object);
+                              NVIF_IOCTL_NEW_V0_PERFMON, NULL, 0, &object);
        assert(ret == 0);
        do {
                u32 prev_iter = args.iter;
 
                args.name[0] = '\0';
-               ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY, &args, sizeof(args));
+               ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
+                               &args, sizeof(args));
                assert(ret == 0);
 
                if (prev_iter) {
@@ -663,7 +662,8 @@ main(int argc, char **argv)
                        args.iter = prev_iter;
                        strncpy(signals[nr_signals - 1], args.name,
                                sizeof(args.name));
-                       ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY, &args, sizeof(args));
+                       ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
+                                       &args, sizeof(args));
                        assert(ret == 0);
                }
        } while (args.iter != 0xffffffff);
drm/nouveau/include/nvif/class.h +16 -10
index 64f8b2f..11935a0 100644
@@ -251,6 +251,20 @@ struct gf110_dma_v0 {
  * perfmon
  ******************************************************************************/
 
+#define NVIF_PERFMON_V0_QUERY_SIGNAL                                       0x00
+
+struct nvif_perfmon_query_signal_v0 {
+       __u8  version;
+       __u8  pad01[3];
+       __u32 iter;
+       char  name[64];
+};
+
+
+/*******************************************************************************
+ * perfctr
+ ******************************************************************************/
+
 struct nvif_perfctr_v0 {
        __u8  version;
        __u8  pad01[1];
@@ -259,16 +273,8 @@ struct nvif_perfctr_v0 {
        char  name[4][64];
 };
 
-#define NVIF_PERFCTR_V0_QUERY                                              0x00
-#define NVIF_PERFCTR_V0_SAMPLE                                             0x01
-#define NVIF_PERFCTR_V0_READ                                               0x02
-
-struct nvif_perfctr_query_v0 {
-       __u8  version;
-       __u8  pad01[3];
-       __u32 iter;
-       char  name[64];
-};
+#define NVIF_PERFCTR_V0_SAMPLE                                             0x00
+#define NVIF_PERFCTR_V0_READ                                               0x01
 
 struct nvif_perfctr_sample {
 };
drm/nouveau/include/nvif/ioctl.h +0 -0
index 4cd8e32..517cd27 100644

drm/nouveau/include/nvif/ioctl.h struct nvif_ioctl_new_v0 { · line 54

Quoted 8 lines
drm/nouveau/include/nvif/ioctl.h +3 -2
@@ -49,8 +49,9 @@ struct nvif_ioctl_new_v0 {
        __u64 token;
        __u32 handle;
 /* these class numbers are made up by us, and not nvidia-assigned */
-#define NVIF_IOCTL_NEW_V0_PERFCTR                                    0x0000ffff
-#define NVIF_IOCTL_NEW_V0_CONTROL                                    0x0000fffe
+#define NVIF_IOCTL_NEW_V0_PERFMON                                    0x0000ffff
+#define NVIF_IOCTL_NEW_V0_PERFCTR                                    0x0000fffe
+#define NVIF_IOCTL_NEW_V0_CONTROL                                    0x0000fffd

It doesn't matter this time, because we're technically breaking ABI already anyway and current userspace won't be effected, but best to avoid changing class numbers like this :) It's fine this time though.

Quoted 73 lines
drm/nouveau/include/nvif/ioctl.h +0 -0
        __u32 oclass;
        __u8  data[];           /* class data (class.h) */
 };
drm/nouveau/nvkm/engine/pm/base.c +28 -6
index 7b07e8b..cb88170 100644
@@ -83,10 +83,10 @@ nvkm_perfsig_find(struct nvkm_pm *ppm, const char *name, u32 size,
  * Perfmon object classes
  ******************************************************************************/
 static int
-nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
+nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data, u32 size)
 {
        union {
-               struct nvif_perfctr_query_v0 v0;
+               struct nvif_perfmon_query_signal_v0 v0;
        } *args = data;
        struct nvkm_device *device = nv_device(object);
        struct nvkm_pm *ppm = (void *)object->engine;
@@ -97,9 +97,9 @@ nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
        int tmp = 0, di, si;
        int ret;
 
-       nv_ioctl(object, "perfctr query size %d\n", size);
+       nv_ioctl(object, "perfmon query signal size %d\n", size);
        if (nvif_unpack(args->v0, 0, 0, false)) {
-               nv_ioctl(object, "perfctr query vers %d iter %08x\n",
+               nv_ioctl(object, "perfmon query signal vers %d iter %08x\n",
                         args->v0.version, args->v0.iter);
                di = (args->v0.iter & 0xff000000) >> 24;
                si = (args->v0.iter & 0x00ffffff) - 1;
@@ -142,6 +142,30 @@ nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
 }
 
 static int
+nvkm_perfmon_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
+{
+       switch (mthd) {
+       case NVIF_PERFMON_V0_QUERY_SIGNAL:
+               return nvkm_perfmon_mthd_query_signal(object, data, size);
+       default:
+               break;
+       }
+       return -EINVAL;
+}
+
+static struct nvkm_ofuncs
+nvkm_perfmon_ofuncs = {
+       .ctor = _nvkm_object_ctor,
+       .dtor = nvkm_object_destroy,
+       .init = nvkm_object_init,
+       .fini = nvkm_object_fini,
+       .mthd = nvkm_perfmon_mthd,
+};
+
+/*******************************************************************************
+ * Perfctr object classes
+ ******************************************************************************/
+static int
 nvkm_perfctr_sample(struct nvkm_object *object, void *data, u32 size)
 {
        union {
@@ -221,8 +245,6 @@ static int
 nvkm_perfctr_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
 {
        switch (mthd) {
-       case NVIF_PERFCTR_V0_QUERY:
-               return nvkm_perfctr_query(object, data, size);
        case NVIF_PERFCTR_V0_SAMPLE:
                return nvkm_perfctr_sample(object, data, size);
        case NVIF_PERFCTR_V0_READ:

drm/nouveau/nvkm/engine/pm/base.c nvkm_perfctr_ofuncs = { · line 330

Quoted 10 lines
drm/nouveau/nvkm/engine/pm/base.c +4 -0
@@ -299,6 +321,10 @@ nvkm_perfctr_ofuncs = {
 
 struct nvkm_oclass
 nvkm_pm_sclass[] = {
+       {
+         .handle = NVIF_IOCTL_NEW_V0_PERFMON,
+         .ofuncs = &nvkm_perfmon_ofuncs,
+       },
        { .handle = NVIF_IOCTL_NEW_V0_PERFCTR,
          .ofuncs = &nvkm_perfctr_ofuncs,
        },

What I'd like to see here is that nvkm_pm_sclass() only has PERFMON, and PERFCTR is created as a child of it (like how all the PDISP channel objects are children of the main disp class). To do this, you need to create PERFMON as a nvkm_parent instead of an nvkm_object, and have its parent.sclass contain PERFMON. This will perhaps look a bit yucky for the moment, but I'm working on making things cleaner so I'll fix it later. Feel free to ping me on IRC if you need a hand making the change though.

I actually have a large patch series with the first part of this cleanup work queued up, but if you can make the above change first, I'll rebase my work on yours so you don't have to deal with that.

Thanks,
Ben.

Quoted 7 lines

--
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#10 lore raw

Re: [PATCH RFC 05/20] pm: reorganize the nvif interface

In reply to a message not in the archive
Quoted 10 lines · Ben Skeggs
Quoted 3 lines · Samuel Pitoiset

This commit introduces the NVIF_IOCTL_NEW_V0_PERFMON class which will be used in order to query domains, signals and sources. This separates the querying and the counting interface.

Hey Samuel,

I've merged patches 1-4 already, I've got some comments on this one, but after they're solved I'm happy to merge up to (and including) patch 18. Patches 19/20, I need to think about some more.

Hey Ben,

Thanks for reviewing this series so quickly. :-)

Quoted 102 lines
Quoted 102 lines
---
  bin/nv_perfmon.c                  | 12 ++++++------
  drm/nouveau/include/nvif/class.h  | 26 ++++++++++++++++----------
  drm/nouveau/include/nvif/ioctl.h  |  5 +++--
  drm/nouveau/nvkm/engine/pm/base.c | 38 ++++++++++++++++++++++++++++++++------
  4 files changed, 57 insertions(+), 24 deletions(-)
bin/nv_perfmon.c +6 -6
index a8c5838..30a3138 100644
@@ -600,7 +600,7 @@ main(int argc, char **argv)
         const char *cfg = NULL;
         const char *dbg = "error";
         u64 dev = ~0ULL;
-       struct nvif_perfctr_query_v0 args = {};
+       struct nvif_perfmon_query_signal_v0 args = {};
         struct nvif_client *client;
         struct nvif_object object;
         int ret, c, k;
@@ -644,15 +644,14 @@ main(int argc, char **argv)
         }
 
         ret = nvif_object_init(nvif_object(device), NULL, 0xdeadbeef,
-                              NVIF_IOCTL_NEW_V0_PERFCTR,
-                              &(struct nvif_perfctr_v0) {
-                              }, sizeof(struct nvif_perfctr_v0), &object);
+                              NVIF_IOCTL_NEW_V0_PERFMON, NULL, 0, &object);
         assert(ret == 0);
         do {
                 u32 prev_iter = args.iter;
 
                 args.name[0] = '\0';
-               ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY, &args, sizeof(args));
+               ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
+                               &args, sizeof(args));
                 assert(ret == 0);
 
                 if (prev_iter) {
@@ -663,7 +662,8 @@ main(int argc, char **argv)
                         args.iter = prev_iter;
                         strncpy(signals[nr_signals - 1], args.name,
                                 sizeof(args.name));
-                       ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY, &args, sizeof(args));
+                       ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
+                                       &args, sizeof(args));
                         assert(ret == 0);
                 }
         } while (args.iter != 0xffffffff);
drm/nouveau/include/nvif/class.h +16 -10
index 64f8b2f..11935a0 100644
@@ -251,6 +251,20 @@ struct gf110_dma_v0 {
   * perfmon
   ******************************************************************************/
 
+#define NVIF_PERFMON_V0_QUERY_SIGNAL                                       0x00
+
+struct nvif_perfmon_query_signal_v0 {
+       __u8  version;
+       __u8  pad01[3];
+       __u32 iter;
+       char  name[64];
+};
+
+
+/*******************************************************************************
+ * perfctr
+ ******************************************************************************/
+
  struct nvif_perfctr_v0 {
         __u8  version;
         __u8  pad01[1];
@@ -259,16 +273,8 @@ struct nvif_perfctr_v0 {
         char  name[4][64];
  };
 
-#define NVIF_PERFCTR_V0_QUERY                                              0x00
-#define NVIF_PERFCTR_V0_SAMPLE                                             0x01
-#define NVIF_PERFCTR_V0_READ                                               0x02
-
-struct nvif_perfctr_query_v0 {
-       __u8  version;
-       __u8  pad01[3];
-       __u32 iter;
-       char  name[64];
-};
+#define NVIF_PERFCTR_V0_SAMPLE                                             0x00
+#define NVIF_PERFCTR_V0_READ                                               0x01
 
  struct nvif_perfctr_sample {
  };
drm/nouveau/include/nvif/ioctl.h +0 -0
index 4cd8e32..517cd27 100644
@@ -49,8 +49,9 @@ struct nvif_ioctl_new_v0 {
         __u64 token;
         __u32 handle;
  /* these class numbers are made up by us, and not nvidia-assigned */
Quoted 8 lines

drm/nouveau/include/nvif/ioctl.h struct nvif_ioctl_new_v0 { · line 54

Quoted 5 lines
drm/nouveau/include/nvif/ioctl.h +3 -2
-#define NVIF_IOCTL_NEW_V0_PERFCTR                                    0x0000ffff
-#define NVIF_IOCTL_NEW_V0_CONTROL                                    0x0000fffe
+#define NVIF_IOCTL_NEW_V0_PERFMON                                    0x0000ffff
+#define NVIF_IOCTL_NEW_V0_PERFCTR                                    0x0000fffe
+#define NVIF_IOCTL_NEW_V0_CONTROL                                    0x0000fffd

It doesn't matter this time, because we're technically breaking ABI already anyway and current userspace won't be effected, but best to avoid changing class numbers like this :) It's fine this time though.

Sure, since the nvif interface is still not exposed through libdrm, this is not going to affect userspace. Btw, what is your plan about this? Are you going to merge nvif support to libdrm ?

Quoted 93 lines
Quoted 74 lines
drm/nouveau/include/nvif/ioctl.h +0 -0
         __u32 oclass;
         __u8  data[];           /* class data (class.h) */
  };
drm/nouveau/nvkm/engine/pm/base.c +28 -6
index 7b07e8b..cb88170 100644
@@ -83,10 +83,10 @@ nvkm_perfsig_find(struct nvkm_pm *ppm, const char *name, u32 size,
   * Perfmon object classes
   ******************************************************************************/
  static int
-nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
+nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data, u32 size)
  {
         union {
-               struct nvif_perfctr_query_v0 v0;
+               struct nvif_perfmon_query_signal_v0 v0;
         } *args = data;
         struct nvkm_device *device = nv_device(object);
         struct nvkm_pm *ppm = (void *)object->engine;
@@ -97,9 +97,9 @@ nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
         int tmp = 0, di, si;
         int ret;
 
-       nv_ioctl(object, "perfctr query size %d\n", size);
+       nv_ioctl(object, "perfmon query signal size %d\n", size);
         if (nvif_unpack(args->v0, 0, 0, false)) {
-               nv_ioctl(object, "perfctr query vers %d iter %08x\n",
+               nv_ioctl(object, "perfmon query signal vers %d iter %08x\n",
                          args->v0.version, args->v0.iter);
                 di = (args->v0.iter & 0xff000000) >> 24;
                 si = (args->v0.iter & 0x00ffffff) - 1;
@@ -142,6 +142,30 @@ nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
  }
 
  static int
+nvkm_perfmon_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
+{
+       switch (mthd) {
+       case NVIF_PERFMON_V0_QUERY_SIGNAL:
+               return nvkm_perfmon_mthd_query_signal(object, data, size);
+       default:
+               break;
+       }
+       return -EINVAL;
+}
+
+static struct nvkm_ofuncs
+nvkm_perfmon_ofuncs = {
+       .ctor = _nvkm_object_ctor,
+       .dtor = nvkm_object_destroy,
+       .init = nvkm_object_init,
+       .fini = nvkm_object_fini,
+       .mthd = nvkm_perfmon_mthd,
+};
+
+/*******************************************************************************
+ * Perfctr object classes
+ ******************************************************************************/
+static int
  nvkm_perfctr_sample(struct nvkm_object *object, void *data, u32 size)
  {
         union {
@@ -221,8 +245,6 @@ static int
  nvkm_perfctr_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
  {
         switch (mthd) {
-       case NVIF_PERFCTR_V0_QUERY:
-               return nvkm_perfctr_query(object, data, size);
         case NVIF_PERFCTR_V0_SAMPLE:
                 return nvkm_perfctr_sample(object, data, size);
         case NVIF_PERFCTR_V0_READ:

drm/nouveau/nvkm/engine/pm/base.c nvkm_perfctr_ofuncs = { · line 330

Quoted 10 lines
drm/nouveau/nvkm/engine/pm/base.c +4 -0
@@ -299,6 +321,10 @@ nvkm_perfctr_ofuncs = {
 
  struct nvkm_oclass
  nvkm_pm_sclass[] = {
+       {
+         .handle = NVIF_IOCTL_NEW_V0_PERFMON,
+         .ofuncs = &nvkm_perfmon_ofuncs,
+       },
         { .handle = NVIF_IOCTL_NEW_V0_PERFCTR,
           .ofuncs = &nvkm_perfctr_ofuncs,
         },

What I'd like to see here is that nvkm_pm_sclass() only has PERFMON, and PERFCTR is created as a child of it (like how all the PDISP channel objects are children of the main disp class). To do this, you need to create PERFMON as a nvkm_parent instead of an nvkm_object, and have its parent.sclass contain PERFMON. This will perhaps look a bit yucky for the moment, but I'm working on making things cleaner so I'll fix it later. Feel free to ping me on IRC if you need a hand making the change though.

Quoted 3 lines

I actually have a large patch series with the first part of this cleanup work queued up, but if you can make the above change first, I'll rebase my work on yours so you don't have to deal with that.

Okay, I'll take a look at the PDISP engine and make this change for the PM engine this week. And if I have some other questions, I'll ping you on IRC.

Thanks,
Samuel.

Quoted 11 lines

Thanks,
Ben.

Quoted 7 lines

--
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#12 lore raw

Re: [PATCH RFC 05/20] pm: reorganize the nvif interface

In reply to a message not in the archive
Quoted 158 lines · Samuel Pitoiset
Quoted 8 lines · Ben Skeggs
Quoted 4 lines · Samuel Pitoiset

This commit introduces the NVIF_IOCTL_NEW_V0_PERFMON class which will be used in order to query domains, signals and sources. This separates the querying and the counting interface.

Quoted 6 lines

Hey Samuel,

I've merged patches 1-4 already, I've got some comments on this one, but after they're solved I'm happy to merge up to (and including) patch 18. Patches 19/20, I need to think about some more.

Hey Ben,

Thanks for reviewing this series so quickly. :-)

Quoted 125 lines
Quoted 125 lines
---
  bin/nv_perfmon.c                  | 12 ++++++------
  drm/nouveau/include/nvif/class.h  | 26 ++++++++++++++++----------
  drm/nouveau/include/nvif/ioctl.h  |  5 +++--
  drm/nouveau/nvkm/engine/pm/base.c | 38
++++++++++++++++++++++++++++++++------
  4 files changed, 57 insertions(+), 24 deletions(-)
bin/nv_perfmon.c +4 -5
index a8c5838..30a3138 100644
@@ -600,7 +600,7 @@ main(int argc, char **argv)
         const char *cfg = NULL;
         const char *dbg = "error";
         u64 dev = ~0ULL;
-       struct nvif_perfctr_query_v0 args = {};
+       struct nvif_perfmon_query_signal_v0 args = {};
         struct nvif_client *client;
         struct nvif_object object;
         int ret, c, k;
@@ -644,15 +644,14 @@ main(int argc, char **argv)
         }
 
         ret = nvif_object_init(nvif_object(device), NULL, 0xdeadbeef,
-                              NVIF_IOCTL_NEW_V0_PERFCTR,
-                              &(struct nvif_perfctr_v0) {
-                              }, sizeof(struct nvif_perfctr_v0),
 &object);
+                              NVIF_IOCTL_NEW_V0_PERFMON, NULL, 0,
 &object);
         assert(ret == 0);
         do {
                 u32 prev_iter = args.iter;
 
                 args.name[0] = '\0';
-               ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY, &args,
 sizeof(args));
+               ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
+                               &args, sizeof(args));
                 assert(ret == 0);

                 if (prev_iter) {
bin/nv_perfmon.c +2 -1
@@ -663,7 +662,8 @@ main(int argc, char **argv)
                         args.iter = prev_iter;
                         strncpy(signals[nr_signals - 1], args.name,
                                 sizeof(args.name));
-                       ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY,
 &args, sizeof(args));
+                       ret = nvif_mthd(&object,
 NVIF_PERFMON_V0_QUERY_SIGNAL,
+                                       &args, sizeof(args));
                         assert(ret == 0);
                 }
         } while (args.iter != 0xffffffff);
drm/nouveau/include/nvif/class.h +1 -0
index 64f8b2f..11935a0 100644
@@ -251,6 +251,20 @@ struct gf110_dma_v0 {
   * perfmon
 
 ******************************************************************************/
 
+#define NVIF_PERFMON_V0_QUERY_SIGNAL

0x00

drm/nouveau/include/nvif/class.h +12 -0
+
+struct nvif_perfmon_query_signal_v0 {
+       __u8  version;
+       __u8  pad01[3];
+       __u32 iter;
+       char  name[64];
+};
+
+
 
+/*******************************************************************************
+ * perfctr
+

******************************************************************************/

drm/nouveau/include/nvif/class.h +1 -1
+
  struct nvif_perfctr_v0 {
         __u8  version;
         __u8  pad01[1];
@@ -259,16 +273,8 @@ struct nvif_perfctr_v0 {
         char  name[4][64];
  };
 
-#define NVIF_PERFCTR_V0_QUERY

0x00
-#define NVIF_PERFCTR_V0_SAMPLE
0x01
-#define NVIF_PERFCTR_V0_READ
0x02

drm/nouveau/include/nvif/class.h +1 -7
-
-struct nvif_perfctr_query_v0 {
-       __u8  version;
-       __u8  pad01[3];
-       __u32 iter;
-       char  name[64];
-};
+#define NVIF_PERFCTR_V0_SAMPLE

0x00
+#define NVIF_PERFCTR_V0_READ
0x01

  struct nvif_perfctr_sample {
  };
drm/nouveau/include/nvif/ioctl.h +0 -1
index 4cd8e32..517cd27 100644
@@ -49,8 +49,9 @@ struct nvif_ioctl_new_v0 {
         __u64 token;
         __u32 handle;
  /* these class numbers are made up by us, and not nvidia-assigned */
-#define NVIF_IOCTL_NEW_V0_PERFCTR

0x0000ffff
-#define NVIF_IOCTL_NEW_V0_CONTROL
0x0000fffe
+#define NVIF_IOCTL_NEW_V0_PERFMON
0x0000ffff

Quoted 8 lines
Quoted 4 lines

+#define NVIF_IOCTL_NEW_V0_PERFCTR
0x0000fffe
+#define NVIF_IOCTL_NEW_V0_CONTROL
0x0000fffd

It doesn't matter this time, because we're technically breaking ABI already anyway and current userspace won't be effected, but best to avoid changing class numbers like this :) It's fine this time though.

Quoted 4 lines

Sure, since the nvif interface is still not exposed through libdrm, this is not going to affect userspace.
Btw, what is your plan about this? Are you going to merge nvif support to libdrm ?

Well, Ilia hasn't quite reviewed the patches yet still ;) But, you've been using them successfully so far, so that counts as review.

I have some changes that I haven't quite pushed yet that'll need some slight re-jigging of the libdrm series, but I'll push to merge it (finally) once that's done.

Quoted 108 lines
Quoted 108 lines
Quoted 88 lines


         __u32 oclass;
         __u8  data[];           /* class data (class.h) */

};

drm/nouveau/nvkm/engine/pm/base.c +2 -2
index 7b07e8b..cb88170 100644
@@ -83,10 +83,10 @@ nvkm_perfsig_find(struct nvkm_pm *ppm, const char
 *name, u32 size,
   * Perfmon object classes
 
 ******************************************************************************/
  static int
-nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
+nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data,
 u32 size)
  {
         union {
-               struct nvif_perfctr_query_v0 v0;
+               struct nvif_perfmon_query_signal_v0 v0;
         } *args = data;
         struct nvkm_device *device = nv_device(object);
         struct nvkm_pm *ppm = (void *)object->engine;
drm/nouveau/nvkm/engine/pm/base.c +2 -2
@@ -97,9 +97,9 @@ nvkm_perfctr_query(struct nvkm_object *object, void
 *data, u32 size)
         int tmp = 0, di, si;
         int ret;
 
-       nv_ioctl(object, "perfctr query size %d\n", size);
+       nv_ioctl(object, "perfmon query signal size %d\n", size);
         if (nvif_unpack(args->v0, 0, 0, false)) {
-               nv_ioctl(object, "perfctr query vers %d iter %08x\n",
+               nv_ioctl(object, "perfmon query signal vers %d iter
 %08x\n",
                          args->v0.version, args->v0.iter);
                 di = (args->v0.iter & 0xff000000) >> 24;
                 si = (args->v0.iter & 0x00ffffff) - 1;
drm/nouveau/nvkm/engine/pm/base.c +23 -0
@@ -142,6 +142,30 @@ nvkm_perfctr_query(struct nvkm_object *object, void
 *data, u32 size)
  }
 
  static int
+nvkm_perfmon_mthd(struct nvkm_object *object, u32 mthd, void *data, u32
 size)
+{
+       switch (mthd) {
+       case NVIF_PERFMON_V0_QUERY_SIGNAL:
+               return nvkm_perfmon_mthd_query_signal(object, data,
 size);
+       default:
+               break;
+       }
+       return -EINVAL;
+}
+
+static struct nvkm_ofuncs
+nvkm_perfmon_ofuncs = {
+       .ctor = _nvkm_object_ctor,
+       .dtor = nvkm_object_destroy,
+       .init = nvkm_object_init,
+       .fini = nvkm_object_fini,
+       .mthd = nvkm_perfmon_mthd,
+};
+
 
+/*******************************************************************************
+ * Perfctr object classes
+

******************************************************************************/

drm/nouveau/nvkm/engine/pm/base.c +1 -2
+static int
  nvkm_perfctr_sample(struct nvkm_object *object, void *data, u32 size)
  {
         union {
@@ -221,8 +245,6 @@ static int
  nvkm_perfctr_mthd(struct nvkm_object *object, u32 mthd, void *data, u32
 size)
  {
         switch (mthd) {
-       case NVIF_PERFCTR_V0_QUERY:
-               return nvkm_perfctr_query(object, data, size);
         case NVIF_PERFCTR_V0_SAMPLE:
                 return nvkm_perfctr_sample(object, data, size);

case NVIF_PERFCTR_V0_READ:

drm/nouveau/nvkm/engine/pm/base.c nvkm_perfctr_ofuncs = { · line 330

Quoted 10 lines
drm/nouveau/nvkm/engine/pm/base.c +4 -0
@@ -299,6 +321,10 @@ nvkm_perfctr_ofuncs = {
 
  struct nvkm_oclass
  nvkm_pm_sclass[] = {
+       {
+         .handle = NVIF_IOCTL_NEW_V0_PERFMON,
+         .ofuncs = &nvkm_perfmon_ofuncs,
+       },
         { .handle = NVIF_IOCTL_NEW_V0_PERFCTR,
           .ofuncs = &nvkm_perfctr_ofuncs,
         },

What I'd like to see here is that nvkm_pm_sclass() only has PERFMON, and PERFCTR is created as a child of it (like how all the PDISP channel objects are children of the main disp class). To do this, you need to create PERFMON as a nvkm_parent instead of an nvkm_object, and have its parent.sclass contain PERFMON. This will perhaps look a bit yucky for the moment, but I'm working on making things cleaner so I'll fix it later. Feel free to ping me on IRC if you need a hand making the change though.

Quoted 8 lines
Quoted 3 lines

I actually have a large patch series with the first part of this cleanup work queued up, but if you can make the above change first, I'll rebase my work on yours so you don't have to deal with that.

Okay, I'll take a look at the PDISP engine and make this change for the PM engine this week.
And if I have some other questions, I'll ping you on IRC.

Some work I've got queued up would conflict with these, so I've merged your patches ahead of time and made that change myself to avoid you having to rebase your whole series. Any fixes etc that'd been done since can be done as separate patches before going to Linus.

Thanks,
Ben.

Quoted 18 lines

Thanks,
Samuel.

Quoted 11 lines

Thanks,
Ben.

Quoted 7 lines

--
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#14 lore raw

Re: [PATCH RFC 05/20] pm: reorganize the nvif interface

In reply to a message not in the archive
Quoted 156 lines · Ben Skeggs
Quoted 151 lines · Samuel Pitoiset
Quoted 11 lines · Ben Skeggs
Quoted 3 lines · Samuel Pitoiset

This commit introduces the NVIF_IOCTL_NEW_V0_PERFMON class which will be used in order to query domains, signals and sources. This separates the querying and the counting interface.

Hey Samuel,

I've merged patches 1-4 already, I've got some comments on this one, but after they're solved I'm happy to merge up to (and including) patch 18. Patches 19/20, I need to think about some more.

Hey Ben,

Thanks for reviewing this series so quickly. :-)

Quoted 124 lines
Quoted 124 lines
---
   bin/nv_perfmon.c                  | 12 ++++++------
   drm/nouveau/include/nvif/class.h  | 26 ++++++++++++++++----------
   drm/nouveau/include/nvif/ioctl.h  |  5 +++--
   drm/nouveau/nvkm/engine/pm/base.c | 38
++++++++++++++++++++++++++++++++------
   4 files changed, 57 insertions(+), 24 deletions(-)
bin/nv_perfmon.c +4 -5
index a8c5838..30a3138 100644
@@ -600,7 +600,7 @@ main(int argc, char **argv)
          const char *cfg = NULL;
          const char *dbg = "error";
          u64 dev = ~0ULL;
-       struct nvif_perfctr_query_v0 args = {};
+       struct nvif_perfmon_query_signal_v0 args = {};
          struct nvif_client *client;
          struct nvif_object object;
          int ret, c, k;
@@ -644,15 +644,14 @@ main(int argc, char **argv)
          }
 
          ret = nvif_object_init(nvif_object(device), NULL, 0xdeadbeef,
-                              NVIF_IOCTL_NEW_V0_PERFCTR,
-                              &(struct nvif_perfctr_v0) {
-                              }, sizeof(struct nvif_perfctr_v0),
 &object);
+                              NVIF_IOCTL_NEW_V0_PERFMON, NULL, 0,
 &object);
          assert(ret == 0);
          do {
                  u32 prev_iter = args.iter;
 
                  args.name[0] = '\0';
-               ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY, &args,
 sizeof(args));
+               ret = nvif_mthd(&object, NVIF_PERFMON_V0_QUERY_SIGNAL,
+                               &args, sizeof(args));
                  assert(ret == 0);

                  if (prev_iter) {
bin/nv_perfmon.c +2 -1
@@ -663,7 +662,8 @@ main(int argc, char **argv)
                          args.iter = prev_iter;
                          strncpy(signals[nr_signals - 1], args.name,
                                  sizeof(args.name));
-                       ret = nvif_mthd(&object, NVIF_PERFCTR_V0_QUERY,
 &args, sizeof(args));
+                       ret = nvif_mthd(&object,
 NVIF_PERFMON_V0_QUERY_SIGNAL,
+                                       &args, sizeof(args));
                          assert(ret == 0);
                  }
          } while (args.iter != 0xffffffff);
drm/nouveau/include/nvif/class.h +1 -0
index 64f8b2f..11935a0 100644
@@ -251,6 +251,20 @@ struct gf110_dma_v0 {
    * perfmon
 
 ******************************************************************************/
 
+#define NVIF_PERFMON_V0_QUERY_SIGNAL

0x00

drm/nouveau/include/nvif/class.h +12 -0
+
+struct nvif_perfmon_query_signal_v0 {
+       __u8  version;
+       __u8  pad01[3];
+       __u32 iter;
+       char  name[64];
+};
+
+
 
+/*******************************************************************************
+ * perfctr
+

******************************************************************************/

drm/nouveau/include/nvif/class.h +1 -1
+
   struct nvif_perfctr_v0 {
          __u8  version;
          __u8  pad01[1];
@@ -259,16 +273,8 @@ struct nvif_perfctr_v0 {
          char  name[4][64];
   };
 
-#define NVIF_PERFCTR_V0_QUERY

0x00
-#define NVIF_PERFCTR_V0_SAMPLE
0x01
-#define NVIF_PERFCTR_V0_READ
0x02

drm/nouveau/include/nvif/class.h +1 -7
-
-struct nvif_perfctr_query_v0 {
-       __u8  version;
-       __u8  pad01[3];
-       __u32 iter;
-       char  name[64];
-};
+#define NVIF_PERFCTR_V0_SAMPLE

0x00
+#define NVIF_PERFCTR_V0_READ
0x01

   struct nvif_perfctr_sample {
   };
drm/nouveau/include/nvif/ioctl.h +0 -1
index 4cd8e32..517cd27 100644
@@ -49,8 +49,9 @@ struct nvif_ioctl_new_v0 {
          __u64 token;
          __u32 handle;
   /* these class numbers are made up by us, and not nvidia-assigned */
-#define NVIF_IOCTL_NEW_V0_PERFCTR

0x0000ffff
-#define NVIF_IOCTL_NEW_V0_CONTROL
0x0000fffe
+#define NVIF_IOCTL_NEW_V0_PERFMON

Quoted 8 lines
Quoted 5 lines

0x0000ffff
+#define NVIF_IOCTL_NEW_V0_PERFCTR
0x0000fffe
+#define NVIF_IOCTL_NEW_V0_CONTROL
0x0000fffd

It doesn't matter this time, because we're technically breaking ABI already anyway and current userspace won't be effected, but best to avoid changing class numbers like this :) It's fine this time though.

Quoted 4 lines

Sure, since the nvif interface is still not exposed through libdrm, this is not going to affect userspace.
Btw, what is your plan about this? Are you going to merge nvif support to libdrm ?

Quoted 6 lines

Well, Ilia hasn't quite reviewed the patches yet still ;) But, you've been using them successfully so far, so that counts as review.

I have some changes that I haven't quite pushed yet that'll need some slight re-jigging of the libdrm series, but I'll push to merge it (finally) once that's done.

Sounds good to me. :-)

Quoted 110 lines
Quoted 110 lines
Quoted 109 lines
Quoted 87 lines

          __u32 oclass;
          __u8  data[];           /* class data (class.h) */

};

drm/nouveau/nvkm/engine/pm/base.c +2 -2
index 7b07e8b..cb88170 100644
@@ -83,10 +83,10 @@ nvkm_perfsig_find(struct nvkm_pm *ppm, const char
 *name, u32 size,
    * Perfmon object classes
 
 ******************************************************************************/
   static int
-nvkm_perfctr_query(struct nvkm_object *object, void *data, u32 size)
+nvkm_perfmon_mthd_query_signal(struct nvkm_object *object, void *data,
 u32 size)
   {
          union {
-               struct nvif_perfctr_query_v0 v0;
+               struct nvif_perfmon_query_signal_v0 v0;
          } *args = data;
          struct nvkm_device *device = nv_device(object);
          struct nvkm_pm *ppm = (void *)object->engine;
drm/nouveau/nvkm/engine/pm/base.c +2 -2
@@ -97,9 +97,9 @@ nvkm_perfctr_query(struct nvkm_object *object, void
 *data, u32 size)
          int tmp = 0, di, si;
          int ret;
 
-       nv_ioctl(object, "perfctr query size %d\n", size);
+       nv_ioctl(object, "perfmon query signal size %d\n", size);
          if (nvif_unpack(args->v0, 0, 0, false)) {
-               nv_ioctl(object, "perfctr query vers %d iter %08x\n",
+               nv_ioctl(object, "perfmon query signal vers %d iter
 %08x\n",
                           args->v0.version, args->v0.iter);
                  di = (args->v0.iter & 0xff000000) >> 24;
                  si = (args->v0.iter & 0x00ffffff) - 1;
drm/nouveau/nvkm/engine/pm/base.c +23 -0
@@ -142,6 +142,30 @@ nvkm_perfctr_query(struct nvkm_object *object, void
 *data, u32 size)
   }
 
   static int
+nvkm_perfmon_mthd(struct nvkm_object *object, u32 mthd, void *data, u32
 size)
+{
+       switch (mthd) {
+       case NVIF_PERFMON_V0_QUERY_SIGNAL:
+               return nvkm_perfmon_mthd_query_signal(object, data,
 size);
+       default:
+               break;
+       }
+       return -EINVAL;
+}
+
+static struct nvkm_ofuncs
+nvkm_perfmon_ofuncs = {
+       .ctor = _nvkm_object_ctor,
+       .dtor = nvkm_object_destroy,
+       .init = nvkm_object_init,
+       .fini = nvkm_object_fini,
+       .mthd = nvkm_perfmon_mthd,
+};
+
 
+/*******************************************************************************
+ * Perfctr object classes
+

******************************************************************************/

drm/nouveau/nvkm/engine/pm/base.c +1 -2
+static int
   nvkm_perfctr_sample(struct nvkm_object *object, void *data, u32 size)
   {
          union {
@@ -221,8 +245,6 @@ static int
   nvkm_perfctr_mthd(struct nvkm_object *object, u32 mthd, void *data, u32
 size)
   {
          switch (mthd) {
-       case NVIF_PERFCTR_V0_QUERY:
-               return nvkm_perfctr_query(object, data, size);
          case NVIF_PERFCTR_V0_SAMPLE:
                  return nvkm_perfctr_sample(object, data, size);

case NVIF_PERFCTR_V0_READ:

drm/nouveau/nvkm/engine/pm/base.c nvkm_perfctr_ofuncs = { · line 330

Quoted 10 lines
drm/nouveau/nvkm/engine/pm/base.c +4 -0
@@ -299,6 +321,10 @@ nvkm_perfctr_ofuncs = {
 
   struct nvkm_oclass
   nvkm_pm_sclass[] = {
+       {
+         .handle = NVIF_IOCTL_NEW_V0_PERFMON,
+         .ofuncs = &nvkm_perfmon_ofuncs,
+       },
          { .handle = NVIF_IOCTL_NEW_V0_PERFCTR,
            .ofuncs = &nvkm_perfctr_ofuncs,
          },

What I'd like to see here is that nvkm_pm_sclass() only has PERFMON, and PERFCTR is created as a child of it (like how all the PDISP channel objects are children of the main disp class). To do this, you need to create PERFMON as a nvkm_parent instead of an nvkm_object, and have its parent.sclass contain PERFMON. This will perhaps look a bit yucky for the moment, but I'm working on making things cleaner so I'll fix it later. Feel free to ping me on IRC if you need a hand making the change though.

I actually have a large patch series with the first part of this cleanup work queued up, but if you can make the above change first, I'll rebase my work on yours so you don't have to deal with that.

Quoted 7 lines
Quoted 3 lines

Okay, I'll take a look at the PDISP engine and make this change for the PM engine this week.
And if I have some other questions, I'll ping you on IRC.

Some work I've got queued up would conflict with these, so I've merged your patches ahead of time and made that change myself to avoid you having to rebase your whole series. Any fixes etc that'd been done since can be done as separate patches before going to Linus.

Well, I submitted two patches which fix some minor stuff to the series. Let met know if they are okay for you.

By the way, I also submitted a patch which adds compute signals/sources on Fermi.

Thanks,
Samuel.

Quoted 19 lines

Thanks,
Ben.

Quoted 15 lines

Thanks,
Samuel.

Quoted 10 lines

Thanks,
Ben.

Quoted 7 lines

--
2.4.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau