linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] MediaTek SCP IPI cleanups
@ 2023-01-04 11:53 AngeloGioacchino Del Regno
  2023-01-04 11:53 ` [PATCH 1/2] remoteproc/mtk_scp: Use readl_poll_timeout_atomic() for polling AngeloGioacchino Del Regno
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-04 11:53 UTC (permalink / raw)
  To: andersson
  Cc: mathieu.poirier, matthias.bgg, linux-remoteproc, linux-arm-kernel,
	linux-mediatek, linux-kernel, wenst, AngeloGioacchino Del Regno

Cleanups bringing no functional changes.
Tested on MT8173 Elm, MT8192 Asurada, MT8195 Tomato.

This series applies only on top of [1].

[1]: https://lore.kernel.org/lkml/20230104083110.736377-1-wenst@chromium.org/

AngeloGioacchino Del Regno (2):
  remoteproc/mtk_scp: Use readl_poll_timeout_atomic() for polling
  remoteproc/mtk_scp: Remove timeout variable from scp_ipi_send()

 drivers/remoteproc/mtk_scp_ipi.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] remoteproc/mtk_scp: Use readl_poll_timeout_atomic() for polling
  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 ` [PATCH 2/2] remoteproc/mtk_scp: Remove timeout variable from scp_ipi_send() AngeloGioacchino Del Regno
  2023-01-04 22:47 ` [PATCH 0/2] MediaTek SCP IPI cleanups Mathieu Poirier
  2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-04 11:53 UTC (permalink / raw)
  To: andersson
  Cc: mathieu.poirier, matthias.bgg, linux-remoteproc, linux-arm-kernel,
	linux-mediatek, linux-kernel, wenst, AngeloGioacchino Del Regno

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] remoteproc/mtk_scp: Remove timeout variable from scp_ipi_send()
  2023-01-04 11:53 [PATCH 0/2] MediaTek SCP IPI cleanups AngeloGioacchino Del Regno
  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 ` AngeloGioacchino Del Regno
  2023-01-04 22:47 ` [PATCH 0/2] MediaTek SCP IPI cleanups Mathieu Poirier
  2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-04 11:53 UTC (permalink / raw)
  To: andersson
  Cc: mathieu.poirier, matthias.bgg, linux-remoteproc, linux-arm-kernel,
	linux-mediatek, linux-kernel, wenst, AngeloGioacchino Del Regno

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 <angelogioacchino.delregno@collabora.com>
---
 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;
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] MediaTek SCP IPI cleanups
  2023-01-04 11:53 [PATCH 0/2] MediaTek SCP IPI cleanups AngeloGioacchino Del Regno
  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 22:47 ` Mathieu Poirier
  2 siblings, 0 replies; 4+ messages in thread
From: Mathieu Poirier @ 2023-01-04 22:47 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: andersson, matthias.bgg, linux-remoteproc, linux-arm-kernel,
	linux-mediatek, linux-kernel, wenst

On Wed, Jan 04, 2023 at 12:53:39PM +0100, AngeloGioacchino Del Regno wrote:
> Cleanups bringing no functional changes.
> Tested on MT8173 Elm, MT8192 Asurada, MT8195 Tomato.
> 
> This series applies only on top of [1].
> 
> [1]: https://lore.kernel.org/lkml/20230104083110.736377-1-wenst@chromium.org/
> 
> AngeloGioacchino Del Regno (2):
>   remoteproc/mtk_scp: Use readl_poll_timeout_atomic() for polling
>   remoteproc/mtk_scp: Remove timeout variable from scp_ipi_send()
>

I have applied both patches.

Thanks,
Mathieu

>  drivers/remoteproc/mtk_scp_ipi.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> -- 
> 2.39.0
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-05  2:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04 11:53 [PATCH 0/2] MediaTek SCP IPI cleanups AngeloGioacchino Del Regno
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 22:47 ` [PATCH 0/2] MediaTek SCP IPI cleanups Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).