From patchwork Wed Mar 13 03:24:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 2261171 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 9355F3FD8C for ; Wed, 13 Mar 2013 03:35:43 +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 1UFcQe-0005wV-2u; Wed, 13 Mar 2013 03:32:36 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UFcNY-0004QW-RV for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2013 03:29:31 +0000 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r2D3TEO3012542; Tue, 12 Mar 2013 22:29:14 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2D3TEi2007037; Tue, 12 Mar 2013 22:29:14 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Tue, 12 Mar 2013 22:29:14 -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 r2D3TE0h011152; Tue, 12 Mar 2013 22:29:14 -0500 From: Suman Anna To: Greg Kroah-Hartman Subject: [PATCHv3 10/14] mailbox: add no_irq send message Date: Tue, 12 Mar 2013 22:24:26 -0500 Message-ID: <1363145066-14681-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_232925_038777_986B1242 X-CRM114-Status: GOOD ( 11.31 ) 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 [192.94.94.40 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 For debug purpose, mailbox must be available when interrupts are disabled to collect dump information. Signed-off-by: Loic Pallardy Signed-off-by: Linus Walleij --- drivers/mailbox/mailbox.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mailbox.h | 3 +++ 2 files changed, 69 insertions(+) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 35813f5..eaaf87e 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -110,6 +110,72 @@ out: } EXPORT_SYMBOL(mailbox_msg_send); +#define TRANSFER_TIMEOUT 30000 /* Becomes ~3s timeout */ + +static struct mailbox_msg no_irq_msg_res; + +struct mailbox_msg *mailbox_msg_send_receive_no_irq(struct mailbox *mbox, + struct mailbox_msg *msg) +{ + int ret = 0; + int count = 0; + + BUG_ON(!irqs_disabled()); + + if (likely(mbox->ops->write && mbox->ops->read)) { + if (__mbox_poll_for_space(mbox)) { + ret = -EBUSY; + goto out; + } + mbox->ops->write(mbox, msg); + while (!is_mbox_irq(mbox, IRQ_RX)) { + udelay(100); + cpu_relax(); + count++; + if (count > TRANSFER_TIMEOUT) { + pr_err("%s: Error: transfer timed out\n", + __func__); + ret = -EINVAL; + goto out; + } + } + mbox->ops->read(mbox, &no_irq_msg_res); + ack_mbox_irq(mbox, IRQ_RX); + } else { + ret = -EINVAL; + } + +out: + BUG_ON(ret < 0); + + return &no_irq_msg_res; +} +EXPORT_SYMBOL(mailbox_msg_send_receive_no_irq); + +int mailbox_msg_send_no_irq(struct mailbox *mbox, + struct mailbox_msg *msg) +{ + int ret = 0; + + BUG_ON(!irqs_disabled()); + + if (likely(mbox->ops->write)) { + if (__mbox_poll_for_space(mbox)) { + ret = -EBUSY; + goto out; + } + mbox->ops->write(mbox, msg); + } else { + ret = -EINVAL; + } + +out: + WARN_ON(ret < 0); + + return ret; +} +EXPORT_SYMBOL(mailbox_msg_send_no_irq); + void mailbox_save_ctx(struct mailbox *mbox) { if (!mbox->ops->save_ctx) { diff --git a/include/linux/mailbox.h b/include/linux/mailbox.h index f8730b4..a41b67d 100644 --- a/include/linux/mailbox.h +++ b/include/linux/mailbox.h @@ -28,6 +28,9 @@ struct mailbox_msg { } int mailbox_msg_send(struct mailbox *, struct mailbox_msg *msg); +struct mailbox_msg *mailbox_msg_send_receive_no_irq(struct mailbox *, + struct mailbox_msg *msg); +int mailbox_msg_send_no_irq(struct mailbox *, struct mailbox_msg *msg); struct mailbox *mailbox_get(const char *, struct notifier_block *nb); void mailbox_put(struct mailbox *mbox, struct notifier_block *nb);