Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 7fe2b2948652443ff43d907855bd7a051d54d309 Mon Sep 17 00:00:00 2001 |
| 2 | From: Chris Wilson <chris@chris-wilson.co.uk> |
| 3 | Date: Thu, 19 Mar 2015 23:14:17 +0000 |
| 4 | Subject: [PATCH] sna: Protect against ABI breakage in recent versions of |
| 5 | libdrm |
| 6 | |
| 7 | commit 7fe2b2948652443ff43d907855bd7a051d54d309 upstream. |
| 8 | |
| 9 | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> |
| 10 | Upstream-Status: Backport |
| 11 | Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| 12 | |
| 13 | diff --git a/src/sna/kgem.c b/src/sna/kgem.c |
| 14 | index 11f0828f2bbc..6f16cbac87f2 100644 |
| 15 | --- a/src/sna/kgem.c |
| 16 | +++ b/src/sna/kgem.c |
| 17 | @@ -182,6 +182,15 @@ struct local_i915_gem_caching { |
| 18 | #define LOCAL_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + LOCAL_I915_GEM_SET_CACHING, struct local_i915_gem_caching) |
| 19 | #define LOCAL_IOCTL_I915_GEM_GET_CACHING DRM_IOW(DRM_COMMAND_BASE + LOCAL_I915_GEM_GET_CACHING, struct local_i915_gem_caching) |
| 20 | |
| 21 | +struct local_i915_gem_mmap { |
| 22 | + uint32_t handle; |
| 23 | + uint32_t pad; |
| 24 | + uint64_t offset; |
| 25 | + uint64_t size; |
| 26 | + uint64_t addr_ptr; |
| 27 | +}; |
| 28 | +#define LOCAL_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct local_i915_gem_mmap) |
| 29 | + |
| 30 | struct local_i915_gem_mmap2 { |
| 31 | uint32_t handle; |
| 32 | uint32_t pad; |
| 33 | @@ -514,15 +523,15 @@ retry_wc: |
| 34 | |
| 35 | static void *__kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo) |
| 36 | { |
| 37 | - struct drm_i915_gem_mmap mmap_arg; |
| 38 | + struct local_i915_gem_mmap arg; |
| 39 | int err; |
| 40 | |
| 41 | retry: |
| 42 | - VG_CLEAR(mmap_arg); |
| 43 | - mmap_arg.handle = bo->handle; |
| 44 | - mmap_arg.offset = 0; |
| 45 | - mmap_arg.size = bytes(bo); |
| 46 | - if ((err = do_ioctl(kgem->fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg))) { |
| 47 | + VG_CLEAR(arg); |
| 48 | + arg.handle = bo->handle; |
| 49 | + arg.offset = 0; |
| 50 | + arg.size = bytes(bo); |
| 51 | + if ((err = do_ioctl(kgem->fd, LOCAL_IOCTL_I915_GEM_MMAP, &arg))) { |
| 52 | assert(err != EINVAL); |
| 53 | |
| 54 | if (__kgem_throttle_retire(kgem, 0)) |
| 55 | @@ -536,10 +545,10 @@ retry: |
| 56 | return NULL; |
| 57 | } |
| 58 | |
| 59 | - VG(VALGRIND_MAKE_MEM_DEFINED(mmap_arg.addr_ptr, bytes(bo))); |
| 60 | + VG(VALGRIND_MAKE_MEM_DEFINED(arg.addr_ptr, bytes(bo))); |
| 61 | |
| 62 | DBG(("%s: caching CPU vma for %d\n", __FUNCTION__, bo->handle)); |
| 63 | - return bo->map__cpu = (void *)(uintptr_t)mmap_arg.addr_ptr; |
| 64 | + return bo->map__cpu = (void *)(uintptr_t)arg.addr_ptr; |
| 65 | } |
| 66 | |
| 67 | static int gem_write(int fd, uint32_t handle, |
| 68 | -- |
| 69 | 2.4.4 |
| 70 | |