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: 38880 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5102084wrt; Wed, 4 Jan 2023 03:56:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXsDcNzLTd3K3FF0yTFi0z5WJ31fTjcizUA4Sx1opjsnsEadTzBJqF1lgY9S3XTDSlJ91hPx X-Received: by 2002:a17:906:2ccc:b0:7c0:e23d:12c4 with SMTP id r12-20020a1709062ccc00b007c0e23d12c4mr36682709ejr.63.1672833387752; Wed, 04 Jan 2023 03:56:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672833387; cv=none; d=google.com; s=arc-20160816; b=OIrJCnu2owRZZFtJv0et0a6CWCgtxK7dhptqc/MtLf94pI8jNMkiSa5Bi33g0NOnag fi6+xAXXeY+fSviC6AaJOJlppk6susTSUiLbEsW9TAv0l6KF0S/cmmkcTT/fbybCTZJp ZTqpyjQFmkgNLrw9Wkcl2JKdDj4XItopaJtNusSsFhEQ8IrsqpbBf7Bf+IL6WiyiuqhA hlPDlsOoFWkQjisK2Y8VGCST7dz9j7VC5fGH8cYdWtitW8CIzc3YTc7FwvZfQr/OHiuP YtZerLN5OfgddNT0KTrsZ7bfotcHopc7oyTjlN+xvsj2flceHtIBfTWZYmiIRA0h8Jju LzAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O9ZGJ7Jp9oQ22M78uPvC1nEDZDYsnt+58xOGIQtTnt4=; b=kCkkX9hTSj/VL6YvyuSy+8MHI6YoNo8hyQwy3GwCvElnAMjOAV8dyzDA8n49SFoAIB 9fZu3RuERhbTP7CP2VkXDIuseXQ6B5vhOOhL5mqJlSNJTJrCsKxRru+cjOZQRv2pV1al w7Uouri6lNw+UULJNJpDT8lH3jOu0m58i66wJPhPTHEySM3kNzTVbEWpF+5BAn05kOqp 3TBc1LnFqZJ92HKdn5Ypd72+b0YGQnApS8UvF4otEBm3lL+t1ng+nExGasct9SRYHkmT jgr5rnWh2VQU8Gk6vPSOudFuHILAQroG5PUSIVc2VAe4WVRzLQHJauTJhNGfoa0yGDRR VzLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SlFYipZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a056402084500b00463b0df4604si35049612edz.488.2023.01.04.03.56.04; Wed, 04 Jan 2023 03:56:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SlFYipZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239133AbjADLx5 (ORCPT + 99 others); Wed, 4 Jan 2023 06:53:57 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754092942440058951?= X-GMAIL-MSGID: =?utf-8?q?1754092942440058951?= 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: 38881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5102144wrt; Wed, 4 Jan 2023 03:56:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXtQEr61en9H1PFy1kcfI3HZqfj4tbCZRIgYgbqxU93O9eSudyw9k4kOwe21fqNmcFzx3Hvt X-Received: by 2002:a17:906:fcc1:b0:7c0:e310:3191 with SMTP id qx1-20020a170906fcc100b007c0e3103191mr51831568ejb.11.1672833398224; Wed, 04 Jan 2023 03:56:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672833398; cv=none; d=google.com; s=arc-20160816; b=Wle/LY632ipIYbCQ12nSv9KWnXDzjrklh5fOXE5Z+u7z9AqaeKnIOXeC7J1h8EgfK0 yJ2N2ha6rQnoJpLCwupF6OG1DTmisdmTejUL8jru8nlLlDn7t3aN2W1NEHJCrNtf332k asejPxl7jNTActLtisvyWW+LAOcPfdKoGUy4/O0gKo2Ai/87DYLsQ1r0/uCc2Wewt7a6 /LAT+7iPT671QC4eadMxs+EQ3cCyFDfCePiuz5ZznrffIoksau21VwiqUqgorSWYO2Eo 95ARoixY4y3XdoILEDgBavd/hPaGh64n2MSUz3P8+qYl7YTrCst9atgVXGTsT8CgvmBK Ez5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ah6dyrT41r5BxS/Hb5ZCXo1J7cLNhawslXRMpW4jJyk=; b=xj2pbBLydUPKAlMEFZ9+HQTySfN9v9e/LZyxpBR7Ug4UYSNc9NFSUss9jNLBKO6D7L rjGFgQHiPaOEQ7ZGsygwyag03a84S8CZaCeKa0XPGhD+K0o1vBIS5PXNTGih7nc8uM/+ 9NYPbvwdWFot2wekREhTWtskMOIIiGLewRFGkO+7z0dic5l26SQP1svLG8VuxvBfFq99 xLd3rPJQzChYwsKNnQ0CkC5AMmKVqnQ7Cdmgg7e6GLrcvrB8xDwKn8/fRDqoim4Er4Oy hgHXNHChPcZ3lrVXwUOzb9C7DEo7c157e1ZsdS+Qz+jr1t2LozRNUrrDQkC23q2zT0LU 6CLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nG9YtxlC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a1709064fc800b007c89c44ec82si33068932ejw.84.2023.01.04.03.56.13; Wed, 04 Jan 2023 03:56:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nG9YtxlC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239150AbjADLyA (ORCPT + 99 others); Wed, 4 Jan 2023 06:54:00 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754092953014239110?= X-GMAIL-MSGID: =?utf-8?q?1754092953014239110?= 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;