diff options
-rw-r--r-- | Documentation/DocBook/drm.tmpl | 274 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_gem.c | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_gem_cma_helper.c | 259 | ||||
-rw-r--r-- | drivers/gpu/drm/omapdrm/omap_gem.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/rcar-du/rcar_du_kms.c | 4 | ||||
-rw-r--r-- | include/drm/drm_gem_cma_helper.h | 30 |
7 files changed, 395 insertions, 196 deletions
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index b8bfa8d1f289..8c54f9a393cf 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl | |||
@@ -492,10 +492,10 @@ char *date;</synopsis> | |||
492 | <sect2> | 492 | <sect2> |
493 | <title>The Translation Table Manager (TTM)</title> | 493 | <title>The Translation Table Manager (TTM)</title> |
494 | <para> | 494 | <para> |
495 | TTM design background and information belongs here. | 495 | TTM design background and information belongs here. |
496 | </para> | 496 | </para> |
497 | <sect3> | 497 | <sect3> |
498 | <title>TTM initialization</title> | 498 | <title>TTM initialization</title> |
499 | <warning><para>This section is outdated.</para></warning> | 499 | <warning><para>This section is outdated.</para></warning> |
500 | <para> | 500 | <para> |
501 | Drivers wishing to support TTM must fill out a drm_bo_driver | 501 | Drivers wishing to support TTM must fill out a drm_bo_driver |
@@ -503,42 +503,42 @@ char *date;</synopsis> | |||
503 | pointers for initializing the TTM, allocating and freeing memory, | 503 | pointers for initializing the TTM, allocating and freeing memory, |
504 | waiting for command completion and fence synchronization, and memory | 504 | waiting for command completion and fence synchronization, and memory |
505 | migration. See the radeon_ttm.c file for an example of usage. | 505 | migration. See the radeon_ttm.c file for an example of usage. |
506 | </para> | 506 | </para> |
507 | <para> | 507 | <para> |
508 | The ttm_global_reference structure is made up of several fields: | 508 | The ttm_global_reference structure is made up of several fields: |
509 | </para> | 509 | </para> |
510 | <programlisting> | 510 | <programlisting> |
511 | struct ttm_global_reference { | 511 | struct ttm_global_reference { |
512 | enum ttm_global_types global_type; | 512 | enum ttm_global_types global_type; |
513 | size_t size; | 513 | size_t size; |
514 | void *object; | 514 | void *object; |
515 | int (*init) (struct ttm_global_reference *); | 515 | int (*init) (struct ttm_global_reference *); |
516 | void (*release) (struct ttm_global_reference *); | 516 | void (*release) (struct ttm_global_reference *); |
517 | }; | 517 | }; |
518 | </programlisting> | 518 | </programlisting> |
519 | <para> | 519 | <para> |
520 | There should be one global reference structure for your memory | 520 | There should be one global reference structure for your memory |
521 | manager as a whole, and there will be others for each object | 521 | manager as a whole, and there will be others for each object |
522 | created by the memory manager at runtime. Your global TTM should | 522 | created by the memory manager at runtime. Your global TTM should |
523 | have a type of TTM_GLOBAL_TTM_MEM. The size field for the global | 523 | have a type of TTM_GLOBAL_TTM_MEM. The size field for the global |
524 | object should be sizeof(struct ttm_mem_global), and the init and | 524 | object should be sizeof(struct ttm_mem_global), and the init and |
525 | release hooks should point at your driver-specific init and | 525 | release hooks should point at your driver-specific init and |
526 | release routines, which probably eventually call | 526 | release routines, which probably eventually call |
527 | ttm_mem_global_init and ttm_mem_global_release, respectively. | 527 | ttm_mem_global_init and ttm_mem_global_release, respectively. |
528 | </para> | 528 | </para> |
529 | <para> | 529 | <para> |
530 | Once your global TTM accounting structure is set up and initialized | 530 | Once your global TTM accounting structure is set up and initialized |
531 | by calling ttm_global_item_ref() on it, | 531 | by calling ttm_global_item_ref() on it, |
532 | you need to create a buffer object TTM to | 532 | you need to create a buffer object TTM to |
533 | provide a pool for buffer object allocation by clients and the | 533 | provide a pool for buffer object allocation by clients and the |
534 | kernel itself. The type of this object should be TTM_GLOBAL_TTM_BO, | 534 | kernel itself. The type of this object should be TTM_GLOBAL_TTM_BO, |
535 | and its size should be sizeof(struct ttm_bo_global). Again, | 535 | and its size should be sizeof(struct ttm_bo_global). Again, |
536 | driver-specific init and release functions may be provided, | 536 | driver-specific init and release functions may be provided, |
537 | likely eventually calling ttm_bo_global_init() and | 537 | likely eventually calling ttm_bo_global_init() and |
538 | ttm_bo_global_release(), respectively. Also, like the previous | 538 | ttm_bo_global_release(), respectively. Also, like the previous |
539 | object, ttm_global_item_ref() is used to create an initial reference | 539 | object, ttm_global_item_ref() is used to create an initial reference |
540 | count for the TTM, which will call your initialization function. | 540 | count for the TTM, which will call your initialization function. |
541 | </para> | 541 | </para> |
542 | </sect3> | 542 | </sect3> |
543 | </sect2> | 543 | </sect2> |
544 | <sect2 id="drm-gem"> | 544 | <sect2 id="drm-gem"> |
@@ -566,19 +566,19 @@ char *date;</synopsis> | |||
566 | using driver-specific ioctls. | 566 | using driver-specific ioctls. |
567 | </para> | 567 | </para> |
568 | <para> | 568 | <para> |
569 | On a fundamental level, GEM involves several operations: | 569 | On a fundamental level, GEM involves several operations: |
570 | <itemizedlist> | 570 | <itemizedlist> |
571 | <listitem>Memory allocation and freeing</listitem> | 571 | <listitem>Memory allocation and freeing</listitem> |
572 | <listitem>Command execution</listitem> | 572 | <listitem>Command execution</listitem> |
573 | <listitem>Aperture management at command execution time</listitem> | 573 | <listitem>Aperture management at command execution time</listitem> |
574 | </itemizedlist> | 574 | </itemizedlist> |
575 | Buffer object allocation is relatively straightforward and largely | 575 | Buffer object allocation is relatively straightforward and largely |
576 | provided by Linux's shmem layer, which provides memory to back each | 576 | provided by Linux's shmem layer, which provides memory to back each |
577 | object. | 577 | object. |
578 | </para> | 578 | </para> |
579 | <para> | 579 | <para> |
580 | Device-specific operations, such as command execution, pinning, buffer | 580 | Device-specific operations, such as command execution, pinning, buffer |
581 | read & write, mapping, and domain ownership transfers are left to | 581 | read & write, mapping, and domain ownership transfers are left to |
582 | driver-specific ioctls. | 582 | driver-specific ioctls. |
583 | </para> | 583 | </para> |
584 | <sect3> | 584 | <sect3> |
@@ -738,16 +738,16 @@ char *date;</synopsis> | |||
738 | respectively. The conversion is handled by the DRM core without any | 738 | respectively. The conversion is handled by the DRM core without any |
739 | driver-specific support. | 739 | driver-specific support. |
740 | </para> | 740 | </para> |
741 | <para> | 741 | <para> |
742 | GEM also supports buffer sharing with dma-buf file descriptors through | 742 | GEM also supports buffer sharing with dma-buf file descriptors through |
743 | PRIME. GEM-based drivers must use the provided helpers functions to | 743 | PRIME. GEM-based drivers must use the provided helpers functions to |
744 | implement the exporting and importing correctly. See <xref linkend="drm-prime-support" />. | 744 | implement the exporting and importing correctly. See <xref linkend="drm-prime-support" />. |
745 | Since sharing file descriptors is inherently more secure than the | 745 | Since sharing file descriptors is inherently more secure than the |
746 | easily guessable and global GEM names it is the preferred buffer | 746 | easily guessable and global GEM names it is the preferred buffer |
747 | sharing mechanism. Sharing buffers through GEM names is only supported | 747 | sharing mechanism. Sharing buffers through GEM names is only supported |
748 | for legacy userspace. Furthermore PRIME also allows cross-device | 748 | for legacy userspace. Furthermore PRIME also allows cross-device |
749 | buffer sharing since it is based on dma-bufs. | 749 | buffer sharing since it is based on dma-bufs. |
750 | </para> | 750 | </para> |
751 | </sect3> | 751 | </sect3> |
752 | <sect3 id="drm-gem-objects-mapping"> | 752 | <sect3 id="drm-gem-objects-mapping"> |
753 | <title>GEM Objects Mapping</title> | 753 | <title>GEM Objects Mapping</title> |
@@ -852,7 +852,7 @@ char *date;</synopsis> | |||
852 | <sect3> | 852 | <sect3> |
853 | <title>Command Execution</title> | 853 | <title>Command Execution</title> |
854 | <para> | 854 | <para> |
855 | Perhaps the most important GEM function for GPU devices is providing a | 855 | Perhaps the most important GEM function for GPU devices is providing a |
856 | command execution interface to clients. Client programs construct | 856 | command execution interface to clients. Client programs construct |
857 | command buffers containing references to previously allocated memory | 857 | command buffers containing references to previously allocated memory |
858 | objects, and then submit them to GEM. At that point, GEM takes care to | 858 | objects, and then submit them to GEM. At that point, GEM takes care to |
@@ -874,95 +874,101 @@ char *date;</synopsis> | |||
874 | <title>GEM Function Reference</title> | 874 | <title>GEM Function Reference</title> |
875 | !Edrivers/gpu/drm/drm_gem.c | 875 | !Edrivers/gpu/drm/drm_gem.c |
876 | </sect3> | 876 | </sect3> |
877 | </sect2> | 877 | </sect2> |
878 | <sect2> | 878 | <sect2> |
879 | <title>VMA Offset Manager</title> | 879 | <title>VMA Offset Manager</title> |
880 | !Pdrivers/gpu/drm/drm_vma_manager.c vma offset manager | 880 | !Pdrivers/gpu/drm/drm_vma_manager.c vma offset manager |
881 | !Edrivers/gpu/drm/drm_vma_manager.c | 881 | !Edrivers/gpu/drm/drm_vma_manager.c |
882 | !Iinclude/drm/drm_vma_manager.h | 882 | !Iinclude/drm/drm_vma_manager.h |
883 | </sect2> | 883 | </sect2> |
884 | <sect2 id="drm-prime-support"> | 884 | <sect2 id="drm-prime-support"> |
885 | <title>PRIME Buffer Sharing</title> | 885 | <title>PRIME Buffer Sharing</title> |
886 | <para> | 886 | <para> |
887 | PRIME is the cross device buffer sharing framework in drm, originally | 887 | PRIME is the cross device buffer sharing framework in drm, originally |
888 | created for the OPTIMUS range of multi-gpu platforms. To userspace | 888 | created for the OPTIMUS range of multi-gpu platforms. To userspace |
889 | PRIME buffers are dma-buf based file descriptors. | 889 | PRIME buffers are dma-buf based file descriptors. |
890 | </para> | 890 | </para> |
891 | <sect3> | 891 | <sect3> |
892 | <title>Overview and Driver Interface</title> | 892 | <title>Overview and Driver Interface</title> |
893 | <para> | 893 | <para> |
894 | Similar to GEM global names, PRIME file descriptors are | 894 | Similar to GEM global names, PRIME file descriptors are |
895 | also used to share buffer objects across processes. They offer | 895 | also used to share buffer objects across processes. They offer |
896 | additional security: as file descriptors must be explicitly sent over | 896 | additional security: as file descriptors must be explicitly sent over |
897 | UNIX domain sockets to be shared between applications, they can't be | 897 | UNIX domain sockets to be shared between applications, they can't be |
898 | guessed like the globally unique GEM names. | 898 | guessed like the globally unique GEM names. |
899 | </para> | 899 | </para> |
900 | <para> | 900 | <para> |
901 | Drivers that support the PRIME | 901 | Drivers that support the PRIME |
902 | API must set the DRIVER_PRIME bit in the struct | 902 | API must set the DRIVER_PRIME bit in the struct |
903 | <structname>drm_driver</structname> | 903 | <structname>drm_driver</structname> |
904 | <structfield>driver_features</structfield> field, and implement the | 904 | <structfield>driver_features</structfield> field, and implement the |
905 | <methodname>prime_handle_to_fd</methodname> and | 905 | <methodname>prime_handle_to_fd</methodname> and |
906 | <methodname>prime_fd_to_handle</methodname> operations. | 906 | <methodname>prime_fd_to_handle</methodname> operations. |
907 | </para> | 907 | </para> |
908 | <para> | 908 | <para> |
909 | <synopsis>int (*prime_handle_to_fd)(struct drm_device *dev, | 909 | <synopsis>int (*prime_handle_to_fd)(struct drm_device *dev, |
910 | struct drm_file *file_priv, uint32_t handle, | 910 | struct drm_file *file_priv, uint32_t handle, |
911 | uint32_t flags, int *prime_fd); | 911 | uint32_t flags, int *prime_fd); |
912 | int (*prime_fd_to_handle)(struct drm_device *dev, | 912 | int (*prime_fd_to_handle)(struct drm_device *dev, |
913 | struct drm_file *file_priv, int prime_fd, | 913 | struct drm_file *file_priv, int prime_fd, |
914 | uint32_t *handle);</synopsis> | 914 | uint32_t *handle);</synopsis> |
915 | Those two operations convert a handle to a PRIME file descriptor and | 915 | Those two operations convert a handle to a PRIME file descriptor and |
916 | vice versa. Drivers must use the kernel dma-buf buffer sharing framework | 916 | vice versa. Drivers must use the kernel dma-buf buffer sharing framework |
917 | to manage the PRIME file descriptors. Similar to the mode setting | 917 | to manage the PRIME file descriptors. Similar to the mode setting |
918 | API PRIME is agnostic to the underlying buffer object manager, as | 918 | API PRIME is agnostic to the underlying buffer object manager, as |
919 | long as handles are 32bit unsigned integers. | 919 | long as handles are 32bit unsigned integers. |
920 | </para> | 920 | </para> |
921 | <para> | 921 | <para> |
922 | While non-GEM drivers must implement the operations themselves, GEM | 922 | While non-GEM drivers must implement the operations themselves, GEM |
923 | drivers must use the <function>drm_gem_prime_handle_to_fd</function> | 923 | drivers must use the <function>drm_gem_prime_handle_to_fd</function> |
924 | and <function>drm_gem_prime_fd_to_handle</function> helper functions. | 924 | and <function>drm_gem_prime_fd_to_handle</function> helper functions. |
925 | Those helpers rely on the driver | 925 | Those helpers rely on the driver |
926 | <methodname>gem_prime_export</methodname> and | 926 | <methodname>gem_prime_export</methodname> and |
927 | <methodname>gem_prime_import</methodname> operations to create a dma-buf | 927 | <methodname>gem_prime_import</methodname> operations to create a dma-buf |
928 | instance from a GEM object (dma-buf exporter role) and to create a GEM | 928 | instance from a GEM object (dma-buf exporter role) and to create a GEM |
929 | object from a dma-buf instance (dma-buf importer role). | 929 | object from a dma-buf instance (dma-buf importer role). |
930 | </para> | 930 | </para> |
931 | <para> | 931 | <para> |
932 | <synopsis>struct dma_buf * (*gem_prime_export)(struct drm_device *dev, | 932 | <synopsis>struct dma_buf * (*gem_prime_export)(struct drm_device *dev, |
933 | struct drm_gem_object *obj, | 933 | struct drm_gem_object *obj, |
934 | int flags); | 934 | int flags); |
935 | struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, | 935 | struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, |
936 | struct dma_buf *dma_buf);</synopsis> | 936 | struct dma_buf *dma_buf);</synopsis> |
937 | These two operations are mandatory for GEM drivers that support | 937 | These two operations are mandatory for GEM drivers that support |
938 | PRIME. | 938 | PRIME. |
939 | </para> | 939 | </para> |
940 | </sect3> | ||
941 | <sect3> | ||
942 | <title>PRIME Helper Functions</title> | ||
943 | !Pdrivers/gpu/drm/drm_prime.c PRIME Helpers | ||
944 | </sect3> | 940 | </sect3> |
945 | </sect2> | 941 | <sect3> |
946 | <sect2> | 942 | <title>PRIME Helper Functions</title> |
947 | <title>PRIME Function References</title> | 943 | !Pdrivers/gpu/drm/drm_prime.c PRIME Helpers |
944 | </sect3> | ||
945 | </sect2> | ||
946 | <sect2> | ||
947 | <title>PRIME Function References</title> | ||
948 | !Edrivers/gpu/drm/drm_prime.c | 948 | !Edrivers/gpu/drm/drm_prime.c |
949 | </sect2> | 949 | </sect2> |
950 | <sect2> | 950 | <sect2> |
951 | <title>DRM MM Range Allocator</title> | 951 | <title>DRM MM Range Allocator</title> |
952 | <sect3> | 952 | <sect3> |
953 | <title>Overview</title> | 953 | <title>Overview</title> |
954 | !Pdrivers/gpu/drm/drm_mm.c Overview | 954 | !Pdrivers/gpu/drm/drm_mm.c Overview |
955 | </sect3> | 955 | </sect3> |
956 | <sect3> | 956 | <sect3> |
957 | <title>LRU Scan/Eviction Support</title> | 957 | <title>LRU Scan/Eviction Support</title> |
958 | !Pdrivers/gpu/drm/drm_mm.c lru scan roaster | 958 | !Pdrivers/gpu/drm/drm_mm.c lru scan roaster |
959 | </sect3> | 959 | </sect3> |
960 | </sect2> | 960 | </sect2> |
961 | <sect2> | 961 | <sect2> |
962 | <title>DRM MM Range Allocator Function References</title> | 962 | <title>DRM MM Range Allocator Function References</title> |
963 | !Edrivers/gpu/drm/drm_mm.c | 963 | !Edrivers/gpu/drm/drm_mm.c |
964 | !Iinclude/drm/drm_mm.h | 964 | !Iinclude/drm/drm_mm.h |
965 | </sect2> | 965 | </sect2> |
966 | <sect2> | ||
967 | <title>CMA Helper Functions Reference</title> | ||
968 | !Pdrivers/gpu/drm/drm_gem_cma_helper.c cma helpers | ||
969 | !Edrivers/gpu/drm/drm_gem_cma_helper.c | ||
970 | !Iinclude/drm/drm_gem_cma_helper.h | ||
971 | </sect2> | ||
966 | </sect1> | 972 | </sect1> |
967 | 973 | ||
968 | <!-- Internals: mode setting --> | 974 | <!-- Internals: mode setting --> |
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 15f8b3bfd1ee..56737e74b59d 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -4774,6 +4774,16 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev, | |||
4774 | if (PAGE_ALIGN(size) == 0) | 4774 | if (PAGE_ALIGN(size) == 0) |
4775 | return -EINVAL; | 4775 | return -EINVAL; |
4776 | 4776 | ||
4777 | /* | ||
4778 | * handle, pitch and size are output parameters. Zero them out to | ||
4779 | * prevent drivers from accidentally using uninitialized data. Since | ||
4780 | * not all existing userspace is clearing these fields properly we | ||
4781 | * cannot reject IOCTL with garbage in them. | ||
4782 | */ | ||
4783 | args->handle = 0; | ||
4784 | args->pitch = 0; | ||
4785 | args->size = 0; | ||
4786 | |||
4777 | return dev->driver->dumb_create(file_priv, dev, args); | 4787 | return dev->driver->dumb_create(file_priv, dev, args); |
4778 | } | 4788 | } |
4779 | 4789 | ||
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 973a9b6644d4..16a164770713 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c | |||
@@ -309,7 +309,7 @@ EXPORT_SYMBOL(drm_gem_dumb_destroy); | |||
309 | * drm_gem_handle_create_tail - internal functions to create a handle | 309 | * drm_gem_handle_create_tail - internal functions to create a handle |
310 | * @file_priv: drm file-private structure to register the handle for | 310 | * @file_priv: drm file-private structure to register the handle for |
311 | * @obj: object to register | 311 | * @obj: object to register |
312 | * @handlep: pionter to return the created handle to the caller | 312 | * @handlep: pointer to return the created handle to the caller |
313 | * | 313 | * |
314 | * This expects the dev->object_name_lock to be held already and will drop it | 314 | * This expects the dev->object_name_lock to be held already and will drop it |
315 | * before returning. Used to avoid races in establishing new handles when | 315 | * before returning. Used to avoid races in establishing new handles when |
@@ -362,7 +362,7 @@ drm_gem_handle_create_tail(struct drm_file *file_priv, | |||
362 | } | 362 | } |
363 | 363 | ||
364 | /** | 364 | /** |
365 | * gem_handle_create - create a gem handle for an object | 365 | * drm_gem_handle_create - create a gem handle for an object |
366 | * @file_priv: drm file-private structure to register the handle for | 366 | * @file_priv: drm file-private structure to register the handle for |
367 | * @obj: object to register | 367 | * @obj: object to register |
368 | * @handlep: pionter to return the created handle to the caller | 368 | * @handlep: pionter to return the created handle to the caller |
@@ -371,10 +371,9 @@ drm_gem_handle_create_tail(struct drm_file *file_priv, | |||
371 | * to the object, which includes a regular reference count. Callers | 371 | * to the object, which includes a regular reference count. Callers |
372 | * will likely want to dereference the object afterwards. | 372 | * will likely want to dereference the object afterwards. |
373 | */ | 373 | */ |
374 | int | 374 | int drm_gem_handle_create(struct drm_file *file_priv, |
375 | drm_gem_handle_create(struct drm_file *file_priv, | 375 | struct drm_gem_object *obj, |
376 | struct drm_gem_object *obj, | 376 | u32 *handlep) |
377 | u32 *handlep) | ||
378 | { | 377 | { |
379 | mutex_lock(&obj->dev->object_name_lock); | 378 | mutex_lock(&obj->dev->object_name_lock); |
380 | 379 | ||
diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index 0316310e2cc4..e419eedf751d 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c | |||
@@ -29,18 +29,31 @@ | |||
29 | #include <drm/drm_gem_cma_helper.h> | 29 | #include <drm/drm_gem_cma_helper.h> |
30 | #include <drm/drm_vma_manager.h> | 30 | #include <drm/drm_vma_manager.h> |
31 | 31 | ||
32 | /* | 32 | /** |
33 | * DOC: cma helpers | ||
34 | * | ||
35 | * The Contiguous Memory Allocator reserves a pool of memory at early boot | ||
36 | * that is used to service requests for large blocks of contiguous memory. | ||
37 | * | ||
38 | * The DRM GEM/CMA helpers use this allocator as a means to provide buffer | ||
39 | * objects that are physically contiguous in memory. This is useful for | ||
40 | * display drivers that are unable to map scattered buffers via an IOMMU. | ||
41 | */ | ||
42 | |||
43 | /** | ||
33 | * __drm_gem_cma_create - Create a GEM CMA object without allocating memory | 44 | * __drm_gem_cma_create - Create a GEM CMA object without allocating memory |
34 | * @drm: The drm device | 45 | * @drm: DRM device |
35 | * @size: The GEM object size | 46 | * @size: size of the object to allocate |
36 | * | 47 | * |
37 | * This function creates and initializes a GEM CMA object of the given size, but | 48 | * This function creates and initializes a GEM CMA object of the given size, |
38 | * doesn't allocate any memory to back the object. | 49 | * but doesn't allocate any memory to back the object. |
39 | * | 50 | * |
40 | * Return a struct drm_gem_cma_object* on success or ERR_PTR values on failure. | 51 | * Returns: |
52 | * A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative | ||
53 | * error code on failure. | ||
41 | */ | 54 | */ |
42 | static struct drm_gem_cma_object * | 55 | static struct drm_gem_cma_object * |
43 | __drm_gem_cma_create(struct drm_device *drm, unsigned int size) | 56 | __drm_gem_cma_create(struct drm_device *drm, size_t size) |
44 | { | 57 | { |
45 | struct drm_gem_cma_object *cma_obj; | 58 | struct drm_gem_cma_object *cma_obj; |
46 | struct drm_gem_object *gem_obj; | 59 | struct drm_gem_object *gem_obj; |
@@ -69,14 +82,21 @@ error: | |||
69 | return ERR_PTR(ret); | 82 | return ERR_PTR(ret); |
70 | } | 83 | } |
71 | 84 | ||
72 | /* | 85 | /** |
73 | * drm_gem_cma_create - allocate an object with the given size | 86 | * drm_gem_cma_create - allocate an object with the given size |
87 | * @drm: DRM device | ||
88 | * @size: size of the object to allocate | ||
89 | * | ||
90 | * This function creates a CMA GEM object and allocates a contiguous chunk of | ||
91 | * memory as backing store. The backing memory has the writecombine attribute | ||
92 | * set. | ||
74 | * | 93 | * |
75 | * returns a struct drm_gem_cma_object* on success or ERR_PTR values | 94 | * Returns: |
76 | * on failure. | 95 | * A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative |
96 | * error code on failure. | ||
77 | */ | 97 | */ |
78 | struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, | 98 | struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, |
79 | unsigned int size) | 99 | size_t size) |
80 | { | 100 | { |
81 | struct drm_gem_cma_object *cma_obj; | 101 | struct drm_gem_cma_object *cma_obj; |
82 | int ret; | 102 | int ret; |
@@ -104,17 +124,26 @@ error: | |||
104 | } | 124 | } |
105 | EXPORT_SYMBOL_GPL(drm_gem_cma_create); | 125 | EXPORT_SYMBOL_GPL(drm_gem_cma_create); |
106 | 126 | ||
107 | /* | 127 | /** |
108 | * drm_gem_cma_create_with_handle - allocate an object with the given | 128 | * drm_gem_cma_create_with_handle - allocate an object with the given size and |
109 | * size and create a gem handle on it | 129 | * return a GEM handle to it |
130 | * @file_priv: DRM file-private structure to register the handle for | ||
131 | * @drm: DRM device | ||
132 | * @size: size of the object to allocate | ||
133 | * @handle: return location for the GEM handle | ||
134 | * | ||
135 | * This function creates a CMA GEM object, allocating a physically contiguous | ||
136 | * chunk of memory as backing store. The GEM object is then added to the list | ||
137 | * of object associated with the given file and a handle to it is returned. | ||
110 | * | 138 | * |
111 | * returns a struct drm_gem_cma_object* on success or ERR_PTR values | 139 | * Returns: |
112 | * on failure. | 140 | * A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative |
141 | * error code on failure. | ||
113 | */ | 142 | */ |
114 | static struct drm_gem_cma_object *drm_gem_cma_create_with_handle( | 143 | static struct drm_gem_cma_object * |
115 | struct drm_file *file_priv, | 144 | drm_gem_cma_create_with_handle(struct drm_file *file_priv, |
116 | struct drm_device *drm, unsigned int size, | 145 | struct drm_device *drm, size_t size, |
117 | unsigned int *handle) | 146 | uint32_t *handle) |
118 | { | 147 | { |
119 | struct drm_gem_cma_object *cma_obj; | 148 | struct drm_gem_cma_object *cma_obj; |
120 | struct drm_gem_object *gem_obj; | 149 | struct drm_gem_object *gem_obj; |
@@ -145,16 +174,19 @@ err_handle_create: | |||
145 | return ERR_PTR(ret); | 174 | return ERR_PTR(ret); |
146 | } | 175 | } |
147 | 176 | ||
148 | /* | 177 | /** |
149 | * drm_gem_cma_free_object - (struct drm_driver)->gem_free_object callback | 178 | * drm_gem_cma_free_object - free resources associated with a CMA GEM object |
150 | * function | 179 | * @gem_obj: GEM object to free |
180 | * | ||
181 | * This function frees the backing memory of the CMA GEM object, cleans up the | ||
182 | * GEM object state and frees the memory used to store the object itself. | ||
183 | * Drivers using the CMA helpers should set this as their DRM driver's | ||
184 | * ->gem_free_object() callback. | ||
151 | */ | 185 | */ |
152 | void drm_gem_cma_free_object(struct drm_gem_object *gem_obj) | 186 | void drm_gem_cma_free_object(struct drm_gem_object *gem_obj) |
153 | { | 187 | { |
154 | struct drm_gem_cma_object *cma_obj; | 188 | struct drm_gem_cma_object *cma_obj; |
155 | 189 | ||
156 | drm_gem_free_mmap_offset(gem_obj); | ||
157 | |||
158 | cma_obj = to_drm_gem_cma_obj(gem_obj); | 190 | cma_obj = to_drm_gem_cma_obj(gem_obj); |
159 | 191 | ||
160 | if (cma_obj->vaddr) { | 192 | if (cma_obj->vaddr) { |
@@ -170,18 +202,26 @@ void drm_gem_cma_free_object(struct drm_gem_object *gem_obj) | |||
170 | } | 202 | } |
171 | EXPORT_SYMBOL_GPL(drm_gem_cma_free_object); | 203 | EXPORT_SYMBOL_GPL(drm_gem_cma_free_object); |
172 | 204 | ||
173 | /* | 205 | /** |
174 | * drm_gem_cma_dumb_create - (struct drm_driver)->dumb_create callback | 206 | * drm_gem_cma_dumb_create_internal - create a dumb buffer object |
175 | * function | 207 | * @file_priv: DRM file-private structure to create the dumb buffer for |
208 | * @drm: DRM device | ||
209 | * @args: IOCTL data | ||
210 | * | ||
211 | * This aligns the pitch and size arguments to the minimum required. This is | ||
212 | * an internal helper that can be wrapped by a driver to account for hardware | ||
213 | * with more specific alignment requirements. It should not be used directly | ||
214 | * as the ->dumb_create() callback in a DRM driver. | ||
176 | * | 215 | * |
177 | * This aligns the pitch and size arguments to the minimum required. wrap | 216 | * Returns: |
178 | * this into your own function if you need bigger alignment. | 217 | * 0 on success or a negative error code on failure. |
179 | */ | 218 | */ |
180 | int drm_gem_cma_dumb_create(struct drm_file *file_priv, | 219 | int drm_gem_cma_dumb_create_internal(struct drm_file *file_priv, |
181 | struct drm_device *dev, struct drm_mode_create_dumb *args) | 220 | struct drm_device *drm, |
221 | struct drm_mode_create_dumb *args) | ||
182 | { | 222 | { |
223 | unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8); | ||
183 | struct drm_gem_cma_object *cma_obj; | 224 | struct drm_gem_cma_object *cma_obj; |
184 | int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8); | ||
185 | 225 | ||
186 | if (args->pitch < min_pitch) | 226 | if (args->pitch < min_pitch) |
187 | args->pitch = min_pitch; | 227 | args->pitch = min_pitch; |
@@ -189,18 +229,63 @@ int drm_gem_cma_dumb_create(struct drm_file *file_priv, | |||
189 | if (args->size < args->pitch * args->height) | 229 | if (args->size < args->pitch * args->height) |
190 | args->size = args->pitch * args->height; | 230 | args->size = args->pitch * args->height; |
191 | 231 | ||
192 | cma_obj = drm_gem_cma_create_with_handle(file_priv, dev, | 232 | cma_obj = drm_gem_cma_create_with_handle(file_priv, drm, args->size, |
193 | args->size, &args->handle); | 233 | &args->handle); |
234 | return PTR_ERR_OR_ZERO(cma_obj); | ||
235 | } | ||
236 | EXPORT_SYMBOL_GPL(drm_gem_cma_dumb_create_internal); | ||
237 | |||
238 | /** | ||
239 | * drm_gem_cma_dumb_create - create a dumb buffer object | ||
240 | * @file_priv: DRM file-private structure to create the dumb buffer for | ||
241 | * @drm: DRM device | ||
242 | * @args: IOCTL data | ||
243 | * | ||
244 | * This function computes the pitch of the dumb buffer and rounds it up to an | ||
245 | * integer number of bytes per pixel. Drivers for hardware that doesn't have | ||
246 | * any additional restrictions on the pitch can directly use this function as | ||
247 | * their ->dumb_create() callback. | ||
248 | * | ||
249 | * For hardware with additional restrictions, drivers can adjust the fields | ||
250 | * set up by userspace and pass the IOCTL data along to the | ||
251 | * drm_gem_cma_dumb_create_internal() function. | ||
252 | * | ||
253 | * Returns: | ||
254 | * 0 on success or a negative error code on failure. | ||
255 | */ | ||
256 | int drm_gem_cma_dumb_create(struct drm_file *file_priv, | ||
257 | struct drm_device *drm, | ||
258 | struct drm_mode_create_dumb *args) | ||
259 | { | ||
260 | struct drm_gem_cma_object *cma_obj; | ||
261 | |||
262 | args->pitch = DIV_ROUND_UP(args->width * args->bpp, 8); | ||
263 | args->size = args->pitch * args->height; | ||
264 | |||
265 | cma_obj = drm_gem_cma_create_with_handle(file_priv, drm, args->size, | ||
266 | &args->handle); | ||
194 | return PTR_ERR_OR_ZERO(cma_obj); | 267 | return PTR_ERR_OR_ZERO(cma_obj); |
195 | } | 268 | } |
196 | EXPORT_SYMBOL_GPL(drm_gem_cma_dumb_create); | 269 | EXPORT_SYMBOL_GPL(drm_gem_cma_dumb_create); |
197 | 270 | ||
198 | /* | 271 | /** |
199 | * drm_gem_cma_dumb_map_offset - (struct drm_driver)->dumb_map_offset callback | 272 | * drm_gem_cma_dumb_map_offset - return the fake mmap offset for a CMA GEM |
200 | * function | 273 | * object |
274 | * @file_priv: DRM file-private structure containing the GEM object | ||
275 | * @drm: DRM device | ||
276 | * @handle: GEM object handle | ||
277 | * @offset: return location for the fake mmap offset | ||
278 | * | ||
279 | * This function look up an object by its handle and returns the fake mmap | ||
280 | * offset associated with it. Drivers using the CMA helpers should set this | ||
281 | * as their DRM driver's ->dumb_map_offset() callback. | ||
282 | * | ||
283 | * Returns: | ||
284 | * 0 on success or a negative error code on failure. | ||
201 | */ | 285 | */ |
202 | int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv, | 286 | int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv, |
203 | struct drm_device *drm, uint32_t handle, uint64_t *offset) | 287 | struct drm_device *drm, u32 handle, |
288 | u64 *offset) | ||
204 | { | 289 | { |
205 | struct drm_gem_object *gem_obj; | 290 | struct drm_gem_object *gem_obj; |
206 | 291 | ||
@@ -208,7 +293,7 @@ int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv, | |||
208 | 293 | ||
209 | gem_obj = drm_gem_object_lookup(drm, file_priv, handle); | 294 | gem_obj = drm_gem_object_lookup(drm, file_priv, handle); |
210 | if (!gem_obj) { | 295 | if (!gem_obj) { |
211 | dev_err(drm->dev, "failed to lookup gem object\n"); | 296 | dev_err(drm->dev, "failed to lookup GEM object\n"); |
212 | mutex_unlock(&drm->struct_mutex); | 297 | mutex_unlock(&drm->struct_mutex); |
213 | return -EINVAL; | 298 | return -EINVAL; |
214 | } | 299 | } |
@@ -251,8 +336,20 @@ static int drm_gem_cma_mmap_obj(struct drm_gem_cma_object *cma_obj, | |||
251 | return ret; | 336 | return ret; |
252 | } | 337 | } |
253 | 338 | ||
254 | /* | 339 | /** |
255 | * drm_gem_cma_mmap - (struct file_operation)->mmap callback function | 340 | * drm_gem_cma_mmap - memory-map a CMA GEM object |
341 | * @filp: file object | ||
342 | * @vma: VMA for the area to be mapped | ||
343 | * | ||
344 | * This function implements an augmented version of the GEM DRM file mmap | ||
345 | * operation for CMA objects: In addition to the usual GEM VMA setup it | ||
346 | * immediately faults in the entire object instead of using on-demaind | ||
347 | * faulting. Drivers which employ the CMA helpers should use this function | ||
348 | * as their ->mmap() handler in the DRM device file's file_operations | ||
349 | * structure. | ||
350 | * | ||
351 | * Returns: | ||
352 | * 0 on success or a negative error code on failure. | ||
256 | */ | 353 | */ |
257 | int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma) | 354 | int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma) |
258 | { | 355 | { |
@@ -272,7 +369,16 @@ int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma) | |||
272 | EXPORT_SYMBOL_GPL(drm_gem_cma_mmap); | 369 | EXPORT_SYMBOL_GPL(drm_gem_cma_mmap); |
273 | 370 | ||
274 | #ifdef CONFIG_DEBUG_FS | 371 | #ifdef CONFIG_DEBUG_FS |
275 | void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj, struct seq_file *m) | 372 | /** |
373 | * drm_gem_cma_describe - describe a CMA GEM object for debugfs | ||
374 | * @cma_obj: CMA GEM object | ||
375 | * @m: debugfs file handle | ||
376 | * | ||
377 | * This function can be used to dump a human-readable representation of the | ||
378 | * CMA GEM object into a synthetic file. | ||
379 | */ | ||
380 | void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj, | ||
381 | struct seq_file *m) | ||
276 | { | 382 | { |
277 | struct drm_gem_object *obj = &cma_obj->base; | 383 | struct drm_gem_object *obj = &cma_obj->base; |
278 | struct drm_device *dev = obj->dev; | 384 | struct drm_device *dev = obj->dev; |
@@ -291,7 +397,18 @@ void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj, struct seq_file *m | |||
291 | EXPORT_SYMBOL_GPL(drm_gem_cma_describe); | 397 | EXPORT_SYMBOL_GPL(drm_gem_cma_describe); |
292 | #endif | 398 | #endif |
293 | 399 | ||
294 | /* low-level interface prime helpers */ | 400 | /** |
401 | * drm_gem_cma_prime_get_sg_table - provide a scatter/gather table of pinned | ||
402 | * pages for a CMA GEM object | ||
403 | * @obj: GEM object | ||
404 | * | ||
405 | * This function exports a scatter/gather table suitable for PRIME usage by | ||
406 | * calling the standard DMA mapping API. Drivers using the CMA helpers should | ||
407 | * set this as their DRM driver's ->gem_prime_get_sg_table() callback. | ||
408 | * | ||
409 | * Returns: | ||
410 | * A pointer to the scatter/gather table of pinned pages or NULL on failure. | ||
411 | */ | ||
295 | struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj) | 412 | struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj) |
296 | { | 413 | { |
297 | struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj); | 414 | struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj); |
@@ -315,6 +432,23 @@ out: | |||
315 | } | 432 | } |
316 | EXPORT_SYMBOL_GPL(drm_gem_cma_prime_get_sg_table); | 433 | EXPORT_SYMBOL_GPL(drm_gem_cma_prime_get_sg_table); |
317 | 434 | ||
435 | /** | ||
436 | * drm_gem_cma_prime_import_sg_table - produce a CMA GEM object from another | ||
437 | * driver's scatter/gather table of pinned pages | ||
438 | * @dev: device to import into | ||
439 | * @attach: DMA-BUF attachment | ||
440 | * @sgt: scatter/gather table of pinned pages | ||
441 | * | ||
442 | * This function imports a scatter/gather table exported via DMA-BUF by | ||
443 | * another driver. Imported buffers must be physically contiguous in memory | ||
444 | * (i.e. the scatter/gather table must contain a single entry). Drivers that | ||
445 | * use the CMA helpers should set this as their DRM driver's | ||
446 | * ->gem_prime_import_sg_table() callback. | ||
447 | * | ||
448 | * Returns: | ||
449 | * A pointer to a newly created GEM object or an ERR_PTR-encoded negative | ||
450 | * error code on failure. | ||
451 | */ | ||
318 | struct drm_gem_object * | 452 | struct drm_gem_object * |
319 | drm_gem_cma_prime_import_sg_table(struct drm_device *dev, | 453 | drm_gem_cma_prime_import_sg_table(struct drm_device *dev, |
320 | struct dma_buf_attachment *attach, | 454 | struct dma_buf_attachment *attach, |
@@ -339,6 +473,18 @@ drm_gem_cma_prime_import_sg_table(struct drm_device *dev, | |||
339 | } | 473 | } |
340 | EXPORT_SYMBOL_GPL(drm_gem_cma_prime_import_sg_table); | 474 | EXPORT_SYMBOL_GPL(drm_gem_cma_prime_import_sg_table); |
341 | 475 | ||
476 | /** | ||
477 | * drm_gem_cma_prime_mmap - memory-map an exported CMA GEM object | ||
478 | * @obj: GEM object | ||
479 | * @vma: VMA for the area to be mapped | ||
480 | * | ||
481 | * This function maps a buffer imported via DRM PRIME into a userspace | ||
482 | * process's address space. Drivers that use the CMA helpers should set this | ||
483 | * as their DRM driver's ->gem_prime_mmap() callback. | ||
484 | * | ||
485 | * Returns: | ||
486 | * 0 on success or a negative error code on failure. | ||
487 | */ | ||
342 | int drm_gem_cma_prime_mmap(struct drm_gem_object *obj, | 488 | int drm_gem_cma_prime_mmap(struct drm_gem_object *obj, |
343 | struct vm_area_struct *vma) | 489 | struct vm_area_struct *vma) |
344 | { | 490 | { |
@@ -357,6 +503,20 @@ int drm_gem_cma_prime_mmap(struct drm_gem_object *obj, | |||
357 | } | 503 | } |
358 | EXPORT_SYMBOL_GPL(drm_gem_cma_prime_mmap); | 504 | EXPORT_SYMBOL_GPL(drm_gem_cma_prime_mmap); |
359 | 505 | ||
506 | /** | ||
507 | * drm_gem_cma_prime_vmap - map a CMA GEM object into the kernel's virtual | ||
508 | * address space | ||
509 | * @obj: GEM object | ||
510 | * | ||
511 | * This function maps a buffer exported via DRM PRIME into the kernel's | ||
512 | * virtual address space. Since the CMA buffers are already mapped into the | ||
513 | * kernel virtual address space this simply returns the cached virtual | ||
514 | * address. Drivers using the CMA helpers should set this as their DRM | ||
515 | * driver's ->gem_prime_vmap() callback. | ||
516 | * | ||
517 | * Returns: | ||
518 | * The kernel virtual address of the CMA GEM object's backing store. | ||
519 | */ | ||
360 | void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj) | 520 | void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj) |
361 | { | 521 | { |
362 | struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj); | 522 | struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj); |
@@ -365,6 +525,17 @@ void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj) | |||
365 | } | 525 | } |
366 | EXPORT_SYMBOL_GPL(drm_gem_cma_prime_vmap); | 526 | EXPORT_SYMBOL_GPL(drm_gem_cma_prime_vmap); |
367 | 527 | ||
528 | /** | ||
529 | * drm_gem_cma_prime_vunmap - unmap a CMA GEM object from the kernel's virtual | ||
530 | * address space | ||
531 | * @obj: GEM object | ||
532 | * @vaddr: kernel virtual address where the CMA GEM object was mapped | ||
533 | * | ||
534 | * This function removes a buffer exported via DRM PRIME from the kernel's | ||
535 | * virtual address space. This is a no-op because CMA buffers cannot be | ||
536 | * unmapped from kernel space. Drivers using the CMA helpers should set this | ||
537 | * as their DRM driver's ->gem_prime_vunmap() callback. | ||
538 | */ | ||
368 | void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr) | 539 | void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr) |
369 | { | 540 | { |
370 | /* Nothing to do */ | 541 | /* Nothing to do */ |
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index e4849413ee80..aeb91ed653c9 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c | |||
@@ -612,8 +612,7 @@ int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev, | |||
612 | { | 612 | { |
613 | union omap_gem_size gsize; | 613 | union omap_gem_size gsize; |
614 | 614 | ||
615 | /* in case someone tries to feed us a completely bogus stride: */ | 615 | args->pitch = align_pitch(0, args->width, args->bpp); |
616 | args->pitch = align_pitch(args->pitch, args->width, args->bpp); | ||
617 | args->size = PAGE_ALIGN(args->pitch * args->height); | 616 | args->size = PAGE_ALIGN(args->pitch * args->height); |
618 | 617 | ||
619 | gsize = (union omap_gem_size){ | 618 | gsize = (union omap_gem_size){ |
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 6c24ad7d03ef..6289e3797bc5 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c | |||
@@ -126,9 +126,9 @@ int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, | |||
126 | else | 126 | else |
127 | align = 16 * args->bpp / 8; | 127 | align = 16 * args->bpp / 8; |
128 | 128 | ||
129 | args->pitch = roundup(max(args->pitch, min_pitch), align); | 129 | args->pitch = roundup(min_pitch, align); |
130 | 130 | ||
131 | return drm_gem_cma_dumb_create(file, dev, args); | 131 | return drm_gem_cma_dumb_create_internal(file, dev, args); |
132 | } | 132 | } |
133 | 133 | ||
134 | static struct drm_framebuffer * | 134 | static struct drm_framebuffer * |
diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h index 2ff35f3de9c5..acd6af8a8e67 100644 --- a/include/drm/drm_gem_cma_helper.h +++ b/include/drm/drm_gem_cma_helper.h | |||
@@ -4,6 +4,13 @@ | |||
4 | #include <drm/drmP.h> | 4 | #include <drm/drmP.h> |
5 | #include <drm/drm_gem.h> | 5 | #include <drm/drm_gem.h> |
6 | 6 | ||
7 | /** | ||
8 | * struct drm_gem_cma_object - GEM object backed by CMA memory allocations | ||
9 | * @base: base GEM object | ||
10 | * @paddr: physical address of the backing memory | ||
11 | * @sgt: scatter/gather table for imported PRIME buffers | ||
12 | * @vaddr: kernel virtual address of the backing memory | ||
13 | */ | ||
7 | struct drm_gem_cma_object { | 14 | struct drm_gem_cma_object { |
8 | struct drm_gem_object base; | 15 | struct drm_gem_object base; |
9 | dma_addr_t paddr; | 16 | dma_addr_t paddr; |
@@ -19,23 +26,30 @@ to_drm_gem_cma_obj(struct drm_gem_object *gem_obj) | |||
19 | return container_of(gem_obj, struct drm_gem_cma_object, base); | 26 | return container_of(gem_obj, struct drm_gem_cma_object, base); |
20 | } | 27 | } |
21 | 28 | ||
22 | /* free gem object. */ | 29 | /* free GEM object */ |
23 | void drm_gem_cma_free_object(struct drm_gem_object *gem_obj); | 30 | void drm_gem_cma_free_object(struct drm_gem_object *gem_obj); |
24 | 31 | ||
25 | /* create memory region for drm framebuffer. */ | 32 | /* create memory region for DRM framebuffer */ |
33 | int drm_gem_cma_dumb_create_internal(struct drm_file *file_priv, | ||
34 | struct drm_device *drm, | ||
35 | struct drm_mode_create_dumb *args); | ||
36 | |||
37 | /* create memory region for DRM framebuffer */ | ||
26 | int drm_gem_cma_dumb_create(struct drm_file *file_priv, | 38 | int drm_gem_cma_dumb_create(struct drm_file *file_priv, |
27 | struct drm_device *drm, struct drm_mode_create_dumb *args); | 39 | struct drm_device *drm, |
40 | struct drm_mode_create_dumb *args); | ||
28 | 41 | ||
29 | /* map memory region for drm framebuffer to user space. */ | 42 | /* map memory region for DRM framebuffer to user space */ |
30 | int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv, | 43 | int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv, |
31 | struct drm_device *drm, uint32_t handle, uint64_t *offset); | 44 | struct drm_device *drm, u32 handle, |
45 | u64 *offset); | ||
32 | 46 | ||
33 | /* set vm_flags and we can change the vm attribute to other one at here. */ | 47 | /* set vm_flags and we can change the VM attribute to other one at here */ |
34 | int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma); | 48 | int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma); |
35 | 49 | ||
36 | /* allocate physical memory. */ | 50 | /* allocate physical memory */ |
37 | struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, | 51 | struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, |
38 | unsigned int size); | 52 | size_t size); |
39 | 53 | ||
40 | extern const struct vm_operations_struct drm_gem_cma_vm_ops; | 54 | extern const struct vm_operations_struct drm_gem_cma_vm_ops; |
41 | 55 | ||