From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 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 <angelogioacchino.delregno@collabora.com> Subject: [PATCH 1/2] remoteproc/mtk_scp: Use readl_poll_timeout_atomic() for polling Date: Wed, 4 Jan 2023 12:53:40 +0100 [thread overview] Message-ID: <20230104115341.320951-2-angelogioacchino.delregno@collabora.com> (raw) In-Reply-To: <20230104115341.320951-1-angelogioacchino.delregno@collabora.com> 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 <angelogioacchino.delregno@collabora.com> --- 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 <linux/clk.h> #include <linux/err.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/time64.h> #include <linux/remoteproc/mtk_scp.h> #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
WARNING: multiple messages have this Message-ID (diff)
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 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 <angelogioacchino.delregno@collabora.com> Subject: [PATCH 1/2] remoteproc/mtk_scp: Use readl_poll_timeout_atomic() for polling Date: Wed, 4 Jan 2023 12:53:40 +0100 [thread overview] Message-ID: <20230104115341.320951-2-angelogioacchino.delregno@collabora.com> (raw) In-Reply-To: <20230104115341.320951-1-angelogioacchino.delregno@collabora.com> 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 <angelogioacchino.delregno@collabora.com> --- 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 <linux/clk.h> #include <linux/err.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/time64.h> #include <linux/remoteproc/mtk_scp.h> #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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-01-04 11:53 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-04 11:53 [PATCH 0/2] MediaTek SCP IPI cleanups AngeloGioacchino Del Regno 2023-01-04 11:53 ` AngeloGioacchino Del Regno 2023-01-04 11:53 ` AngeloGioacchino Del Regno [this message] 2023-01-04 11:53 ` [PATCH 1/2] remoteproc/mtk_scp: Use readl_poll_timeout_atomic() for polling AngeloGioacchino Del Regno 2023-01-04 11:53 ` [PATCH 2/2] remoteproc/mtk_scp: Remove timeout variable from scp_ipi_send() AngeloGioacchino Del Regno 2023-01-04 11:53 ` AngeloGioacchino Del Regno 2023-01-04 22:47 ` [PATCH 0/2] MediaTek SCP IPI cleanups Mathieu Poirier 2023-01-04 22:47 ` Mathieu Poirier
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230104115341.320951-2-angelogioacchino.delregno@collabora.com \ --to=angelogioacchino.delregno@collabora.com \ --cc=andersson@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mediatek@lists.infradead.org \ --cc=linux-remoteproc@vger.kernel.org \ --cc=mathieu.poirier@linaro.org \ --cc=matthias.bgg@gmail.com \ --cc=wenst@chromium.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.