Mesa (master): freedreno: import libdrm_freedreno + redesign submit

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 26 22:11:41 UTC 2018


Module: Mesa
Branch: master
Commit: f3cc0d2747568a186dba433ac94af607c38fa024
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3cc0d2747568a186dba433ac94af607c38fa024

Author: Rob Clark <robdclark at gmail.com>
Date:   Sun Oct 21 10:22:11 2018 -0400

freedreno: import libdrm_freedreno + redesign submit

In the pursuit of lowering driver overhead, it became clear that some
amount of redesign of how libdrm_freedreno constructs the submit ioctl
would be needed.  In particular, as the gallium driver is starting to
make heavier use of CP_SET_DRAW_STATE state groups/objects, the over-
head of tracking cmd buffers and relocs becomes too much.  And for
"streaming" state, which isn't ever reused (like uniform uploads) the
overhead of allocating/freeing ringbuffer[1] objects is too high.

This redesign makes two main changes:

 1) Introduces a fd_submit object for tracking bos and cmds table
    for the submit ioctl, making ringbuffer objects more light-
    weight.  This was previously done in the ringbuffer.  But we
    have many ringbuffer instances involved in a submit (gmem +
    draw + potentially 1000's of state-group rbs), and only need
    a single bos and cmds table.  (Reloc table is still per-rb)

    The submit is also a convenient place for a slab allocator for
    ringbuffer objects.  Other options would have required locking
    because, while we can guarantee allocations will only happen on
    a single thread, free's could happen either on the application
    thread or the flush_queue thread.  With the slab allocator in
    the submit object, any frees that happen on the flush_queue
    thread happen after we know that the application thread is done
    with the submit.

 2) Introduce a new "softpin" msm_ringbuffer_sp implementation that
    does not use relocs and only has cmds table entries for IB1 (ie.
    the cmdstream buffers that kernel needs to CP_INDIRECT_BUFFER
    to from the RB).  To do this properly will require some updates
    on the kernel side, so whether you get the softpin or legacy
    submit/ringbuffer implementation at runtime depends on your
    kernel version.

To make all these changes in libdrm would basically require adding a
libdrm_freedreno2, so this is a good point to just pull the libdrm code
into mesa.  Plus it allows for using mesa's hashtable, slab allocator,
etc.  And it lets us have asserts enabled for debug mesa buids but
omitted for release builds.  And it makes life easier if further API
changes become necessary.

At this point I haven't tried to pull in the kgsl backend.  Although
I left the level of vfunc indirection which would make it possible
to have other backends.  (And this was convenient to keep to allow
for the "softpin" ringbuffer to coexist.)

NOTE: if bisecting a build error takes you here, try a clean build.
There are a bunch of ways things can go wrong if you still have
libdrm_freedreno cflags.

[1] "ringbuffer" is probably a bad name, the only level of cmdstream
    buffer that is actually a ring is RB managed by kernel.  User-
    space cmdstream is all IB1/IB2 and state-groups.

Reviewed-by: Kristian H. Kristensen <hoegsberg at chromium.org>
Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>
Signed-off-by: Rob Clark <robdclark at gmail.com>

---

 configure.ac                                       |   2 -
 meson.build                                        |   3 -
 src/gallium/drivers/freedreno/Android.mk           |   3 +-
 src/gallium/drivers/freedreno/Makefile.am          |   7 +-
 src/gallium/drivers/freedreno/Makefile.sources     |  17 +
 src/gallium/drivers/freedreno/a3xx/fd3_context.h   |   2 -
 src/gallium/drivers/freedreno/a4xx/fd4_context.h   |   2 -
 src/gallium/drivers/freedreno/a5xx/fd5_context.h   |   2 -
 src/gallium/drivers/freedreno/a5xx/fd5_draw.c      |   3 +-
 src/gallium/drivers/freedreno/a6xx/fd6_context.h   |   2 -
 src/gallium/drivers/freedreno/a6xx/fd6_draw.c      |   3 +-
 src/gallium/drivers/freedreno/a6xx/fd6_emit.c      |  26 +-
 src/gallium/drivers/freedreno/drm/freedreno_bo.c   | 361 +++++++++++
 .../drivers/freedreno/drm/freedreno_bo_cache.c     | 218 +++++++
 .../drivers/freedreno/drm/freedreno_device.c       | 156 +++++
 .../drivers/freedreno/drm/freedreno_drmif.h        | 126 ++++
 src/gallium/drivers/freedreno/drm/freedreno_pipe.c | 100 +++
 src/gallium/drivers/freedreno/drm/freedreno_priv.h | 258 ++++++++
 .../drivers/freedreno/drm/freedreno_ringbuffer.c   | 114 ++++
 .../drivers/freedreno/drm/freedreno_ringbuffer.h   | 159 +++++
 src/gallium/drivers/freedreno/drm/msm_bo.c         | 170 +++++
 src/gallium/drivers/freedreno/drm/msm_device.c     |  61 ++
 src/gallium/drivers/freedreno/drm/msm_drm.h        | 308 +++++++++
 src/gallium/drivers/freedreno/drm/msm_pipe.c       | 223 +++++++
 src/gallium/drivers/freedreno/drm/msm_priv.h       | 140 ++++
 src/gallium/drivers/freedreno/drm/msm_ringbuffer.c | 721 +++++++++++++++++++++
 .../drivers/freedreno/drm/msm_ringbuffer_sp.c      | 551 ++++++++++++++++
 src/gallium/drivers/freedreno/freedreno_batch.c    |  25 +-
 src/gallium/drivers/freedreno/freedreno_batch.h    |   2 +
 src/gallium/drivers/freedreno/freedreno_gmem.c     |   8 +-
 src/gallium/drivers/freedreno/freedreno_screen.c   |   1 +
 src/gallium/drivers/freedreno/freedreno_screen.h   |   4 +-
 src/gallium/drivers/freedreno/freedreno_util.h     |  30 +-
 src/gallium/drivers/freedreno/ir3/ir3_shader.c     |  11 +-
 src/gallium/drivers/freedreno/meson.build          |  23 +-
 src/gallium/winsys/freedreno/drm/meson.build       |   2 +-
 36 files changed, 3765 insertions(+), 79 deletions(-)

Diff:   http://cgit.freedesktop.org/mesa/mesa/diff/?id=f3cc0d2747568a186dba433ac94af607c38fa024



More information about the mesa-commit mailing list