public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] remoteproc: mediatek: Zero out only remaining bytes of IPI buffer
@ 2024-05-20 11:27 AngeloGioacchino Del Regno
  2024-05-20 15:01 ` Mukesh Ojha
  2024-05-21 16:47 ` Mathieu Poirier
  0 siblings, 2 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-05-20 11:27 UTC (permalink / raw)
  To: mathieu.poirier
  Cc: andersson, matthias.bgg, angelogioacchino.delregno,
	linux-remoteproc, linux-kernel, linux-arm-kernel, linux-mediatek,
	kernel

In scp_ipi_handler(), instead of zeroing out the entire shared
buffer, which may be as large as 600 bytes, overwrite it with the
received data, then zero out only the remaining bytes.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/remoteproc/mtk_scp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index e5214d43181e..dc70cf7db44d 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -117,8 +117,8 @@ static void scp_ipi_handler(struct mtk_scp *scp)
 		return;
 	}
 
-	memset(scp->share_buf, 0, scp_sizes->ipi_share_buffer_size);
 	memcpy_fromio(scp->share_buf, &rcv_obj->share_buf, len);
+	memset(&scp->share_buf[len], 0, scp_sizes->ipi_share_buffer_size - len);
 	handler(scp->share_buf, len, ipi_desc[id].priv);
 	scp_ipi_unlock(scp, id);
 
-- 
2.45.1


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

* Re: [PATCH] remoteproc: mediatek: Zero out only remaining bytes of IPI buffer
  2024-05-20 11:27 [PATCH] remoteproc: mediatek: Zero out only remaining bytes of IPI buffer AngeloGioacchino Del Regno
@ 2024-05-20 15:01 ` Mukesh Ojha
  2024-05-21 16:47 ` Mathieu Poirier
  1 sibling, 0 replies; 3+ messages in thread
From: Mukesh Ojha @ 2024-05-20 15:01 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, mathieu.poirier
  Cc: andersson, matthias.bgg, linux-remoteproc, linux-kernel,
	linux-arm-kernel, linux-mediatek, kernel



On 5/20/2024 4:57 PM, AngeloGioacchino Del Regno wrote:
> In scp_ipi_handler(), instead of zeroing out the entire shared
> buffer, which may be as large as 600 bytes, overwrite it with the
> received data, then zero out only the remaining bytes.
> 
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
>   drivers/remoteproc/mtk_scp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index e5214d43181e..dc70cf7db44d 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -117,8 +117,8 @@ static void scp_ipi_handler(struct mtk_scp *scp)
>   		return;
>   	}
>   
> -	memset(scp->share_buf, 0, scp_sizes->ipi_share_buffer_size);
>   	memcpy_fromio(scp->share_buf, &rcv_obj->share_buf, len);
> +	memset(&scp->share_buf[len], 0, scp_sizes->ipi_share_buffer_size - len);

Although, it does not make any difference apart from a write of len 
bytes, still a good improvement to do ..

Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>

-Mukesh

>   	handler(scp->share_buf, len, ipi_desc[id].priv);
>   	scp_ipi_unlock(scp, id);
>   

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

* Re: [PATCH] remoteproc: mediatek: Zero out only remaining bytes of IPI buffer
  2024-05-20 11:27 [PATCH] remoteproc: mediatek: Zero out only remaining bytes of IPI buffer AngeloGioacchino Del Regno
  2024-05-20 15:01 ` Mukesh Ojha
@ 2024-05-21 16:47 ` Mathieu Poirier
  1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Poirier @ 2024-05-21 16:47 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: andersson, matthias.bgg, linux-remoteproc, linux-kernel,
	linux-arm-kernel, linux-mediatek, kernel

On Mon, May 20, 2024 at 01:27:24PM +0200, AngeloGioacchino Del Regno wrote:
> In scp_ipi_handler(), instead of zeroing out the entire shared
> buffer, which may be as large as 600 bytes, overwrite it with the
> received data, then zero out only the remaining bytes.
> 
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
>  drivers/remoteproc/mtk_scp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index e5214d43181e..dc70cf7db44d 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -117,8 +117,8 @@ static void scp_ipi_handler(struct mtk_scp *scp)
>  		return;
>  	}
>  
> -	memset(scp->share_buf, 0, scp_sizes->ipi_share_buffer_size);
>  	memcpy_fromio(scp->share_buf, &rcv_obj->share_buf, len);
> +	memset(&scp->share_buf[len], 0, scp_sizes->ipi_share_buffer_size - len);

I will apply this patch when rc1 comes out next week.

Thanks,
Mathieu

>  	handler(scp->share_buf, len, ipi_desc[id].priv);
>  	scp_ipi_unlock(scp, id);
>  
> -- 
> 2.45.1
> 

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

end of thread, other threads:[~2024-05-21 16:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-20 11:27 [PATCH] remoteproc: mediatek: Zero out only remaining bytes of IPI buffer AngeloGioacchino Del Regno
2024-05-20 15:01 ` Mukesh Ojha
2024-05-21 16:47 ` Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox