Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vgem: Ditch attach trickery in the fence ioctl

It looks like this was done purely to get a consistent place to look
up the reservation object pointer. With the drm_prime.c helper code
now also setting gem_object->resv for imported objects we can just use
that pointer directly, instead of first ensuring a dma-buf exists.

v2: Note that I screwed up the patch ordering, hence why this needed
a Fixes: tag - CI spotted the broken intermediate state.

Fixes: 5eab998741c8 ("drm/vgem: Drop drm_gem_prime_export")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190614203615.12639-49-daniel.vetter@ffwll.ch

+1 -21
+1 -21
drivers/gpu/drm/vgem/vgem_fence.c
··· 100 100 return &fence->base; 101 101 } 102 102 103 - static int attach_dmabuf(struct drm_device *dev, 104 - struct drm_gem_object *obj) 105 - { 106 - struct dma_buf *dmabuf; 107 - 108 - if (obj->dma_buf) 109 - return 0; 110 - 111 - dmabuf = dev->driver->gem_prime_export(obj, 0); 112 - if (IS_ERR(dmabuf)) 113 - return PTR_ERR(dmabuf); 114 - 115 - obj->dma_buf = dmabuf; 116 - return 0; 117 - } 118 - 119 103 /* 120 104 * vgem_fence_attach_ioctl (DRM_IOCTL_VGEM_FENCE_ATTACH): 121 105 * ··· 141 157 if (!obj) 142 158 return -ENOENT; 143 159 144 - ret = attach_dmabuf(dev, obj); 145 - if (ret) 146 - goto err; 147 - 148 160 fence = vgem_fence_create(vfile, arg->flags); 149 161 if (!fence) { 150 162 ret = -ENOMEM; ··· 148 168 } 149 169 150 170 /* Check for a conflicting fence */ 151 - resv = obj->dma_buf->resv; 171 + resv = obj->resv; 152 172 if (!reservation_object_test_signaled_rcu(resv, 153 173 arg->flags & VGEM_FENCE_WRITE)) { 154 174 ret = -EBUSY;