aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristofer Jonsson <kristofer.jonsson@arm.com>2022-06-28 14:09:19 +0200
committerKristofer Jonsson <kristofer.jonsson@arm.com>2022-06-29 12:09:52 +0200
commite2a581556c65d4bf6fbffa45286ff797e2fe8ca3 (patch)
treeedcca9d7387bd8382937fd0e413463d70cd15aa5
parente3e264343bac8f2bbcacdf84c13383766b0e6aff (diff)
downloadethos-u-linux-driver-stack-e2a581556c65d4bf6fbffa45286ff797e2fe8ca3.tar.gz
Bug fix for queue capacity calculation
Reduce queue capacity by one byte, else it will not be possible to distinguish between an empty and full queue. Change-Id: Ia243a7175833826dc816d536cc79ac5a252f3e3a
-rw-r--r--kernel/ethosu_mailbox.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/ethosu_mailbox.c b/kernel/ethosu_mailbox.c
index 014ceb8..b5cde0d 100644
--- a/kernel/ethosu_mailbox.c
+++ b/kernel/ethosu_mailbox.c
@@ -105,7 +105,8 @@ static size_t ethosu_queue_available(struct ethosu_core_queue *queue)
static size_t ethosu_queue_capacity(struct ethosu_core_queue *queue)
{
- return queue->header.size - ethosu_queue_available(queue);
+ return max_t(ssize_t,
+ queue->header.size - ethosu_queue_available(queue) - 1, 0);
}
static int ethosu_queue_write(struct ethosu_mailbox *mbox,