xf86-video-intel: src/sna/kgem.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Oct 10 14:20:36 PDT 2013


 src/sna/kgem.c |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit 3e3af6936ea26be57e80e09752a8736c9cfe2566
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 10 22:16:53 2013 +0100

    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 at bitplanet.net>
    Suggested-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 3dcc614..dbcd142 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));


More information about the xorg-commit mailing list