[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1355836212-17956-6-git-send-email-loic.pallardy-ext@stericsson.com>
Date: Tue, 18 Dec 2012 14:10:08 +0100
From: Loic Pallardy <loic.pallardy-ext@...ricsson.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Russell King <linux@....linux.org.uk>,
Tony Lindgren <tony@...mide.com>,
Janusz Krzysztofik <jkrzyszt@....icnet.pl>,
Omar Ramirez Luna <omar.ramirez@...itl.com>,
Loic PALLARDY <loic.pallardy@...com>,
Arnd Bergmann <arnd@...db.de>,
Ohad Ben-Cohen <ohad@...ery.com>,
Mark Brown <broonie@...nsource.wolfsonmicro.com>,
Dom Cobley <popcornmix@...il.com>,
Wim Van Sebroeck <wim@...ana.be>,
Linus Walleij <linus.walleij@...aro.org>,
Suman Anna <s-anna@...com>, Juan Gutierrez <jgutierrez@...com>,
Felipe Contreras <felipe.contreras@...ia.com>,
Tejun Heo <tj@...nel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <linux-omap@...r.kernel.org>,
STEricsson_nomadik_linux <STEricsson_nomadik_linux@...t.st.com>,
Loic Pallardy <loic.pallardy-ext@...ricsson.com>
Subject: [PATCH 5/9] mailbox: change protection mechanisms
TX: replace spin by mutex
RX: replace spin_lock_irq by spin_lock_irqsave
Signed-off-by: Loic Pallardy <loic.pallardy@...com>
---
drivers/mailbox/mailbox.c | 10 ++++++----
drivers/mailbox/mailbox.h | 1 +
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 727e67e..8b7d7bd 100644
--- a/drivers/mailbox/mailbox.c
+++ b/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);
@@ -198,6 +198,7 @@ static void mbox_rx_work(struct work_struct *work)
int len;
struct mailbox *mbox = mq->mbox;
struct mailbox_msg msg;
+ unsigned long flags;
while (kfifo_len(&mq->fifo) >= sizeof(msg)) {
len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
@@ -210,12 +211,12 @@ static void mbox_rx_work(struct work_struct *work)
}
blocking_notifier_call_chain(&mbox->notifier, len, (void *)&msg);
- spin_lock_irq(&mq->lock);
+ spin_lock_irqsave(&mq->lock, flags);
if (mq->full) {
mq->full = false;
mailbox_enable_irq(mbox, IRQ_RX);
}
- spin_unlock_irq(&mq->lock);
+ spin_unlock_irqrestore(&mq->lock, flags);
}
}
@@ -288,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.h b/drivers/mailbox/mailbox.h
index 23ac551..0a31c99 100644
--- a/drivers/mailbox/mailbox.h
+++ b/drivers/mailbox/mailbox.h
@@ -37,6 +37,7 @@ struct mailbox_ops {
struct mailbox_queue {
spinlock_t lock;
+ struct mutex mlock;
struct kfifo fifo;
struct work_struct work;
struct tasklet_struct tasklet;
--
1.7.11.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists