From: James Bottomley <James.Bottomley@SteelEye.com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-kernel@vger.kernel.org, jayalk@intworks.biz,
akpm@linux-foundation.org
Subject: Re: [PATCH] dma_declare_coherent_memory wrong allocation
Date: Mon, 23 Apr 2007 11:58:25 -0400 [thread overview]
Message-ID: <1177343905.6284.22.camel@mulgrave> (raw)
In-Reply-To: <Pine.LNX.4.60.0704222202050.4127@poirot.grange>
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
buffer. If the size isn't a multiple of page size, we have to round
down (we can't allocate the last page if the memory we have is only part
of a page).
I suppose if you want to catch the unlikely nutcase where size <
PAGE_SIZE you could
if (unlikely(pages == 0))
goto out;
> + int bitmap_size = BITS_TO_LONGS(pages) * BYTES_PER_LONG;
This is fine, except the BYTES_PER_LONG. Traditionally, we do this with
sizeof(long). The only reason to have a #define for it is if it has to
be used in a macro (the compiler does sizeof() not the preprocessor).
How about just a simple
int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
?
Then you don't need the first patch defining BYTES_PER_LONG.
> to also allow for size not an integer number of pages as Andrew noticed?
> This could be done in 2 patches:
James
next prev parent reply other threads:[~2007-04-23 16:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-13 18:08 [PATCH] dma_declare_coherent_memory wrong allocation Guennadi Liakhovetski
2007-04-21 7:08 ` Andrew Morton
2007-04-21 11:01 ` Guennadi Liakhovetski
2007-04-22 16:52 ` James Bottomley
2007-04-22 22:45 ` Guennadi Liakhovetski
2007-04-22 22:49 ` Guennadi Liakhovetski
2007-04-23 15:58 ` James Bottomley [this message]
2007-04-23 20:45 ` Guennadi Liakhovetski
2007-04-26 13:47 ` James Bottomley
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=1177343905.6284.22.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=akpm@linux-foundation.org \
--cc=g.liakhovetski@gmx.de \
--cc=jayalk@intworks.biz \
--cc=linux-kernel@vger.kernel.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