From patchwork Tue Dec 18 13:10:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 1891931 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 4F01A3FC64 for ; Tue, 18 Dec 2012 13:17:47 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tkwzz-0001Cf-98; Tue, 18 Dec 2012 13:14:19 +0000 Received: from eu1sys200aog112.obsmtp.com ([207.126.144.133]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1TkwyX-0000EZ-8w for linux-arm-kernel@lists.infradead.org; Tue, 18 Dec 2012 13:12:51 +0000 Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKUNBrqY8KTRGksn7WFNvk2GUHRrVuSuVN@postini.com; Tue, 18 Dec 2012 13:12:48 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id B711941; Tue, 18 Dec 2012 13:10:25 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 9BED96B; Tue, 18 Dec 2012 07:56:22 +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 relay2.stm.gmessaging.net (Postfix) with ESMTPS id 5915BA8083; Tue, 18 Dec 2012 14:10:58 +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:11:02 +0100 From: Loic Pallardy To: Greg Kroah-Hartman Subject: [PATCH 8/9] mailbox: add no_irq send message Date: Tue, 18 Dec 2012 14:10:11 +0100 Message-ID: <1355836212-17956-9-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_192104_E75D34CD X-CRM114-Status: GOOD ( 15.80 ) 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 ---- ---------------------- -------------------------------------------------- 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [207.126.144.133 listed in list.dnswl.org] -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 For debug purpose, mailbox must be available when interrupts are disabled to collect dump information. Signed-off-by: Loic Pallardy --- 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 57cb566..2f50226 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 d256e1a..3f9ec1e 100644 --- a/include/linux/mailbox.h +++ b/include/linux/mailbox.h @@ -23,6 +23,9 @@ struct mailbox_msg { MAILBOX_FILL_MSG(_msg, _header, NULL, 0); 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);