xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Oleksandr Tyshchenko <olekstysh@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien.grall@linaro.org>
Subject: [RFC PATCH 23/31] xen/arm: Add Xen changes to mailbox infrastructure
Date: Thu,  9 Nov 2017 19:10:13 +0200	[thread overview]
Message-ID: <1510247421-24094-24-git-send-email-olekstysh@gmail.com> (raw)
In-Reply-To: <1510247421-24094-1-git-send-email-olekstysh@gmail.com>

From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Modify the direct ported mailbox infrastructure to be
functional inside Xen.

Include "wrappers.h" which contains all required things the direct
ported code relies on.

Important note: the usage of dummy "wait-for-completion" based on
busy loop restricts us from using timer based polling.
So, prevent mailbox controllers (which need polling timer involved)
from being registered.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@linaro.org>
---
 xen/arch/arm/cpufreq/mailbox.c            | 51 +++++++++++++++++++++++++++++--
 xen/arch/arm/cpufreq/mailbox.h            | 14 +++++++++
 xen/arch/arm/cpufreq/mailbox_client.h     | 18 +++++++++++
 xen/arch/arm/cpufreq/mailbox_controller.h | 22 +++++++++++++
 4 files changed, 102 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/cpufreq/mailbox.c b/xen/arch/arm/cpufreq/mailbox.c
index 537f4f6..7a34e36 100644
--- a/xen/arch/arm/cpufreq/mailbox.c
+++ b/xen/arch/arm/cpufreq/mailbox.c
@@ -7,8 +7,16 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
+ *
+ * Based on Linux drivers/mailbox/mailbox.c
+ * => commit b7133d6fcd9a9eb4633357d4a27430d4e0c794ad
+ *
+ * Xen modification:
+ * Oleksandr Tyshchenko <Oleksandr_Tyshchenko@epam.com>
+ * Copyright (C) 2017 EPAM Systems Inc.
  */
 
+#if 0
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
@@ -20,8 +28,16 @@
 #include <linux/bitops.h>
 #include <linux/mailbox_client.h>
 #include <linux/mailbox_controller.h>
+#endif
+
+#include <xen/device_tree.h>
+#include <xen/err.h>
+#include <xen/xmalloc.h>
 
 #include "mailbox.h"
+#include "mailbox_client.h"
+#include "mailbox_controller.h"
+#include "wrappers.h"
 
 static LIST_HEAD(mbox_cons);
 static DEFINE_MUTEX(con_mutex);
@@ -85,9 +101,11 @@ static void msg_submit(struct mbox_chan *chan)
 exit:
 	spin_unlock_irqrestore(&chan->lock, flags);
 
+#if 0 /* We don't support timer based polling. */
 	if (!err && (chan->txdone_method & TXDONE_BY_POLL))
 		/* kick start the timer immediately to avoid delays */
 		hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL);
+#endif
 }
 
 static void tx_tick(struct mbox_chan *chan, int r)
@@ -114,6 +132,7 @@ static void tx_tick(struct mbox_chan *chan, int r)
 		complete(&chan->tx_complete);
 }
 
+#if 0 /* We don't support timer based polling. */
 static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer)
 {
 	struct mbox_controller *mbox =
@@ -139,6 +158,7 @@ static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer)
 	}
 	return HRTIMER_NORESTART;
 }
+#endif
 
 /**
  * mbox_chan_received_data - A way for controller driver to push data
@@ -374,7 +394,7 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl,
 					      const char *name)
 {
 	struct device_node *np = cl->dev->of_node;
-	struct property *prop;
+	const struct property *prop;
 	const char *mbox_name;
 	int index = 0;
 
@@ -452,13 +472,26 @@ int mbox_controller_register(struct mbox_controller *mbox)
 	if (!mbox || !mbox->dev || !mbox->ops || !mbox->num_chans)
 		return -EINVAL;
 
+	/*
+	 * Unfortunately, here we have to prevent some controllers (which need
+	 * polling timer involved) from being registered. The possible controller
+	 * must have both TX-Done and RX-Done irqs or to be completely synchronous.
+	 */
+	if (!mbox->rxdone_auto) {
+		dev_err(mbox->dev, "rx polling method is not supported\n");
+		return -EINVAL;
+	}
+
 	if (mbox->txdone_irq)
 		txdone = TXDONE_BY_IRQ;
