aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2017-02-23 04:41:41 -0500
committerBen Skeggs <bskeggs@redhat.com>2017-03-07 02:05:13 -0500
commitb62880f7966781eb0b3b1e50f63d6aac362476d3 (patch)
tree3db7e7808baadcfbe10d329a9bfd79bfcd4b008e
parent16307b5d720af3fec8d2153a68e23066e20c481f (diff)
drm/nouveau/core: add SEC2 engine
SEC2 is the name given by NVIDIA to the SEC engine post-Fermi (reasons unknown). Even though it shares the same address range as SEC, its usage is quite different and this justifies a new engine. Add this engine and make TOP use it all post-TOP devices should use this implementation and not the older SEC. Also quickly add the short gp102 implementation which will be used for falcon booting purposes. Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/core/device.h3
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/engine/sec2.h13
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/core/subdev.c1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/base.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sec2/Kbuild2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sec2/base.c101
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sec2/gp102.c30
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sec2/priv.h9
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c2
11 files changed, 164 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
index 6d6e7e71067b..bb4c214f1046 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h
@@ -59,6 +59,7 @@ enum nvkm_devidx {
59 NVKM_ENGINE_NVDEC, 59 NVKM_ENGINE_NVDEC,
60 NVKM_ENGINE_PM, 60 NVKM_ENGINE_PM,
61 NVKM_ENGINE_SEC, 61 NVKM_ENGINE_SEC,
62 NVKM_ENGINE_SEC2,
62 NVKM_ENGINE_SW, 63 NVKM_ENGINE_SW,
63 NVKM_ENGINE_VIC, 64 NVKM_ENGINE_VIC,
64 NVKM_ENGINE_VP, 65 NVKM_ENGINE_VP,
@@ -158,6 +159,7 @@ struct nvkm_device {
158 struct nvkm_nvdec *nvdec; 159 struct nvkm_nvdec *nvdec;
159 struct nvkm_pm *pm; 160 struct nvkm_pm *pm;
160 struct nvkm_engine *sec; 161 struct nvkm_engine *sec;
162 struct nvkm_sec2 *sec2;
161 struct nvkm_sw *sw; 163 struct nvkm_sw *sw;
162 struct nvkm_engine *vic; 164 struct nvkm_engine *vic;
163 struct nvkm_engine *vp; 165 struct nvkm_engine *vp;
@@ -228,6 +230,7 @@ struct nvkm_device_chip {
228 int (*nvdec )(struct nvkm_device *, int idx, struct nvkm_nvdec **); 230 int (*nvdec )(struct nvkm_device *, int idx, struct nvkm_nvdec **);
229 int (*pm )(struct nvkm_device *, int idx, struct nvkm_pm **); 231 int (*pm )(struct nvkm_device *, int idx, struct nvkm_pm **);
230 int (*sec )(struct nvkm_device *, int idx, struct nvkm_engine **); 232 int (*sec )(struct nvkm_device *, int idx, struct nvkm_engine **);
233 int (*sec2 )(struct nvkm_device *, int idx, struct nvkm_sec2 **);
231 int (*sw )(struct nvkm_device *, int idx, struct nvkm_sw **); 234 int (*sw )(struct nvkm_device *, int idx, struct nvkm_sw **);
232 int (*vic )(struct nvkm_device *, int idx, struct nvkm_engine **); 235 int (*vic )(struct nvkm_device *, int idx, struct nvkm_engine **);
233 int (*vp )(struct nvkm_device *, int idx, struct nvkm_engine **); 236 int (*vp )(struct nvkm_device *, int idx, struct nvkm_engine **);
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/sec2.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/sec2.h
new file mode 100644
index 000000000000..d3db1b1e75c4
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/sec2.h
@@ -0,0 +1,13 @@
1#ifndef __NVKM_SEC2_H__
2#define __NVKM_SEC2_H__
3#include <core/engine.h>
4
5struct nvkm_sec2 {
6 struct nvkm_engine engine;
7 struct nvkm_falcon *falcon;
8 struct nvkm_msgqueue *queue;
9 struct work_struct work;
10};
11
12int gp102_sec2_new(struct nvkm_device *, int, struct nvkm_sec2 **);
13#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
index 19044aba265e..a134d225f958 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
@@ -78,6 +78,7 @@ nvkm_subdev_name[NVKM_SUBDEV_NR] = {
78 [NVKM_ENGINE_NVDEC ] = "nvdec", 78 [NVKM_ENGINE_NVDEC ] = "nvdec",
79 [NVKM_ENGINE_PM ] = "pm", 79 [NVKM_ENGINE_PM ] = "pm",
80 [NVKM_ENGINE_SEC ] = "sec", 80 [NVKM_ENGINE_SEC ] = "sec",
81 [NVKM_ENGINE_SEC2 ] = "sec2",
81 [NVKM_ENGINE_SW ] = "sw", 82 [NVKM_ENGINE_SW ] = "sw",
82 [NVKM_ENGINE_VIC ] = "vic", 83 [NVKM_ENGINE_VIC ] = "vic",
83 [NVKM_ENGINE_VP ] = "vp", 84 [NVKM_ENGINE_VP ] = "vp",
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
index c2c8d2ac01b8..78571e8b01c5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
@@ -18,6 +18,7 @@ include $(src)/nvkm/engine/nvenc/Kbuild
18include $(src)/nvkm/engine/nvdec/Kbuild 18include $(src)/nvkm/engine/nvdec/Kbuild
19include $(src)/nvkm/engine/pm/Kbuild 19include $(src)/nvkm/engine/pm/Kbuild
20include $(src)/nvkm/engine/sec/Kbuild 20include $(src)/nvkm/engine/sec/Kbuild
21include $(src)/nvkm/engine/sec2/Kbuild
21include $(src)/nvkm/engine/sw/Kbuild 22include $(src)/nvkm/engine/sw/Kbuild
22include $(src)/nvkm/engine/vic/Kbuild 23include $(src)/nvkm/engine/vic/Kbuild
23include $(src)/nvkm/engine/vp/Kbuild 24include $(src)/nvkm/engine/vp/Kbuild
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
index 883e6e474d1b..cf76d6c657ba 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
@@ -2365,6 +2365,7 @@ nvkm_device_engine(struct nvkm_device *device, int index)
2365 _(NVDEC , device->nvdec , &device->nvdec->engine); 2365 _(NVDEC , device->nvdec , &device->nvdec->engine);
2366 _(PM , device->pm , &device->pm->engine); 2366 _(PM , device->pm , &device->pm->engine);
2367 _(SEC , device->sec , device->sec); 2367 _(SEC , device->sec , device->sec);
2368 _(SEC2 , device->sec2 , &device->sec2->engine);
2368 _(SW , device->sw , &device->sw->engine); 2369 _(SW , device->sw , &device->sw->engine);
2369 _(VIC , device->vic , device->vic); 2370 _(VIC , device->vic , device->vic);
2370 _(VP , device->vp , device->vp); 2371 _(VP , device->vp , device->vp);
@@ -2812,6 +2813,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
2812 _(NVKM_ENGINE_NVDEC , nvdec); 2813 _(NVKM_ENGINE_NVDEC , nvdec);
2813 _(NVKM_ENGINE_PM , pm); 2814 _(NVKM_ENGINE_PM , pm);
2814 _(NVKM_ENGINE_SEC , sec); 2815 _(NVKM_ENGINE_SEC , sec);
2816 _(NVKM_ENGINE_SEC2 , sec2);
2815 _(NVKM_ENGINE_SW , sw); 2817 _(NVKM_ENGINE_SW , sw);
2816 _(NVKM_ENGINE_VIC , vic); 2818 _(NVKM_ENGINE_VIC , vic);
2817 _(NVKM_ENGINE_VP , vp); 2819 _(NVKM_ENGINE_VP , vp);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h
index 1a06ac175f55..6c16f3835f44 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h
@@ -41,6 +41,7 @@
41#include <engine/nvdec.h> 41#include <engine/nvdec.h>
42#include <engine/pm.h> 42#include <engine/pm.h>
43#include <engine/sec.h> 43#include <engine/sec.h>
44#include <engine/sec2.h>
44#include <engine/sw.h> 45#include <engine/sw.h>
45#include <engine/vic.h> 46#include <engine/vic.h>
46#include <engine/vp.h> 47#include <engine/vp.h>
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sec2/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/sec2/Kbuild
new file mode 100644
index 000000000000..4b17254cfbd0
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sec2/Kbuild
@@ -0,0 +1,2 @@
1nvkm-y += nvkm/engine/sec2/base.o
2nvkm-y += nvkm/engine/sec2/gp102.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sec2/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/sec2/base.c
new file mode 100644
index 000000000000..814daf35e21f
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sec2/base.c
@@ -0,0 +1,101 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22#include "priv.h"
23
24#include <core/msgqueue.h>
25#include <engine/falcon.h>
26
27static void *
28nvkm_sec2_dtor(struct nvkm_engine *engine)
29{
30 struct nvkm_sec2 *sec2 = nvkm_sec2(engine);
31 nvkm_msgqueue_del(&sec2->queue);
32 nvkm_falcon_del(&sec2->falcon);
33 return sec2;
34}
35
36static void
37nvkm_sec2_intr(struct nvkm_engine *engine)
38{
39 struct nvkm_sec2 *sec2 = nvkm_sec2(engine);
40 struct nvkm_subdev *subdev = &engine->subdev;
41 struct nvkm_device *device = subdev->device;
42 u32 disp = nvkm_rd32(device, 0x8701c);
43 u32 intr = nvkm_rd32(device, 0x87008) & disp & ~(disp >> 16);
44
45 if (intr & 0x00000040) {
46 schedule_work(&sec2->work);
47 nvkm_wr32(device, 0x87004, 0x00000040);
48 intr &= ~0x00000040;
49 }
50
51 if (intr) {
52 nvkm_error(subdev, "unhandled intr %08x\n", intr);
53 nvkm_wr32(device, 0x87004, intr);
54
55 }
56}
57
58static void
59nvkm_sec2_recv(struct work_struct *work)
60{
61 struct nvkm_sec2 *sec2 = container_of(work, typeof(*sec2), work);
62 nvkm_msgqueue_recv(sec2->queue);
63}
64
65
66static int
67nvkm_sec2_oneinit(struct nvkm_engine *engine)
68{
69 struct nvkm_sec2 *sec2 = nvkm_sec2(engine);
70 return nvkm_falcon_v1_new(&sec2->engine.subdev, "SEC2", 0x87000,
71 &sec2->falcon);
72}
73
74static int
75nvkm_sec2_fini(struct nvkm_engine *engine, bool suspend)
76{
77 struct nvkm_sec2 *sec2 = nvkm_sec2(engine);
78 flush_work(&sec2->work);
79 return 0;
80}
81
82static const struct nvkm_engine_func
83nvkm_sec2 = {
84 .dtor = nvkm_sec2_dtor,
85 .oneinit = nvkm_sec2_oneinit,
86 .fini = nvkm_sec2_fini,
87 .intr = nvkm_sec2_intr,
88};
89
90int
91nvkm_sec2_new_(struct nvkm_device *device, int index,
92 struct nvkm_sec2 **psec2)
93{
94 struct nvkm_sec2 *sec2;
95
96 if (!(sec2 = *psec2 = kzalloc(sizeof(*sec2), GFP_KERNEL)))
97 return -ENOMEM;
98 INIT_WORK(&sec2->work, nvkm_sec2_recv);
99
100 return nvkm_engine_ctor(&nvkm_sec2, device, index, true, &sec2->engine);
101};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sec2/gp102.c b/drivers/gpu/drm/nouveau/nvkm/engine/sec2/gp102.c
new file mode 100644
index 000000000000..9be1524c08f5
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sec2/gp102.c
@@ -0,0 +1,30 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23#include "priv.h"
24
25int
26gp102_sec2_new(struct nvkm_device *device, int index,
27 struct nvkm_sec2 **psec2)
28{
29 return nvkm_sec2_new_(device, index, psec2);
30}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sec2/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/sec2/priv.h
new file mode 100644
index 000000000000..7ecc9d4724dc
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sec2/priv.h
@@ -0,0 +1,9 @@
1#ifndef __NVKM_SEC2_PRIV_H__
2#define __NVKM_SEC2_PRIV_H__
3#include <engine/sec2.h>
4
5#define nvkm_sec2(p) container_of((p), struct nvkm_sec2, engine)
6
7int nvkm_sec2_new_(struct nvkm_device *, int, struct nvkm_sec2 **);
8
9#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c b/drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c
index efac3402f9dd..fea4957291da 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c
@@ -82,7 +82,7 @@ gk104_top_oneinit(struct nvkm_top *top)
82 case 0x0000000a: A_(MSVLD ); break; 82 case 0x0000000a: A_(MSVLD ); break;
83 case 0x0000000b: A_(MSENC ); break; 83 case 0x0000000b: A_(MSENC ); break;
84 case 0x0000000c: A_(VIC ); break; 84 case 0x0000000c: A_(VIC ); break;
85 case 0x0000000d: A_(SEC ); break; 85 case 0x0000000d: A_(SEC2 ); break;
86 case 0x0000000e: B_(NVENC ); break; 86 case 0x0000000e: B_(NVENC ); break;
87 case 0x0000000f: A_(NVENC1); break; 87 case 0x0000000f: A_(NVENC1); break;
88 case 0x00000010: A_(NVDEC ); break; 88 case 0x00000010: A_(NVDEC ); break;