This source file includes following definitions.
- nvif_fifo_runlists
- nvif_fifo_runlist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include <nvif/fifo.h>
23
24 static int
25 nvif_fifo_runlists(struct nvif_device *device)
26 {
27 struct nvif_object *object = &device->object;
28 struct {
29 struct nv_device_info_v1 m;
30 struct {
31 struct nv_device_info_v1_data runlists;
32 struct nv_device_info_v1_data runlist[64];
33 } v;
34 } *a;
35 int ret, i;
36
37 if (device->runlist)
38 return 0;
39
40 if (!(a = kmalloc(sizeof(*a), GFP_KERNEL)))
41 return -ENOMEM;
42 a->m.version = 1;
43 a->m.count = sizeof(a->v) / sizeof(a->v.runlists);
44 a->v.runlists.mthd = NV_DEVICE_FIFO_RUNLISTS;
45 for (i = 0; i < ARRAY_SIZE(a->v.runlist); i++)
46 a->v.runlist[i].mthd = NV_DEVICE_FIFO_RUNLIST_ENGINES(i);
47
48 ret = nvif_object_mthd(object, NV_DEVICE_V0_INFO, a, sizeof(*a));
49 if (ret)
50 goto done;
51
52 device->runlists = fls64(a->v.runlists.data);
53 device->runlist = kcalloc(device->runlists, sizeof(*device->runlist),
54 GFP_KERNEL);
55 if (!device->runlist) {
56 ret = -ENOMEM;
57 goto done;
58 }
59
60 for (i = 0; i < device->runlists; i++) {
61 if (a->v.runlists.data & BIT_ULL(i))
62 device->runlist[i].engines = a->v.runlist[i].data;
63 }
64
65 done:
66 kfree(a);
67 return ret;
68 }
69
70 u64
71 nvif_fifo_runlist(struct nvif_device *device, u64 engine)
72 {
73 struct nvif_object *object = &device->object;
74 struct {
75 struct nv_device_info_v1 m;
76 struct {
77 struct nv_device_info_v1_data engine;
78 } v;
79 } a = {
80 .m.version = 1,
81 .m.count = sizeof(a.v) / sizeof(a.v.engine),
82 .v.engine.mthd = engine,
83 };
84 u64 runm = 0;
85 int ret, i;
86
87 if ((ret = nvif_fifo_runlists(device)))
88 return runm;
89
90 ret = nvif_object_mthd(object, NV_DEVICE_V0_INFO, &a, sizeof(a));
91 if (ret == 0) {
92 for (i = 0; i < device->runlists; i++) {
93 if (device->runlist[i].engines & a.v.engine.data)
94 runm |= BIT_ULL(i);
95 }
96 }
97
98 return runm;
99 }