drm/nouveau/core: move falcon class to engine/
authorBen Skeggs <bskeggs@redhat.com>
Thu, 27 Jun 2013 03:59:01 +0000 (13:59 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Mon, 1 Jul 2013 03:50:47 +0000 (13:50 +1000)
Not really "core" per-se.  About to merge Ilia's work adding another
similar class for the VP2 xtensa engines, so, seems like a good time to
move all these to engine/.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
13 files changed:
drivers/gpu/drm/nouveau/Makefile
drivers/gpu/drm/nouveau/core/core/falcon.c [deleted file]
drivers/gpu/drm/nouveau/core/engine/bsp/nvc0.c
drivers/gpu/drm/nouveau/core/engine/bsp/nve0.c
drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
drivers/gpu/drm/nouveau/core/engine/copy/nvc0.c
drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
drivers/gpu/drm/nouveau/core/engine/falcon.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/core/engine/ppp/nvc0.c
drivers/gpu/drm/nouveau/core/engine/vp/nvc0.c
drivers/gpu/drm/nouveau/core/engine/vp/nve0.c
drivers/gpu/drm/nouveau/core/include/core/falcon.h [deleted file]
drivers/gpu/drm/nouveau/core/include/engine/falcon.h [new file with mode: 0644]

index 3eb0d08c315bcf3faac36b9d42f0bfa8fc9a867d..5a2695f2759adb28eb71161928fa3c6d81abc0d8 100644 (file)
@@ -12,7 +12,6 @@ nouveau-y += core/core/engctx.o
 nouveau-y += core/core/engine.o
 nouveau-y += core/core/enum.o
 nouveau-y += core/core/event.o
-nouveau-y += core/core/falcon.o
 nouveau-y += core/core/gpuobj.o
 nouveau-y += core/core/handle.o
 nouveau-y += core/core/mm.o
@@ -142,6 +141,7 @@ nouveau-y += core/subdev/vm/nv44.o
 nouveau-y += core/subdev/vm/nv50.o
 nouveau-y += core/subdev/vm/nvc0.o
 
+nouveau-y += core/engine/falcon.o
 nouveau-y += core/engine/dmaobj/base.o
 nouveau-y += core/engine/dmaobj/nv04.o
 nouveau-y += core/engine/dmaobj/nv50.o
diff --git a/drivers/gpu/drm/nouveau/core/core/falcon.c b/drivers/gpu/drm/nouveau/core/core/falcon.c
deleted file mode 100644 (file)
index e05c157..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2012 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.
- */
-
-#include <core/falcon.h>
-
-#include <subdev/timer.h>
-
-u32
-_nouveau_falcon_rd32(struct nouveau_object *object, u64 addr)
-{
-       struct nouveau_falcon *falcon = (void *)object;
-       return nv_rd32(falcon, falcon->addr + addr);
-}
-
-void
-_nouveau_falcon_wr32(struct nouveau_object *object, u64 addr, u32 data)
-{
-       struct nouveau_falcon *falcon = (void *)object;
-       nv_wr32(falcon, falcon->addr + addr, data);
-}
-
-int
-_nouveau_falcon_init(struct nouveau_object *object)
-{
-       struct nouveau_device *device = nv_device(object);
-       struct nouveau_falcon *falcon = (void *)object;
-       const struct firmware *fw;
-       char name[32] = "internal";
-       int ret, i;
-       u32 caps;
-
-       /* enable engine, and determine its capabilities */
-       ret = nouveau_engine_init(&falcon->base);
-       if (ret)
-               return ret;
-
-       if (device->chipset <  0xa3 ||
-           device->chipset == 0xaa || device->chipset == 0xac) {
-               falcon->version = 0;
-               falcon->secret  = (falcon->addr == 0x087000) ? 1 : 0;
-       } else {
-               caps = nv_ro32(falcon, 0x12c);
-               falcon->version = (caps & 0x0000000f);
-               falcon->secret  = (caps & 0x00000030) >> 4;
-       }
-
-       caps = nv_ro32(falcon, 0x108);
-       falcon->code.limit = (caps & 0x000001ff) << 8;
-       falcon->data.limit = (caps & 0x0003fe00) >> 1;
-
-       nv_debug(falcon, "falcon version: %d\n", falcon->version);
-       nv_debug(falcon, "secret level: %d\n", falcon->secret);
-       nv_debug(falcon, "code limit: %d\n", falcon->code.limit);
-       nv_debug(falcon, "data limit: %d\n", falcon->data.limit);
-
-       /* wait for 'uc halted' to be signalled before continuing */
-       if (falcon->secret && falcon->version < 4) {
-               if (!falcon->version)
-                       nv_wait(falcon, 0x008, 0x00000010, 0x00000010);
-               else
-                       nv_wait(falcon, 0x180, 0x80000000, 0);
-               nv_wo32(falcon, 0x004, 0x00000010);
-       }
-
-       /* disable all interrupts */
-       nv_wo32(falcon, 0x014, 0xffffffff);
-
-       /* no default ucode provided by the engine implementation, try and
-        * locate a "self-bootstrapping" firmware image for the engine
-        */
-       if (!falcon->code.data) {
-               snprintf(name, sizeof(name), "nouveau/nv%02x_fuc%03x",
-                        device->chipset, falcon->addr >> 12);
-
-               ret = request_firmware(&fw, name, &device->pdev->dev);
-               if (ret == 0) {
-                       falcon->code.data = kmemdup(fw->data, fw->size, GFP_KERNEL);
-                       falcon->code.size = fw->size;
-                       falcon->data.data = NULL;
-                       falcon->data.size = 0;
-                       release_firmware(fw);
-               }
-
-               falcon->external = true;
-       }
-
-       /* next step is to try and load "static code/data segment" firmware
-        * images for the engine
-        */
-       if (!falcon->code.data) {
-               snprintf(name, sizeof(name), "nouveau/nv%02x_fuc%03xd",
-                        device->chipset, falcon->addr >> 12);
-
-               ret = request_firmware(&fw, name, &device->pdev->dev);
-               if (ret) {
-                       nv_error(falcon, "unable to load firmware data\n");
-                       return ret;
-               }
-
-               falcon->data.data = kmemdup(fw->data, fw->size, GFP_KERNEL);
-               falcon->data.size = fw->size;
-               release_firmware(fw);
-               if (!falcon->data.data)
-                       return -ENOMEM;
-
-               snprintf(name, sizeof(name), "nouveau/nv%02x_fuc%03xc",
-                        device->chipset, falcon->addr >> 12);
-
-               ret = request_firmware(&fw, name, &device->pdev->dev);
-               if (ret) {
-                       nv_error(falcon, "unable to load firmware code\n");
-                       return ret;
-               }
-
-               falcon->code.data = kmemdup(fw->data, fw->size, GFP_KERNEL);
-               falcon->code.size = fw->size;
-               release_firmware(fw);
-               if (!falcon->code.data)
-                       return -ENOMEM;
-       }
-
-       nv_debug(falcon, "firmware: %s (%s)\n", name, falcon->data.data ?
-                "static code/data segments" : "self-bootstrapping");
-
-       /* ensure any "self-bootstrapping" firmware image is in vram */
-       if (!falcon->data.data && !falcon->core) {
-               ret = nouveau_gpuobj_new(object->parent, NULL,
-                                        falcon->code.size, 256, 0,
-                                       &falcon->core);
-               if (ret) {
-                       nv_error(falcon, "core allocation failed, %d\n", ret);
-                       return ret;
-               }
-
-               for (i = 0; i < falcon->code.size; i += 4)
-                       nv_wo32(falcon->core, i, falcon->code.data[i / 4]);
-       }
-
-       /* upload firmware bootloader (or the full code segments) */
-       if (falcon->core) {
-               if (device->card_type < NV_C0)
-                       nv_wo32(falcon, 0x618, 0x04000000);
-               else
-                       nv_wo32(falcon, 0x618, 0x00000114);
-               nv_wo32(falcon, 0x11c, 0);
-               nv_wo32(falcon, 0x110, falcon->core->addr >> 8);
-               nv_wo32(falcon, 0x114, 0);
-               nv_wo32(falcon, 0x118, 0x00006610);
-       } else {
-               if (falcon->code.size > falcon->code.limit ||
-                   falcon->data.size > falcon->data.limit) {
-                       nv_error(falcon, "ucode exceeds falcon limit(s)\n");
-                       return -EINVAL;
-               }
-
-               if (falcon->version < 3) {
-                       nv_wo32(falcon, 0xff8, 0x00100000);
-                       for (i = 0; i < falcon->code.size / 4; i++)
-                               nv_wo32(falcon, 0xff4, falcon->code.data[i]);
-               } else {
-                       nv_wo32(falcon, 0x180, 0x01000000);
-                       for (i = 0; i < falcon->code.size / 4; i++) {
-                               if ((i & 0x3f) == 0)
-                                       nv_wo32(falcon, 0x188, i >> 6);
-                               nv_wo32(falcon, 0x184, falcon->code.data[i]);
-                       }
-               }
-       }
-
-       /* upload data segment (if necessary), zeroing the remainder */
-       if (falcon->version < 3) {
-               nv_wo32(falcon, 0xff8, 0x00000000);
-               for (i = 0; !falcon->core && i < falcon->data.size / 4; i++)
-                       nv_wo32(falcon, 0xff4, falcon->data.data[i]);
-               for (; i < falcon->data.limit; i += 4)
-                       nv_wo32(falcon, 0xff4, 0x00000000);
-       } else {
-               nv_wo32(falcon, 0x1c0, 0x01000000);
-               for (i = 0; !falcon->core && i < falcon->data.size / 4; i++)
-                       nv_wo32(falcon, 0x1c4, falcon->data.data[i]);
-               for (; i < falcon->data.limit / 4; i++)
-                       nv_wo32(falcon, 0x1c4, 0x00000000);
-       }
-
-       /* start it running */
-       nv_wo32(falcon, 0x10c, 0x00000001); /* BLOCK_ON_FIFO */
-       nv_wo32(falcon, 0x104, 0x00000000); /* ENTRY */
-       nv_wo32(falcon, 0x100, 0x00000002); /* TRIGGER */
-       nv_wo32(falcon, 0x048, 0x00000003); /* FIFO | CHSW */
-       return 0;
-}
-
-int
-_nouveau_falcon_fini(struct nouveau_object *object, bool suspend)
-{
-       struct nouveau_falcon *falcon = (void *)object;
-
-       if (!suspend) {
-               nouveau_gpuobj_ref(NULL, &falcon->core);
-               if (falcon->external) {
-                       kfree(falcon->data.data);
-                       kfree(falcon->code.data);
-                       falcon->code.data = NULL;
-               }
-       }
-
-       nv_mo32(falcon, 0x048, 0x00000003, 0x00000000);
-       nv_wo32(falcon, 0x014, 0xffffffff);
-
-       return nouveau_engine_fini(&falcon->base, suspend);
-}
-
-int
-nouveau_falcon_create_(struct nouveau_object *parent,
-                      struct nouveau_object *engine,
-                      struct nouveau_oclass *oclass, u32 addr, bool enable,
-                      const char *iname, const char *fname,
-                      int length, void **pobject)
-{
-       struct nouveau_falcon *falcon;
-       int ret;
-
-       ret = nouveau_engine_create_(parent, engine, oclass, enable, iname,
-                                    fname, length, pobject);
-       falcon = *pobject;
-       if (ret)
-               return ret;
-
-       falcon->addr = addr;
-       return 0;
-}
index 0a5aa6bb08706b58ffea4bb9a64f055e05fd11d5..262c9f5f5f60b322d1a122fe44d99e86d079c818 100644 (file)
@@ -22,8 +22,7 @@
  * Authors: Maarten Lankhorst
  */
 
-#include <core/falcon.h>
-
+#include <engine/falcon.h>
 #include <engine/bsp.h>
 
 struct nvc0_bsp_priv {
index d4f23bbd75b4f2d450e93c0cabc86e67a8caf819..c46882c8398253ceb1739d82dc31739fef8e09e4 100644 (file)
@@ -22,8 +22,7 @@
  * Authors: Ben Skeggs
  */
 
-#include <core/falcon.h>
-
+#include <engine/falcon.h>
 #include <engine/bsp.h>
 
 struct nve0_bsp_priv {
index 85f2e03dcf3f5dd32ebd35532610993d5d38e00f..f31527733e00fcb1f82a78538b5f1b2c90938b42 100644 (file)
  * Authors: Ben Skeggs
  */
 
-#include <core/client.h>
-#include <core/falcon.h>
-#include <core/class.h>
-#include <core/enum.h>
+#include <engine/falcon.h>
+#include <engine/fifo.h>
+#include <engine/copy.h>
 
 #include <subdev/fb.h>
 #include <subdev/vm.h>
 
-#include <engine/fifo.h>
-#include <engine/copy.h>
+#include <core/client.h>
+#include <core/class.h>
+#include <core/enum.h>
+
 
 #include "fuc/nva3.fuc.h"
 
index b3ed2737e21f2778ea07df796a2ac1b7dce212fe..993df09ad64386e51ab7316e1dbc57de5cba5409 100644 (file)
  * Authors: Ben Skeggs
  */
 
-#include <core/falcon.h>
-#include <core/class.h>
-#include <core/enum.h>
-
+#include <engine/falcon.h>
 #include <engine/fifo.h>
 #include <engine/copy.h>
 
+#include <core/class.h>
+#include <core/enum.h>
+#include <core/class.h>
+#include <core/enum.h>
+
 #include "fuc/nvc0.fuc.h"
 
 struct nvc0_copy_priv {
index 83ec3a30f93f400b293bef53a8224000057a0d25..c7082377ec76315e29fea6465d8afa56fac1146a 100644 (file)
 #include <core/enum.h>
 #include <core/class.h>
 #include <core/engctx.h>
-#include <core/falcon.h>
 
 #include <subdev/timer.h>
 #include <subdev/fb.h>
 
+#include <engine/falcon.h>
 #include <engine/fifo.h>
 #include <engine/crypt.h>
 
diff --git a/drivers/gpu/drm/nouveau/core/engine/falcon.c b/drivers/gpu/drm/nouveau/core/engine/falcon.c
new file mode 100644 (file)
index 0000000..3c7a31f
--- /dev/null
@@ -0,0 +1,249 @@
+/*
+ * Copyright 2012 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.
+ */
+
+#include <engine/falcon.h>
+#include <subdev/timer.h>
+
+u32
+_nouveau_falcon_rd32(struct nouveau_object *object, u64 addr)
+{
+       struct nouveau_falcon *falcon = (void *)object;
+       return nv_rd32(falcon, falcon->addr + addr);
+}
+
+void
+_nouveau_falcon_wr32(struct nouveau_object *object, u64 addr, u32 data)
+{
+       struct nouveau_falcon *falcon = (void *)object;
+       nv_wr32(falcon, falcon->addr + addr, data);
+}
+
+int
+_nouveau_falcon_init(struct nouveau_object *object)
+{
+       struct nouveau_device *device = nv_device(object);
+       struct nouveau_falcon *falcon = (void *)object;
+       const struct firmware *fw;
+       char name[32] = "internal";
+       int ret, i;
+       u32 caps;
+
+       /* enable engine, and determine its capabilities */
+       ret = nouveau_engine_init(&falcon->base);
+       if (ret)
+               return ret;
+
+       if (device->chipset <  0xa3 ||
+           device->chipset == 0xaa || device->chipset == 0xac) {
+               falcon->version = 0;
+               falcon->secret  = (falcon->addr == 0x087000) ? 1 : 0;
+       } else {
+               caps = nv_ro32(falcon, 0x12c);
+               falcon->version = (caps & 0x0000000f);
+               falcon->secret  = (caps & 0x00000030) >> 4;
+       }
+
+       caps = nv_ro32(falcon, 0x108);
+       falcon->code.limit = (caps & 0x000001ff) << 8;
+       falcon->data.limit = (caps & 0x0003fe00) >> 1;
+
+       nv_debug(falcon, "falcon version: %d\n", falcon->version);
+       nv_debug(falcon, "secret level: %d\n", falcon->secret);
+       nv_debug(falcon, "code limit: %d\n", falcon->code.limit);
+       nv_debug(falcon, "data limit: %d\n", falcon->data.limit);
+
+       /* wait for 'uc halted' to be signalled before continuing */
+       if (falcon->secret && falcon->version < 4) {
+               if (!falcon->version)
+                       nv_wait(falcon, 0x008, 0x00000010, 0x00000010);
+               else
+                       nv_wait(falcon, 0x180, 0x80000000, 0);
+               nv_wo32(falcon, 0x004, 0x00000010);
+       }
+
+       /* disable all interrupts */
+       nv_wo32(falcon, 0x014, 0xffffffff);
+
+       /* no default ucode provided by the engine implementation, try and
+        * locate a "self-bootstrapping" firmware image for the engine
+        */
+       if (!falcon->code.data) {
+               snprintf(name, sizeof(name), "nouveau/nv%02x_fuc%03x",
+                        device->chipset, falcon->addr >> 12);
+
+               ret = request_firmware(&fw, name, &device->pdev->dev);
+               if (ret == 0) {
+                       falcon->code.data = kmemdup(fw->data, fw->size, GFP_KERNEL);
+                       falcon->code.size = fw->size;
+                       falcon->data.data = NULL;
+                       falcon->data.size = 0;
+                       release_firmware(fw);
+               }
+
+               falcon->external = true;
+       }
+
+       /* next step is to try and load "static code/data segment" firmware
+        * images for the engine
+        */
+       if (!falcon->code.data) {
+               snprintf(name, sizeof(name), "nouveau/nv%02x_fuc%03xd",
+                        device->chipset, falcon->addr >> 12);
+
+               ret = request_firmware(&fw, name, &device->pdev->dev);
+               if (ret) {
+                       nv_error(falcon, "unable to load firmware data\n");
+                       return ret;
+               }
+
+               falcon->data.data = kmemdup(fw->data, fw->size, GFP_KERNEL);
+               falcon->data.size = fw->size;
+               release_firmware(fw);
+               if (!falcon->data.data)
+                       return -ENOMEM;
+
+               snprintf(name, sizeof(name), "nouveau/nv%02x_fuc%03xc",
+                        device->chipset, falcon->addr >> 12);
+
+               ret = request_firmware(&fw, name, &device->pdev->dev);
+               if (ret) {
+                       nv_error(falcon, "unable to load firmware code\n");
+                       return ret;
+               }
+
+               falcon->code.data = kmemdup(fw->data, fw->size, GFP_KERNEL);
+               falcon->code.size = fw->size;
+               release_firmware(fw);
+               if (!falcon->code.data)
+                       return -ENOMEM;
+       }
+
+       nv_debug(falcon, "firmware: %s (%s)\n", name, falcon->data.data ?
+                "static code/data segments" : "self-bootstrapping");
+
+       /* ensure any "self-bootstrapping" firmware image is in vram */
+       if (!falcon->data.data && !falcon->core) {
+               ret = nouveau_gpuobj_new(object->parent, NULL,
+                                        falcon->code.size, 256, 0,
+                                       &falcon->core);
+               if (ret) {
+                       nv_error(falcon, "core allocation failed, %d\n", ret);
+                       return ret;
+               }
+
+               for (i = 0; i < falcon->code.size; i += 4)
+                       nv_wo32(falcon->core, i, falcon->code.data[i / 4]);
+       }
+
+       /* upload firmware bootloader (or the full code segments) */
+       if (falcon->core) {
+               if (device->card_type < NV_C0)
+                       nv_wo32(falcon, 0x618, 0x04000000);
+               else
+                       nv_wo32(falcon, 0x618, 0x00000114);
+               nv_wo32(falcon, 0x11c, 0);
+               nv_wo32(falcon, 0x110, falcon->core->addr >> 8);
+               nv_wo32(falcon, 0x114, 0);
+               nv_wo32(falcon, 0x118, 0x00006610);
+       } else {
+               if (falcon->code.size > falcon->code.limit ||
+                   falcon->data.size > falcon->data.limit) {
+                       nv_error(falcon, "ucode exceeds falcon limit(s)\n");
+                       return -EINVAL;
+               }
+
+               if (falcon->version < 3) {
+                       nv_wo32(falcon, 0xff8, 0x00100000);
+                       for (i = 0; i < falcon->code.size / 4; i++)
+                               nv_wo32(falcon, 0xff4, falcon->code.data[i]);
+               } else {
+                       nv_wo32(falcon, 0x180, 0x01000000);
+                       for (i = 0; i < falcon->code.size / 4; i++) {
+                               if ((i & 0x3f) == 0)
+                                       nv_wo32(falcon, 0x188, i >> 6);
+                               nv_wo32(falcon, 0x184, falcon->code.data[i]);
+                       }
+               }
+       }
+
+       /* upload data segment (if necessary), zeroing the remainder */
+       if (falcon->version < 3) {
+               nv_wo32(falcon, 0xff8, 0x00000000);
+               for (i = 0; !falcon->core && i < falcon->data.size / 4; i++)
+                       nv_wo32(falcon, 0xff4, falcon->data.data[i]);
+               for (; i < falcon->data.limit; i += 4)
+                       nv_wo32(falcon, 0xff4, 0x00000000);
+       } else {
+               nv_wo32(falcon, 0x1c0, 0x01000000);
+               for (i = 0; !falcon->core && i < falcon->data.size / 4; i++)
+                       nv_wo32(falcon, 0x1c4, falcon->data.data[i]);
+               for (; i < falcon->data.limit / 4; i++)
+                       nv_wo32(falcon, 0x1c4, 0x00000000);
+       }
+
+       /* start it running */
+       nv_wo32(falcon, 0x10c, 0x00000001); /* BLOCK_ON_FIFO */
+       nv_wo32(falcon, 0x104, 0x00000000); /* ENTRY */
+       nv_wo32(falcon, 0x100, 0x00000002); /* TRIGGER */
+       nv_wo32(falcon, 0x048, 0x00000003); /* FIFO | CHSW */
+       return 0;
+}
+
+int
+_nouveau_falcon_fini(struct nouveau_object *object, bool suspend)
+{
+       struct nouveau_falcon *falcon = (void *)object;
+
+       if (!suspend) {
+               nouveau_gpuobj_ref(NULL, &falcon->core);
+               if (falcon->external) {
+                       kfree(falcon->data.data);
+                       kfree(falcon->code.data);
+                       falcon->code.data = NULL;
+               }
+       }
+
+       nv_mo32(falcon, 0x048, 0x00000003, 0x00000000);
+       nv_wo32(falcon, 0x014, 0xffffffff);
+
+       return nouveau_engine_fini(&falcon->base, suspend);
+}
+
+int
+nouveau_falcon_create_(struct nouveau_object *parent,
+                      struct nouveau_object *engine,
+                      struct nouveau_oclass *oclass, u32 addr, bool enable,
+                      const char *iname, const char *fname,
+                      int length, void **pobject)
+{
+       struct nouveau_falcon *falcon;
+       int ret;
+
+       ret = nouveau_engine_create_(parent, engine, oclass, enable, iname,
+                                    fname, length, pobject);
+       falcon = *pobject;
+       if (ret)
+               return ret;
+
+       falcon->addr = addr;
+       return 0;
+}
index ebf0d860e2ddd4e63ef6b1aba2c6a3a865261889..98072c1ff3606117e477cb294435e0e75bc11116 100644 (file)
@@ -22,8 +22,7 @@
  * Authors: Maarten Lankhorst
  */
 
-#include <core/falcon.h>
-
+#include <engine/falcon.h>
 #include <engine/ppp.h>
 
 struct nvc0_ppp_priv {
index f761949d703921a3ebe5722a1ddfb2b3b20ca470..1879229b60eb8ef4e347d16c07f78fed8a8b3f82 100644 (file)
@@ -22,8 +22,7 @@
  * Authors: Maarten Lankhorst
  */
 
-#include <core/falcon.h>
-
+#include <engine/falcon.h>
 #include <engine/vp.h>
 
 struct nvc0_vp_priv {
index 2384ce5dbe1662ceaa84c56cb6ffb90a6dcb1a6a..d28ecbf7bc49ee6c2fd521c6ab652237e04bb6ae 100644 (file)
@@ -22,8 +22,7 @@
  * Authors: Ben Skeggs
  */
 
-#include <core/falcon.h>
-
+#include <engine/falcon.h>
 #include <engine/vp.h>
 
 struct nve0_vp_priv {
diff --git a/drivers/gpu/drm/nouveau/core/include/core/falcon.h b/drivers/gpu/drm/nouveau/core/include/core/falcon.h
deleted file mode 100644 (file)
index 1edec38..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef __NOUVEAU_FALCON_H__
-#define __NOUVEAU_FALCON_H__
-
-#include <core/engine.h>
-#include <core/engctx.h>
-#include <core/gpuobj.h>
-
-struct nouveau_falcon_chan {
-       struct nouveau_engctx base;
-};
-
-#define nouveau_falcon_context_create(p,e,c,g,s,a,f,d)                         \
-       nouveau_engctx_create((p), (e), (c), (g), (s), (a), (f), (d))
-#define nouveau_falcon_context_destroy(d)                                      \
-       nouveau_engctx_destroy(&(d)->base)
-#define nouveau_falcon_context_init(d)                                         \
-       nouveau_engctx_init(&(d)->base)
-#define nouveau_falcon_context_fini(d,s)                                       \
-       nouveau_engctx_fini(&(d)->base, (s))
-
-#define _nouveau_falcon_context_ctor _nouveau_engctx_ctor
-#define _nouveau_falcon_context_dtor _nouveau_engctx_dtor
-#define _nouveau_falcon_context_init _nouveau_engctx_init
-#define _nouveau_falcon_context_fini _nouveau_engctx_fini
-#define _nouveau_falcon_context_rd32 _nouveau_engctx_rd32
-#define _nouveau_falcon_context_wr32 _nouveau_engctx_wr32
-
-struct nouveau_falcon_data {
-       bool external;
-};
-
-struct nouveau_falcon {
-       struct nouveau_engine base;
-
-       u32 addr;
-       u8  version;
-       u8  secret;
-
-       struct nouveau_gpuobj *core;
-       bool external;
-
-       struct {
-               u32 limit;
-               u32 *data;
-               u32  size;
-       } code;
-
-       struct {
-               u32 limit;
-               u32 *data;
-               u32  size;
-       } data;
-};
-
-#define nv_falcon(priv) (&(priv)->base)
-
-#define nouveau_falcon_create(p,e,c,b,d,i,f,r)                                 \
-       nouveau_falcon_create_((p), (e), (c), (b), (d), (i), (f),              \
-                              sizeof(**r),(void **)r)
-#define nouveau_falcon_destroy(p)                                              \
-       nouveau_engine_destroy(&(p)->base)
-#define nouveau_falcon_init(p) ({                                              \
-       struct nouveau_falcon *falcon = (p);                                   \
-       _nouveau_falcon_init(nv_object(falcon));                               \
-})
-#define nouveau_falcon_fini(p,s) ({                                            \
-       struct nouveau_falcon *falcon = (p);                                   \
-       _nouveau_falcon_fini(nv_object(falcon), (s));                          \
-})
-
-int nouveau_falcon_create_(struct nouveau_object *, struct nouveau_object *,
-                          struct nouveau_oclass *, u32, bool, const char *,
-                          const char *, int, void **);
-
-#define _nouveau_falcon_dtor _nouveau_engine_dtor
-int  _nouveau_falcon_init(struct nouveau_object *);
-int  _nouveau_falcon_fini(struct nouveau_object *, bool);
-u32  _nouveau_falcon_rd32(struct nouveau_object *, u64);
-void _nouveau_falcon_wr32(struct nouveau_object *, u64, u32);
-
-#endif
diff --git a/drivers/gpu/drm/nouveau/core/include/engine/falcon.h b/drivers/gpu/drm/nouveau/core/include/engine/falcon.h
new file mode 100644 (file)
index 0000000..1edec38
--- /dev/null
@@ -0,0 +1,81 @@
+#ifndef __NOUVEAU_FALCON_H__
+#define __NOUVEAU_FALCON_H__
+
+#include <core/engine.h>
+#include <core/engctx.h>
+#include <core/gpuobj.h>
+
+struct nouveau_falcon_chan {
+       struct nouveau_engctx base;
+};
+
+#define nouveau_falcon_context_create(p,e,c,g,s,a,f,d)                         \
+       nouveau_engctx_create((p), (e), (c), (g), (s), (a), (f), (d))
+#define nouveau_falcon_context_destroy(d)                                      \
+       nouveau_engctx_destroy(&(d)->base)
+#define nouveau_falcon_context_init(d)                                         \
+       nouveau_engctx_init(&(d)->base)
+#define nouveau_falcon_context_fini(d,s)                                       \
+       nouveau_engctx_fini(&(d)->base, (s))
+
+#define _nouveau_falcon_context_ctor _nouveau_engctx_ctor
+#define _nouveau_falcon_context_dtor _nouveau_engctx_dtor
+#define _nouveau_falcon_context_init _nouveau_engctx_init
+#define _nouveau_falcon_context_fini _nouveau_engctx_fini
+#define _nouveau_falcon_context_rd32 _nouveau_engctx_rd32
+#define _nouveau_falcon_context_wr32 _nouveau_engctx_wr32
+
+struct nouveau_falcon_data {
+       bool external;
+};
+
+struct nouveau_falcon {
+       struct nouveau_engine base;
+
+       u32 addr;
+       u8  version;
+       u8  secret;
+
+       struct nouveau_gpuobj *core;
+       bool external;
+
+       struct {
+               u32 limit;
+               u32 *data;
+               u32  size;
+       } code;
+
+       struct {
+               u32 limit;
+               u32 *data;
+               u32  size;
+       } data;
+};
+
+#define nv_falcon(priv) (&(priv)->base)
+
+#define nouveau_falcon_create(p,e,c,b,d,i,f,r)                                 \
+       nouveau_falcon_create_((p), (e), (c), (b), (d), (i), (f),              \
+                              sizeof(**r),(void **)r)
+#define nouveau_falcon_destroy(p)                                              \
+       nouveau_engine_destroy(&(p)->base)
+#define nouveau_falcon_init(p) ({                                              \
+       struct nouveau_falcon *falcon = (p);                                   \
+       _nouveau_falcon_init(nv_object(falcon));                               \
+})
+#define nouveau_falcon_fini(p,s) ({                                            \
+       struct nouveau_falcon *falcon = (p);                                   \
+       _nouveau_falcon_fini(nv_object(falcon), (s));                          \
+})
+
+int nouveau_falcon_create_(struct nouveau_object *, struct nouveau_object *,
+                          struct nouveau_oclass *, u32, bool, const char *,
+                          const char *, int, void **);
+
+#define _nouveau_falcon_dtor _nouveau_engine_dtor
+int  _nouveau_falcon_init(struct nouveau_object *);
+int  _nouveau_falcon_fini(struct nouveau_object *, bool);
+u32  _nouveau_falcon_rd32(struct nouveau_object *, u64);
+void _nouveau_falcon_wr32(struct nouveau_object *, u64, u32);
+
+#endif