Commit Graph

65 Commits (bec2a28e98f430f4a82b085b4d1c69a98988359f)

Author SHA1 Message Date
Eric Engestrom 360292c7ab fix various typos
Saw a couple of typos fixes in the patch DragonFlyBSD carries [1], so
I ran codespell (a spell checker for code) on the whole repo.

[1] https://github.com/DragonFlyBSD/DPorts/blob/master/graphics/libdrm/files/patch-xf86drm.c

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-04-17 18:23:25 +01:00
Rob Clark f94075c3c5 freedreno/msm: fix c90 warning
Wasn't really sure how to switch the silly -Wdeclaration-after-statement
flag off on a per directory basis.  So make the code uglier instead.
2018-10-14 11:23:17 -04:00
Rob Clark 032258b7f7 freedreno/msm: handle ring-reloc to other stateobjs
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:24:12 -04:00
Rob Clark 413a49a068 freedreno/msm: simplify msm_ringbuffer_flush()
Now that it doesn't have to deal with ringmarkers we can simplify the
reloc handling.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:23:54 -04:00
Rob Clark 880871b378 freedreno/msm: use hashtable to track submit.cmds table
With streaming stateobjs to upload uniforms, the submit.cmds table gets
much larger, and iterating over it for each ring to ring reloc starts
getting expensive.

TODO if we have flag to pass when constructing parent rb, we could
avoid dynamically allocating this and bo_table in get_cmd() or bo2idx

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:23:35 -04:00
Rob Clark 5c4722e907 freedreno/msm: simplify emit_reloc_ring() vfunc
Now that it doesn't have to deal with the ringmarker case, we can make
some simplifications.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:23:12 -04:00
Rob Clark 96b625240c freedreno/msm: remove reset of linked rings
The msm_cmd isn't refcount'd, so with stateobj rb's that have
independent lifecycle, this is no longer a safe thing to do.
Really, now that there is a bo-cache for rb's, fd_ringbuffer_reset()
should be deprecated because it adds a bunch of pointless complexity.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:22:49 -04:00
Rob Clark 33faf339c3 freedreno/msm: support suballocation for stateobj rb's
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:21:53 -04:00
Rob Clark a8a0061926 freedreno: expose refcnt'ing on ringbuffers
Move this out of msm_ringbuffer backend so that the gallium driver can
refcnt rb's

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:18:43 -04:00
Rob Clark 566b1d9f93 freedreno/msm: get rid of ring_bo unref hack
Since 28328298 'freedreno: move ring_cache behind fd_bo_del()' this hack
is no longer necessary.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:12:22 -04:00
Rob Clark 28328298ca freedreno: move ring_cache behind fd_bo_del()
So that it isn't bypassing normal refcnt'ing.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-09-14 13:41:44 -04:00
Tanmay Shah f0c642e8df libdrm: add msm drm uapi header
msm_drm.h file Generated using make headers_install.

Generated from
tree - git://people.freedesktop.org/~airlied/linux
branch - drm-next
commit - 6d08b06e67cd117f6992c46611dfb4ce267cd71e

Remove freedreno/msm/msm_drm.h to maintain only
one copy of msm_drm.h and change freedreno Makefile
and meson.build file accordingly.

v2: Remove private freedreno/msm/msm_drm.h
v3: meson.build update
v3: README update (by anholt)

Signed-off-by: Tanmay Shah <tanmay@codeaurora.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
2018-08-23 08:48:45 -07:00
Rob Clark 879d7c0298 freedreno: fix use-after-free with stateobj rb's
We could be dropping last reference in ->flush(), so clear the entry in
the parent rb's table to avoid deref'ing after free'd.

Also, ring_bo_del()'s use of ring_cache expects that it is dropping the
last reference.  So drop our ref to the stateobj's ring_bo first.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-08-08 14:31:17 -04:00
Rob Clark a43940eb91 freedreno: don't leak stateobj rb refs
One stateobj can be emitted multiple times in a single cmdstream, but
only the first time is a cmd entry added to the parent.  Since it will
be only unref'd once after flush, we should only ref it the first time
it is emitted (ie. the time it is added to cmd table).

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-08-08 14:31:17 -04:00
Rob Clark 716ab859c3 freedreno/msm: "stateobj" support
Adds support for "state object" cmdstream buffers which can be
constructed once, and re-used many times.  This enables the use
for CP_SET_DRAW_STATE packets on newer hardware, to lower the
CPU overhead.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-07-30 12:18:58 -04:00
Rob Clark 04190a912e freedreno: slight reordering
Splitting code-motion out from next patch.  Once we add stateobj rb's
this loop could add new entries to bos table, so it needs to be before
we set req.bos/req.nr_bos.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-07-30 12:18:58 -04:00
Rob Clark 2932a03180 freedreno: small cleanup
Make cheezy growable array thing less open-coded before adding more.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-07-30 12:18:58 -04:00
Rob Clark fcbf206aa2 freedreno: add fd_ringbuffer_new_object()
Add new API for reusable "state objects" which can be re-used multiple
times.  Backend implementation for msm will follow.  (Probably not
needed to support this for any device that uses kgsl backend, since this
is mostly useful for a5xx+.)

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-07-30 12:18:58 -04:00
Eric Engestrom 0926f0af54 meson,configure: include config.h automatically
This will prevent any more missing `#include "config.h"` bug, at the
cost of having to recompile some files that didn't need to be when
changing build options.

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-03-20 18:19:26 +00:00
Rob Clark 1384c08123 freedreno: add interface to get buffer address
Needed for clover/OpenCL.  Fortunately the kernel interface is already
in place.

