From c844c3a97366e913752e6099b91de6670f752415 Mon Sep 17 00:00:00 2001 From: Dipesh Gandhi Date: Tue, 6 Mar 2018 13:47:55 +0530 Subject: [PATCH] nvadsp: false trigger for adsp boot Change add spinlock protection for message enqueue to avoid possible race condition between enqueue and dequeue of ADSP OS message. Bug 2031075 Change-Id: Iad243fdf034db89a61e32411a8b03c817c19d81e Signed-off-by: Dipesh Gandhi Reviewed-on: https://git-master.nvidia.com/r/1613124 (cherry picked from commit 3d146a3ba4dbe4c1375d64d425ff0b9be7f7c272) Reviewed-on: https://git-master.nvidia.com/r/1669402 Reviewed-by: Bharat Nihalani Tested-by: Bharat Nihalani Reviewed-by: svc-mobile-coverity Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Tested-by: Ajay Nandakumar M Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/platform/tegra/nvadsp/mailbox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/platform/tegra/nvadsp/mailbox.c b/drivers/platform/tegra/nvadsp/mailbox.c index 06e2159c..753265a7 100644 --- a/drivers/platform/tegra/nvadsp/mailbox.c +++ b/drivers/platform/tegra/nvadsp/mailbox.c @@ -56,19 +56,21 @@ static void mboxq_destroy(struct nvadsp_mbox_queue *queue) static status_t mboxq_enqueue(struct nvadsp_mbox_queue *queue, uint32_t data) { + unsigned long flags; int ret = 0; if (is_mboxq_full(queue)) { ret = -EINVAL; goto out; } - + spin_lock_irqsave(&queue->lock, flags); if (is_mboxq_empty(queue)) complete_all(&queue->comp); queue->array[queue->tail] = data; queue->tail = (queue->tail + 1) & NVADSP_MBOX_QUEUE_SIZE_MASK; queue->count++; + spin_unlock_irqrestore(&queue->lock, flags); out: return ret; }