[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mesa3d-dev
Subject:    Re: GBM as standalone buffer allocator
From:       Yiwei Zhang <zzyiwei () chromium ! org>
Date:       2023-11-19 23:08:29
Message-ID: CAH25ezuxkHOkWc=EHvAZezW8Cu_fFGm5W1EyPwvwEsN8XK9oUQ () mail ! gmail ! com
[Download RAW message or body]

There's
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26038. It is
quite appealing to me considering a VK only scenario.

On Thu, Nov 2, 2023 at 5:50 AM Srinivas Pullakavi (QUIC) <
quic_spullaka@quicinc.com> wrote:

> Hi Rob,
>
> Thanks for your inputs.
>
> We are planning to use DMA-Buf for GBM backend. DMA-buf supported heaps
> are listed in /dev/dma_heap/
> Gbm backend selects the best heap based on usage. For example: Secure
> buffers will be allocated from secure heap.
>
> Sample output:
>                      # ls /dev/dma_heap
>                  reserved  system
>
> Sample code to allocate a buffer from system heap:
>         int heap_fd = open(/dev/dma_heap/system, O_RDONLY | O_CLOEXEC))
>         struct dma_heap_allocation_data heap_data {
>               .len = size,                      // length of data to be
> allocated in bytes
>               .fd_flags = O_RDWR | O_CLOEXEC,   // permissions for the
> memory to be allocated
>               };
>         int status = ioctl(heap_fd, DMA_HEAP_IOCTL_ALLOC, &heap_data)
>         if (status == 0) {
>                  int buffer_fd = heap_data.fd;
>               }
>
> In this case, there is no dependency on display / Graphics driver. But
> still GBM create device expects a device fd to be passed.
>
> Can we make it optional to pass device fd ?
>
> Thanks,
> Srinivas
>
> -----Original Message-----
> From: Rob Clark <robdclark@gmail.com>
> Sent: Tuesday, October 24, 2023 1:06 AM
> To: Srinivas Pullakavi (QUIC) <quic_spullaka@quicinc.com>
> Cc: mesa-dev@lists.freedesktop.org
> Subject: Re: GBM as standalone buffer allocator
>
> On Mon, Oct 23, 2023 at 6:22 AM Srinivas Pullakavi (QUIC) <
> quic_spullaka@quicinc.com> wrote:
> >
> > Hi,
> >
> >
> >
> > We are planning to enhance GBM as a standalone buffer allocator, which
> > can be used for all multi-media clients. Ex: video, camera, display
> > etc;
> >
> >
> >
> > GBM create device expects a file descriptor to be passed, which points
> to drm node. This brings in a dependency on display for buffer allocation.
> On headless devices where display driver is not present, GBM cannot be used
> for buffer allocations. E.g. Recording cases where pipeline is setup
> between Camera, Video, Graphics.
> >
>
> Note that you need some sort of device to allocate buffers from.  With
> mesa and upstream kernel, that would be the drm device.  (However as Adam
> points out, a drm device does not necessarily need a display..
> for example, several vendors have compute-only GPUs (pci) which have no
> display outputs.)
>
> You might want to look at ChromeOS's minigbm.  It already handles these
> cases (buffer sharing across display/gpu/video/camera).
>
> BR,
> -R
>
> [1] https://chromium.googlesource.com/chromiumos/platform/minigbm/
>
> >
> > Could you please share your comments on what will be a good design to
> make GBM flexible for above?
> >
> >
> >
> > Thanks,
> >
> > Srinivas
> >
> >
>

[Attachment #3 (text/html)]

<div dir="auto">There's  <br></div><div dir="auto"><div dir="auto"><a \
href="https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26038">https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26038</a>. \
It is quite appealing to me considering a VK only scenario.</div></div><div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 2, 2023 at \
5:50 AM Srinivas Pullakavi (QUIC) &lt;<a \
href="mailto:quic_spullaka@quicinc.com">quic_spullaka@quicinc.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">Hi \
Rob,<br> <br>
Thanks for your inputs.<br>
<br>
We are planning to use DMA-Buf for GBM backend. DMA-buf supported heaps are listed in \
/dev/dma_heap/<br> Gbm backend selects the best heap based on usage. For example: \
Secure buffers will be allocated from secure heap.<br> <br>
Sample output: <br>
                                # ls /dev/dma_heap<br>
                          reserved   system<br>
<br>
Sample code to allocate a buffer from system heap:<br>
            int heap_fd = open(/dev/dma_heap/system, O_RDONLY | O_CLOEXEC))<br>
            struct dma_heap_allocation_data heap_data {<br>
                     .len = size,                                 // length of data \
                to be allocated in bytes<br>
                     .fd_flags = O_RDWR | O_CLOEXEC,     // permissions for the \
memory to be allocated<br>  };<br>
            int status = ioctl(heap_fd, DMA_HEAP_IOCTL_ALLOC, &amp;heap_data)<br>
            if (status == 0) {<br>
                          int buffer_fd = heap_data.fd;<br>
                     }<br>
<br>
In this case, there is no dependency on display / Graphics driver. But still GBM \
create device expects a device fd to be passed.<br> <br>
Can we make it optional to pass device fd ?<br>
<br>
Thanks,<br>
Srinivas<br>
<br>
-----Original Message-----<br>
From: Rob Clark &lt;<a href="mailto:robdclark@gmail.com" \
                target="_blank">robdclark@gmail.com</a>&gt; <br>
Sent: Tuesday, October 24, 2023 1:06 AM<br>
To: Srinivas Pullakavi (QUIC) &lt;<a href="mailto:quic_spullaka@quicinc.com" \
                target="_blank">quic_spullaka@quicinc.com</a>&gt;<br>
Cc: <a href="mailto:mesa-dev@lists.freedesktop.org" \
                target="_blank">mesa-dev@lists.freedesktop.org</a><br>
Subject: Re: GBM as standalone buffer allocator<br>
<br>
On Mon, Oct 23, 2023 at 6:22 AM Srinivas Pullakavi (QUIC) &lt;<a \
href="mailto:quic_spullaka@quicinc.com" \
target="_blank">quic_spullaka@quicinc.com</a>&gt; wrote:<br> &gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; We are planning to enhance GBM as a standalone buffer allocator, which <br>
&gt; can be used for all multi-media clients. Ex: video, camera, display <br>
&gt; etc;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; GBM create device expects a file descriptor to be passed, which points to drm \
node. This brings in a dependency on display for buffer allocation. On headless \
devices where display driver is not present, GBM cannot be used for buffer \
allocations. E.g. Recording cases where pipeline is setup between Camera, Video, \
Graphics.<br> &gt;<br>
<br>
Note that you need some sort of device to allocate buffers from.   With mesa and \
upstream kernel, that would be the drm device.   (However as Adam points out, a drm \
device does not necessarily need a display..<br> for example, several vendors have \
compute-only GPUs (pci) which have no display outputs.)<br> <br>
You might want to look at ChromeOS&#39;s minigbm.   It already handles these cases \
(buffer sharing across display/gpu/video/camera).<br> <br>
BR,<br>
-R<br>
<br>
[1] <a href="https://chromium.googlesource.com/chromiumos/platform/minigbm/" \
rel="noreferrer" target="_blank">https://chromium.googlesource.com/chromiumos/platform/minigbm/</a><br>
 <br>
&gt;<br>
&gt; Could you please share your comments on what will be a good design to make GBM \
flexible for above?<br> &gt;<br>
&gt;<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Srinivas<br>
&gt;<br>
&gt;<br>
</blockquote></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic