[{"id":1794764,"web_url":"http://patchwork.ozlabs.org/comment/1794764/","msgid":"<90d25374-cc83-7f75-eb38-766f0cdb9c53@arm.com>","list_archive_url":null,"date":"2017-10-27T10:40:59","subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","submitter":{"id":72256,"url":"http://patchwork.ozlabs.org/api/people/72256/","name":"Julien Thierry","email":"julien.thierry@arm.com"},"content":"Hi Kaihua,\n\nOn 27/10/17 07:15, Kaihua Zhong wrote:\n> Hi3660 mailbox controller is used to send message within multiple\n> processors, MCU, HIFI, etc.  It supports 32 mailbox channels and every\n> channel can only be used for single transferring direction.  Once the\n> channel is enabled, it needs to specify the destination interrupt and\n> acknowledge interrupt, these two interrupt vectors are used to create\n> the connection between the mailbox and interrupt controllers.\n> \n> The application processor (or from point of view of kernel) is not the\n> only one master which can launch the data transferring, other\n> processors or MCU/DSP also can kick off the data transferring.  So this\n> driver implements a locking mechanism to support exclusive accessing.\n> \n> The data transferring supports two modes, one is named as \"automatic\n> acknowledge\" mode so after send message the kernel doesn't need to wait\n> for acknowledge from remote and directly return; there have another mode\n> is to rely on handling interrupt for acknowledge.\n> \n> This commit is for initial version driver, which only supports\n> \"automatic acknowledge\" mode to support CPU clock, which is the only\n> one consumer to use mailbox and has been verified.  Later may enhance\n> this driver for interrupt mode (e.g. for supporting HIFI).\n> \n> Cc: John Stultz <john.stultz@linaro.org>\n> Cc: Guodong Xu <guodong.xu@linaro.org>\n> Cc: Haojian Zhuang <haojian.zhuang@linaro.org>\n> Cc: Niranjan Yadla <nyadla@cadence.com>\n> Cc: Raj Pawate <pawateb@cadence.com>\n> Signed-off-by: Leo Yan <leo.yan@linaro.org>\n> Signed-off-by: Ruyi Wang <wangruyi@huawei.com>\n> Signed-off-by: Kaihua Zhong <zhongkaihua@huawei.com>\n> Signed-off-by: Kevin Wang <kevin.wangtao@hisilicon.com>\n> ---\n>   drivers/mailbox/Kconfig          |   8 +\n>   drivers/mailbox/Makefile         |   2 +\n>   drivers/mailbox/hi3660-mailbox.c | 331 +++++++++++++++++++++++++++++++++++++++\n>   3 files changed, 341 insertions(+)\n>   create mode 100644 drivers/mailbox/hi3660-mailbox.c\n> \n> diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig\n> index c5731e5..4b5d6e9 100644\n> --- a/drivers/mailbox/Kconfig\n> +++ b/drivers/mailbox/Kconfig\n> @@ -108,6 +108,14 @@ config TI_MESSAGE_MANAGER\n>   \t  multiple processors within the SoC. Select this driver if your\n>   \t  platform has support for the hardware block.\n>   \n> +config HI3660_MBOX\n> +\ttristate \"Hi3660 Mailbox\"\n> +\tdepends on ARCH_HISI && OF\n> +\thelp\n> +\t  An implementation of the hi3660 mailbox. It is used to send message\n> +\t  between application processors and other processors/MCU/DSP. Select\n> +\t  Y here if you want to use Hi3660 mailbox controller.\n> +\n>   config HI6220_MBOX\n>   \ttristate \"Hi6220 Mailbox\"\n>   \tdepends on ARCH_HISI\n> diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile\n> index d54e412..7d1bd51 100644\n> --- a/drivers/mailbox/Makefile\n> +++ b/drivers/mailbox/Makefile\n> @@ -26,6 +26,8 @@ obj-$(CONFIG_TI_MESSAGE_MANAGER) += ti-msgmgr.o\n>   \n>   obj-$(CONFIG_XGENE_SLIMPRO_MBOX) += mailbox-xgene-slimpro.o\n>   \n> +obj-$(CONFIG_HI3660_MBOX)\t+= hi3660-mailbox.o\n> +\n>   obj-$(CONFIG_HI6220_MBOX)\t+= hi6220-mailbox.o\n>   \n>   obj-$(CONFIG_BCM_PDC_MBOX)\t+= bcm-pdc-mailbox.o\n> diff --git a/drivers/mailbox/hi3660-mailbox.c b/drivers/mailbox/hi3660-mailbox.c\n> new file mode 100644\n> index 0000000..67df8f8\n> --- /dev/null\n> +++ b/drivers/mailbox/hi3660-mailbox.c\n> @@ -0,0 +1,331 @@\n> +/*\n> + * Hisilicon's Hi3660 mailbox controller driver\n> + *\n> + * Copyright (c) 2017 Hisilicon Limited.\n> + * Copyright (c) 2017 Linaro Limited.\n> + *\n> + * Author: Leo Yan <leo.yan@linaro.org>\n> + *\n> + * This program is free software: you can redistribute it and/or modify\n> + * it under the terms of the GNU General Public License as published by\n> + * the Free Software Foundation, version 2 of the License.\n> + *\n> + * This program is distributed in the hope that it will be useful,\n> + * but WITHOUT ANY WARRANTY; without even the implied warranty of\n> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n> + * GNU General Public License for more details.\n> + *\n> + */\n> +\n> +#include <linux/bitops.h>\n> +#include <linux/delay.h>\n> +#include <linux/device.h>\n> +#include <linux/err.h>\n> +#include <linux/interrupt.h>\n> +#include <linux/io.h>\n> +#include <linux/iopoll.h>\n> +#include <linux/mailbox_controller.h>\n> +#include <linux/module.h>\n> +#include <linux/platform_device.h>\n> +#include <linux/slab.h>\n> +\n> +#include \"mailbox.h\"\n> +\n> +#define MBOX_CHAN_MAX\t\t\t32\n> +\n> +#define MBOX_RX\t\t\t\t(0x0)\n> +#define MBOX_TX\t\t\t\t(0x1)\n> +\n> +#define MBOX_BASE(mbox, ch)\t\t((mbox)->base + ((ch) * 0x40))\n> +#define MBOX_SRC_REG\t\t\t(0x00)\n> +#define MBOX_DST_REG\t\t\t(0x04)\n> +#define MBOX_DCLR_REG\t\t\t(0x08)\n> +#define MBOX_DSTAT_REG\t\t\t(0x0c)\n> +#define MBOX_MODE_REG\t\t\t(0x10)\n> +#define MBOX_IMASK_REG\t\t\t(0x14)\n> +#define MBOX_ICLR_REG\t\t\t(0x18)\n> +#define MBOX_SEND_REG\t\t\t(0x1c)\n> +#define MBOX_DATA_REG\t\t\t(0x20)\n> +\n> +#define MBOX_IPC_LOCK_REG\t\t(0xa00)\n> +#define MBOX_IPC_UNLOCK\t\t\t(0x1acce551)\n> +\n> +#define MBOX_AUTOMATIC_ACK\t\t(1)\n> +\n> +#define MBOX_STATE_IDLE\t\t\tBIT(4)\n> +#define MBOX_STATE_ACK\t\t\tBIT(7)\n> +\n> +#define MBOX_MSG_LEN\t\t\t8\n> +\n> +/**\n> + * Hi3660 mailbox channel device data\n> + *\n> + * A channel can be used for TX or RX, it can trigger remote\n> + * processor interrupt to notify remote processor and can receive\n> + * interrupt if has incoming message.\n> + *\n> + * @dst_irq:\tInterrupt vector for remote processor\n> + * @ack_irq:\tInterrupt vector for local processor\n> + */\n> +struct hi3660_mbox_dev {\n> +\tunsigned int dst_irq;\n> +\tunsigned int ack_irq;\n> +};\n> +\n> +/**\n> + * Hi3660 mailbox controller data\n> + *\n> + * Mailbox controller includes 32 channels and can allocate\n> + * channel for message transferring.\n> + *\n> + * @dev:\tDevice to which it is attached\n> + * @base:\tBase address of the register mapping region\n> + * @chan:\tRepresentation of channels in mailbox controller\n> + * @mdev:\tRepresentation of channel device data\n> + * @controller:\tRepresentation of a communication channel controller\n> + */\n> +struct hi3660_mbox {\n> +\tstruct device *dev;\n> +\tvoid __iomem *base;\n> +\tstruct mbox_chan chan[MBOX_CHAN_MAX];\n> +\tstruct hi3660_mbox_dev mdev[MBOX_CHAN_MAX];\n> +\tstruct mbox_controller controller;\n> +};\n> +\n> +static inline struct hi3660_mbox *to_hi3660_mbox(struct mbox_chan *chan)\n> +{\n> +\treturn container_of(chan->mbox, struct hi3660_mbox, controller);\n> +}\n> +\n> +static int hi3660_mbox_check_state(struct mbox_chan *chan)\n> +{\n> +\tunsigned long ch = (unsigned long)chan->con_priv;\n> +\tstruct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n> +\tstruct hi3660_mbox_dev *mdev = &mbox->mdev[ch];\n> +\tvoid __iomem *base = MBOX_BASE(mbox, ch);\n> +\tunsigned long val;\n> +\tunsigned int state, ret;\n> +\n> +\t/* Mailbox is idle so directly bail out */\n> +\tstate = readl_relaxed(base + MBOX_MODE_REG);\n> +\tif (state & MBOX_STATE_IDLE)\n> +\t\treturn 0;\n> +\n> +\t/* Wait for acknowledge from remote */\n> +\tret = readx_poll_timeout_atomic(readl_relaxed, base + MBOX_MODE_REG,\n> +\t\t\tval, (val & MBOX_STATE_ACK), 1000, 300000);\n> +\tif (ret) {\n> +\t\tdev_err(mbox->dev, \"%s: timeout for receiving ack\\n\", __func__);\n> +\t\treturn ret;\n> +\t}\n> +\n> +\t/* Ensure channel is released */\n> +\twritel_relaxed(0xffffffff, base + MBOX_IMASK_REG);\n> +\twritel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n> +\t__asm__ volatile (\"sev\");\n\nThere is an existing sev() macro for this.\n\n> +\treturn 0;\n> +}\n> +\n> +static int hi3660_mbox_unlock(struct mbox_chan *chan)\n> +{\n> +\tstruct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n> +\tunsigned int val, retry = 3;\n> +\n> +\tdo {\n> +\t\twritel_relaxed(MBOX_IPC_UNLOCK, mbox->base + MBOX_IPC_LOCK_REG);\n> +\n> +\t\tval = readl_relaxed(mbox->base + MBOX_IPC_LOCK_REG);\n> +\t\tif (!val)\n> +\t\t\tbreak;\n> +\n> +\t\tudelay(10);\n> +\t} while (retry--);\n> +\n> +\treturn (!val) ? 0 : -ETIMEDOUT;\n> +}\n> +\n> +static int hi3660_mbox_acquire_channel(struct mbox_chan *chan)\n> +{\n> +\tunsigned long ch = (unsigned long)chan->con_priv;\n> +\tstruct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n> +\tstruct hi3660_mbox_dev *mdev = &mbox->mdev[ch];\n> +\tvoid __iomem *base = MBOX_BASE(mbox, ch);\n> +\tunsigned int val = 0, retry = 10;\n> +\n> +\t/*\n> +\t * Hardware locking for exclusive accessing within CPUs\n> +\t * without exclusive monitor mechanism.\n> +\t */\n> +\tdo {\n> +\t\tval = readl_relaxed(base + MBOX_MODE_REG);\n> +\t\tif (!(val & MBOX_STATE_IDLE)) {\n> +\t\t\t__asm__ volatile (\"wfe\");\n> +\t\t\tcontinue;\n\nSo this is going to \"wfe\" when retry == 0 and the continue statement \nwill take us out of the loop?\n\nAlso, there is a wfe() macro for arm and arm64 which could be used here.\n\n> +\t\t}\n> +\n> +\t\t/* Check if channel has be acquired */\n> +\t\twritel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n> +\t\tval = readl_relaxed(base + MBOX_SRC_REG) & BIT(mdev->ack_irq);\n> +\t\tif (val)\n> +\t\t\tbreak;\n> +\n> +\t} while (retry--);\n> +\n> +\treturn (val) ? 0 : -ETIMEDOUT;\n\nIf timeout occurs while waiting for the MBOX to be idle, val will hold \nthe last value from MBOX_MODE_REG, and if this can be different than 0, \nthis will hide the fact it timed out.\n\nMaybe the following would be more appropriate:\n\nreturn (retry >= 0) ? 0 : -ETIMEDOUT;\n\nAlso, your do {} while loops for the timeouts falsely give the \nimpression we do \"retry\" attempts when we actually do \"retry + 1\" \nattempts (but I guess it doesn't make a big difference from the \nfunctional point of view).\n\n> +}\n> +\n> +static int hi3660_mbox_send(struct mbox_chan *chan, u32 *msg)\n> +{\n> +\tunsigned long ch = (unsigned long)chan->con_priv;\n> +\tstruct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n> +\tstruct hi3660_mbox_dev *mdev = &mbox->mdev[ch];\n> +\tvoid __iomem *base = MBOX_BASE(mbox, ch);\n> +\tunsigned int i;\n> +\n> +\t/* Clear mask for destination interrupt */\n> +\twritel_relaxed(~BIT(mdev->dst_irq), base + MBOX_IMASK_REG);\n> +\n> +\t/* Config destination for interrupt vector */\n> +\twritel_relaxed(BIT(mdev->dst_irq), base + MBOX_DST_REG);\n> +\n> +\t/* Automatic acknowledge mode */\n> +\twritel_relaxed(MBOX_AUTOMATIC_ACK, base + MBOX_MODE_REG);\n> +\n> +\t/* Fill message data */\n> +\tfor (i = 0; i < MBOX_MSG_LEN; i++)\n> +\t\twritel_relaxed(msg[i], base + MBOX_DATA_REG + i * 4);\n> +\n> +\t/* Trigger data transferring */\n> +\twritel_relaxed(BIT(mdev->ack_irq), base + MBOX_SEND_REG);\n> +\treturn 0;\n> +}\n> +\n> +static int hi3660_mbox_send_data(struct mbox_chan *chan, void *msg)\n> +{\n> +\tstruct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n> +\tint err;\n> +\n> +\terr = hi3660_mbox_check_state(chan);\n> +\tif (err) {\n> +\t\tdev_err(mbox->dev, \"checking state failed\\n\");\n> +\t\treturn err;\n> +\t}\n> +\n> +\terr = hi3660_mbox_unlock(chan);\n> +\tif (err) {\n> +\t\tdev_err(mbox->dev, \"unlocking mailbox failed\\n\");\n> +\t\treturn err;\n> +\t}\n> +\n> +\terr = hi3660_mbox_acquire_channel(chan);\n> +\tif (err) {\n> +\t\tdev_err(mbox->dev, \"acquiring channel failed\\n\");\n> +\t\treturn err;\n> +\t}\n> +\n> +\treturn hi3660_mbox_send(chan, msg);\n> +}\n> +\n> +static struct mbox_chan_ops hi3660_mbox_ops = {\n> +\t.send_data    = hi3660_mbox_send_data,\n> +};\n> +\n> +static struct mbox_chan *hi3660_mbox_xlate(struct mbox_controller *controller,\n> +\t\t\t\t\t   const struct of_phandle_args *spec)\n> +{\n> +\tstruct hi3660_mbox *mbox = dev_get_drvdata(controller->dev);\n\nnit:\nIn to_hi3660_mbox, you use the fact that the mbox_controller structure \nis part of hi3660_mbox and use container of to retrieve hi3660_mbox.\n\nI think it would be nice to be consistent about this, either use \ncontainer_of or dev drvdata, but not both.\n\nCheers,","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"WwmZ42rG\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yNgRR55Hyz9t2d\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tFri, 27 Oct 2017 21:41:50 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e825A-0007LA-98; Fri, 27 Oct 2017 10:41:44 +0000","from foss.arm.com ([217.140.101.70])\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e824r-0007Ga-Hr for linux-arm-kernel@lists.infradead.org;\n\tFri, 27 Oct 2017 10:41:27 +0000","from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249])\n\tby usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D36FD15AD;\n\tFri, 27 Oct 2017 03:41:03 -0700 (PDT)","from [10.1.207.56] (e112298-lin.cambridge.arm.com [10.1.207.56])\n\tby usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id\n\t1CBE43F24A; Fri, 27 Oct 2017 03:41:00 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type:\n\tContent-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive:\n\tList-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From:\n\tReferences:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date:\n\tResent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;\n\tbh=Yj9xH5O6qMjEYS8CSdbTaM98EufVwh09ALRGD2f90QU=;\n\tb=WwmZ42rGUnyS1zUJcjxDQb7dt\n\tPFX4fkcI9DEmho8gewhczo61mQ8ue1lu47CJpv1C520+GfTKo+lbAzUIP0K9/urvUdcjy7E9u2hCZ\n\t8/fnflNIKkL0rN37uhqQ+O5GwDSoD+a21/kTMZheQNVFVJVoW7VftuggisInOke81c10MdJjCijOk\n\tU/GswZu/HjJo1BDnSW/w2XyCTwUJ/5N+VjSLrDEKLJchiNE9eLQhZjuGxjHL+5vHMFSzNjtkGv3yv\n\tcQAR4DISiOfqYgW9xK4prhbXzKMoZZYEyyBVlROrdfFj5VHGeig1PU7ycbEq8YD8UT67WCBnI038d\n\trhrBIAyHA==;","Subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","To":"Kaihua Zhong <zhongkaihua@huawei.com>, robh+dt@kernel.org,\n\tmark.rutland@arm.com, xuwei5@hisilicon.com, catalin.marinas@arm.com, \n\twill.deacon@arm.com, jassisinghbrar@gmail.com","References":"<1509084904-2505-1-git-send-email-zhongkaihua@huawei.com>\n\t<1509084904-2505-3-git-send-email-zhongkaihua@huawei.com>","From":"Julien Thierry <julien.thierry@arm.com>","Message-ID":"<90d25374-cc83-7f75-eb38-766f0cdb9c53@arm.com>","Date":"Fri, 27 Oct 2017 11:40:59 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<1509084904-2505-3-git-send-email-zhongkaihua@huawei.com>","Content-Language":"en-US","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171027_034125_610009_C226BE6F ","X-CRM114-Status":"GOOD (  35.17  )","X-Spam-Score":"-6.9 (------)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-6.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/,\n\thigh trust [217.140.101.70 listed in list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"xuezhiliang@hisilicon.com, devicetree@vger.kernel.org,\n\tguodong.xu@linaro.org, suzhuangluan@hisilicon.com,\n\tlinux-kernel@vger.kernel.org, haojian.zhuang@linaro.org,\n\tkevin.wangtao@hisilicon.com, linux-arm-kernel@lists.infradead.org","Content-Transfer-Encoding":"7bit","Content-Type":"text/plain; charset=\"us-ascii\"; Format=\"flowed\"","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1794804,"web_url":"http://patchwork.ozlabs.org/comment/1794804/","msgid":"<20171027104559.em5n5ogro46ethmq@salmiak>","list_archive_url":null,"date":"2017-10-27T10:46:00","subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","submitter":{"id":8806,"url":"http://patchwork.ozlabs.org/api/people/8806/","name":"Mark Rutland","email":"mark.rutland@arm.com"},"content":"On Fri, Oct 27, 2017 at 02:15:03PM +0800, Kaihua Zhong wrote:\n> Hi3660 mailbox controller is used to send message within multiple\n> processors, MCU, HIFI, etc.  It supports 32 mailbox channels and every\n> channel can only be used for single transferring direction.  Once the\n> channel is enabled, it needs to specify the destination interrupt and\n> acknowledge interrupt, these two interrupt vectors are used to create\n> the connection between the mailbox and interrupt controllers.\n> \n> The application processor (or from point of view of kernel) is not the\n> only one master which can launch the data transferring, other\n> processors or MCU/DSP also can kick off the data transferring.  So this\n> driver implements a locking mechanism to support exclusive accessing.\n\n... and that locking mechanism is what precisely?\n\nWhere is the protocol defined?\n\n> +static int hi3660_mbox_check_state(struct mbox_chan *chan)\n> +{\n> +\tunsigned long ch = (unsigned long)chan->con_priv;\n> +\tstruct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n> +\tstruct hi3660_mbox_dev *mdev = &mbox->mdev[ch];\n> +\tvoid __iomem *base = MBOX_BASE(mbox, ch);\n> +\tunsigned long val;\n> +\tunsigned int state, ret;\n> +\n> +\t/* Mailbox is idle so directly bail out */\n> +\tstate = readl_relaxed(base + MBOX_MODE_REG);\n> +\tif (state & MBOX_STATE_IDLE)\n> +\t\treturn 0;\n> +\n> +\t/* Wait for acknowledge from remote */\n> +\tret = readx_poll_timeout_atomic(readl_relaxed, base + MBOX_MODE_REG,\n> +\t\t\tval, (val & MBOX_STATE_ACK), 1000, 300000);\n> +\tif (ret) {\n> +\t\tdev_err(mbox->dev, \"%s: timeout for receiving ack\\n\", __func__);\n> +\t\treturn ret;\n> +\t}\n> +\n> +\t/* Ensure channel is released */\n> +\twritel_relaxed(0xffffffff, base + MBOX_IMASK_REG);\n> +\twritel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n> +\t__asm__ volatile (\"sev\");\n> +\treturn 0;\n> +}\n\nDrivers really shouldn't be using SEV directly (even if via the sev() macro)...\n\nThis SEV isn't ordered w.r.t. anything, and it's unclear what ordering you\nneed, so this simply does not work.\n\n> +static int hi3660_mbox_acquire_channel(struct mbox_chan *chan)\n> +{\n> +\tunsigned long ch = (unsigned long)chan->con_priv;\n> +\tstruct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n> +\tstruct hi3660_mbox_dev *mdev = &mbox->mdev[ch];\n> +\tvoid __iomem *base = MBOX_BASE(mbox, ch);\n> +\tunsigned int val = 0, retry = 10;\n> +\n> +\t/*\n> +\t * Hardware locking for exclusive accessing within CPUs\n> +\t * without exclusive monitor mechanism.\n> +\t */\n> +\tdo {\n> +\t\tval = readl_relaxed(base + MBOX_MODE_REG);\n> +\t\tif (!(val & MBOX_STATE_IDLE)) {\n> +\t\t\t__asm__ volatile (\"wfe\");\n\n... and likewise for WFE / wfe().\n\n> +\t\t\tcontinue;\n> +\t\t}\n> +\n> +\t\t/* Check if channel has be acquired */\n> +\t\twritel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n> +\t\tval = readl_relaxed(base + MBOX_SRC_REG) & BIT(mdev->ack_irq);\n> +\t\tif (val)\n> +\t\t\tbreak;\n> +\n> +\t} while (retry--);\n> +\n> +\treturn (val) ? 0 : -ETIMEDOUT;\n> +}\n\nPlease elaborate on how this synchronisation mechanism is expected to work, and\nwhy it is necessary in the first place.\n\nThanks,\nMark.","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"H+N1M4AV\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yNjV573N1z9t2h\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tFri, 27 Oct 2017 23:14:21 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e83Wl-0007jr-OA; Fri, 27 Oct 2017 12:14:19 +0000","from foss.arm.com ([217.140.101.70])\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e83WX-0007hM-I4 for linux-arm-kernel@lists.infradead.org;\n\tFri, 27 Oct 2017 12:14:07 +0000","from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249])\n\tby usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 47A3280D;\n\tFri, 27 Oct 2017 05:13:43 -0700 (PDT)","from salmiak (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70])\n\tby usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id\n\t5DC653F24A; Fri, 27 Oct 2017 05:13:40 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=Es166r8Nx+QavzYfYUgT/sQwE/BXMukxYMaoODnQvc0=;\n\tb=H+N1M4AVFYSw3M\n\tyfcNQgzeihyjtqQfWNYCooD3z88p0sUWvU9mQuxwx/IEefi+x0F6OuyT9mqQ5pRPFumLFnzp41hr/\n\tUkGdXF3pFpilrQH0f+vTu9vG1Pz+EnyB0EguiKNDv/0l6olv1PnRoDkP3AN4GTRr/fvj8Xhqm336L\n\tiAqlzoBBF/+NextOFQNwxb4bE4Oxv9zPQ+BlXX1+hChjhUOiM/BWwYehroJ/IX89f3E+9KBpv1qEO\n\tx4ngB63jOttcixFtm2N8TF2WWFUPIHROPsXXfrxq3KStfKPzi+3IusGrHfAYoPjJgbGIaopNpfMis\n\txZZ4dl7MsgYiNpyc5NBg==;","Date":"Fri, 27 Oct 2017 11:46:00 +0100","From":"Mark Rutland <mark.rutland@arm.com>","To":"Kaihua Zhong <zhongkaihua@huawei.com>","Subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","Message-ID":"<20171027104559.em5n5ogro46ethmq@salmiak>","References":"<1509084904-2505-1-git-send-email-zhongkaihua@huawei.com>\n\t<1509084904-2505-3-git-send-email-zhongkaihua@huawei.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<1509084904-2505-3-git-send-email-zhongkaihua@huawei.com>","User-Agent":"NeoMutt/20170113 (1.7.2)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171027_051405_611991_F2BB3959 ","X-CRM114-Status":"GOOD (  18.64  )","X-Spam-Score":"-6.9 (------)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-6.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/,\n\thigh trust [217.140.101.70 listed in list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"xuezhiliang@hisilicon.com, devicetree@vger.kernel.org,\n\tguodong.xu@linaro.org, catalin.marinas@arm.com,\n\tsuzhuangluan@hisilicon.com, \n\tjassisinghbrar@gmail.com, will.deacon@arm.com,\n\tlinux-kernel@vger.kernel.org, \n\txuwei5@hisilicon.com, robh+dt@kernel.org, haojian.zhuang@linaro.org, \n\tkevin.wangtao@hisilicon.com, linux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1794940,"web_url":"http://patchwork.ozlabs.org/comment/1794940/","msgid":"<20171027143844.uxhl3vbzacvv3z4j@rob-hp-laptop>","list_archive_url":null,"date":"2017-10-27T14:38:44","subject":"Re: [PATCH v2 1/3] dt-bindings: mailbox: Introduce Hi3660 controller\n\tbinding","submitter":{"id":62529,"url":"http://patchwork.ozlabs.org/api/people/62529/","name":"Rob Herring (Arm)","email":"robh@kernel.org"},"content":"On Fri, Oct 27, 2017 at 02:15:02PM +0800, Kaihua Zhong wrote:\n> From: Leo Yan <leo.yan@linaro.org>\n> \n> Introduce a binding for the Hi3660 mailbox controller, the mailbox is\n> used within application processor (AP), communication processor (CP),\n> HIFI and MCU, etc.\n> \n> Cc: John Stultz <john.stultz@linaro.org>\n> Cc: Guodong Xu <guodong.xu@linaro.org>\n> Cc: Haojian Zhuang <haojian.zhuang@linaro.org>\n> Cc: Niranjan Yadla <nyadla@cadence.com>\n> Cc: Raj Pawate <pawateb@cadence.com>\n> Signed-off-by: Leo Yan <leo.yan@linaro.org>\n> ---\n>  .../bindings/mailbox/hisilicon,hi3660-mailbox.txt  | 52 ++++++++++++++++++++++\n>  1 file changed, 52 insertions(+)\n>  create mode 100644 Documentation/devicetree/bindings/mailbox/hisilicon,hi3660-mailbox.txt\n> \n> diff --git a/Documentation/devicetree/bindings/mailbox/hisilicon,hi3660-mailbox.txt b/Documentation/devicetree/bindings/mailbox/hisilicon,hi3660-mailbox.txt\n> new file mode 100644\n> index 0000000..8a8d7e1\n> --- /dev/null\n> +++ b/Documentation/devicetree/bindings/mailbox/hisilicon,hi3660-mailbox.txt\n> @@ -0,0 +1,52 @@\n> +Hisilicon Hi3660 Mailbox Driver\n\nBindings are for h/w, not drivers.\n\n> +\n> +Hisilicon Hi3660 mailbox controller supports up to 32 channels.  Messages\n> +are passed between processors, including application & communication\n> +processors, MCU, HIFI, etc.  Each channel is unidirectional and accessed\n> +by using MMIO registers; it supports maximum to 8 words message.\n> +\n> +Controller\n> +----------\n> +\n> +Required properties:\n> +- compatible:\t\t: Shall be \"hisilicon,hi3660-mbox\"\n> +- reg:\t\t\t: Offset and length of the device's register set\n> +- #mbox-cells:\t\t: Must be 3\n> +\t\t\t  <&phandle channel dst_irq ack_irq>\n> +\t\t\t    phandle\t: Label name of controller\n> +\t\t\t    channel\t: Channel number\n> +\t\t\t    dst_irq\t: Remote interrupt vector\n> +\t\t\t    ack_irq\t: Local interrupt vector\n> +\n> +- interrupts:\t\t: Contains the two IRQ lines for mailbox.\n> +\n> +Example:\n> +\n> +mailbox: mailbox@e896b000 {\n> +\tcompatible = \"hisilicon,hi3660-mbox\";\n> +\treg = <0x0 0xe896b000 0x0 0x1000>;\n> +\tinterrupts = <0x0 0xc0 0x4>,\n> +\t\t     <0x0 0xc1 0x4>;\n> +\t#mbox-cells = <3>;\n> +};\n> +\n> +Client\n> +------\n> +\n> +Required properties:\n> +- compatible\t\t: See the client docs\n> +- mboxes\t\t: Standard property to specify a Mailbox (See ./mailbox.txt)\n> +\t\t\t  Cells must match 'mbox-cells' (See Controller docs above)\n> +\n> +Optional properties\n> +- mbox-names\t\t: Name given to channels seen in the 'mboxes' property.\n> +\n> +Example:\n> +\n> +stub_clock: stub_clock {\n\nclock@e896b500\n\n> +\tcompatible = \"hisilicon,hi3660-stub-clk\";\n> +\treg = <0x0 0xe896b500 0x0 0x0100>;\n> +\t#clock-cells = <1>;\n> +\tmbox-names = \"mbox-tx\";\n\nDon't need -names when there is only one. Plus \"mbox-\" part is \nredundant.\n\n> +\tmboxes = <&mailbox 13 3 0>;\n> +};\n> -- \n> 1.9.1\n>","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"KR3CPw6O\"; \n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=infradead.org header.i=@infradead.org\n\theader.b=\"WVn4v+xZ\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yNmx259YMz9t2Z\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tSat, 28 Oct 2017 01:49:26 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e85wq-0008LD-T3; Fri, 27 Oct 2017 14:49:24 +0000","from merlin.infradead.org ([2001:8b0:10b:1231::1])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e85wi-0008Fz-9J for linux-arm-kernel@bombadil.infradead.org;\n\tFri, 27 Oct 2017 14:49:16 +0000","from mail-oi0-f66.google.com ([209.85.218.66])\n\tby merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e85mu-0006Ub-KI for linux-arm-kernel@lists.infradead.org;\n\tFri, 27 Oct 2017 14:39:09 +0000","by mail-oi0-f66.google.com with SMTP id v132so11200131oie.1\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tFri, 27 Oct 2017 07:38:48 -0700 (PDT)","from localhost (mobile-166-176-121-60.mycingular.net.\n\t[166.176.121.60]) by smtp.gmail.com with ESMTPSA id\n\tv21sm3722576ote.49.2017.10.27.07.38.45\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tFri, 27 Oct 2017 07:38:45 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=Bd7ka4kCa+bF8YsQhufySj02opddDvbY+OAL/OyaNYU=;\n\tb=KR3CPw6OdTofVT\n\tQwr6pdOggDAQg8ds2wb+Q+AJeU7NLwnLED8s1APULtWNW668qg0fQYE//hu5exQDErF4ll5Ho0Pqh\n\t/Wybm2WcbcCBTjxAXaiLy1u0sIvADl1W8XXB16jFRyrUrGZzRAGR71W0tlujoezg+bsnEmUH6u9PV\n\t/RSPzOhbyvNyw9AF4d7V6sYpj4x63ptwjFjb4bmBSiexxxgTBxu6r38V6FeWHmN0UFgUnBtrENF13\n\tfx7XbrXoBbnnYaXZvrvlquyVvkIskG70uRcgZdD1fgaIIbP5+g8vXgHpUM/vinxGhXqi/Seuw9QuN\n\tuaGL5S+dY5BY09me776A==;","v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=infradead.org; s=merlin.20170209;\n\th=In-Reply-To:Content-Type:MIME-Version:\n\tReferences:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:\n\tContent-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:\n\tResent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:\n\tList-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;\n\tbh=XqwDsNNoiWo6lj3cHBjd0Hdp8/2NkMrJJyzKtOdROzE=;\n\tb=WVn4v+xZiPickuRU1ztk4XQiP\n\tAFza/Jh9FzxXEKc3vg+/pIjQUe7ydjG4nuZiXkAwmWnTKQZdDgu/MyA1xt/vrv8CW3oT04T1AKPj2\n\tlT65t4q9BS7m7OVdEvPVklf3P/LgWpA/5WeUQS/F3vwluA42sw6GgJNghg6ccNVYnVvoy9lhwjpWn\n\tNGAl+S6P++8UYfP/hA3JjnuDBGgY8N0aBtEVOsUgxrKjJYZywhZiBjd5N6uR764yZm0vrR9iJTEgn\n\toIXd57aB5rfMAVfSqwG6nZTYSna37YTO6XY8aGyVBwYdnlBv/dbKmxeupIbTgZxrwYrxp11MDy9Ka\n\tyvPNbFzhw==;"],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to:user-agent;\n\tbh=XqwDsNNoiWo6lj3cHBjd0Hdp8/2NkMrJJyzKtOdROzE=;\n\tb=Ry+Aqognrem9MkwKaVT81cYvxXvl213YApY7Prj95mxLq0FBIZ8Ku5rgacJuUiUpVi\n\tJmSjoa6tJAm2UOyoUmt7wk0gBVwudR0oBqbZCSny7AklBw+rsnocBm7oRwej5Q+esytL\n\tEJnIhL3MBiesEUwCSjQiGL0UO5+jVqWGdMvFOeWx8a2oPsYRxotoghBHjHZD62QbHpjI\n\t3zlQCkXMQH8L84g9n5U+ezmNjXFsqIR8W+AQB60m3UlMzSta/jbLLwuIGOVgS97tg5Z6\n\tBhXJQIAbz/L8y59We93Or3NGOKqFHmIs8Q7iIn7ezB57q+jjKA2o0eFU+TzVGUKkk3mO\n\tWkbw==","X-Gm-Message-State":"AMCzsaWuz8E1hJEWRGlW20MZiOgFWgr5EVo5G2zTFAu3XZl4IsZT8XYN\n\tyJDXUu2Rtu4JtLgH8Hbe9w==","X-Google-Smtp-Source":"ABhQp+Q8lGobUY82WLrw4wloJi9PJN/iEtvlHdaaMMt9ImB2JCDtnHrfw35EMcp4JszAFqIoU/He0A==","X-Received":"by 10.202.204.197 with SMTP id c188mr337985oig.143.1509115126359;\n\tFri, 27 Oct 2017 07:38:46 -0700 (PDT)","Date":"Fri, 27 Oct 2017 09:38:44 -0500","From":"Rob Herring <robh@kernel.org>","To":"Kaihua Zhong <zhongkaihua@huawei.com>","Subject":"Re: [PATCH v2 1/3] dt-bindings: mailbox: Introduce Hi3660 controller\n\tbinding","Message-ID":"<20171027143844.uxhl3vbzacvv3z4j@rob-hp-laptop>","References":"<1509084904-2505-1-git-send-email-zhongkaihua@huawei.com>\n\t<1509084904-2505-2-git-send-email-zhongkaihua@huawei.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<1509084904-2505-2-git-send-email-zhongkaihua@huawei.com>","User-Agent":"NeoMutt/20170609 (1.8.3)","X-Spam-Note":"CRM114 invocation failed","X-Spam-Score":"-1.0 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on merlin.infradead.org summary:\n\tContent analysis details:   (-1.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t0.5 RCVD_IN_SORBS_SPAM     RBL: SORBS: sender is a spam source\n\t[209.85.218.66 listed in dnsbl.sorbs.net]\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno trust [209.85.218.66 listed in list.dnswl.org]\n\t-0.0 RCVD_IN_MSPIKE_H3      RBL: Good reputation (+3)\n\t[209.85.218.66 listed in wl.mailspike.net]\n\t0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends\n\tin digit (robherring2[at]gmail.com)\n\t0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level\n\tmail domains are different\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\n\tprovider (robherring2[at]gmail.com)\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders\n\t0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and\n\tEnvelopeFrom freemail headers are different","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"mark.rutland@arm.com, devicetree@vger.kernel.org,\n\txuezhiliang@hisilicon.com, \n\tguodong.xu@linaro.org, catalin.marinas@arm.com,\n\tsuzhuangluan@hisilicon.com, \n\tjassisinghbrar@gmail.com, will.deacon@arm.com,\n\tlinux-kernel@vger.kernel.org, \n\txuwei5@hisilicon.com, haojian.zhuang@linaro.org,\n\tkevin.wangtao@hisilicon.com, linux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1794960,"web_url":"http://patchwork.ozlabs.org/comment/1794960/","msgid":"<20171027150251.GE29281@leoy-linaro>","list_archive_url":null,"date":"2017-10-27T15:02:51","subject":"Re: [PATCH v2 1/3] dt-bindings: mailbox: Introduce Hi3660 controller\n\tbinding","submitter":{"id":66057,"url":"http://patchwork.ozlabs.org/api/people/66057/","name":"Leo Yan","email":"leo.yan@linaro.org"},"content":"On Fri, Oct 27, 2017 at 09:38:44AM -0500, Rob Herring wrote:\n> On Fri, Oct 27, 2017 at 02:15:02PM +0800, Kaihua Zhong wrote:\n> > From: Leo Yan <leo.yan@linaro.org>\n> > \n> > Introduce a binding for the Hi3660 mailbox controller, the mailbox is\n> > used within application processor (AP), communication processor (CP),\n> > HIFI and MCU, etc.\n> > \n> > Cc: John Stultz <john.stultz@linaro.org>\n> > Cc: Guodong Xu <guodong.xu@linaro.org>\n> > Cc: Haojian Zhuang <haojian.zhuang@linaro.org>\n> > Cc: Niranjan Yadla <nyadla@cadence.com>\n> > Cc: Raj Pawate <pawateb@cadence.com>\n> > Signed-off-by: Leo Yan <leo.yan@linaro.org>\n> > ---\n> >  .../bindings/mailbox/hisilicon,hi3660-mailbox.txt  | 52 ++++++++++++++++++++++\n> >  1 file changed, 52 insertions(+)\n> >  create mode 100644 Documentation/devicetree/bindings/mailbox/hisilicon,hi3660-mailbox.txt\n> > \n> > diff --git a/Documentation/devicetree/bindings/mailbox/hisilicon,hi3660-mailbox.txt b/Documentation/devicetree/bindings/mailbox/hisilicon,hi3660-mailbox.txt\n> > new file mode 100644\n> > index 0000000..8a8d7e1\n> > --- /dev/null\n> > +++ b/Documentation/devicetree/bindings/mailbox/hisilicon,hi3660-mailbox.txt\n> > @@ -0,0 +1,52 @@\n> > +Hisilicon Hi3660 Mailbox Driver\n> \n> Bindings are for h/w, not drivers.\n\nThanks for reviewing, Rob.\n\nWill fix for this and below comments.\n\n> > +\n> > +Hisilicon Hi3660 mailbox controller supports up to 32 channels.  Messages\n> > +are passed between processors, including application & communication\n> > +processors, MCU, HIFI, etc.  Each channel is unidirectional and accessed\n> > +by using MMIO registers; it supports maximum to 8 words message.\n> > +\n> > +Controller\n> > +----------\n> > +\n> > +Required properties:\n> > +- compatible:\t\t: Shall be \"hisilicon,hi3660-mbox\"\n> > +- reg:\t\t\t: Offset and length of the device's register set\n> > +- #mbox-cells:\t\t: Must be 3\n> > +\t\t\t  <&phandle channel dst_irq ack_irq>\n> > +\t\t\t    phandle\t: Label name of controller\n> > +\t\t\t    channel\t: Channel number\n> > +\t\t\t    dst_irq\t: Remote interrupt vector\n> > +\t\t\t    ack_irq\t: Local interrupt vector\n> > +\n> > +- interrupts:\t\t: Contains the two IRQ lines for mailbox.\n> > +\n> > +Example:\n> > +\n> > +mailbox: mailbox@e896b000 {\n> > +\tcompatible = \"hisilicon,hi3660-mbox\";\n> > +\treg = <0x0 0xe896b000 0x0 0x1000>;\n> > +\tinterrupts = <0x0 0xc0 0x4>,\n> > +\t\t     <0x0 0xc1 0x4>;\n> > +\t#mbox-cells = <3>;\n> > +};\n> > +\n> > +Client\n> > +------\n> > +\n> > +Required properties:\n> > +- compatible\t\t: See the client docs\n> > +- mboxes\t\t: Standard property to specify a Mailbox (See ./mailbox.txt)\n> > +\t\t\t  Cells must match 'mbox-cells' (See Controller docs above)\n> > +\n> > +Optional properties\n> > +- mbox-names\t\t: Name given to channels seen in the 'mboxes' property.\n> > +\n> > +Example:\n> > +\n> > +stub_clock: stub_clock {\n> \n> clock@e896b500\n> \n> > +\tcompatible = \"hisilicon,hi3660-stub-clk\";\n> > +\treg = <0x0 0xe896b500 0x0 0x0100>;\n> > +\t#clock-cells = <1>;\n> > +\tmbox-names = \"mbox-tx\";\n> \n> Don't need -names when there is only one. Plus \"mbox-\" part is \n> redundant.\n> \n> > +\tmboxes = <&mailbox 13 3 0>;\n> > +};\n> > -- \n> > 1.9.1\n> >","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"ctzwpq2N\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"eolyyPsl\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yNnFH0RTwz9t3r\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tSat, 28 Oct 2017 02:03:31 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e86AS-00026U-JM; Fri, 27 Oct 2017 15:03:28 +0000","from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e86AP-00022P-6F for linux-arm-kernel@lists.infradead.org;\n\tFri, 27 Oct 2017 15:03:27 +0000","by mail-wm0-x243.google.com with SMTP id r196so4126462wmf.2\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tFri, 27 Oct 2017 08:03:03 -0700 (PDT)","from leoy-linaro (li1530-42.members.linode.com. [139.162.245.42])\n\tby smtp.gmail.com with ESMTPSA id\n\tl15sm5560433wrb.45.2017.10.27.08.02.55\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 27 Oct 2017 08:03:01 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=+v6E8ZbQMEiPXS28DXWTXd1W6SgiktzEuzmw0RUn3dA=;\n\tb=ctzwpq2N8Ni9IG\n\tf+D4DYygU7W/r3lK80LLzaxqdvecQwdyUXSDd90leRxepX87CxkuNnFnZyF4J/XOwXO5tzoDLddYm\n\t07Qxj54GMv70K4tC4jz1sHj8X9xlvYqBzQX9PAoz7pnVA+F3lTk+9veGGTjkjSRHWDnsbQgDr6CjH\n\thGoCLR3LD5wWyrsQRpvjB8N0roGzBEeXdopNhTBhaMZZHsK+qftV4W/si1cj4yRJYHNUf/9pZN7TG\n\t3Vo/akNdPmdRWJ/t2x7eHPdacpwCtG2mb81b522spcLf/8umqtDxINwciv5lVD3HTZvP4Rr19PFzM\n\taAOik9ZzzI2KuS0xNjcw==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:in-reply-to:user-agent;\n\tbh=w0HNWa86GvEnmcgIIK5o9qj0HAD9S2MgOg2ZyeNREAw=;\n\tb=eolyyPslSRjsscN9RSU/l7sllOnipaX8WKWjpmA5j6R+yu02t+kodNu350AKOCd1xz\n\tnALLrPzc6qSxczxQwXaPoTBLOjUBsXGoF5PxMriOH/D/N+Fmmx9rinDcer+UfqZhBY7x\n\tIkKf4nyjbQG8E/atyyGxzUPF7RbkgXm0RvZ2s="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to:user-agent;\n\tbh=w0HNWa86GvEnmcgIIK5o9qj0HAD9S2MgOg2ZyeNREAw=;\n\tb=Mi6cXcRSfsqL0dLFKNqD1bJDefCE9v8kQiOeOXC+GRj0z09Oh6iRKielCYe1uQr6hH\n\tkO3bS8jlq8YMs9/nBL0SXHWna6k2CshNccMkHC1f0EZutB2fKN7ia+aziAAcmehxuaP3\n\tckjyenAiuwm972i9NlCuGHgMG0y0OpZo0SzeYmC5QTLaDLEB1j0mzw7t8/5GzWVsXvgL\n\tI3n73Q4XhhXHLr+oV6bVBbCofu6HM49esJwOBYeAK287A+3LXgBMHWpCKQc6zNPL7/Lr\n\tMk3P30U/pRl48YyvLyOeSRxmkBP9wtQq0G2dQeKSMIylSfVXtHPSdjj97j1zQ0vAgWTT\n\tOIcA==","X-Gm-Message-State":"AMCzsaUWwFclklYF71qqV+H+5Z9AA41FRVR3OXZZk7LhTlMeerIHWSdN\n\t6XlRz1NwuKLlk+49mWiLPnfWZg==","X-Google-Smtp-Source":"ABhQp+TUTFb9h4QjLkJpAEMiiEFRqZl3zOjzOPpDIEOsFISfUQgXe3T+hM5Nlm99DprNUIgUNY+BMQ==","X-Received":"by 10.28.190.12 with SMTP id o12mr748272wmf.4.1509116582569;\n\tFri, 27 Oct 2017 08:03:02 -0700 (PDT)","Date":"Fri, 27 Oct 2017 23:02:51 +0800","From":"Leo Yan <leo.yan@linaro.org>","To":"Rob Herring <robh@kernel.org>","Subject":"Re: [PATCH v2 1/3] dt-bindings: mailbox: Introduce Hi3660 controller\n\tbinding","Message-ID":"<20171027150251.GE29281@leoy-linaro>","References":"<1509084904-2505-1-git-send-email-zhongkaihua@huawei.com>\n\t<1509084904-2505-2-git-send-email-zhongkaihua@huawei.com>\n\t<20171027143844.uxhl3vbzacvv3z4j@rob-hp-laptop>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20171027143844.uxhl3vbzacvv3z4j@rob-hp-laptop>","User-Agent":"Mutt/1.5.24 (2015-08-30)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171027_080325_388945_BC607430 ","X-CRM114-Status":"GOOD (  15.89  )","X-Spam-Score":"-2.0 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno\n\ttrust [2a00:1450:400c:c09:0:0:0:243 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"mark.rutland@arm.com, devicetree@vger.kernel.org,\n\txuezhiliang@hisilicon.com, \n\tguodong.xu@linaro.org, catalin.marinas@arm.com,\n\tsuzhuangluan@hisilicon.com, \n\tjassisinghbrar@gmail.com, will.deacon@arm.com,\n\tlinux-kernel@vger.kernel.org, \n\txuwei5@hisilicon.com, Kaihua Zhong <zhongkaihua@huawei.com>,\n\thaojian.zhuang@linaro.org, kevin.wangtao@hisilicon.com,\n\tlinux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1795631,"web_url":"http://patchwork.ozlabs.org/comment/1795631/","msgid":"<20171030044506.GE31478@leoy-ThinkPad-T440>","list_archive_url":null,"date":"2017-10-30T04:45:06","subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","submitter":{"id":66057,"url":"http://patchwork.ozlabs.org/api/people/66057/","name":"Leo Yan","email":"leo.yan@linaro.org"},"content":"Hi Mark,\n\nOn Fri, Oct 27, 2017 at 11:46:00AM +0100, Mark Rutland wrote:\n> On Fri, Oct 27, 2017 at 02:15:03PM +0800, Kaihua Zhong wrote:\n> > Hi3660 mailbox controller is used to send message within multiple\n> > processors, MCU, HIFI, etc.  It supports 32 mailbox channels and every\n> > channel can only be used for single transferring direction.  Once the\n> > channel is enabled, it needs to specify the destination interrupt and\n> > acknowledge interrupt, these two interrupt vectors are used to create\n> > the connection between the mailbox and interrupt controllers.\n> > \n> > The application processor (or from point of view of kernel) is not the\n> > only one master which can launch the data transferring, other\n> > processors or MCU/DSP also can kick off the data transferring.  So this\n> > driver implements a locking mechanism to support exclusive accessing.\n> \n> ... and that locking mechanism is what precisely?\n> \n> Where is the protocol defined?\n> \n> > +static int hi3660_mbox_check_state(struct mbox_chan *chan)\n> > +{\n> > +\tunsigned long ch = (unsigned long)chan->con_priv;\n> > +\tstruct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n> > +\tstruct hi3660_mbox_dev *mdev = &mbox->mdev[ch];\n> > +\tvoid __iomem *base = MBOX_BASE(mbox, ch);\n> > +\tunsigned long val;\n> > +\tunsigned int state, ret;\n> > +\n> > +\t/* Mailbox is idle so directly bail out */\n> > +\tstate = readl_relaxed(base + MBOX_MODE_REG);\n> > +\tif (state & MBOX_STATE_IDLE)\n> > +\t\treturn 0;\n> > +\n> > +\t/* Wait for acknowledge from remote */\n> > +\tret = readx_poll_timeout_atomic(readl_relaxed, base + MBOX_MODE_REG,\n> > +\t\t\tval, (val & MBOX_STATE_ACK), 1000, 300000);\n> > +\tif (ret) {\n> > +\t\tdev_err(mbox->dev, \"%s: timeout for receiving ack\\n\", __func__);\n> > +\t\treturn ret;\n> > +\t}\n> > +\n> > +\t/* Ensure channel is released */\n> > +\twritel_relaxed(0xffffffff, base + MBOX_IMASK_REG);\n> > +\twritel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n> > +\t__asm__ volatile (\"sev\");\n> > +\treturn 0;\n> > +}\n> \n> Drivers really shouldn't be using SEV directly (even if via the sev() macro)...\n> \n> This SEV isn't ordered w.r.t. anything, and it's unclear what ordering you\n> need, so this simply does not work.\n\nI will leave your questions for Hisilicon colleagues, essentially\nyour questions are related with mailbox mechanism.\n\nBut I'd like to firstly get clear your question for \"This SEV isn't\nordered w.r.t. anything\". From my understanding, ARMv8 architecture\nnatually adds DMB before SEV so all previous register writing\nopreations should be ensured to endpoint before SEV?\n\n[...]\n\nThanks,\nLeo Yan","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"dpF9n8ym\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"UYR4O14x\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yQMPP5PT4z9t3Z\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon, 30 Oct 2017 15:45:53 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e91xM-0006Be-AL; Mon, 30 Oct 2017 04:45:48 +0000","from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e91xH-00068a-NC for linux-arm-kernel@lists.infradead.org;\n\tMon, 30 Oct 2017 04:45:46 +0000","by mail-wm0-x244.google.com with SMTP id m72so13201425wmc.1\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tSun, 29 Oct 2017 21:45:21 -0700 (PDT)","from leoy-ThinkPad-T440 (li1530-42.members.linode.com.\n\t[139.162.245.42]) by smtp.gmail.com with ESMTPSA id\n\th66sm3637174wmd.11.2017.10.29.21.45.13\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tSun, 29 Oct 2017 21:45:18 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=RrPnJsH1nnl7qw6HssOlrM7vz6nKAnP5Yx5c2BnRSKo=;\n\tb=dpF9n8ym6+RhMQ\n\tfG0LCOs+ILDXSXwLC/4e7Cm7GJYCnJp2EVyeI8C06wj4sPegjKFlcvFiVLS83WYt9txNtWUymMLgH\n\ttghWotumxhLwLGaboJnU0c5ebKQCxQi3SZ7xWvOWSR2hVBk8ZLQTzFhcOa0a4TR4KZcMx3gTtwO+R\n\tpw/Dr+68JhSN2xCfeHufSdwNcTrM6xF4YjSEbxXW1NAq5CAaWfbkFdHZwb1J4OJxRbxZ9na7TU8YI\n\t8NPM8j/RLnXW7ApBNgUA0/a35AvOlegJ7tYkL21sNOzCHeewkT5qtMLfqHKlpfQyM3WBgYefS8lMB\n\t99fwQaEQuHF7v3wItaEQ==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:in-reply-to:user-agent;\n\tbh=9es4clMr1pSx9mQQITN7FhPRpPc/QAjvuokKWitan80=;\n\tb=UYR4O14x+zwj2OkzrFDq4xfJ/KkOVtTFcfrXEA3WMI7LNQSp+xupzz+IgVfL+AlaXF\n\tpcgWbARqllDrLa/wy3tP3y3D6yVDwWFXg2eoybPogUVu30LyHGUiMrksu4Rau9DsWxB4\n\tThAFQdSkBDnxvwF9h+sUzCbpBOWL8H1g5Q0No="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to:user-agent;\n\tbh=9es4clMr1pSx9mQQITN7FhPRpPc/QAjvuokKWitan80=;\n\tb=fuPSnw3AORyzDPJTti6kxXActzWqNmk85gtnzsCikfzUSle4U7G7kyPzUpZk/pEaff\n\tj+56PWMMTjuO+voKYg1JVj5AoVyl75cIFtedGWbrTTQrdeLw80pM4rfdZyEKhJQ7xoVn\n\tXBf+BjpAK8cLyu4Ii2c6rOgfgCwWhdMmIHkF/DPSSFKOVThpktYRbJl8l8Oifx5Yr+KW\n\tclpN4/NjW03sGS+UQErvEwGJ3F5PZJ8kkyfwi6n6DTIiyHZnz5JGwHLrkH1IQTgV8Kav\n\tkZW1FsZbreI1Q0/U5A5NhRLlp4HqmE/m9l6S9ESG/KCfEkxihEiqMu78qNjmWccF9els\n\tDdgw==","X-Gm-Message-State":"AMCzsaXp8BOMBggu/WiJTOg8QI1nyPVpEbNrSWYjudlAqXy4GByJl3q9\n\tVaDfiXR3nSJgwmge23iGMvzVow==","X-Google-Smtp-Source":"ABhQp+QHQilRitIAkF77kN3qDMOzdBYK7N4LnC2OPO9QD+AmMMQ4QHScuG8ZT2ZsCmHYYRa0tkiDLg==","X-Received":"by 10.28.64.198 with SMTP id n189mr2347846wma.0.1509338719699;\n\tSun, 29 Oct 2017 21:45:19 -0700 (PDT)","Date":"Mon, 30 Oct 2017 12:45:06 +0800","From":"Leo Yan <leo.yan@linaro.org>","To":"Mark Rutland <mark.rutland@arm.com>","Subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","Message-ID":"<20171030044506.GE31478@leoy-ThinkPad-T440>","References":"<1509084904-2505-1-git-send-email-zhongkaihua@huawei.com>\n\t<1509084904-2505-3-git-send-email-zhongkaihua@huawei.com>\n\t<20171027104559.em5n5ogro46ethmq@salmiak>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20171027104559.em5n5ogro46ethmq@salmiak>","User-Agent":"Mutt/1.5.21 (2010-09-15)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171029_214543_943099_05CB5C78 ","X-CRM114-Status":"GOOD (  20.17  )","X-Spam-Score":"-2.0 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno\n\ttrust [2a00:1450:400c:c09:0:0:0:244 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"xuezhiliang@hisilicon.com, devicetree@vger.kernel.org,\n\tguodong.xu@linaro.org, catalin.marinas@arm.com,\n\tsuzhuangluan@hisilicon.com, \n\tjassisinghbrar@gmail.com, will.deacon@arm.com,\n\tlinux-kernel@vger.kernel.org, xuwei5@hisilicon.com, robh+dt@kernel.org,\n\tKaihua Zhong <zhongkaihua@huawei.com>, haojian.zhuang@linaro.org,\n\tkevin.wangtao@hisilicon.com, linux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1795805,"web_url":"http://patchwork.ozlabs.org/comment/1795805/","msgid":"<20171030101940.dtf6rw7alhkn6irf@lakrids.cambridge.arm.com>","list_archive_url":null,"date":"2017-10-30T10:19:40","subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","submitter":{"id":8806,"url":"http://patchwork.ozlabs.org/api/people/8806/","name":"Mark Rutland","email":"mark.rutland@arm.com"},"content":"Hi,\n\nOn Mon, Oct 30, 2017 at 12:45:06PM +0800, Leo Yan wrote:\n> On Fri, Oct 27, 2017 at 11:46:00AM +0100, Mark Rutland wrote:\n> > On Fri, Oct 27, 2017 at 02:15:03PM +0800, Kaihua Zhong wrote:\n> > > +static int hi3660_mbox_check_state(struct mbox_chan *chan)\n> > > +{\n\n> > > +\t/* Ensure channel is released */\n> > > +\twritel_relaxed(0xffffffff, base + MBOX_IMASK_REG);\n> > > +\twritel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n> > > +\t__asm__ volatile (\"sev\");\n> > > +\treturn 0;\n> > > +}\n> > \n> > Drivers really shouldn't be using SEV directly (even if via the\n> > sev() macro)...\n> > \n> > This SEV isn't ordered w.r.t. anything, and it's unclear what\n> > ordering you need, so this simply does not work.\n> \n> I will leave your questions for Hisilicon colleagues, essentially your\n> questions are related with mailbox mechanism.\n> \n> But I'd like to firstly get clear your question for \"This SEV isn't\n> ordered w.r.t. anything\". From my understanding, ARMv8 architecture\n> natually adds DMB before SEV so all previous register writing\n> opreations should be ensured to endpoint before SEV?\n\nThis is not the case; SEV does not add any implicit memory barrier, and\nis not ordered w.r.t. memory accesses.\n\nSee ARM DDI 0487B.b, page D1-1905, \"The Send Event instructions\":\n\n    The PE is not required to guarantee the ordering of this event with\n    respect to the completion of memory accesses by instructions before\n    the SEV instruction. Therefore, ARM recommends that software\n    includes a DSB instruction before any SEV instruction.\n\nNote that a DMB is not sufficient, as SEV is not a memory access.\n\nThanks,\nMark.","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"kSB8SvcZ\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yQVq22Bvpz9t2t\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon, 30 Oct 2017 21:20:14 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e97Ax-0004yZ-VO; Mon, 30 Oct 2017 10:20:11 +0000","from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]\n\thelo=foss.arm.com)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e97Av-0003kK-01 for linux-arm-kernel@lists.infradead.org;\n\tMon, 30 Oct 2017 10:20:10 +0000","from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249])\n\tby usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 613921596;\n\tMon, 30 Oct 2017 03:19:48 -0700 (PDT)","from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com\n\t[10.72.51.249])\n\tby usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id\n\tD70383F483; Mon, 30 Oct 2017 03:19:45 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=wtJQGfb2SBtalC6fkhQ1oMVde6cXi3SQlW1o8PkNKIQ=;\n\tb=kSB8SvcZ3F/XdA\n\tljdjb5jetysy+rjCVC0CvE3Zk2aF8hvLRo9dxq/ORZSJ0H0DFSYroTHvqXxv1N/Gt7PBmyMeFACJn\n\tM67FODfZMg0ihD8dsHRZVbJ0fcuMZTSOVkgg/iQAAlhwIQN8QG1rF/LQMZTa64A9Be/512g2GxYIl\n\tbxkxBLLw1qjluPZiaFRjLrynFDCzYLvUd8AuTJihkNdwXdlmPdQSI5ONecKmomqTcxqemUILSdrSo\n\t5fybwZxWaU6Mk7jDdjP4h2gBWybQ8LjKqwi6wjK5FzS3xdRzcZCYavrw2NaskJEQ8aJta/SaZZr19\n\t0uHkxDejUUT4cjtgD1jw==;","Date":"Mon, 30 Oct 2017 10:19:40 +0000","From":"Mark Rutland <mark.rutland@arm.com>","To":"Leo Yan <leo.yan@linaro.org>","Subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","Message-ID":"<20171030101940.dtf6rw7alhkn6irf@lakrids.cambridge.arm.com>","References":"<1509084904-2505-1-git-send-email-zhongkaihua@huawei.com>\n\t<1509084904-2505-3-git-send-email-zhongkaihua@huawei.com>\n\t<20171027104559.em5n5ogro46ethmq@salmiak>\n\t<20171030044506.GE31478@leoy-ThinkPad-T440>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20171030044506.GE31478@leoy-ThinkPad-T440>","User-Agent":"NeoMutt/20170113 (1.7.2)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171030_032009_058772_18BA874F ","X-CRM114-Status":"GOOD (  12.34  )","X-Spam-Score":"-6.9 (------)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-6.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/,\n\thigh trust [217.140.101.70 listed in list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"xuezhiliang@hisilicon.com, devicetree@vger.kernel.org,\n\tguodong.xu@linaro.org, catalin.marinas@arm.com,\n\tsuzhuangluan@hisilicon.com, \n\tjassisinghbrar@gmail.com, will.deacon@arm.com,\n\tlinux-kernel@vger.kernel.org, xuwei5@hisilicon.com, robh+dt@kernel.org,\n\tKaihua Zhong <zhongkaihua@huawei.com>, haojian.zhuang@linaro.org,\n\tkevin.wangtao@hisilicon.com, linux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1795838,"web_url":"http://patchwork.ozlabs.org/comment/1795838/","msgid":"<20171030111313.GF31478@leoy-ThinkPad-T440>","list_archive_url":null,"date":"2017-10-30T11:13:13","subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","submitter":{"id":66057,"url":"http://patchwork.ozlabs.org/api/people/66057/","name":"Leo Yan","email":"leo.yan@linaro.org"},"content":"Hi Mark,\n\nOn Mon, Oct 30, 2017 at 10:19:40AM +0000, Mark Rutland wrote:\n> Hi,\n> \n> On Mon, Oct 30, 2017 at 12:45:06PM +0800, Leo Yan wrote:\n> > On Fri, Oct 27, 2017 at 11:46:00AM +0100, Mark Rutland wrote:\n> > > On Fri, Oct 27, 2017 at 02:15:03PM +0800, Kaihua Zhong wrote:\n> > > > +static int hi3660_mbox_check_state(struct mbox_chan *chan)\n> > > > +{\n> \n> > > > +\t/* Ensure channel is released */\n> > > > +\twritel_relaxed(0xffffffff, base + MBOX_IMASK_REG);\n> > > > +\twritel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n> > > > +\t__asm__ volatile (\"sev\");\n> > > > +\treturn 0;\n> > > > +}\n> > > \n> > > Drivers really shouldn't be using SEV directly (even if via the\n> > > sev() macro)...\n> > > \n> > > This SEV isn't ordered w.r.t. anything, and it's unclear what\n> > > ordering you need, so this simply does not work.\n> > \n> > I will leave your questions for Hisilicon colleagues, essentially your\n> > questions are related with mailbox mechanism.\n> > \n> > But I'd like to firstly get clear your question for \"This SEV isn't\n> > ordered w.r.t. anything\". From my understanding, ARMv8 architecture\n> > natually adds DMB before SEV so all previous register writing\n> > opreations should be ensured to endpoint before SEV?\n> \n> This is not the case; SEV does not add any implicit memory barrier, and\n> is not ordered w.r.t. memory accesses.\n> \n> See ARM DDI 0487B.b, page D1-1905, \"The Send Event instructions\":\n> \n>     The PE is not required to guarantee the ordering of this event with\n>     respect to the completion of memory accesses by instructions before\n>     the SEV instruction. Therefore, ARM recommends that software\n>     includes a DSB instruction before any SEV instruction.\n\nMy fault and thanks for explanation.\n\n> Note that a DMB is not sufficient, as SEV is not a memory access.\n\nUnderstood now, so below code should be safe?\n\nwmb();  -> dsb(st);\nsev();\n\nThanks,\nLeo Yan","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"cHxN3myt\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"WS+TuVK3\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yQX144JBKz9t3R\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon, 30 Oct 2017 22:14:00 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e9811-0004bb-3e; Mon, 30 Oct 2017 11:13:59 +0000","from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e980s-0004L2-Kh for linux-arm-kernel@lists.infradead.org;\n\tMon, 30 Oct 2017 11:13:56 +0000","by mail-wm0-x242.google.com with SMTP id r196so15102392wmf.2\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tMon, 30 Oct 2017 04:13:28 -0700 (PDT)","from leoy-ThinkPad-T440 (li1530-42.members.linode.com.\n\t[139.162.245.42]) by smtp.gmail.com with ESMTPSA id\n\tf132sm3349196wmf.38.2017.10.30.04.13.20\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tMon, 30 Oct 2017 04:13:24 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=q2J+B6zDEngaFb3g+xFycWe7MHMM0DWTsX/xFNHCuo0=;\n\tb=cHxN3myt4/IF+K\n\tiS/hYHBgIdp3jNITz7YeiQ7EfwehgvshKdu524lH35eIBFjESiDv7UFw8wUT50L/bI9hFcSPBV7jx\n\tilHkPxw6bcp7FzjFehrLZ0JfeYp9HAl6A1GC61vtR1kGNhLeDmOMc2btqHnxL7hMF7JLcDlh5Ffvv\n\tJ1mrGXNwTnY9uEVQZNVrtM3mw6m8q1qKScVYYo7oeeHIbvbBkEMafswq4cp6g7qJozK+TQ6dPNGRi\n\tGKPMvPOtbYDLCIiEBqZARw6hlAwaviVyk6GY0SyiQcKDDxqdndgE/yDroxXXoqOAKA7lF5W+52FeS\n\t1OxEDbu/XqdGqm1NR4sg==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:in-reply-to:user-agent;\n\tbh=ZsYkx3yMOjbMcSi10bBcynX8Y2Ofn+deAtAiLk6U+0c=;\n\tb=WS+TuVK35DHjUwde2yj+hNPsfxcSmhBiINai5xxwcTlH1s+KtvP9B0ndIdzOXkxyRI\n\tESH8P5aIZC+RuT2Bz+4REnYwYrNThReRNMg1jyPDLMUOugl50CLL61rvAPTyKw5n8iVI\n\t240XDuufFQ0I1WkGxGQDXDc4VA/XFiBpILX4I="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to:user-agent;\n\tbh=ZsYkx3yMOjbMcSi10bBcynX8Y2Ofn+deAtAiLk6U+0c=;\n\tb=Z8YHsvH7pqKon561Zh4LuyGasBxAb7wxY0qEuxVEECgvzhiWLJVd2rU6OinVRMl5Sv\n\t6Wf94kwUY2bayLuaYfW63ZN/myoni12PUSQDZKhwSYLZcgmCQiDqIem9GMc8t4w7f7lt\n\tz2zr41BeAN25kP9ZtijwP3Lmykv0rMyaM5QhK0Ed3pyH+kPnMwI8xiKhqqnUe/CGxPCP\n\tEUzR6nQRTSiMkUvREc1Pn5dNm2+FWR+MRkUH6N9HF/pW/iiIB7hsNNVCnc8/3JGOlJjL\n\t/VxWS9KJH1fxreSxiEYqP+0MU2VWBSRVbF9svnWGjWhG50J3CNh+w4K6V06b2YnQx7yf\n\tWoJg==","X-Gm-Message-State":"AMCzsaWgYOYAqMa+9cTnNb9Bax1xjK/8doJ/nj3MNqa1y+MI1qRcuRb9\n\t2nSD62qpLFdPIFJrXRwi7az9Hg==","X-Google-Smtp-Source":"ABhQp+TGezso5M/sD90tiaQIPD/ycacv1SDxoJTLIuQKkC/ePGHZLG7JEc6hn884mn7G4rj0ciLaBw==","X-Received":"by 10.28.169.21 with SMTP id s21mr3190377wme.87.1509362006407;\n\tMon, 30 Oct 2017 04:13:26 -0700 (PDT)","Date":"Mon, 30 Oct 2017 19:13:13 +0800","From":"Leo Yan <leo.yan@linaro.org>","To":"Mark Rutland <mark.rutland@arm.com>","Subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","Message-ID":"<20171030111313.GF31478@leoy-ThinkPad-T440>","References":"<1509084904-2505-1-git-send-email-zhongkaihua@huawei.com>\n\t<1509084904-2505-3-git-send-email-zhongkaihua@huawei.com>\n\t<20171027104559.em5n5ogro46ethmq@salmiak>\n\t<20171030044506.GE31478@leoy-ThinkPad-T440>\n\t<20171030101940.dtf6rw7alhkn6irf@lakrids.cambridge.arm.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20171030101940.dtf6rw7alhkn6irf@lakrids.cambridge.arm.com>","User-Agent":"Mutt/1.5.21 (2010-09-15)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171030_041350_932638_7AAC90CF ","X-CRM114-Status":"GOOD (  16.64  )","X-Spam-Score":"-2.0 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno\n\ttrust [2a00:1450:400c:c09:0:0:0:242 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"xuezhiliang@hisilicon.com, devicetree@vger.kernel.org,\n\tguodong.xu@linaro.org, catalin.marinas@arm.com,\n\tsuzhuangluan@hisilicon.com, \n\tjassisinghbrar@gmail.com, will.deacon@arm.com,\n\tlinux-kernel@vger.kernel.org, xuwei5@hisilicon.com, robh+dt@kernel.org,\n\tKaihua Zhong <zhongkaihua@huawei.com>, haojian.zhuang@linaro.org,\n\tkevin.wangtao@hisilicon.com, linux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1795851,"web_url":"http://patchwork.ozlabs.org/comment/1795851/","msgid":"<20171030113732.dajsdj3lcm2qjxke@lakrids.cambridge.arm.com>","list_archive_url":null,"date":"2017-10-30T11:37:32","subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","submitter":{"id":8806,"url":"http://patchwork.ozlabs.org/api/people/8806/","name":"Mark Rutland","email":"mark.rutland@arm.com"},"content":"On Mon, Oct 30, 2017 at 07:13:13PM +0800, Leo Yan wrote:\n> Hi Mark,\n> \n> On Mon, Oct 30, 2017 at 10:19:40AM +0000, Mark Rutland wrote:\n> > Hi,\n> > \n> > On Mon, Oct 30, 2017 at 12:45:06PM +0800, Leo Yan wrote:\n> > > On Fri, Oct 27, 2017 at 11:46:00AM +0100, Mark Rutland wrote:\n> > > > On Fri, Oct 27, 2017 at 02:15:03PM +0800, Kaihua Zhong wrote:\n> > > > > +static int hi3660_mbox_check_state(struct mbox_chan *chan)\n> > > > > +{\n> > \n> > > > > +\t/* Ensure channel is released */\n> > > > > +\twritel_relaxed(0xffffffff, base + MBOX_IMASK_REG);\n> > > > > +\twritel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n> > > > > +\t__asm__ volatile (\"sev\");\n> > > > > +\treturn 0;\n> > > > > +}\n> > > > \n> > > > Drivers really shouldn't be using SEV directly (even if via the\n> > > > sev() macro)...\n> > > > \n> > > > This SEV isn't ordered w.r.t. anything, and it's unclear what\n> > > > ordering you need, so this simply does not work.\n> > > \n> > > I will leave your questions for Hisilicon colleagues, essentially your\n> > > questions are related with mailbox mechanism.\n> > > \n> > > But I'd like to firstly get clear your question for \"This SEV isn't\n> > > ordered w.r.t. anything\". From my understanding, ARMv8 architecture\n> > > natually adds DMB before SEV so all previous register writing\n> > > opreations should be ensured to endpoint before SEV?\n> > \n> > This is not the case; SEV does not add any implicit memory barrier, and\n> > is not ordered w.r.t. memory accesses.\n> > \n> > See ARM DDI 0487B.b, page D1-1905, \"The Send Event instructions\":\n> > \n> >     The PE is not required to guarantee the ordering of this event with\n> >     respect to the completion of memory accesses by instructions before\n> >     the SEV instruction. Therefore, ARM recommends that software\n> >     includes a DSB instruction before any SEV instruction.\n> \n> My fault and thanks for explanation.\n> \n> > Note that a DMB is not sufficient, as SEV is not a memory access.\n> \n> Understood now, so below code should be safe?\n> \n> wmb();  -> dsb(st);\n> sev();\n\nWhether that is safe depends on what you are trying to ensure is\nordered, and what the other side (with the WFE) is doing.\n\nFor example, my understanding is that in general, WFE is also not\nordered w.r.t.  memory accesses.\n\nThis is a very subtle part of the architecture, and I'm very much not\nkeen on using WFE and SEV outside of architecture code implementing\nlocking primitives.\n\nThanks,\nMark.","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"d9HWQ/Ey\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yQXXr0GY7z9sRm\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon, 30 Oct 2017 22:38:04 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e98OI-0006Xv-C3; Mon, 30 Oct 2017 11:38:02 +0000","from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]\n\thelo=foss.arm.com)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e98OF-0006VW-5T for linux-arm-kernel@lists.infradead.org;\n\tMon, 30 Oct 2017 11:38:00 +0000","from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249])\n\tby usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C8DDE1529;\n\tMon, 30 Oct 2017 04:37:37 -0700 (PDT)","from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com\n\t[10.72.51.249])\n\tby usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id\n\t1DF1B3F483; Mon, 30 Oct 2017 04:37:34 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=oS4ZpIMTRxDotvY4kKDEoGfUYlH3W6H+EexHmSuknUY=;\n\tb=d9HWQ/EyC8IvGj\n\tYtgkXk7W+mBdXZ82KgHHAwBKdT8O/bORulw7bVjYB81htXwnqEEO+irmxdwUrsRAE/BSPF1M8/9z7\n\trvQpzhq7XRrmU4cxrDHZXPJ1jKcUFuPiKztwKcFwFBFfWETY9/iBU4+Pb78r+vwNEMvW9EVXAw3yE\n\tUpV/o7WhE/x0abr7SesIkp8zN3xXlzZIQKROdfVbaPo85NG326k1JTo6TLXWtPyiOVDJpdNzW8dZA\n\tw8r3qXpp7k4xDFhfFQL9W+W5dcit7zhBu0AXAq9YCI3CpDq8ZstYqpPODa4/3sOm2YE89q5D50I+P\n\tES+bnw/B6qZH8fhOcEkA==;","Date":"Mon, 30 Oct 2017 11:37:32 +0000","From":"Mark Rutland <mark.rutland@arm.com>","To":"Leo Yan <leo.yan@linaro.org>","Subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","Message-ID":"<20171030113732.dajsdj3lcm2qjxke@lakrids.cambridge.arm.com>","References":"<1509084904-2505-1-git-send-email-zhongkaihua@huawei.com>\n\t<1509084904-2505-3-git-send-email-zhongkaihua@huawei.com>\n\t<20171027104559.em5n5ogro46ethmq@salmiak>\n\t<20171030044506.GE31478@leoy-ThinkPad-T440>\n\t<20171030101940.dtf6rw7alhkn6irf@lakrids.cambridge.arm.com>\n\t<20171030111313.GF31478@leoy-ThinkPad-T440>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20171030111313.GF31478@leoy-ThinkPad-T440>","User-Agent":"NeoMutt/20170113 (1.7.2)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171030_043759_221053_F0060E68 ","X-CRM114-Status":"GOOD (  18.67  )","X-Spam-Score":"-6.9 (------)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-6.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/,\n\thigh trust [217.140.101.70 listed in list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"xuezhiliang@hisilicon.com, devicetree@vger.kernel.org,\n\tguodong.xu@linaro.org, catalin.marinas@arm.com,\n\tsuzhuangluan@hisilicon.com, \n\tjassisinghbrar@gmail.com, will.deacon@arm.com,\n\tlinux-kernel@vger.kernel.org, xuwei5@hisilicon.com, robh+dt@kernel.org,\n\tKaihua Zhong <zhongkaihua@huawei.com>, haojian.zhuang@linaro.org,\n\tkevin.wangtao@hisilicon.com, linux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1797766,"web_url":"http://patchwork.ozlabs.org/comment/1797766/","msgid":"<59FAE221.3080600@huawei.com>","list_archive_url":null,"date":"2017-11-02T09:15:13","subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","submitter":{"id":67537,"url":"http://patchwork.ozlabs.org/api/people/67537/","name":"Kaihua Zhong","email":"zhongkaihua@huawei.com"},"content":"Hi, Julien,\n\nOn 2017/10/27 18:40, Julien Thierry wrote:\n> Hi Kaihua,\n> \n> On 27/10/17 07:15, Kaihua Zhong wrote:\n>> Hi3660 mailbox controller is used to send message within multiple\n>> processors, MCU, HIFI, etc.  It supports 32 mailbox channels and every\n>> channel can only be used for single transferring direction.  Once the\n>> channel is enabled, it needs to specify the destination interrupt and\n>> acknowledge interrupt, these two interrupt vectors are used to create\n>> the connection between the mailbox and interrupt controllers.\n>>\n>> The application processor (or from point of view of kernel) is not the\n>> only one master which can launch the data transferring, other\n>> processors or MCU/DSP also can kick off the data transferring.  So this\n>> driver implements a locking mechanism to support exclusive accessing.\n>>\n>> The data transferring supports two modes, one is named as \"automatic\n>> acknowledge\" mode so after send message the kernel doesn't need to wait\n>> for acknowledge from remote and directly return; there have another mode\n>> is to rely on handling interrupt for acknowledge.\n>>\n>> This commit is for initial version driver, which only supports\n>> \"automatic acknowledge\" mode to support CPU clock, which is the only\n>> one consumer to use mailbox and has been verified.  Later may enhance\n>> this driver for interrupt mode (e.g. for supporting HIFI).\n>>\n>> Cc: John Stultz <john.stultz@linaro.org>\n>> Cc: Guodong Xu <guodong.xu@linaro.org>\n>> Cc: Haojian Zhuang <haojian.zhuang@linaro.org>\n>> Cc: Niranjan Yadla <nyadla@cadence.com>\n>> Cc: Raj Pawate <pawateb@cadence.com>\n>> Signed-off-by: Leo Yan <leo.yan@linaro.org>\n>> Signed-off-by: Ruyi Wang <wangruyi@huawei.com>\n>> Signed-off-by: Kaihua Zhong <zhongkaihua@huawei.com>\n>> Signed-off-by: Kevin Wang <kevin.wangtao@hisilicon.com>\n>> ---\n>>   drivers/mailbox/Kconfig          |   8 +\n>>   drivers/mailbox/Makefile         |   2 +\n>>   drivers/mailbox/hi3660-mailbox.c | 331 +++++++++++++++++++++++++++++++++++++++\n>>   3 files changed, 341 insertions(+)\n>>   create mode 100644 drivers/mailbox/hi3660-mailbox.c\n>>\n>> diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig\n>> index c5731e5..4b5d6e9 100644\n>> --- a/drivers/mailbox/Kconfig\n>> +++ b/drivers/mailbox/Kconfig\n>> @@ -108,6 +108,14 @@ config TI_MESSAGE_MANAGER\n>>         multiple processors within the SoC. Select this driver if your\n>>         platform has support for the hardware block.\n>>   +config HI3660_MBOX\n>> +    tristate \"Hi3660 Mailbox\"\n>> +    depends on ARCH_HISI && OF\n>> +    help\n>> +      An implementation of the hi3660 mailbox. It is used to send message\n>> +      between application processors and other processors/MCU/DSP. Select\n>> +      Y here if you want to use Hi3660 mailbox controller.\n>> +\n>>   config HI6220_MBOX\n>>       tristate \"Hi6220 Mailbox\"\n>>       depends on ARCH_HISI\n>> diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile\n>> index d54e412..7d1bd51 100644\n>> --- a/drivers/mailbox/Makefile\n>> +++ b/drivers/mailbox/Makefile\n>> @@ -26,6 +26,8 @@ obj-$(CONFIG_TI_MESSAGE_MANAGER) += ti-msgmgr.o\n>>     obj-$(CONFIG_XGENE_SLIMPRO_MBOX) += mailbox-xgene-slimpro.o\n>>   +obj-$(CONFIG_HI3660_MBOX)    += hi3660-mailbox.o\n>> +\n>>   obj-$(CONFIG_HI6220_MBOX)    += hi6220-mailbox.o\n>>     obj-$(CONFIG_BCM_PDC_MBOX)    += bcm-pdc-mailbox.o\n>> diff --git a/drivers/mailbox/hi3660-mailbox.c b/drivers/mailbox/hi3660-mailbox.c\n>> new file mode 100644\n>> index 0000000..67df8f8\n>> --- /dev/null\n>> +++ b/drivers/mailbox/hi3660-mailbox.c\n>> @@ -0,0 +1,331 @@\n>> +/*\n>> + * Hisilicon's Hi3660 mailbox controller driver\n>> + *\n>> + * Copyright (c) 2017 Hisilicon Limited.\n>> + * Copyright (c) 2017 Linaro Limited.\n>> + *\n>> + * Author: Leo Yan <leo.yan@linaro.org>\n>> + *\n>> + * This program is free software: you can redistribute it and/or modify\n>> + * it under the terms of the GNU General Public License as published by\n>> + * the Free Software Foundation, version 2 of the License.\n>> + *\n>> + * This program is distributed in the hope that it will be useful,\n>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of\n>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n>> + * GNU General Public License for more details.\n>> + *\n>> + */\n>> +\n>> +#include <linux/bitops.h>\n>> +#include <linux/delay.h>\n>> +#include <linux/device.h>\n>> +#include <linux/err.h>\n>> +#include <linux/interrupt.h>\n>> +#include <linux/io.h>\n>> +#include <linux/iopoll.h>\n>> +#include <linux/mailbox_controller.h>\n>> +#include <linux/module.h>\n>> +#include <linux/platform_device.h>\n>> +#include <linux/slab.h>\n>> +\n>> +#include \"mailbox.h\"\n>> +\n>> +#define MBOX_CHAN_MAX            32\n>> +\n>> +#define MBOX_RX                (0x0)\n>> +#define MBOX_TX                (0x1)\n>> +\n>> +#define MBOX_BASE(mbox, ch)        ((mbox)->base + ((ch) * 0x40))\n>> +#define MBOX_SRC_REG            (0x00)\n>> +#define MBOX_DST_REG            (0x04)\n>> +#define MBOX_DCLR_REG            (0x08)\n>> +#define MBOX_DSTAT_REG            (0x0c)\n>> +#define MBOX_MODE_REG            (0x10)\n>> +#define MBOX_IMASK_REG            (0x14)\n>> +#define MBOX_ICLR_REG            (0x18)\n>> +#define MBOX_SEND_REG            (0x1c)\n>> +#define MBOX_DATA_REG            (0x20)\n>> +\n>> +#define MBOX_IPC_LOCK_REG        (0xa00)\n>> +#define MBOX_IPC_UNLOCK            (0x1acce551)\n>> +\n>> +#define MBOX_AUTOMATIC_ACK        (1)\n>> +\n>> +#define MBOX_STATE_IDLE            BIT(4)\n>> +#define MBOX_STATE_ACK            BIT(7)\n>> +\n>> +#define MBOX_MSG_LEN            8\n>> +\n>> +/**\n>> + * Hi3660 mailbox channel device data\n>> + *\n>> + * A channel can be used for TX or RX, it can trigger remote\n>> + * processor interrupt to notify remote processor and can receive\n>> + * interrupt if has incoming message.\n>> + *\n>> + * @dst_irq:    Interrupt vector for remote processor\n>> + * @ack_irq:    Interrupt vector for local processor\n>> + */\n>> +struct hi3660_mbox_dev {\n>> +    unsigned int dst_irq;\n>> +    unsigned int ack_irq;\n>> +};\n>> +\n>> +/**\n>> + * Hi3660 mailbox controller data\n>> + *\n>> + * Mailbox controller includes 32 channels and can allocate\n>> + * channel for message transferring.\n>> + *\n>> + * @dev:    Device to which it is attached\n>> + * @base:    Base address of the register mapping region\n>> + * @chan:    Representation of channels in mailbox controller\n>> + * @mdev:    Representation of channel device data\n>> + * @controller:    Representation of a communication channel controller\n>> + */\n>> +struct hi3660_mbox {\n>> +    struct device *dev;\n>> +    void __iomem *base;\n>> +    struct mbox_chan chan[MBOX_CHAN_MAX];\n>> +    struct hi3660_mbox_dev mdev[MBOX_CHAN_MAX];\n>> +    struct mbox_controller controller;\n>> +};\n>> +\n>> +static inline struct hi3660_mbox *to_hi3660_mbox(struct mbox_chan *chan)\n>> +{\n>> +    return container_of(chan->mbox, struct hi3660_mbox, controller);\n>> +}\n>> +\n>> +static int hi3660_mbox_check_state(struct mbox_chan *chan)\n>> +{\n>> +    unsigned long ch = (unsigned long)chan->con_priv;\n>> +    struct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n>> +    struct hi3660_mbox_dev *mdev = &mbox->mdev[ch];\n>> +    void __iomem *base = MBOX_BASE(mbox, ch);\n>> +    unsigned long val;\n>> +    unsigned int state, ret;\n>> +\n>> +    /* Mailbox is idle so directly bail out */\n>> +    state = readl_relaxed(base + MBOX_MODE_REG);\n>> +    if (state & MBOX_STATE_IDLE)\n>> +        return 0;\n>> +\n>> +    /* Wait for acknowledge from remote */\n>> +    ret = readx_poll_timeout_atomic(readl_relaxed, base + MBOX_MODE_REG,\n>> +            val, (val & MBOX_STATE_ACK), 1000, 300000);\n>> +    if (ret) {\n>> +        dev_err(mbox->dev, \"%s: timeout for receiving ack\\n\", __func__);\n>> +        return ret;\n>> +    }\n>> +\n>> +    /* Ensure channel is released */\n>> +    writel_relaxed(0xffffffff, base + MBOX_IMASK_REG);\n>> +    writel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n>> +    __asm__ volatile (\"sev\");\n> \n> There is an existing sev() macro for this.\n> \nMacro will be used in next patch，if this function is not redesigned.\nMark and Leo is discussing memory barrier protection issues.\n\n>> +    return 0;\n>> +}\n>> +\n>> +static int hi3660_mbox_unlock(struct mbox_chan *chan)\n>> +{\n>> +    struct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n>> +    unsigned int val, retry = 3;\n>> +\n>> +    do {\n>> +        writel_relaxed(MBOX_IPC_UNLOCK, mbox->base + MBOX_IPC_LOCK_REG);\n>> +\n>> +        val = readl_relaxed(mbox->base + MBOX_IPC_LOCK_REG);\n>> +        if (!val)\n>> +            break;\n>> +\n>> +        udelay(10);\n>> +    } while (retry--);\n>> +\n>> +    return (!val) ? 0 : -ETIMEDOUT;\n>> +}\n>> +\n>> +static int hi3660_mbox_acquire_channel(struct mbox_chan *chan)\n>> +{\n>> +    unsigned long ch = (unsigned long)chan->con_priv;\n>> +    struct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n>> +    struct hi3660_mbox_dev *mdev = &mbox->mdev[ch];\n>> +    void __iomem *base = MBOX_BASE(mbox, ch);\n>> +    unsigned int val = 0, retry = 10;\n>> +\n>> +    /*\n>> +     * Hardware locking for exclusive accessing within CPUs\n>> +     * without exclusive monitor mechanism.\n>> +     */\n>> +    do {\n>> +        val = readl_relaxed(base + MBOX_MODE_REG);\n>> +        if (!(val & MBOX_STATE_IDLE)) {\n>> +            __asm__ volatile (\"wfe\");\n>> +            continue;\n> \n> So this is going to \"wfe\" when retry == 0 and the continue statement will take us out of the loop?\n> \n> Also, there is a wfe() macro for arm and arm64 which could be used here.\n> \n>> +        }\n>> +\n>> +        /* Check if channel has be acquired */\n>> +        writel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG);\n>> +        val = readl_relaxed(base + MBOX_SRC_REG) & BIT(mdev->ack_irq);\n>> +        if (val)\n>> +            break;\n>> +\n>> +    } while (retry--);\n>> +\n>> +    return (val) ? 0 : -ETIMEDOUT;\n> \n> If timeout occurs while waiting for the MBOX to be idle, val will hold the last value from MBOX_MODE_REG, and if this can be different than 0, this will hide the fact it timed out.\n> \n> Maybe the following would be more appropriate:\n> \n> return (retry >= 0) ? 0 : -ETIMEDOUT;\n> \n> Also, your do {} while loops for the timeouts falsely give the impression we do \"retry\" attempts when we actually do \"retry + 1\" attempts (but I guess it doesn't make a big difference from the functional point of view).\n> \n\nAgreed. The current logic of code is confusing as val is used twice.\n\n>> +}\n>> +\n>> +static int hi3660_mbox_send(struct mbox_chan *chan, u32 *msg)\n>> +{\n>> +    unsigned long ch = (unsigned long)chan->con_priv;\n>> +    struct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n>> +    struct hi3660_mbox_dev *mdev = &mbox->mdev[ch];\n>> +    void __iomem *base = MBOX_BASE(mbox, ch);\n>> +    unsigned int i;\n>> +\n>> +    /* Clear mask for destination interrupt */\n>> +    writel_relaxed(~BIT(mdev->dst_irq), base + MBOX_IMASK_REG);\n>> +\n>> +    /* Config destination for interrupt vector */\n>> +    writel_relaxed(BIT(mdev->dst_irq), base + MBOX_DST_REG);\n>> +\n>> +    /* Automatic acknowledge mode */\n>> +    writel_relaxed(MBOX_AUTOMATIC_ACK, base + MBOX_MODE_REG);\n>> +\n>> +    /* Fill message data */\n>> +    for (i = 0; i < MBOX_MSG_LEN; i++)\n>> +        writel_relaxed(msg[i], base + MBOX_DATA_REG + i * 4);\n>> +\n>> +    /* Trigger data transferring */\n>> +    writel_relaxed(BIT(mdev->ack_irq), base + MBOX_SEND_REG);\n>> +    return 0;\n>> +}\n>> +\n>> +static int hi3660_mbox_send_data(struct mbox_chan *chan, void *msg)\n>> +{\n>> +    struct hi3660_mbox *mbox = to_hi3660_mbox(chan);\n>> +    int err;\n>> +\n>> +    err = hi3660_mbox_check_state(chan);\n>> +    if (err) {\n>> +        dev_err(mbox->dev, \"checking state failed\\n\");\n>> +        return err;\n>> +    }\n>> +\n>> +    err = hi3660_mbox_unlock(chan);\n>> +    if (err) {\n>> +        dev_err(mbox->dev, \"unlocking mailbox failed\\n\");\n>> +        return err;\n>> +    }\n>> +\n>> +    err = hi3660_mbox_acquire_channel(chan);\n>> +    if (err) {\n>> +        dev_err(mbox->dev, \"acquiring channel failed\\n\");\n>> +        return err;\n>> +    }\n>> +\n>> +    return hi3660_mbox_send(chan, msg);\n>> +}\n>> +\n>> +static struct mbox_chan_ops hi3660_mbox_ops = {\n>> +    .send_data    = hi3660_mbox_send_data,\n>> +};\n>> +\n>> +static struct mbox_chan *hi3660_mbox_xlate(struct mbox_controller *controller,\n>> +                       const struct of_phandle_args *spec)\n>> +{\n>> +    struct hi3660_mbox *mbox = dev_get_drvdata(controller->dev);\n> \n> nit:\n> In to_hi3660_mbox, you use the fact that the mbox_controller structure is part of hi3660_mbox and use container of to retrieve hi3660_mbox.\n> \n> I think it would be nice to be consistent about this, either use container_of or dev drvdata, but not both.\n> \n> Cheers,\n> \nI will discuss with Leo.\n\nThanks for your comments.\n\nBest Regards,","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"AUtW407N\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3ySKg1367Nz9sRg\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tThu,  2 Nov 2017 20:34:37 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1eABtU-0002OA-1V; Thu, 02 Nov 2017 09:34:36 +0000","from szxga05-in.huawei.com ([45.249.212.191])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1eABgE-0003Ek-Su for linux-arm-kernel@lists.infradead.org;\n\tThu, 02 Nov 2017 09:21:04 +0000","from 172.30.72.60 (EHLO DGGEMS401-HUB.china.huawei.com)\n\t([172.30.72.60])\n\tby dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued)\n\twith ESMTP id DKG94079; Thu, 02 Nov 2017 17:17:09 +0800 (CST)","from [127.0.0.1] (10.142.146.73) by DGGEMS401-HUB.china.huawei.com\n\t(10.3.19.201) with Microsoft SMTP Server id 14.3.361.1;\n\tThu, 2 Nov 2017 17:16:45 +0800"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:References:Subject:To:\n\tMIME-Version:From:Date:Message-ID:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=5sfKhf98IYzoTmVAB1DBsSSoQqMm8lt01KeZGh0nT0k=;\n\tb=AUtW407NEjvSAK\n\tOtFUJOYHmwt4LkWNwbqDv73BrMCw9DvttGRS6Z+PNQLSWNgQYHOz+KI5fxU9HRMWeFMQu95aKtzVH\n\tVdGaBz5/AA39IJb8PCltLwSRKxYwtk7o8euc1gmFzK5ytFQf1E7VHFmQcVctThamlmVqy9tmQsz0r\n\tBsLedLJ+HuePGkCVaXolM6NQQbnx/RYvUOhKcDVTkFWwgl+cJbebrCgdL76ZtO0KnGGddqPG6aTC1\n\tsCtBG7FXDeT3xCxBT67BI9bxPOuwb57zYP5c2j7omCejF+Huf30Yli8zHXpyP6Y6TuIkQBoNhMUFK\n\tmk2a+wu+kNDKhN3pR5Mg==;","Message-ID":"<59FAE221.3080600@huawei.com>","Date":"Thu, 2 Nov 2017 17:15:13 +0800","From":"Zhong Kaihua <zhongkaihua@huawei.com>","User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64;\n\trv:17.0) Gecko/20130509 Thunderbird/17.0.6","MIME-Version":"1.0","To":"Julien Thierry <julien.thierry@arm.com>","Subject":"Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox","References":"<1509084904-2505-1-git-send-email-zhongkaihua@huawei.com>\n\t<1509084904-2505-3-git-send-email-zhongkaihua@huawei.com>\n\t<90d25374-cc83-7f75-eb38-766f0cdb9c53@arm.com>","In-Reply-To":"<90d25374-cc83-7f75-eb38-766f0cdb9c53@arm.com>","X-Originating-IP":"[10.142.146.73]","X-CFilter-Loop":"Reflected","X-Mirapoint-Virus-RAPID-Raw":"score=unknown(0),\n\trefid=str=0001.0A020202.59FAE295.007B, ss=1, re=0.000, recu=0.000,\n\treip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0,\n\tso=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32","X-Mirapoint-Loop-Id":"b2ac9fd7cf6b4824a3fe9b7aa4b70c21","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171102_022056_196350_5308CAAC ","X-CRM114-Status":"GOOD (  29.45  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno trust [45.249.212.191 listed in list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"mark.rutland@arm.com, xuezhiliang@hisilicon.com, guodong.xu@linaro.org, \n\tdevicetree@vger.kernel.org, catalin.marinas@arm.com,\n\tsuzhuangluan@hisilicon.com, jassisinghbrar@gmail.com,\n\twill.deacon@arm.com, \n\tlinux-kernel@vger.kernel.org, xuwei5@hisilicon.com, robh+dt@kernel.org,\n\thaojian.zhuang@linaro.org, kevin.wangtao@hisilicon.com,\n\tlinux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}}]