Skip to content
Browse files

mailbox: change protection mechanisms

TX: replace spin by mutex to release CPU
during wait on mailbox resource.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information...
1 parent 96e9ef8 commit 4564a6ba486a5c329d4d6630fe6173a6dc3e2355 @ydrallap ydrallap committed with Jan 31, 2013
Showing with 4 additions and 2 deletions.
  1. +3 −2 drivers/mailbox/mailbox.c
  2. +1 −0 drivers/mailbox/mailbox_internal.h
View
5 drivers/mailbox/mailbox.c
@@ -95,7 +95,7 @@ int mailbox_msg_send(struct mailbox *mbox, struct mailbox_msg *msg)
struct mailbox_queue *mq = mbox->txq;
int ret = 0, len;
- spin_lock_bh(&mq->lock);
+ mutex_lock(&mq->mlock);
if (kfifo_avail(&mq->fifo) < (sizeof(msg) + msg->size)) {
ret = -ENOMEM;
@@ -118,7 +118,7 @@ int mailbox_msg_send(struct mailbox *mbox, struct mailbox_msg *msg)
tasklet_schedule(&mbox->txq->tasklet);
out:
- spin_unlock_bh(&mq->lock);
+ mutex_unlock(&mq->mlock);
return ret;
}
EXPORT_SYMBOL(mailbox_msg_send);
@@ -288,6 +288,7 @@ static struct mailbox_queue *mbox_queue_alloc(struct mailbox *mbox,
return NULL;
spin_lock_init(&mq->lock);
+ mutex_init(&mq->mlock);
if (kfifo_alloc(&mq->fifo, mbox_kfifo_size, GFP_KERNEL))
goto error;
View
1 drivers/mailbox/mailbox_internal.h
@@ -43,6 +43,7 @@ struct mailbox_ops {
struct mailbox_queue {
spinlock_t lock;
+ struct mutex mlock;
struct kfifo fifo;
struct work_struct work;
struct tasklet_struct tasklet;

0 comments on commit 4564a6b

Please sign in to comment.
Something went wrong with that request. Please try again.