* [3/3] Use the DMA32 zone for dma_alloc_coherent()/pci_alloc_consistent on x86-64
@ 2005-09-11 16:59 Andi Kleen
2005-09-12 17:41 ` Linus Torvalds
0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2005-09-11 16:59 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel, discuss
Use the DMA32 zone for dma_alloc_coherent()/pci_alloc_consistent on x86-64
Signed-off-by: Andi Kleen <ak@suse.de>
Index: linux/arch/x86_64/kernel/pci-gart.c
===================================================================
--- linux.orig/arch/x86_64/kernel/pci-gart.c
+++ linux/arch/x86_64/kernel/pci-gart.c
@@ -219,6 +219,8 @@ dma_alloc_coherent(struct device *dev, s
/* Kludge to make it bug-to-bug compatible with i386. i386
uses the normal dma_mask for alloc_coherent. */
dma_mask &= *dev->dma_mask;
+ if (dma_mask <= 0xffffffff)
+ gfp |= GFP_DMA32;
again:
memory = dma_alloc_pages(dev, gfp, get_order(size));
@@ -245,7 +247,7 @@ dma_alloc_coherent(struct device *dev, s
}
if (!(gfp & GFP_DMA)) {
- gfp |= GFP_DMA;
+ gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
goto again;
}
return NULL;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [3/3] Use the DMA32 zone for dma_alloc_coherent()/pci_alloc_consistent on x86-64
2005-09-11 16:59 [3/3] Use the DMA32 zone for dma_alloc_coherent()/pci_alloc_consistent on x86-64 Andi Kleen
@ 2005-09-12 17:41 ` Linus Torvalds
2005-09-12 17:59 ` Andi Kleen
0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2005-09-12 17:41 UTC (permalink / raw)
To: Andi Kleen; +Cc: linux-kernel, discuss
On Sun, 11 Sep 2005, Andi Kleen wrote:
>
> Use the DMA32 zone for dma_alloc_coherent()/pci_alloc_consistent on x86-64
>
> Signed-off-by: Andi Kleen <ak@suse.de>
>
> Index: linux/arch/x86_64/kernel/pci-gart.c
> ===================================================================
> --- linux.orig/arch/x86_64/kernel/pci-gart.c
> +++ linux/arch/x86_64/kernel/pci-gart.c
> @@ -219,6 +219,8 @@ dma_alloc_coherent(struct device *dev, s
> /* Kludge to make it bug-to-bug compatible with i386. i386
> uses the normal dma_mask for alloc_coherent. */
> dma_mask &= *dev->dma_mask;
> + if (dma_mask <= 0xffffffff)
> + gfp |= GFP_DMA32;
How can this be right?
Let's say that dma_mask is 0xfffff (ie 20-bit legacy DMA). It will trigger
the test, and set the GFP_DMA32 bit. Which can't be right.
I'm going to drop the DMA32 parts of the patches, they seem to be pretty
raw.
Linus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [3/3] Use the DMA32 zone for dma_alloc_coherent()/pci_alloc_consistent on x86-64
2005-09-12 17:41 ` Linus Torvalds
@ 2005-09-12 17:59 ` Andi Kleen
0 siblings, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2005-09-12 17:59 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel, discuss
On Monday 12 September 2005 19:41, Linus Torvalds wrote:
> On Sun, 11 Sep 2005, Andi Kleen wrote:
> > Use the DMA32 zone for dma_alloc_coherent()/pci_alloc_consistent on
> > x86-64
> >
> > Signed-off-by: Andi Kleen <ak@suse.de>
> >
> > Index: linux/arch/x86_64/kernel/pci-gart.c
> > ===================================================================
> > --- linux.orig/arch/x86_64/kernel/pci-gart.c
> > +++ linux/arch/x86_64/kernel/pci-gart.c
> > @@ -219,6 +219,8 @@ dma_alloc_coherent(struct device *dev, s
> > /* Kludge to make it bug-to-bug compatible with i386. i386
> > uses the normal dma_mask for alloc_coherent. */
> > dma_mask &= *dev->dma_mask;
> > + if (dma_mask <= 0xffffffff)
> > + gfp |= GFP_DMA32;
>
> How can this be right?
No that's intentional. The rationale is that usually the mask is bigger
than 16MB, so you first try it in the higher zone where you already
have some chance to get the right memory, and then only
if you don't get it fall back to the "precious" zone.
The cost is very low because the allocators are fast enough.
Given for a real 0xfffff allocation it is not very likely it will
work, but most <4GB allocations are bigger than that.
I had the same algorithm previously with GFP_DMA.
> Let's say that dma_mask is 0xfffff (ie 20-bit legacy DMA). It will trigger
> the test, and set the GFP_DMA32 bit. Which can't be right.
>
> I'm going to drop the DMA32 parts of the patches, they seem to be pretty
> raw.
Please don't.
-Andi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-09-12 18:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-11 16:59 [3/3] Use the DMA32 zone for dma_alloc_coherent()/pci_alloc_consistent on x86-64 Andi Kleen
2005-09-12 17:41 ` Linus Torvalds
2005-09-12 17:59 ` Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox