ps2_drv: wait longer for ACK after RESET command

On some machines, more time passes until the acknowledgement arrives.

Fixes #3442
This commit is contained in:
Christian Prochaska 2019-07-09 16:38:11 +02:00 committed by Christian Helmuth
parent 193a401097
commit 04e8ba716c
1 changed files with 23 additions and 10 deletions

View File

@ -165,6 +165,19 @@ class Ps2::Mouse : public Input_driver
return id == 4;
}
bool _wait_for_data_ready()
{
/* poll TIMEOUT_MS for reset results each SLEEP_MS */
enum { TIMEOUT_MS = 700, SLEEP_MS = 10 };
unsigned timeout_ms = 0;
do {
_timer.msleep(SLEEP_MS);
timeout_ms += SLEEP_MS;
} while (!_aux.data_read_ready() && timeout_ms < TIMEOUT_MS);
return _aux.data_read_ready();
}
public:
Mouse(Serial_interface &aux, Input::Event_queue &ev_queue,
@ -180,18 +193,18 @@ class Ps2::Mouse : public Input_driver
void reset()
{
_aux.write(CMD_RESET);
if (_aux.read() != RET_ACK)
if (!_wait_for_data_ready()) {
Genode::warning("could not reset mouse (no response)");
return;
}
if (_aux.read() != RET_ACK) {
Genode::warning("could not reset mouse (missing ack)");
return;
}
/* poll TIMEOUT_MS for reset results each SLEEP_MS */
enum { TIMEOUT_MS = 700, SLEEP_MS = 10 };
unsigned timeout_ms = 0;
do {
_timer.msleep(SLEEP_MS);
timeout_ms += SLEEP_MS;
} while (!_aux.data_read_ready() && timeout_ms < TIMEOUT_MS);
if (!_aux.data_read_ready()) {
if (!_wait_for_data_ready()) {
Genode::warning("could not reset mouse (no response)");
return;
}