diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-05-25 19:48:30 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-07-13 14:42:33 +0000 |
commit | 169dbb5b08a1c5367dd7a1714cd547a7f3ecac3d (patch) | |
tree | baa2c7c9c8598cca81ef43c1e65e8f2ba659c687 /src/panfrost | |
parent | 37d89e0f93601e520edcdc41dc68197dff736c1e (diff) |
panfrost: Add a sparse array to map GEM handles to BOs
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Boris Brezillon <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5859>
Diffstat (limited to 'src/panfrost')
-rw-r--r-- | src/panfrost/encoder/pan_device.h | 11 | ||||
-rw-r--r-- | src/panfrost/encoder/pan_props.c | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/panfrost/encoder/pan_device.h b/src/panfrost/encoder/pan_device.h index 693c156f2e3..d8d1e035cb8 100644 --- a/src/panfrost/encoder/pan_device.h +++ b/src/panfrost/encoder/pan_device.h @@ -2,6 +2,7 @@ * * Copyright 2018-2019 Alyssa Rosenzweig * Copyright 2018-2019 Collabora, Ltd. + * Copyright © 2015 Intel Corporation * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -35,6 +36,7 @@ #include "util/bitset.h" #include "util/set.h" #include "util/list.h" +#include "util/sparse_array.h" #include <panfrost-misc.h> @@ -89,6 +91,9 @@ struct panfrost_device { pthread_mutex_t active_bos_lock; struct set *active_bos; + pthread_mutex_t bo_map_lock; + struct util_sparse_array bo_map; + struct { pthread_mutex_t lock; @@ -113,4 +118,10 @@ panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev); void panfrost_close_device(struct panfrost_device *dev); +static inline struct panfrost_bo * +pan_lookup_bo(struct panfrost_device *dev, uint32_t gem_handle) +{ + return util_sparse_array_get(&dev->bo_map, gem_handle); +} + #endif diff --git a/src/panfrost/encoder/pan_props.c b/src/panfrost/encoder/pan_props.c index d505a111e7e..d0fadc9a55b 100644 --- a/src/panfrost/encoder/pan_props.c +++ b/src/panfrost/encoder/pan_props.c @@ -145,6 +145,8 @@ panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev) dev->active_bos = _mesa_set_create(memctx, panfrost_active_bos_hash, panfrost_active_bos_cmp); + util_sparse_array_init(&dev->bo_map, sizeof(struct panfrost_bo), 512); + pthread_mutex_init(&dev->bo_cache.lock, NULL); list_inithead(&dev->bo_cache.lru); @@ -159,5 +161,6 @@ panfrost_close_device(struct panfrost_device *dev) pthread_mutex_destroy(&dev->bo_cache.lock); pthread_mutex_destroy(&dev->active_bos_lock); drmFreeVersion(dev->kernel_version); + util_sparse_array_finish(&dev->bo_map); } |