[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20081023204706X.fujita.tomonori@lab.ntt.co.jp>
Date: Thu, 23 Oct 2008 20:46:55 +0900
From: FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
To: mingo@...e.hu
Cc: tiwai@...e.de, fujita.tomonori@....ntt.co.jp, svens@...ckframe.org,
joerg.roedel@....com, linux-kernel@...r.kernel.org, hpa@...or.com
Subject: Re: swiotlb_alloc_coherent: allocated memory is out of range for
device
On Thu, 23 Oct 2008 12:15:57 +0200
Ingo Molnar <mingo@...e.hu> wrote:
>
> * Takashi Iwai <tiwai@...e.de> wrote:
>
> > At Thu, 23 Oct 2008 07:22:09 +0200,
> > I wrote:
> > >
> > > > The current dma_alloc_coherent (asm-x86/dma-mapping.h) handles the gfp
> > > > flags in the exact same way as the old dma_alloc_coherent
> > > > (pci-dma.c). Neither sets GFP_DMA even if coherent_dma_mask is
> > > > 24bits. The old code is fine because of the GFP_DMA retry
> > > > mechanism. But if coherent_dma_mask is 24bits, there is no point to go
> > > > into the GFP_DMA retry mechanism. We should use GFP_DMA in the first
> > > > place.
> > > >
> > > > How about the following patch?
> > >
> > > I'll give it a try later (the machine is in my office).
> >
> > The patch seems working fine. Thanks!
> >
> > Tested-by: Takashi Iwai <tiwai@...e.de>
>
> thanks guys - i've queued it up in tip/core/urgent and will send a pull
> request to Linus later today.
Thanks, I can't find the commit right now so I'm not sure if you need
the patch description but anyway, here's a sane format of the patch.
=
From: FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
Subject: [PATCH] x86: use GFP_DMA for 24bit coherent_dma_mask
dma_alloc_coherent (include/asm-x86/dma-mapping.h) avoids GFP_DMA
allocation first and if the allocated address is not fit for the
device's coherent_dma_mask, then dma_alloc_coherent does GFP_DMA
allocation. This is because dma_alloc_coherent avoids precious GFP_DMA
zone if possible. This is also how the old dma_alloc_coherent
(arch/x86/kernel/pci-dma.c) works.
However, if the coherent_dma_mask of a device is 24bit, there is no
point to go into the above GFP_DMA retry mechanism. We had better use
GFP_DMA in the first place.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
Tested-by: Takashi Iwai <tiwai@...e.de>
---
include/asm-x86/dma-mapping.h | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 219c33d..05fcec5 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -255,9 +255,11 @@ static inline unsigned long dma_alloc_coherent_mask(struct device *dev,
static inline gfp_t dma_alloc_coherent_gfp_flags(struct device *dev, gfp_t gfp)
{
-#ifdef CONFIG_X86_64
unsigned long dma_mask = dma_alloc_coherent_mask(dev, gfp);
+ if (dma_mask <= DMA_24BIT_MASK)
+ gfp |= GFP_DMA;
+#ifdef CONFIG_X86_64
if (dma_mask <= DMA_32BIT_MASK && !(gfp & GFP_DMA))
gfp |= GFP_DMA32;
#endif
--
1.5.5.GIT
--
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