diff mbox series

[v2,3/4] dmaengine: at_xdmac: In at_xdmac_prep_dma_memset, treat value as a single byte

Message ID 20220218205557.486208-4-benjamin.walker@intel.com (mailing list archive)
State Superseded
Headers show
Series dmaengine: memset clarifications and fixes | expand

Commit Message

Ben Walker Feb. 18, 2022, 8:55 p.m. UTC
The value passed in to .prep_dma_memset is to be treated as a single
byte repeating pattern.

Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
Cc: Tudor Ambarus <tudor.ambarus@microchip.com>
---
 drivers/dma/at_xdmac.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Ben Walker Feb. 18, 2022, 9:48 p.m. UTC | #1
On 2/18/2022 1:55 PM, Ben Walker wrote:
> The value passed in to .prep_dma_memset is to be treated as a single
> byte repeating pattern.
> 
> Signed-off-by: Ben Walker <benjamin.walker@intel.com>
> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> Cc: Tudor Ambarus <tudor.ambarus@microchip.com>
> ---
>   drivers/dma/at_xdmac.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index a1da2b4b6d732..547778fc6445b 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -1202,6 +1202,7 @@ static struct at_xdmac_desc *at_xdmac_memset_create_desc(struct dma_chan *chan,
>   	unsigned long		flags;
>   	size_t			ublen;
>   	u32			dwidth;
> +	unsigned char		pattern;
>   	/*
>   	 * WARNING: The channel configuration is set here since there is no
>   	 * dmaengine_slave_config call in this case. Moreover we don't know the
> @@ -1244,10 +1245,16 @@ static struct at_xdmac_desc *at_xdmac_memset_create_desc(struct dma_chan *chan,
>   
>   	chan_cc |= AT_XDMAC_CC_DWIDTH(dwidth);
>   
> +	/* Only the first byte of value is to be used according to dmaengine */
> +	pattern = (unsigned char)value;

I need to change this to signed as well.

> +
>   	ublen = len >> dwidth;
>   
>   	desc->lld.mbr_da = dst_addr;
> -	desc->lld.mbr_ds = value;
> +	desc->lld.mbr_ds = (pattern << 24) |
> +			   (pattern << 16) |
> +			   (pattern << 8) |
> +			   pattern;
>   	desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV3
>   		| AT_XDMAC_MBR_UBC_NDEN
>   		| AT_XDMAC_MBR_UBC_NSEN
diff mbox series

Patch

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index a1da2b4b6d732..547778fc6445b 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -1202,6 +1202,7 @@  static struct at_xdmac_desc *at_xdmac_memset_create_desc(struct dma_chan *chan,
 	unsigned long		flags;
 	size_t			ublen;
 	u32			dwidth;
+	unsigned char		pattern;
 	/*
 	 * WARNING: The channel configuration is set here since there is no
 	 * dmaengine_slave_config call in this case. Moreover we don't know the
@@ -1244,10 +1245,16 @@  static struct at_xdmac_desc *at_xdmac_memset_create_desc(struct dma_chan *chan,
 
 	chan_cc |= AT_XDMAC_CC_DWIDTH(dwidth);
 
+	/* Only the first byte of value is to be used according to dmaengine */
+	pattern = (unsigned char)value;
+
 	ublen = len >> dwidth;
 
 	desc->lld.mbr_da = dst_addr;
-	desc->lld.mbr_ds = value;
+	desc->lld.mbr_ds = (pattern << 24) |
+			   (pattern << 16) |
+			   (pattern << 8) |
+			   pattern;
 	desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV3
 		| AT_XDMAC_MBR_UBC_NDEN
 		| AT_XDMAC_MBR_UBC_NSEN