mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCHv2] dmaengine: at_hdmac: fix sparse '__iomem' cast warning in memset helpers
@ 2026-07-24 22:59 Rosen Penev
  2026-08-14 21:12 ` Frank Li
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-07-24 22:59 UTC (permalink / raw)
  To: dmaengine
  Cc: Ludovic Desroches, Vinod Koul, Frank Li, Rosen Penev,
	Eugen Hristev, moderated list:MICROCHIP AT91 DMA DRIVERS,
	open list

Both atc_prep_dma_memset() and atc_prep_dma_memset_sg() declare vaddr
as 'void __iomem *' but assign the return of dma_pool_alloc(), which
returns 'void *' (not iomem memory). This causes sparse to warn about
a cast removing the __iomem address space at the dereference site.

The struct field memset_vaddr is also typed as 'int *', which is
neither the type returned by dma_pool_alloc() nor the type used for
the actual writes.

Fix by declaring vaddr as 'u32 *' in both functions and changing
memset_vaddr in struct at_desc from 'int *' to 'u32 *'. This matches
the actual usage and eliminates the need for the (u32 *) cast.

Fixes: 5d8c5bea0da9 ("dmaengine: at_hdmac: add COMPILE_TEST support")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202607231110.8MqNRj0Q-lkp@intel.com/
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 v2: remove extra cast
 drivers/dma/at_hdmac.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 7b6aa9bbc3c8..f24e64219fb5 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -244,7 +244,7 @@ struct at_desc {
 	/* Memset temporary buffer */
 	bool				memset_buffer;
 	dma_addr_t			memset_paddr;
-	int				*memset_vaddr;
+	u32				*memset_vaddr;
 	struct atdma_sg			sg[] __counted_by(sglen);
 };
 
@@ -1097,7 +1097,7 @@ atc_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value,
 	struct at_dma_chan	*atchan = to_at_dma_chan(chan);
 	struct at_dma		*atdma = to_at_dma(chan->device);
 	struct at_desc		*desc;
-	void __iomem		*vaddr;
+	u32			*vaddr;
 	dma_addr_t		paddr;
 	char			fill_pattern;
 	int			ret;
@@ -1126,10 +1126,10 @@ atc_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value,
 	/* Only the first byte of value is to be used according to dmaengine */
 	fill_pattern = (char)value;
 
-	*(u32*)vaddr = (fill_pattern << 24) |
-		       (fill_pattern << 16) |
-		       (fill_pattern << 8) |
-		       fill_pattern;
+	*vaddr = (fill_pattern << 24) |
+		 (fill_pattern << 16) |
+		 (fill_pattern << 8) |
+		  fill_pattern;
 
 	desc = kzalloc_flex(*desc, sg, 1, GFP_ATOMIC);
 	if (!desc)
@@ -1168,7 +1168,7 @@ atc_prep_dma_memset_sg(struct dma_chan *chan,
 	struct at_dma		*atdma = to_at_dma(chan->device);
 	struct at_desc		*desc;
 	struct scatterlist	*sg;
-	void __iomem		*vaddr;
+	u32			*vaddr;
 	dma_addr_t		paddr;
 	size_t			total_len = 0;
 	int			i;
@@ -1189,7 +1189,7 @@ atc_prep_dma_memset_sg(struct dma_chan *chan,
 			__func__);
 		return NULL;
 	}
-	*(u32*)vaddr = value;
+	*vaddr = value;
 
 	desc = kzalloc_flex(*desc, sg, sg_len, GFP_ATOMIC);
 	if (!desc)
-- 
2.55.0


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

* Re: [PATCHv2] dmaengine: at_hdmac: fix sparse '__iomem' cast warning in memset helpers
  2026-07-24 22:59 [PATCHv2] dmaengine: at_hdmac: fix sparse '__iomem' cast warning in memset helpers Rosen Penev
@ 2026-08-14 21:12 ` Frank Li
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-08-14 21:12 UTC (permalink / raw)
  To: Rosen Penev
  Cc: dmaengine, Ludovic Desroches, Vinod Koul, Frank Li,
	Eugen Hristev, moderated list:MICROCHIP AT91 DMA DRIVERS,
	open list

