summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-10-10 22:16:53 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-10-10 22:19:44 +0100
commit3e3af6936ea26be57e80e09752a8736c9cfe2566 (patch)
tree00c70e5452606b70dabecb0a2dc8a192f62f28d6
parentf0bd716425d1514b62565f9a65397cd1cb2ffb3a (diff)
sna: Populate bo->size from dma-buf
Recent kernels gained the ability to report the actual size of the dma-buf through an lseek. We can use this to set the correct size of the bo when available, overriding the guess provided by the caller. Suggested-by: Kristian Høgsberg <krh@bitplanet.net> Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 3dcc6142..dbcd1428 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -3554,6 +3554,7 @@ struct kgem_bo *kgem_create_for_prime(struct kgem *kgem, int name, uint32_t size
struct drm_prime_handle args;
struct drm_i915_gem_get_tiling tiling;
struct kgem_bo *bo;
+ off_t seek;
DBG(("%s(name=%d)\n", __FUNCTION__, name));
@@ -3573,6 +3574,11 @@ struct kgem_bo *kgem_create_for_prime(struct kgem *kgem, int name, uint32_t size
return NULL;
}
+ /* Query actual size, overriding specified if available */
+ seek = lseek(args.fd, 0, SEEK_END);
+ if (seek != -1)
+ size = seek;
+
DBG(("%s: new handle=%d, tiling=%d\n", __FUNCTION__,
args.handle, tiling.tiling_mode));
bo = __kgem_bo_alloc(args.handle, NUM_PAGES(size));