分配大的DMA缓冲区 [英] Allocating a large DMA buffer

查看:338
本文介绍了分配大的DMA缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想分配一个大的DMA缓冲区,大小约为40 MB.当我使用dma_alloc_coherent()时,它失败了,我看到的是:

I want to allocate a large DMA buffer, about 40 MB in size. When I use dma_alloc_coherent(), it fails and what I see is:

------------[ cut here ]------------
WARNING: at mm/page_alloc.c:2106 __alloc_pages_nodemask+0x1dc/0x788()
Modules linked in:
[<8004799c>] (unwind_backtrace+0x0/0xf8) from [<80078ae4>] (warn_slowpath_common+0x4c/0x64)
[<80078ae4>] (warn_slowpath_common+0x4c/0x64) from [<80078b18>] (warn_slowpath_null+0x1c/0x24)
[<80078b18>] (warn_slowpath_null+0x1c/0x24) from [<800dfbd0>] (__alloc_pages_nodemask+0x1dc/0x788)
[<800dfbd0>] (__alloc_pages_nodemask+0x1dc/0x788) from [<8004a880>] (__dma_alloc+0xa4/0x2fc)
[<8004a880>] (__dma_alloc+0xa4/0x2fc) from [<8004b0b4>] (dma_alloc_coherent+0x54/0x60)
[<8004b0b4>] (dma_alloc_coherent+0x54/0x60) from [<803ced70>] (mxc_ipu_ioctl+0x270/0x3ec)
[<803ced70>] (mxc_ipu_ioctl+0x270/0x3ec) from [<80123b78>] (do_vfs_ioctl+0x80/0x54c)
[<80123b78>] (do_vfs_ioctl+0x80/0x54c) from [<8012407c>] (sys_ioctl+0x38/0x5c)
[<8012407c>] (sys_ioctl+0x38/0x5c) from [<80041f80>] (ret_fast_syscall+0x0/0x30)
---[ end trace 4e0c10ffc7ffc0d8 ]---

我尝试了不同的值,看来dma_alloc_coherent()分配的字节数不能超过2 ^ 25字节(32 MB).

I've tried different values and it looks like dma_alloc_coherent() can't allocate more than 2^25 bytes (32 MB).

如何分配这么大的DMA缓冲区?

How can such a large DMA buffer can be allocated?

推荐答案

系统启动后,dma_alloc_coherent()不一定对大型分配可靠.这仅仅是因为不可移动的页面会迅速填满您的物理内存,从而使连续的大范围区域变得罕见.长期以来这一直是一个问题.

After the system has booted up dma_alloc_coherent() is not necessarily reliable for large allocations. This is simply because non-moveable pages quickly fill up your physical memory making large contiguous ranges rare. This has been a problem for a long time.

方便的是,最近的补丁集可能会对您有所帮助,这是出现在内核3.5中的连续内存分配器.如果您正在使用带有此功能的内核,那么您应该能够在内核命令行上传递cma=64M,并且将保留大量内存(仅可移动页面将被放置在此处).当您随后要求分配40M时,它应该可靠地成功.简单!

Conveniently a recent patch-set may help you out, this is the contiguous memory allocator which appeared in kernel 3.5. If you're using a kernel with this then you should be able to pass cma=64M on your kernel command line and that much memory will be reserved (only moveable pages will be placed there). When you subsequently ask for your 40M allocation it should reliably succeed. Simples!

有关更多信息,请查看这篇LWN文章:

For more information check out this LWN article:

https://lwn.net/Articles/486301/

这篇关于分配大的DMA缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