From patchwork Wed Jan 4 11:53:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13088513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 438FBC46467 for ; Wed, 4 Jan 2023 11:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238964AbjADLxy (ORCPT ); Wed, 4 Jan 2023 06:53:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbjADLxx (ORCPT ); Wed, 4 Jan 2023 06:53:53 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCA7A1ADA6; Wed, 4 Jan 2023 03:53:52 -0800 (PST) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id E60EA6602D0D; Wed, 4 Jan 2023 11:53:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1672833231; bh=vP3IAcg06zI74g3paG4cXxNW+LMkpVI/HPlq08rPNm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SlFYipZI9wBvadHJlDs3O0ADsIrxmlpLkBnGKw5RNDS8To3+QNFhXvVLwrWABIR4E MNxpDL2tnCDB8QDv6uKbanD2jxChPdL+MBFLJ7kk8I1Z1GofdwrXR0GrZrMQ2Pxva/ kIfBvnVSFETVHM9NBpM70al6Dfs3TBtFeLIMVNU4mbAw+KpYyTmaI/xa5s5MYDF18f yJnd7HxEmEzY81mx8f9xapa1hin+HhoKnBeqw5rj41F8Jl+WyfrtSHcDWe/8NpmDRz aQQyQySLuaHcdbvEmANhyie7SKkl7NEM9qcIL33jiPcS0gSCHJcexyeQNc6He4164N O4jlIWuoFMm1w== From: AngeloGioacchino Del Regno To: andersson@kernel.org Cc: mathieu.poirier@linaro.org, matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, wenst@chromium.org, AngeloGioacchino Del Regno Subject: [PATCH 1/2] remoteproc/mtk_scp: Use readl_poll_timeout_atomic() for polling Date: Wed, 4 Jan 2023 12:53:40 +0100 Message-Id: <20230104115341.320951-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230104115341.320951-1-angelogioacchino.delregno@collabora.com> References: <20230104115341.320951-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Convert the usage of an open-coded custom tight poll while loop with the provided readl_poll_timeout_atomic() macro. This cleanup brings no functional change. Signed-off-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_scp_ipi.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/remoteproc/mtk_scp_ipi.c b/drivers/remoteproc/mtk_scp_ipi.c index 4c0d121c2f54..af47504bdb61 100644 --- a/drivers/remoteproc/mtk_scp_ipi.c +++ b/drivers/remoteproc/mtk_scp_ipi.c @@ -6,13 +6,17 @@ #include #include #include +#include #include #include #include +#include #include #include "mtk_common.h" +#define SCP_TIMEOUT_US (2000 * USEC_PER_MSEC) + /** * scp_ipi_register() - register an ipi function * @@ -157,6 +161,7 @@ int scp_ipi_send(struct mtk_scp *scp, u32 id, void *buf, unsigned int len, { struct mtk_share_obj __iomem *send_obj = scp->send_buf; unsigned long timeout; + u32 val; int ret; if (WARN_ON(id <= SCP_IPI_INIT) || WARN_ON(id >= SCP_IPI_MAX) || @@ -173,14 +178,12 @@ int scp_ipi_send(struct mtk_scp *scp, u32 id, void *buf, unsigned int len, mutex_lock(&scp->send_lock); /* Wait until SCP receives the last command */ - timeout = jiffies + msecs_to_jiffies(2000); - do { - if (time_after(jiffies, timeout)) { - dev_err(scp->dev, "%s: IPI timeout!\n", __func__); - ret = -ETIMEDOUT; - goto unlock_mutex; - } - } while (readl(scp->reg_base + scp->data->host_to_scp_reg)); + ret = readl_poll_timeout_atomic(scp->reg_base + scp->data->host_to_scp_reg, + val, !val, 0, SCP_TIMEOUT_US); + if (ret) { + dev_err(scp->dev, "%s: IPI timeout!\n", __func__); + goto unlock_mutex; + } scp_memcpy_aligned(send_obj->share_buf, buf, len); From patchwork Wed Jan 4 11:53:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13088514 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D2FFC4708E for ; Wed, 4 Jan 2023 11:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239083AbjADLxz (ORCPT ); Wed, 4 Jan 2023 06:53:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234981AbjADLxy (ORCPT ); Wed, 4 Jan 2023 06:53:54 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 392361ADB0; Wed, 4 Jan 2023 03:53:53 -0800 (PST) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8DC066602D0F; Wed, 4 Jan 2023 11:53:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1672833232; bh=2wlL/l4UVdjL1Sgoaf9FkMG8l//bAlIIYXjMNm/jsVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nG9YtxlCpjBCeQOKrMwEtYzNapyLY6ccOPHmL66vj0KAIBNw72cQvDIaARvyeFDaL yYNo7gzc8J8hgzJX9qwqb/3CHf28jwOdr4e36SnO5d6gmSoiiSpDozdp6wlj+B90oM mj37MP7AlorWVTwZLmQzYwRz/sfuAobepb9Sw8TPRTk8Ed6aLcPnDeoJphwmYQhhlU cnbVpVFvFM76Hu/cy03ym3Bbh2qJjEIRtkrayygYRVtG2OJqEwzoYDLpslteYrzU9u DJTQrLYpAO2s7LxbJ7AZowZj7cPJW6e96VS4e3/Mcox5bxnTkUzkHI61kBhWrceozk Pr3ijnFVb6kYQ== From: AngeloGioacchino Del Regno To: andersson@kernel.org Cc: mathieu.poirier@linaro.org, matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, wenst@chromium.org, AngeloGioacchino Del Regno Subject: [PATCH 2/2] remoteproc/mtk_scp: Remove timeout variable from scp_ipi_send() Date: Wed, 4 Jan 2023 12:53:41 +0100 Message-Id: <20230104115341.320951-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230104115341.320951-1-angelogioacchino.delregno@collabora.com> References: <20230104115341.320951-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org That variable was used twice, but now it's just used once to store msecs_to_jiffies(wait), fed to wait_event_timeout(): we might as well remove it for the sake of cleaning up. This brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_scp_ipi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/remoteproc/mtk_scp_ipi.c b/drivers/remoteproc/mtk_scp_ipi.c index af47504bdb61..fc55df649b40 100644 --- a/drivers/remoteproc/mtk_scp_ipi.c +++ b/drivers/remoteproc/mtk_scp_ipi.c @@ -160,7 +160,6 @@ int scp_ipi_send(struct mtk_scp *scp, u32 id, void *buf, unsigned int len, unsigned int wait) { struct mtk_share_obj __iomem *send_obj = scp->send_buf; - unsigned long timeout; u32 val; int ret; @@ -197,10 +196,9 @@ int scp_ipi_send(struct mtk_scp *scp, u32 id, void *buf, unsigned int len, if (wait) { /* wait for SCP's ACK */ - timeout = msecs_to_jiffies(wait); ret = wait_event_timeout(scp->ack_wq, scp->ipi_id_ack[id], - timeout); + msecs_to_jiffies(wait)); scp->ipi_id_ack[id] = false; if (WARN(!ret, "scp ipi %d ack time out !", id)) ret = -EIO;