Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1040134ybd; Wed, 26 Jun 2019 10:07:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaQB5malwtJZKN+RLNieBX1FvvlzvKAu2XCf8o2wQG1j5YZOVmmVJ2ntUCjbvUHxx/62do X-Received: by 2002:a63:e43:: with SMTP id 3mr3682360pgo.402.1561568858590; Wed, 26 Jun 2019 10:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561568858; cv=none; d=google.com; s=arc-20160816; b=IKNpf3KrBjLrcdIQk8IjkAzXcvCfstOc5O1szMbVLqsLTfUVFZosp6SgnARglEfIFs MR6xMgt+bBEokAJNulIuUMUXDp7VczWQKJQI0EkLzkYA3OF5K+74dhd3KAXjijZ2LOaO 8eGAgrQ2N2tmhJu7fLNyU95kqdONWfaK9L8uAtohfoq4KU71dpNQDYcNy9bBirasN85Z zDdvto6m6fByVpOyVAjt/zlv41A3fImW18wW3UixbzblTgoY7G8Xp8+bSaEX7/0OlTzg F8Hbp7bd+21Orz4HK63rC7xkrUeBAUnViFiJgVJASiuuPoe5f1SYSa66jW84U8eVCWqA 4DIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject; bh=K6fzxJE2pk33FV21ND2RUWgtkCx4E4MImNVzbjXXDp0=; b=BYGHVZ9YTbFFKvL3yv/CyvHpCxajIG7N91YPFOgkcX/dRMaOFMfttu25pYk6zJ5Xir qWpvSHBMOeRp8Ze/j3/3tZQEqZi/YR9S1wUr4Buoi7YEjVDv0ZZnr+wTbGbwVP7PnxuG 5kC1ZavtvoONu/08Cz+sUYUjfbRBlZVnKXWbgRAWmtuIH7GsMgUbWgaHLgnVI0OrFDyD RqAfqKx+kRTJzf+jkidWi2RRyy8mjOXCY5UrN4VPSGA7cJEnkncwX77YGDP1/INouUX0 hN6nl1x0alW+E1s8n/l7goqqKf6+1nX0YlhQNG0e4TFwTZ6DGlo7t4z9EmsQHr/i+sco DHtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cl14si3838992plb.341.2019.06.26.10.07.21; Wed, 26 Jun 2019 10:07:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbfFZRF4 (ORCPT + 99 others); Wed, 26 Jun 2019 13:05:56 -0400 Received: from foss.arm.com ([217.140.110.172]:37366 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726042AbfFZRFz (ORCPT ); Wed, 26 Jun 2019 13:05:55 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F0A682B; Wed, 26 Jun 2019 10:05:53 -0700 (PDT) Received: from [192.168.3.111] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 248973F706; Wed, 26 Jun 2019 10:05:52 -0700 (PDT) Subject: Re: [PATCH V2 2/2] mailbox: introduce ARM SMC based mailbox To: Peng Fan , Jassi Brar Cc: Rob Herring , Mark Rutland , Sudeep Holla , Florian Fainelli , ", Sascha Hauer" , dl-linux-imx , Shawn Guo , "festevam@gmail.com" , Devicetree List , Linux Kernel Mailing List , "linux-arm-kernel@lists.infradead.org" , "van.freenix@gmail.com" References: <20190603083005.4304-1-peng.fan@nxp.com> <20190603083005.4304-3-peng.fan@nxp.com> From: =?UTF-8?Q?Andr=c3=a9_Przywara?= Openpgp: preference=signencrypt Autocrypt: addr=andre.przywara@arm.com; prefer-encrypt=mutual; keydata= mQINBFNPCKMBEAC+6GVcuP9ri8r+gg2fHZDedOmFRZPtcrMMF2Cx6KrTUT0YEISsqPoJTKld tPfEG0KnRL9CWvftyHseWTnU2Gi7hKNwhRkC0oBL5Er2hhNpoi8x4VcsxQ6bHG5/dA7ctvL6 kYvKAZw4X2Y3GTbAZIOLf+leNPiF9175S8pvqMPi0qu67RWZD5H/uT/TfLpvmmOlRzNiXMBm kGvewkBpL3R2clHquv7pB6KLoY3uvjFhZfEedqSqTwBVu/JVZZO7tvYCJPfyY5JG9+BjPmr+ REe2gS6w/4DJ4D8oMWKoY3r6ZpHx3YS2hWZFUYiCYovPxfj5+bOr78sg3JleEd0OB0yYtzTT esiNlQpCo0oOevwHR+jUiaZevM4xCyt23L2G+euzdRsUZcK/M6qYf41Dy6Afqa+PxgMEiDto ITEH3Dv+zfzwdeqCuNU0VOGrQZs/vrKOUmU/QDlYL7G8OIg5Ekheq4N+Ay+3EYCROXkstQnf YYxRn5F1oeVeqoh1LgGH7YN9H9LeIajwBD8OgiZDVsmb67DdF6EQtklH0ycBcVodG1zTCfqM AavYMfhldNMBg4vaLh0cJ/3ZXZNIyDlV372GmxSJJiidxDm7E1PkgdfCnHk+pD8YeITmSNyb 7qeU08Hqqh4ui8SSeUp7+yie9zBhJB5vVBJoO5D0MikZAODIDwARAQABtC1BbmRyZSBQcnp5 d2FyYSAoQVJNKSA8YW5kcmUucHJ6eXdhcmFAYXJtLmNvbT6JAjsEEwECACUCGwMGCwkIBwMC BhUIAgkKCwQWAgMBAh4BAheABQJTWSV8AhkBAAoJEAL1yD+ydue63REP/1tPqTo/f6StS00g NTUpjgVqxgsPWYWwSLkgkaUZn2z9Edv86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2019 18:05:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/06/2019 08:20, Peng Fan wrote: > Hi Jassi, > >> -----Original Message----- >> From: Jassi Brar [mailto:jassisinghbrar@gmail.com] >> Sent: 2019年6月21日 0:50 >> To: Peng Fan >> Cc: Rob Herring ; Mark Rutland >> ; Sudeep Holla ; Florian >> Fainelli ; , Sascha Hauer ; >> dl-linux-imx ; Shawn Guo ; >> festevam@gmail.com; Devicetree List ; Linux >> Kernel Mailing List ; >> linux-arm-kernel@lists.infradead.org; Andre Przywara >> ; van.freenix@gmail.com >> Subject: Re: [PATCH V2 2/2] mailbox: introduce ARM SMC based mailbox >> >> On Mon, Jun 3, 2019 at 3:28 AM wrote: >>> >>> From: Peng Fan >>> >>> This mailbox driver implements a mailbox which signals transmitted >>> data via an ARM smc (secure monitor call) instruction. The mailbox >>> receiver is implemented in firmware and can synchronously return data >>> when it returns execution to the non-secure world again. >>> An asynchronous receive path is not implemented. >>> This allows the usage of a mailbox to trigger firmware actions on SoCs >>> which either don't have a separate management processor or on which >>> such a core is not available. A user of this mailbox could be the SCP >>> interface. >>> >>> Modified from Andre Przywara's v2 patch >>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore >>> .kernel.org%2Fpatchwork%2Fpatch%2F812999%2F&data=02%7C01%7 >> Cpeng.fa >>> >> n%40nxp.com%7C1237677cb01044ad714508d6f59f648f%7C686ea1d3bc2b4 >> c6fa92cd >>> >> 99c5c301635%7C0%7C0%7C636966462272457978&sdata=Hzgeu43m5 >> ZkeRMtL8Bx >>> gUm3%2B6FBObib1OPHPlSccE%2B0%3D&reserved=0 >>> >>> Cc: Andre Przywara >>> Signed-off-by: Peng Fan >>> --- >>> >>> V2: >>> Add interrupts notification support. >>> >>> drivers/mailbox/Kconfig | 7 ++ >>> drivers/mailbox/Makefile | 2 + >>> drivers/mailbox/arm-smc-mailbox.c | 190 >> ++++++++++++++++++++++++++++++++ >>> include/linux/mailbox/arm-smc-mailbox.h | 10 ++ >>> 4 files changed, 209 insertions(+) >>> create mode 100644 drivers/mailbox/arm-smc-mailbox.c create mode >>> 100644 include/linux/mailbox/arm-smc-mailbox.h >>> >>> diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index >>> 595542bfae85..c3bd0f1ddcd8 100644 >>> --- a/drivers/mailbox/Kconfig >>> +++ b/drivers/mailbox/Kconfig >>> @@ -15,6 +15,13 @@ config ARM_MHU >>> The controller has 3 mailbox channels, the last of which can be >>> used in Secure mode only. >>> >>> +config ARM_SMC_MBOX >>> + tristate "Generic ARM smc mailbox" >>> + depends on OF && HAVE_ARM_SMCCC >>> + help >>> + Generic mailbox driver which uses ARM smc calls to call into >>> + firmware for triggering mailboxes. >>> + >>> config IMX_MBOX >>> tristate "i.MX Mailbox" >>> depends on ARCH_MXC || COMPILE_TEST diff --git >>> a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index >>> c22fad6f696b..93918a84c91b 100644 >>> --- a/drivers/mailbox/Makefile >>> +++ b/drivers/mailbox/Makefile >>> @@ -7,6 +7,8 @@ obj-$(CONFIG_MAILBOX_TEST) += mailbox-test.o >>> >>> obj-$(CONFIG_ARM_MHU) += arm_mhu.o >>> >>> +obj-$(CONFIG_ARM_SMC_MBOX) += arm-smc-mailbox.o >>> + >>> obj-$(CONFIG_IMX_MBOX) += imx-mailbox.o >>> >>> obj-$(CONFIG_ARMADA_37XX_RWTM_MBOX) += >> armada-37xx-rwtm-mailbox.o >>> diff --git a/drivers/mailbox/arm-smc-mailbox.c >>> b/drivers/mailbox/arm-smc-mailbox.c >>> new file mode 100644 >>> index 000000000000..fef6e38d8b98 >>> --- /dev/null >>> +++ b/drivers/mailbox/arm-smc-mailbox.c >>> @@ -0,0 +1,190 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +/* >>> + * Copyright (C) 2016,2017 ARM Ltd. >>> + * Copyright 2019 NXP >>> + */ >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include #include >>> + >>> +#include >>> +#include >>> + >>> +#define ARM_SMC_MBOX_USE_HVC BIT(0) >>> +#define ARM_SMC_MBOX_USB_IRQ BIT(1) >>> + >> IRQ bit is unused (and unnecessary IMO) > > This will be removed in next version. > >> >>> +struct arm_smc_chan_data { >>> + u32 function_id; >>> + u32 flags; >>> + int irq; >>> +}; >>> + >>> +static int arm_smc_send_data(struct mbox_chan *link, void *data) { >>> + struct arm_smc_chan_data *chan_data = link->con_priv; >>> + struct arm_smccc_mbox_cmd *cmd = data; >>> + struct arm_smccc_res res; >>> + u32 function_id; >>> + >>> + if (chan_data->function_id != UINT_MAX) >>> + function_id = chan_data->function_id; >>> + else >>> + function_id = cmd->a0; >>> + >> Not sure about chan_data->function_id. Why restrict from DT? >> 'a0' is the function_id register, let the user pass func-id via the 'a0' like other >> values via 'a[1-7]' >> >> >>> + if (chan_data->flags & ARM_SMC_MBOX_USE_HVC) >>> + arm_smccc_hvc(function_id, cmd->a1, cmd->a2, >> cmd->a3, cmd->a4, >>> + cmd->a5, cmd->a6, cmd->a7, &res); >>> + else >>> + arm_smccc_smc(function_id, cmd->a1, cmd->a2, >> cmd->a3, cmd->a4, >>> + cmd->a5, cmd->a6, cmd->a7, &res); >>> + >>> + if (chan_data->irq) >>> + return 0; >>> + >> This irq thing seems like oob signalling, that is, a protocol thing. >> And then it provides lesser info via chan_irq_handler (returns NULL) than >> res.a0 - which can always be ignored if not needed. >> So the irq should be implemented in the upper layer if the protocol needs it. > > The interrupts was added here because in v1, Florian suggest > " > I would just put a > provision in the binding to support an optional interrupt such that > asynchronism gets reasonably easy to plug in when it is available (and > desirable). > " > > So I introduced interrupt in V2. In my testcase, after smc call done, > it means firmware->smc mailbox->firmware done. Interrupt notification > from firmware->Linux, means firmware has done the operation. > > When using interrupts, we could not know res.a0 as smc sync call. > > Interrupts is not a must in my testcase, Florian, Andre, do you have > any comments? Should I keep interrupts in V3 or drop it as Jassi comments? The smc mailbox is by its very design a one-way channel - and it's synchronous. I think this is all the mailbox driver should be concerned about. The fact that there is a protocol user that would benefit from a return channel is a separate issue. The SCMI binding explicitly mentions *two* mailboxes, one TX, one RX, so the return channel could be very well implemented by a separate driver. I am wondering if we get away without a functioning return channel, at least for a subset of SCMI functionality? Can we use some dummy driver? Or specify another smc channel with some unhandled/ignored channel ID for that purpose? So I would leave the IRQ return channel out for now, unless we desperately need it. Cheers, Andre.