Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Mar 2002 16:10:06 -0600 (CST)
From:      mark tinguely <tinguely@web.cs.ndsu.nodak.edu>
To:        gjohnson@research.canon.com.au, tinguely@web.cs.ndsu.nodak.edu
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: DMA memory allocation/deallocation
Message-ID:  <200203132210.g2DMA6s15248@web.cs.ndsu.nodak.edu>
In-Reply-To: <20020313204049.13A80540D0@brixi.research.canon.com.au>

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.
>

you may want a bugreport.

>  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?

It tries to squeeze out pageable memory, but it is not always successful.
no other re-arranging is done because we don't know all the pointers
and devices that are using that memory.

but since most allocations are done by grabbing the first available
chunk that works, you can try the trick of allocating the big things
towards the end of the memory range and work your way backwards,
unfortunately that would mean bypassing the politically correct
way of allocating the buffer by using bus_dmamem_alloc().
Evenually that trick will fail too.

You can make that memory "static", by not really releasing it.
Of course no one else can use it either.

the contig allocation leak I alluded to was if you have lots of
physical memory, but did not expand the kernel virtual map. then
we don't put back the contiguous memory back into the available
array. since you should have a kernel virtual of at least 1GB and
only physical of 512MB, you are not hitting this situation.

--mark tinguely.

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?200203132210.g2DMA6s15248>