From b816e857b2d3b602473bf28703ad2cff722535e5 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 10 May 2025 09:45:32 +0200 Subject: dev(kernel): feat: AHCI driver improvements against 'disk hangs', and HeFS has been improved with better traversal, and inode/ind allocation. Signed-off-by: Amlal --- dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'dev/kernel/HALKit') diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index ad4f9eeb..80053ea8 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -144,12 +144,6 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz lba /= sector_sz; - if (lba > kSATASectorCount) { - kout << "Out of range LBA.\r"; - err_global_get() = kErrorDisk; - return; - } - if (!buffer || size_buffer == 0) { kout << "Invalid buffer for AHCI I/O.\r"; err_global_get() = kErrorDisk; @@ -160,12 +154,12 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz UInt16 timeout = 0; - constexpr static UInt16 kTimeout = 0x7000; + constexpr static UInt16 kTimeout = 0x8000; while (slot == ~0UL) { - kout << "No free command slot found, AHCI disk is busy!\r"; - if (timeout > kTimeout) { + kout << "No free command slot found, AHCI disk is busy!\r"; + err_global_get() = kErrorDisk; return; } @@ -265,7 +259,18 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz // Issue command kSATAHba->Ports[kSATAIndex].Ci = (1 << slot); + timeout = 0UL; + while (YES) { + if (timeout > kTimeout) { + kout << "Disk hangup!\r"; + + err_global_get() = kErrorDisk; + return; + } + + ++timeout; + if (!(kSATAHba->Ports[kSATAIndex].Ci & (1 << slot))) break; } -- cgit v1.2.3