diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-11-21 21:18:57 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2012-11-28 18:58:01 -0500 |
commit | 27abc13e47d7366bf87d6f9c61b118de27ab48da (patch) | |
tree | 293193ec004a8a7372ffb876ad68742e4d50f53e | |
parent | e3aaa946bd7d0073bd338c159778015ed32ecb5b (diff) |
drm/nv98/crypt: use nouveau_falcon base class
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c | 27 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c | 64 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/core/include/engine/crypt.h | 39 |
3 files changed, 35 insertions, 95 deletions
diff --git a/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c b/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c index 1d85e5b66ca0..10d12ad2571b 100644 --- a/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c +++ b/drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c | |||
@@ -34,11 +34,11 @@ | |||
34 | #include <engine/crypt.h> | 34 | #include <engine/crypt.h> |
35 | 35 | ||
36 | struct nv84_crypt_priv { | 36 | struct nv84_crypt_priv { |
37 | struct nouveau_crypt base; | 37 | struct nouveau_engine base; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | struct nv84_crypt_chan { | 40 | struct nv84_crypt_chan { |
41 | struct nouveau_crypt_chan base; | 41 | struct nouveau_engctx base; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | /******************************************************************************* | 44 | /******************************************************************************* |
@@ -96,8 +96,8 @@ nv84_crypt_context_ctor(struct nouveau_object *parent, | |||
96 | struct nv84_crypt_chan *priv; | 96 | struct nv84_crypt_chan *priv; |
97 | int ret; | 97 | int ret; |
98 | 98 | ||
99 | ret = nouveau_crypt_context_create(parent, engine, oclass, NULL, 256, | 99 | ret = nouveau_engctx_create(parent, engine, oclass, NULL, 256, |
100 | 0, NVOBJ_FLAG_ZERO_ALLOC, &priv); | 100 | 0, NVOBJ_FLAG_ZERO_ALLOC, &priv); |
101 | *pobject = nv_object(priv); | 101 | *pobject = nv_object(priv); |
102 | if (ret) | 102 | if (ret) |
103 | return ret; | 103 | return ret; |
@@ -110,11 +110,11 @@ nv84_crypt_cclass = { | |||
110 | .handle = NV_ENGCTX(CRYPT, 0x84), | 110 | .handle = NV_ENGCTX(CRYPT, 0x84), |
111 | .ofuncs = &(struct nouveau_ofuncs) { | 111 | .ofuncs = &(struct nouveau_ofuncs) { |
112 | .ctor = nv84_crypt_context_ctor, | 112 | .ctor = nv84_crypt_context_ctor, |
113 | .dtor = _nouveau_crypt_context_dtor, | 113 | .dtor = _nouveau_engctx_dtor, |
114 | .init = _nouveau_crypt_context_init, | 114 | .init = _nouveau_engctx_init, |
115 | .fini = _nouveau_crypt_context_fini, | 115 | .fini = _nouveau_engctx_fini, |
116 | .rd32 = _nouveau_crypt_context_rd32, | 116 | .rd32 = _nouveau_engctx_rd32, |
117 | .wr32 = _nouveau_crypt_context_wr32, | 117 | .wr32 = _nouveau_engctx_wr32, |
118 | }, | 118 | }, |
119 | }; | 119 | }; |
120 | 120 | ||
@@ -176,7 +176,8 @@ nv84_crypt_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
176 | struct nv84_crypt_priv *priv; | 176 | struct nv84_crypt_priv *priv; |
177 | int ret; | 177 | int ret; |
178 | 178 | ||
179 | ret = nouveau_crypt_create(parent, engine, oclass, &priv); | 179 | ret = nouveau_engine_create(parent, engine, oclass, true, |
180 | "PCRYPT", "crypt", &priv); | ||
180 | *pobject = nv_object(priv); | 181 | *pobject = nv_object(priv); |
181 | if (ret) | 182 | if (ret) |
182 | return ret; | 183 | return ret; |
@@ -195,7 +196,7 @@ nv84_crypt_init(struct nouveau_object *object) | |||
195 | struct nv84_crypt_priv *priv = (void *)object; | 196 | struct nv84_crypt_priv *priv = (void *)object; |
196 | int ret; | 197 | int ret; |
197 | 198 | ||
198 | ret = nouveau_crypt_init(&priv->base); | 199 | ret = nouveau_engine_init(&priv->base); |
199 | if (ret) | 200 | if (ret) |
200 | return ret; | 201 | return ret; |
201 | 202 | ||
@@ -210,8 +211,8 @@ nv84_crypt_oclass = { | |||
210 | .handle = NV_ENGINE(CRYPT, 0x84), | 211 | .handle = NV_ENGINE(CRYPT, 0x84), |
211 | .ofuncs = &(struct nouveau_ofuncs) { | 212 | .ofuncs = &(struct nouveau_ofuncs) { |
212 | .ctor = nv84_crypt_ctor, | 213 | .ctor = nv84_crypt_ctor, |
213 | .dtor = _nouveau_crypt_dtor, | 214 | .dtor = _nouveau_engine_dtor, |
214 | .init = nv84_crypt_init, | 215 | .init = nv84_crypt_init, |
215 | .fini = _nouveau_crypt_fini, | 216 | .fini = _nouveau_engine_fini, |
216 | }, | 217 | }, |
217 | }; | 218 | }; |
diff --git a/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c b/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c index 9e3876c89b96..0912b79be97f 100644 --- a/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c +++ b/drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <core/enum.h> | 26 | #include <core/enum.h> |
27 | #include <core/class.h> | 27 | #include <core/class.h> |
28 | #include <core/engctx.h> | 28 | #include <core/engctx.h> |
29 | #include <core/falcon.h> | ||
29 | 30 | ||
30 | #include <subdev/timer.h> | 31 | #include <subdev/timer.h> |
31 | #include <subdev/fb.h> | 32 | #include <subdev/fb.h> |
@@ -36,11 +37,11 @@ | |||
36 | #include "fuc/nv98.fuc.h" | 37 | #include "fuc/nv98.fuc.h" |
37 | 38 | ||
38 | struct nv98_crypt_priv { | 39 | struct nv98_crypt_priv { |
39 | struct nouveau_crypt base; | 40 | struct nouveau_falcon base; |
40 | }; | 41 | }; |
41 | 42 | ||
42 | struct nv98_crypt_chan { | 43 | struct nv98_crypt_chan { |
43 | struct nouveau_crypt_chan base; | 44 | struct nouveau_falcon_chan base; |
44 | }; | 45 | }; |
45 | 46 | ||
46 | /******************************************************************************* | 47 | /******************************************************************************* |
@@ -66,8 +67,8 @@ nv98_crypt_context_ctor(struct nouveau_object *parent, | |||
66 | struct nv98_crypt_chan *priv; | 67 | struct nv98_crypt_chan *priv; |
67 | int ret; | 68 | int ret; |
68 | 69 | ||
69 | ret = nouveau_crypt_context_create(parent, engine, oclass, NULL, 256, | 70 | ret = nouveau_falcon_context_create(parent, engine, oclass, NULL, 256, |
70 | 256, NVOBJ_FLAG_ZERO_ALLOC, &priv); | 71 | 256, NVOBJ_FLAG_ZERO_ALLOC, &priv); |
71 | *pobject = nv_object(priv); | 72 | *pobject = nv_object(priv); |
72 | if (ret) | 73 | if (ret) |
73 | return ret; | 74 | return ret; |
@@ -80,11 +81,11 @@ nv98_crypt_cclass = { | |||
80 | .handle = NV_ENGCTX(CRYPT, 0x98), | 81 | .handle = NV_ENGCTX(CRYPT, 0x98), |
81 | .ofuncs = &(struct nouveau_ofuncs) { | 82 | .ofuncs = &(struct nouveau_ofuncs) { |
82 | .ctor = nv98_crypt_context_ctor, | 83 | .ctor = nv98_crypt_context_ctor, |
83 | .dtor = _nouveau_crypt_context_dtor, | 84 | .dtor = _nouveau_falcon_context_dtor, |
84 | .init = _nouveau_crypt_context_init, | 85 | .init = _nouveau_falcon_context_init, |
85 | .fini = _nouveau_crypt_context_fini, | 86 | .fini = _nouveau_falcon_context_fini, |
86 | .rd32 = _nouveau_crypt_context_rd32, | 87 | .rd32 = _nouveau_falcon_context_rd32, |
87 | .wr32 = _nouveau_crypt_context_wr32, | 88 | .wr32 = _nouveau_falcon_context_wr32, |
88 | }, | 89 | }, |
89 | }; | 90 | }; |
90 | 91 | ||
@@ -153,7 +154,8 @@ nv98_crypt_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
153 | struct nv98_crypt_priv *priv; | 154 | struct nv98_crypt_priv *priv; |
154 | int ret; | 155 | int ret; |
155 | 156 | ||
156 | ret = nouveau_crypt_create(parent, engine, oclass, &priv); | 157 | ret = nouveau_falcon_create(parent, engine, oclass, 0x087000, true, |
158 | "PCRYPT", "crypt", &priv); | ||
157 | *pobject = nv_object(priv); | 159 | *pobject = nv_object(priv); |
158 | if (ret) | 160 | if (ret) |
159 | return ret; | 161 | return ret; |
@@ -163,36 +165,10 @@ nv98_crypt_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
163 | nv_engine(priv)->cclass = &nv98_crypt_cclass; | 165 | nv_engine(priv)->cclass = &nv98_crypt_cclass; |
164 | nv_engine(priv)->sclass = nv98_crypt_sclass; | 166 | nv_engine(priv)->sclass = nv98_crypt_sclass; |
165 | nv_engine(priv)->tlb_flush = nv98_crypt_tlb_flush; | 167 | nv_engine(priv)->tlb_flush = nv98_crypt_tlb_flush; |
166 | return 0; | 168 | nv_falcon(priv)->code.data = nv98_pcrypt_code; |
167 | } | 169 | nv_falcon(priv)->code.size = sizeof(nv98_pcrypt_code); |
168 | 170 | nv_falcon(priv)->data.data = nv98_pcrypt_data; | |
169 | static int | 171 | nv_falcon(priv)->data.size = sizeof(nv98_pcrypt_data); |
170 | nv98_crypt_init(struct nouveau_object *object) | ||
171 | { | ||
172 | struct nv98_crypt_priv *priv = (void *)object; | ||
173 | int ret, i; | ||
174 | |||
175 | ret = nouveau_crypt_init(&priv->base); | ||
176 | if (ret) | ||
177 | return ret; | ||
178 | |||
179 | /* wait for exit interrupt to signal */ | ||
180 | nv_wait(priv, 0x087008, 0x00000010, 0x00000010); | ||
181 | nv_wr32(priv, 0x087004, 0x00000010); | ||
182 | |||
183 | /* upload microcode code and data segments */ | ||
184 | nv_wr32(priv, 0x087ff8, 0x00100000); | ||
185 | for (i = 0; i < ARRAY_SIZE(nv98_pcrypt_code); i++) | ||
186 | nv_wr32(priv, 0x087ff4, nv98_pcrypt_code[i]); | ||
187 | |||
188 | nv_wr32(priv, 0x087ff8, 0x00000000); | ||
189 | for (i = 0; i < ARRAY_SIZE(nv98_pcrypt_data); i++) | ||
190 | nv_wr32(priv, 0x087ff4, nv98_pcrypt_data[i]); | ||
191 | |||
192 | /* start it running */ | ||
193 | nv_wr32(priv, 0x08710c, 0x00000000); | ||
194 | nv_wr32(priv, 0x087104, 0x00000000); /* ENTRY */ | ||
195 | nv_wr32(priv, 0x087100, 0x00000002); /* TRIGGER */ | ||
196 | return 0; | 172 | return 0; |
197 | } | 173 | } |
198 | 174 | ||
@@ -201,8 +177,10 @@ nv98_crypt_oclass = { | |||
201 | .handle = NV_ENGINE(CRYPT, 0x98), | 177 | .handle = NV_ENGINE(CRYPT, 0x98), |
202 | .ofuncs = &(struct nouveau_ofuncs) { | 178 | .ofuncs = &(struct nouveau_ofuncs) { |
203 | .ctor = nv98_crypt_ctor, | 179 | .ctor = nv98_crypt_ctor, |
204 | .dtor = _nouveau_crypt_dtor, | 180 | .dtor = _nouveau_falcon_dtor, |
205 | .init = nv98_crypt_init, | 181 | .init = _nouveau_falcon_init, |
206 | .fini = _nouveau_crypt_fini, | 182 | .fini = _nouveau_falcon_fini, |
183 | .rd32 = _nouveau_falcon_rd32, | ||
184 | .wr32 = _nouveau_falcon_wr32, | ||
207 | }, | 185 | }, |
208 | }; | 186 | }; |
diff --git a/drivers/gpu/drm/nouveau/core/include/engine/crypt.h b/drivers/gpu/drm/nouveau/core/include/engine/crypt.h index e3674743baaa..db975618e937 100644 --- a/drivers/gpu/drm/nouveau/core/include/engine/crypt.h +++ b/drivers/gpu/drm/nouveau/core/include/engine/crypt.h | |||
@@ -1,45 +1,6 @@ | |||
1 | #ifndef __NOUVEAU_CRYPT_H__ | 1 | #ifndef __NOUVEAU_CRYPT_H__ |
2 | #define __NOUVEAU_CRYPT_H__ | 2 | #define __NOUVEAU_CRYPT_H__ |
3 | 3 | ||
4 | #include <core/engine.h> | ||
5 | #include <core/engctx.h> | ||
6 | |||
7 | struct nouveau_crypt_chan { | ||
8 | struct nouveau_engctx base; | ||
9 | }; | ||
10 | |||
11 | #define nouveau_crypt_context_create(p,e,c,g,s,a,f,d) \ | ||
12 | nouveau_engctx_create((p), (e), (c), (g), (s), (a), (f), (d)) | ||
13 | #define nouveau_crypt_context_destroy(d) \ | ||
14 | nouveau_engctx_destroy(&(d)->base) | ||
15 | #define nouveau_crypt_context_init(d) \ | ||
16 | nouveau_engctx_init(&(d)->base) | ||
17 | #define nouveau_crypt_context_fini(d,s) \ | ||
18 | nouveau_engctx_fini(&(d)->base, (s)) | ||
19 | |||
20 | #define _nouveau_crypt_context_dtor _nouveau_engctx_dtor | ||
21 | #define _nouveau_crypt_context_init _nouveau_engctx_init | ||
22 | #define _nouveau_crypt_context_fini _nouveau_engctx_fini | ||
23 | #define _nouveau_crypt_context_rd32 _nouveau_engctx_rd32 | ||
24 | #define _nouveau_crypt_context_wr32 _nouveau_engctx_wr32 | ||
25 | |||
26 | struct nouveau_crypt { | ||
27 | struct nouveau_engine base; | ||
28 | }; | ||
29 | |||
30 | #define nouveau_crypt_create(p,e,c,d) \ | ||
31 | nouveau_engine_create((p), (e), (c), true, "PCRYPT", "crypt", (d)) | ||
32 | #define nouveau_crypt_destroy(d) \ | ||
33 | nouveau_engine_destroy(&(d)->base) | ||
34 | #define nouveau_crypt_init(d) \ | ||
35 | nouveau_engine_init(&(d)->base) | ||
36 | #define nouveau_crypt_fini(d,s) \ | ||
37 | nouveau_engine_fini(&(d)->base, (s)) | ||
38 | |||
39 | #define _nouveau_crypt_dtor _nouveau_engine_dtor | ||
40 | #define _nouveau_crypt_init _nouveau_engine_init | ||
41 | #define _nouveau_crypt_fini _nouveau_engine_fini | ||
42 | |||
43 | extern struct nouveau_oclass nv84_crypt_oclass; | 4 | extern struct nouveau_oclass nv84_crypt_oclass; |
44 | extern struct nouveau_oclass nv98_crypt_oclass; | 5 | extern struct nouveau_oclass nv98_crypt_oclass; |
45 | 6 | ||