From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D41EC3A5A1 for ; Wed, 28 Aug 2019 14:02:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EC8C2064A for ; Wed, 28 Aug 2019 14:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbfH1OCW (ORCPT ); Wed, 28 Aug 2019 10:02:22 -0400 Received: from foss.arm.com ([217.140.110.172]:60126 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726438AbfH1OCV (ORCPT ); Wed, 28 Aug 2019 10:02:21 -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 D5A7D28; Wed, 28 Aug 2019 07:02:20 -0700 (PDT) Received: from e107155-lin (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 66CB93F246; Wed, 28 Aug 2019 07:02:19 -0700 (PDT) Date: Wed, 28 Aug 2019 15:02:17 +0100 From: Sudeep Holla To: Peng Fan Cc: "robh+dt@kernel.org" , "mark.rutland@arm.com" , "jassisinghbrar@gmail.com" , "andre.przywara@arm.com" , "f.fainelli@gmail.com" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , dl-linux-imx , Sudeep Holla Subject: Re: [PATCH v5 2/2] mailbox: introduce ARM SMC based mailbox Message-ID: <20190828140217.GC21614@e107155-lin> References: <1567004515-3567-1-git-send-email-peng.fan@nxp.com> <1567004515-3567-3-git-send-email-peng.fan@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1567004515-3567-3-git-send-email-peng.fan@nxp.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 28, 2019 at 03:03:02AM +0000, Peng Fan 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/patchwork/patch/812999/ > > Cc: Andre Przywara > Signed-off-by: Peng Fan > --- > drivers/mailbox/Kconfig | 7 ++ > drivers/mailbox/Makefile | 2 + > drivers/mailbox/arm-smc-mailbox.c | 215 ++++++++++++++++++++++++++++++++++++++ > 3 files changed, 224 insertions(+) > create mode 100644 drivers/mailbox/arm-smc-mailbox.c > [...] > +static int arm_smc_mbox_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct mbox_controller *mbox; > + struct arm_smc_chan_data *chan_data; > + const char *method; > + bool mem_trans = false; > + int ret, i; > + u32 val; > + > + if (!of_property_read_u32(dev->of_node, "arm,num-chans", &val)) { > + if (!val) { > + dev_err(dev, "invalid arm,num-chans value %u\n", val); > + return -EINVAL; > + } > + } else { > + return -EINVAL; > + } > + > + if (!of_property_read_string(dev->of_node, "transports", &method)) { > + if (!strcmp("mem", method)) { > + mem_trans = true; > + } else if (!strcmp("reg", method)) { > + mem_trans = false; > + } else { > + dev_warn(dev, "invalid \"transports\" property: %s\n", > + method); > + > + return -EINVAL; > + } > + } else { > + return -EINVAL; > + } > + > + if (!of_property_read_string(dev->of_node, "method", &method)) { > + if (!strcmp("hvc", method)) { > + invoke_smc_mbox_fn = __invoke_fn_hvc; > + } else if (!strcmp("smc", method)) { > + invoke_smc_mbox_fn = __invoke_fn_smc; > + } else { > + dev_warn(dev, "invalid \"method\" property: %s\n", > + method); > + > + return -EINVAL; > + } > + } else { > + return -EINVAL; > + } > + > + mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); > + if (!mbox) > + return -ENOMEM; > + > + mbox->num_chans = val; > + mbox->chans = devm_kcalloc(dev, mbox->num_chans, sizeof(*mbox->chans), > + GFP_KERNEL); > + if (!mbox->chans) > + return -ENOMEM; > + > + chan_data = devm_kcalloc(dev, mbox->num_chans, sizeof(*chan_data), > + GFP_KERNEL); > + if (!chan_data) > + return -ENOMEM; > + > + for (i = 0; i < mbox->num_chans; i++) { > + u32 function_id; > + > + ret = of_property_read_u32_index(dev->of_node, > + "arm,func-ids", i, > + &function_id); I missed it in binding but I thought we agreed to make this "arm,func-ids" a required property and not optional ? -- Regards, Sudeep