[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#42686] Update to linux-libre 5.7

From: Danny Milosavljevic
Subject: [bug#42686] Update to linux-libre 5.7
Date: Tue, 4 Aug 2020 12:36:57 +0200

Hi Leo,

On Sun, 2 Aug 2020 18:43:56 -0400
Leo Famulari <> wrote:

> * Enable the DMA-BUF userland memory heaps? This options creates per
> heap chardevs in /dev/dma_heap/ which allows userspace to allocate
> dma-bufs that can be shared between drivers. (DMABUF_HEAPS)
> I don't really know what that means.

DMA ("direct memory access") is a method to automatically have devices transfer
memory blocks to (and/or from) volatile memory without the involvement of the

dma-bufs are buffers that can be used for DMA.  These are distinct from regular
buffers because DMA is done without the involvement of the CPU, so setting up
a DMA buffer, telling the device the buffer location, and then freeing (or
swapping out) the buffer would be very bad (the device wouldn't know that it
is freed and would just continue using it, bypassing all the usual kernel
access checks--because it doesn't use the CPU in the first place).

A dma-buf heap is an allocator for dma-buf buffers and some limits where it
can allocate.  That is needed because peripheral chips have all kinds of
weird limitations on where the dma-buf buffer can be in memory (for example
some GPUs require the dma-buf buffers to be in the first 256 MiB of memory),
so the allocator has to take into account that the later devices can actually
reach the buffers and give them a dma-buf buffer at some weird location,
aliged like the device likes it and size-padded so the device doesn't
scribble over something else while using potentially huge block transfers.

A dma-buf userland memory heap is a device file in directory /dev/dma_heap/
which is connected to one specific dma-buf heap allocator in the kernel.
A userspace program can then use a weird ioctl to request a dma-buf buffer,
which then will be allocated.  A file descriptor will be returned to the
userspace program.  This FD can be inherited by child processes etc--the

These dma-buf buffers are annoying in that you can't swap them out, free them
and reallocate them later--or anything else you would do with normal memory.
Also, when using them you need to use a memory fence in order to synchronize
accesses between the CPU and the other devices that are using the buffer.

That means allocating those dma-buf buffers without needing them is a great
way to exhaust all RAM, with the kernel not having any recourse in reclaiming
them.  So, require root.

If the heap allocator that is used for that has a device-specific limit,
that is much safer, though.

The thing is mostly used by Android.

Attachment: pgpNYL31mZ79V.pgp
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]