From patchwork Tue Feb 12 04:57:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 2127261 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 95C39DFB7B for ; Tue, 12 Feb 2013 05:06:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932993Ab3BLFGn (ORCPT ); Tue, 12 Feb 2013 00:06:43 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:34500 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751254Ab3BLFDR (ORCPT ); Tue, 12 Feb 2013 00:03:17 -0500 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r1C52MS0027860; Mon, 11 Feb 2013 23:02:22 -0600 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r1C52L5f012916; Mon, 11 Feb 2013 23:02:21 -0600 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Mon, 11 Feb 2013 23:02:22 -0600 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 r1C52Lci009625; Mon, 11 Feb 2013 23:02:21 -0600 From: Suman Anna To: Greg Kroah-Hartman CC: Linus Walleij , Russell King , Tony Lindgren , Arnd Bergmann , Ohad Ben-Cohen , Paul Walmsley , Benoit Cousson , Loic Pallardy , Omar Ramirez Luna , , , , Mark Brown , Janusz Krzysztofik , Dom Cobley , Wim Van Sebroeck , Felipe Contreras , Tejun Heo , Omar Ramirez Luna Subject: [PATCH v2 06/13] mailbox: change protection mechanisms Date: Mon, 11 Feb 2013 22:57:05 -0600 Message-ID: <1360645032-9668-7-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1360645032-9668-1-git-send-email-s-anna@ti.com> References: <1360645032-9668-1-git-send-email-s-anna@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.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 ba03910..04f83bf 100644 --- a/drivers/mailbox/mailbox_internal.h +++ b/drivers/mailbox/mailbox_internal.h @@ -45,6 +45,7 @@ struct mailbox_ops { struct mailbox_queue { spinlock_t lock; + struct mutex mlock; struct kfifo fifo; struct work_struct work; struct tasklet_struct tasklet;