2005-12-09 21:16:27

by Orion Poplawski

[permalink] [raw]
Subject: Please help with kernel BUG at include/linux/gfp.h:80 with ndiswrapper on x86_64

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

With kernel 2.6.15-rc5, gfp_zone has the following BUG_ON:

static inline int gfp_zone(gfp_t gfp)
{
int zone = GFP_ZONEMASK & (__force int) gfp;
BUG_ON(zone >= GFP_ZONETYPES);
return zone;
}

This is being tripped by ndiswrapper on x86_64 when it calls:

dma_alloc_coherent(&pci_dev->dev,size,dma_handle, \
GFP_KERNEL | __GFP_REPEAT | GFP_DMA)

because dma_alloc_coherent does:

dma_mask = dev->coherent_dma_mask;
if (dma_mask == 0)
dma_mask = 0xffffffff;

/* Kludge to make it bug-to-bug compatible with i386. i386
uses the normal dma_mask for alloc_coherent. */
dma_mask &= *dev->dma_mask;

/* Why <=? Even when the mask is smaller than 4GB it is often larger
than 16MB and in this case we have a chance of finding
fitting memory
in the next higher zone first. If not retry with true
GFP_DMA. -AK */
if (dma_mask <= 0xffffffff)
gfp |= GFP_DMA32;

again:
memory = dma_alloc_pages(dev, gfp, get_order(size));


so it appears that gfp becomes GFP_DMA | GFP_DMA32 = 5 and triggers the BUG.

So, what should ndiswrapper be using in it's call to dma_alloc_coherent?
GFP_DMA32?

Thanks!

Orion Poplawski

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFDmfNoORnzrtFC2/sRAsp2AKCiK/VAMoIGvxn3uvSuapcop7GUCwCgq9U+
HZShybTsF7LZyG1yXSJceFo=
=iInr
-----END PGP SIGNATURE-----


2005-12-10 18:10:20

by Arjan van de Ven

[permalink] [raw]
Subject: Re: Please help with kernel BUG at include/linux/gfp.h:80 with ndiswrapper on x86_64

On Fri, 2005-12-09 at 14:13 -0700, Orion Poplawski wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> With kernel 2.6.15-rc5, gfp_zone has the following BUG_ON:
>
> static inline int gfp_zone(gfp_t gfp)
> {
> int zone = GFP_ZONEMASK & (__force int) gfp;
> BUG_ON(zone >= GFP_ZONETYPES);
> return zone;
> }
>
> This is being tripped by ndiswrapper on x86_64 when it calls:
>
> dma_alloc_coherent(&pci_dev->dev,size,dma_handle, \
> GFP_KERNEL | __GFP_REPEAT | GFP_DMA)


I don't think GFP_DMA is a valid option for dma_alloc_coherent at all;
GFP_DMA was for isa card allocations, for PCI stuff you need to set the
proper masks instead, and GFP_DMA is obsolete and wrong for PCI.
(except for potentially deep arch code that knows what it's doing).