[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH 23/31] xen/arm: Add Xen changes to mailbox infrastructure
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx> 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@xxxxxxxx> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx> CC: Julien Grall <julien.grall@xxxxxxxxxx> --- 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@xxxxxxxx> + * 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@xxxxxxxx> + * 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@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |