Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1806389ybn; Thu, 26 Sep 2019 02:29:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3+ifbBGdeMfI+Ox/hMBT/8IfRwRQnTW25zruaLxMleJbxvzpG05rWWS2gYfB5CcaJBMJf X-Received: by 2002:a17:906:1f57:: with SMTP id d23mr2185991ejk.103.1569490169164; Thu, 26 Sep 2019 02:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569490169; cv=none; d=google.com; s=arc-20160816; b=GSyB1F/LNvravjdEDhHuq1fNyJC1U5t4ANI40QbJ4ImGe652T9SvQbVwgQBsjv4uSK RFmOs0w0Z3k7zA4dySV3f/DjUQfRWAZSApZnOK5RmrOb4mww0WQKHZbdPj7qJyzXLRr6 yPGsSfc+DHdxoKLhAEPRgMrfcJ2zyIN+t+Ivayaepig1SSR2YJ1Qm2rguWmzrdHS5jk5 5/s+3Mp0MXksBx8ABqdmiUJs4bbBQN53GTtEOmBqAvJaMoWZdKzcxwcIChhnuQ1bmCZN VB4xTo0/GoJ5+ZxAIRagYLxSdUykYzWpYkrDJRRfHcQdfgxTduZZ7/x1sQoN0XstuHK0 I1sw== 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=ons3daUrLfIW9ceTGbrGjyOqHQdha9bpJNAo52ke+pg=; b=DsemfGT6K3UzxUQzndCEYexIvYkdfYdw08/RGXFMTzt5YLoZGL8jpEmTiYTtm0gnis sClJgZInLna6aokCKHhJa4QvdbZ6IUNoXSUqDeb1lpcFWznWT+nFE/KV1U/8NDIofOez OG043KjkaMEAlLpkKmytYc8gUnx4LLlUuS2FJ97MDlE1vZCUxJ2PrlQU45+ZxQpiExyb DURURA+eakdf+Z07p22165/z7/b3TiA/PuI5vN1yq7T4Q2MYrDkAVQ90bAoVl8+DQb2o RBDO4qyQ6wHxgk1Ub9zEoZBUqUuYVKtJwaYuKvjvu7HRKsOeN6ZkGxT2q4XX8o8yDgVh inbw== 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 u3si718097ejj.47.2019.09.26.02.29.05; Thu, 26 Sep 2019 02:29:29 -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 S1728394AbfIYKJa (ORCPT + 99 others); Wed, 25 Sep 2019 06:09:30 -0400 Received: from inva020.nxp.com ([92.121.34.13]:39274 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbfIYKJa (ORCPT ); Wed, 25 Sep 2019 06:09:30 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CCC431A0824; Wed, 25 Sep 2019 12:09:27 +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 9B6C71A00DD; Wed, 25 Sep 2019 12:09:23 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 2FE40402ED; Wed, 25 Sep 2019 18:09:18 +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] firmware: imx: Skip return value check for some special SCU firmware APIs Date: Wed, 25 Sep 2019 18:07:46 +0800 Message-Id: <1569406066-16626-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 --- - 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 }, +}; + 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