1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <core/client.h>
26#include <core/falcon.h>
27#include <core/class.h>
28#include <core/enum.h>
29
30#include <subdev/fb.h>
31#include <subdev/vm.h>
32
33#include <engine/fifo.h>
34#include <engine/copy.h>
35
36#include "fuc/nva3.fuc.h"
37
38struct nva3_copy_priv {
39 struct nouveau_falcon base;
40};
41
42
43
44
45
46static struct nouveau_oclass
47nva3_copy_sclass[] = {
48 { 0x85b5, &nouveau_object_ofuncs },
49 {}
50};
51
52
53
54
55
56static struct nouveau_oclass
57nva3_copy_cclass = {
58 .handle = NV_ENGCTX(COPY0, 0xa3),
59 .ofuncs = &(struct nouveau_ofuncs) {
60 .ctor = _nouveau_falcon_context_ctor,
61 .dtor = _nouveau_falcon_context_dtor,
62 .init = _nouveau_falcon_context_init,
63 .fini = _nouveau_falcon_context_fini,
64 .rd32 = _nouveau_falcon_context_rd32,
65 .wr32 = _nouveau_falcon_context_wr32,
66
67 },
68};
69
70
71
72
73
74static const struct nouveau_enum nva3_copy_isr_error_name[] = {
75 { 0x0001, "ILLEGAL_MTHD" },
76 { 0x0002, "INVALID_ENUM" },
77 { 0x0003, "INVALID_BITFIELD" },
78 {}
79};
80
81void
82nva3_copy_intr(struct nouveau_subdev *subdev)
83{
84 struct nouveau_fifo *pfifo = nouveau_fifo(subdev);
85 struct nouveau_engine *engine = nv_engine(subdev);
86 struct nouveau_falcon *falcon = (void *)subdev;
87 struct nouveau_object *engctx;
88 u32 dispatch = nv_ro32(falcon, 0x01c);
89 u32 stat = nv_ro32(falcon, 0x008) & dispatch & ~(dispatch >> 16);
90 u64 inst = nv_ro32(falcon, 0x050) & 0x3fffffff;
91 u32 ssta = nv_ro32(falcon, 0x040) & 0x0000ffff;
92 u32 addr = nv_ro32(falcon, 0x040) >> 16;
93 u32 mthd = (addr & 0x07ff) << 2;
94 u32 subc = (addr & 0x3800) >> 11;
95 u32 data = nv_ro32(falcon, 0x044);
96 int chid;
97
98 engctx = nouveau_engctx_get(engine, inst);
99 chid = pfifo->chid(pfifo, engctx);
100
101 if (stat & 0x00000040) {
102 nv_error(falcon, "DISPATCH_ERROR [");
103 nouveau_enum_print(nva3_copy_isr_error_name, ssta);
104 pr_cont("] ch %d [0x%010llx %s] subc %d mthd 0x%04x data 0x%08x\n",
105 chid, inst << 12, nouveau_client_name(engctx), subc,
106 mthd, data);
107 nv_wo32(falcon, 0x004, 0x00000040);
108 stat &= ~0x00000040;
109 }
110
111 if (stat) {
112 nv_error(falcon, "unhandled intr 0x%08x\n", stat);
113 nv_wo32(falcon, 0x004, stat);
114 }
115
116 nouveau_engctx_put(engctx);
117}
118
119static int
120nva3_copy_tlb_flush(struct nouveau_engine *engine)
121{
122 nv50_vm_flush_engine(&engine->base, 0x0d);
123 return 0;
124}
125
126static int
127nva3_copy_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
128 struct nouveau_oclass *oclass, void *data, u32 size,
129 struct nouveau_object **pobject)
130{
131 bool enable = (nv_device(parent)->chipset != 0xaf);
132 struct nva3_copy_priv *priv;
133 int ret;
134
135 ret = nouveau_falcon_create(parent, engine, oclass, 0x104000, enable,
136 "PCE0", "copy0", &priv);
137 *pobject = nv_object(priv);
138 if (ret)
139 return ret;
140
141 nv_subdev(priv)->unit = 0x00802000;
142 nv_subdev(priv)->intr = nva3_copy_intr;
143 nv_engine(priv)->cclass = &nva3_copy_cclass;
144 nv_engine(priv)->sclass = nva3_copy_sclass;
145 nv_engine(priv)->tlb_flush = nva3_copy_tlb_flush;
146 nv_falcon(priv)->code.data = nva3_pcopy_code;
147 nv_falcon(priv)->code.size = sizeof(nva3_pcopy_code);
148 nv_falcon(priv)->data.data = nva3_pcopy_data;
149 nv_falcon(priv)->data.size = sizeof(nva3_pcopy_data);
150 return 0;
151}
152
153struct nouveau_oclass
154nva3_copy_oclass = {
155 .handle = NV_ENGINE(COPY0, 0xa3),
156 .ofuncs = &(struct nouveau_ofuncs) {
157 .ctor = nva3_copy_ctor,
158 .dtor = _nouveau_falcon_dtor,
159 .init = _nouveau_falcon_init,
160 .fini = _nouveau_falcon_fini,
161 .rd32 = _nouveau_falcon_rd32,
162 .wr32 = _nouveau_falcon_wr32,
163 },
164};
165