public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning
@ 2024-02-09 21:08 Frank Li
  2024-02-16 12:33 ` Vinod Koul
  2024-02-23 12:08 ` Vinod Koul
  0 siblings, 2 replies; 4+ messages in thread
From: Frank Li @ 2024-02-09 21:08 UTC (permalink / raw)
  To: Vinod Koul, open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM,
	open list; +Cc: imx

Fix below sparse warnings.

drivers/dma/fsl-qdma.c:645:50: sparse: warning: incorrect type in argument 2 (different address spaces)
drivers/dma/fsl-qdma.c:645:50: sparse:    expected void [noderef] __iomem *addr
drivers/dma/fsl-qdma.c:645:50: sparse:    got void

drivers/dma/fsl-qdma.c:387:15: sparse: sparse: restricted __le32 degrades to integer
drivers/dma/fsl-qdma.c:390:19: sparse:     expected restricted __le64 [usertype] data
drivers/dma/fsl-qdma.c:392:13: sparse:     expected unsigned int [assigned] [usertype] cmd

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202402081929.mggOTHaZ-lkp@intel.com/
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/dma/fsl-qdma.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c
index 1e3bf6f30f784..5005e138fc239 100644
--- a/drivers/dma/fsl-qdma.c
+++ b/drivers/dma/fsl-qdma.c
@@ -161,6 +161,10 @@ struct fsl_qdma_format {
 			u8 __reserved1[2];
 			u8 cfg8b_w1;
 		} __packed;
+		struct {
+			__le32 __reserved2;
+			__le32 cmd;
+		} __packed;
 		__le64 data;
 	};
 } __packed;
