summaryrefslogtreecommitdiff
path: root/lib/libdrm/freedreno
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2015-12-27 08:58:22 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2015-12-27 08:58:22 +0000
commit5db7cad38be896315e2b897f68d1751d340a2483 (patch)
treecaab7de8344c4ce0d7d769184a89ea35d80dce1c /lib/libdrm/freedreno
parent5550a33ac941747a471b1029b7f6ae4a7569c8c3 (diff)
Import libdrm 2.4.65
Diffstat (limited to 'lib/libdrm/freedreno')
-rwxr-xr-xlib/libdrm/freedreno/freedreno-symbol-check1
-rw-r--r--lib/libdrm/freedreno/freedreno_bo.c38
-rw-r--r--lib/libdrm/freedreno/freedreno_device.c5
-rw-r--r--lib/libdrm/freedreno/freedreno_drmif.h1
-rw-r--r--lib/libdrm/freedreno/freedreno_priv.h6
-rw-r--r--lib/libdrm/freedreno/freedreno_ringbuffer.h2
-rw-r--r--lib/libdrm/freedreno/kgsl/kgsl_bo.c2
-rw-r--r--lib/libdrm/freedreno/kgsl/kgsl_device.c2
-rw-r--r--lib/libdrm/freedreno/kgsl/kgsl_pipe.c2
-rw-r--r--lib/libdrm/freedreno/kgsl/kgsl_ringbuffer.c2
-rw-r--r--lib/libdrm/freedreno/msm/msm_bo.c2
-rw-r--r--lib/libdrm/freedreno/msm/msm_device.c2
-rw-r--r--lib/libdrm/freedreno/msm/msm_pipe.c2
-rw-r--r--lib/libdrm/freedreno/msm/msm_ringbuffer.c2
14 files changed, 43 insertions, 26 deletions
diff --git a/lib/libdrm/freedreno/freedreno-symbol-check b/lib/libdrm/freedreno/freedreno-symbol-check
index e593df4d7..f517b6e71 100755
--- a/lib/libdrm/freedreno/freedreno-symbol-check
+++ b/lib/libdrm/freedreno/freedreno-symbol-check
@@ -25,6 +25,7 @@ fd_bo_new
fd_bo_ref
fd_bo_size
fd_device_del
+fd_device_fd
fd_device_new
fd_device_new_dup
fd_device_ref
diff --git a/lib/libdrm/freedreno/freedreno_bo.c b/lib/libdrm/freedreno/freedreno_bo.c
index eec218c6b..1cb67595b 100644
--- a/lib/libdrm/freedreno/freedreno_bo.c
+++ b/lib/libdrm/freedreno/freedreno_bo.c
@@ -52,6 +52,9 @@ static struct fd_bo * lookup_bo(void *tbl, uint32_t key)
if (!drmHashLookup(tbl, key, (void **)&bo)) {
/* found, incr refcnt and return: */
bo = fd_bo_ref(bo);
+
+ /* don't break the bucket if this bo was found in one */
+ list_delinit(&bo->list);
}
return bo;
}
@@ -223,20 +226,30 @@ out_unlock:
struct fd_bo *
fd_bo_from_dmabuf(struct fd_device *dev, int fd)
{
- struct drm_prime_handle req = {
- .fd = fd,
- };
int ret, size;
+ uint32_t handle;
+ struct fd_bo *bo;
- ret = drmIoctl(dev->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &req);
+ pthread_mutex_lock(&table_lock);
+ ret = drmPrimeFDToHandle(dev->fd, fd, &handle);
if (ret) {
return NULL;
}
- /* hmm, would be nice if we had a way to figure out the size.. */
- size = 0;
+ bo = lookup_bo(dev->handle_table, handle);
+ if (bo)
+ goto out_unlock;
+
+ /* lseek() to get bo size */
+ size = lseek(fd, 0, SEEK_END);
+ lseek(fd, 0, SEEK_CUR);
- return fd_bo_from_handle(dev, req.handle, size);
+ bo = bo_from_handle(dev, size, handle);
+
+out_unlock:
+ pthread_mutex_unlock(&table_lock);
+
+ return bo;
}
struct fd_bo * fd_bo_from_name(struct fd_device *dev, uint32_t name)
@@ -373,18 +386,15 @@ uint32_t fd_bo_handle(struct fd_bo *bo)
int fd_bo_dmabuf(struct fd_bo *bo)
{
if (bo->fd < 0) {
- struct drm_prime_handle req = {
- .handle = bo->handle,
- .flags = DRM_CLOEXEC,
- };
- int ret;
+ int ret, prime_fd;
- ret = drmIoctl(bo->dev->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &req);
+ ret = drmPrimeHandleToFD(bo->dev->fd, bo->handle, DRM_CLOEXEC,
+ &prime_fd);
if (ret) {
return ret;
}
- bo->fd = req.fd;
+ bo->fd = prime_fd;
}
return dup(bo->fd);
}
diff --git a/lib/libdrm/freedreno/freedreno_device.c b/lib/libdrm/freedreno/freedreno_device.c
index 3bc4cb21a..ddb954551 100644
--- a/lib/libdrm/freedreno/freedreno_device.c
+++ b/lib/libdrm/freedreno/freedreno_device.c
@@ -160,3 +160,8 @@ void fd_device_del(struct fd_device *dev)
fd_device_del_impl(dev);
pthread_mutex_unlock(&table_lock);
}
+
+int fd_device_fd(struct fd_device *dev)
+{
+ return dev->fd;
+}
diff --git a/lib/libdrm/freedreno/freedreno_drmif.h b/lib/libdrm/freedreno/freedreno_drmif.h
index 81a14b433..5547e9439 100644
--- a/lib/libdrm/freedreno/freedreno_drmif.h
+++ b/lib/libdrm/freedreno/freedreno_drmif.h
@@ -76,6 +76,7 @@ struct fd_device * fd_device_new(int fd);
struct fd_device * fd_device_new_dup(int fd);
struct fd_device * fd_device_ref(struct fd_device *dev);
void fd_device_del(struct fd_device *dev);
+int fd_device_fd(struct fd_device *dev);
/* pipe functions:
diff --git a/lib/libdrm/freedreno/freedreno_priv.h b/lib/libdrm/freedreno/freedreno_priv.h
index 1dddcc39e..4e442e420 100644
--- a/lib/libdrm/freedreno/freedreno_priv.h
+++ b/lib/libdrm/freedreno/freedreno_priv.h
@@ -83,7 +83,7 @@ struct fd_device {
*/
void *handle_table, *name_table;
- struct fd_device_funcs *funcs;
+ const struct fd_device_funcs *funcs;
struct fd_bo_bucket cache_bucket[14 * 4];
int num_buckets;
@@ -107,7 +107,7 @@ struct fd_pipe_funcs {
struct fd_pipe {
struct fd_device *dev;
enum fd_pipe_id id;
- struct fd_pipe_funcs *funcs;
+ const struct fd_pipe_funcs *funcs;
};
struct fd_ringmarker {
@@ -141,7 +141,7 @@ struct fd_bo {
int fd; /* dmabuf handle */
void *map;
atomic_t refcnt;
- struct fd_bo_funcs *funcs;
+ const struct fd_bo_funcs *funcs;
int bo_reuse;
struct list_head list; /* bucket-list entry */
diff --git a/lib/libdrm/freedreno/freedreno_ringbuffer.h b/lib/libdrm/freedreno/freedreno_ringbuffer.h
index a5e1d032e..578cdb243 100644
--- a/lib/libdrm/freedreno/freedreno_ringbuffer.h
+++ b/lib/libdrm/freedreno/freedreno_ringbuffer.h
@@ -44,7 +44,7 @@ struct fd_ringbuffer {
int size;
uint32_t *cur, *end, *start, *last_start;
struct fd_pipe *pipe;
- struct fd_ringbuffer_funcs *funcs;
+ const struct fd_ringbuffer_funcs *funcs;
uint32_t last_timestamp;
struct fd_ringbuffer *parent;
};
diff --git a/lib/libdrm/freedreno/kgsl/kgsl_bo.c b/lib/libdrm/freedreno/kgsl/kgsl_bo.c
index 3407c769c..b8ac10261 100644
--- a/lib/libdrm/freedreno/kgsl/kgsl_bo.c
+++ b/lib/libdrm/freedreno/kgsl/kgsl_bo.c
@@ -123,7 +123,7 @@ static void kgsl_bo_destroy(struct fd_bo *bo)
}
-static struct fd_bo_funcs funcs = {
+static const struct fd_bo_funcs funcs = {
.offset = kgsl_bo_offset,
.cpu_prep = kgsl_bo_cpu_prep,
.cpu_fini = kgsl_bo_cpu_fini,
diff --git a/lib/libdrm/freedreno/kgsl/kgsl_device.c b/lib/libdrm/freedreno/kgsl/kgsl_device.c
index 8352d605f..175e83781 100644
--- a/lib/libdrm/freedreno/kgsl/kgsl_device.c
+++ b/lib/libdrm/freedreno/kgsl/kgsl_device.c
@@ -42,7 +42,7 @@ static void kgsl_device_destroy(struct fd_device *dev)
free(kgsl_dev);
}
-static struct fd_device_funcs funcs = {
+static const struct fd_device_funcs funcs = {
.bo_new_handle = kgsl_bo_new_handle,
.bo_from_handle = kgsl_bo_from_handle,
.pipe_new = kgsl_pipe_new,
diff --git a/lib/libdrm/freedreno/kgsl/kgsl_pipe.c b/lib/libdrm/freedreno/kgsl/kgsl_pipe.c
index e2fd65c01..58b3b4d50 100644
--- a/lib/libdrm/freedreno/kgsl/kgsl_pipe.c
+++ b/lib/libdrm/freedreno/kgsl/kgsl_pipe.c
@@ -108,7 +108,7 @@ static void kgsl_pipe_destroy(struct fd_pipe *pipe)
free(kgsl_pipe);
}
-static struct fd_pipe_funcs funcs = {
+static const struct fd_pipe_funcs funcs = {
.ringbuffer_new = kgsl_ringbuffer_new,
.get_param = kgsl_pipe_get_param,
.wait = kgsl_pipe_wait,
diff --git a/lib/libdrm/freedreno/kgsl/kgsl_ringbuffer.c b/lib/libdrm/freedreno/kgsl/kgsl_ringbuffer.c
index f0133078c..6f68f2f30 100644
--- a/lib/libdrm/freedreno/kgsl/kgsl_ringbuffer.c
+++ b/lib/libdrm/freedreno/kgsl/kgsl_ringbuffer.c
@@ -191,7 +191,7 @@ static void kgsl_ringbuffer_destroy(struct fd_ringbuffer *ring)
free(kgsl_ring);
}
-static struct fd_ringbuffer_funcs funcs = {
+static const struct fd_ringbuffer_funcs funcs = {
.hostptr = kgsl_ringbuffer_hostptr,
.flush = kgsl_ringbuffer_flush,
.emit_reloc = kgsl_ringbuffer_emit_reloc,
diff --git a/lib/libdrm/freedreno/msm/msm_bo.c b/lib/libdrm/freedreno/msm/msm_bo.c
index fd944131e..ee668aba9 100644
--- a/lib/libdrm/freedreno/msm/msm_bo.c
+++ b/lib/libdrm/freedreno/msm/msm_bo.c
@@ -96,7 +96,7 @@ static void msm_bo_destroy(struct fd_bo *bo)
}
-static struct fd_bo_funcs funcs = {
+static const struct fd_bo_funcs funcs = {
.offset = msm_bo_offset,
.cpu_prep = msm_bo_cpu_prep,
.cpu_fini = msm_bo_cpu_fini,
diff --git a/lib/libdrm/freedreno/msm/msm_device.c b/lib/libdrm/freedreno/msm/msm_device.c
index 81077e1a5..25c097c25 100644
--- a/lib/libdrm/freedreno/msm/msm_device.c
+++ b/lib/libdrm/freedreno/msm/msm_device.c
@@ -42,7 +42,7 @@ static void msm_device_destroy(struct fd_device *dev)
free(msm_dev);
}
-static struct fd_device_funcs funcs = {
+static const struct fd_device_funcs funcs = {
.bo_new_handle = msm_bo_new_handle,
.bo_from_handle = msm_bo_from_handle,
.pipe_new = msm_pipe_new,
diff --git a/lib/libdrm/freedreno/msm/msm_pipe.c b/lib/libdrm/freedreno/msm/msm_pipe.c
index e1edffea6..aa0866b4a 100644
--- a/lib/libdrm/freedreno/msm/msm_pipe.c
+++ b/lib/libdrm/freedreno/msm/msm_pipe.c
@@ -80,7 +80,7 @@ static void msm_pipe_destroy(struct fd_pipe *pipe)
free(msm_pipe);
}
-static struct fd_pipe_funcs funcs = {
+static const struct fd_pipe_funcs funcs = {
.ringbuffer_new = msm_ringbuffer_new,
.get_param = msm_pipe_get_param,
.wait = msm_pipe_wait,
diff --git a/lib/libdrm/freedreno/msm/msm_ringbuffer.c b/lib/libdrm/freedreno/msm/msm_ringbuffer.c
index 5ddea5740..ee6af0ba0 100644
--- a/lib/libdrm/freedreno/msm/msm_ringbuffer.c
+++ b/lib/libdrm/freedreno/msm/msm_ringbuffer.c
@@ -356,7 +356,7 @@ static void msm_ringbuffer_destroy(struct fd_ringbuffer *ring)
free(msm_ring);
}
-static struct fd_ringbuffer_funcs funcs = {
+static const struct fd_ringbuffer_funcs funcs = {
.hostptr = msm_ringbuffer_hostptr,
.flush = msm_ringbuffer_flush,
.reset = msm_ringbuffer_reset,