diff options
author | Andreas Kling <kling@serenityos.org> | 2022-01-12 01:47:42 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-12 02:08:58 +0100 |
commit | 05ed8d17385e6965fd66c42758d332bd7af741c0 (patch) | |
tree | 07fae19b77cfbf5dfa4d9faa21d50817646817e9 /Kernel/Storage | |
parent | 8177e7eb228f73a9834f9e08a8a70feb66307b2c (diff) | |
download | serenity-05ed8d17385e6965fd66c42758d332bd7af741c0.zip |
Kernel: Wait for the ATA busy bit to clear after switching channels
This is a speculative fix for a flaky boot crash that shows up every now
and then on CI.
Fixes #10177. Hopefully.
Diffstat (limited to 'Kernel/Storage')
-rw-r--r-- | Kernel/Storage/ATA/IDEChannel.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Kernel/Storage/ATA/IDEChannel.cpp b/Kernel/Storage/ATA/IDEChannel.cpp index 92d49316ab..c394951436 100644 --- a/Kernel/Storage/ATA/IDEChannel.cpp +++ b/Kernel/Storage/ATA/IDEChannel.cpp @@ -304,10 +304,11 @@ UNMAP_AFTER_INIT void IDEChannel::detect_disks() // There are only two possible disks connected to a channel for (auto i = 0; i < 2; i++) { - // We need to select the drive and then we wait 20 microseconds... and it doesn't hurt anything so let's just do it. - IO::delay(20); - m_io_group.io_base().offset(ATA_REG_HDDEVSEL).out<u8>(0xA0 | (i << 4)); // First, we need to select the drive itself - IO::delay(20); + + if (!select_device_and_wait_until_not_busy(i == 0 ? DeviceType::Master : DeviceType::Slave, 32000)) { + dbgln("IDEChannel: Timeout waiting for busy flag to clear during {} {} detection", channel_type_string(), channel_string(i)); + continue; + } auto status = m_io_group.control_base().in<u8>(); if (status == 0x0) { |