This source file includes following definitions.
- nvkm_ufault_map
- nvkm_ufault_ntfy
- nvkm_ufault_fini
- nvkm_ufault_init
- nvkm_ufault_dtor
- nvkm_ufault_new
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include "priv.h"
23
24 #include <core/memory.h>
25 #include <subdev/mmu.h>
26
27 #include <nvif/clb069.h>
28 #include <nvif/unpack.h>
29
30 static int
31 nvkm_ufault_map(struct nvkm_object *object, void *argv, u32 argc,
32 enum nvkm_object_map *type, u64 *addr, u64 *size)
33 {
34 struct nvkm_fault_buffer *buffer = nvkm_fault_buffer(object);
35 struct nvkm_device *device = buffer->fault->subdev.device;
36 *type = NVKM_OBJECT_MAP_IO;
37 *addr = device->func->resource_addr(device, 3) + buffer->addr;
38 *size = nvkm_memory_size(buffer->mem);
39 return 0;
40 }
41
42 static int
43 nvkm_ufault_ntfy(struct nvkm_object *object, u32 type,
44 struct nvkm_event **pevent)
45 {
46 struct nvkm_fault_buffer *buffer = nvkm_fault_buffer(object);
47 if (type == NVB069_V0_NTFY_FAULT) {
48 *pevent = &buffer->fault->event;
49 return 0;
50 }
51 return -EINVAL;
52 }
53
54 static int
55 nvkm_ufault_fini(struct nvkm_object *object, bool suspend)
56 {
57 struct nvkm_fault_buffer *buffer = nvkm_fault_buffer(object);
58 buffer->fault->func->buffer.fini(buffer);
59 return 0;
60 }
61
62 static int
63 nvkm_ufault_init(struct nvkm_object *object)
64 {
65 struct nvkm_fault_buffer *buffer = nvkm_fault_buffer(object);
66 buffer->fault->func->buffer.init(buffer);
67 return 0;
68 }
69
70 static void *
71 nvkm_ufault_dtor(struct nvkm_object *object)
72 {
73 return NULL;
74 }
75
76 static const struct nvkm_object_func
77 nvkm_ufault = {
78 .dtor = nvkm_ufault_dtor,
79 .init = nvkm_ufault_init,
80 .fini = nvkm_ufault_fini,
81 .ntfy = nvkm_ufault_ntfy,
82 .map = nvkm_ufault_map,
83 };
84
85 int
86 nvkm_ufault_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
87 void *argv, u32 argc, struct nvkm_object **pobject)
88 {
89 union {
90 struct nvif_clb069_v0 v0;
91 } *args = argv;
92 struct nvkm_fault *fault = device->fault;
93 struct nvkm_fault_buffer *buffer = fault->buffer[fault->func->user.rp];
94 int ret = -ENOSYS;
95
96 if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
97 args->v0.entries = buffer->entries;
98 args->v0.get = buffer->get;
99 args->v0.put = buffer->put;
100 } else
101 return ret;
102
103 nvkm_object_ctor(&nvkm_ufault, oclass, &buffer->object);
104 *pobject = &buffer->object;
105 return 0;
106 }