-	else if (mbox->txdone_poll)
-		txdone = TXDONE_BY_POLL;
+	else if (mbox->txdone_poll) {
+		dev_err(mbox->dev, "tx polling method is not supported\n");
+		return -EINVAL;
+	}
 	else /* It has to be ACK then */
 		txdone = TXDONE_BY_ACK;
 
+#if 0 /* We don't support timer based polling. */
 	if (txdone == TXDONE_BY_POLL) {
 
 		if (!mbox->ops->last_tx_done) {
@@ -470,6 +503,7 @@ int mbox_controller_register(struct mbox_controller *mbox)
 			     HRTIMER_MODE_REL);
 		mbox->poll_hrt.function = txdone_hrtimer;
 	}
+#endif
 
 	for (i = 0; i < mbox->num_chans; i++) {
 		struct mbox_chan *chan = &mbox->chans[i];
@@ -509,9 +543,20 @@ void mbox_controller_unregister(struct mbox_controller *mbox)
 	for (i = 0; i < mbox->num_chans; i++)
 		mbox_free_channel(&mbox->chans[i]);
 
+#if 0 /* We don't support timer based polling. */
 	if (mbox->txdone_poll)
 		hrtimer_cancel(&mbox->poll_hrt);
+#endif
 
 	mutex_unlock(&con_mutex);
 }
 EXPORT_SYMBOL_GPL(mbox_controller_unregister);
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
diff --git a/xen/arch/arm/cpufreq/mailbox.h b/xen/arch/arm/cpufreq/mailbox.h
index 456ba68..ed8fd42 100644
--- a/xen/arch/arm/cpufreq/mailbox.h
+++ b/xen/arch/arm/cpufreq/mailbox.h
@@ -2,6 +2,11 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
+ *
+ * Based on Linux drivers/mailbox/mailbox.h
+ * => commit 86c22f8c9a3b71d42d38bfcd80372de72f573713
+ *
+ * No Xen modification.
  */
 
 #ifndef __MAILBOX_H
@@ -12,3 +17,12 @@
 #define TXDONE_BY_ACK	BIT(2) /* S/W ACK recevied by Client ticks the TX */
 
 #endif /* __MAILBOX_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
diff --git a/xen/arch/arm/cpufreq/mailbox_client.h b/xen/arch/arm/cpufreq/mailbox_client.h
index 4434871..d6ded8b 100644
--- a/xen/arch/arm/cpufreq/mailbox_client.h
+++ b/xen/arch/arm/cpufreq/mailbox_client.h
@@ -5,13 +5,22 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
+ *
+ * Based on Linux include/linux/mailbox_client.h
+ * => commit dfabde206aa10ae71a89ba75e68b1f58a6336a05
+ *
+ * No Xen modification.
  */
 
 #ifndef __MAILBOX_CLIENT_H
 #define __MAILBOX_CLIENT_H
 
+#if 0
 #include <linux/of.h>
 #include <linux/device.h>
+#endif
+
+#include <asm/device.h>
 
 struct mbox_chan;
 
@@ -49,3 +58,12 @@ bool mbox_client_peek_data(struct mbox_chan *chan); /* atomic */
 void mbox_free_channel(struct mbox_chan *chan); /* may sleep */
 
 #endif /* __MAILBOX_CLIENT_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
diff --git a/xen/arch/arm/cpufreq/mailbox_controller.h b/xen/arch/arm/cpufreq/mailbox_controller.h
index 05c6e45..93ab62d 100644
--- a/xen/arch/arm/cpufreq/mailbox_controller.h
+++ b/xen/arch/arm/cpufreq/mailbox_controller.h
@@ -2,16 +2,27 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
+ *
+ * Based on Linux include/linux/mailbox_controller.h
+ * => commit 0cc67945ea5933d53db69606312cf52f553d1b81
+ *
+ * Xen modification:
+ * Oleksandr Tyshchenko <Oleksandr_Tyshchenko@epam.com>
+ * Copyright (C) 2017 EPAM Systems Inc.
  */
 
 #ifndef __MAILBOX_CONTROLLER_H
 #define __MAILBOX_CONTROLLER_H
 
+#if 0
 #include <linux/of.h>
 #include <linux/types.h>
 #include <linux/hrtimer.h>
 #include <linux/device.h>
 #include <linux/completion.h>
+#endif
+
+#include "wrappers.h"
 
 struct mbox_chan;
 
