summaryrefslogtreecommitdiff
path: root/common/charge_state_v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/charge_state_v2.c')
-rw-r--r--common/charge_state_v2.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 5eb37e83a0..7b20c52eef 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -112,6 +112,12 @@ static int update_static_battery_info(void)
*/
int rv;
+ /*
+ * We're updating multi-byte memmap vars, don't allow ACPI to do
+ * reads while we're updating.
+ */
+ host_lock_memmap();
+
/* Smart battery serial number is 16 bits */
batt_str = (char *)host_get_memmap(EC_MEMMAP_BATT_SERIAL);
memset(batt_str, 0, EC_MEMMAP_TEXT_MAX);
@@ -155,6 +161,9 @@ static int update_static_battery_info(void)
*(int *)host_get_memmap(EC_MEMMAP_BATT_LFCC) = 0;
*host_get_memmap(EC_MEMMAP_BATT_FLAG) = 0;
+ /* No more multi-byte memmap writes. */
+ host_unlock_memmap();
+
if (rv)
problem(PR_STATIC_UPDATE, 0);
else
@@ -199,6 +208,12 @@ static void update_dynamic_battery_info(void)
batt_present = 0;
}
+ /*
+ * We're updating multi-byte memmap vars, don't allow ACPI to do
+ * reads while we're updating.
+ */
+ host_lock_memmap();
+
if (!(curr.batt.flags & BATT_FLAG_BAD_VOLTAGE))
*memmap_volt = curr.batt.voltage;
@@ -225,6 +240,9 @@ static void update_dynamic_battery_info(void)
send_batt_info_event++;
}
+ /* No more multi-byte memmap writes. */
+ host_unlock_memmap();
+
if (curr.batt.is_present == BP_YES &&
!(curr.batt.flags & BATT_FLAG_BAD_STATE_OF_CHARGE) &&
curr.batt.state_of_charge <= BATTERY_LEVEL_CRITICAL)