freedreno/drm: Consider allocation flags in bo-cache
It hasn't really mattered until now, as we keep a separate cache for cmdstream (which is FD_BO_GPU_READONLY), and the only other flag so far is FD_BO_SCANOUT (which the bo cache probably messes up, but it does not matter on most hw, and on hw where it does the scanout buffer will be imported (and therefore won't end up in the bo cache). But when we add cached-coherent (or if we wanted to use GPU_READONLY more) it starts to matter. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11176>
This commit is contained in:
@@ -106,6 +106,7 @@ bo_new(struct fd_device *dev, uint32_t size, uint32_t flags,
|
||||
bo = bo_from_handle(dev, size, handle);
|
||||
simple_mtx_unlock(&table_lock);
|
||||
|
||||
bo->alloc_flags = flags;
|
||||
bo->max_fences = 1;
|
||||
bo->fences = &bo->_inline_fence;
|
||||
|
||||
|
||||
@@ -135,13 +135,13 @@ find_in_bucket(struct fd_bo_bucket *bucket, uint32_t flags)
|
||||
* (MRU, since likely to be in GPU cache), rather than head (LRU)..
|
||||
*/
|
||||
simple_mtx_lock(&table_lock);
|
||||
if (!list_is_empty(&bucket->list)) {
|
||||
bo = LIST_ENTRY(struct fd_bo, bucket->list.next, list);
|
||||
/* TODO check for compatible flags? */
|
||||
if (fd_bo_state(bo) == FD_BO_STATE_IDLE) {
|
||||
list_for_each_entry (struct fd_bo, entry, &bucket->list, list) {
|
||||
if (fd_bo_state(entry) != FD_BO_STATE_IDLE)
|
||||
break;
|
||||
if (entry->alloc_flags == flags) {
|
||||
bo = entry;
|
||||
list_del(&bo->list);
|
||||
} else {
|
||||
bo = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
simple_mtx_unlock(&table_lock);
|
||||
|
||||
@@ -285,6 +285,7 @@ struct fd_bo {
|
||||
uint32_t name;
|
||||
int32_t refcnt;
|
||||
uint32_t reloc_flags; /* flags like FD_RELOC_DUMP to use for relocs to this BO */
|
||||
uint32_t alloc_flags; /* flags that control allocation/mapping, ie. FD_BO_x */
|
||||
uint64_t iova;
|
||||
void *map;
|
||||
const struct fd_bo_funcs *funcs;
|
||||
|
||||
Reference in New Issue
Block a user