Alpha arch development list
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Bob Tracy <rct@gherkin.frus.com>,
	Michal Piotrowski <michal.k.k.piotrowski@gmail.com>,
	linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: 2.6.22-rc6 bad page error
Date: Wed, 11 Jul 2007 18:07:59 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707111743580.22786@blonde.wat.veritas.com> (raw)
In-Reply-To: <20070711170245.A1148@jurassic.park.msu.ru>

On Wed, 11 Jul 2007, Ivan Kokshaysky wrote:
> On Tue, Jul 10, 2007 at 09:25:50PM +0100, Hugh Dickins wrote:
> > On Mon, 9 Jul 2007, Bob Tracy wrote:
> > > That seems to have done the trick.  Normally, I get the "bad page"
> > > errors on the second NX session, but I'm on the third session of the
> > > day (thus far), and everything seems to be ok as far as I can tell.
> > 
> > Thanks a lot for the feedback, that tells us we've made the right
> > guesses, and my __GFP_COMP patch should be a good bandaid for you;
> > but for the right patch, let's wait to hear from Ivan.
> 
> Here it is. Bob, can you test this one?
> 
> ---
> 
> Take care of DMA flags passed to dma_alloc_coherent().
> Particularly ALSA needs that.
> 
> Signed-off-by: Ivan Kokshaysky <ink@jurassic.park.msu.ru>

Yes, I agree that's the right way to go.  Aside from fixing Bob's
crash, it also liberates ALSA from needing GFP_ATOMIC there on Alpha.
Couple of GFP_ notes below.

Hugh

> 
> Ivan.
> 
> --- 2.6.22/arch/alpha/kernel/pci_iommu.c	Mon Jul  9 03:32:17 2007
> +++ linux/arch/alpha/kernel/pci_iommu.c	Wed Jul 11 14:40:37 2007
> @@ -398,11 +398,13 @@ EXPORT_SYMBOL(pci_unmap_page);
>     else DMA_ADDRP is undefined.  */
>  
>  void *
> -pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp)
> +__pci_alloc_consistent(struct pci_dev *pdev, size_t size,
> +		       dma_addr_t *dma_addrp, gfp_t gfp)
>  {
>  	void *cpu_addr;
>  	long order = get_order(size);
> -	gfp_t gfp = GFP_ATOMIC;
> +
> +	gfp &= ~GFP_DMA;

The canonical form for this masking, even on arches without HIGHMEM,
appears to be:
	gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
But I guess that won't make any actual difference.

>  
>  try_again:
>  	cpu_addr = (void *)__get_free_pages(gfp, order);
> @@ -432,7 +434,7 @@ try_again:
>  
>  	return cpu_addr;
>  }
> -EXPORT_SYMBOL(pci_alloc_consistent);
> +EXPORT_SYMBOL(__pci_alloc_consistent);
>  
>  /* Free and unmap a consistent DMA buffer.  CPU_ADDR and DMA_ADDR must
>     be values that were returned from pci_alloc_consistent.  SIZE must
> --- 2.6.22/include/asm-alpha/pci.h	Mon Jul  9 03:32:17 2007
> +++ linux/include/asm-alpha/pci.h	Wed Jul 11 14:40:37 2007
> @@ -75,7 +75,13 @@ extern inline void pcibios_penalize_isa_
>     successful and sets *DMA_ADDRP to the pci side dma address as well,
>     else DMA_ADDRP is undefined.  */
>  
> -extern void *pci_alloc_consistent(struct pci_dev *, size_t, dma_addr_t *);
> +extern void *__pci_alloc_consistent(struct pci_dev *, size_t,
> +				    dma_addr_t *, gfp_t);
> +static inline void *
> +pci_alloc_consistent(struct pci_dev *dev, size_t size, dma_addr_t *dma)
> +{
> +	return __pci_alloc_consistent(dev, size, dma, GFP_ATOMIC);

I was going to ask you why that needs to be GFP_ATOMIC on Alpha.
But find you're following the example of asm-generic and others.
So really should be asking Sparc how it gets away with GFP_KERNEL.

> +}
>  
>  /* Free and unmap a consistent DMA buffer.  CPU_ADDR and DMA_ADDR must
>     be values that were returned from pci_alloc_consistent.  SIZE must
> --- 2.6.22/include/asm-alpha/dma-mapping.h	Mon Jul  9 03:32:17 2007
> +++ linux/include/asm-alpha/dma-mapping.h	Wed Jul 11 14:40:37 2007
> @@ -11,7 +11,7 @@
>  #define dma_unmap_single(dev, addr, size, dir)		\
>  		pci_unmap_single(alpha_gendev_to_pci(dev), addr, size, dir)
>  #define dma_alloc_coherent(dev, size, addr, gfp)	\
> -		pci_alloc_consistent(alpha_gendev_to_pci(dev), size, addr)
> +	      __pci_alloc_consistent(alpha_gendev_to_pci(dev), size, addr, gfp)
>  #define dma_free_coherent(dev, size, va, addr)		\
>  		pci_free_consistent(alpha_gendev_to_pci(dev), size, va, addr)
>  #define dma_map_page(dev, page, off, size, dir)		\

  reply	other threads:[~2007-07-11 17:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070705195835.AAB19DBA1@gherkin.frus.com>
2007-07-07 13:48 ` 2.6.22-rc6 bad page error Michal Piotrowski
2007-07-07 14:56   ` Bob Tracy
2007-07-07 18:38     ` Hugh Dickins
2007-07-08 21:05       ` Bob Tracy
2007-07-09 18:53       ` Bob Tracy
2007-07-10 20:25         ` Hugh Dickins
2007-07-11 13:02           ` Ivan Kokshaysky
2007-07-11 17:07             ` Hugh Dickins [this message]
2007-07-12  9:46               ` Ivan Kokshaysky
2007-07-12 16:13                 ` Hugh Dickins

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=Pine.LNX.4.64.0707111743580.22786@blonde.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=akpm@linux-foundation.org \
    --cc=ink@jurassic.park.msu.ru \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.k.k.piotrowski@gmail.com \
    --cc=rct@gherkin.frus.com \
    /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