]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/nouveau/pm: add concept of sources
authorSamuel Pitoiset <samuel.pitoisetœgmail.com>
Sun, 7 Jun 2015 20:40:22 +0000 (22:40 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 28 Aug 2015 02:39:59 +0000 (12:39 +1000)
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>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/engine/pm.h
drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
drivers/gpu/drm/nouveau/nvkm/engine/pm/priv.h

index 6c2d0578400a0c46ab788a911e4cead0de23124d..130b545b4e9e9d0c79a769c8a190e03a689a890d 100644 (file)
@@ -11,6 +11,7 @@ struct nvkm_pm {
        void *profile_data;
 
        struct list_head domains;
+       struct list_head sources;
        u32 sequence;
 };
 
index 610c0ca5c80b80b86a7d85904d2108fd8f9036bc..dfafefd9facf12b2fc95992e68778d2bd7d61d4b 100644 (file)
@@ -433,6 +433,67 @@ nvkm_pm_cclass = {
 /*******************************************************************************
  * PPM engine/subdev functions
  ******************************************************************************/
+int
+nvkm_perfsrc_new(struct nvkm_pm *ppm, struct nvkm_perfsig *sig,
+                const struct nvkm_specsrc *spec)
+{
+       const struct nvkm_specsrc *ssrc;
+       const struct nvkm_specmux *smux;
+       struct nvkm_perfsrc *src;
+       u8 source_nr = 0;
+
+       if (!spec) {
+               /* No sources are defined for this signal. */
+               return 0;
+       }
+
+       ssrc = spec;
+       while (ssrc->name) {
+               smux = ssrc->mux;
+               while (smux->name) {
+                       bool found = false;
+                       u8 source_id = 0;
+                       u32 len;
+
+                       list_for_each_entry(src, &ppm->sources, head) {
+                               if (src->addr == ssrc->addr &&
+                                   src->shift == smux->shift) {
+                                       found = true;
+                                       break;
+                               }
+                               source_id++;
+                       }
+
+                       if (!found) {
+                               src = kzalloc(sizeof(*src), GFP_KERNEL);
+                               if (!src)
+                                       return -ENOMEM;
+
+                               src->addr   = ssrc->addr;
+                               src->mask   = smux->mask;
+                               src->shift  = smux->shift;
+                               src->enable = smux->enable;
+
+                               len = strlen(ssrc->name) +
+                                     strlen(smux->name) + 2;
+                               src->name = kzalloc(len, GFP_KERNEL);
+                               if (!src->name)
+                                       return -ENOMEM;
+                               snprintf(src->name, len, "%s_%s", ssrc->name,
+                                        smux->name);
+
+                               list_add_tail(&src->head, &ppm->sources);
+                       }
+
+                       sig->source[source_nr++] = source_id + 1;
+                       smux++;
+               }
+               ssrc++;
+       }
+
+       return 0;
+}
+
 int
 nvkm_perfdom_new(struct nvkm_pm *ppm, const char *name, u32 mask,
                 u32 base, u32 size_unit, u32 size_domain,
@@ -441,7 +502,7 @@ nvkm_perfdom_new(struct nvkm_pm *ppm, const char *name, u32 mask,
        const struct nvkm_specdom *sdom;
        const struct nvkm_specsig *ssig;
        struct nvkm_perfdom *dom;
-       int i;
+       int ret, i;
 
        for (i = 0; i == 0 || mask; i++) {
                u32 addr = base + (i * size_unit);
@@ -473,7 +534,12 @@ nvkm_perfdom_new(struct nvkm_pm *ppm, const char *name, u32 mask,
 
                        ssig = (sdom++)->signal;
                        while (ssig->name) {
-                               dom->signal[ssig->signal].name = ssig->name;
+                               struct nvkm_perfsig *sig =
+                                       &dom->signal[ssig->signal];
+                               sig->name = ssig->name;
+                               ret = nvkm_perfsrc_new(ppm, sig, ssig->source);
+                               if (ret)
+                                       return ret;
                                ssig++;
                        }
 
@@ -504,13 +570,20 @@ void
 _nvkm_pm_dtor(struct nvkm_object *object)
 {
        struct nvkm_pm *ppm = (void *)object;
-       struct nvkm_perfdom *dom, *tmp;
+       struct nvkm_perfdom *dom, *next_dom;
+       struct nvkm_perfsrc *src, *next_src;
 
-       list_for_each_entry_safe(dom, tmp, &ppm->domains, head) {
+       list_for_each_entry_safe(dom, next_dom, &ppm->domains, head) {
                list_del(&dom->head);
                kfree(dom);
        }
 
+       list_for_each_entry_safe(src, next_src, &ppm->sources, head) {
+               list_del(&src->head);
+               kfree(src->name);
+               kfree(src);
+       }
+
        nvkm_engine_destroy(&ppm->base);
 }
 
@@ -528,5 +601,6 @@ nvkm_pm_create_(struct nvkm_object *parent, struct nvkm_object *engine,
                return ret;
 
        INIT_LIST_HEAD(&ppm->domains);
+       INIT_LIST_HEAD(&ppm->sources);
        return 0;
 }
index 71667fcbd9de266b5097cc1d54ee41d97f6b3f82..f954c98685940f6b545de5fe8339f0fa56c4f82f 100644 (file)
@@ -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 {