aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma-buf/dma-buf.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-03-18 16:02:39 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-03-19 06:03:49 -0400
commit18b862dcd57a3e23e34c8cd1e939f68548c1209a (patch)
tree2cae837505f27d327f0a51751c3d79e88148e8aa /drivers/dma-buf/dma-buf.c
parentb47ff7e6a534bc285eb98f90eadd2a56e2e54056 (diff)
dma-buf, drm, ion: Propagate error code from dma_buf_start_cpu_access()
Drivers, especially i915.ko, can fail during the initial migration of a dma-buf for CPU access. However, the error code from the driver was not being propagated back to ioctl and so userspace was blissfully ignorant of the failure. Rendering corruption ensues. Whilst fixing the ioctl to return the error code from dma_buf_start_cpu_access(), also do the same for dma_buf_end_cpu_access(). For most drivers, dma_buf_end_cpu_access() cannot fail. i915.ko however, as most drivers would, wants to avoid being uninterruptible (as would be required to guarrantee no failure when flushing the buffer to the device). As userspace already has to handle errors from the SYNC_IOCTL, take advantage of this to be able to restart the syscall across signals. This fixes a coherency issue for i915.ko as well as reducing the uninterruptible hold upon its BKL, the struct_mutex. Fixes commit c11e391da2a8fe973c3c2398452000bed505851e Author: Daniel Vetter <daniel.vetter@ffwll.ch> Date: Thu Feb 11 20:04:51 2016 -0200 dma-buf: Add ioctls to allow userspace to flush Testcase: igt/gem_concurrent_blit/*dmabuf*interruptible Testcase: igt/prime_mmap_coherency/ioctl-errors Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tiago Vignatti <tiago.vignatti@intel.com> Cc: Stéphane Marchesin <marcheu@chromium.org> Cc: David Herrmann <dh.herrmann@gmail.com> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Daniel Vetter <daniel.vetter@intel.com> CC: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linaro-mm-sig@lists.linaro.org Cc: intel-gfx@lists.freedesktop.org Cc: devel@driverdev.osuosl.org Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1458331359-2634-1-git-send-email-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/dma-buf/dma-buf.c')
-rw-r--r--drivers/dma-buf/dma-buf.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 9810d1df0691..774a60f4309a 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -259,6 +259,7 @@ static long dma_buf_ioctl(struct file *file,
259 struct dma_buf *dmabuf; 259 struct dma_buf *dmabuf;
260 struct dma_buf_sync sync; 260 struct dma_buf_sync sync;
261 enum dma_data_direction direction; 261 enum dma_data_direction direction;
262 int ret;
262 263
263 dmabuf = file->private_data; 264 dmabuf = file->private_data;
264 265
@@ -285,11 +286,11 @@ static long dma_buf_ioctl(struct file *file,
285 } 286 }
286 287
287 if (sync.flags & DMA_BUF_SYNC_END) 288 if (sync.flags & DMA_BUF_SYNC_END)
288 dma_buf_end_cpu_access(dmabuf, direction); 289 ret = dma_buf_end_cpu_access(dmabuf, direction);
289 else 290 else
290 dma_buf_begin_cpu_access(dmabuf, direction); 291 ret = dma_buf_begin_cpu_access(dmabuf, direction);
291 292
292 return 0; 293 return ret;
293 default: 294 default:
294 return -ENOTTY; 295 return -ENOTTY;
295 } 296 }
@@ -613,13 +614,17 @@ EXPORT_SYMBOL_GPL(dma_buf_begin_cpu_access);
613 * 614 *
614 * This call must always succeed. 615 * This call must always succeed.
615 */ 616 */
616void dma_buf_end_cpu_access(struct dma_buf *dmabuf, 617int dma_buf_end_cpu_access(struct dma_buf *dmabuf,
617 enum dma_data_direction direction) 618 enum dma_data_direction direction)
618{ 619{
620 int ret = 0;
621
619 WARN_ON(!dmabuf); 622 WARN_ON(!dmabuf);
620 623
621 if (dmabuf->ops->end_cpu_access) 624 if (dmabuf->ops->end_cpu_access)
622 dmabuf->ops->end_cpu_access(dmabuf, direction); 625 ret = dmabuf->ops->end_cpu_access(dmabuf, direction);
626
627 return ret;
623} 628}
624EXPORT_SYMBOL_GPL(dma_buf_end_cpu_access); 629EXPORT_SYMBOL_GPL(dma_buf_end_cpu_access);
625 630