acpica: adjust acpi device reports

If ACPI IRQs are received but no changes to the watched state for a specified
count can be observed, than generate nonetheless a Genode report.

Issue #2816
This commit is contained in:
Alexander Boettcher 2018-05-18 15:52:18 +02:00 committed by Christian Helmuth
parent aa8b725457
commit 487e8ea934
2 changed files with 35 additions and 10 deletions

View File

@ -109,7 +109,10 @@ struct Acpica::Main
Genode::Signal_handler<Acpica::Main> sci_irq;
Genode::Constructible<Genode::Irq_connection> sci_conn;
Acpica::Reportstate * report = nullptr;
Acpica::Reportstate * report { nullptr };
unsigned unchanged_state_count { 0 };
unsigned unchanged_state_max;
static struct Irq_handler {
UINT32 irq;
@ -122,7 +125,8 @@ struct Acpica::Main
Main(Genode::Env &env)
:
env(env),
sci_irq(env.ep(), *this, &Main::acpi_irq)
sci_irq(env.ep(), *this, &Main::acpi_irq),
unchanged_state_max(config.xml().attribute_value("update_unchanged", 20U))
{
bool const enable_reset = config.xml().attribute_value("reset", false);
bool const enable_poweroff = config.xml().attribute_value("poweroff", false);
@ -177,8 +181,24 @@ struct Acpica::Main
AcpiOsWaitEventsComplete();
if (report)
report->generate_report();
if (report) {
bool const changed = report->generate_report();
if (unchanged_state_max) {
if (changed)
unchanged_state_count = 0;
else
unchanged_state_count ++;
if (unchanged_state_count >= unchanged_state_max) {
Genode::log("generate report because of ",
unchanged_state_count, " irqs without state "
"changes");
report->generate_report(true);
unchanged_state_count = 0;
}
}
}
if (res == ACPI_INTERRUPT_HANDLED)
return;

View File

@ -71,9 +71,12 @@ class Acpica::Reportstate {
void lid_event() { _changed_lid = true; }
void ac_event() { _changed_ac = true; battery_event(); }
void generate_report()
bool generate_report(bool force = false)
{
if (_changed_lid) {
bool const changed = _changed_sb || _changed_ec ||
_changed_fixed || _changed_lid || _changed_ac;
if (_changed_lid || force) {
_changed_lid = false;
if (_lid)
Genode::Reporter::Xml_generator xml(_reporter_lid, [&] () {
@ -81,7 +84,7 @@ class Acpica::Reportstate {
});
}
if (_changed_ac) {
if (_changed_ac || force) {
_changed_ac = false;
Genode::Reporter::Xml_generator xml(_reporter_ac, [&] () {
for (Callback<Ac> * ac = _list_ac.first(); ac; ac = ac->next())
@ -89,7 +92,7 @@ class Acpica::Reportstate {
});
}
if (_changed_ec) {
if (_changed_ec || force) {
_changed_ec = false;
Genode::Reporter::Xml_generator xml(_reporter_ec, [&] () {
for (Callback<Ec> * ec = _list_ec.first(); ec; ec = ec->next())
@ -97,7 +100,7 @@ class Acpica::Reportstate {
});
}
if (_changed_sb) {
if (_changed_sb || force) {
_changed_sb = false;
Genode::Reporter::Xml_generator xml(_reporter_sb, [&] () {
for (Callback<Battery> * sb = _list_sb.first(); sb; sb = sb->next())
@ -105,12 +108,14 @@ class Acpica::Reportstate {
});
}
if (_changed_fixed) {
if (_changed_fixed || force) {
_changed_fixed = false;
if (_fixed)
Genode::Reporter::Xml_generator xml(_reporter_fix, [&] () {
_fixed->generate(xml);
});
}
return changed;
}
};