aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>2017-01-27 02:04:25 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2017-01-27 09:00:26 -0500
commitfa4c1de4a1aeeb0ef4dca692c779abbcc6c4960f (patch)
tree21c239cacb6f16cfbc0c56de44c06278eb228b2f /drivers/gpu
parent239ac65fa5ffab71adf66e642750f940e7241d99 (diff)
drm/prime: Clarify DMA-BUF/GEM Object lifetime
From the description of the "DMA-BUF/GEM Object references and lifetime overview" it is not clear when exactly dma_buf gets destroyed and memory freed: only driver .release function mentioned which makes confusion on the real buffer's lifetime. Add more description so all the paths are covered. Cc: Rob Clark <robdclark@gmail.com> Cc: Dave Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> [danvet: Minor spelling fixes, and some clarification of the 2nd paragraph.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1485500665-27690-1-git-send-email-andr2000@gmail.com
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/drm_prime.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 485e558d6661..25aa4558f1b5 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -40,8 +40,11 @@
40 * On the export the dma_buf holds a reference to the exporting GEM 40 * On the export the dma_buf holds a reference to the exporting GEM
41 * object. It takes this reference in handle_to_fd_ioctl, when it 41 * object. It takes this reference in handle_to_fd_ioctl, when it
42 * first calls .prime_export and stores the exporting GEM object in 42 * first calls .prime_export and stores the exporting GEM object in
43 * the dma_buf priv. This reference is released when the dma_buf 43 * the dma_buf priv. This reference needs to be released when the
44 * object goes away in the driver .release function. 44 * final reference to the &dma_buf itself is dropped and its
45 * &dma_buf_ops.release function is called. For GEM-based drivers,
46 * the dma_buf should be exported using drm_gem_dmabuf_export() and
47 * then released by drm_gem_dmabuf_release().
45 * 48 *
46 * On the import the importing GEM object holds a reference to the 49 * On the import the importing GEM object holds a reference to the
47 * dma_buf (which in turn holds a ref to the exporting GEM object). 50 * dma_buf (which in turn holds a ref to the exporting GEM object).
@@ -51,6 +54,16 @@
51 * when the imported object is destroyed, we remove the attachment 54 * when the imported object is destroyed, we remove the attachment
52 * and drop the reference to the dma_buf. 55 * and drop the reference to the dma_buf.
53 * 56 *
57 * When all the references to the &dma_buf are dropped, i.e. when
58 * userspace has closed both handles to the imported GEM object (through the
59 * FD_TO_HANDLE IOCTL) and closed the file descriptor of the exported
60 * (through the HANDLE_TO_FD IOCTL) dma_buf, and all kernel-internal references
61 * are also gone, then the dma_buf gets destroyed. This can also happen as a
62 * part of the clean up procedure in the drm_release() function if userspace
63 * fails to properly clean up. Note that both the kernel and userspace (by
64 * keeeping the PRIME file descriptors open) can hold references onto a
65 * &dma_buf.
66 *
54 * Thus the chain of references always flows in one direction 67 * Thus the chain of references always flows in one direction
55 * (avoiding loops): importing_gem -> dmabuf -> exporting_gem 68 * (avoiding loops): importing_gem -> dmabuf -> exporting_gem
56 * 69 *