From patchwork Sat Feb 13 01:42:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guzman Lugo, Fernando" X-Patchwork-Id: 79056 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1D1gkjj020491 for ; Sat, 13 Feb 2010 01:42:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756447Ab0BMBmZ (ORCPT ); Fri, 12 Feb 2010 20:42:25 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:49007 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756234Ab0BMBmV convert rfc822-to-8bit (ORCPT ); Fri, 12 Feb 2010 20:42:21 -0500 Received: from dlep34.itg.ti.com ([157.170.170.115]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o1D1gHQ4003441 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 12 Feb 2010 19:42:18 -0600 Received: from dlep26.itg.ti.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id o1D1gHBT002723; Fri, 12 Feb 2010 19:42:17 -0600 (CST) Received: from dsbe71.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id o1D1gHe4004560; Fri, 12 Feb 2010 19:42:17 -0600 (CST) Received: from dlee06.ent.ti.com ([157.170.170.11]) by dsbe71.ent.ti.com ([156.117.232.23]) with mapi; Fri, 12 Feb 2010 19:42:17 -0600 From: "Guzman Lugo, Fernando" To: linux-omap CC: Hiroshi Doyu Date: Fri, 12 Feb 2010 19:42:16 -0600 Subject: [PATCH 5/6] Mailbox: sleeping function called from invalid context fix Thread-Topic: [PATCH 5/6] Mailbox: sleeping function called from invalid context fix Thread-Index: AcqsTcWy+uocZckzSxOtYYVeOjV3Mg== Message-ID: <496565EC904933469F292DDA3F1663E602AA7C18DB@dlee06.ent.ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 13 Feb 2010 01:42:47 +0000 (UTC) diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c index 8136ee3..d8bfa45 100644 --- a/arch/arm/plat-omap/mailbox.c +++ b/arch/arm/plat-omap/mailbox.c @@ -29,7 +29,7 @@ #include static struct omap_mbox *mboxes; -static DEFINE_RWLOCK(mboxes_lock); +static DECLARE_RWSEM(mboxes_sem); static int mbox_configured; @@ -248,16 +248,16 @@ static int omap_mbox_startup(struct omap_mbox *mbox) struct omap_mbox_queue *mq; if (likely(mbox->ops->startup)) { - write_lock(&mboxes_lock); + down_write(&mboxes_sem); if (!mbox_configured) ret = mbox->ops->startup(mbox); if (unlikely(ret)) { - write_unlock(&mboxes_lock); + up_write(&mboxes_sem); return ret; } mbox_configured++; - write_unlock(&mboxes_lock); + up_write(&mboxes_sem); } ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED, @@ -304,12 +304,12 @@ static void omap_mbox_fini(struct omap_mbox *mbox) mbox_queue_free(mbox->rxq); if (unlikely(mbox->ops->shutdown)) { - write_lock(&mboxes_lock); + down_write(&mboxes_sem); if (mbox_configured > 0) mbox_configured--; if (!mbox_configured) mbox->ops->shutdown(mbox); - write_unlock(&mboxes_lock); + up_write(&mboxes_sem); } } @@ -330,14 +330,14 @@ struct omap_mbox *omap_mbox_get(const char *name) struct omap_mbox *mbox; int ret; - read_lock(&mboxes_lock); + down_read(&mboxes_sem); mbox = *(find_mboxes(name)); if (mbox == NULL) { - read_unlock(&mboxes_lock); + up_read(&mboxes_sem); return ERR_PTR(-ENOENT); } - read_unlock(&mboxes_lock); + up_read(&mboxes_sem); ret = omap_mbox_startup(mbox); if (ret) @@ -363,15 +363,15 @@ int omap_mbox_register(struct device *parent, struct omap_mbox *mbox) if (mbox->next) return -EBUSY; - write_lock(&mboxes_lock); + down_write(&mboxes_sem); tmp = find_mboxes(mbox->name); if (*tmp) { ret = -EBUSY; - write_unlock(&mboxes_lock); + up_write(&mboxes_sem); goto err_find; } *tmp = mbox; - write_unlock(&mboxes_lock); + up_write(&mboxes_sem); return 0; @@ -384,18 +384,18 @@ int omap_mbox_unregister(struct omap_mbox *mbox) { struct omap_mbox **tmp; - write_lock(&mboxes_lock); + down_write(&mboxes_sem); tmp = &mboxes; while (*tmp) { if (mbox == *tmp) { *tmp = mbox->next; mbox->next = NULL; - write_unlock(&mboxes_lock); + up_write(&mboxes_sem); return 0; } tmp = &(*tmp)->next; } - write_unlock(&mboxes_lock); + up_write(&mboxes_sem); return -EINVAL; }