From patchwork Tue Feb 12 04:57:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 2127241 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 17F643FD4F for ; Tue, 12 Feb 2013 05:06:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932967Ab3BLFD2 (ORCPT ); Tue, 12 Feb 2013 00:03:28 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:34506 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932936Ab3BLFD0 (ORCPT ); Tue, 12 Feb 2013 00:03:26 -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 r1C52Mkb027861; Mon, 11 Feb 2013 23:02:22 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r1C52M4E012921; Mon, 11 Feb 2013 23:02:22 -0600 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.1.323.3; Mon, 11 Feb 2013 23:02:21 -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 r1C52LmS009634; 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 09/13] mailbox: add no_irq send message Date: Mon, 11 Feb 2013 22:57:08 -0600 Message-ID: <1360645032-9668-10-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 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);