From a9527fd686dcdd0b04c4eac6690531d945e7f221 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Mon, 27 Jul 2015 14:36:53 -0700 Subject: acpi: Ensure continuity of memmap data with a read cache For multi-byte ACPI memmap reads, we previously had a mutex to ensure data continuity. A better approach is to use a read cache. Since the kernel will enable burst mode before reading a multi-byte memmap variable and disable it afterward, we can populate the cache on the first read after enabling burst. This solution removes deadlock bugs, is contained entirely in acpi.c, and saves a deferred function. BUG=chromium:514283 TEST=Manual on Glados. Add prints in acpi_read, verify that multi-byte reads come from cache and non-burst reads continue to function as before. BRANCH=Cyan Signed-off-by: Shawn Nematbakhsh Change-Id: I74e4927bf2b433e31a9ff65d72820fa087c51722 Reviewed-on: https://chromium-review.googlesource.com/288871 Reviewed-by: Bill Richardson Reviewed-by: Vincent Palatin --- common/charge_state_v2.c | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'common/charge_state_v2.c') diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index d588ae3362..0ca0974739 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -124,12 +124,6 @@ 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); @@ -173,9 +167,6 @@ 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, rv); else @@ -220,12 +211,6 @@ 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; @@ -252,9 +237,6 @@ 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) -- cgit v1.2.1