freedreno/cffdec: Add helper to find next pkt

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19551>
This commit is contained in:
Rob Clark 2022-11-04 15:07:40 -07:00 committed by Marge Bot
parent cb13e24758
commit c01ac4b583
3 changed files with 20 additions and 8 deletions

View file

@ -1703,6 +1703,8 @@ got cmdszdw=27
bad type! deadd00d
opcode: CP_NOP (10) (1 dwords)
ESTIMATED CRASH LOCATION!
000000010000001c: 0000: 70108000
opcode: CP_NOP (10) (1 dwords)
0000000100000020: 0000: 70108000
opcode: CP_NOP (10) (1 dwords)
0000000100000024: 0000: 70108000

View file

@ -2899,18 +2899,12 @@ dump_commands(uint32_t *dwords, uint32_t sizedwords, int level)
printl(3, "%snop\n", levels[level + 1]);
count = 1;
} else {
printf("bad type! %08x\n", dwords[0]);
/* for 5xx+ we can do a passable job of looking for start of next valid
* packet: */
if (options->gpu_id >= 500) {
while (dwords_left > 0) {
if (pkt_is_type7(dwords[0]) || pkt_is_type4(dwords[0]))
break;
printf("bad type! %08x\n", dwords[0]);
dwords++;
dwords_left--;
}
count = find_next_packet(dwords, dwords_left);
} else {
printf("bad type! %08x\n", dwords[0]);
return;
}
}

View file

@ -158,4 +158,20 @@ pkt_is_opcode(uint32_t dword, uint32_t *opcode, uint32_t *size)
return false;
}
/**
* For a5xx+ we can detect valid packet headers vs random other noise, and
* can use this to "re-sync" to the start of the next valid packet. So that
* the same cmdstream corruption that confused the GPU doesn't confuse us!
*/
static inline uint32_t
find_next_packet(uint32_t *dwords, uint32_t sizedwords)
{
for (uint32_t c = 0; c < sizedwords; c++) {
if (pkt_is_type7(dwords[c]) || pkt_is_type4(dwords[c]))
return c;
}
return sizedwords;
}
#endif /* __CFFDEC_H__ */