]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mailbox: add no_irq send message
authorLoic Pallardy <loic.pallardy@st.com>
Thu, 31 Jan 2013 16:55:31 +0000 (17:55 +0100)
committerSuman Anna <s-anna@ti.com>
Thu, 14 Mar 2013 18:08:58 +0000 (13:08 -0500)
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>
Signed-off-by: Suman Anna <s-anna@ti.com>
drivers/mailbox/mailbox.c
include/linux/mailbox.h

index 35813f5f2d6ababaa92154525328042379b4d325..eaaf87ec9009c4b25741843d0e573446170ad572 100644 (file)
@@ -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) {
index f8730b4b4f1d7739484cb5d0327584d3c629e213..a41b67d784315900a4e35688c1a3415c5454a5d1 100644 (file)
@@ -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);