Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1007515ybd; Wed, 26 Jun 2019 09:33:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsPDBerScZUJc9R1fA6I228PLIBAyD6OGUPb2I7omj/btGAOa3DRmXMjAXwdAsQy2c69AA X-Received: by 2002:a17:90a:898e:: with SMTP id v14mr5759227pjn.119.1561566802090; Wed, 26 Jun 2019 09:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561566802; cv=none; d=google.com; s=arc-20160816; b=socMrDJhqygd0C5G/mkmLT1LQ0+FMQiBUFhhWn7pS7SQRvpINmLltwd7I0PpfGkf5O 3DLy736zBCYAzLqK+No6l0Kbjz1Dcog1XWOWWZ+C6B9An+bGJC0AkN+vjrdOx3hLEvDl uemH1xZekz2GObmdn5xC+b7vDTszljWilDKv48uHLsLXPJejwA0afIhaV/HEhaJWLiM/ VwgwBiAZ914M4zdVBgak8u46QknnXGC7WENppSrrao898Xw0PKbIWLF8ESwBssm+DkKJ 0Ili8DuImd5zbLSfG4Dq/IL4KbFxflAxDBIMUzmNgG+vdgVMQQZmnRBFGT/4RGQO9YWO mFEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eXsH0Wot6VTPu8I3uYJKAlb46FTe/8mUOs1QhqQgoHE=; b=JhGOgrB51pL6SLMnlhEkKm3IXLaEvm54oG0QDkbtnV+Ig4c7uidTvihG/WsdsaL+su FYG4P7EOpVWsf+vMKPa8aJHlhu+/Et64cR8bJoBU0vTvRjUp7s1AkWH7EFdexDj8fAy0 jZKztGUKBLAOJA0ikqsS7Vo6cL8k7n2HHyIyaU6yf0Vt8q7NON+G3WG3XshKYXPGy5eB w0qNLwVEcAHXmKatTXcM3LhzMN/tAYcVgic7ULDazCWbndYsKAVbxRdpEd7ThviDlGKs SCjtMad/VYEcQlNJj6ANOVsbuybR8tPnRZ/GdUl+6+v/+Ie8Orn6EpNMaRizLZ7ms9F6 2Y5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kz2ktaIh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11si16669609pgb.78.2019.06.26.09.33.05; Wed, 26 Jun 2019 09:33:22 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kz2ktaIh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726565AbfFZQbc (ORCPT + 99 others); Wed, 26 Jun 2019 12:31:32 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:38656 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726006AbfFZQbb (ORCPT ); Wed, 26 Jun 2019 12:31:31 -0400 Received: by mail-io1-f68.google.com with SMTP id j6so4735721ioa.5; Wed, 26 Jun 2019 09:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eXsH0Wot6VTPu8I3uYJKAlb46FTe/8mUOs1QhqQgoHE=; b=Kz2ktaIhuW3Bn79QJv6uL9IwADagdfZBpWyb2JSPma5J2cyjBICI/dZYITW2J8CBNI jjWK1NQ5vLpF8prSEYbDoq/rfyQ/JKvqIUhaulmIdxZVO4//jgqPgmpwIsmJ9rcD0DQq T+3qrg3dajSbKuE7YDBpPtg0c/PSIYOPRn6nNxA7m2IKV3RYbUo5MUJiOdFWRl/BPpww 4Qad5cEv3drHbft2G+JVVSt2uJ8kxNFKPLwcWXHhI8/pxt44VvQIu9a1JAM0zqDToAXD h96nZNV/8tJCrlG3Glv7yLxpNkC5YRq2IyVwI3dm8uOVghF46xmSu1jm4Pav6vJTaJHk Mj5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eXsH0Wot6VTPu8I3uYJKAlb46FTe/8mUOs1QhqQgoHE=; b=d4XjR8QTzE5uu6U1oyNJYnwvge53tiMrN6WuR7XCoECQ8oNz9QQMjCIMbELNIpqAGU O2s+F54qpxEFajVmxaMTguCSCmRf/l5kfICauRmzyIyrsAV9A5z1e/XBjGryIWBJa6Ct vU3+Ijxk5Uy5MMSJfXEfqir+agYBAParrLRpOsdS3yG57H33SJLayLWTQZ4+5eaOwkcC h8G/EZShfxEvPXcoCJXRjh/kDlgveZcPv41vWVWUWsIyCVl7kNGu9Boc2Bpr9iiFAjaE BXQlKNp3+KD46AC/9af2u+P+fFVOJYbX1vvlVXs7K9Q5/ncHOZjpXnBTxWjeP0fQuORC GvVw== X-Gm-Message-State: APjAAAUw2Sm5b5fW8SPjZenW3EJfqHZJNzEjyjeFhiFhtRq2D+yRhsOn 6eSDo1Hw5s2mkoelnsU6kcnWtOqweMYUOpq7cks= X-Received: by 2002:a6b:cb07:: with SMTP id b7mr5806333iog.7.1561566690250; Wed, 26 Jun 2019 09:31:30 -0700 (PDT) MIME-Version: 1.0 References: <20190603083005.4304-1-peng.fan@nxp.com> <20190603083005.4304-3-peng.fan@nxp.com> In-Reply-To: From: Jassi Brar Date: Wed, 26 Jun 2019 11:31:18 -0500 Message-ID: Subject: Re: [PATCH V2 2/2] mailbox: introduce ARM SMC based mailbox 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" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 26, 2019 at 8:31 AM Peng Fan wrote: > > > Hi All, > > > Subject: Re: [PATCH V2 2/2] mailbox: introduce ARM SMC based mailbox > > > > On Tue, Jun 25, 2019 at 2:30 AM Peng Fan wrote: > > > > > > Hi Jassi > > > > > > > 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://lore > > > > > .kernel.org%2Fpatchwork%2Fpatch%2F812999%2F&data=02%7C0 > > 1%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) > > > > > > > > > +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]' > > > > > > Missed to reply this comment. > > > > > > The firmware driver might not have func-id, such as SCMI/SCPI. > > > So add an optional func-id to let smc mailbox driver could > > > use smc SiP func id. > > > > > There is no end to conforming to protocols. Controller drivers should > > be written having no particular client in mind. > > If the func-id needs be passed from user, then the chan_id suggested > by Sudeep should also be passed from user, not in mailbox driver. > Isn't it already so? > Jassi, so from your point, arm_smc_send_data just send a0 - a6 > to firmware, right? > Yes. > Sudeep, Andre, Florian, > > What's your suggestion? SCMI not support, do you have > plan to add smc transport in SCMI? > Not replying on their behalf .... but SCMI should eventually support more than MHU. And I can't see why that matters here? thanks.