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.
24 #include <core/memory.h>
25 #include <subdev/mmu.h>
27 #include <nvif/clb069.h>
28 #include <nvif/unpack.h>
31 nvkm_ufault_map(struct nvkm_object
*object
, void *argv
, u32 argc
,
32 enum nvkm_object_map
*type
, u64
*addr
, u64
*size
)
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
);
43 nvkm_ufault_ntfy(struct nvkm_object
*object
, u32 type
,
44 struct nvkm_event
**pevent
)
46 struct nvkm_fault_buffer
*buffer
= nvkm_fault_buffer(object
);
47 if (type
== NVB069_V0_NTFY_FAULT
) {
48 *pevent
= &buffer
->fault
->event
;
55 nvkm_ufault_fini(struct nvkm_object
*object
, bool suspend
)
57 struct nvkm_fault_buffer
*buffer
= nvkm_fault_buffer(object
);
58 buffer
->fault
->func
->buffer
.fini(buffer
);
63 nvkm_ufault_init(struct nvkm_object
*object
)
65 struct nvkm_fault_buffer
*buffer
= nvkm_fault_buffer(object
);
66 buffer
->fault
->func
->buffer
.init(buffer
);
71 nvkm_ufault_dtor(struct nvkm_object
*object
)
76 static const struct nvkm_object_func
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
,
86 nvkm_ufault_new(struct nvkm_device
*device
, const struct nvkm_oclass
*oclass
,
87 void *argv
, u32 argc
, struct nvkm_object
**pobject
)
90 struct nvif_clb069_v0 v0
;
92 struct nvkm_fault
*fault
= device
->fault
;
93 struct nvkm_fault_buffer
*buffer
= fault
->buffer
[fault
->func
->user
.rp
];
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
;
103 nvkm_object_ctor(&nvkm_ufault
, oclass
, &buffer
->object
);
104 *pobject
= &buffer
->object
;