From: Takashi Iwai <tiwai@suse.de>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: svens@stackframe.org, joerg.roedel@amd.com, mingo@elte.hu,
linux-kernel@vger.kernel.org
Subject: Re: swiotlb_alloc_coherent: allocated memory is out of range for device
Date: Thu, 23 Oct 2008 07:22:09 +0200 [thread overview]
Message-ID: <s5h63nj51j2.wl%tiwai@suse.de> (raw)
In-Reply-To: <20081023113618T.fujita.tomonori@lab.ntt.co.jp>
At Thu, 23 Oct 2008 11:36:20 +0900,
FUJITA Tomonori wrote:
>
> On Wed, 22 Oct 2008 15:32:52 +0200
> Takashi Iwai <tiwai@suse.de> wrote:
>
> > > About the bug that you hit, I suspect that dma_map_coherent() in
> > > asm-x86/dma-mapping.h doesn't set gfp flags correctly.
> > >
> > > dma_map_coherent() calls swiotlb_alloc_coherent with the flags GFP_DMA
> > > set? parport driver set dev->coherent_dma_mask properly?
> >
> > The parport driver itself passes always GFP_KERNEL. So I added
> > GFP_DMA in my initial patch as a workaround.
>
> Hmm, have you actually tried your patch?
Err, sorry, no I checked only the combination of two patches.
Apparently the first one doesn't do anything good.
> dma_alloc_coherent clears the gfp zone flags that the callers pass. So
> even if a driver passes GFP_DMA, swiotlb_alloc_coherent doesn't get
> GFP_DMA. So I'm not sure how your patch fixes the parport problem.
>
>
> 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).
thanks,
Takashi
>
>
> 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
>
next prev parent reply other threads:[~2008-10-23 5:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-19 10:09 Sven Schnelle
2008-10-22 10:53 ` Takashi Iwai
2008-10-22 11:07 ` Takashi Iwai
2008-10-22 11:29 ` FUJITA Tomonori
2008-10-22 12:06 ` Takashi Iwai
2008-10-22 13:13 ` FUJITA Tomonori
2008-10-22 13:19 ` FUJITA Tomonori
2008-10-22 13:32 ` Takashi Iwai
2008-10-23 2:36 ` FUJITA Tomonori
2008-10-23 5:22 ` Takashi Iwai [this message]
2008-10-23 11:58 ` Takashi Iwai
2008-10-23 10:15 ` Ingo Molnar
2008-10-23 11:46 ` FUJITA Tomonori
2008-10-28 10:36 ` Takashi Iwai
2008-10-28 10:39 ` Ingo Molnar
2008-10-28 10:47 ` Takashi Iwai
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=s5h63nj51j2.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=joerg.roedel@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=svens@stackframe.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
all inboxes | Powered by JetHome®