Feature
ION
DMABUF
Memory Manager Role
ION replaces PMEM as the manager of provisioned memory pools. The list of ION heaps can be extended per device.
DMABUF is a buffer sharing framework, designed to integrate with the memory allocators in DMA mapping frameworks, like the work-in-progress DMA-contiguous allocator, also known as theContiguous Memory Allocator (CMA). DMABUF exporters have the option to implement custom allocators.
User Space Access Control
ION offers the /dev/ion interface for user-space programs to allocate and share buffers. Any user program with ION access can cripple the system by depleting the ION heaps. Android checks user and group IDs to block unauthorized access to ION heaps.
DMABUF offers only kernel APIs. Access control is a function of the permissions on the devices using the DMABUF feature.
Global Client and Buffer Database
ION contains a device driver associated with /dev/ion. The device structure contains a database that tracks the allocated ION buffers, handles and file descriptors, all grouped by user clients and kernel clients. ION validates all client calls according to the rules of the database. For example, there is a rule that a client cannot have two handles to the same buffer.
The DMA debug facility implements a global hashtable,dma_entry_hash, to track DMA buffers, but only when the kernel was built with theCONFIG_DMA_API_DEBUG option.
Cross-architecture Usage
ION usage today is limited to architectures that run the Android kernel.
DMABUF usage is cross-architecture. The DMA mapping redesign preparation patchset modified the DMA mapping code in 9 architectures besides the ARM architecture.
Buffer Synchronization
ION considers buffer synchronization to be an orthogonal problem.
DMABUF provides a pair of APIs for synchronization. The buffer-user callsdma_buf_map_attachment() whenever it wants to use the buffer for DMA . Once the DMA for the current buffer-user is over, it signals 'end-of-DMA' to the exporter via a call todma_buf_unmap_attachment().
Delayed Buffer Allocation
ION allocates the physical memory before the buffer is shared.
DMABUF can defer the allocation until the first call todma_buf_map_attachment(). The exporter of DMA buffer has the opportunity to scan all client attachments, collate their buffer constraints, then choose the appropriate backing storage.
聯(lián)系客服