aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-01-22 13:16:30 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-03-13 07:48:34 -0400
commit39cc344acd414eda231f612325cf824b976025e5 (patch)
treecfcf8105752fd87ec99dfac19ef16d50fb6b71b1 /drivers/gpu
parent251261db7f71829968a8fe80ae3f296fc96851cd (diff)
drm/doc: Add PRIME function references
For giant hilarity the DocBook reference overview is only generated when in a level 2 section, not in a level 3 section. So we need to move this up a bit as a side-by-side section to the main PRIME documentation. Whatever. To have a complete set of references add the missing kerneldoc for all functions exported to modules with the exception of the file private init/destroy functions - drivers have no business calling those, so let's just drop the EXPORT_SYMBOL instead. Also reflow the function parameters to align correctly and break at 80 chars - my OCD couldn't stand them while writing the kerneldoc ;-) Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/drm_prime.c110
1 files changed, 89 insertions, 21 deletions
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 56805c39c906..f1437b6c8dbf 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -68,7 +68,8 @@ struct drm_prime_attachment {
68 enum dma_data_direction dir; 68 enum dma_data_direction dir;
69}; 69};
70 70
71static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle) 71static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,
72 struct dma_buf *dma_buf, uint32_t handle)
72{ 73{
73 struct drm_prime_member *member; 74 struct drm_prime_member *member;
74 75
@@ -174,7 +175,7 @@ void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpr
174} 175}
175 176
176static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, 177static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
177 enum dma_data_direction dir) 178 enum dma_data_direction dir)
178{ 179{
179 struct drm_prime_attachment *prime_attach = attach->priv; 180 struct drm_prime_attachment *prime_attach = attach->priv;
180 struct drm_gem_object *obj = attach->dmabuf->priv; 181 struct drm_gem_object *obj = attach->dmabuf->priv;
@@ -211,11 +212,19 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
211} 212}
212 213
213static void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach, 214static void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
214 struct sg_table *sgt, enum dma_data_direction dir) 215 struct sg_table *sgt,
216 enum dma_data_direction dir)
215{ 217{
216 /* nothing to be done here */ 218 /* nothing to be done here */
217} 219}
218 220
221/**
222 * drm_gem_dmabuf_release - dma_buf release implementation for GEM
223 * @dma_buf: buffer to be released
224 *
225 * Generic release function for dma_bufs exported as PRIME buffers. GEM drivers
226 * must use this in their dma_buf ops structure as the release callback.
227 */
219void drm_gem_dmabuf_release(struct dma_buf *dma_buf) 228void drm_gem_dmabuf_release(struct dma_buf *dma_buf)
220{ 229{
221 struct drm_gem_object *obj = dma_buf->priv; 230 struct drm_gem_object *obj = dma_buf->priv;
@@ -242,30 +251,30 @@ static void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr)
242} 251}
243 252
244static void *drm_gem_dmabuf_kmap_atomic(struct dma_buf *dma_buf, 253static void *drm_gem_dmabuf_kmap_atomic(struct dma_buf *dma_buf,
245 unsigned long page_num) 254 unsigned long page_num)
246{ 255{
247 return NULL; 256 return NULL;
248} 257}
249 258
250static void drm_gem_dmabuf_kunmap_atomic(struct dma_buf *dma_buf, 259static void drm_gem_dmabuf_kunmap_atomic(struct dma_buf *dma_buf,
251 unsigned long page_num, void *addr) 260 unsigned long page_num, void *addr)
252{ 261{
253 262
254} 263}
255static void *drm_gem_dmabuf_kmap(struct dma_buf *dma_buf, 264static void *drm_gem_dmabuf_kmap(struct dma_buf *dma_buf,
256 unsigned long page_num) 265 unsigned long page_num)
257{ 266{
258 return NULL; 267 return NULL;
259} 268}
260 269
261static void drm_gem_dmabuf_kunmap(struct dma_buf *dma_buf, 270static void drm_gem_dmabuf_kunmap(struct dma_buf *dma_buf,
262 unsigned long page_num, void *addr) 271 unsigned long page_num, void *addr)
263{ 272{
264 273
265} 274}
266 275
267static int drm_gem_dmabuf_mmap(struct dma_buf *dma_buf, 276static int drm_gem_dmabuf_mmap(struct dma_buf *dma_buf,
268 struct vm_area_struct *vma) 277 struct vm_area_struct *vma)
269{ 278{
270 struct drm_gem_object *obj = dma_buf->priv; 279 struct drm_gem_object *obj = dma_buf->priv;
271 struct drm_device *dev = obj->dev; 280 struct drm_device *dev = obj->dev;
@@ -315,6 +324,15 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = {
315 * driver's scatter/gather table 324 * driver's scatter/gather table
316 */ 325 */
317 326
327/**
328 * drm_gem_prime_export - helper library implemention of the export callback
329 * @dev: drm_device to export from
330 * @obj: GEM object to export
331 * @flags: flags like DRM_CLOEXEC
332 *
333 * This is the implementation of the gem_prime_export functions for GEM drivers
334 * using the PRIME helpers.
335 */
318struct dma_buf *drm_gem_prime_export(struct drm_device *dev, 336struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
319 struct drm_gem_object *obj, int flags) 337 struct drm_gem_object *obj, int flags)
320{ 338{
@@ -355,9 +373,23 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,
355 return dmabuf; 373 return dmabuf;
356} 374}
357 375
376/**
377 * drm_gem_prime_handle_to_fd - PRIME export function for GEM drivers
378 * @dev: dev to export the buffer from
379 * @file_priv: drm file-private structure
380 * @handle: buffer handle to export
381 * @flags: flags like DRM_CLOEXEC
382 * @prime_fd: pointer to storage for the fd id of the create dma-buf
383 *
384 * This is the PRIME export function which must be used mandatorily by GEM
385 * drivers to ensure correct lifetime management of the underlying GEM object.
386 * The actual exporting from GEM object to a dma-buf is done through the
387 * gem_prime_export driver callback.
388 */
358int drm_gem_prime_handle_to_fd(struct drm_device *dev, 389int drm_gem_prime_handle_to_fd(struct drm_device *dev,
359 struct drm_file *file_priv, uint32_t handle, uint32_t flags, 390 struct drm_file *file_priv, uint32_t handle,
360 int *prime_fd) 391 uint32_t flags,
392 int *prime_fd)
361{ 393{
362 struct drm_gem_object *obj; 394 struct drm_gem_object *obj;
363 int ret = 0; 395 int ret = 0;
@@ -441,6 +473,14 @@ out_unlock:
441} 473}
442EXPORT_SYMBOL(drm_gem_prime_handle_to_fd); 474EXPORT_SYMBOL(drm_gem_prime_handle_to_fd);
443 475
476/**
477 * drm_gem_prime_import - helper library implemention of the import callback
478 * @dev: drm_device to import into
479 * @dma_buf: dma-buf object to import
480 *
481 * This is the implementation of the gem_prime_import functions for GEM drivers
482 * using the PRIME helpers.
483 */
444struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, 484struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
445 struct dma_buf *dma_buf) 485 struct dma_buf *dma_buf)
446{ 486{
@@ -496,8 +536,21 @@ fail_detach:
496} 536}
497EXPORT_SYMBOL(drm_gem_prime_import); 537EXPORT_SYMBOL(drm_gem_prime_import);
498 538
539/**
540 * drm_gem_prime_fd_to_handle - PRIME import function for GEM drivers
541 * @dev: dev to export the buffer from
542 * @file_priv: drm file-private structure
543 * @prime_fd: fd id of the dma-buf which should be imported
544 * @handle: pointer to storage for the handle of the imported buffer object
545 *
546 * This is the PRIME import function which must be used mandatorily by GEM
547 * drivers to ensure correct lifetime management of the underlying GEM object.
548 * The actual importing of GEM object from the dma-buf is done through the
549 * gem_import_export driver callback.
550 */
499int drm_gem_prime_fd_to_handle(struct drm_device *dev, 551int drm_gem_prime_fd_to_handle(struct drm_device *dev,
500 struct drm_file *file_priv, int prime_fd, uint32_t *handle) 552 struct drm_file *file_priv, int prime_fd,
553 uint32_t *handle)
501{ 554{
502 struct dma_buf *dma_buf; 555 struct dma_buf *dma_buf;
503 struct drm_gem_object *obj; 556 struct drm_gem_object *obj;
@@ -598,12 +651,14 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
598 args->fd, &args->handle); 651 args->fd, &args->handle);
599} 652}
600 653
601/* 654/**
602 * drm_prime_pages_to_sg 655 * drm_prime_pages_to_sg - converts a page array into an sg list
656 * @pages: pointer to the array of page pointers to convert
657 * @nr_pages: length of the page vector
603 * 658 *
604 * this helper creates an sg table object from a set of pages 659 * This helper creates an sg table object from a set of pages
605 * the driver is responsible for mapping the pages into the 660 * the driver is responsible for mapping the pages into the
606 * importers address space 661 * importers address space for use with dma_buf itself.
607 */ 662 */
608struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages) 663struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages)
609{ 664{
@@ -628,9 +683,16 @@ out:
628} 683}
629EXPORT_SYMBOL(drm_prime_pages_to_sg); 684EXPORT_SYMBOL(drm_prime_pages_to_sg);
630 685
631/* export an sg table into an array of pages and addresses 686/**
632 this is currently required by the TTM driver in order to do correct fault 687 * drm_prime_sg_to_page_addr_arrays - convert an sg table into a page array
633 handling */ 688 * @sgt: scatter-gather table to convert
689 * @pages: array of page pointers to store the page array in
690 * @addrs: optional array to store the dma bus address of each page
691 * @max_pages: size of both the passed-in arrays
692 *
693 * Exports an sg table into an array of pages and addresses. This is currently
694 * required by the TTM driver in order to do correct fault handling.
695 */
634int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, 696int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
635 dma_addr_t *addrs, int max_pages) 697 dma_addr_t *addrs, int max_pages)
636{ 698{
@@ -663,7 +725,15 @@ int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
663 return 0; 725 return 0;
664} 726}
665EXPORT_SYMBOL(drm_prime_sg_to_page_addr_arrays); 727EXPORT_SYMBOL(drm_prime_sg_to_page_addr_arrays);
666/* helper function to cleanup a GEM/prime object */ 728
729/**
730 * drm_prime_gem_destroy - helper to clean up a PRIME-imported GEM object
731 * @obj: GEM object which was created from a dma-buf
732 * @sg: the sg-table which was pinned at import time
733 *
734 * This is the cleanup functions which GEM drivers need to call when they use
735 * @drm_gem_prime_import to import dma-bufs.
736 */
667void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg) 737void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg)
668{ 738{
669 struct dma_buf_attachment *attach; 739 struct dma_buf_attachment *attach;
@@ -683,11 +753,9 @@ void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv)
683 INIT_LIST_HEAD(&prime_fpriv->head); 753 INIT_LIST_HEAD(&prime_fpriv->head);
684 mutex_init(&prime_fpriv->lock); 754 mutex_init(&prime_fpriv->lock);
685} 755}
686EXPORT_SYMBOL(drm_prime_init_file_private);
687 756
688void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv) 757void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv)
689{ 758{
690 /* by now drm_gem_release should've made sure the list is empty */ 759 /* by now drm_gem_release should've made sure the list is empty */
691 WARN_ON(!list_empty(&prime_fpriv->head)); 760 WARN_ON(!list_empty(&prime_fpriv->head));
692} 761}
693EXPORT_SYMBOL(drm_prime_destroy_file_private);