summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/vc4/vc4_bufmgr.c
AgeCommit message (Collapse)AuthorFilesLines
2017-11-09broadcom/vc4: Mark BOs as purgeable when they enter the BO cacheBoris Brezillon1-48/+83
This patch makes use of the DRM_IOCTL_VC4_GEM_MADVISE ioctl to mark all BOs placed in the mesa BO cache as purgeable so that the system can reclaim this memory under memory pressure. v2: - Removed BOs from the cache when they've been purged by the kernel - Check whether the madvise ioctl is supported or not before using it v3: Don't walk the whole list when we find a busy BO (by anholt, acked by Boris) Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2017-10-17broadcom/vc4: Skip BO labeling when in simulator mode.Eric Anholt1-1/+1
It was calling down into i915 trying to label the BO, which is definitely not the right thing.
2017-09-27broadcom/vc4: Fix release buildEric Anholt1-1/+1
I remember thinking "gosh, it would be nice if I could do a kernel-style 'if (!IS_ENABLED(DEBUG))' instead of using an #ifdef, so the code was compiled on both builds", and then forgot to test a release build anyway. Fixes: a8fd58eae596 ("vc4: Add labels to BOs for debug builds or with VC4_DEBUG=surf set.") Reported-by: Derek Foreman <derekf@osg.samsung.com>
2017-09-27vc4: Add labels to BOs for debug builds or with VC4_DEBUG=surf set.Eric Anholt1-0/+30
This has proven to be incredibly useful for debugging CMA allocation failures and driving memory management improvements. However, we don't want to burden entry and exit from the BO cache with the labeling ioctl's overhead on release builds.
2017-09-26broadcom/vc4: Fix infinite retry in vc4_bo_alloc()Boris Brezillon1-6/+4
cleared_and_retried is always reset to false when jumping to the retry label, thus leading to an infinite retry loop. Fix that by moving the cleared_and_retried variable definitions at the beginning of the function. While we're at it, move the create variable with the other local variables and explicitly reset its content in the retry path. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Fixes: 78087676c98aa8884ba92 "vc4: Restructure the simulator mode."
2017-03-07gallium/util: replace pipe_mutex_unlock() with mtx_unlock()Timothy Arceri1-6/+6
pipe_mutex_unlock() was made unnecessary with fd33a6bcd7f12. Replaced using: find ./src -type f -exec sed -i -- \ 's:pipe_mutex_unlock(\([^)]*\)):mtx_unlock(\&\1):g' {} \; Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07gallium/util: replace pipe_mutex_lock() with mtx_lock()Timothy Arceri1-5/+5
replace pipe_mutex_lock() was made unnecessary with fd33a6bcd7f12. Replaced using: find ./src -type f -exec sed -i -- \ 's:pipe_mutex_lock(\([^)]*\)):mtx_lock(\&\1):g' {} \; Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-01-05vc4: Reuse a list function to simplify bufmgr code.Eric Anholt1-11/+2
2016-10-21vc4: Move simulator winsys mapping and tracking to the simulator.Eric Anholt1-9/+5
One tiny hack is left in vc4_bufmgr.c for what kind of mapping we got so that we can free it.
2016-10-21vc4: Move simulator memory management to a u_mm.h heap.Eric Anholt1-0/+2
Now we aren't limited to 256MB total allocated across a driver instance, just 256MB at one time. We're still copying in and out, which should get fixed.
2016-10-21vc4: Restructure the simulator mode.Eric Anholt1-69/+29
Rather than having simulator mode changes scattered around vc4_bufmgr.c and vc4_screen.c, make vc4_bufmgr.c just call a vc4_simulator_ioctl, which then dispatches to a corresponding implementation. This will give the simulator support a centralized place to do tricks like storing most BOs directly in simulator memory rather than copying in and out. This leaves special casing of mmaping BOs and execution, because of the winsys mapping.
2016-08-03vc4: Tell valgrind about BO allocations from mmap time to destroy.Eric Anholt1-0/+10
This helps in debugging memory pressure. It would be nice if we could tell valgrind about it all the way from allocation time to destroy, but we need a pointer to hand to VALGRIND_MALLOCLIKE_BLOCK.
2016-07-26vc4: add hash table look-up for exported dmabufsRob Herring1-1/+19
It is necessary to reuse existing BOs when dmabufs are imported. There are 2 cases that need to be handled. dmabufs can be created/exported and imported by the same process and can be imported multiple times. Copying other drivers, add a hash table to track exported BOs so the BOs get reused. v2: Whitespace fixup (by anholt) Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2015-11-09vc4: Return GL_OUT_OF_MEMORY when buffer allocation fails.Eric Anholt1-2/+3
I was afraid our callers weren't prepared for this, but it looks like at least for resource creation, mesa/st throws an error appropriately. Cc: "11.0" <mesa-stable@lists.freedesktop.org>
2015-11-04vc4: When the create ioctl fails, free our cache and try again.Eric Anholt1-5/+24
This greatly increases the pressure you can put on the driver before create fails. Ultimately we need to let the kernel take control of our cached BOs and just take them from us (and other clients) directly, but this is a very easy patch for the moment. Cc: "11.0" <mesa-stable@lists.freedesktop.org>
2015-11-04vc4: Print the rounded shader size in debug output.Eric Anholt1-1/+1
It's surprising to see "0kb" printed for debug on short shaders, while 4kb alignment won't be suprising.
2015-11-04vc4: Fix dumping the size of BOs allocated/cached.Eric Anholt1-2/+2
60MB of cached BOs are a lot less scary than 600MB.
2015-07-17vc4: Switch to using a separate ioctl for making shaders.Eric Anholt1-7/+49
This gives the kernel a chance to validate and lock down the data, without having to deal with mmap zapping. With this, GLBenchmark stops on a texture relocations, because we'd recycled a shader BO as another shader and failed to revalidate, since we weren't clearing the cached validation state on mmap faults.
2015-07-14vc4: Add perf debug for when we wait on BOs.Eric Anholt1-39/+67
2015-06-17vc4: Fix memory leak from simple_list conversion.Eric Anholt1-3/+2
I accidentally shadowed the outside declaration, so we always returned NULL even when we'd found something in the cache.
2015-06-17vc4: Track the number of BOs allocated and their size.Eric Anholt1-7/+94
This is useful for BO leak debugging.
2015-05-29vc4: Convert from simple_list.h to list.hEric Anholt1-29/+24
list.h is a nicer and more familiar set of list functions/macros.
2015-05-29vc4: Make sure we allocate idle BOs from the cache.Eric Anholt1-1/+11
We were returning the most recently freed BO, without checking if it was idle yet. This meant that we generally stalled immediately on the previous frame when generating a new one. Instead, allocate new BOs when the *oldest* BO is still busy, so that the cache scales with how much is needed to keep some frames outstanding, as originally intended. Note that if you don't have some throttling happening, this means that you can accidentally run the system out of memory. The kernel is now applying some throttling on all execs, to hopefully avoid this.
2015-05-29vc4: Fix return value handling for BO waits.Eric Anholt1-12/+15
If the wait ever returned -ETIME, we'd abort because the errno was stored in errno and not drmIoctl()'s return value.
2015-05-27vc4: Don't try to put our dmabuf-exported BOs into the BO cache.Eric Anholt1-0/+1
We'd sometimes try to reallocate something that X was using as a new pipe_resource, and potentially conflict in our rendering. But even worse, if we reallocated the BO as a shader, the kernel would reject rendering using the shader.
2015-03-24vc4: Use our device-specific ioctls for create/mmap.Eric Anholt1-15/+36
They don't do anything special for us, but I've been told by kernel maintainers that relying on dumb for my acceleration-capable buffers is not OK.
2015-03-24vc4: Make a new #define for making code conditional on the simulator.Eric Anholt1-10/+14
I'd like to compile as much of the device-specific code as possible when building for simulator, and using if (using_simulator) instead of ifdefs helps.
2015-01-10vc4: Move global seqno short-circuiting to vc4_wait_seqno().Eric Anholt1-0/+3
Any other caller would want it, too.
2014-12-17vc4: Add a userspace BO cache.Eric Anholt1-1/+130
Since our kernel BOs require CMA allocation, and the use of them requires new mmaps, it's pretty expensive and we should avoid it if possible. Copying my original design for Intel, make a userspace cache that reuses BOs that haven't been shared to other processes but frees BOs that have sat in the cache for over a second. Improves glxgears framerate on RPi by around 30%.
2014-12-17vc4: Add dmabuf support.Eric Anholt1-14/+61
This gets DRI3 working on modesetting with glamor. It's not enabled under simulation, because it looks like handing our dumb-allocated buffers off to the server doesn't actually work for the server's rendering.
2014-11-20vc4: Update for new kernel ABI with async execution and waits.Eric Anholt1-1/+64
Our submits now return immediately and you have to manually wait for things to complete if you want to (like a normal driver).
2014-09-25vc4: Switch from errx() to fprintf() and abort().Eric Anholt1-6/+11
These are pretty catastrophic, "should never happen" failure paths (though 4 tests in piglit hit them currently, due to a single bug). An abort() that you can gdb on easily is probably more useful than a clean exit, particularly since a bug in piglit framework right now is causing early exit(1)s to simply not be recorded in the results at all.
2014-08-23vc4: Clear padding of ioctl arguments.Eric Anholt1-0/+1
Fixes valgrind complaints from valgrind being unaware of our ioctls.
2014-08-22vc4: Include stdio/stdlib in headers so I don't have to include it per file.Eric Anholt1-1/+0
There are a few tools I want to have always available, and fprintf() and abort() are among them.
2014-08-11vc4: Stash some debug code for looking at what BOs are at what hindex.Eric Anholt1-0/+1
When you're debugging validation, it's nice to know what the BOs are for.
2014-08-11vc4: Use GEM under simulation even for non-winsys BOs.Eric Anholt1-14/+8
In addition to reducing sim-specific code, it also avoids our local handle allocation conflicting with the host GEM's handle numbering, which was causing vc4_gem_hindex() to not distinguish between winsys BOs and the same-numbered non-winsys bo.
2014-08-11vc4: Don't forget to unmap the GEM BO when freeing.Eric Anholt1-0/+3
Otherwise it'll stick around forever.
2014-08-11vc4: Switch simulator to using kernel validatorEric Anholt1-2/+7
This ensures that when I'm using the simulator, I get a closer match to what behavior on real hardware will be. It lets me rapidly iterate on the kernel validation code (which otherwise has a several-minute turnaround time), and helps catch buffer overflow bugs in the userspace driver faster.
2014-08-08vc4: Initial skeleton driver import.Eric Anholt1-0/+173
This mostly just takes every draw call and turns it into a sequence of commands that clear the FBO and draw a single shaded triangle to it, regardless of the actual input vertices or shaders. I copied the initial driver skeleton mostly from freedreno, and I've preserved Rob Clark's copyright for those. I also based my initial hardcoded shaders and command lists on Scott Mansell (phire)'s "hackdriver" project, though the bit patterns of the shaders emitted end up being different. v2: Rebase on gallium megadrivers changes. v3: Rebase on PIPE_SHADER_CAP_MAX_CONSTS change. v4: Rely on simpenrose actually being installed when building for simulation. v5: Add more header duplicate-include guards. v6: Apply Emil's review (protection against vc4 sim and ilo at the same time, and dropping the dricommon drm bits) and fix a copyright header (thanks, Roland)