diff options
author | Simon Glass <sjg@chromium.org> | 2021-02-04 16:36:27 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-05 16:44:19 +0000 |
commit | 9b49eb469e64712804d3141bc730318f56509e71 (patch) | |
tree | f4ced7f4f6a78dca6dc5ae4ba29c32c3b166e33e | |
parent | 06fa2ba85860edf3e811fb002584a38690d79831 (diff) | |
download | chrome-ec-9b49eb469e64712804d3141bc730318f56509e71.tar.gz |
entry_log: Convert to use new-style interrupt disable
Update this file to use the irq_lock/unlock() method.
BUG=b:175434113
BRANCH=none
TEST=make -j30 BOARD=volteer
Signed-off-by: Simon Glass <sjg@chromium.org>
Change-Id: I25960d9f9848425e5894d515908ec705b815e96f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2674957
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | common/event_log.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/common/event_log.c b/common/event_log.c index 994967664c..95e44413bc 100644 --- a/common/event_log.c +++ b/common/event_log.c @@ -51,22 +51,23 @@ void log_add_event(uint8_t type, uint8_t size, uint16_t data, size_t payload_size = EVENT_LOG_SIZE(size); size_t total_size = ENTRY_SIZE(payload_size); size_t current_tail, first; + uint32_t lock_key; /* --- critical section : reserve queue space --- */ - interrupt_disable(); + lock_key = irq_lock(); current_tail = log_tail_next; log_tail_next = current_tail + total_size; - interrupt_enable(); + irq_unlock(lock_key); /* --- end of critical section --- */ /* Out of space : discard the oldest entry */ while ((UNIT_COUNT - (current_tail - log_head)) < total_size) { struct event_log_entry *oldest; /* --- critical section : atomically free-up space --- */ - interrupt_disable(); + lock_key = irq_lock(); oldest = log_events + (log_head & UNIT_COUNT_MASK); log_head += ENTRY_SIZE(EVENT_LOG_SIZE(oldest->size)); - interrupt_enable(); + irq_unlock(lock_key); /* --- end of critical section --- */ } @@ -95,6 +96,7 @@ int log_dequeue_event(struct event_log_entry *r) unsigned int total_size, first; struct event_log_entry *entry; size_t current_head; + uint32_t lock_key; retry: current_head = log_head; @@ -113,13 +115,13 @@ retry: memcpy(r + first, log_events, (total_size-first) * UNIT_SIZE); /* --- critical section : remove the entry from the queue --- */ - interrupt_disable(); + lock_key = irq_lock(); if (log_head != current_head) { /* our entry was thrown away */ - interrupt_enable(); + irq_unlock(lock_key); goto retry; } log_head += total_size; - interrupt_enable(); + irq_unlock(lock_key); /* --- end of critical section --- */ /* fixup the timestamp : number of milliseconds in the past */ |