2 * Copyright 2018 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
22 #include <nvif/fifo.h>
25 nvif_fifo_runlists(struct nvif_device
*device
)
27 struct nvif_object
*object
= &device
->object
;
29 struct nv_device_info_v1 m
;
31 struct nv_device_info_v1_data runlists
;
32 struct nv_device_info_v1_data runlist
[64];
40 if (!(a
= kmalloc(sizeof(*a
), GFP_KERNEL
)))
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
);
48 ret
= nvif_object_mthd(object
, NV_DEVICE_V0_INFO
, a
, sizeof(*a
));
52 device
->runlists
= fls64(a
->v
.runlists
.data
);
53 device
->runlist
= kcalloc(device
->runlists
, sizeof(*device
->runlist
),
55 if (!device
->runlist
) {
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
;
71 nvif_fifo_runlist(struct nvif_device
*device
, u64 engine
)
73 struct nvif_object
*object
= &device
->object
;
75 struct nv_device_info_v1 m
;
77 struct nv_device_info_v1_data engine
;
81 .m
.count
= sizeof(a
.v
) / sizeof(a
.v
.engine
),
82 .v
.engine
.mthd
= engine
,
87 if ((ret
= nvif_fifo_runlists(device
)))
90 ret
= nvif_object_mthd(object
, NV_DEVICE_V0_INFO
, &a
, sizeof(a
));
92 for (i
= 0; i
< device
->runlists
; i
++) {
93 if (device
->runlist
[i
].engines
& a
.v
.engine
.data
)