summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_bufmgr.c
Commit message (Collapse)AuthorAgeFilesLines
* broadcom/vc4: Mark BOs as purgeable when they enter the BO cacheBoris Brezillon2017-11-091-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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* broadcom/vc4: Skip BO labeling when in simulator mode.Eric Anholt2017-10-171-1/+1
| | | | | It was calling down into i915 trying to label the BO, which is definitely not the right thing.
* broadcom/vc4: Fix release buildEric Anholt2017-09-271-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 <[email protected]>
* vc4: Add labels to BOs for debug builds or with VC4_DEBUG=surf set.Eric Anholt2017-09-271-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.
* broadcom/vc4: Fix infinite retry in vc4_bo_alloc()Boris Brezillon2017-09-261-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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Fixes: 78087676c98aa8884ba92 "vc4: Restructure the simulator mode."
* gallium/util: replace pipe_mutex_unlock() with mtx_unlock()Timothy Arceri2017-03-071-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 <[email protected]>
* gallium/util: replace pipe_mutex_lock() with mtx_lock()Timothy Arceri2017-03-071-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 <[email protected]>
* vc4: Reuse a list function to simplify bufmgr code.Eric Anholt2017-01-051-11/+2
|
* vc4: Move simulator winsys mapping and tracking to the simulator.Eric Anholt2016-10-211-9/+5
| | | | | One tiny hack is left in vc4_bufmgr.c for what kind of mapping we got so that we can free it.
* vc4: Move simulator memory management to a u_mm.h heap.Eric Anholt2016-10-211-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.
* vc4: Restructure the simulator mode.Eric Anholt2016-10-211-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.
* vc4: Tell valgrind about BO allocations from mmap time to destroy.Eric Anholt2016-08-031-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.
* vc4: add hash table look-up for exported dmabufsRob Herring2016-07-261-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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* vc4: Return GL_OUT_OF_MEMORY when buffer allocation fails.Eric Anholt2015-11-091-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" <[email protected]>
* vc4: When the create ioctl fails, free our cache and try again.Eric Anholt2015-11-041-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" <[email protected]>
* vc4: Print the rounded shader size in debug output.Eric Anholt2015-11-041-1/+1
| | | | | It's surprising to see "0kb" printed for debug on short shaders, while 4kb alignment won't be suprising.
* vc4: Fix dumping the size of BOs allocated/cached.Eric Anholt2015-11-041-2/+2
| | | | 60MB of cached BOs are a lot less scary than 600MB.
* vc4: Switch to using a separate ioctl for making shaders.Eric Anholt2015-07-171-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.
* vc4: Add perf debug for when we wait on BOs.Eric Anholt2015-07-141-39/+67
|
* vc4: Fix memory leak from simple_list conversion.Eric Anholt2015-06-171-3/+2
| | | | | I accidentally shadowed the outside declaration, so we always returned NULL even when we'd found something in the cache.
* vc4: Track the number of BOs allocated and their size.Eric Anholt2015-06-171-7/+94
| | | | This is useful for BO leak debugging.
* vc4: Convert from simple_list.h to list.hEric Anholt2015-05-291-29/+24
| | | | list.h is a nicer and more familiar set of list functions/macros.
* vc4: Make sure we allocate idle BOs from the cache.Eric Anholt2015-05-291-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.
* vc4: Fix return value handling for BO waits.Eric Anholt2015-05-291-12/+15
| | | | | If the wait ever returned -ETIME, we'd abort because the errno was stored in errno and not drmIoctl()'s return value.
* vc4: Don't try to put our dmabuf-exported BOs into the BO cache.Eric Anholt2015-05-271-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.
* vc4: Use our device-specific ioctls for create/mmap.Eric Anholt2015-03-241-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.
* vc4: Make a new #define for making code conditional on the simulator.Eric Anholt2015-03-241-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.
* vc4: Move global seqno short-circuiting to vc4_wait_seqno().Eric Anholt2015-01-101-0/+3
| | | | Any other caller would want it, too.
* vc4: Add a userspace BO cache.Eric Anholt2014-12-171-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%.
* vc4: Add dmabuf support.Eric Anholt2014-12-171-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.
* vc4: Update for new kernel ABI with async execution and waits.Eric Anholt2014-11-201-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).
* vc4: Switch from errx() to fprintf() and abort().Eric Anholt2014-09-251-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.
* vc4: Clear padding of ioctl arguments.Eric Anholt2014-08-231-0/+1
| | | | Fixes valgrind complaints from valgrind being unaware of our ioctls.
* vc4: Include stdio/stdlib in headers so I don't have to include it per file.Eric Anholt2014-08-221-1/+0
| | | | | There are a few tools I want to have always available, and fprintf() and abort() are among them.
* vc4: Stash some debug code for looking at what BOs are at what hindex.Eric Anholt2014-08-111-0/+1
| | | | When you're debugging validation, it's nice to know what the BOs are for.
* vc4: Use GEM under simulation even for non-winsys BOs.Eric Anholt2014-08-111-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.
* vc4: Don't forget to unmap the GEM BO when freeing.Eric Anholt2014-08-111-0/+3
| | | | Otherwise it'll stick around forever.
* vc4: Switch simulator to using kernel validatorEric Anholt2014-08-111-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.
* vc4: Initial skeleton driver import.Eric Anholt2014-08-081-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)