drm/nouveau/pm: allow to query the number of sources for a signal
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 7 Jun 2015 20:40:23 +0000 (22:40 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 28 Aug 2015 02:39:59 +0000 (12:39 +1000)
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 9e4db3aaada7de2eba92978f5325d1205f0b7ebf..caae193f354e87b907bbdc63a267b076e07ee530 100644 (file)
@@ -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];
 };
 
index dfafefd9facf12b2fc95992e68778d2bd7d61d4b..a9c57a20186ad0919b730ea70dc7bcd27c80c9e1 100644 (file)
@@ -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) {