Clement Deschamps

qbox: fixed reset deadlock

... ... @@ -121,6 +121,7 @@ struct QBOXBase
void (*before_cpu_start)(QBOXBase *);
struct ResetRequest *reset_request;
QemuMutex lock_reset;
QemuSemaphore sem_eoe;
};
... ... @@ -433,16 +434,18 @@ static void qbox_reset_b_transport(void *model, Payload *payload)
return;
}
qemu_mutex_lock(&qbox->lock_reset);
bool value = !!payload_get_value(p);
if (value == qbox->reset_request[cpu_idx].value) {
qemu_mutex_unlock(&qbox->lock_reset);
trace_qbox_reset_b_transport_skip(cpu_idx, value);
return;
}
trace_qbox_reset_b_transport(cpu_idx, value);
qbox->reset_request[cpu_idx].valid = true;
qbox->reset_request[cpu_idx].value = value;
qemu_mutex_unlock(&qbox->lock_reset);
trace_qbox_reset_b_transport(cpu_idx, value);
payload_set_response_status(p, OK_RESPONSE);
}
... ... @@ -583,6 +586,7 @@ static void qbox_end_of_elaboration(Model *model)
qbox->reset_request[i].valid = false;
qbox->reset_request[i].value = 0;
}
qemu_mutex_init(&qbox->lock_reset);
qemu_sem_init(&qbox->sem_eoe, 0);
... ... @@ -682,6 +686,7 @@ static void handle_cpu_reset(void)
{
int i;
qemu_mutex_lock(&handle.lock_reset);
for (i = 0; i < smp_cpus; i++) {
struct ResetRequest *request = &handle.reset_request[i];
... ... @@ -708,6 +713,7 @@ static void handle_cpu_reset(void)
request->valid = false;
}
}
qemu_mutex_unlock(&handle.lock_reset);
}
/*
... ...