os: avoid state names in system ROM

for ahci/gpu/nvme. Instead conclude from empty and non empty system state
to resume or stop driver.

Issue #5180
This commit is contained in:
Alexander Boettcher 2024-04-17 11:52:16 +02:00 committed by Christian Helmuth
parent 7c7c4e80e1
commit d52af2ac94
3 changed files with 32 additions and 8 deletions

View File

@ -129,7 +129,10 @@ class Ahci::Driver : Noncopyable
auto state = _system_rom->xml().attribute_value("state",
String<32>(""));
if (state == "driver_stop") {
bool const resume_driver = _schedule_stop && state == "";
bool const stop_driver = !_schedule_stop && state != "";
if (stop_driver) {
_schedule_stop = true;
for_each_port([&](auto &port, auto, auto) {
@ -138,14 +141,16 @@ class Ahci::Driver : Noncopyable
device_release_if_stopped_and_idle();
log("driver halted");
return;
}
if (state == "driver_reinit") {
_resources.acquire_device();
if (resume_driver) {
_schedule_stop = false;
_resources.acquire_device();
/* re-start request handling of client sessions */
for_each_port([&](auto &port, auto const index, auto) {
port.stop_processing = false;
@ -153,6 +158,8 @@ class Ahci::Driver : Noncopyable
_dispatch.session(index);
});
log("driver resumed");
return;
}
}

View File

@ -1204,13 +1204,19 @@ struct Igd::Device
void handle_system_update(String<32> const & state)
{
if (state == "driver_stop") {
bool const resume_driver = _schedule_stop && state == "";
bool const stop_driver = !_schedule_stop && state != "";
if (stop_driver) {
_schedule_stop = true;
device_release_if_stopped_and_idle();
log("driver halted");
return;
}
if (state == "driver_reinit") {
if (resume_driver) {
_resources.acquire_device();
_resources.with_mmio([&](auto &mmio) {
@ -1231,6 +1237,9 @@ struct Igd::Device
} else
warning("setup_ring_vram failed");
});
log("driver resumed");
}, []() {
error("reinit - failed");
});

View File

@ -1952,18 +1952,26 @@ class Nvme::Driver : Genode::Noncopyable
auto state = _system_rom->xml().attribute_value("state",
String<32>(""));
if (state == "driver_stop") {
bool const resume_driver = _stop_processing && state == "";
bool const stop_driver = !_stop_processing && state != "";
if (stop_driver) {
_stop_processing = true;
device_release_if_stopped_and_idle();
log("driver halted");
return;
}
if (state == "driver_reinit") {
if (resume_driver) {
_stop_processing = false;
_nvme_ctrlr.construct(_env, _platform, _delayer, _irq_sigh);
reinit(*_nvme_ctrlr);
log("driver resumed");
/* restart block session handling */
Signal_transmitter(_restart_sigh).submit();