From patchwork Tue Dec 18 13:10:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 1891941 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 7E5373FC64 for ; Tue, 18 Dec 2012 13:18:11 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tkx0L-0001SC-Na; Tue, 18 Dec 2012 13:14:42 +0000 Received: from eu1sys200aog118.obsmtp.com ([207.126.144.145]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1TkwyY-0000Ev-3S for linux-arm-kernel@lists.infradead.org; Tue, 18 Dec 2012 13:12:52 +0000 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKUNBrrQPLxnfsVEznNEpaJMj5drBRg8M5@postini.com; Tue, 18 Dec 2012 13:12:49 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E2B4119C; Tue, 18 Dec 2012 13:11:00 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0341E46B0; Tue, 18 Dec 2012 13:10:58 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 19AF924C37C; Tue, 18 Dec 2012 14:10:53 +0100 (CET) Received: from lmenx30v.lme.st.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 18 Dec 2012 14:10:58 +0100 From: Loic Pallardy To: Greg Kroah-Hartman Subject: [PATCH 5/9] mailbox: change protection mechanisms Date: Tue, 18 Dec 2012 14:10:08 +0100 Message-ID: <1355836212-17956-6-git-send-email-loic.pallardy-ext@stericsson.com> X-Mailer: git-send-email 1.7.11.1 In-Reply-To: <1355836212-17956-1-git-send-email-loic.pallardy-ext@stericsson.com> References: <1355836212-17956-1-git-send-email-loic.pallardy-ext@stericsson.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121218_081250_876035_70DA93F0 X-CRM114-Status: GOOD ( 16.34 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [207.126.144.145 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Ohad Ben-Cohen , Loic Pallardy , linux-omap@vger.kernel.org, Russell King , Loic PALLARDY , Arnd Bergmann , Janusz Krzysztofik , Tony Lindgren , Linus Walleij , Mark Brown , Juan Gutierrez , linux-kernel@vger.kernel.org, Felipe Contreras , Dom Cobley , Wim Van Sebroeck , Omar Ramirez Luna , Tejun Heo , Suman Anna , STEricsson_nomadik_linux , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org TX: replace spin by mutex RX: replace spin_lock_irq by spin_lock_irqsave Signed-off-by: Loic Pallardy --- 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;