On Fri, Jul 24, 2026 at 03:59:58PM -0700, Rosen Penev wrote:
> Both atc_prep_dma_memset() and atc_prep_dma_memset_sg() declare vaddr
> as 'void __iomem *' but assign the return of dma_pool_alloc(), which
> returns 'void *' (not iomem memory). This causes sparse to warn about
> a cast removing the __iomem address space at the dereference site.
>
> The struct field memset_vaddr is also typed as 'int *', which is
> neither the type returned by dma_pool_alloc() nor the type used for
> the actual writes.
>
> Fix by declaring vaddr as 'u32 *' in both functions and changing
> memset_vaddr in struct at_desc from 'int *' to 'u32 *'. This matches
> the actual usage and eliminates the need for the (u32 *) cast.
>
> Fixes: 5d8c5bea0da9 ("dmaengine: at_hdmac: add COMPILE_TEST support")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202607231110.8MqNRj0Q-lkp@intel.com/
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  v2: remove extra cast
>  drivers/dma/at_hdmac.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index 7b6aa9bbc3c8..f24e64219fb5 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
> @@ -244,7 +244,7 @@ struct at_desc {
>  	/* Memset temporary buffer */
>  	bool				memset_buffer;
>  	dma_addr_t			memset_paddr;
> -	int				*memset_vaddr;
> +	u32				*memset_vaddr;
>  	struct atdma_sg			sg[] __counted_by(sglen);
>  };
>
> @@ -1097,7 +1097,7 @@ atc_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value,
>  	struct at_dma_chan	*atchan = to_at_dma_chan(chan);
>  	struct at_dma		*atdma = to_at_dma(chan->device);
>  	struct at_desc		*desc;
> -	void __iomem		*vaddr;
> +	u32			*vaddr;
>  	dma_addr_t		paddr;
>  	char			fill_pattern;
>  	int			ret;
> @@ -1126,10 +1126,10 @@ atc_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value,
>  	/* Only the first byte of value is to be used according to dmaengine */
>  	fill_pattern = (char)value;
>
> -	*(u32*)vaddr = (fill_pattern << 24) |
> -		       (fill_pattern << 16) |
> -		       (fill_pattern << 8) |
> -		       fill_pattern;
> +	*vaddr = (fill_pattern << 24) |
> +		 (fill_pattern << 16) |
> +		 (fill_pattern << 8) |
> +		  fill_pattern;
>
>  	desc = kzalloc_flex(*desc, sg, 1, GFP_ATOMIC);
>  	if (!desc)
> @@ -1168,7 +1168,7 @@ atc_prep_dma_memset_sg(struct dma_chan *chan,
>  	struct at_dma		*atdma = to_at_dma(chan->device);
>  	struct at_desc		*desc;
>  	struct scatterlist	*sg;
> -	void __iomem		*vaddr;
> +	u32			*vaddr;
>  	dma_addr_t		paddr;
>  	size_t			total_len = 0;
>  	int			i;
> @@ -1189,7 +1189,7 @@ atc_prep_dma_memset_sg(struct dma_chan *chan,
>  			__func__);
>  		return NULL;
>  	}
> -	*(u32*)vaddr = value;
> +	*vaddr = value;
>
>  	desc = kzalloc_flex(*desc, sg, sg_len, GFP_ATOMIC);
>  	if (!desc)
> --
> 2.55.0
>

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

end of thread, other threads:[~2026-08-14 21:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-24 22:59 [PATCHv2] dmaengine: at_hdmac: fix sparse '__iomem' cast warning in memset helpers Rosen Penev
2026-08-14 21:12 ` Frank Li

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

all inboxes | Powered by JetHome®