From a6fc3cf7a64134657a532c85c4ce7ff181f1e62d Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 26 Nov 2024 01:39:11 +0200 Subject: [PATCH] Kernel: Clear AHCI pending interrupts I have no idea why I did not have this in. All devices were just constatly spamming interrupts like crazy :D --- kernel/kernel/Storage/ATA/AHCI/Controller.cpp | 6 +++--- kernel/kernel/Storage/ATA/AHCI/Device.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/kernel/Storage/ATA/AHCI/Controller.cpp b/kernel/kernel/Storage/ATA/AHCI/Controller.cpp index c5f575c0..3cbb822d 100644 --- a/kernel/kernel/Storage/ATA/AHCI/Controller.cpp +++ b/kernel/kernel/Storage/ATA/AHCI/Controller.cpp @@ -77,7 +77,9 @@ namespace Kernel { auto& abar_mem = *(volatile HBAGeneralMemorySpace*)m_abar->vaddr(); - uint32_t is = abar_mem.is; + const uint32_t is = abar_mem.is; + abar_mem.is = is; + for (uint8_t i = 0; i < 32; i++) { if (is & (1 << i)) @@ -88,8 +90,6 @@ namespace Kernel dwarnln("ignoring interrupt to device {}", i); } } - - abar_mem.is = is; } BAN::Optional AHCIController::check_port_type(volatile HBAPortMemorySpace& port) diff --git a/kernel/kernel/Storage/ATA/AHCI/Device.cpp b/kernel/kernel/Storage/ATA/AHCI/Device.cpp index 92b70844..d65fd5ab 100644 --- a/kernel/kernel/Storage/ATA/AHCI/Device.cpp +++ b/kernel/kernel/Storage/ATA/AHCI/Device.cpp @@ -149,8 +149,12 @@ namespace Kernel void AHCIDevice::handle_irq() { - uint16_t err = m_port->serr & 0xFFFF; - if (err) + const uint32_t is = m_port->is; + m_port->is = is; + + const uint32_t serr = m_port->serr; + m_port->serr = serr; + if (auto err = serr & 0xFFFF) print_error(err); }