Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Mar 2002 07:40:49 +1100 (EST)
From:      gjohnson@research.canon.com.au (Greg Johnson)
To:        tinguely@web.cs.ndsu.nodak.edu (mark tinguely)
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: DMA memory allocation/deallocation
Message-ID:  <20020313204049.13A80540D0@brixi.research.canon.com.au>
In-Reply-To: <200203132019.g2DKJl514183@web.cs.ndsu.nodak.edu> from "mark tinguely" at Mar 13, 2002 02:19:47 

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks for the reply Mark, I tracked my problem down. In
'bus_dmamem_alloc', 'contigmalloc' is used if the size is
greater than PAGE_SIZE. However, in 'bus_dmamem_free'
the same PAGE_SIZE check is performed, but nothing is
done for the case where the size is greater than PAGE_SIZE.

So I then called contigfree explicitly in my code, and the
memory is released.

Another problem though, I am allocating a large DMAable buffer
~300MB. I get to allocate this and free this twice on our system
(512MB memory). However, when I try a third time to load my device
driver and allocate the memory, it fails. Subsequent attempts
also fail.

It seems that something is allocating in the middle of my
nice big free buffer.

Does 'contigalloc' do anything sensible like shuffling arround
of pages in physical memory to make room for the requested amount
of space?

Regards

Greg.

Quoth mark tinguely:
> there was a contig_free bug that was squashed between 4.4 and 4.5,
> by Matt Dillon. If I remember correctly there is a slight leak if
> the contig_malloc failed, but that would not be your problem.
> 
> it is possible that something else on the system is allocating at least
> single block in that now freed, but perfect sized chunk. as a result,
> the new allocation can no longer use that memory and has to search higher
> in RAM.
> 
> try a few back to back bus_dmamem_alloc() and bus_dmamem_free() without
> any other operations and if that is sliding up in RAM there is a(nother)
> problem in the contiguous free...my guess it will operate normally and
> the problem is related to someone allocating a block and breaking up
> that nice contiguous chunk.

-- 
+------------------------------------------------------+
| Do you want to know more? www.geocities.com/worfsom/ |
|              ..ooOO Greg Johnson OOoo..              |
| HW/SW Engineer        gjohnson@research.canon.COM.Au |
| Canon Information Systems Research Australia (CISRA) |
| 1 Thomas Holt Dr., North Ryde, NSW, 2113,  Australia |
|      "I FLEXed my BISON and it went YACC!" - me.     |
+------------------------------------------------------+


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020313204049.13A80540D0>