Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-26 Thread James Bottomley
On Mon, 2007-04-23 at 22:45 +0200, Guennadi Liakhovetski wrote: > On Mon, 23 Apr 2007, James Bottomley wrote: > > > On Mon, 2007-04-23 at 00:45 +0200, Guennadi Liakhovetski wrote: > > > Right, thinko. How about using his: > > > > > > + int pages = DIV_ROUND_UP(size, PAGE_SIZE); > > > >

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-26 Thread James Bottomley
On Mon, 2007-04-23 at 22:45 +0200, Guennadi Liakhovetski wrote: On Mon, 23 Apr 2007, James Bottomley wrote: On Mon, 2007-04-23 at 00:45 +0200, Guennadi Liakhovetski wrote: Right, thinko. How about using his: + int pages = DIV_ROUND_UP(size, PAGE_SIZE); Actually, no ... this has

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-23 Thread Guennadi Liakhovetski
On Mon, 23 Apr 2007, James Bottomley wrote: > On Mon, 2007-04-23 at 00:45 +0200, Guennadi Liakhovetski wrote: > > Right, thinko. How about using his: > > > > + int pages = DIV_ROUND_UP(size, PAGE_SIZE); > > Actually, no ... this has to be size >> PAGE_SHIFT. The reason being > that the

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-23 Thread James Bottomley
On Mon, 2007-04-23 at 00:45 +0200, Guennadi Liakhovetski wrote: > Right, thinko. How about using his: > > + int pages = DIV_ROUND_UP(size, PAGE_SIZE); Actually, no ... this has to be size >> PAGE_SHIFT. The reason being that the allocator is designed to allocate pages out of a device

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-23 Thread James Bottomley
On Mon, 2007-04-23 at 00:45 +0200, Guennadi Liakhovetski wrote: Right, thinko. How about using his: + int pages = DIV_ROUND_UP(size, PAGE_SIZE); Actually, no ... this has to be size PAGE_SHIFT. The reason being that the allocator is designed to allocate pages out of a device memory

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-23 Thread Guennadi Liakhovetski
On Mon, 23 Apr 2007, James Bottomley wrote: On Mon, 2007-04-23 at 00:45 +0200, Guennadi Liakhovetski wrote: Right, thinko. How about using his: + int pages = DIV_ROUND_UP(size, PAGE_SIZE); Actually, no ... this has to be size PAGE_SHIFT. The reason being that the allocator is

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-22 Thread Guennadi Liakhovetski
On Mon, 23 Apr 2007, Guennadi Liakhovetski wrote: > to also allow for size not an integer number of pages as Andrew noticed? > This could be done in 2 patches: patch 2: --- Fix bitmap allocation and size non-multiple of PAGE_SIZE in dma_declare_coherent_memory implementations. i386

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-22 Thread Guennadi Liakhovetski
On Sun, 22 Apr 2007, James Bottomley wrote: > On Fri, 2007-04-13 at 20:08 +0200, Guennadi Liakhovetski wrote: > > - int bitmap_size = (pages + 31)/32; > > + int bitmap_size = DIV_ROUND_UP(pages, 8); > > This isn't quite right. Bitmaps are arrays of longs, not arrays of > bytes. The bug is

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-22 Thread James Bottomley
On Fri, 2007-04-13 at 20:08 +0200, Guennadi Liakhovetski wrote: > Either I've finally gone blind on this Friday 13th or... Looks like this > almost 3 year old function has a bug. Patch below compile-tested... in a > way. No, it's a longstanding bug in the x86 implementation, thanks for finding

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-22 Thread James Bottomley
On Fri, 2007-04-13 at 20:08 +0200, Guennadi Liakhovetski wrote: Either I've finally gone blind on this Friday 13th or... Looks like this almost 3 year old function has a bug. Patch below compile-tested... in a way. No, it's a longstanding bug in the x86 implementation, thanks for finding it.

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-22 Thread Guennadi Liakhovetski
On Sun, 22 Apr 2007, James Bottomley wrote: On Fri, 2007-04-13 at 20:08 +0200, Guennadi Liakhovetski wrote: - int bitmap_size = (pages + 31)/32; + int bitmap_size = DIV_ROUND_UP(pages, 8); This isn't quite right. Bitmaps are arrays of longs, not arrays of bytes. The bug is

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-22 Thread Guennadi Liakhovetski
On Mon, 23 Apr 2007, Guennadi Liakhovetski wrote: to also allow for size not an integer number of pages as Andrew noticed? This could be done in 2 patches: patch 2: --- Fix bitmap allocation and size non-multiple of PAGE_SIZE in dma_declare_coherent_memory implementations. i386

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-21 Thread Guennadi Liakhovetski
On Sat, 21 Apr 2007, Andrew Morton wrote: > On Fri, 13 Apr 2007 20:08:28 +0200 (CEST) Guennadi Liakhovetski <[EMAIL > PROTECTED]> wrote: > > > Hi > > > > Either I've finally gone blind on this Friday 13th or... Looks like this > > almost 3 year old function has a bug. Patch below

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-21 Thread Andrew Morton
On Fri, 13 Apr 2007 20:08:28 +0200 (CEST) Guennadi Liakhovetski <[EMAIL PROTECTED]> wrote: > Hi > > Either I've finally gone blind on this Friday 13th or... Looks like this > almost 3 year old function has a bug. Patch below compile-tested... in a > way. > > Thanks > Guennadi > --- >

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-21 Thread Andrew Morton
On Fri, 13 Apr 2007 20:08:28 +0200 (CEST) Guennadi Liakhovetski [EMAIL PROTECTED] wrote: Hi Either I've finally gone blind on this Friday 13th or... Looks like this almost 3 year old function has a bug. Patch below compile-tested... in a way. Thanks Guennadi --- Guennadi

Re: [PATCH] dma_declare_coherent_memory wrong allocation

2007-04-21 Thread Guennadi Liakhovetski
On Sat, 21 Apr 2007, Andrew Morton wrote: On Fri, 13 Apr 2007 20:08:28 +0200 (CEST) Guennadi Liakhovetski [EMAIL PROTECTED] wrote: Hi Either I've finally gone blind on this Friday 13th or... Looks like this almost 3 year old function has a bug. Patch below compile-tested... in a

[PATCH] dma_declare_coherent_memory wrong allocation

2007-04-13 Thread Guennadi Liakhovetski
Hi Either I've finally gone blind on this Friday 13th or... Looks like this almost 3 year old function has a bug. Patch below compile-tested... in a way. Thanks Guennadi --- Guennadi Liakhovetski dma_declare_coherent_memory() allocates a bitmap 1 bit per page, it calculates the bitmap size

[PATCH] dma_declare_coherent_memory wrong allocation

2007-04-13 Thread Guennadi Liakhovetski
Hi Either I've finally gone blind on this Friday 13th or... Looks like this almost 3 year old function has a bug. Patch below compile-tested... in a way. Thanks Guennadi --- Guennadi Liakhovetski dma_declare_coherent_memory() allocates a bitmap 1 bit per page, it calculates the bitmap size