Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1867903ybn; Thu, 26 Sep 2019 03:28:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4esi2f+41R+JpWMt+8J5SbyZih5fdxuQ4bMLwm7lQOEhv7j84nCpPwmxFHoP7BxOTfCvI X-Received: by 2002:a17:906:3298:: with SMTP id 24mr2377433ejw.136.1569493704937; Thu, 26 Sep 2019 03:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569493704; cv=none; d=google.com; s=arc-20160816; b=f3J9zyXiu4/yOMMK5YAP2SbsuuKinqQuLaSADjKwhg9MjnAtMl8GTTfm61hYEwL37l 3NuYqJYqeC4HDJ96eWPSMEbmBSspTtMZocOiS40pANo3MGpUnmSdJ5GAQWi8LmPJ4AN+ sTi4bLOkvelbcZE/N5YGksZrx2XeXw9tspMXOmqFP+7t3rrjcXmWtOd4jrm3gaR4N90P UFaTzPtoBqptwIFzcH3NyV7RuJkBDzjPLPrDW5EC3NCfzOgWQOQGj+siqxWmYK/jY2lO teYDw7s+MA+HOLJS+K1rxkj2tL3fWUxof46t24YqzPUoQW8nR2A2fFqpLhPTpLKEIiqE P3Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=xmNH4w1nCL+/pWYrn/3VR8pIzw+geQOwRdW1b521x6A=; b=DyxRTHo2GKt/HRspTIHw/eRDhy1hx80cNff7YmAc9rE1v0XCAF0Lqhx6QN7lJAe1Gb 5wQt3xrWHGnuKY+JhEGbBv6XlClPWpz5pXMhcHJkqV9pbXx+KhUkBWfCAkvvFsaVmKYd ZK30oP9M5EX2cmciTxLiDytDMy0Nds0qr1Gs39twX7Mq/NWHCGQg1NaDTwcxEnDRbtyo 2k8xPUk9q+E3o05rglqLtM4UdXl7z/boAXC6GbbrEqLF9l4w9zASwWYIoc5UyflOHKtD ay2EnWHHgrrrZ6erq0ZHQa3VkTdJgq8ItLr5kEb7bJfvMJ82qfTTP+qYqif8DpVRThp7 a03w== 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 jz12si739149ejb.193.2019.09.26.03.28.01; Thu, 26 Sep 2019 03:28:24 -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 S1727906AbfIZH7T (ORCPT + 99 others); Thu, 26 Sep 2019 03:59:19 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:49499 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727578AbfIZH7T (ORCPT ); Thu, 26 Sep 2019 03:59:19 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iDOgF-0004ax-0i; Thu, 26 Sep 2019 09:59:15 +0200 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iDOgE-0006lM-8C; Thu, 26 Sep 2019 09:59:14 +0200 Date: Thu, 26 Sep 2019 09:59:14 +0200 From: Marco Felsch To: Anson Huang Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, aisheng.dong@nxp.com, leonard.crestez@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linux-imx@nxp.com Subject: Re: [PATCH] firmware: imx: Skip return value check for some special SCU firmware APIs Message-ID: <20190926075914.i7tsd3cbpitrqe4q@pengutronix.de> References: <1569406066-16626-1-git-send-email-Anson.Huang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1569406066-16626-1-git-send-email-Anson.Huang@nxp.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 09:53:40 up 131 days, 14:11, 85 users, load average: 0.03, 0.21, 0.16 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: mfe@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 Hi, On 19-09-25 18:07, Anson Huang wrote: > The SCU firmware does NOT always have return value stored in message > header's function element even the API has response data, those special > APIs are defined as void function in SCU firmware, so they should be > treated as return success always. > > Signed-off-by: Anson Huang > --- > - This patch is based on the patch of https://patchwork.kernel.org/patch/11129553/ > --- > drivers/firmware/imx/imx-scu.c | 34 ++++++++++++++++++++++++++++++++-- > 1 file changed, 32 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c > index 869be7a..ced5b12 100644 > --- a/drivers/firmware/imx/imx-scu.c > +++ b/drivers/firmware/imx/imx-scu.c > @@ -78,6 +78,11 @@ static int imx_sc_linux_errmap[IMX_SC_ERR_LAST] = { > -EIO, /* IMX_SC_ERR_FAIL */ > }; > > +static const struct imx_sc_rpc_msg whitelist[] = { > + { .svc = IMX_SC_RPC_SVC_MISC, .func = IMX_SC_MISC_FUNC_UNIQUE_ID }, > + { .svc = IMX_SC_RPC_SVC_MISC, .func = IMX_SC_MISC_FUNC_GET_BUTTON_STATUS }, > +}; Is this going to be extended in the near future? I see some upcoming problems here if someone uses a different scu-fw<->kernel combination as nxp would suggest. Regards, Marco > + > static struct imx_sc_ipc *imx_sc_ipc_handle; > > static inline int imx_sc_to_linux_errno(int errno) > @@ -157,11 +162,24 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg) > return 0; > } > > +static bool imx_scu_call_skip_return_value_check(uint8_t svc, uint8_t func) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(whitelist); i++) > + if (svc == whitelist[i].svc && > + func == whitelist[i].func) > + return true; > + > + return false; > +} > + > /* > * RPC command/response > */ > int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) > { > + uint8_t saved_svc, saved_func; > struct imx_sc_rpc_msg *hdr; > int ret; > > @@ -171,8 +189,11 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) > mutex_lock(&sc_ipc->lock); > reinit_completion(&sc_ipc->done); > > - if (have_resp) > + if (have_resp) { > sc_ipc->msg = msg; > + saved_svc = ((struct imx_sc_rpc_msg *)msg)->svc; > + saved_func = ((struct imx_sc_rpc_msg *)msg)->func; > + } > sc_ipc->count = 0; > ret = imx_scu_ipc_write(sc_ipc, msg); > if (ret < 0) { > @@ -190,7 +211,16 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) > > /* response status is stored in hdr->func field */ > hdr = msg; > - ret = hdr->func; > + /* > + * Some special SCU firmware APIs do NOT have return value > + * in hdr->func, but they do have response data, those special > + * APIs are defined as void function in SCU firmware, so they > + * should be treated as return success always. > + */ > + if (!imx_scu_call_skip_return_value_check(saved_svc, saved_func)) > + ret = hdr->func; > + else > + ret = 0; > } > > out: > -- > 2.7.4 > > > -- 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 |