Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3706961ybp; Sun, 6 Oct 2019 18:22:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzM7wdeNdUi14xYJPj9e5yY79kkoASOEa131UtalmxBdr5b+qmaFOapOFzSS+J2+kch1KbW X-Received: by 2002:aa7:c343:: with SMTP id j3mr27101574edr.187.1570411345511; Sun, 06 Oct 2019 18:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570411345; cv=none; d=google.com; s=arc-20160816; b=aWIPiglqCeoKXew98zuRXzQXHcPhh07SAoDpdBr+UbvLo99gvvlsu++K5CSpQPNAZA HwubZkRL8+bZBbn601JIO7+HQkUOQFRD+e2+/b4oQ70KJEny8/s57J/mKGBWHwJG8FQ4 DndYX1vNBl5/kyqS4jG8er8jcRyl/rlsUkmBVlbaApkWVbHy2s7S2FXl8wk+CbLsWFCb ij/H1soyDDPO/t2ZLIu6YB20UGY4O+FMXpu3fybxepNOFSPEtXNy/7HFNiXs7T6rvmEJ 7w0KuSS82osgp2rCfPM/cp5X0cfQiVMMjUgvKMgQMN1d96917GRyfTg+C6HAsXuq4QK+ ZLbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=vJS8fbu9U9JCrZPWDiCxoN/vTgQDRcj8p7CqTqssr+s=; b=gbn7MNkgO6BksaDWQt4Ps7LDQLJr4WkwJej3s5FFjG4H8yzdpnQ8Eal78H1iT1Ui1i eSWblImdX8TFa/vuHAo094SYpyGQ6TDl/cWD7ezbBvpWFCsIzzI4yUpX1TiEH3ES274C pNNIKeBb5cnoUaSgh73MBk0dGsu2y7lQ+EOi1GMzqcoJl+gpLQsYOjFy5pmlPaUQT9d9 TneFEvtTFebbthJ+k0tJXUzQrmoVivGZaPmv+DDLAgSY3kdAoUYXcXZA2J4W9OzAaUUY y3/+1kdzz2S6RbqWlnc2cGRAvA6OPEeDPL5pXw00XhlBlQWvjzJYuJ7Lg1Zop8YdfWbE Gtfg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si6243294eji.94.2019.10.06.18.22.01; Sun, 06 Oct 2019 18:22:25 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbfJGBSQ (ORCPT + 99 others); Sun, 6 Oct 2019 21:18:16 -0400 Received: from inva020.nxp.com ([92.121.34.13]:37848 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726266AbfJGBSQ (ORCPT ); Sun, 6 Oct 2019 21:18:16 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 3BEFB1A05E8; Mon, 7 Oct 2019 03:18:14 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id C10E61A0009; Mon, 7 Oct 2019 03:18:09 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id BC8B44031E; Mon, 7 Oct 2019 09:18:03 +0800 (SGT) From: Anson Huang To: 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 Cc: Linux-imx@nxp.com Subject: [PATCH V2] firmware: imx: Skip return value check for some special SCU firmware APIs Date: Mon, 7 Oct 2019 09:15:59 +0800 Message-Id: <1570410959-32563-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes since V1: - Use direct API check instead of calling another function to check. - This patch is based on https://patchwork.kernel.org/patch/11129553/ --- drivers/firmware/imx/imx-scu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c index 869be7a..03b43b7 100644 --- a/drivers/firmware/imx/imx-scu.c +++ b/drivers/firmware/imx/imx-scu.c @@ -162,6 +162,7 @@ static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg) */ 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 +172,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) { @@ -191,6 +195,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 ((saved_svc == IMX_SC_RPC_SVC_MISC) && + (saved_func == IMX_SC_MISC_FUNC_UNIQUE_ID || + saved_func == IMX_SC_MISC_FUNC_GET_BUTTON_STATUS)) + ret = 0; } out: -- 2.7.4