diff options
-rw-r--r-- | Documentation/DocBook/drm.tmpl | 125 |
1 files changed, 74 insertions, 51 deletions
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 0e0390ece122..641db5cb656c 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl | |||
@@ -697,55 +697,16 @@ char *date;</synopsis> | |||
697 | respectively. The conversion is handled by the DRM core without any | 697 | respectively. The conversion is handled by the DRM core without any |
698 | driver-specific support. | 698 | driver-specific support. |
699 | </para> | 699 | </para> |
700 | <para> | 700 | <para> |
701 | Similar to global names, GEM file descriptors are also used to share GEM | 701 | GEM also supports buffer sharing with dma-buf file descriptors through |
702 | objects across processes. They offer additional security: as file | 702 | PRIME. GEM-based drivers must use the provided helpers functions to |
703 | descriptors must be explicitly sent over UNIX domain sockets to be shared | 703 | implement the exporting and importing correctly. See <xref linkend="drm-prime-support" />. |
704 | between applications, they can't be guessed like the globally unique GEM | 704 | Since sharing file descriptors is inherently more secure than the |
705 | names. | 705 | easily guessable and global GEM names it is the preferred buffer |
706 | </para> | 706 | sharing mechanism. Sharing buffers through GEM names is only supported |
707 | <para> | 707 | for legacy userspace. Furthermore PRIME also allows cross-device |
708 | Drivers that support GEM file descriptors, also known as the DRM PRIME | 708 | buffer sharing since it is based on dma-bufs. |
709 | API, must set the DRIVER_PRIME bit in the struct | 709 | </para> |
710 | <structname>drm_driver</structname> | ||
711 | <structfield>driver_features</structfield> field, and implement the | ||
712 | <methodname>prime_handle_to_fd</methodname> and | ||
713 | <methodname>prime_fd_to_handle</methodname> operations. | ||
714 | </para> | ||
715 | <para> | ||
716 | <synopsis>int (*prime_handle_to_fd)(struct drm_device *dev, | ||
717 | struct drm_file *file_priv, uint32_t handle, | ||
718 | uint32_t flags, int *prime_fd); | ||
719 | int (*prime_fd_to_handle)(struct drm_device *dev, | ||
720 | struct drm_file *file_priv, int prime_fd, | ||
721 | uint32_t *handle);</synopsis> | ||
722 | Those two operations convert a handle to a PRIME file descriptor and | ||
723 | vice versa. Drivers must use the kernel dma-buf buffer sharing framework | ||
724 | to manage the PRIME file descriptors. | ||
725 | </para> | ||
726 | <para> | ||
727 | While non-GEM drivers must implement the operations themselves, GEM | ||
728 | drivers must use the <function>drm_gem_prime_handle_to_fd</function> | ||
729 | and <function>drm_gem_prime_fd_to_handle</function> helper functions. | ||
730 | Those helpers rely on the driver | ||
731 | <methodname>gem_prime_export</methodname> and | ||
732 | <methodname>gem_prime_import</methodname> operations to create a dma-buf | ||
733 | instance from a GEM object (dma-buf exporter role) and to create a GEM | ||
734 | object from a dma-buf instance (dma-buf importer role). | ||
735 | </para> | ||
736 | <para> | ||
737 | <synopsis>struct dma_buf * (*gem_prime_export)(struct drm_device *dev, | ||
738 | struct drm_gem_object *obj, | ||
739 | int flags); | ||
740 | struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, | ||
741 | struct dma_buf *dma_buf);</synopsis> | ||
742 | These two operations are mandatory for GEM drivers that support DRM | ||
743 | PRIME. | ||
744 | </para> | ||
745 | <sect4> | ||
746 | <title>DRM PRIME Helper Functions Reference</title> | ||
747 | !Pdrivers/gpu/drm/drm_prime.c PRIME Helpers | ||
748 | </sect4> | ||
749 | </sect3> | 710 | </sect3> |
750 | <sect3 id="drm-gem-objects-mapping"> | 711 | <sect3 id="drm-gem-objects-mapping"> |
751 | <title>GEM Objects Mapping</title> | 712 | <title>GEM Objects Mapping</title> |
@@ -868,10 +829,10 @@ char *date;</synopsis> | |||
868 | abstracted from the client in libdrm. | 829 | abstracted from the client in libdrm. |
869 | </para> | 830 | </para> |
870 | </sect3> | 831 | </sect3> |
871 | <sect2> | 832 | <sect3> |
872 | <title>GEM Function Reference</title> | 833 | <title>GEM Function Reference</title> |
873 | !Edrivers/gpu/drm/drm_gem.c | 834 | !Edrivers/gpu/drm/drm_gem.c |
874 | </sect2> | 835 | </sect3> |
875 | </sect2> | 836 | </sect2> |
876 | <sect2> | 837 | <sect2> |
877 | <title>VMA Offset Manager</title> | 838 | <title>VMA Offset Manager</title> |
@@ -879,6 +840,68 @@ char *date;</synopsis> | |||
879 | !Edrivers/gpu/drm/drm_vma_manager.c | 840 | !Edrivers/gpu/drm/drm_vma_manager.c |
880 | !Iinclude/drm/drm_vma_manager.h | 841 | !Iinclude/drm/drm_vma_manager.h |
881 | </sect2> | 842 | </sect2> |
843 | <sect2 id="drm-prime-support"> | ||
844 | <title>PRIME Buffer Sharing</title> | ||
845 | <para> | ||
846 | PRIME is the cross device buffer sharing framework in drm, originally | ||
847 | created for the OPTIMUS range of multi-gpu platforms. To userspace | ||
848 | PRIME buffers are dma-buf based file descriptors. | ||
849 | </para> | ||
850 | <sect3> | ||
851 | <title>Overview and Driver Interface</title> | ||
852 | <para> | ||
853 | Similar to GEM global names, PRIME file descriptors are | ||
854 | also used to share buffer objects across processes. They offer | ||
855 | additional security: as file descriptors must be explicitly sent over | ||
856 | UNIX domain sockets to be shared between applications, they can't be | ||
857 | guessed like the globally unique GEM names. | ||
858 | </para> | ||
859 | <para> | ||
860 | Drivers that support the PRIME | ||
861 | API must set the DRIVER_PRIME bit in the struct | ||
862 | <structname>drm_driver</structname> | ||
863 | <structfield>driver_features</structfield> field, and implement the | ||
864 | <methodname>prime_handle_to_fd</methodname> and | ||
865 | <methodname>prime_fd_to_handle</methodname> operations. | ||
866 | </para> | ||
867 | <para> | ||
868 | <synopsis>int (*prime_handle_to_fd)(struct drm_device *dev, | ||
869 | struct drm_file *file_priv, uint32_t handle, | ||
870 | uint32_t flags, int *prime_fd); | ||
871 | int (*prime_fd_to_handle)(struct drm_device *dev, | ||
872 | struct drm_file *file_priv, int prime_fd, | ||
873 | uint32_t *handle);</synopsis> | ||
874 | Those two operations convert a handle to a PRIME file descriptor and | ||
875 | vice versa. Drivers must use the kernel dma-buf buffer sharing framework | ||
876 | to manage the PRIME file descriptors. Similar to the mode setting | ||
877 | API PRIME is agnostic to the underlying buffer object manager, as | ||
878 | long as handles are 32bit unsinged integers. | ||
879 | </para> | ||
880 | <para> | ||
881 | While non-GEM drivers must implement the operations themselves, GEM | ||
882 | drivers must use the <function>drm_gem_prime_handle_to_fd</function> | ||
883 | and <function>drm_gem_prime_fd_to_handle</function> helper functions. | ||
884 | Those helpers rely on the driver | ||
885 | <methodname>gem_prime_export</methodname> and | ||
886 | <methodname>gem_prime_import</methodname> operations to create a dma-buf | ||
887 | instance from a GEM object (dma-buf exporter role) and to create a GEM | ||
888 | object from a dma-buf instance (dma-buf importer role). | ||
889 | </para> | ||
890 | <para> | ||
891 | <synopsis>struct dma_buf * (*gem_prime_export)(struct drm_device *dev, | ||
892 | struct drm_gem_object *obj, | ||
893 | int flags); | ||
894 | struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, | ||
895 | struct dma_buf *dma_buf);</synopsis> | ||
896 | These two operations are mandatory for GEM drivers that support | ||
897 | PRIME. | ||
898 | </para> | ||
899 | </sect3> | ||
900 | <sect3> | ||
901 | <title>PRIME Helper Functions Reference</title> | ||
902 | !Pdrivers/gpu/drm/drm_prime.c PRIME Helpers | ||
903 | </sect3> | ||
904 | </sect2> | ||
882 | </sect1> | 905 | </sect1> |
883 | 906 | ||
884 | <!-- Internals: mode setting --> | 907 | <!-- Internals: mode setting --> |