lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 16 May 2013 08:35:53 +0100
From:	Lee Jones <lee.jones@...aro.org>
To:	Vinod Koul <vinod.koul@...el.com>
Cc:	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	balbi@...com, linux-usb@...r.kernel.org,
	linux-crypto@...r.kernel.org, davem@...emloft.net,
	herbert@...dor.hengli.com.au, arnd@...db.de,
	linus.walleij@...ricsson.com, srinidhi.kasagar@...ricsson.com,
	Dan Williams <djbw@...com>,
	Per Forlin <per.forlin@...ricsson.com>,
	Rabin Vincent <rabin@....in>
Subject: Re: [PATCH 34/39] dmaengine: ste_dma40: Convert data_width from
 register bit format to value

On Thu, 16 May 2013, Vinod Koul wrote:

> On Wed, May 15, 2013 at 10:51:57AM +0100, Lee Jones wrote:
> > When a DMA client requests and configures a DMA channel, it requests
> > data_width in Bytes. The DMA40 driver then swiftly converts it over to
> > the necessary register bit value. Unfortunately, for any subsequent
> > calculations we have to shift '1' by the bit pattern (1 << data_width)
> > times to make any sense of it.
> > 
> > This patch flips the semantics on its head and only converts the value
> > to its respective register bit pattern when writing to registers. This
> > way we can use the true data_width (in Bytes) value.
> > 
> > Cc: Vinod Koul <vinod.koul@...el.com>
> > Cc: Dan Williams <djbw@...com>
> > Cc: Per Forlin <per.forlin@...ricsson.com>
> > Cc: Rabin Vincent <rabin@....in>
> > Signed-off-by: Lee Jones <lee.jones@...aro.org>
> > ---
>   
> > @@ -2804,14 +2781,24 @@ static int d40_set_runtime_config(struct dma_chan *chan,
> >  		src_maxburst = dst_maxburst * dst_addr_width / src_addr_width;
> >  	}
> >  
> > +	/* Only valid widths are; 1, 2, 4 and 8. */
> > +	if (src_addr_width <= DMA_SLAVE_BUSWIDTH_UNDEFINED ||
> > +	    src_addr_width >  DMA_SLAVE_BUSWIDTH_8_BYTES   ||
> > +	    dst_addr_width <= DMA_SLAVE_BUSWIDTH_UNDEFINED ||
> > +	    dst_addr_width >  DMA_SLAVE_BUSWIDTH_8_BYTES   ||
> > +	    ((src_addr_width > 1) && (src_addr_width & 1)) ||
> > +	    ((dst_addr_width > 1) && (dst_addr_width & 1)))
> > +		return -EINVAL;
> how about a simple macro to check above..

I thought about it, but as this code appears only once, I considered
it to be unnecessary abstraction.

> > +
> > +	cfg->src_info.data_width = src_addr_width;
> > +	cfg->dst_info.data_width = dst_addr_width;
> > +
> >  	ret = dma40_config_to_halfchannel(d40c, &cfg->src_info,
> > -					  src_addr_width,
> >  					  src_maxburst);
> >  	if (ret)
> >  		return ret;
> >  
> >  	ret = dma40_config_to_halfchannel(d40c, &cfg->dst_info,
> > -					  dst_addr_width,
> >  					  dst_maxburst);
> >  	if (ret)
> >  		return ret;
> > diff --git a/drivers/dma/ste_dma40_ll.c b/drivers/dma/ste_dma40_ll.c
> > index 5ddd724..a035dfe 100644
> > --- a/drivers/dma/ste_dma40_ll.c
> > +++ b/drivers/dma/ste_dma40_ll.c
> > @@ -10,6 +10,18 @@
> >  
> >  #include "ste_dma40_ll.h"
> >  
> > +u8 d40_width_to_bits(enum dma_slave_buswidth width)
> > +{
> > +	if (width == DMA_SLAVE_BUSWIDTH_1_BYTE)
> > +		return STEDMA40_ESIZE_8_BIT;
> > +	else if (width == DMA_SLAVE_BUSWIDTH_2_BYTES)
> > +		return STEDMA40_ESIZE_16_BIT;
> > +	else if (width == DMA_SLAVE_BUSWIDTH_8_BYTES)
> > +		return STEDMA40_ESIZE_64_BIT;
> > +	else
> > +		return STEDMA40_ESIZE_32_BIT;
> > +}
> > +
> Switch looks better for this and how about
> 	return fls(width);
> 
> as your defines are 0...3 and dmaengine define 1,2,..8 for same thing
> then you can also get rid of STEDMA40_XXX_WIDTH macros!

I like it.

Will you let me do it as a follow-up patch?

> > @@ -70,13 +70,6 @@ enum stedma40_flow_ctrl {
> >  	STEDMA40_FLOW_CTRL,
> >  };
> >  
> > -enum stedma40_periph_data_width {
> > -	STEDMA40_BYTE_WIDTH = STEDMA40_ESIZE_8_BIT,
> > -	STEDMA40_HALFWORD_WIDTH = STEDMA40_ESIZE_16_BIT,
> > -	STEDMA40_WORD_WIDTH = STEDMA40_ESIZE_32_BIT,
> > -	STEDMA40_DOUBLEWORD_WIDTH = STEDMA40_ESIZE_64_BIT
> > -};
> nice
> 

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