]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/nouveau/fifo/gk104-: simplify definition of channel classes
authorBen Skeggs <bskeggs@redhat.com>
Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 18 May 2018 05:01:21 +0000 (15:01 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
18 files changed:
drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/changk104.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk110.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk208.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk20a.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm107.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm200.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm20b.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gp100.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gp10b.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk110.c [deleted file]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogm200.c [deleted file]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogp100.c [deleted file]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h

index 64e51838edf857733a54736b9a95aeb772d037d9..b888ea64df21046317d6ad8a68e3cdcab2b506fb 100644 (file)
@@ -31,6 +31,3 @@ nvkm-y += nvkm/engine/fifo/gpfifonv50.o
 nvkm-y += nvkm/engine/fifo/gpfifog84.o
 nvkm-y += nvkm/engine/fifo/gpfifogf100.o
 nvkm-y += nvkm/engine/fifo/gpfifogk104.o
-nvkm-y += nvkm/engine/fifo/gpfifogk110.o
-nvkm-y += nvkm/engine/fifo/gpfifogm200.o
-nvkm-y += nvkm/engine/fifo/gpfifogp100.o
index 1642d8ea68f1ceaa98fbfd8296639e848aeba432..c773caf21f6be068a464d6bf64f0a3449cc49382 100644 (file)
@@ -215,6 +215,20 @@ nvkm_fifo_uevent(struct nvkm_fifo *fifo)
        nvkm_event_send(&fifo->uevent, 1, 0, &rep, sizeof(rep));
 }
 
