drm/nouveau/pm: allow to query signals by domain
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 7 Jun 2015 20:40:18 +0000 (22:40 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 28 Aug 2015 02:39:58 +0000 (12:39 +1000)
This will allow to configure performance counters with hardware signal
indexes instead of user-readable names in an upcoming patch.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvif/class.h
drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c

index 0b28929f5be6c9d4f73829478acdd6a6177dc503..cf2af89b711242af552a3606aa73e4f5af1ade1a 100644 (file)
@@ -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];
 };
index 3d9bcbc1064c50c53993aee761b01a6d08d8e6ef..d61beffd2404e875e9cd417e2e038553e97e5549 100644 (file)
@@ -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;