2004-10-19 05:45:05

by Srinivas G.

[permalink] [raw]
Subject: DMA memory allocation --how to more than 1 MB

Hi All,

I have a doubt about allocating the DMA memory using kmalloc OR
__get_dma_pages OR pci_alloc_consistent. I was unable to allocate the
memory greater than 1 MB using any one of the above memory functions.

Is there any other method which will allocate the DMA memory greater
than 1 MB?

My system configuration is: Red Hat 7.3 with 2.4.18-3 kernel version on
IA32 platform.

Thanks and regards,
Srinivas G


2004-10-19 10:37:51

by William Lee Irwin III

[permalink] [raw]
Subject: Re: DMA memory allocation --how to more than 1 MB

On Tue, Oct 19, 2004 at 11:18:13AM +0530, Srinivas G. wrote:
> I have a doubt about allocating the DMA memory using kmalloc OR
> __get_dma_pages OR pci_alloc_consistent. I was unable to allocate the
> memory greater than 1 MB using any one of the above memory functions.
> Is there any other method which will allocate the DMA memory greater
> than 1 MB?
> My system configuration is: Red Hat 7.3 with 2.4.18-3 kernel version on
> IA32 platform.

This is not supported at runtime. If this is an absolute requirement,
using the bootmem.c physical memory reservation system from architecture-
specific initialization code is the way.

It's more likely that you should be using scatter/gather than that you
should try to carry that out.


-- wli

2004-10-19 13:52:30

by Christian Leber

[permalink] [raw]
Subject: Re: DMA memory allocation --how to more than 1 MB

On Tue, Oct 19, 2004 at 11:18:13AM +0530, Srinivas G. wrote:
> I have a doubt about allocating the DMA memory using kmalloc OR
> __get_dma_pages OR pci_alloc_consistent. I was unable to allocate the
> memory greater than 1 MB using any one of the above memory functions.
>
> Is there any other method which will allocate the DMA memory greater
> than 1 MB?

You should be able to get at least order 9, therefore 2 MB.
With kernel 2.6 you should also be able to get order 10, therefore 4 MB.
If you need more you have to puzzle the areas together.

The way wli suggested is better.
But if this is no possible just make it a requierement to load the
module while booting, then there are enough free areas.


Christian Leber

--
"Omnis enim res, quae dando non deficit, dum habetur et non datur,
nondum habetur, quomodo habenda est." (Aurelius Augustinus)
Translation: <http://gnuhh.org/work/fsf-europe/augustinus.html>

2004-10-19 14:22:16

by William Lee Irwin III

[permalink] [raw]
Subject: Re: DMA memory allocation --how to more than 1 MB

On Tue, Oct 19, 2004 at 11:18:13AM +0530, Srinivas G. wrote:
>> I have a doubt about allocating the DMA memory using kmalloc OR
>> __get_dma_pages OR pci_alloc_consistent. I was unable to allocate the
>> memory greater than 1 MB using any one of the above memory functions.
>> Is there any other method which will allocate the DMA memory greater
>> than 1 MB?

On Tue, Oct 19, 2004 at 03:52:14PM +0200, Christian Leber wrote:
> You should be able to get at least order 9, therefore 2 MB.
> With kernel 2.6 you should also be able to get order 10, therefore 4 MB.
> If you need more you have to puzzle the areas together.
> The way wli suggested is better.
> But if this is no possible just make it a requierement to load the
> module while booting, then there are enough free areas.

Please understand that the possibility of requesting higher orders at
runtime is not the same as a guarantee. While it is allowed to request
such large physically contiguous areas, there is no assurance of success,
so any requester of such large areas doing so at runtime must
understand alternative methods of carrying out its task when such large
physically contiguous areas are unavailable, as they typically are after
even small amounts of runtime because of external memory fragmentation.

Consider, for example, i386 hugetlb. Hugetlb can't function at all
without large physically contiguous areas of order 9 or 10 on i386 as
the hardware it programs has such contiguity as an absolute requirement.
Toward the ends I described, when a request is made for it to increase
the size of its memory pool, it does not rely on the success of the
allocations, but instead only increases the size of its pool by the
amount of memory that was successfully allocated. Also, for the purpose
of reliably obtaining the memory, a kernel command-line option was
implemented carrying out these allocations at boot-time.

Constraints analogous to hugetlb's are truly rarely encountered in the
context of I/O devices. Those typically support scatter/gather, and in
general should use that feature to operate on physically discontiguous
memory as opposed to relying upon large contiguous allocations. Please
ignore the numerous examples in the kernel contradicting me, as they
are generally not thought well of.


-- wli