From edef9062e19f04dd123a06a4efad031d79bb3f91 Mon Sep 17 00:00:00 2001 From: Loic Pallardy Date: Thu, 31 Jan 2013 17:55:28 +0100 Subject: [PATCH] mailbox: change protection mechanisms TX: replace spin by mutex to release CPU during wait on mailbox resource. Signed-off-by: Loic Pallardy Signed-off-by: Linus Walleij Signed-off-by: Suman Anna --- drivers/mailbox/mailbox.c | 5 +++-- drivers/mailbox/mailbox_internal.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 6b43e7c66167..ff6595ad1921 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -94,7 +94,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); @@ -289,6 +289,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; diff --git a/drivers/mailbox/mailbox_internal.h b/drivers/mailbox/mailbox_internal.h index da5e263409b5..7ac8bb8205bd 100644 --- a/drivers/mailbox/mailbox_internal.h +++ b/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; -- 2.39.5