diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/DocBook/drm.tmpl | 274 |
1 files changed, 140 insertions, 134 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 --> |