linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/10] ARM: change ARM_DMA_ZONE_SIZE into a variable
Date: Fri, 8 Jul 2011 13:14:41 +0100	[thread overview]
Message-ID: <20110708121441.GD4812@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <alpine.LFD.2.00.1107062043180.14596@xanadu.home>

On Wed, Jul 06, 2011 at 10:46:03PM -0400, Nicolas Pitre wrote:
> On Thu, 7 Jul 2011, Russell King - ARM Linux wrote:
> 
> > On Tue, Jul 05, 2011 at 10:30:33PM -0400, Nicolas Pitre wrote:
> > > +extern unsigned long arm_dma_zone_size;
> > > +#define MAX_DMA_ADDRESS	(PAGE_OFFSET + arm_dma_zone_size)
> > ...
> > > -#ifndef ARM_DMA_ZONE_SIZE
> > > +#ifndef CONFIG_ZONE_DMA
> > >  #define ISA_DMA_THRESHOLD	(0xffffffffULL)
> > >  #else
> > > -#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
> > > +#define ISA_DMA_THRESHOLD	({ \
> > > +	extern unsigned long arm_dma_zone_size; \
> > > +	arm_dma_zone_size ? \
> > > +		(PHYS_OFFSET + arm_dma_zone_size - 1) : 0xffffffffULL; })
> > 
> > These two usages do not agree.  With unrestricted DMA, both
> > MAX_DMA_ADDRESS and ISA_DMA_THRESHOLD should be 0xffffffff.  However,
> > you get that with arm_dma_zone_size=0 for ISA_DMA_THRESHOLD, which
> > then gives a MAX_DMA_ADDRESS of PAGE_OFFSET.  So this potentially
> > changes the behaviour of these macros.
> 
> Looking at what other architectures do, we have:
> 
> avr32, parisc, powerpc, sparc -> 0xffffffff
> 
> cris, frv, h8300, m68k, mips -> PAGE_OFFSET
> 
> microblaze, score, xtensa -> 0
> 
> So I wonder if this macro makes any sense when there is no DMA zone.  
> 
> OTOH, since it is almost never used, it is best to make it behave 
> like the original. Fixed tusly in my tree:
> 
> diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
> index 1d34c11..fcf15de 100644
> --- a/arch/arm/include/asm/dma.h
> +++ b/arch/arm/include/asm/dma.h
> @@ -9,8 +9,10 @@
>  #ifndef CONFIG_ZONE_DMA
>  #define MAX_DMA_ADDRESS	0xffffffffUL
>  #else
> -extern unsigned long arm_dma_zone_size;
> -#define MAX_DMA_ADDRESS	(PAGE_OFFSET + arm_dma_zone_size)
> +#define MAX_DMA_ADDRESS	({ \
> +	extern unsigned long arm_dma_zone_size; \
> +	arm_dma_zone_size ? \
> +		(PAGE_OFFSET + arm_dma_zone_size) : 0xffffffffUL; })
>  #endif
>  
>  #ifdef CONFIG_ISA_DMA_API
> 
> Yet, excluding sound/oss/dmabuf.c, this is used by only 6 drivers in the 
> whole tree which appear to be old ISA based drivers which would use a a 
> DMA zone already.  The exception is cs89x0.c, however MAX_DMA_ADDRESS is 
> only used in the context of ISA DMA.

Most drivers treat it as a virtual address, and it's used to determine
whether a driver private bounce buffer needs to be used.  Setting it
to PAGE_OFFSET means that the bounce buffer will always be used.  Setting
it to all-ones means that the bounce buffer will never be used and some
code will be optimized away.  Intermediate settings means that we get
run-time checks which aren't required on ARM platforms.

> What is more worrisome is its usage in a few places in the mm code where 
> it is always passed to __pa().  Certainly __pa(0xffffffff) is not going 
> to produce sensible results.

The only real user there is bootmem, which hopefully will be killed
off on ARM soon.  In any case, I wouldn't worry about that at the
moment because it's been that way for a long time and we haven't had
any reports of badness from it.

> One thing is for sure: ISA_DMA_THRESHOLD is not used anywhere in the 
> whole tree except in arch/arm/mm/dma-mapping.c:get_coherent_dma_mask() 
> and arch/arm/include/asm/dma-mapping.h:dma_supported() where its usage 
> is certainly not ISA specific.  Maybe this should be renamed?

It looks like ISA_DMA_THRESHOLD has become unused by most of the kernel,
so yes, renaming it to "dma_zone_limit" would be more descriptive.  We
should probably make dma_supported() be out-of-line anyway (which then
means that dma_zone_limit doesn't have to be exported to drivers) - and
I think the DMA bounce stuff needs cleaning up in dma_set_mask().

  reply	other threads:[~2011-07-08 12:14 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-06  2:30 [PATCH 01/10] ARM: change ARM_DMA_ZONE_SIZE into a variable Nicolas Pitre
2011-07-06  2:30 ` [PATCH 02/10] ARM: add dma_zone_size to the machine_desc structure Nicolas Pitre
2011-07-06 23:10   ` Russell King - ARM Linux
2011-07-07  2:59     ` Nicolas Pitre
2011-07-06  2:30 ` [PATCH 03/10] ARM: mach-davinci: move from ARM_DMA_ZONE_SIZE to mdesc->dma_zone_size Nicolas Pitre
2011-07-06  2:30 ` [PATCH 04/10] ARM: mach-h720x: " Nicolas Pitre
2011-07-06  2:30 ` [PATCH 05/10] ARM: mach-ixp4xx: " Nicolas Pitre
2011-07-06 23:12   ` Russell King - ARM Linux
2011-07-07  3:31     ` Nicolas Pitre
2011-07-06  2:30 ` [PATCH 06/10] ARM: mach-pxa: " Nicolas Pitre
2011-07-06  2:30 ` [PATCH 07/10] ARM: mach-realview: " Nicolas Pitre
2011-07-06 23:15   ` Russell King - ARM Linux
2011-07-07  3:59     ` Nicolas Pitre
2011-07-06  2:30 ` [PATCH 08/10] ARM: mach-sa1100: move " Nicolas Pitre
2011-07-06  2:30 ` [PATCH 09/10] ARM: mach-shark: " Nicolas Pitre
2011-07-06  2:30 ` [PATCH 10/10] ARM: ARM_DMA_ZONE_SIZE is no more Nicolas Pitre
2011-07-06  2:48 ` [PATCH 01/10] ARM: change ARM_DMA_ZONE_SIZE into a variable Barry Song
2011-07-06  3:12   ` Nicolas Pitre
2011-07-06 23:09     ` Russell King - ARM Linux
2011-07-07  2:50       ` Nicolas Pitre
2011-07-07 16:17         ` Arnd Bergmann
2011-07-07 17:08           ` John Linn
2011-07-07 17:40             ` Arnd Bergmann
2011-07-08  8:59             ` Russell King - ARM Linux
2011-07-08 13:58               ` John Linn
2011-07-08 16:23                 ` Russell King - ARM Linux
2011-07-07 18:15           ` Grant Likely
2011-07-06 23:04 ` Russell King - ARM Linux
2011-07-07  2:46   ` Nicolas Pitre
2011-07-08 12:14     ` Russell King - ARM Linux [this message]
2011-07-08 20:30       ` Russell King - ARM Linux
2011-07-09  8:12         ` Russell King - ARM Linux
2011-07-09  8:13         ` Russell King - ARM Linux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110708121441.GD4812@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).