From 5674a77bd69514418247c9aff41ea7a254f9e403 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 29 Jun 2020 17:15:29 -0600 Subject: [PATCH] PATA: Ignore interrupts that weren't generated by the disk --- Kernel/Devices/PATAChannel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Kernel/Devices/PATAChannel.cpp b/Kernel/Devices/PATAChannel.cpp index d75a9292ee..877412741c 100644 --- a/Kernel/Devices/PATAChannel.cpp +++ b/Kernel/Devices/PATAChannel.cpp @@ -183,12 +183,19 @@ void PATAChannel::wait_for_irq() void PATAChannel::handle_irq(const RegisterState&) { - // FIXME: We might get random interrupts due to malfunctioning hardware, so we should check that we actually requested something to happen. - u8 status = m_io_base.offset(ATA_REG_STATUS).in(); m_entropy_source.add_random_event(status); + u8 bstatus = m_bus_master_base.offset(2).in(); + if (!(bstatus & 0x4)) { + // interrupt not from this device, ignore +#ifdef PATA_DEBUG + klog() << "PATAChannel: ignore interrupt"; +#endif + return; + } + if (status & ATA_SR_ERR) { print_ide_status(status); m_device_error = m_io_base.offset(ATA_REG_ERROR).in();