diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-15 08:27:57 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-07-15 16:12:56 -0700 |
commit | f3464f798719198df54f0f596b734a3113b5466c (patch) | |
tree | 1aff2ec3931ac92077be49920ca9fd2d693b6a60 | |
parent | f3b7e1ddc77fad6d31f910a6ed9c33db4b13919e (diff) |
panfrost: Describe BO cache architecture
Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_bo_cache.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gallium/drivers/panfrost/pan_bo_cache.c b/src/gallium/drivers/panfrost/pan_bo_cache.c index d0ca99da136..da4a9a21e56 100644 --- a/src/gallium/drivers/panfrost/pan_bo_cache.c +++ b/src/gallium/drivers/panfrost/pan_bo_cache.c @@ -26,6 +26,26 @@ #include "pan_screen.h" +/* This file implements a userspace BO cache. Allocating and freeing + * GPU-visible buffers is very expensive, and even the extra kernel roundtrips + * adds more work than we would like at this point. So caching BOs in userspace + * solves both of these problems and does not require kernel updates. + * + * Cached BOs are sorted into a bucket based on rounding their size down to the + * nearest power-of-two. Each bucket contains a linked list of free panfrost_bo + * objects. Putting a BO into the cache is accomplished by adding it to the + * corresponding bucket. Getting a BO from the cache consists of finding the + * appropriate bucket and sorting. A cache eviction is a kernel-level free of a + * BO and removing it from the bucket. We special case evicting all BOs from + * the cache, since that's what helpful in practice and avoids extra logic + * around the linked list. + */ + +/* Tries to fetch a BO of sufficient size with the appropriate flags from the + * BO cache. If it succeeds, it returns that BO and removes the BO from the + * cache. If it fails, it returns NULL signaling the caller to allocate a new + * BO. */ + struct panfrost_bo * panfrost_bo_cache_fetch( struct panfrost_screen *screen, |