diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2019-04-25 12:13:20 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-02 05:38:28 -0700 |
commit | 6e97f4aab723afd67946c4fab2ecd59c1579deaf (patch) | |
tree | d4cdc69b57cab75ba44e6578b7013dec38ed7874 /include/nvmem_vars.h | |
parent | 4ffa4bb861612f9debffc9088bac72a1ac611ff5 (diff) | |
download | chrome-ec-6e97f4aab723afd67946c4fab2ecd59c1579deaf.tar.gz |
nvmem: protect flash accesses with a mutex
Multiple tasks could be trying to modify NVMEM concurrently. To avoid
data corruption add a mutex which guarantees that only one thread of
execution has access to the flash storing NVMEM objects.
Various paths accessing flash contents are now protected by the same
mutex. Mutex control functions are put in wrappers, which makes it
easier to add debugging code when needed.
BRANCH=cr50, cr50-mp
BUG=b:69907320, b:130828517
TEST=attempts to take a device through RMA open do not fail any more.
Change-Id: I6424477dced20d00f6165006cd3b3968433be6d0
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1584586
Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'include/nvmem_vars.h')
-rw-r--r-- | include/nvmem_vars.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/nvmem_vars.h b/include/nvmem_vars.h index eec1e757a2..08bd9164c8 100644 --- a/include/nvmem_vars.h +++ b/include/nvmem_vars.h @@ -70,6 +70,8 @@ int initvars(void); * The val_len field in the passed in tuple indicates how much room is * available, the actual value size could be smaller. * + * Could block as it acquires the flash protection mutex before proceeding. + * * Return: * * EC_SUCCESS - if the key was found and there was enough room in the passed @@ -98,6 +100,8 @@ const uint8_t *tuple_val(const struct tuple *); /* * Save the tuple in the RAM buffer. If val is NULL or val_len is 0, the * tuple is deleted (if it existed). Returns EC_SUCCESS or error code. + * + * Could block as it acquires the flash protection mutex before proceeding. */ int setvar(const uint8_t *key, uint8_t key_len, const uint8_t *val, uint8_t val_len); |