diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2017-01-26 01:16:32 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2017-03-07 02:05:13 -0500 |
commit | 16307b5d720af3fec8d2153a68e23066e20c481f (patch) | |
tree | 85a5f6739ceb072897f747f17d54c72ab58443cd | |
parent | 9e4397579fa4cd5cc411d47815eb805e337d0203 (diff) |
drm/nouveau/nvdec: add gp102 support
gp10x' secure boot requires a blob to be run on NVDEC. Expose the falcon
through a dummy device.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
7 files changed, 108 insertions, 4 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h index d426b86e2712..6d6e7e71067b 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h | |||
@@ -155,7 +155,7 @@ struct nvkm_device { | |||
155 | struct nvkm_engine *msppp; | 155 | struct nvkm_engine *msppp; |
156 | struct nvkm_engine *msvld; | 156 | struct nvkm_engine *msvld; |
157 | struct nvkm_engine *nvenc[3]; | 157 | struct nvkm_engine *nvenc[3]; |
158 | struct nvkm_engine *nvdec; | 158 | struct nvkm_nvdec *nvdec; |
159 | struct nvkm_pm *pm; | 159 | struct nvkm_pm *pm; |
160 | struct nvkm_engine *sec; | 160 | struct nvkm_engine *sec; |
161 | struct nvkm_sw *sw; | 161 | struct nvkm_sw *sw; |
@@ -225,7 +225,7 @@ struct nvkm_device_chip { | |||
225 | int (*msppp )(struct nvkm_device *, int idx, struct nvkm_engine **); | 225 | int (*msppp )(struct nvkm_device *, int idx, struct nvkm_engine **); |
226 | int (*msvld )(struct nvkm_device *, int idx, struct nvkm_engine **); | 226 | int (*msvld )(struct nvkm_device *, int idx, struct nvkm_engine **); |
227 | int (*nvenc[3])(struct nvkm_device *, int idx, struct nvkm_engine **); | 227 | int (*nvenc[3])(struct nvkm_device *, int idx, struct nvkm_engine **); |
228 | int (*nvdec )(struct nvkm_device *, int idx, struct nvkm_engine **); | 228 | int (*nvdec )(struct nvkm_device *, int idx, struct nvkm_nvdec **); |
229 | int (*pm )(struct nvkm_device *, int idx, struct nvkm_pm **); | 229 | int (*pm )(struct nvkm_device *, int idx, struct nvkm_pm **); |
230 | int (*sec )(struct nvkm_device *, int idx, struct nvkm_engine **); | 230 | int (*sec )(struct nvkm_device *, int idx, struct nvkm_engine **); |
231 | int (*sw )(struct nvkm_device *, int idx, struct nvkm_sw **); | 231 | int (*sw )(struct nvkm_device *, int idx, struct nvkm_sw **); |
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h index 30b76d13fdcb..00b2b227ff41 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h | |||
@@ -1,4 +1,12 @@ | |||
1 | #ifndef __NVKM_NVDEC_H__ | 1 | #ifndef __NVKM_NVDEC_H__ |
2 | #define __NVKM_NVDEC_H__ | 2 | #define __NVKM_NVDEC_H__ |
3 | #define nvkm_nvdec(p) container_of((p), struct nvkm_nvdec, engine) | ||
3 | #include <core/engine.h> | 4 | #include <core/engine.h> |
5 | |||
6 | struct nvkm_nvdec { | ||
7 | struct nvkm_engine engine; | ||
8 | struct nvkm_falcon *falcon; | ||
9 | }; | ||
10 | |||
11 | int gp102_nvdec_new(struct nvkm_device *, int, struct nvkm_nvdec **); | ||
4 | #endif | 12 | #endif |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c index 273562dd6bbd..883e6e474d1b 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c | |||
@@ -2362,7 +2362,7 @@ nvkm_device_engine(struct nvkm_device *device, int index) | |||
2362 | _(NVENC0 , device->nvenc[0], device->nvenc[0]); | 2362 | _(NVENC0 , device->nvenc[0], device->nvenc[0]); |
2363 | _(NVENC1 , device->nvenc[1], device->nvenc[1]); | 2363 | _(NVENC1 , device->nvenc[1], device->nvenc[1]); |
2364 | _(NVENC2 , device->nvenc[2], device->nvenc[2]); | 2364 | _(NVENC2 , device->nvenc[2], device->nvenc[2]); |
2365 | _(NVDEC , device->nvdec , device->nvdec); | 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 | _(SW , device->sw , &device->sw->engine); | 2368 | _(SW , device->sw , &device->sw->engine); |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild index 13b7c71ff900..98477beb823a 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild +++ b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild | |||
@@ -1 +1,2 @@ | |||
1 | #nvkm-y += nvkm/engine/nvdec/base.o | 1 | nvkm-y += nvkm/engine/nvdec/base.o |
2 | nvkm-y += nvkm/engine/nvdec/gp102.o | ||
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/base.c new file mode 100644 index 000000000000..4807021fd990 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/base.c | |||
@@ -0,0 +1,59 @@ | |||
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 <engine/falcon.h> | ||
25 | |||
26 | static int | ||
27 | nvkm_nvdec_oneinit(struct nvkm_engine *engine) | ||
28 | { | ||
29 | struct nvkm_nvdec *nvdec = nvkm_nvdec(engine); | ||
30 | return nvkm_falcon_v1_new(&nvdec->engine.subdev, "NVDEC", 0x84000, | ||
31 | &nvdec->falcon); | ||
32 | } | ||
33 | |||
34 | static void * | ||
35 | nvkm_nvdec_dtor(struct nvkm_engine *engine) | ||
36 | { | ||
37 | struct nvkm_nvdec *nvdec = nvkm_nvdec(engine); | ||
38 | nvkm_falcon_del(&nvdec->falcon); | ||
39 | return nvdec; | ||
40 | } | ||
41 | |||
42 | static const struct nvkm_engine_func | ||
43 | nvkm_nvdec = { | ||
44 | .dtor = nvkm_nvdec_dtor, | ||
45 | .oneinit = nvkm_nvdec_oneinit, | ||
46 | }; | ||
47 | |||
48 | int | ||
49 | nvkm_nvdec_new_(struct nvkm_device *device, int index, | ||
50 | struct nvkm_nvdec **pnvdec) | ||
51 | { | ||
52 | struct nvkm_nvdec *nvdec; | ||
53 | |||
54 | if (!(nvdec = *pnvdec = kzalloc(sizeof(*nvdec), GFP_KERNEL))) | ||
55 | return -ENOMEM; | ||
56 | |||
57 | return nvkm_engine_ctor(&nvkm_nvdec, device, index, true, | ||
58 | &nvdec->engine); | ||
59 | }; | ||
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/gp102.c b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/gp102.c new file mode 100644 index 000000000000..fde6328c6d71 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/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 | |||
25 | int | ||
26 | gp102_nvdec_new(struct nvkm_device *device, int index, | ||
27 | struct nvkm_nvdec **pnvdec) | ||
28 | { | ||
29 | return nvkm_nvdec_new_(device, index, pnvdec); | ||
30 | } | ||
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/priv.h new file mode 100644 index 000000000000..353b94f51205 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/priv.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __NVKM_NVDEC_PRIV_H__ | ||
2 | #define __NVKM_NVDEC_PRIV_H__ | ||
3 | #include <engine/nvdec.h> | ||
4 | |||
5 | int nvkm_nvdec_new_(struct nvkm_device *, int, struct nvkm_nvdec **); | ||
6 | #endif | ||