xref: /aosp_15_r20/external/mesa3d/src/intel/common/intel_hang_dump.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2022 Intel Corporation
3  *
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:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 #ifndef INTEL_HANG_DUMP_H
24 #define INTEL_HANG_DUMP_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <stdint.h>
31 
32 /**
33  * This files contains a format description for data saved in a hang dump.
34  * This allows us to replay the dump later on simulation.
35  */
36 
37 /* TODO: Consider compression? ZSTD_error_dstSize_tooSmall */
38 
39 #define INTEL_HANG_DUMP_VERSION (1)
40 #define INTEL_HANG_DUMP_MAGIC   (0x4245012345676463)
41 
42 enum intel_hang_dump_block_type {
43    INTEL_HANG_DUMP_BLOCK_TYPE_HEADER    = 1,
44    INTEL_HANG_DUMP_BLOCK_TYPE_BO        = 2,
45    INTEL_HANG_DUMP_BLOCK_TYPE_MAP       = 3,
46    INTEL_HANG_DUMP_BLOCK_TYPE_EXEC      = 4,
47    INTEL_HANG_DUMP_BLOCK_TYPE_HW_IMAGE  = 5,
48 };
49 
50 struct intel_hang_dump_block_base {
51    uint32_t type; /* enum intel_hang_dump_block_type */
52 
53    uint32_t pad;
54 };
55 
56 struct intel_hang_dump_block_header {
57    struct intel_hang_dump_block_base base;
58 
59    uint64_t magic;
60 
61    uint32_t version;
62    uint32_t pad;
63 };
64 
65 struct intel_hang_dump_block_bo {
66    struct intel_hang_dump_block_base base;
67 
68    /* Helpful */
69    char name[64];
70 
71    /* PPGTT location */
72    uint64_t offset;
73 
74    /* Buffer size */
75    uint64_t size;
76 
77    /* Data follows */
78 };
79 
80 struct intel_hang_dump_block_map {
81    struct intel_hang_dump_block_base base;
82 
83    /* Helpful */
84    char name[64];
85 
86    /* PPGTT location */
87    uint64_t offset;
88 
89    /* Buffer size */
90    uint64_t size;
91 };
92 
93 struct intel_hang_dump_block_exec {
94    struct intel_hang_dump_block_base base;
95 
96    /* PPGTT location */
97    uint64_t offset;
98 };
99 
100 struct intel_hang_dump_block_hw_image {
101    struct intel_hang_dump_block_base base;
102 
103    /* Buffer size */
104    uint64_t size;
105 
106    /* Data follows */
107 };
108 
109 union intel_hang_dump_block_all {
110    struct intel_hang_dump_block_base     base;
111    struct intel_hang_dump_block_header   header;
112    struct intel_hang_dump_block_bo       bo;
113    struct intel_hang_dump_block_map      map;
114    struct intel_hang_dump_block_exec     exec;
115    struct intel_hang_dump_block_hw_image hw_img;
116 };
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif /* INTEL_HANG_DUMP_H */
123