Commit Graph

155 Commits (5a3bdc7add2f30f7673052376514c91dbcd1b64a)

Author SHA1 Message Date
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 b730f5c8c5 freedreno/kgsl: fix build
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-14 11:23:03 -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 09cbccff55 freedreno: remove deprecated ringmarker API
It's usage in mesa was removed more than two years ago.  And it stands
in the way of some optimizations needed to reduce the overhead of hw
stateobjs (ie. CP_SET_DRAW_STATE, where the # of cmds in the submit
ioctl goes up significantly).

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:22:20 -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 bf001648a9 freedreno: add flags param for rb creation
For now, we want a way for gallium to be able to provide hints for the
upcoming rb suballocation.  But could be useful for other things down
the road.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-10-13 17:20:43 -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
Emil Velikov 99c3540dd4 *-symbols-check: error out when using unset variables
It will make bugs like the one fixed with previous patch dead obvious.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2018-10-04 14:39:27 +01:00
Emil Velikov 660643e498 automake: set NM before running the tests
Set/export the NM variable since it may not be set already.

Fixes: 4f08bfe96d ("*-symbol-check: Don't hard-code nm executable")
Cc: Heiko Becker <heirecka@exherbo.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2018-10-04 14:39:06 +01:00
Eric Engestrom 4ec31fc31a freedreno: add missing drm_public
Fixes: 9a1470fb41 "freedreno: annotate public functions"
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
2018-09-20 19:28:56 +01:00
Lucas De Marchi 1e3fcc495b autotools: make symbols hidden by default
Now that symbols that should be exported are annotated accordingly, make
all the rest hidden by default.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Eric Engestrom <eric.engestrom@intel.com>
2018-09-19 22:46:45 -07:00
Lucas De Marchi ba808253bc meson: make symbols hidden by default
Now that symbols that should be exported are annotated accordingly, make
all the rest hidden by default.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2018-09-19 22:46:45 -07:00
Lucas De Marchi 9a1470fb41 freedreno: annotate public functions
while read sym; do
	read f func line _ <<<$(cscope -d -L -1 $sym)
	if [ ! -z "$f" ]; then
		sed -i "${line}s/^/drm_public /" $f
	fi
done < /tmp/a.txt

In which /tmp/a.txt contains the public symbols from
freedreno-symbol-check. The idea here will be to switch the default
visibility to hidden so we don't export symbols we shouldn't.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Eric Engestrom <eric.engestrom@intel.com>
2018-09-19 22:46:45 -07: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
Rob Clark 3b64b54e32 freedreno: fix spelling typo
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
Rob Clark 22b3efbe9b freedreno: add user ptr to fd_ringbuffer
Something for users of fd_ringbuffer to use as they see fit.  (For now,
just so mesa can add some debugging state.)

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-06-18 13:07:17 -04:00
Rob Clark c5a6568184 freedreno: add fd_pipe refcounting
In mesa/gallium, a pipe_fence can outlive the pipe_context it was
created from.  But to wait on the fence we need to know the submit-
queue (ie. the fd_pipe).

The most straightforward way to fix this is to add reference counting
to the fd_pipe and let the fence hold a reference to the pipe (rather
than hanging on to the context, which might have been destroyed before
the fence).

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2018-05-09 07:40:29 -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
Eric Engestrom 5236de6cc1 meson: use pkg-config to detect libatomic_ops
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-03-09 17:12:02 +00:00
Eric Engestrom 28370370af freedreno: add missing symbols to symbol-check
Fixes: 1384c08123 "freedreno: add interface to get buffer address"
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2018-03-08 17:54:07 +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
Heiko Becker 4f08bfe96d *-symbol-check: Don't hard-code nm executable
Helpful if your nm executable has a prefix based on the
architecture, for example.

Signed-off-by: Heiko Becker <heirecka@exherbo.org>
Cc: Timo Gurr <timo.gurr@gmail.com>
[Eric: v2: rebase and add Meson support]
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-02-23 17:53:08 +00:00
Eric Engestrom 1d7bbf8520 always define HAVE_VALGRIND
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
2018-01-29 15:41:52 +00:00
Eric Engestrom ec53f4808c always define HAVE_FREEDRENO_KGSL
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
2018-01-29 15:41:52 +00: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
Dylan Baker 7e28d73af0 meson: set proper pkg-config version for libdrm_freedreno
Copy and paste error from exynos.

Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2018-01-25 10:29:31 -08:00
Dylan Baker 5f7deb5078 Add meson build system
This patch adds a complete meson build system, including tests and
install. It has the necessary hooks to allow it be used as a subproject
for other meson based builds such as mesa.

Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Reviewed-and-tested-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2018-01-12 09:40:48 -08:00
Emil Velikov cfe0ae5355 freedreno: add the API fd_pipe_new2 to the symbol test
As kindly spotted by `make check'

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2017-11-07 11:21:32 +00: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 76418c244d freedreno/kgsl: fix pointer-to-int cast
Fixes this warning:

freedreno/kgsl/kgsl_ringbuffer.c: In function ‘kgsl_ringbuffer_flush’:
freedreno/kgsl/kgsl_ringbuffer.c:149:19: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   req.timestamp = (uint32_t)kgsl_ring->bo->hostptr;
                   ^

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
2017-09-15 17:06:29 +01:00
Eric Engestrom ceb70a6b10 freedreno: prevent deadlock in error path
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Rob Clark <robdclark@gmail.com>
2017-08-07 14:16:41 +01: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
Eric Engestrom ac2b806c45 freedreno: remove dead error path
`pipe` cannot be non-null, so the label reduces to a simple return.
Then, there is no point initialising `pipe` 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 f45853802e freedreno: fix double-free on exit
Fixes: a07ae97 ("freedreno: fix device close issues")
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2017-04-15 14:43:17 -04:00
Rob Clark a07ae97c75 freedreno: fix device close issues
Move closing the fd to after subclass ->destroy() (since it might want
to delete gem bo's, etc), and actually free() the fd_device object.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2017-03-23 15:22:30 -04: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