diff --git a/repos/os/src/drivers/ahci/ahci.h b/repos/os/src/drivers/ahci/ahci.h index af6ff32f04a..a586d7ba671 100644 --- a/repos/os/src/drivers/ahci/ahci.h +++ b/repos/os/src/drivers/ahci/ahci.h @@ -954,6 +954,9 @@ struct Ahci::Port : private Port_base typedef Port_mmio::Ci Ci; typedef Port_mmio::Register_set::Polling_timeout Polling_timeout; + typedef Port_mmio::Register_set::Attempts Attempts; + typedef Port_mmio::Register_set::Microseconds Microseconds; + void ack_irq(Port_mmio &mmio) { @@ -992,7 +995,11 @@ struct Ahci::Port : private Port_base return; try { - mmio.wait_for(delayer, Tfd::Sts_bsy::Equal(0)); + /* wait up to 5s */ + mmio.wait_for(Port::Attempts(5000), + Port::Microseconds(1000), + delayer, + Tfd::Sts_bsy::Equal(0)); } catch (Polling_timeout) { error("HBA busy unable to start command processing."); return; diff --git a/repos/os/src/drivers/ahci/main.cc b/repos/os/src/drivers/ahci/main.cc index ede3581e5aa..08909c3d77a 100644 --- a/repos/os/src/drivers/ahci/main.cc +++ b/repos/os/src/drivers/ahci/main.cc @@ -141,8 +141,6 @@ class Ahci::Driver : Noncopyable device_release_if_stopped_and_idle(); - log("driver halted"); - return; } @@ -153,9 +151,13 @@ class Ahci::Driver : Noncopyable /* re-start request handling of client sessions */ for_each_port([&](auto &port, auto const index, auto) { - port.stop_processing = false; - port.reinit(); - _dispatch.session(index); + try { + port.reinit(); + port.stop_processing = false; + _dispatch.session(index); + } catch (...) { + error("port ", index, " failed to be resumed"); + } }); log("driver resumed"); @@ -221,6 +223,8 @@ class Ahci::Driver : Noncopyable if (pending) return; + log("driver halted"); + _resources.release_device(); }