Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13130548rwl; Wed, 4 Jan 2023 04:06:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXuGcCIJ1eIsbREosP06SM37ZAZPdeYGtVu/9f1aVBAAWutj6szsGpFHLNtKUzJNG8v3bgKL X-Received: by 2002:a17:907:7da4:b0:78d:f455:b5dc with SMTP id oz36-20020a1709077da400b0078df455b5dcmr49437192ejc.28.1672833967069; Wed, 04 Jan 2023 04:06:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672833967; cv=none; d=google.com; s=arc-20160816; b=BRnQO7tncBDvmSfFmcfU41aFIraq8vztgd4bEfFhTJC1URP5T1WpR8b1DY+7l7QFsb NEomVJoEwreKQEJzMos55fWVbm0AjxP6xDD63/qHhqlf3GUP3vS+E334fdfraNCPXkoj 4ihpNPoiNbFcy/ohZKtWxanM1y7CyEdJah8B/IuJY7q0tWTKBvPlcmanZyA6928Nel4R /3i65ahGHyu5mbCJbvRd3dW81bSlKH4xch73mpnemCSPvSXbchce4PKzFN/+cuIR4CZS +81Ye5SQ6TU/Ujwu6gij0ihdie0NrN/BpJ5xtXdFGLYJZFIggEts5ZONLy/5GaMCUbZ0 3wFw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd22-20020a1709069b9600b007c14eabf6adsi33014779ejc.116.2023.01.04.04.05.47; Wed, 04 Jan 2023 04:06:07 -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 + 59 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 Content-Transfer-Encoding: 8bit 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 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); -- 2.39.0