linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Jassi Brar <jassisinghbrar@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>,
	Mikko Perttunen <mperttunen@nvidia.com>,
	Jon Hunter <jonathanh@nvidia.com>, Timo Alho <talho@nvidia.com>,
	Pekka Pessi <ppessi@nvidia.com>,
	Mika Liljeberg <mliljeberg@nvidia.com>,
	linux-tegra@vger.kernel.org, linux-serial@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/9] mailbox: Support blocking transfers in atomic context
Date: Fri, 26 Oct 2018 13:16:30 +0200	[thread overview]
Message-ID: <20181026111638.10759-2-thierry.reding@gmail.com> (raw)
In-Reply-To: <20181026111638.10759-1-thierry.reding@gmail.com>

From: Thierry Reding <treding@nvidia.com>

The mailbox framework supports blocking transfers via completions for
clients that can sleep. In order to support blocking transfers in cases
where the transmission is not permitted to sleep, add a new ->flush()
callback that controller drivers can implement to busy loop until the
transmission has been completed. This will automatically be called when
available and interrupts are disabled for clients that request blocking
transfers.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/mailbox.c          | 8 ++++++++
 include/linux/mailbox_controller.h | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 674b35f402f5..0eaf21259874 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -267,6 +267,14 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
 		unsigned long wait;
 		int ret;
 
+		if (irqs_disabled() && chan->mbox->ops->flush) {
+			ret = chan->mbox->ops->flush(chan, chan->cl->tx_tout);
+			if (ret < 0)
+				tx_tick(chan, ret);
+
+			return ret;
+		}
+
 		if (!chan->cl->tx_tout) /* wait forever */
 			wait = msecs_to_jiffies(3600000);
 		else
diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h
index 74deadb42d76..2a07d93f781a 100644
--- a/include/linux/mailbox_controller.h
+++ b/include/linux/mailbox_controller.h
@@ -24,6 +24,9 @@ struct mbox_chan;
  *		transmission of data is reported by the controller via
  *		mbox_chan_txdone (if it has some TX ACK irq). It must not
  *		sleep.
+ * @flush:	Called when a client requests transmissions to be blocking but
+ *		the context doesn't allow sleeping. Typically the controller
+ *		will implement a busy loop waiting for the data to flush out.
  * @startup:	Called when a client requests the chan. The controller
  *		could ask clients for additional parameters of communication
  *		to be provided via client's chan_data. This call may
@@ -46,6 +49,7 @@ struct mbox_chan;
  */
 struct mbox_chan_ops {
 	int (*send_data)(struct mbox_chan *chan, void *data);
+	int (*flush)(struct mbox_chan *chan, unsigned long timeout);
 	int (*startup)(struct mbox_chan *chan);
 	void (*shutdown)(struct mbox_chan *chan);
 	bool (*last_tx_done)(struct mbox_chan *chan);
-- 
2.19.1


  reply	other threads:[~2018-10-26 11:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 11:16 [PATCH 0/9] serial: Add Tegra Combined UART driver Thierry Reding
2018-10-26 11:16 ` Thierry Reding [this message]
2018-10-26 11:16 ` [PATCH 2/9] mailbox: Allow multiple controllers per device Thierry Reding
2018-10-26 11:16 ` [PATCH 3/9] dt-bindings: tegra186-hsp: Add shared interrupts Thierry Reding
2018-10-26 11:16 ` [PATCH 4/9] mailbox: tegra-hsp: Add support for shared mailboxes Thierry Reding
2018-10-29 10:04   ` Pekka Pessi
2018-10-29 10:39     ` Thierry Reding
2018-10-29 12:25       ` Pekka Pessi
2018-10-29 13:16         ` Thierry Reding
2018-10-30 16:15           ` Pekka Pessi
2018-10-26 11:16 ` [PATCH 5/9] mailbox: tegra-hsp: Add suspend/resume support Thierry Reding
2018-10-26 11:16 ` [PATCH 6/9] dt-bindings: serial: Add bindings for nvidia,tegra194-tcu Thierry Reding
2018-10-26 11:16 ` [PATCH 7/9] serial: Add Tegra Combined UART driver Thierry Reding
2018-11-09 17:05   ` Greg Kroah-Hartman
2018-11-12 15:30     ` Thierry Reding
2018-11-12 18:03       ` Greg Kroah-Hartman
2018-10-26 11:16 ` [PATCH 8/9] arm64: tegra: Add nodes for TCU on Tegra194 Thierry Reding
2018-10-26 11:16 ` [PATCH 9/9] arm64: tegra: Mark TCU as primary serial port on Tegra194 P2888 Thierry Reding
2018-10-29  9:04 ` [PATCH 0/9] serial: Add Tegra Combined UART driver Pekka Pessi
2018-10-29 10:11   ` Thierry Reding

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=20181026111638.10759-2-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=jslaby@suse.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mliljeberg@nvidia.com \
    --cc=mperttunen@nvidia.com \
    --cc=ppessi@nvidia.com \
    --cc=talho@nvidia.com \
    /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;
as well as URLs for NNTP newsgroup(s).