From patchwork Wed Mar 13 03:24:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 2261111 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 488403FD8C for ; Wed, 13 Mar 2013 03:33:20 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UFcOV-0004hT-Vs; Wed, 13 Mar 2013 03:30:23 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UFcNQ-0004NB-4y for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2013 03:29:17 +0000 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r2D3T9W1013465; Tue, 12 Mar 2013 22:29:09 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2D3T93E006962; Tue, 12 Mar 2013 22:29:09 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Tue, 12 Mar 2013 22:29:08 -0500 Received: from localhost (irmo.am.dhcp.ti.com [128.247.74.241]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2D3T9M5011078; Tue, 12 Mar 2013 22:29:09 -0500 From: Suman Anna To: Greg Kroah-Hartman Subject: [PATCHv3 07/14] mailbox: change protection mechanisms Date: Tue, 12 Mar 2013 22:24:20 -0500 Message-ID: <1363145060-14578-1-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 1.8.1.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130312_232916_321834_CF810074 X-CRM114-Status: UNSURE ( 9.28 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -9.5 (---------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-9.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.152 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -2.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Ohad Ben-Cohen , Suman Anna , Russell King , Loic Pallardy , Arnd Bergmann , Tony Lindgren , Linus Walleij , linux-kernel@vger.kernel.org, Omar Ramirez Luna , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Loic Pallardy TX: replace spin by mutex to release CPU during wait on mailbox resource. Signed-off-by: Loic Pallardy Signed-off-by: Linus Walleij --- 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 6b43e7c..ff6595a 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 da5e263..7ac8bb8 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;