Kernel: Increase attempts count when waiting before doing i8042 IO

Apparently on VirtualBox the keyboard device refused to complete the
reset sequence. With longer delays and more attempts before giving up,
it seems like the problem is gone.
This commit is contained in:
Liav A 2022-02-11 18:59:26 +02:00 committed by Andreas Kling
parent 0881a7be8d
commit 32053e8f25
Notes: sideshowbarker 2024-07-17 18:59:15 +09:00

View file

@ -268,17 +268,17 @@ ErrorOr<void> I8042Controller::prepare_for_input(HIDDevice::Type device)
{
VERIFY(m_lock.is_locked());
u8 const second_port_flag = device == HIDDevice::Type::Keyboard ? 0 : I8042StatusFlag::SecondPS2PortOutputBuffer;
for (int attempt = 0; attempt < 5; attempt++) {
for (int attempt = 0; attempt < 50; attempt++) {
u8 status = IO::in8(I8042Port::Status);
if (!(status & I8042StatusFlag::OutputBuffer)) {
IO::delay(100);
IO::delay(1000);
continue;
}
if (device == HIDDevice::Type::Unknown)
return {};
if ((status & I8042StatusFlag::SecondPS2PortOutputBuffer) == second_port_flag)
return {};
IO::delay(100);
IO::delay(1000);
}
return Error::from_errno(EBUSY);
}
@ -286,11 +286,11 @@ ErrorOr<void> I8042Controller::prepare_for_input(HIDDevice::Type device)
ErrorOr<void> I8042Controller::prepare_for_output()
{
VERIFY(m_lock.is_locked());
for (int attempt = 0; attempt < 5; attempt++) {
for (int attempt = 0; attempt < 50; attempt++) {
u8 status = IO::in8(I8042Port::Status);
if (!(status & I8042StatusFlag::InputBuffer))
return {};
IO::delay(100);
IO::delay(1000);
}
return Error::from_errno(EBUSY);
}