Patchwork [1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit

login
register
mail settings
Submitter Becky Bruce
Date April 20, 2009, 4:26 p.m.
Message ID <1240244810-32193-4-git-send-email-beckyb@kernel.crashing.org>
Download mbox | patch
Permalink /patch/26201/
State Accepted, archived
Commit 2138422bbab91c3e924c9836e394f4925b456b79
Delegated to: Benjamin Herrenschmidt
Headers show

Comments

Becky Bruce - April 20, 2009, 4:26 p.m.
Currently, the 32-bit code uses sg->length instead of sg->dma_lentgh
to report sg_dma_len.  However, since the default dma code for 32-bit
(the dma_direct case) sets dma_length and length to the same thing,
we should be able to use dma_length there as well.  This gets rid of
some 32-vs-64-bit ifdefs, and is needed by the swiotlb code which
actually distinguishes between dma_length and length.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
---
 arch/powerpc/include/asm/scatterlist.h |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
Kumar Gala - April 20, 2009, 8:06 p.m.
On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote:

> Currently, the 32-bit code uses sg->length instead of sg->dma_lentgh
> to report sg_dma_len.  However, since the default dma code for 32-bit
> (the dma_direct case) sets dma_length and length to the same thing,
> we should be able to use dma_length there as well.  This gets rid of
> some 32-vs-64-bit ifdefs, and is needed by the swiotlb code which
> actually distinguishes between dma_length and length.
>
> Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
> ---
> arch/powerpc/include/asm/scatterlist.h |    6 +-----
> 1 files changed, 1 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/scatterlist.h b/arch/powerpc/ 
> include/asm/scatterlist.h
> index fcf7d55..912bf59 100644
> --- a/arch/powerpc/include/asm/scatterlist.h
> +++ b/arch/powerpc/include/asm/scatterlist.h
> @@ -21,7 +21,7 @@ struct scatterlist {
> 	unsigned int offset;
> 	unsigned int length;

can we get rid of length?

>
>
> -	/* For TCE support */
> +	/* For TCE or SWIOTLB support */
> 	dma_addr_t dma_address;
> 	u32 dma_length;
> };
> @@ -34,11 +34,7 @@ struct scatterlist {
>  * is 0.
>  */
> #define sg_dma_address(sg)	((sg)->dma_address)
> -#ifdef __powerpc64__
> #define sg_dma_len(sg)		((sg)->dma_length)
> -#else
> -#define sg_dma_len(sg)		((sg)->length)
> -#endif
>
> #ifdef __powerpc64__
> #define ISA_DMA_THRESHOLD	(~0UL)
> -- 
> 1.6.0.6

- k
FUJITA Tomonori - April 21, 2009, 2:27 a.m.
On Mon, 20 Apr 2009 15:06:16 -0500
Kumar Gala <galak@kernel.crashing.org> wrote:

> 
> On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote:
> 
> > Currently, the 32-bit code uses sg->length instead of sg->dma_lentgh
> > to report sg_dma_len.  However, since the default dma code for 32-bit
> > (the dma_direct case) sets dma_length and length to the same thing,
> > we should be able to use dma_length there as well.  This gets rid of
> > some 32-vs-64-bit ifdefs, and is needed by the swiotlb code which
> > actually distinguishes between dma_length and length.
> >
> > Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
> > ---
> > arch/powerpc/include/asm/scatterlist.h |    6 +-----
> > 1 files changed, 1 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/scatterlist.h b/arch/powerpc/ 
> > include/asm/scatterlist.h
> > index fcf7d55..912bf59 100644
> > --- a/arch/powerpc/include/asm/scatterlist.h
> > +++ b/arch/powerpc/include/asm/scatterlist.h
> > @@ -21,7 +21,7 @@ struct scatterlist {
> > 	unsigned int offset;
> > 	unsigned int length;
> 
> can we get rid of length?

You can't.


> >
> >
> > -	/* For TCE support */
> > +	/* For TCE or SWIOTLB support */
> > 	dma_addr_t dma_address;
> > 	u32 dma_length;
> > };
> > @@ -34,11 +34,7 @@ struct scatterlist {
> >  * is 0.
> >  */
> > #define sg_dma_address(sg)	((sg)->dma_address)
> > -#ifdef __powerpc64__
> > #define sg_dma_len(sg)		((sg)->dma_length)
> > -#else
> > -#define sg_dma_len(sg)		((sg)->length)
> > -#endif
> >
> > #ifdef __powerpc64__
> > #define ISA_DMA_THRESHOLD	(~0UL)
> > -- 
> > 1.6.0.6
> 
> - k
> 
>
Becky Bruce - April 21, 2009, 3:23 p.m.
On Apr 20, 2009, at 3:06 PM, Kumar Gala wrote:

>
> On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote:
>
>> Currently, the 32-bit code uses sg->length instead of sg->dma_lentgh
>> to report sg_dma_len.  However, since the default dma code for 32-bit
>> (the dma_direct case) sets dma_length and length to the same thing,
>> we should be able to use dma_length there as well.  This gets rid of
>> some 32-vs-64-bit ifdefs, and is needed by the swiotlb code which
>> actually distinguishes between dma_length and length.
>>
>> Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
>> ---
>> arch/powerpc/include/asm/scatterlist.h |    6 +-----
>> 1 files changed, 1 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/scatterlist.h b/arch/powerpc/ 
>> include/asm/scatterlist.h
>> index fcf7d55..912bf59 100644
>> --- a/arch/powerpc/include/asm/scatterlist.h
>> +++ b/arch/powerpc/include/asm/scatterlist.h
>> @@ -21,7 +21,7 @@ struct scatterlist {
>> 	unsigned int offset;
>> 	unsigned int length;
>
> can we get rid of length?

No - they're both used by the iotlb code and are conceptually  
different.  "dma_length" can get set to less than "length" to indicate  
that something went wrong with a dma request - the iotlb code sets it  
to 0 if we can't allocate a bounce buffer, for example.  It probably  
has other uses as well - this is just the one I'm familiar with.  In  
most cases they are equal.

Cheers,
B

Patch

diff --git a/arch/powerpc/include/asm/scatterlist.h b/arch/powerpc/include/asm/scatterlist.h
index fcf7d55..912bf59 100644
--- a/arch/powerpc/include/asm/scatterlist.h
+++ b/arch/powerpc/include/asm/scatterlist.h
@@ -21,7 +21,7 @@  struct scatterlist {
 	unsigned int offset;
 	unsigned int length;
 
-	/* For TCE support */
+	/* For TCE or SWIOTLB support */
 	dma_addr_t dma_address;
 	u32 dma_length;
 };
@@ -34,11 +34,7 @@  struct scatterlist {
  * is 0.
  */
 #define sg_dma_address(sg)	((sg)->dma_address)
-#ifdef __powerpc64__
 #define sg_dma_len(sg)		((sg)->dma_length)
-#else
-#define sg_dma_len(sg)		((sg)->length)
-#endif
 
 #ifdef __powerpc64__
 #define ISA_DMA_THRESHOLD	(~0UL)