@@ -355,7 +359,6 @@ static void fsl_qdma_free_chan_resources(struct dma_chan *chan)
 static void fsl_qdma_comp_fill_memcpy(struct fsl_qdma_comp *fsl_comp,
 				      dma_addr_t dst, dma_addr_t src, u32 len)
 {
-	u32 cmd;
 	struct fsl_qdma_format *sdf, *ddf;
 	struct fsl_qdma_format *ccdf, *csgf_desc, *csgf_src, *csgf_dest;
 
@@ -384,15 +387,11 @@ static void fsl_qdma_comp_fill_memcpy(struct fsl_qdma_comp *fsl_comp,
 	/* This entry is the last entry. */
 	qdma_csgf_set_f(csgf_dest, len);
 	/* Descriptor Buffer */
-	cmd = cpu_to_le32(FSL_QDMA_CMD_RWTTYPE <<
-			  FSL_QDMA_CMD_RWTTYPE_OFFSET) |
-			  FSL_QDMA_CMD_PF;
-	sdf->data = QDMA_SDDF_CMD(cmd);
-
-	cmd = cpu_to_le32(FSL_QDMA_CMD_RWTTYPE <<
-			  FSL_QDMA_CMD_RWTTYPE_OFFSET);
-	cmd |= cpu_to_le32(FSL_QDMA_CMD_LWC << FSL_QDMA_CMD_LWC_OFFSET);
-	ddf->data = QDMA_SDDF_CMD(cmd);
+	sdf->cmd = cpu_to_le32((FSL_QDMA_CMD_RWTTYPE << FSL_QDMA_CMD_RWTTYPE_OFFSET) |
+			       FSL_QDMA_CMD_PF);
+
+	ddf->cmd = cpu_to_le32((FSL_QDMA_CMD_RWTTYPE << FSL_QDMA_CMD_RWTTYPE_OFFSET) |
+			       (FSL_QDMA_CMD_LWC << FSL_QDMA_CMD_LWC_OFFSET));
 }
 
 /*
@@ -626,7 +625,7 @@ static int fsl_qdma_halt(struct fsl_qdma_engine *fsl_qdma)
 
 static int
 fsl_qdma_queue_transfer_complete(struct fsl_qdma_engine *fsl_qdma,
-				 void *block,
+				 __iomem void *block,
 				 int id)
 {
 	bool duplicate;
-- 
2.34.1


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

* Re: [PATCH 1/1] dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning
  2024-02-09 21:08 [PATCH 1/1] dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning Frank Li
@ 2024-02-16 12:33 ` Vinod Koul
  2024-02-16 15:00   ` Frank Li
  2024-02-23 12:08 ` Vinod Koul
  1 sibling, 1 reply; 4+ messages in thread
From: Vinod Koul @ 2024-02-16 12:33 UTC (permalink / raw)
  To: Frank Li; +Cc: open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM, open list, imx

On 09-02-24, 16:08, Frank Li wrote:
> Fix below sparse warnings.
> 
> drivers/dma/fsl-qdma.c:645:50: sparse: warning: incorrect type in argument 2 (different address spaces)
> drivers/dma/fsl-qdma.c:645:50: sparse:    expected void [noderef] __iomem *addr
> drivers/dma/fsl-qdma.c:645:50: sparse:    got void
> 
> drivers/dma/fsl-qdma.c:387:15: sparse: sparse: restricted __le32 degrades to integer
> drivers/dma/fsl-qdma.c:390:19: sparse:     expected restricted __le64 [usertype] data
> drivers/dma/fsl-qdma.c:392:13: sparse:     expected unsigned int [assigned] [usertype] cmd

Please document why you are adding the annotations

Also I see this after the patch:

dmaengine/drivers/dma/fsl-edma-main.c:56:16: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-main.c:60:9: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:76:15: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:93:9: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:100:22: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:101:25: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:104:15: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:106:9: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:131:19: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:137:17: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:140:9: warning: cast removes address space '__iomem' of expression
  CC [M]  drivers/dma/idma64.o
dmaengine/drivers/dma/fsl-edma-common.c:473:17: warning: cast removes address space '__iomem' of expression
dmaengine/drivers/dma/fsl-edma-common.c:473:17: warning: cast removes address space '__iomem' of expression

> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202402081929.mggOTHaZ-lkp@intel.com/
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>  drivers/dma/fsl-qdma.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c
> index 1e3bf6f30f784..5005e138fc239 100644
> --- a/drivers/dma/fsl-qdma.c
> +++ b/drivers/dma/fsl-qdma.c
> @@ -161,6 +161,10 @@ struct fsl_qdma_format {
>  			u8 __reserved1[2];
>  			u8 cfg8b_w1;
>  		} __packed;
> +		struct {
> +			__le32 __reserved2;
> +			__le32 cmd;
> +		} __packed;
>  		__le64 data;
>  	};
>  } __packed;
> @@ -355,7 +359,6 @@ static void fsl_qdma_free_chan_resources(struct dma_chan *chan)
>  static void fsl_qdma_comp_fill_memcpy(struct fsl_qdma_comp *fsl_comp,
>  				      dma_addr_t dst, dma_addr_t src, u32 len)
>  {
> -	u32 cmd;
>  	struct fsl_qdma_format *sdf, *ddf;
>  	struct fsl_qdma_format *ccdf, *csgf_desc, *csgf_src, *csgf_dest;
>  
> @@ -384,15 +387,11 @@ static void fsl_qdma_comp_fill_memcpy(struct fsl_qdma_comp *fsl_comp,
>  	/* This entry is the last entry. */
>  	qdma_csgf_set_f(csgf_dest, len);
>  	/* Descriptor Buffer */
> -	cmd = cpu_to_le32(FSL_QDMA_CMD_RWTTYPE <<
> -			  FSL_QDMA_CMD_RWTTYPE_OFFSET) |
> -			  FSL_QDMA_CMD_PF;
> -	sdf->data = QDMA_SDDF_CMD(cmd);
> -
> -	cmd = cpu_to_le32(FSL_QDMA_CMD_RWTTYPE <<
> -			  FSL_QDMA_CMD_RWTTYPE_OFFSET);
> -	cmd |= cpu_to_le32(FSL_QDMA_CMD_LWC << FSL_QDMA_CMD_LWC_OFFSET);
> -	ddf->data = QDMA_SDDF_CMD(cmd);
> +	sdf->cmd = cpu_to_le32((FSL_QDMA_CMD_RWTTYPE << FSL_QDMA_CMD_RWTTYPE_OFFSET) |
> +			       FSL_QDMA_CMD_PF);
> +
> +	ddf->cmd = cpu_to_le32((FSL_QDMA_CMD_RWTTYPE << FSL_QDMA_CMD_RWTTYPE_OFFSET) |
> +			       (FSL_QDMA_CMD_LWC << FSL_QDMA_CMD_LWC_OFFSET));
>  }
>  
>  /*
> @@ -626,7 +625,7 @@ static int fsl_qdma_halt(struct fsl_qdma_engine *fsl_qdma)
>  
>  static int
>  fsl_qdma_queue_transfer_complete(struct fsl_qdma_engine *fsl_qdma,
> -				 void *block,
> +				 __iomem void *block,
>  				 int id)
>  {
>  	bool duplicate;
> -- 
> 2.34.1

-- 
~Vinod

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

* Re: [PATCH 1/1] dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning
  2024-02-16 12:33 ` Vinod Koul
@ 2024-02-16 15:00   ` Frank Li
  0 siblings, 0 replies; 4+ messages in thread
From: Frank Li @ 2024-02-16 15:00 UTC (permalink / raw)
  To: Vinod Koul; +Cc: open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM, open list, imx

On Fri, Feb 16, 2024 at 06:03:29PM +0530, Vinod Koul wrote:
> On 09-02-24, 16:08, Frank Li wrote:
> > Fix below sparse warnings.
> > 
> > drivers/dma/fsl-qdma.c:645:50: sparse: warning: incorrect type in argument 2 (different address spaces)
> > drivers/dma/fsl-qdma.c:645:50: sparse:    expected void [noderef] __iomem *addr
> > drivers/dma/fsl-qdma.c:645:50: sparse:    got void
> > 
> > drivers/dma/fsl-qdma.c:387:15: sparse: sparse: restricted __le32 degrades to integer
> > drivers/dma/fsl-qdma.c:390:19: sparse:     expected restricted __le64 [usertype] data
> > drivers/dma/fsl-qdma.c:392:13: sparse:     expected unsigned int [assigned] [usertype] cmd
> 
> Please document why you are adding the annotations

Okay, I will add at next version.

> 
> Also I see this after the patch:

Strange!, it is difference driver (fsl-qdma.c, which will not touch
fsl-edma*). the below warning should exist or invovled by other patches.

Did you try antoher patches
https://lore.kernel.org/imx/20240209213606.367025-1-Frank.Li@nxp.com/T/#t

what's command do you build to see below warning.

Frank

> 
> dmaengine/drivers/dma/fsl-edma-main.c:56:16: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-main.c:60:9: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:76:15: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:93:9: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:100:22: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:101:25: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:104:15: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:106:9: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:131:19: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:137:17: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:140:9: warning: cast removes address space '__iomem' of expression
>   CC [M]  drivers/dma/idma64.o
> dmaengine/drivers/dma/fsl-edma-common.c:473:17: warning: cast removes address space '__iomem' of expression
> dmaengine/drivers/dma/fsl-edma-common.c:473:17: warning: cast removes address space '__iomem' of expression
> 
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202402081929.mggOTHaZ-lkp@intel.com/
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> >  drivers/dma/fsl-qdma.c | 21 ++++++++++-----------
> >  1 file changed, 10 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c
> > index 1e3bf6f30f784..5005e138fc239 100644
> > --- a/drivers/dma/fsl-qdma.c
> > +++ b/drivers/dma/fsl-qdma.c
> > @@ -161,6 +161,10 @@ struct fsl_qdma_format {
> >  			u8 __reserved1[2];
> >  			u8 cfg8b_w1;
> >  		} __packed;
> > +		struct {
> > +			__le32 __reserved2;
> > +			__le32 cmd;
> > +		} __packed;
> >  		__le64 data;
> >  	};
> >  } __packed;
> > @@ -355,7 +359,6 @@ static void fsl_qdma_free_chan_resources(struct dma_chan *chan)
> >  static void fsl_qdma_comp_fill_memcpy(struct fsl_qdma_comp *fsl_comp,
> >  				      dma_addr_t dst, dma_addr_t src, u32 len)
> >  {
> > -	u32 cmd;
> >  	struct fsl_qdma_format *sdf, *ddf;
> >  	struct fsl_qdma_format *ccdf, *csgf_desc, *csgf_src, *csgf_dest;
> >  
> > @@ -384,15 +387,11 @@ static void fsl_qdma_comp_fill_memcpy(struct fsl_qdma_comp *fsl_comp,
> >  	/* This entry is the last entry. */
> >  	qdma_csgf_set_f(csgf_dest, len);
> >  	/* Descriptor Buffer */
> > -	cmd = cpu_to_le32(FSL_QDMA_CMD_RWTTYPE <<
> > -			  FSL_QDMA_CMD_RWTTYPE_OFFSET) |
> > -			  FSL_QDMA_CMD_PF;
> > -	sdf->data = QDMA_SDDF_CMD(cmd);
> > -
> > -	cmd = cpu_to_le32(FSL_QDMA_CMD_RWTTYPE <<
> > -			  FSL_QDMA_CMD_RWTTYPE_OFFSET);
> > -	cmd |= cpu_to_le32(FSL_QDMA_CMD_LWC << FSL_QDMA_CMD_LWC_OFFSET);
> > -	ddf->data = QDMA_SDDF_CMD(cmd);
> > +	sdf->cmd = cpu_to_le32((FSL_QDMA_CMD_RWTTYPE << FSL_QDMA_CMD_RWTTYPE_OFFSET) |
> > +			       FSL_QDMA_CMD_PF);
> > +
> > +	ddf->cmd = cpu_to_le32((FSL_QDMA_CMD_RWTTYPE << FSL_QDMA_CMD_RWTTYPE_OFFSET) |
> > +			       (FSL_QDMA_CMD_LWC << FSL_QDMA_CMD_LWC_OFFSET));
> >  }
> >  
> >  /*
> > @@ -626,7 +625,7 @@ static int fsl_qdma_halt(struct fsl_qdma_engine *fsl_qdma)
> >  
> >  static int
> >  fsl_qdma_queue_transfer_complete(struct fsl_qdma_engine *fsl_qdma,
> > -				 void *block,
> > +				 __iomem void *block,
> >  				 int id)
> >  {
> >  	bool duplicate;
> > -- 
> > 2.34.1
> 
> -- 
> ~Vinod

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

* Re: [PATCH 1/1] dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning
  2024-02-09 21:08 [PATCH 1/1] dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning Frank Li
  2024-02-16 12:33 ` Vinod Koul
@ 2024-02-23 12:08 ` Vinod Koul
  1 sibling, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2024-02-23 12:08 UTC (permalink / raw)
  To: dmaengine, linux-kernel, Frank Li; +Cc: imx


On Fri, 09 Feb 2024 16:08:37 -0500, Frank Li wrote:
> Fix below sparse warnings.
> 
> drivers/dma/fsl-qdma.c:645:50: sparse: warning: incorrect type in argument 2 (different address spaces)
> drivers/dma/fsl-qdma.c:645:50: sparse:    expected void [noderef] __iomem *addr
> drivers/dma/fsl-qdma.c:645:50: sparse:    got void
> 
> drivers/dma/fsl-qdma.c:387:15: sparse: sparse: restricted __le32 degrades to integer
> drivers/dma/fsl-qdma.c:390:19: sparse:     expected restricted __le64 [usertype] data
> drivers/dma/fsl-qdma.c:392:13: sparse:     expected unsigned int [assigned] [usertype] cmd
> 
> [...]

Applied, thanks!

[1/1] dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning
      commit: 1878840a0328dac1c85d29fee31456ec26fcc01c

Best regards,
-- 
~Vinod



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

end of thread, other threads:[~2024-02-23 12:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-09 21:08 [PATCH 1/1] dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning Frank Li
2024-02-16 12:33 ` Vinod Koul
2024-02-16 15:00   ` Frank Li
2024-02-23 12:08 ` Vinod Koul

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