diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2013-10-10 14:40:58 -0700 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-10-10 14:41:40 -0700 |
commit | 9c52c3dc4763336884277d8005eac7e6efb77600 (patch) | |
tree | 1a197243e8166926a2970d13ed21c1c3e3c80f36 /intel | |
parent | ddbbdb13d80ea7f60e6f71356a444995b905366b (diff) |
intel: Set bo size from lseek if kernel supports it
The various create and open functions set the buffer size, but
drm_intel_bo_gem_create_from_prime() is an exception. In the 3.12 kernel
we can now use lseek on the prime fd to determine the size of the bo.
Use that and override the userprovided size. If the kernel doesn't
support this, we get an error and fall back to the user provided size.
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Diffstat (limited to 'intel')
-rw-r--r-- | intel/intel_bufmgr_gem.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index f98f7a72..278f5c87 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -2452,7 +2452,17 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s if (!bo_gem) return NULL; - bo_gem->bo.size = size; + /* Determine size of bo. The fd-to-handle ioctl really should + * return the size, but it doesn't. If we have kernel 3.12 or + * later, we can lseek on the prime fd to get the size. Older + * kernels will just fail, in which case we fall back to the + * provided (estimated or guess size). */ + ret = lseek(prime_fd, 0, SEEK_END); + if (ret != -1) + bo_gem->bo.size = ret; + else + bo_gem->bo.size = size; + bo_gem->bo.handle = handle; bo_gem->bo.bufmgr = bufmgr; |