Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6632893ybe; Wed, 18 Sep 2019 06:43:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqybMEI/lSNNMxk6rLS4AidXRTJbCNJEbuxMJ9AbdX+32WUhRaZZhTKVDtoWVmuFiJIq2I/W X-Received: by 2002:a17:906:d0c5:: with SMTP id bq5mr9701587ejb.95.1568814223268; Wed, 18 Sep 2019 06:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568814223; cv=none; d=google.com; s=arc-20160816; b=lNN7JffGGCeUUPV9Anl1u4eLyMlwUFg8f4+dCh+yTHE9o0LkDOoVzaMqfpP1U9LMY0 wt9Dg5bFgCZKKN/UJZzeb/O7ltgqz3MpGLE6ZDT3E1wcXH6eoWdOnvfPRjzOOFY3p3cI wJs6n2ThOuj1i5q8nC0wSUdXTVRgUnU35raO3b5h7YwEq4uYaHp7jD+h73RwWk0DRqVt 10wpadP8sH5hd72uAQov3gUTqi2mlKdXfJ2k8y5/8RUFW4kP8OihT+tsyXoz7u/jceYk 612aAuV63kyZlq3kUQQF4ok7X+dhWKIbjkZqfilnbrDITm8Crsq7xouVl6okCrenNmF/ eKEQ== 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=JZFdNYiiGOjgcmbWDBqcSFS+4Hig0B1106x65CqCAe8=; b=xgZCOTmAijpqT1BnJIKL10MmzqhhTEoiIELlvzHcUbF3fGmuNTsneZtV5/+xUsQRCK pU21Ax8UmMBkS3wA5y7bJVZ3dixIwO5Vuka7Y86LwwfeDaP89xgXEd5Bw/vkzmp11g9b juIRtOfeSPQ3rm5YR8DA4KOFBePoftmK96sSLEdm7YVXjBWUNt695E2t8DkXHTBhR8Xj fpgzfrOwhCFQ5GWVpGkXT20uEJUseOjZOdTdeo7muTsV0lryGVx/+i1Rm054iIas2Epu QJjHe0s8Ri3tjJvlciTrmK+hUiWCwMSdEYTIJqrcTDzj5cZr4k8zUX8oabTi4HEgK9RR 2grQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="AEr/t5Pw"; 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 f2si2730672ejc.252.2019.09.18.06.43.19; Wed, 18 Sep 2019 06:43:43 -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="AEr/t5Pw"; 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 S1729909AbfIRNcK (ORCPT + 99 others); Wed, 18 Sep 2019 09:32:10 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:39245 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726671AbfIRNcJ (ORCPT ); Wed, 18 Sep 2019 09:32:09 -0400 Received: by mail-io1-f66.google.com with SMTP id a1so16148033ioc.6; Wed, 18 Sep 2019 06:32:09 -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=JZFdNYiiGOjgcmbWDBqcSFS+4Hig0B1106x65CqCAe8=; b=AEr/t5PwUUa7Z2j94wsWLg4s12+ybS7o2UbrCX7BIr4WnGnmn+abCrepKWbLvVstbM NxGuG5qbyM6a9ndPikrt8III7aA8u5SK5O7qsu/aDV0yv2FHqoGXRtvY6hnMe31iTriK BnXG6qOJuJq5JMWEenxhG/r7wmH+jnmO1G4D/modvpMYuY4pjrn/0PQHfidER6RjW+Bx vlBt0d8iSUiEhGMQ5Xt4bzYze2i+uOakAFd4OxSRSc9RXVhC8TRdPk3u3cAWnP4rTydi YWkYWNNLy7E1cAZ8DX2y9As4YkgW1mqXQCrKiWlLLhNJiAyDv2EtJf0vIuFr0tla1iRH OhZA== 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=JZFdNYiiGOjgcmbWDBqcSFS+4Hig0B1106x65CqCAe8=; b=TGce75CQGzkPCz3gUx1sRFoASmY+K6z6dmT6Qa0gQeD3joaaXjF5az81ITYxGUr8ZV uBdBdq9hooVSNvTUHnnD8mDj5egExuYbQaphTTMxAC1hIMculLrF9WkePW3l9rmLqhEN nifMuEl00M5wly4RhIFMhqs3wZz5rqv+4A6tw7yfpBOV7qy8tNx6LYlfFvV6peg/PZo3 22wWSELciGyHe0FjtfFrO1r9bgXuyHX1YeLlRzcZ7jPtoxGK55Od5vgn4MB5iOMhLLpA K1urmHte99xXRAFks5VKuNJB01XvZgZP2b/1/TUuluHD9qtq/LLRI7fEslMsN54qNugY XyUQ== X-Gm-Message-State: APjAAAVju+5VR87Q//VDeGo9QDs4+3j2Hx4c27KXc+ObplAHM3C1K1g0 6HEL44kxz4IFQdQ6nvF/ql2Sy6C/Y+8l0wGG3iTNsdbh X-Received: by 2002:a5e:960a:: with SMTP id a10mr5386914ioq.87.1568813528689; Wed, 18 Sep 2019 06:32:08 -0700 (PDT) MIME-Version: 1.0 References: <1568626884-5189-1-git-send-email-peng.fan@nxp.com> <1568626884-5189-3-git-send-email-peng.fan@nxp.com> <20190917183856.2342beed@donnerap.cambridge.arm.com> <20190918110037.4edefb2f@donnerap.cambridge.arm.com> In-Reply-To: <20190918110037.4edefb2f@donnerap.cambridge.arm.com> From: Jassi Brar Date: Wed, 18 Sep 2019 08:31:57 -0500 Message-ID: Subject: Re: [PATCH V6 2/2] mailbox: introduce ARM SMC based mailbox To: Andre Przywara Cc: Peng Fan , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "sudeep.holla@arm.com" , "f.fainelli@gmail.com" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , dl-linux-imx 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, Sep 18, 2019 at 5:00 AM Andre Przywara wrote: > > > > > > > > > + }; > > > > +}; > > > > > > If this is the data structure that this mailbox controller uses, I would expect > > > this to be documented somewhere, or even exported. > > > > Export this structure in include/linux/mailbox/smc-mailbox.h? > > For instance, even though I am not sure this is really desired or helpful, since we expect a generic mailbox client (the SCPI or SCMI driver) to deal with that mailbox. > > But at least the expected format should be documented, which could just be in writing, not necessarily in code. > Yes, the packet format is specified by the controller and defined in some header for clients to include. Other platforms do that already. > > > > + > > > > +typedef unsigned long (smc_mbox_fn)(unsigned int, unsigned long, > > > > + unsigned long, unsigned long, > > > > + unsigned long, unsigned long, > > > > + unsigned long); > > > > +static smc_mbox_fn *invoke_smc_mbox_fn; > > > > + > > > > +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; > > > > + unsigned long ret; > > > > + u32 function_id; > > > > + > > > > + function_id = chan_data->function_id; > > > > + if (!function_id) > > > > + function_id = cmd->function_id; > > > > + > > > > + if (function_id & BIT(30)) { > > > > > > if (ARM_SMCCC_IS_64(function_id)) { > > > > ok > > > > > > > > > + ret = invoke_smc_mbox_fn(function_id, cmd->args_smccc64[0], > > > > + cmd->args_smccc64[1], > > > > + cmd->args_smccc64[2], > > > > + cmd->args_smccc64[3], > > > > + cmd->args_smccc64[4], > > > > + cmd->args_smccc64[5]); > > > > + } else { > > > > + ret = invoke_smc_mbox_fn(function_id, cmd->args_smccc32[0], > > > > + cmd->args_smccc32[1], > > > > + cmd->args_smccc32[2], > > > > + cmd->args_smccc32[3], > > > > + cmd->args_smccc32[4], > > > > + cmd->args_smccc32[5]); > > > > + } > > > > + > > > > + mbox_chan_received_data(link, (void *)ret); > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +static unsigned long __invoke_fn_hvc(unsigned int function_id, > > > > + unsigned long arg0, unsigned long arg1, > > > > + unsigned long arg2, unsigned long arg3, > > > > + unsigned long arg4, unsigned long arg5) { > > > > + struct arm_smccc_res res; > > > > + > > > > + arm_smccc_hvc(function_id, arg0, arg1, arg2, arg3, arg4, > > > > + arg5, 0, &res); > > > > + return res.a0; > > > > +} > > > > + > > > > +static unsigned long __invoke_fn_smc(unsigned int function_id, > > > > + unsigned long arg0, unsigned long arg1, > > > > + unsigned long arg2, unsigned long arg3, > > > > + unsigned long arg4, unsigned long arg5) { > > > > + struct arm_smccc_res res; > > > > + > > > > + arm_smccc_smc(function_id, arg0, arg1, arg2, arg3, arg4, > > > > + arg5, 0, &res); > > > > + return res.a0; > > > > +} > > > > + > > > > +static const struct mbox_chan_ops arm_smc_mbox_chan_ops = { > > > > + .send_data = arm_smc_send_data, > > > > +}; > > > > + > > > > +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; > > > > + int ret; > > > > + u32 function_id = 0; > > > > + > > > > + if (of_device_is_compatible(dev->of_node, "arm,smc-mbox")) > > > > + invoke_smc_mbox_fn = __invoke_fn_smc; > > > > + else > > > > + invoke_smc_mbox_fn = __invoke_fn_hvc; > > > > + > > > > + mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); > > > > + if (!mbox) > > > > + return -ENOMEM; > > > > + > > > > + mbox->num_chans = 1; > > > > + mbox->chans = devm_kzalloc(dev, sizeof(*mbox->chans), GFP_KERNEL); > > > > + if (!mbox->chans) > > > > + return -ENOMEM; > > > > + > > > > + chan_data = devm_kzalloc(dev, sizeof(*chan_data), GFP_KERNEL); > > > > + if (!chan_data) > > > > + return -ENOMEM; > > > > + > > > > + of_property_read_u32(dev->of_node, "arm,func-id", &function_id); > > > > + chan_data->function_id = function_id; > > > > + > > > > + mbox->chans->con_priv = chan_data; > > > > + > > > > + mbox->txdone_poll = false; > > > > + mbox->txdone_irq = false; > > > > > > Don't we need to provide something to confirm reception to the client? In our > > > case we can set this as soon as the smc/hvc returns. > > > > As smc/hvc returns, it means the transfer is over and receive is done. > > I understand that, but was wondering if the Linux mailbox framework knows about that? In my older version I was calling mbox_chan_received_data() after the smc call returned. > The code already does that at the end of send_data > Also there is mbox_chan_txdone() with which a controller driver can signal TX completion explicitly. > No. Controller can use that only if it has specified txdone_irq, which is not the case here. Thanks