From 80323260aef21e3d25dffb1b70f3a83e18e802a1 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Sat, 4 Feb 2017 19:47:39 -0800 Subject: [PATCH] common: do not release lock after nvmem read when commits are suspended The nvmem_release_cache() function checks if there is a pending write and refuses to release the lock if so. It should also be checking if submits have need suspended, as the task suspending commits is holding the lock and is supposed to release it explicitly when done. BRANCH=none BUG=chrome-os-partner:62531 TEST=verified that the message reporting attempts to commit when cache is unlocked is not showing up at startup any more, Change-Id: I5a63e7421cdd4a6b11dddff3103e1d63e0be0e65 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/437758 Reviewed-by: Scott Collyer --- common/nvmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/nvmem.c b/common/nvmem.c index 561fa5e537..2f7d37923c 100644 --- a/common/nvmem.c +++ b/common/nvmem.c @@ -77,7 +77,7 @@ struct nvmem_mutex_ { struct mutex mtx; }; -static struct nvmem_mutex_ nvmem_mutex; +static struct nvmem_mutex_ nvmem_mutex = { .task = TASK_ID_COUNT }; static uint8_t nvmem_cache[NVMEM_PARTITION_SIZE] __aligned(4); static uint8_t commits_enabled; @@ -229,7 +229,7 @@ static void nvmem_lock_cache(void) static void nvmem_release_cache(void) { - if (nvmem_mutex.write_in_progress) + if (nvmem_mutex.write_in_progress || !commits_enabled) return; /* It will have to be saved first. */ /* Reset task number to max value */