| 1 |
#include "nv_push.h" |
| 2 |
|
| 3 |
#include "nv_device_info.h" |
| 4 |
|
| 5 |
#include <inttypes.h> |
| 6 |
#include "util/os_misc.h" |
| 7 |
|
| 8 |
#include "drf.h" |
| 9 |
#include "cl906f.h" |
| 10 |
#include "nv_push_class_dump.h" |
| 11 |
|
| 12 |
#ifndef NDEBUG |
| 13 |
void |
| 14 |
nv_push_validate(struct nv_push *push) |
| 15 |
{ |
| 16 |
uint32_t *cur = push->start; |
| 17 |
|
| 18 |
/* submitting empty push buffers is probably a bug */ |
| 19 |
assert(push->end != push->start); |
| 20 |
|
| 21 |
/* make sure we don't overrun the bo */ |
| 22 |
assert(push->end <= push->limit); |
| 23 |
|
| 24 |
/* parse all the headers to see if we get to buf->map */ |
| 25 |
while (cur < push->end) { |
| 26 |
uint32_t hdr = *cur; |
| 27 |
uint32_t mthd = NVVAL_GET(hdr, NV906F, DMA, SEC_OP); |
| 28 |
|
| 29 |
switch (mthd) { |
| 30 |
case NV906F_DMA_SEC_OP_IMMD_DATA_METHOD: |
| 31 |
break; |
| 32 |
case NV906F_DMA_SEC_OP_INC_METHOD: |
| 33 |
case NV906F_DMA_SEC_OP_NON_INC_METHOD: |
| 34 |
case NV906F_DMA_SEC_OP_ONE_INC: { |
| 35 |
uint32_t count = NVVAL_GET(hdr, NV906F, DMA, METHOD_COUNT); |
| 36 |
assert(count); |
| 37 |
cur += count; |
| 38 |
break; |
| 39 |
} |
| 40 |
default: |
| 41 |
assert(!"unknown method found"); |
| 42 |
} |
| 43 |
|
| 44 |
cur++; |
| 45 |
assert(cur <= push->end); |
| 46 |
} |
| 47 |
} |
| 48 |
#endif |
| 49 |
|
| 50 |
void |
| 51 |
vk_push_print(FILE *fp, const struct nv_push *push, |
| 52 |
const struct nv_device_info *devinfo) |
| 53 |
{ |
| 54 |
uint32_t *cur = push->start; |
| 55 |
uint16_t curr_subchans[8] = {0}; |
| 56 |
curr_subchans[0] = devinfo->cls_eng3d; |
| 57 |
curr_subchans[1] = devinfo->cls_compute; |
| 58 |
curr_subchans[2] = devinfo->cls_m2mf; |
| 59 |
curr_subchans[3] = devinfo->cls_eng2d; |
| 60 |
curr_subchans[4] = devinfo->cls_copy; |
| 61 |
|
| 62 |
const bool print_offsets = true; |
| 63 |
|
| 64 |
while (cur < push->end) { |
| 65 |
uint32_t hdr = *cur; |
| 66 |
uint32_t type = NVVAL_GET(hdr, NV906F, DMA, SEC_OP); |
| 67 |
bool is_tert = type == NV906F_DMA_SEC_OP_GRP0_USE_TERT || |
| 68 |
type == NV906F_DMA_SEC_OP_GRP2_USE_TERT; |
| 69 |
uint32_t inc = 0; |
| 70 |
uint32_t count = is_tert ? (hdr >> 18) & 0x3ff |
| 71 |
: NVVAL_GET(hdr, NV906F, DMA, METHOD_COUNT); |
| 72 |
uint32_t tert_op = NVVAL_GET(hdr, NV906F, DMA, TERT_OP); |
| 73 |
uint32_t subchan = NVVAL_GET(hdr, NV906F, DMA, METHOD_SUBCHANNEL); |
| 74 |
uint32_t mthd = NVVAL_GET(hdr, NV906F, DMA, METHOD_ADDRESS) << 2; |
| 75 |
uint32_t value = 0; |
| 76 |
bool is_immd = false; |
| 77 |
|
| 78 |
if (print_offsets) |
| 79 |
fprintf(fp, "[0x%08" PRIxPTR "] ", cur - push->start); |
| 80 |
|
| 81 |
if (is_tert && tert_op != 0) { |
| 82 |
fprintf(fp, "HDR %x subch N/A", hdr); |
| 83 |
} else { |
| 84 |
fprintf(fp, "HDR %x subch %i", hdr, subchan); |
| 85 |
} |
| 86 |
|
| 87 |
cur++; |
| 88 |
|
| 89 |
const char *mthd_name = ""; |
| 90 |
|
| 91 |
switch (type) { |
| 92 |
case NV906F_DMA_SEC_OP_IMMD_DATA_METHOD: |
| 93 |
fprintf(fp, " IMMD\n"); |
| 94 |
inc = 0; |
| 95 |
is_immd = true; |
| 96 |
value = NVVAL_GET(hdr, NV906F, DMA, IMMD_DATA); |
| 97 |
count = 1; |
| 98 |
break; |
| 99 |
case NV906F_DMA_SEC_OP_INC_METHOD: |
| 100 |
fprintf(fp, " NINC\n"); |
| 101 |
inc = count; |
| 102 |
break; |
| 103 |
case NV906F_DMA_SEC_OP_GRP2_USE_TERT: |
| 104 |
case NV906F_DMA_SEC_OP_NON_INC_METHOD: |
| 105 |
fprintf(fp, " 0INC\n"); |
| 106 |
inc = 0; |
| 107 |
break; |
| 108 |
case NV906F_DMA_SEC_OP_ONE_INC: |
| 109 |
fprintf(fp, " 1INC\n"); |
| 110 |
inc = 1; |
| 111 |
break; |
| 112 |
case NV906F_DMA_SEC_OP_GRP0_USE_TERT: |
| 113 |
switch (tert_op) { |
| 114 |
case NV906F_DMA_TERT_OP_GRP0_INC_METHOD: |
| 115 |
fprintf(fp, " NINC\n"); |
| 116 |
inc = count; |
| 117 |
break; |
| 118 |
case NV906F_DMA_TERT_OP_GRP0_SET_SUB_DEV_MASK: |
| 119 |
fprintf(fp, " SUB_DEVICE_OP\n"); |
| 120 |
mthd_name = "SET_SUBDEVICE_MASK"; |
| 121 |
mthd = tert_op; |
| 122 |
value = (hdr >> 4) & 0xfff; |
| 123 |
count = 1; |
| 124 |
is_immd = true; |
| 125 |
break; |
| 126 |
case NV906F_DMA_TERT_OP_GRP0_STORE_SUB_DEV_MASK: |
| 127 |
fprintf(fp, " SUB_DEVICE_OP\n"); |
| 128 |
mthd_name = "STORE_SUBDEVICE_MASK"; |
| 129 |
mthd = tert_op; |
| 130 |
value = (hdr >> 4) & 0xfff; |
| 131 |
count = 1; |
| 132 |
is_immd = true; |
| 133 |
break; |
| 134 |
case NV906F_DMA_TERT_OP_GRP0_USE_SUB_DEV_MASK: |
| 135 |
fprintf(fp, " SUB_DEVICE_OP\n"); |
| 136 |
mthd_name = "USE_SUBDEVICE_MASK"; |
| 137 |
mthd = tert_op; |
| 138 |
count = 1; |
| 139 |
break; |
| 140 |
} |
| 141 |
break; |
| 142 |
} |
| 143 |
|
| 144 |
while (count--) { |
| 145 |
if (!is_immd) |
| 146 |
value = *cur; |
| 147 |
|
| 148 |
if (mthd == 0) { /* SET_OBJECT */ |
| 149 |
curr_subchans[subchan] = value & 0xffff; |
| 150 |
} |
| 151 |
int class_id = curr_subchans[subchan]; |
| 152 |
|
| 153 |
/* If the sub channel is unbound, the expected behavior is to have it |
| 154 |
* routed to the GPFIFO class */ |
| 155 |
if (class_id == 0) |
| 156 |
class_id = devinfo->cls_gpfifo; |
| 157 |
|
| 158 |
if (!is_tert) |
| 159 |
mthd_name = P_PARSE_NV_MTHD(class_id, mthd); |
| 160 |
|
| 161 |
fprintf(fp, "\tmthd %04x %s\n", mthd, mthd_name); |
| 162 |
P_DUMP_NV_MTHD_DATA(fp, class_id, mthd, value, "\t\t"); |
| 163 |
|
| 164 |
if (!is_immd) |
| 165 |
cur++; |
| 166 |
|
| 167 |
if (inc) { |
| 168 |
inc--; |
| 169 |
mthd += 4; |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
fprintf(fp, "\n"); |
| 174 |
} |
| 175 |
} |