@@ -87,7 +98,9 @@ struct mbox_controller {
 	struct mbox_chan *(*of_xlate)(struct mbox_controller *mbox,
 				      const struct of_phandle_args *sp);
 	/* Internal to API */
+#if 0 /* We don't support timer based polling. */
 	struct hrtimer poll_hrt;
+#endif
 	struct list_head node;
 };
 
@@ -137,3 +150,12 @@ void mbox_chan_received_data(struct mbox_chan *chan, void *data); /* atomic */
 void mbox_chan_txdone(struct mbox_chan *chan, int r); /* atomic */
 
 #endif /* __MAILBOX_CONTROLLER_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-11-09 17:10 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09 17:09 [RFC PATCH 00/31] CPUFreq on ARM Oleksandr Tyshchenko
2017-11-09 17:09 ` [RFC PATCH 01/31] cpufreq: move cpufreq.h file to the xen/include/xen location Oleksandr Tyshchenko
2017-12-02  0:35   ` Stefano Stabellini
2017-11-09 17:09 ` [RFC PATCH 02/31] pm: move processor_perf.h " Oleksandr Tyshchenko
2017-12-02  0:41   ` Stefano Stabellini
2017-11-09 17:09 ` [RFC PATCH 03/31] pmstat: move pmstat.c file to the xen/drivers/pm/stat.c location Oleksandr Tyshchenko
2017-12-02  0:47   ` Stefano Stabellini
2018-05-07 15:36   ` Jan Beulich
2018-05-18 11:14     ` Oleksandr Tyshchenko
2018-05-18 11:35       ` Jan Beulich
2018-05-18 14:13         ` Oleksandr Tyshchenko
2018-05-18 14:21           ` Jan Beulich
2017-11-09 17:09 ` [RFC PATCH 04/31] cpufreq: make turbo settings to be configurable Oleksandr Tyshchenko
2017-12-02  1:06   ` Stefano Stabellini
2017-12-02 17:25     ` Oleksandr Tyshchenko
2017-12-04 11:58       ` Andre Przywara
2017-12-05 15:23         ` Oleksandr Tyshchenko
2017-12-04 22:18       ` Stefano Stabellini
2017-12-05 11:13         ` Oleksandr Tyshchenko
2017-12-05 19:24           ` Stefano Stabellini
2017-12-06 11:28             ` Oleksandr Tyshchenko
2018-05-07 15:39   ` Jan Beulich
2018-05-18 14:36     ` Oleksandr Tyshchenko
2018-05-18 14:41       ` Jan Beulich
2017-11-09 17:09 ` [RFC PATCH 05/31] pmstat: make pmstat functions more generalizable Oleksandr Tyshchenko
2017-12-02  1:21   ` Stefano Stabellini
2017-12-04 16:21     ` Oleksandr Tyshchenko
2017-12-04 22:30       ` Stefano Stabellini
2017-11-09 17:09 ` [RFC PATCH 06/31] cpufreq: make cpufreq driver " Oleksandr Tyshchenko
2017-12-02  1:37   ` Stefano Stabellini
2017-12-04 19:34     ` Oleksandr Tyshchenko
2017-12-04 22:46       ` Stefano Stabellini
2017-12-05 19:29         ` Oleksandr Tyshchenko
2017-12-05 20:48           ` Stefano Stabellini
2017-12-06  7:54             ` Jan Beulich
2017-12-06 23:44               ` Stefano Stabellini
2017-12-07  8:45                 ` Jan Beulich
2017-12-07 20:31                   ` Oleksandr Tyshchenko
2017-12-08  8:07                     ` Jan Beulich
2017-12-08 12:16                       ` Oleksandr Tyshchenko
2017-11-09 17:09 ` [RFC PATCH 07/31] xenpm: Clarify xenpm usage Oleksandr Tyshchenko
2017-11-09 17:13   ` Wei Liu
2017-12-02  1:28     ` Stefano Stabellini
2017-11-09 17:09 ` [RFC PATCH 08/31] xen/device-tree: Add dt_count_phandle_with_args helper Oleksandr Tyshchenko
2017-11-09 17:09 ` [RFC PATCH 09/31] xen/device-tree: Add dt_property_for_each_string macros Oleksandr Tyshchenko
2017-12-04 23:24   ` Stefano Stabellini
2017-12-05 14:19     ` Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 10/31] xen/device-tree: Add dt_property_read_u32_index helper Oleksandr Tyshchenko
2017-12-04 23:29   ` Stefano Stabellini
2017-11-09 17:10 ` [RFC PATCH 11/31] xen/device-tree: Add dt_property_count_elems_of_size helper Oleksandr Tyshchenko
2017-12-04 23:29   ` Stefano Stabellini
2017-11-09 17:10 ` [RFC PATCH 12/31] xen/device-tree: Add dt_property_read_string_helper and friends Oleksandr Tyshchenko
2017-12-04 23:29   ` Stefano Stabellini
2017-11-09 17:10 ` [RFC PATCH 13/31] xen/arm: Add driver_data field to struct device Oleksandr Tyshchenko
2017-12-04 23:31   ` Stefano Stabellini
2017-12-05 11:26   ` Julien Grall
2017-12-05 12:57     ` Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 14/31] xen/arm: Add DEVICE_MAILBOX device class Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 15/31] xen/arm: Store device-tree node per cpu Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 16/31] arm: add SMC wrapper that is compatible with SMCCC Oleksandr Tyshchenko
2017-12-05  2:30   ` Stefano Stabellini
2017-12-05 15:33     ` Volodymyr Babchuk
2017-12-05 17:21       ` Stefano Stabellini
2017-12-05 14:58   ` Julien Grall
2017-12-05 17:08     ` Volodymyr Babchuk
2017-12-05 17:08       ` Julien Grall
2017-12-05 17:20       ` Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 17/31] xen/arm: Add ARM System Control and Power Interface (SCPI) protocol Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 18/31] xen/arm: Add mailbox infrastructure Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 19/31] xen/arm: Introduce ARM SMC based mailbox Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 20/31] xen/arm: Add common header file wrappers.h Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 21/31] xen/arm: Add rxdone_auto flag to mbox_controller structure Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 22/31] xen/arm: Add Xen changes to SCPI protocol Oleksandr Tyshchenko
2017-12-05 21:20   ` Stefano Stabellini
2017-12-05 21:41     ` Julien Grall
2017-12-06 10:08       ` Oleksandr Tyshchenko
2017-11-09 17:10 ` Oleksandr Tyshchenko [this message]
2017-11-09 17:10 ` [RFC PATCH 24/31] xen/arm: Add Xen changes to ARM SMC based mailbox Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 25/31] xen/arm: Use non-blocking mode for SCPI protocol Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 26/31] xen/arm: Don't set txdone_poll flag for ARM SMC mailbox Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 27/31] cpufreq: hack: perf->states isn't a real guest handle on ARM Oleksandr Tyshchenko
2017-12-05 21:34   ` Stefano Stabellini
2017-11-09 17:10 ` [RFC PATCH 28/31] xen/arm: Introduce SCPI based CPUFreq driver Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 29/31] xen/arm: Introduce CPUFreq Interface component Oleksandr Tyshchenko
2017-12-05 22:25   ` Stefano Stabellini
2017-12-06 10:54     ` Oleksandr Tyshchenko
2017-12-07  1:40       ` Stefano Stabellini
2017-11-09 17:10 ` [RFC PATCH 30/31] xen/arm: Build CPUFreq components Oleksandr Tyshchenko
2017-11-09 17:10 ` [RFC PATCH 31/31] xen/arm: Enable CPUFreq on ARM Oleksandr Tyshchenko
2017-11-09 17:18 ` [RFC PATCH 00/31] " Andrii Anisov
2017-11-13 19:40   ` Oleksandr Tyshchenko
2017-11-13 15:21 ` Andre Przywara
2017-11-13 19:40   ` Oleksandr Tyshchenko
2017-11-14 10:49     ` Andre Przywara
2017-11-14 20:46       ` Oleksandr Tyshchenko
2017-11-15  3:03         ` Jassi Brar
2017-11-15 13:28           ` Andre Przywara
2017-11-15 15:18             ` Jassi Brar
2017-11-15 14:28         ` Andre Przywara
2017-11-16 14:57           ` Oleksandr Tyshchenko
2017-11-16 17:04             ` Andre Przywara
2017-11-17 14:01               ` Julien Grall
2017-11-17 18:36                 ` Oleksandr Tyshchenko
2017-11-17 14:55               ` Oleksandr Tyshchenko
2017-11-17 16:41                 ` Andre Przywara
2017-11-17 17:22                   ` Oleksandr Tyshchenko
2017-12-05 22:26 ` Stefano Stabellini
2017-12-06 10:10   ` Oleksandr Tyshchenko

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=1510247421-24094-24-git-send-email-olekstysh@gmail.com \
    --to=olekstysh@gmail.com \
    --cc=julien.grall@linaro.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /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).