diff options
author | Rob Herring <robh@kernel.org> | 2016-07-22 15:28:30 -0500 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2016-07-26 13:47:50 -0700 |
commit | 9ace2c13550609dfe78164f104500d438821f383 (patch) | |
tree | 1b556d0fe722c7bb2603786ebdd1bf49a0ba8068 /src/gallium/drivers/vc4/vc4_bufmgr.h | |
parent | ce8504d196291452b42ed755ed3830ecb16febcd (diff) | |
download | external_mesa3d-9ace2c13550609dfe78164f104500d438821f383.zip external_mesa3d-9ace2c13550609dfe78164f104500d438821f383.tar.gz external_mesa3d-9ace2c13550609dfe78164f104500d438821f383.tar.bz2 |
vc4: add hash table look-up for exported dmabufs
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>
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_bufmgr.h')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_bufmgr.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.h b/src/gallium/drivers/vc4/vc4_bufmgr.h index b77506e..71a4426 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.h +++ b/src/gallium/drivers/vc4/vc4_bufmgr.h @@ -25,6 +25,7 @@ #define VC4_BUFMGR_H #include <stdint.h> +#include "util/u_hash_table.h" #include "util/u_inlines.h" #include "vc4_qir.h" @@ -87,11 +88,27 @@ vc4_bo_reference(struct vc4_bo *bo) static inline void vc4_bo_unreference(struct vc4_bo **bo) { + struct vc4_screen *screen; if (!*bo) return; - if (pipe_reference(&(*bo)->reference, NULL)) - vc4_bo_last_unreference(*bo); + if ((*bo)->private) { + /* Avoid the mutex for private BOs */ + if (pipe_reference(&(*bo)->reference, NULL)) + vc4_bo_last_unreference(*bo); + } else { + screen = (*bo)->screen; + pipe_mutex_lock(screen->bo_handles_mutex); + + if (pipe_reference(&(*bo)->reference, NULL)) { + util_hash_table_remove(screen->bo_handles, + (void *)(uintptr_t)(*bo)->handle); + vc4_bo_last_unreference(*bo); + } + + pipe_mutex_unlock(screen->bo_handles_mutex); + } + *bo = NULL; } |