Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: Suman Anna <s-anna@ti.com>
To: Greg Kroah-Hartman <greg@linuxfoundation.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Russell King <linux@arm.linux.org.uk>,
	Tony Lindgren <tony@atomide.com>, Arnd Bergmann <arnd@arndb.de>,
	Ohad Ben-Cohen <ohad@wizery.com>, Paul Walmsley <paul@pwsan.com>,
	Benoit Cousson <b-cousson@ti.com>,
	Loic Pallardy <loic.pallardy@st.com>,
	Omar Ramirez Luna <omar.ramirez@copitl.com>,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>,
	Dom Cobley <popcornmix@gmail.com>,
	Wim Van Sebroeck <wim@iguana.be>,
	Felipe Contreras <felipe.contreras@nokia.com>,
	Tejun Heo <tj@kernel.org>,
	Omar Ramirez Luna <omar.luna@linaro.org>
Subject: [PATCH v2 09/13] mailbox: add no_irq send message
Date: Mon, 11 Feb 2013 22:57:08 -0600	[thread overview]
Message-ID: <1360645032-9668-10-git-send-email-s-anna@ti.com> (raw)
In-Reply-To: <1360645032-9668-1-git-send-email-s-anna@ti.com>

From: Loic Pallardy <loic.pallardy@st.com>

For debug purpose, mailbox must be available when
interrupts are disabled to collect dump information.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 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);
-- 
1.8.1.2

  parent reply	other threads:[~2013-02-12  4:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-12  4:56 [PATCH v2 00/13] drivers: mailbox: framework creation Suman Anna
2013-02-12  4:57 ` [PATCH v2 01/13] ARM: OMAP2+: mbox: remove dependencies with soc.h Suman Anna
2013-02-12  4:57 ` [PATCH v2 02/13] mailbox: OMAP: introduce mailbox framework Suman Anna
2013-02-12  4:57 ` [PATCH v2 03/13] mailbox: split internal header from API header Suman Anna
2013-02-12  4:57 ` [PATCH v2 04/13] mailbox: rename omap_mbox in mailbox Suman Anna
2013-02-12  4:57 ` [PATCH v2 05/13] mailbox: create opened message type Suman Anna
2013-02-12  4:57 ` [PATCH v2 06/13] mailbox: change protection mechanisms Suman Anna
2013-02-12  4:57 ` [PATCH v2 07/13] mailbox: add shared memory mailbox type Suman Anna
2013-02-12  4:57 ` [PATCH v2 08/13] mailbox: add IRQF_NO_SUSPEND flag Suman Anna
2013-02-12  4:57 ` Suman Anna [this message]
2013-02-12  4:57 ` [PATCH v2 10/13] mailbox: create dbx500 mailbox driver Suman Anna
2013-02-12 10:39   ` Mark Rutland
2013-02-12 20:01     ` Loic PALLARDY
2013-02-13  9:08       ` Mark Rutland
2013-02-12  4:57 ` [PATCH v2 11/13] mailbox/omap: check iomem resource before dereferencing it Suman Anna
2013-02-12  4:57 ` [PATCH v2 12/13] mailbox: check for NULL nb in mailbox_put Suman Anna
2013-02-12  4:57 ` [PATCH v2 13/13] mailbox: call request_irq after mbox queues are allocated Suman Anna
2013-02-13 13:36 ` [PATCH v2 00/13] drivers: mailbox: framework creation Linus Walleij
2013-02-13 13:42   ` Russell King - ARM Linux
2013-02-13 16:41     ` Anna, Suman
2013-02-13 20:36       ` Loic PALLARDY

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360645032-9668-10-git-send-email-s-anna@ti.com \
    --to=s-anna@ti.com \
    --cc=arnd@arndb.de \
    --cc=b-cousson@ti.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=felipe.contreras@nokia.com \
    --cc=greg@linuxfoundation.org \
    --cc=jkrzyszt@tis.icnet.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=loic.pallardy@st.com \
    --cc=ohad@wizery.com \
    --cc=omar.luna@linaro.org \
    --cc=omar.ramirez@copitl.com \
    --cc=paul@pwsan.com \
    --cc=popcornmix@gmail.com \
    --cc=tj@kernel.org \
    --cc=tony@atomide.com \
    --cc=wim@iguana.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox