From 865aade42b4f4db9362fe3e10abc9d1eb8f39403 Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 5 Feb 2021 06:51:47 +0200 Subject: [PATCH] Kernel: Clear pending interrupts before enabling IRQs of IDE Channel Calling detect_disks() can generate interrupts, so we must clear it to allow proper function when booting with kernel argument smp=on. --- Kernel/Storage/IDEChannel.cpp | 8 ++++++++ Kernel/Storage/IDEChannel.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/Kernel/Storage/IDEChannel.cpp b/Kernel/Storage/IDEChannel.cpp index e7dc66846c1..7d18c662e05 100644 --- a/Kernel/Storage/IDEChannel.cpp +++ b/Kernel/Storage/IDEChannel.cpp @@ -142,9 +142,17 @@ IDEChannel::IDEChannel(const IDEController& controller, IOAddressGroup io_group, initialize(force_pio); detect_disks(); + + // Note: calling to detect_disks could generate an interrupt, clear it if that's the case + clear_pending_interrupts(); enable_irq(); } +void IDEChannel::clear_pending_interrupts() const +{ + m_io_group.io_base().offset(ATA_REG_STATUS).in(); +} + IDEChannel::~IDEChannel() { } diff --git a/Kernel/Storage/IDEChannel.h b/Kernel/Storage/IDEChannel.h index edf60473f88..1380ca364ef 100644 --- a/Kernel/Storage/IDEChannel.h +++ b/Kernel/Storage/IDEChannel.h @@ -138,6 +138,8 @@ private: void start_request(AsyncBlockDeviceRequest&, bool, bool, u16); void complete_current_request(AsyncDeviceRequest::RequestResult); + void clear_pending_interrupts() const; + void ata_access(Direction, bool, u32, u8, u16, bool); void ata_read_sectors_with_dma(bool, u16); void ata_read_sectors(bool, u16);