From: roel <12o3l@tiscali.nl>
To: Matthew Wilcox <willy@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] Change dmapool free block management
Date: Wed, 26 Sep 2007 22:07:11 +0200 [thread overview]
Message-ID: <46FABBEF.5000301@tiscali.nl> (raw)
In-Reply-To: <1190833279354-git-send-email-willy@linux.intel.com>
Matthew Wilcox wrote:
[...]
> @@ -113,9 +133,12 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
> return NULL;
> }
>
> - if (size == 0)
> + if (size == 0) {
> return NULL;
> -
> + } else if (size < 4) {
> + size = 4;
> + }
you could do without brackets
[...]
> @@ -263,34 +288,21 @@ void dma_pool_destroy(struct dma_pool *pool)
> *
> * This returns the kernel virtual address of a currently unused block,
> * and reports its dma address through the handle.
> - * If such a memory block can't be allocated, null is returned.
> + * If such a memory block can't be allocated, %NULL is returned.
> */
> void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
> dma_addr_t * handle)
> {
> unsigned long flags;
> struct dma_page *page;
> - int map, block;
> size_t offset;
> void *retval;
>
> spin_lock_irqsave(&pool->lock, flags);
> restart:
> list_for_each_entry(page, &pool->page_list, page_list) {
> - int i;
> - /* only cachable accesses here ... */
> - for (map = 0, i = 0;
> - i < pool->blocks_per_page; i += BITS_PER_LONG, map++) {
> - if (page->bitmap[map] == 0)
> - continue;
> - block = ffz(~page->bitmap[map]);
> - if ((i + block) < pool->blocks_per_page) {
> - clear_bit(block, &page->bitmap[map]);
> - offset = (BITS_PER_LONG * map) + block;
> - offset *= pool->size;
> - goto ready;
> - }
> - }
> + if (page->offset < pool->allocation)
> + goto ready;
> }
> if (!(page = pool_alloc_page(pool, GFP_ATOMIC))) {
page = pool_alloc_page(pool, GFP_ATOMIC);
if(!page) {
[...]
> @@ -355,7 +366,7 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
> {
> struct dma_page *page;
> unsigned long flags;
> - int map, block;
> + unsigned int offset;
>
> if ((page = pool_find_page(pool, dma)) == 0) {
page = pool_find_page(pool, dma);
if (page == 0) {
> if (pool->dev)
> @@ -368,13 +379,9 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
> return;
> }
>
> - block = dma - page->dma;
> - block /= pool->size;
> - map = block / BITS_PER_LONG;
> - block %= BITS_PER_LONG;
> -
> + offset = vaddr - page->vaddr;
> #ifdef CONFIG_DEBUG_SLAB
> - if (((dma - page->dma) + (void *)page->vaddr) != vaddr) {
> + if ((dma - page->dma) != offset) {
if (dma - page->dma != offset) {
[...]
next prev parent reply other threads:[~2007-09-26 20:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-26 18:57 dmapool Matthew Wilcox
2007-09-26 19:01 ` [PATCH 1/4] Avoid taking waitqueue lock in dmapool Matthew Wilcox
2007-09-26 21:10 ` David Miller
2007-09-26 19:01 ` [PATCH 2/4] dmapool: Validate parameters to dma_pool_create Matthew Wilcox
2007-09-26 19:47 ` roel
[not found] ` <20070926214022.GA14710@linuxntel.com>
2007-09-26 21:08 ` roel
2007-09-26 21:10 ` David Miller
2007-09-26 19:01 ` [PATCH 3/4] Change dmapool free block management Matthew Wilcox
2007-09-26 19:23 ` Roland Dreier
2007-09-26 20:07 ` roel [this message]
2007-09-26 21:13 ` David Miller
2007-09-26 19:01 ` [PATCH 4/4] dmapool: Improve memory usage for devices which can't cross boundaries Matthew Wilcox
2007-09-26 20:12 ` roel
2007-09-26 21:14 ` David Miller
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=46FABBEF.5000301@tiscali.nl \
--to=12o3l@tiscali.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.