Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3142315ybf; Tue, 3 Mar 2020 00:01:34 -0800 (PST) X-Google-Smtp-Source: ADFU+vsxT6qtC3lBhEIyZm52Xbxter1evCE0GchTLac58+X64zTc8j1f4uwy1ZY324kvJhf5KmaV X-Received: by 2002:a9d:7088:: with SMTP id l8mr2499862otj.208.1583222493888; Tue, 03 Mar 2020 00:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583222493; cv=none; d=google.com; s=arc-20160816; b=YgXa5QYGbt6s6E+ENojfa2/dDT3tYqKnVf33WRkWbrYicwq5Ww1nqeLCAHje09dfv3 NyySLLJ1l+QD1gtl/eSQBLeeBXlzoZ0K8o+QBJF6lQfHfuci0qmGk6WNKzFWabxa187g ySE+rdiXKQsbAS9XjeE46noT/4KFUcbYyfmZZEUUYsEDE2Dc1JUXW1W95TeWf4UqIk9a MhRGoaqV8b8BaZbVspli8J/eYgg19IUcyyl1GKd1FiRhG9c85hpDvb3ZJcMDzrDAl7dm x5HkVGg6EPd3HhLGQhcC8il+unWik69PuFONOcnhQEW1K9AQpbQbR7Yv6rhzgOms8MPd Cb6A== 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:from:references:cc:to:subject; bh=jCDYcPlrX3lSwWFgE7mpA5vltzfBe5Zfooc21bbkdh4=; b=KwDrwQrVP6IqySG/CqAiu/lEchv2Ss67gzhc1MpZnV+Rk4PVFwH+UKY5CiK7HEDAhX xT/XrUULxsxDOzQ1FyUMLqAJUX3yKoerU8SKOiQUIViNbZT7FHROPQM5WJCt/30i4MBJ 83/2oXBlqIIefBE8TBREhD5sp3H/14YE4GwfyMxt4WqvKmaVljjNHG6aEBDqgNxMZKar T+HCZWhKFln9d7F+acBdEQS3Dv9StqNLeK/cHtoEnB9yFr5/veysIj0Snr7xI1iBJhmO 0+Z2OQVVLHNrkOMCTQtw54KunOkGWITaaulRYJo3YOQpVD7Y+htzCICnjYWN8AcqdShb YwPw== 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 t6si2069506otp.133.2020.03.03.00.01.20; Tue, 03 Mar 2020 00:01:33 -0800 (PST) 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 S1727619AbgCCH7k (ORCPT + 99 others); Tue, 3 Mar 2020 02:59:40 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:59405 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725879AbgCCH7k (ORCPT ); Tue, 3 Mar 2020 02:59:40 -0500 Received: from soja.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:13da]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j92Sl-0004bR-Fx; Tue, 03 Mar 2020 08:59:35 +0100 Subject: Re: [PATCH V5 4/4] firmware: imx-scu: Support one TX and one RX To: peng.fan@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, jassisinghbrar@gmail.com Cc: aisheng.dong@nxp.com, Anson.Huang@nxp.com, linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, leonard.crestez@nxp.com, festevam@gmail.com, linux-arm-kernel@lists.infradead.org References: <1583221359-9285-1-git-send-email-peng.fan@nxp.com> <1583221359-9285-5-git-send-email-peng.fan@nxp.com> From: Oleksij Rempel Message-ID: <4dc08efe-294b-5741-11d7-ae9e1e585d3d@pengutronix.de> Date: Tue, 3 Mar 2020 08:59:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <1583221359-9285-5-git-send-email-peng.fan@nxp.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:13da X-SA-Exim-Mail-From: o.rempel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.03.20 08:42, peng.fan@nxp.com wrote: > From: Peng Fan > > Current imx-scu requires four TX and four RX to communicate with > SCU. This is low efficient and causes lots of mailbox interrupts. > > With imx-mailbox driver could support one TX to use all four transmit > registers and one RX to use all four receive registers, imx-scu > could use one TX and one RX. > > Signed-off-by: Peng Fan This driver should be review by some one else. > --- > V5: > None > V4: > None > V3: > Check mbox fsl,imx8-mu-scu for fast_ipc > > drivers/firmware/imx/imx-scu.c | 54 +++++++++++++++++++++++++++++++++--------- > 1 file changed, 43 insertions(+), 11 deletions(-) > > diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c > index f71eaa5bf52d..e94a5585b698 100644 > --- a/drivers/firmware/imx/imx-scu.c > +++ b/drivers/firmware/imx/imx-scu.c > @@ -38,6 +38,7 @@ struct imx_sc_ipc { > struct device *dev; > struct mutex lock; > struct completion done; > + bool fast_ipc; > > /* temporarily store the SCU msg */ > u32 *msg; > @@ -115,6 +116,7 @@ static void imx_scu_rx_callback(struct mbox_client *c, void *msg) > struct imx_sc_ipc *sc_ipc = sc_chan->sc_ipc; > struct imx_sc_rpc_msg *hdr; > u32 *data = msg; > + int i; > > if (!sc_ipc->msg) { > dev_warn(sc_ipc->dev, "unexpected rx idx %d 0x%08x, ignore!\n", > @@ -122,6 +124,19 @@ static void imx_scu_rx_callback(struct mbox_client *c, void *msg) > return; > } > > + if (sc_ipc->fast_ipc) { > + hdr = msg; > + sc_ipc->rx_size = hdr->size; > + sc_ipc->msg[0] = *data++; > + > + for (i = 1; i < sc_ipc->rx_size; i++) > + sc_ipc->msg[i] = *data++; > + > + complete(&sc_ipc->done); > + > + return; > + } > + > if (sc_chan->idx == 0) { > hdr = msg; > sc_ipc->rx_size = hdr->size; > @@ -147,6 +162,7 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg) > struct imx_sc_chan *sc_chan; > u32 *data = msg; > int ret; > + int size; > int i; > > /* Check size */ > @@ -156,7 +172,8 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg) > dev_dbg(sc_ipc->dev, "RPC SVC %u FUNC %u SIZE %u\n", hdr->svc, > hdr->func, hdr->size); > > - for (i = 0; i < hdr->size; i++) { > + size = sc_ipc->fast_ipc ? 1 : hdr->size; > + for (i = 0; i < size; i++) { > sc_chan = &sc_ipc->chans[i % 4]; > > /* > @@ -168,8 +185,10 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg) > * Wait for tx_done before every send to ensure that no > * queueing happens at the mailbox channel level. > */ > - wait_for_completion(&sc_chan->tx_done); > - reinit_completion(&sc_chan->tx_done); > + if (!sc_ipc->fast_ipc) { > + wait_for_completion(&sc_chan->tx_done); > + reinit_completion(&sc_chan->tx_done); > + } > > ret = mbox_send_message(sc_chan->ch, &data[i]); > if (ret < 0) > @@ -246,6 +265,8 @@ static int imx_scu_probe(struct platform_device *pdev) > struct imx_sc_chan *sc_chan; > struct mbox_client *cl; > char *chan_name; > + struct of_phandle_args args; > + int num_channel; > int ret; > int i; > > @@ -253,11 +274,20 @@ static int imx_scu_probe(struct platform_device *pdev) > if (!sc_ipc) > return -ENOMEM; > > - for (i = 0; i < SCU_MU_CHAN_NUM; i++) { > - if (i < 4) > + ret = of_parse_phandle_with_args(pdev->dev.of_node, "mboxes", > + "#mbox-cells", 0, &args); > + if (ret) > + return ret; > + > + sc_ipc->fast_ipc = of_device_is_compatible(args.np, "fsl,imx8-mu-scu"); > + > + num_channel = sc_ipc->fast_ipc ? 2 : SCU_MU_CHAN_NUM; > + for (i = 0; i < num_channel; i++) { > + if (i < num_channel / 2) > chan_name = kasprintf(GFP_KERNEL, "tx%d", i); > else > - chan_name = kasprintf(GFP_KERNEL, "rx%d", i - 4); > + chan_name = kasprintf(GFP_KERNEL, "rx%d", > + i - num_channel / 2); > > if (!chan_name) > return -ENOMEM; > @@ -269,13 +299,15 @@ static int imx_scu_probe(struct platform_device *pdev) > cl->knows_txdone = true; > cl->rx_callback = imx_scu_rx_callback; > > - /* Initial tx_done completion as "done" */ > - cl->tx_done = imx_scu_tx_done; > - init_completion(&sc_chan->tx_done); > - complete(&sc_chan->tx_done); > + if (!sc_ipc->fast_ipc) { > + /* Initial tx_done completion as "done" */ > + cl->tx_done = imx_scu_tx_done; > + init_completion(&sc_chan->tx_done); > + complete(&sc_chan->tx_done); > + } > > sc_chan->sc_ipc = sc_ipc; > - sc_chan->idx = i % 4; > + sc_chan->idx = i % (num_channel / 2); > sc_chan->ch = mbox_request_channel_byname(cl, chan_name); > if (IS_ERR(sc_chan->ch)) { > ret = PTR_ERR(sc_chan->ch); > Kind regards, Oleksij Rempel -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |