]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
drm/nouveau/dmaobj: merge everything except ctor and bind together
authorBen Skeggs <bskeggs@redhat.com>
Wed, 29 Aug 2012 00:54:49 +0000 (10:54 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 28 Nov 2012 23:56:37 +0000 (09:56 +1000)
Simplifies things a little, and currently no reason to need
chipset-specific dmaobj constructors.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/core/engine/dmaobj/base.c
drivers/gpu/drm/nouveau/core/engine/dmaobj/nv04.c
drivers/gpu/drm/nouveau/core/engine/dmaobj/nv50.c
drivers/gpu/drm/nouveau/core/engine/dmaobj/nvc0.c
drivers/gpu/drm/nouveau/core/include/engine/dmaobj.h

index e1f013d39768c30c70c481b97d408e707fb7dd67..9ca90613306afa4cc4bd392933c98f09a0c63f3e 100644 (file)
 #include <subdev/fb.h>
 #include <engine/dmaobj.h>
 
-int
-nouveau_dmaobj_create_(struct nouveau_object *parent,
-                      struct nouveau_object *engine,
-                      struct nouveau_oclass *oclass,
-                      void *data, u32 size, int len, void **pobject)
+static int
+nouveau_dmaobj_ctor(struct nouveau_object *parent,
+                   struct nouveau_object *engine,
+                   struct nouveau_oclass *oclass, void *data, u32 size,
+                   struct nouveau_object **pobject)
 {
+       struct nouveau_dmaeng *dmaeng = (void *)engine;
+       struct nouveau_dmaobj *dmaobj;
+       struct nouveau_gpuobj *gpuobj;
        struct nv_dma_class *args = data;
-       struct nouveau_dmaobj *object;
        int ret;
 
        if (size < sizeof(*args))
                return -EINVAL;
 
-       ret = nouveau_object_create_(parent, engine, oclass, 0, len, pobject);
-       object = *pobject;
+       ret = nouveau_object_create(parent, engine, oclass, 0, &dmaobj);
+       *pobject = nv_object(dmaobj);
        if (ret)
                return ret;
 
        switch (args->flags & NV_DMA_TARGET_MASK) {
        case NV_DMA_TARGET_VM:
-               object->target = NV_MEM_TARGET_VM;
+               dmaobj->target = NV_MEM_TARGET_VM;
                break;
        case NV_DMA_TARGET_VRAM:
-               object->target = NV_MEM_TARGET_VRAM;
+               dmaobj->target = NV_MEM_TARGET_VRAM;
                break;
        case NV_DMA_TARGET_PCI:
-               object->target = NV_MEM_TARGET_PCI;
+               dmaobj->target = NV_MEM_TARGET_PCI;
                break;
        case NV_DMA_TARGET_PCI_US:
        case NV_DMA_TARGET_AGP:
-               object->target = NV_MEM_TARGET_PCI_NOSNOOP;
+               dmaobj->target = NV_MEM_TARGET_PCI_NOSNOOP;
                break;
        default:
                return -EINVAL;
@@ -66,22 +68,58 @@ nouveau_dmaobj_create_(struct nouveau_object *parent,
 
        switch (args->flags & NV_DMA_ACCESS_MASK) {
        case NV_DMA_ACCESS_VM:
-               object->access = NV_MEM_ACCESS_VM;
+               dmaobj->access = NV_MEM_ACCESS_VM;
                break;
        case NV_DMA_ACCESS_RD:
-               object->access = NV_MEM_ACCESS_RO;
+               dmaobj->access = NV_MEM_ACCESS_RO;
                break;
        case NV_DMA_ACCESS_WR:
-               object->access = NV_MEM_ACCESS_WO;
+               dmaobj->access = NV_MEM_ACCESS_WO;
                break;
        case NV_DMA_ACCESS_RDWR:
-               object->access = NV_MEM_ACCESS_RW;
+               dmaobj->access = NV_MEM_ACCESS_RW;
                break;
        default:
                return -EINVAL;
        }
 
-       object->start = args->start;
-       object->limit = args->limit;
-       return 0;
+       dmaobj->start = args->start;
+       dmaobj->limit = args->limit;
+
+       switch (nv_mclass(parent)) {
+       case NV_DEVICE_CLASS:
+               break;
+       case NV03_CHANNEL_DMA_CLASS:
+       case NV10_CHANNEL_DMA_CLASS:
+       case NV17_CHANNEL_DMA_CLASS:
+       case NV40_CHANNEL_DMA_CLASS:
+       case NV50_CHANNEL_DMA_CLASS:
+       case NV84_CHANNEL_DMA_CLASS:
+       case NV50_CHANNEL_IND_CLASS:
+       case NV84_CHANNEL_IND_CLASS:
+               ret = dmaeng->bind(dmaeng, *pobject, dmaobj, &gpuobj);
+               nouveau_object_ref(NULL, pobject);
+               *pobject = nv_object(gpuobj);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return ret;
 }
+
+static struct nouveau_ofuncs
+nouveau_dmaobj_ofuncs = {
+       .ctor = nouveau_dmaobj_ctor,
+       .dtor = nouveau_object_destroy,
+       .init = nouveau_object_init,
+       .fini = nouveau_object_fini,
+};
+
+struct nouveau_oclass
+nouveau_dmaobj_sclass[] = {
+       { NV_DMA_FROM_MEMORY_CLASS, &nouveau_dmaobj_ofuncs },
+       { NV_DMA_TO_MEMORY_CLASS, &nouveau_dmaobj_ofuncs },
+       { NV_DMA_IN_MEMORY_CLASS, &nouveau_dmaobj_ofuncs },
+       {}
+};
index 9f4cc2f319945b57e7673416738b57492c509b0f..892387327667a33800d29f9bcd3eec67fcf540de 100644 (file)
@@ -34,10 +34,6 @@ struct nv04_dmaeng_priv {
        struct nouveau_dmaeng base;
 };
 
-struct nv04_dmaobj_priv {
-       struct nouveau_dmaobj base;
-};
-
 static int
 nv04_dmaobj_bind(struct nouveau_dmaeng *dmaeng,
                 struct nouveau_object *parent,
@@ -105,56 +101,6 @@ nv04_dmaobj_bind(struct nouveau_dmaeng *dmaeng,
        return ret;
 }
 
-static int
-nv04_dmaobj_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
-                struct nouveau_oclass *oclass, void *data, u32 size,
-                struct nouveau_object **pobject)
-{
-       struct nouveau_dmaeng *dmaeng = (void *)engine;
-       struct nv04_dmaobj_priv *dmaobj;
-       struct nouveau_gpuobj *gpuobj;
-       int ret;
-
-       ret = nouveau_dmaobj_create(parent, engine, oclass,
-                                   data, size, &dmaobj);
-       *pobject = nv_object(dmaobj);
-       if (ret)
-               return ret;
-
-       switch (nv_mclass(parent)) {
-       case NV_DEVICE_CLASS:
-               break;
-       case NV03_CHANNEL_DMA_CLASS:
-       case NV10_CHANNEL_DMA_CLASS:
-       case NV17_CHANNEL_DMA_CLASS:
-       case NV40_CHANNEL_DMA_CLASS:
-               ret = dmaeng->bind(dmaeng, *pobject, &dmaobj->base, &gpuobj);
-               nouveau_object_ref(NULL, pobject);
-               *pobject = nv_object(gpuobj);
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return ret;
-}
-
-static struct nouveau_ofuncs
-nv04_dmaobj_ofuncs = {
-       .ctor = nv04_dmaobj_ctor,
-       .dtor = _nouveau_dmaobj_dtor,
-       .init = _nouveau_dmaobj_init,
-       .fini = _nouveau_dmaobj_fini,
-};
-
-static struct nouveau_oclass
-nv04_dmaobj_sclass[] = {
-       { 0x0002, &nv04_dmaobj_ofuncs },
-       { 0x0003, &nv04_dmaobj_ofuncs },
-       { 0x003d, &nv04_dmaobj_ofuncs },
-       {}
-};
-
 static int
 nv04_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
                 struct nouveau_oclass *oclass, void *data, u32 size,
@@ -168,7 +114,7 @@ nv04_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
        if (ret)
                return ret;
 
-       priv->base.base.sclass = nv04_dmaobj_sclass;
+       nv_engine(priv)->sclass = nouveau_dmaobj_sclass;
        priv->base.bind = nv04_dmaobj_bind;
        return 0;
 }
index 045d2565e28941cf8cf1162ed4e04183c14aba8c..58876f53b3a43d9856c03c4e4eba528fccc1c104 100644 (file)
@@ -32,10 +32,6 @@ struct nv50_dmaeng_priv {
        struct nouveau_dmaeng base;
 };
 
-struct nv50_dmaobj_priv {
-       struct nouveau_dmaobj base;
-};
-
 static int
 nv50_dmaobj_bind(struct nouveau_dmaeng *dmaeng,
                 struct nouveau_object *parent,
@@ -93,56 +89,6 @@ nv50_dmaobj_bind(struct nouveau_dmaeng *dmaeng,
        return ret;
 }
 
-static int
-nv50_dmaobj_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
-                struct nouveau_oclass *oclass, void *data, u32 size,
-                struct nouveau_object **pobject)
-{
-       struct nouveau_dmaeng *dmaeng = (void *)engine;
-       struct nv50_dmaobj_priv *dmaobj;
-       struct nouveau_gpuobj *gpuobj;
-       int ret;
-
-       ret = nouveau_dmaobj_create(parent, engine, oclass,
-                                   data, size, &dmaobj);
-       *pobject = nv_object(dmaobj);
-       if (ret)
-               return ret;
-
-       switch (nv_mclass(parent)) {
-       case NV_DEVICE_CLASS:
-               break;
-       case NV50_CHANNEL_DMA_CLASS:
-       case NV84_CHANNEL_DMA_CLASS:
-       case NV50_CHANNEL_IND_CLASS:
-       case NV84_CHANNEL_IND_CLASS:
-               ret = dmaeng->bind(dmaeng, *pobject, &dmaobj->base, &gpuobj);
-               nouveau_object_ref(NULL, pobject);
-               *pobject = nv_object(gpuobj);
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return ret;
-}
-
-static struct nouveau_ofuncs
-nv50_dmaobj_ofuncs = {
-       .ctor = nv50_dmaobj_ctor,
-       .dtor = _nouveau_dmaobj_dtor,
-       .init = _nouveau_dmaobj_init,
-       .fini = _nouveau_dmaobj_fini,
-};
-
-static struct nouveau_oclass
-nv50_dmaobj_sclass[] = {
-       { 0x0002, &nv50_dmaobj_ofuncs },
-       { 0x0003, &nv50_dmaobj_ofuncs },
-       { 0x003d, &nv50_dmaobj_ofuncs },
-       {}
-};
-
 static int
 nv50_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
                 struct nouveau_oclass *oclass, void *data, u32 size,
@@ -156,7 +102,7 @@ nv50_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
        if (ret)
                return ret;
 
-       priv->base.base.sclass = nv50_dmaobj_sclass;
+       nv_engine(priv)->sclass = nouveau_dmaobj_sclass;
        priv->base.bind = nv50_dmaobj_bind;
        return 0;
 }
index 5baa086955354a96fb7dc6305568a670f1d10dcf..36de449162922be321a54c4c3569e577979d76c3 100644 (file)
  * Authors: Ben Skeggs
  */
 
-#include <core/gpuobj.h>
+#include <core/device.h>
 
-#include <subdev/fb.h>
 #include <engine/dmaobj.h>
 
 struct nvc0_dmaeng_priv {
        struct nouveau_dmaeng base;
 };
 
-struct nvc0_dmaobj_priv {
-       struct nouveau_dmaobj base;
-};
-
-static int
-nvc0_dmaobj_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
-                struct nouveau_oclass *oclass, void *data, u32 size,
-                struct nouveau_object **pobject)
-{
-       struct nvc0_dmaobj_priv *dmaobj;
-       int ret;
-
-       ret = nouveau_dmaobj_create(parent, engine, oclass, data, size, &dmaobj);
-       *pobject = nv_object(dmaobj);
-       if (ret)
-               return ret;
-
-       if (dmaobj->base.target != NV_MEM_TARGET_VM || dmaobj->base.start)
-               return -EINVAL;
-
-       return 0;
-}
-
-static struct nouveau_ofuncs
-nvc0_dmaobj_ofuncs = {
-       .ctor = nvc0_dmaobj_ctor,
-       .dtor = _nouveau_dmaobj_dtor,
-       .init = _nouveau_dmaobj_init,
-       .fini = _nouveau_dmaobj_fini,
-};
-
-static struct nouveau_oclass
-nvc0_dmaobj_sclass[] = {
-       { 0x0002, &nvc0_dmaobj_ofuncs },
-       { 0x0003, &nvc0_dmaobj_ofuncs },
-       { 0x003d, &nvc0_dmaobj_ofuncs },
-       {}
-};
-
 static int
 nvc0_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
                 struct nouveau_oclass *oclass, void *data, u32 size,
@@ -83,7 +43,7 @@ nvc0_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
        if (ret)
                return ret;
 
-       priv->base.base.sclass = nvc0_dmaobj_sclass;
+       nv_engine(priv)->sclass = nouveau_dmaobj_sclass;
        return 0;
 }
 
index 700ccbb1941fb08c91ca50400fd3f6b54c8d0f08..f61d1a8f5c17066ce269c999766a5ee2df2be4a7 100644 (file)
@@ -14,23 +14,6 @@ struct nouveau_dmaobj {
        u64 limit;
 };
 
-#define nouveau_dmaobj_create(p,e,c,a,s,d)                                     \
-       nouveau_dmaobj_create_((p), (e), (c), (a), (s), sizeof(**d), (void **)d)
-#define nouveau_dmaobj_destroy(p)                                              \
-       nouveau_object_destroy(&(p)->base)
-#define nouveau_dmaobj_init(p)                                                 \
-       nouveau_object_init(&(p)->base)
-#define nouveau_dmaobj_fini(p,s)                                               \
-       nouveau_object_fini(&(p)->base, (s))
-
-int nouveau_dmaobj_create_(struct nouveau_object *, struct nouveau_object *,
-                          struct nouveau_oclass *, void *data, u32 size,
-                          int length, void **);
-
-#define _nouveau_dmaobj_dtor nouveau_object_destroy
-#define _nouveau_dmaobj_init nouveau_object_init
-#define _nouveau_dmaobj_fini nouveau_object_fini
-
 struct nouveau_dmaeng {
        struct nouveau_engine base;
        int (*bind)(struct nouveau_dmaeng *, struct nouveau_object *parent,
@@ -54,4 +37,6 @@ extern struct nouveau_oclass nv04_dmaeng_oclass;
 extern struct nouveau_oclass nv50_dmaeng_oclass;
 extern struct nouveau_oclass nvc0_dmaeng_oclass;
 
+extern struct nouveau_oclass nouveau_dmaobj_sclass[];
+
 #endif