projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
etnaviv: drm: s/table_lock/etna_table_lock/
[mesa.git]
/
src
/
etnaviv
/
drm
/
etnaviv_bo.c
diff --git
a/src/etnaviv/drm/etnaviv_bo.c
b/src/etnaviv/drm/etnaviv_bo.c
index 43ce6b4e3c9fd6a8aad68a85081d5b4f6cce3c95..6d6339aff49e24bb36bb7e2b4776304121cc85a5 100644
(file)
--- a/
src/etnaviv/drm/etnaviv_bo.c
+++ b/
src/etnaviv/drm/etnaviv_bo.c
@@
-24,49
+24,53
@@
* Christian Gmeiner <christian.gmeiner@gmail.com>
*/
* Christian Gmeiner <christian.gmeiner@gmail.com>
*/
+#include "os/os_mman.h"
+#include "util/hash_table.h"
+
#include "etnaviv_priv.h"
#include "etnaviv_drmif.h"
#include "etnaviv_priv.h"
#include "etnaviv_drmif.h"
-
drm_private pthread_mutex_t
table_lock = PTHREAD_MUTEX_INITIALIZER;
-
drm_private
void bo_del(struct etna_bo *bo);
+
pthread_mutex_t etna_drm_
table_lock = PTHREAD_MUTEX_INITIALIZER;
+void bo_del(struct etna_bo *bo);
-/* set buffer name, and add to table, call w/ table_lock held: */
+/* set buffer name, and add to table, call w/
etna_drm_
table_lock held: */
static void set_name(struct etna_bo *bo, uint32_t name)
{
bo->name = name;
/* add ourself into the name table: */
static void set_name(struct etna_bo *bo, uint32_t name)
{
bo->name = name;
/* add ourself into the name table: */
-
drmHashInsert(bo->dev->name_table,
name, bo);
+
_mesa_hash_table_insert(bo->dev->name_table, &bo->
name, bo);
}
}
-/* Called under table_lock */
-
drm_private
void bo_del(struct etna_bo *bo)
+/* Called under
etna_drm_
table_lock */
+void bo_del(struct etna_bo *bo)
{
if (bo->map)
{
if (bo->map)
-
drm
_munmap(bo->map, bo->size);
+
os
_munmap(bo->map, bo->size);
if (bo->name)
if (bo->name)
-
drmHashDelete(bo->dev->name_table,
bo->name);
+
_mesa_hash_table_remove_key(bo->dev->name_table, &
bo->name);
if (bo->handle) {
struct drm_gem_close req = {
.handle = bo->handle,
};
if (bo->handle) {
struct drm_gem_close req = {
.handle = bo->handle,
};
-
drmHashDelete(bo->dev->handle_table,
bo->handle);
+
_mesa_hash_table_remove_key(bo->dev->handle_table, &
bo->handle);
drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req);
}
free(bo);
}
drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req);
}
free(bo);
}
-/* lookup a buffer from it's handle, call w/ table_lock held: */
+/* lookup a buffer from it's handle, call w/
etna_drm_
table_lock held: */
static struct etna_bo *lookup_bo(void *tbl, uint32_t handle)
{
struct etna_bo *bo = NULL;
static struct etna_bo *lookup_bo(void *tbl, uint32_t handle)
{
struct etna_bo *bo = NULL;
+ struct hash_entry *entry = _mesa_hash_table_search(tbl, &handle);
- if (
!drmHashLookup(tbl, handle, (void **)&bo)
) {
+ if (
entry
) {
/* found, incr refcnt and return: */
/* found, incr refcnt and return: */
- bo = etna_bo_ref(
bo
);
+ bo = etna_bo_ref(
entry->data
);
/* don't break the bucket if this bo was found in one */
list_delinit(&bo->list);
/* don't break the bucket if this bo was found in one */
list_delinit(&bo->list);
@@
-75,7
+79,7
@@
static struct etna_bo *lookup_bo(void *tbl, uint32_t handle)
return bo;
}
return bo;
}
-/* allocate a new buffer object, call w/ table_lock held */
+/* allocate a new buffer object, call w/
etna_drm_
table_lock held */
static struct etna_bo *bo_from_handle(struct etna_device *dev,
uint32_t size, uint32_t handle, uint32_t flags)
{
static struct etna_bo *bo_from_handle(struct etna_device *dev,
uint32_t size, uint32_t handle, uint32_t flags)
{
@@
-95,16
+99,16
@@
static struct etna_bo *bo_from_handle(struct etna_device *dev,
bo->size = size;
bo->handle = handle;
bo->flags = flags;
bo->size = size;
bo->handle = handle;
bo->flags = flags;
- atomic_set(&bo->refcnt, 1);
+
p_
atomic_set(&bo->refcnt, 1);
list_inithead(&bo->list);
/* add ourselves to the handle table: */
list_inithead(&bo->list);
/* add ourselves to the handle table: */
-
drmHashInsert(dev->handle_table,
handle, bo);
+
_mesa_hash_table_insert(dev->handle_table, &bo->
handle, bo);
return bo;
}
/* allocate a new (un-tiled) buffer object */
return bo;
}
/* allocate a new (un-tiled) buffer object */
-
drm_public
struct etna_bo *etna_bo_new(struct etna_device *dev, uint32_t size,
+struct etna_bo *etna_bo_new(struct etna_device *dev, uint32_t size,
uint32_t flags)
{
struct etna_bo *bo;
uint32_t flags)
{
struct etna_bo *bo;
@@
-123,17
+127,17
@@
drm_public struct etna_bo *etna_bo_new(struct etna_device *dev, uint32_t size,
if (ret)
return NULL;
if (ret)
return NULL;
- pthread_mutex_lock(&table_lock);
+ pthread_mutex_lock(&
etna_drm_
table_lock);
bo = bo_from_handle(dev, size, req.handle, flags);
bo->reuse = 1;
bo = bo_from_handle(dev, size, req.handle, flags);
bo->reuse = 1;
- pthread_mutex_unlock(&table_lock);
+ pthread_mutex_unlock(&
etna_drm_
table_lock);
return bo;
}
return bo;
}
-
drm_public
struct etna_bo *etna_bo_ref(struct etna_bo *bo)
+struct etna_bo *etna_bo_ref(struct etna_bo *bo)
{
{
- atomic_inc(&bo->refcnt);
+
p_
atomic_inc(&bo->refcnt);
return bo;
}
return bo;
}
@@
-159,7
+163,7
@@
static int get_buffer_info(struct etna_bo *bo)
}
/* import a buffer object from DRI2 name */
}
/* import a buffer object from DRI2 name */
-
drm_public
struct etna_bo *etna_bo_from_name(struct etna_device *dev,
+struct etna_bo *etna_bo_from_name(struct etna_device *dev,
uint32_t name)
{
struct etna_bo *bo;
uint32_t name)
{
struct etna_bo *bo;
@@
-167,7
+171,7
@@
drm_public struct etna_bo *etna_bo_from_name(struct etna_device *dev,
.name = name,
};
.name = name,
};
- pthread_mutex_lock(&table_lock);
+ pthread_mutex_lock(&
etna_drm_
table_lock);
/* check name table first, to see if bo is already open: */
bo = lookup_bo(dev->name_table, name);
/* check name table first, to see if bo is already open: */
bo = lookup_bo(dev->name_table, name);
@@
-188,7
+192,7
@@
drm_public struct etna_bo *etna_bo_from_name(struct etna_device *dev,
set_name(bo, name);
out_unlock:
set_name(bo, name);
out_unlock:
- pthread_mutex_unlock(&table_lock);
+ pthread_mutex_unlock(&
etna_drm_
table_lock);
return bo;
}
return bo;
}
@@
-197,7
+201,7
@@
out_unlock:
* fd so caller should close() the fd when it is otherwise done
* with it (even if it is still using the 'struct etna_bo *')
*/
* fd so caller should close() the fd when it is otherwise done
* with it (even if it is still using the 'struct etna_bo *')
*/
-
drm_public
struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd)
+struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd)
{
struct etna_bo *bo;
int ret, size;
{
struct etna_bo *bo;
int ret, size;
@@
-207,11
+211,11
@@
drm_public struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd)
* racing against etna_bo_del, which might invalidate the
* returned handle.
*/
* racing against etna_bo_del, which might invalidate the
* returned handle.
*/
- pthread_mutex_lock(&table_lock);
+ pthread_mutex_lock(&
etna_drm_
table_lock);
ret = drmPrimeFDToHandle(dev->fd, fd, &handle);
if (ret) {
ret = drmPrimeFDToHandle(dev->fd, fd, &handle);
if (ret) {
- pthread_mutex_unlock(&table_lock);
+ pthread_mutex_unlock(&
etna_drm_
table_lock);
return NULL;
}
return NULL;
}
@@
-226,23
+230,23
@@
drm_public struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd)
bo = bo_from_handle(dev, size, handle, 0);
out_unlock:
bo = bo_from_handle(dev, size, handle, 0);
out_unlock:
- pthread_mutex_unlock(&table_lock);
+ pthread_mutex_unlock(&
etna_drm_
table_lock);
return bo;
}
/* destroy a buffer object */
return bo;
}
/* destroy a buffer object */
-
drm_public
void etna_bo_del(struct etna_bo *bo)
+void etna_bo_del(struct etna_bo *bo)
{
struct etna_device *dev = bo->dev;
if (!bo)
return;
{
struct etna_device *dev = bo->dev;
if (!bo)
return;
- if (!
atomic_dec_and_test
(&bo->refcnt))
+ if (!
p_atomic_dec_zero
(&bo->refcnt))
return;
return;
- pthread_mutex_lock(&table_lock);
+ pthread_mutex_lock(&
etna_drm_
table_lock);
if (bo->reuse && (etna_bo_cache_free(&dev->bo_cache, bo) == 0))
goto out;
if (bo->reuse && (etna_bo_cache_free(&dev->bo_cache, bo) == 0))
goto out;
@@
-250,11
+254,11
@@
drm_public void etna_bo_del(struct etna_bo *bo)
bo_del(bo);
etna_device_del_locked(dev);
out:
bo_del(bo);
etna_device_del_locked(dev);
out:
- pthread_mutex_unlock(&table_lock);
+ pthread_mutex_unlock(&
etna_drm_
table_lock);
}
/* get the global flink/DRI2 buffer name */
}
/* get the global flink/DRI2 buffer name */
-
drm_public
int etna_bo_get_name(struct etna_bo *bo, uint32_t *name)
+int etna_bo_get_name(struct etna_bo *bo, uint32_t *name)
{
if (!bo->name) {
struct drm_gem_flink req = {
{
if (!bo->name) {
struct drm_gem_flink req = {
@@
-267,9
+271,9
@@
drm_public int etna_bo_get_name(struct etna_bo *bo, uint32_t *name)
return ret;
}
return ret;
}
- pthread_mutex_lock(&table_lock);
+ pthread_mutex_lock(&
etna_drm_
table_lock);
set_name(bo, req.name);
set_name(bo, req.name);
- pthread_mutex_unlock(&table_lock);
+ pthread_mutex_unlock(&
etna_drm_
table_lock);
bo->reuse = 0;
}
bo->reuse = 0;
}
@@
-278,7
+282,7
@@
drm_public int etna_bo_get_name(struct etna_bo *bo, uint32_t *name)
return 0;
}
return 0;
}
-
drm_public
uint32_t etna_bo_handle(struct etna_bo *bo)
+uint32_t etna_bo_handle(struct etna_bo *bo)
{
return bo->handle;
}
{
return bo->handle;
}
@@
-286,7
+290,7
@@
drm_public uint32_t etna_bo_handle(struct etna_bo *bo)
/* caller owns the dmabuf fd that is returned and is responsible
* to close() it when done
*/
/* caller owns the dmabuf fd that is returned and is responsible
* to close() it when done
*/
-
drm_public
int etna_bo_dmabuf(struct etna_bo *bo)
+int etna_bo_dmabuf(struct etna_bo *bo)
{
int ret, prime_fd;
{
int ret, prime_fd;
@@
-302,20
+306,20
@@
drm_public int etna_bo_dmabuf(struct etna_bo *bo)
return prime_fd;
}
return prime_fd;
}
-
drm_public
uint32_t etna_bo_size(struct etna_bo *bo)
+uint32_t etna_bo_size(struct etna_bo *bo)
{
return bo->size;
}
{
return bo->size;
}
-
drm_public
void *etna_bo_map(struct etna_bo *bo)
+void *etna_bo_map(struct etna_bo *bo)
{
if (!bo->map) {
if (!bo->offset) {
get_buffer_info(bo);
}
{
if (!bo->map) {
if (!bo->offset) {
get_buffer_info(bo);
}
- bo->map =
drm
_mmap(0, bo->size, PROT_READ | PROT_WRITE,
- MAP_SHARED, bo->dev->fd, bo->offset);
+ bo->map =
os
_mmap(0, bo->size, PROT_READ | PROT_WRITE,
+
MAP_SHARED, bo->dev->fd, bo->offset);
if (bo->map == MAP_FAILED) {
ERROR_MSG("mmap failed: %s", strerror(errno));
bo->map = NULL;
if (bo->map == MAP_FAILED) {
ERROR_MSG("mmap failed: %s", strerror(errno));
bo->map = NULL;
@@
-325,7
+329,7
@@
drm_public void *etna_bo_map(struct etna_bo *bo)
return bo->map;
}
return bo->map;
}
-
drm_public
int etna_bo_cpu_prep(struct etna_bo *bo, uint32_t op)
+int etna_bo_cpu_prep(struct etna_bo *bo, uint32_t op)
{
struct drm_etnaviv_gem_cpu_prep req = {
.handle = bo->handle,
{
struct drm_etnaviv_gem_cpu_prep req = {
.handle = bo->handle,
@@
-338,7
+342,7
@@
drm_public int etna_bo_cpu_prep(struct etna_bo *bo, uint32_t op)
&req, sizeof(req));
}
&req, sizeof(req));
}
-
drm_public
void etna_bo_cpu_fini(struct etna_bo *bo)
+void etna_bo_cpu_fini(struct etna_bo *bo)
{
struct drm_etnaviv_gem_cpu_fini req = {
.handle = bo->handle,
{
struct drm_etnaviv_gem_cpu_fini req = {
.handle = bo->handle,