+static int
+nvkm_fifo_class_new_(struct nvkm_device *device,
+                    const struct nvkm_oclass *oclass, void *data, u32 size,
+                    struct nvkm_object **pobject)
+{
+       struct nvkm_fifo *fifo = nvkm_fifo(oclass->engine);
+       return fifo->func->class_new(fifo, oclass, data, size, pobject);
+}
+
+static const struct nvkm_device_oclass
+nvkm_fifo_class_ = {
+       .ctor = nvkm_fifo_class_new_,
+};
+
 static int
 nvkm_fifo_class_new(struct nvkm_device *device,
                    const struct nvkm_oclass *oclass, void *data, u32 size,
@@ -239,13 +253,9 @@ nvkm_fifo_class_get(struct nvkm_oclass *oclass, int index,
        int c = 0;
 
        if (fifo->func->class_get) {
-               int ret = fifo->func->class_get(fifo, index, &sclass);
-               if (ret == 0) {
-                       oclass->base = sclass->base;
-                       oclass->engn = sclass;
-                       *class = &nvkm_fifo_class;
-                       return 0;
-               }
+               int ret = fifo->func->class_get(fifo, index, oclass);
+               if (ret == 0)
+                       *class = &nvkm_fifo_class_;
                return ret;
        }
 
index 1208e3d9dbe283da18ad25435272815bf0084b6f..08b4415f0e24e09ceb989d93fbc8e856831f38a2 100644 (file)
@@ -19,11 +19,6 @@ struct gk104_fifo_chan {
        } engn[NVKM_SUBDEV_NR];
 };
 
-int gk104_fifo_gpfifo_new(struct nvkm_fifo *, const struct nvkm_oclass *,
+int gk104_fifo_gpfifo_new(struct gk104_fifo *, const struct nvkm_oclass *,
                          void *data, u32 size, struct nvkm_object **);
-
-extern const struct nvkm_fifo_chan_oclass gk104_fifo_gpfifo_oclass;
-extern const struct nvkm_fifo_chan_oclass gk110_fifo_gpfifo_oclass;
-extern const struct nvkm_fifo_chan_oclass gm200_fifo_gpfifo_oclass;
-extern const struct nvkm_fifo_chan_oclass gp100_fifo_gpfifo_oclass;
 #endif
index b6c23cf43f832b90e33834baa501062c6050c384..316b2b1d08e830c7227c4517dadace3561eb65ec 100644 (file)
@@ -94,16 +94,30 @@ gk104_fifo_engine_status(struct gk104_fifo *fifo, int engn,
                   status->chan == &status->next ? "*" : " ");
 }
 
+static int
+gk104_fifo_class_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
+                    void *argv, u32 argc, struct nvkm_object **pobject)
+{
+       struct gk104_fifo *fifo = gk104_fifo(base);
+       if (oclass->engn == &fifo->func->chan) {
+               const struct gk104_fifo_chan_user *user = oclass->engn;
+               return user->ctor(fifo, oclass, argv, argc, pobject);
+       }
+       WARN_ON(1);
+       return -EINVAL;
+}
+
 static int
 gk104_fifo_class_get(struct nvkm_fifo *base, int index,
-                    const struct nvkm_fifo_chan_oclass **psclass)
+                    struct nvkm_oclass *oclass)
 {
        struct gk104_fifo *fifo = gk104_fifo(base);
        int c = 0;
 
-       while ((*psclass = fifo->func->chan[c])) {
-               if (c++ == index)
-                       return 0;
+       if (fifo->func->chan.ctor && c++ == index) {
+               oclass->base =  fifo->func->chan.user;
+               oclass->engn = &fifo->func->chan;
+               return 0;
        }
 
        return c;
@@ -950,6 +964,7 @@ gk104_fifo_ = {
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = gk104_fifo_recover_chan,
        .class_get = gk104_fifo_class_get,
+       .class_new = gk104_fifo_class_new,
 };
 
 int
@@ -1096,10 +1111,7 @@ gk104_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .chan = {
-               &gk104_fifo_gpfifo_oclass,
-               NULL
-       },
+       .chan = {{0,0,KEPLER_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
 int
index 0e8b57275e9dd3e5b2502ffa29e1fe12127e1a10..41f1f367eaebbf826c031b3b498b3e4d6d38366b 100644 (file)
@@ -51,7 +51,11 @@ struct gk104_fifo_func {
                const struct nvkm_enum *gpcclient;
        } fault;
 
-       const struct nvkm_fifo_chan_oclass *chan[];
+       struct gk104_fifo_chan_user {
+               struct nvkm_sclass user;
+               int (*ctor)(struct gk104_fifo *, const struct nvkm_oclass *,
+                           void *, u32, struct nvkm_object **);
+       } chan;
 };
 
 int gk104_fifo_new_(const struct gk104_fifo_func *, struct nvkm_device *,
index ad792b6830e5768e83094252ee3b1e1e33a874bd..9611bf1ad0b0a53888671bcc366666c0021a703c 100644 (file)
@@ -24,6 +24,8 @@
 #include "gk104.h"
 #include "changk104.h"
 
+#include <nvif/class.h>
+
 static const struct gk104_fifo_func
 gk110_fifo = {
        .fault.access = gk104_fifo_fault_access,
@@ -31,10 +33,7 @@ gk110_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .chan = {
-               &gk110_fifo_gpfifo_oclass,
-               NULL
-       },
+       .chan = {{0,0,KEPLER_CHANNEL_GPFIFO_B}, gk104_fifo_gpfifo_new },
 };
 
 int
index 5402d22462e86fcf6f50c77f3cc778820ad83e1c..fabc690ddd56e88bfd3a3eed6698863066f4ff3b 100644 (file)
@@ -24,6 +24,8 @@
 #include "gk104.h"
 #include "changk104.h"
 
+#include <nvif/class.h>
+
 static const struct gk104_fifo_func
 gk208_fifo = {
        .fault.access = gk104_fifo_fault_access,
@@ -31,10 +33,7 @@ gk208_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .chan = {
-               &gk104_fifo_gpfifo_oclass,
-               NULL
-       },
+       .chan = {{0,0,KEPLER_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
 int
index 0d7f9f59f80c88f6afdd87ce5f6e7507169eed2b..dee1bd76882a4b6c290198f0f654956e5048575a 100644 (file)
@@ -22,6 +22,8 @@
 #include "gk104.h"
 #include "changk104.h"
 
+#include <nvif/class.h>
+
 static const struct gk104_fifo_func
 gk20a_fifo = {
        .fault.access = gk104_fifo_fault_access,
@@ -29,10 +31,7 @@ gk20a_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .chan = {
-               &gk104_fifo_gpfifo_oclass,
-               NULL
-       },
+       .chan = {{0,0,KEPLER_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
 int
index 58a46ee5ee440c9df9d5842272401030a9b4132a..09f97827167aba14ec7e53224826d04903a2a061 100644 (file)
@@ -24,6 +24,8 @@
 #include "gk104.h"
 #include "changk104.h"
 
+#include <nvif/class.h>
+
 const struct nvkm_enum
 gm107_fifo_fault_engine[] = {
        { 0x01, "DISPLAY" },
@@ -54,10 +56,7 @@ gm107_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .chan = {
-               &gk110_fifo_gpfifo_oclass,
-               NULL
-       },
+       .chan = {{0,0,KEPLER_CHANNEL_GPFIFO_B}, gk104_fifo_gpfifo_new },
 };
 
 int
index f84d5398aebebd02a74ee21336c2af863274e467..052b7c2c5d7644bc257194368fed91a20a93461b 100644 (file)
@@ -24,6 +24,8 @@
 #include "gk104.h"
 #include "changk104.h"
 
+#include <nvif/class.h>
+
 static const struct gk104_fifo_func
 gm200_fifo = {
        .fault.access = gk104_fifo_fault_access,
@@ -31,10 +33,7 @@ gm200_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .chan = {
-               &gm200_fifo_gpfifo_oclass,
-               NULL
-       },
+       .chan = {{0,0,MAXWELL_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
 int
index 66399b9572a686d8b62dc623919eb10ab678616a..844787c6fb62ba834c59b495f21d33b67fe2c6cd 100644 (file)
@@ -22,6 +22,8 @@
 #include "gk104.h"
 #include "changk104.h"
 
+#include <nvif/class.h>
+
 static const struct gk104_fifo_func
 gm20b_fifo = {
        .fault.access = gk104_fifo_fault_access,
@@ -29,10 +31,7 @@ gm20b_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .chan = {
-               &gm200_fifo_gpfifo_oclass,
-               NULL
-       },
+       .chan = {{0,0,MAXWELL_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
 int
index 2b8a6cff7a6863ffb1bc31759717d1d9139f070c..2e31847e2e4fd616fae336a83f73805c751ee438 100644 (file)
@@ -24,6 +24,8 @@
 #include "gk104.h"
 #include "changk104.h"
 
+#include <nvif/class.h>
+
 const struct nvkm_enum
 gp100_fifo_fault_engine[] = {
        { 0x01, "DISPLAY" },
@@ -55,10 +57,7 @@ gp100_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .chan = {
-               &gp100_fifo_gpfifo_oclass,
-               NULL
-       },
+       .chan = {{0,0,PASCAL_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
 int
index 71b8d93b4368e1067205ad9cf50b724965ec0172..38ab6e17ec157827880a3300fcb451d842668c5e 100644 (file)
@@ -22,6 +22,8 @@
 #include "gk104.h"
 #include "changk104.h"
 
+#include <nvif/class.h>
+
 static const struct gk104_fifo_func
 gp10b_fifo = {
        .fault.access = gk104_fifo_fault_access,
@@ -29,10 +31,7 @@ gp10b_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .chan = {
-               &gp100_fifo_gpfifo_oclass,
-               NULL
-       },
+       .chan = {{0,0,PASCAL_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
 int
index e331ab1b702b2d9cef13679bed224c7733d99f3d..f7a4e0e86b23a4d54113ca8c23d039c7848cae9c 100644 (file)
@@ -296,14 +296,13 @@ gk104_fifo_gpfifo_new_(struct gk104_fifo *fifo, u64 *runlists, u16 *chid,
 }
 
 int
-gk104_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
+gk104_fifo_gpfifo_new(struct gk104_fifo *fifo, const struct nvkm_oclass *oclass,
                      void *data, u32 size, struct nvkm_object **pobject)
 {
        struct nvkm_object *parent = oclass->parent;
        union {
                struct kepler_channel_gpfifo_a_v0 v0;
        } *args = data;
-       struct gk104_fifo *fifo = gk104_fifo(base);
        int ret = -ENOSYS;
 
        nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
@@ -324,11 +323,3 @@ gk104_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
 
        return ret;
 }
-
-const struct nvkm_fifo_chan_oclass
-gk104_fifo_gpfifo_oclass = {
-       .base.oclass = KEPLER_CHANNEL_GPFIFO_A,
-       .base.minver = 0,
-       .base.maxver = 0,
-       .ctor = gk104_fifo_gpfifo_new,
-};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk110.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk110.c
deleted file mode 100644 (file)
index a9aa69c..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "changk104.h"
-
-#include <nvif/class.h>
-
-const struct nvkm_fifo_chan_oclass
-gk110_fifo_gpfifo_oclass = {
-       .base.oclass = KEPLER_CHANNEL_GPFIFO_B,
-       .base.minver = 0,
-       .base.maxver = 0,
-       .ctor = gk104_fifo_gpfifo_new,
-};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogm200.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogm200.c
deleted file mode 100644 (file)
index a133151..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "changk104.h"
-
-#include <nvif/class.h>
-
-const struct nvkm_fifo_chan_oclass
-gm200_fifo_gpfifo_oclass = {
-       .base.oclass = MAXWELL_CHANNEL_GPFIFO_A,
-       .base.minver = 0,
-       .base.maxver = 0,
-       .ctor = gk104_fifo_gpfifo_new,
-};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogp100.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogp100.c
deleted file mode 100644 (file)
index 1530a92..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs
- */
-#include "changk104.h"
-
-#include <nvif/class.h>
-
-const struct nvkm_fifo_chan_oclass
-gp100_fifo_gpfifo_oclass = {
-       .base.oclass = PASCAL_CHANNEL_GPFIFO_A,
-       .base.minver = 0,
-       .base.maxver = 0,
-       .ctor = gk104_fifo_gpfifo_new,
-};
index f9b4e9d2c08ab1a88100cb20258c9c2a0c0a1903..d5acbba293f4492ac4e221aa43425c1ed422a2a4 100644 (file)
@@ -28,8 +28,9 @@ struct nvkm_fifo_func {
        void (*uevent_init)(struct nvkm_fifo *);
        void (*uevent_fini)(struct nvkm_fifo *);
        void (*recover_chan)(struct nvkm_fifo *, int chid);
-       int (*class_get)(struct nvkm_fifo *, int index,
-                        const struct nvkm_fifo_chan_oclass **);
+       int (*class_get)(struct nvkm_fifo *, int index, struct nvkm_oclass *);
+       int (*class_new)(struct nvkm_fifo *, const struct nvkm_oclass *,
+                        void *, u32, struct nvkm_object **);
        const struct nvkm_fifo_chan_oclass *chan[];
 };