Include a stub _put_iova() so mesa can tell us when it no longer needs
the buffer to be pinned.  There is no kernel interface for this (yet),
but at least if we want to unpin buffers we won't need mesa changes.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-02-26 14:04:56 -05:00
Rob Clark 6f0f6cee5e freedreno: clamp priority based on # of rings
In case of a kernel that is new enough to support multiple submit-
queues, but with an adreno generation which doesn't support multiple
prioritized ringbuffers, we'd attempt to open a submit-queue with
prio=1 (medium), which is rejected by the kernel.

This could happen either w/ an older mesa (which uses fd_pipe_new())
or a newer mesa which defaults to prio=1 if no pipe context priority
flags are set.

The simple answer to fix both cases is to clamp the requested priority
according to the number of rings.  This might not do exactly what you
want, if we hypothetically had 2 rings (it would result in requested
medium priority being high priority instead of low priority).  But the
number of rings (for hw gen's that support this) is purely a software
construct, so the easy answer there is to have the kernel advertise at
least 3 rings if it supports more than one.  There isn't really any
reason to do otherwise.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-01-26 15:29:10 -05:00
Rob Clark 7064b2eae9 freedreno: submit-queue context priority
With a new-enough kernel to support prioritized submit-queues, we can
expose priority level support to mesa.  Open a submit queue associated
with the fd_pipe and pass it's id back to SUBMIT ioctl.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2017-11-04 17:23:20 -04:00
Rob Clark 62e0767b81 freedreno: sync uapi header (driver version 1.3.0)
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2017-11-04 17:23:20 -04:00
Eric Engestrom 6338e452c9 freedreno/msm: remove dead error path
`ring` cannot be non-null, so the label reduces to a simple return.
Then, there is no point initialising `ring` just to overwrite it before
anyone reads it.

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Rob Clark <robdclark@gmail.com>
2017-08-07 14:16:41 +01:00
Rob Clark d0dae26ca4 freedreno: valgrind support
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2017-03-23 15:22:30 -04:00
Rob Clark 2b7453f478 freedreno: fix potential use-after-free on a5xx+
Something that valgrind spotted:

==8441== Invalid read of size 4
==8441==    at 0x5DEE168: msm_ringbuffer_emit_reloc (msm_ringbuffer.c:506)
==8441==    by 0x5B48F0F: OUT_RELOCW (freedreno_util.h:241)
==8441==    by 0x5B48F0F: fd5_emit_blit (fd5_emit.h:131)
==8441==    by 0x5B48F0F: emit_gmem2mem_surf.isra.12 (fd5_gmem.c:450)
==8441==    by 0x5B4910F: fd5_emit_tile_gmem2mem (fd5_gmem.c:477)
==8441==    by 0x5B14943: render_tiles (freedreno_gmem.c:342)
==8441==    by 0x5B14943: fd_gmem_render_tiles (freedreno_gmem.c:416)
==8441==    by 0x5B0FBA7: batch_flush (freedreno_batch.c:281)
==8441==    by 0x5B0FBA7: fd_batch_flush (freedreno_batch.c:306)
==8441==    by 0x5B11FE7: fd_context_flush (freedreno_context.c:52)
==8441==    by 0x58AD783: st_glFlush (st_cb_flush.c:121)
==8441==    by 0x5751EE7: _mesa_make_current (context.c:1652)
==8441==    by 0x58E6A97: st_api_make_current (st_manager.c:811)
==8441==    by 0x5A2CE43: dri_unbind_context (dri_context.c:207)
==8441==    by 0x5A2C77F: driUnbindContext (dri_util.c:589)
==8441==    by 0x4AC8A67: MakeContextCurrent (glxcurrent.c:214)
==8441==  Address 0x6f5eb1c is 204 bytes inside a block of size 240 free'd
==8441==    at 0x4868F44: realloc (vg_replace_malloc.c:785)
==8441==    by 0x5DEE143: msm_ringbuffer_emit_reloc (msm_ringbuffer.c:502)
==8441==    by 0x5B48F0F: OUT_RELOCW (freedreno_util.h:241)
==8441==    by 0x5B48F0F: fd5_emit_blit (fd5_emit.h:131)
==8441==    by 0x5B48F0F: emit_gmem2mem_surf.isra.12 (fd5_gmem.c:450)
==8441==    by 0x5B4910F: fd5_emit_tile_gmem2mem (fd5_gmem.c:477)
==8441==    by 0x5B14943: render_tiles (freedreno_gmem.c:342)
==8441==    by 0x5B14943: fd_gmem_render_tiles (freedreno_gmem.c:416)
==8441==    by 0x5B0FBA7: batch_flush (freedreno_batch.c:281)
==8441==    by 0x5B0FBA7: fd_batch_flush (freedreno_batch.c:306)
==8441==    by 0x5B11FE7: fd_context_flush (freedreno_context.c:52)
==8441==    by 0x58AD783: st_glFlush (st_cb_flush.c:121)
==8441==    by 0x5751EE7: _mesa_make_current (context.c:1652)
==8441==    by 0x58E6A97: st_api_make_current (st_manager.c:811)
==8441==    by 0x5A2CE43: dri_unbind_context (dri_context.c:207)
==8441==    by 0x5A2C77F: driUnbindContext (dri_util.c:589)
==8441==  Block was alloc'd at
==8441==    at 0x4868F44: realloc (vg_replace_malloc.c:785)
==8441==    by 0x5DEE08B: msm_ringbuffer_emit_reloc (msm_ringbuffer.c:481)
==8441==    by 0x5B48F0F: OUT_RELOCW (freedreno_util.h:241)
==8441==    by 0x5B48F0F: fd5_emit_blit (fd5_emit.h:131)
==8441==    by 0x5B48F0F: emit_gmem2mem_surf.isra.12 (fd5_gmem.c:450)
==8441==    by 0x5B4909F: fd5_emit_tile_gmem2mem (fd5_gmem.c:465)
==8441==    by 0x5B14943: render_tiles (freedreno_gmem.c:342)
==8441==    by 0x5B14943: fd_gmem_render_tiles (freedreno_gmem.c:416)
==8441==    by 0x5B0FBA7: batch_flush (freedreno_batch.c:281)
==8441==    by 0x5B0FBA7: fd_batch_flush (freedreno_batch.c:306)
==8441==    by 0x5B11FE7: fd_context_flush (freedreno_context.c:52)
==8441==    by 0x58AD783: st_glFlush (st_cb_flush.c:121)
==8441==    by 0x5751EE7: _mesa_make_current (context.c:1652)
==8441==    by 0x58E6A97: st_api_make_current (st_manager.c:811)
==8441==    by 0x5A2CE43: dri_unbind_context (dri_context.c:207)
==8441==    by 0x5A2C77F: driUnbindContext (dri_util.c:589)

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2017-03-21 10:03:55 -04:00
Rob Clark 23d10b8244 freedreno: 64bit support
a5xx and later are 64bit devices.. make reloc's handle that.  A new
public symbol is introduced to avoid silent problems with new mesa and
old libdrm (since on 64b reloc consumes two dwords).

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-11-26 12:51:38 -05:00
Rob Clark e9eb44b45b freedreno: add fence fd support
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-11-05 10:18:44 -04:00
Rob Clark 9270d984cd freedreno: sync uapi header
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-11-05 10:17:54 -04:00
Rob Clark feb1b39be1 freedreno: fix warnings
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Tested-by: Rob Herring <robh@kernel.org>
2016-07-21 14:11:05 -04:00
Rob Clark 6a23bd4b3c freedreno/msm: use hashtable to track bo idx
Note: cache the last ring the bo was emitted on, to avoid excess
hashtable lookups.  We do this by tracking ring seqno to avoid
problems with dangling pointers.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark 419a154dbe freedreno: support growable cmdstream buffers
The issue that userspace needed to solve is that there is ~two orders of
magnitude size difference in cmdstream buffers (both for gmem commands
and for draw commands), and that the previous practice of allocating
worst-case sizes is quite wasteful.  Previously a submit would be
constructed (for example) like:

  CMD  TARGET  DESCRIPTION
   g0    N     gmem/tiling commands
   b0    Y     binning commands
   d0    Y     draw commands

Which, after the one non-IB-target cmd buffer is inserted into the
kernel controlled ringbuffer, looks like (not to scale):

         b0:           d0:
        +-----+       +-----+
   IB1  | ... |       | ... |
        +-----+       +-----+
         ^             ^
         |             |
         +-----+       +-+---------+
         g0:   |         |         |
        +----+----+----+----+----+----+----
   IB0  | .. | IB | .. | IB | .. | IB | ...
        +----+----+----+----+----+----+----
         ^              tile0     tile1
         |
         +-----------+
  userspace          |
  ~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  kernel             |
               ----+----+----
   ringbuffer  ... | IB | ...
               ----+----+----

Now, multiple physical cmdstream buffers per fd_ringbuffer are supported,
so this becomes:

  CMD  TARGET  DESCRIPTION
   g0    N
   ...   N     gmem/tiling commands
   gN    N
   b0    Y
   ...   Y     binning commands
   bN    Y
   d0    Y
   ...   Y     draw commands
   dN    Y

Which, after the non-IB-target cmd buffers (g0..gN) are inserted into
the kernel controlled ringbuffer, looks like:

             b0:      b1            d0:      d1
            +-----+  +-----+        +-----+  +-----+
       IB1  | ... |  | ... | ...    | ... |  | ... | ...
            +-----+  +-----+        +-----+  +-----+
             ^        ^              ^        ^
             |        |              |        |
             |        +-+            |  +-----+------+
             +-----+    |            |  |            |
                   |    |         +--+----------+    |
             g0:   |    |         |     |       |    |
            +----+----+----+----+----+----+---+----+----+----
       IB0  | .. | IB | IB | .. | IB | IB |.. | IB | IB |...
            +----+----+----+----+----+----+---+----+----+----
             ^                   tile0         tile1
             | to b0  to b1
             |   |      |          to|d0    to|d1
             |   |      +----+       |      +-+-----------+
             |   |           |       |      |             |
             |   +------+    |       +-+-------------+    |
             |    g1:   |    |         |    |        |    |
             |   +----+----+----+----+----+----+---+----+----+----
       IB0   |   | .. | IB | IB | .. | IB | IB |.. | IB | IB |...
             |   +----+----+----+----+----+----+---+----+----+----
             |    ^                   tileX         tileY
             |    |
             |    +-----------+
             +-----------+    |
      userspace          |    |
      ~~~~~~~~~~~~~~~~~~~|~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      kernel             |    |
                   ----+----+----+----
       ringbuffer  ... | IB | IB | ...
                   ----+----+----+----

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark d93d697deb freedreno/msm: split out dump_submit() helper
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark dd1f372001 freedreno/msm: split out cmd buffer tracking from ring
First step towards supporting a single logical ringbuffer mapping to
multiple physical cmd buffers, which will enable dynamically growing
ringbuffers.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark 0d61529130 freedreno/msm: drop return from get_cmd()
Not actually needed.  It just needs to ensure that there is a
corresponding entry in the submit's cmds table.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark 892141a321 freedreno/msm: use private bo-cache for ringbuffer bo's
Since they get vmap'd on the kernel side, they are a bit more costly.
Don't let them mingle with the riffraff.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark 19b82b9817 freedreno: fix potential leak at free
If user has emit'd reloc's, and then resets or deletes the ring, we want
to drop the ref's that the ring holds to the bo's to avoid a leak.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark 904f1361ae freedreno: expose kernel driver version
gallium needs to know if the kernel is new enough to support explicit
fencing, dynamically grown ringbuffers, etc.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark eb846d46bc freedreno: add madvise support
With a new enough drm/msm, we can let the kernel know about buffers that
are in the bo cache, so the kernel can free them under memory pressure.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark 0c270df8df freedreno: sync uapi
(from drm-next for 4.8)

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark 73db0a0421 freedreno: rework internal ring->emit_reloc_ring()
No need for it to deal with ringmarkers.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-07-20 19:42:21 -04:00
Rob Clark 09bfd5c716 freedreno/msm: fix memory leak on ringbuffer free
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-06-13 09:49:54 -04:00
Rob Clark 49041c3613 freedreno: add support for FD_TIMESTAMP
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-03-13 12:27:30 -04:00
Rob Clark 67e7103cdb freedreno: update uapi
In drm-next.. needed for timestamp queries in mesa.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-03-13 12:27:06 -04:00
Rob Clark 9b77443f63 freedreno: add support for FD_MAX_FREQ
Only msm backend supports this.  Sorry, if you are using kgsl, no
time-elapsed query for you.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-02-12 18:32:22 -05:00
Rob Clark bc5497d061 freedreno: small refactor for get_param
Will simplify next commit.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-02-12 18:32:22 -05:00
Rob Clark c47385ccda freedreno: update uapi
In drm-next.. needed for time-elapsed (and future perf ctrs) in mesa.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2016-02-12 18:32:22 -05:00
Rob Clark 14968e4cf6 freedreno: debug msg cleanup
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2015-09-19 12:12:27 -04:00
Rob Clark 76a1e97eae freedreno: drop exported dmabuf fd tracking
There is really no reason to keep around the fd, it just consumes an
extra file handle.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2015-09-19 12:12:04 -04:00
Emil Velikov 6a6d668fad freedreno: annotate the device/bo/pipe/ringbuffer funcs as const data
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-09-04 21:39:06 +01:00