freedreno/afuc: Run entire bootstrap routine

We also need the BV/LPAC info, so run the entire thing until we get to a
waitin or read $data without waitin, which the BV microcode does
because it is disabled by default and skips everything until a
CP_THREAD_CONTROL packet.

The actual microcode writes the packet table last, but my simple test
one doesn't, and there's no guarantee it will continue to do so.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26771>
This commit is contained in:
Connor Abbott 2023-12-19 18:54:58 -05:00 committed by Marge Bot
parent 71f80d3deb
commit 11b4b570a9
3 changed files with 18 additions and 2 deletions

View file

@ -240,6 +240,11 @@ emu_get_fifo_reg(struct emu *emu, unsigned n, bool peek)
return emu_get_gpu_reg(emu, read_addr);
} else if (n == REG_DATA) {
/* $data */
if (emu->bootstrap_mode) {
emu->bootstrap_finished = true;
return 0;
}
do {
uint32_t rem = emu->gpr_regs.val[REG_REM];
assert(rem >= 0);

View file

@ -460,20 +460,23 @@ emu_step(struct emu *emu)
void
emu_run_bootstrap(struct emu *emu)
{
EMU_CONTROL_REG(PACKET_TABLE_WRITE_ADDR);
EMU_CONTROL_REG(THREAD_SYNC);
emu->quiet = true;
emu->run_mode = true;
emu->bootstrap_mode = true;
emu->bootstrap_finished = false;
if (gpuver == 6 && emu->processor == EMU_PROC_LPAC) {
/* Emulate what the SQE bootstrap routine does after launching LPAC */
emu_set_reg32(emu, &THREAD_SYNC, 1u << 0);
}
while (emu_get_reg32(emu, &PACKET_TABLE_WRITE_ADDR) < 0x80) {
while (!emu->bootstrap_finished && !emu->waitin) {
emu_step(emu);
}
emu->bootstrap_mode = false;
}

View file

@ -203,6 +203,14 @@ struct emu {
/* (r)un mode, don't stop for input until next waitin: */
bool run_mode;
/* Don't prompt on a read from $data with an empty queue and instead assume
* the bootstrap routine has finished and return a dummy value while
* setting bootstrap_finished.
*/
bool bootstrap_mode;
bool bootstrap_finished;
/* carry-bits for add/sub for addhi/subhi
* TODO: this is probably in a SQE register somewhere
*/