Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Update GEM refcounting docs

I just realized that I've forgotten to update all the gem refcounting
docs. For pennance also add pretty docs for the overall drm_gem_object
structure, with a few links thrown in fore good.

As usually we need to make sure the kerneldoc reference is at most a
sect2 for otherwise it won't be listed.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1445533889-7661-1-git-send-email-daniel.vetter@ffwll.ch
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

+100 -21
+8 -7
Documentation/DocBook/gpu.tmpl
··· 635 635 acquired and release by <function>calling drm_gem_object_reference</function> 636 636 and <function>drm_gem_object_unreference</function> respectively. The 637 637 caller must hold the <structname>drm_device</structname> 638 - <structfield>struct_mutex</structfield> lock. As a convenience, GEM 639 - provides the <function>drm_gem_object_reference_unlocked</function> and 640 - <function>drm_gem_object_unreference_unlocked</function> functions that 641 - can be called without holding the lock. 638 + <structfield>struct_mutex</structfield> lock when calling 639 + <function>drm_gem_object_reference</function>. As a convenience, GEM 640 + provides <function>drm_gem_object_unreference_unlocked</function> 641 + functions that can be called without holding the lock. 642 642 </para> 643 643 <para> 644 644 When the last reference to a GEM object is released the GEM core calls ··· 836 836 abstracted from the client in libdrm. 837 837 </para> 838 838 </sect3> 839 - <sect3> 840 - <title>GEM Function Reference</title> 839 + </sect2> 840 + <sect2> 841 + <title>GEM Function Reference</title> 841 842 !Edrivers/gpu/drm/drm_gem.c 842 - </sect3> 843 + !Iinclude/drm/drm_gem.h 843 844 </sect2> 844 845 <sect2> 845 846 <title>VMA Offset Manager</title>
+92 -14
include/drm/drm_gem.h
··· 35 35 */ 36 36 37 37 /** 38 - * This structure defines the drm_mm memory object, which will be used by the 39 - * DRM for its buffer objects. 38 + * struct drm_gem_object - GEM buffer object 39 + * 40 + * This structure defines the generic parts for GEM buffer objects, which are 41 + * mostly around handling mmap and userspace handles. 42 + * 43 + * Buffer objects are often abbreviated to BO. 40 44 */ 41 45 struct drm_gem_object { 42 - /** Reference count of this object */ 46 + /** 47 + * @refcount: 48 + * 49 + * Reference count of this object 50 + * 51 + * Please use drm_gem_object_reference() to acquire and 52 + * drm_gem_object_unreference() or drm_gem_object_unreference_unlocked() 53 + * to release a reference to a GEM buffer object. 54 + */ 43 55 struct kref refcount; 44 56 45 57 /** 46 - * handle_count - gem file_priv handle count of this object 58 + * @handle_count: 59 + * 60 + * This is the GEM file_priv handle count of this object. 47 61 * 48 62 * Each handle also holds a reference. Note that when the handle_count 49 63 * drops to 0 any global names (e.g. the id in the flink namespace) will 50 64 * be cleared. 51 65 * 52 66 * Protected by dev->object_name_lock. 53 - * */ 67 + */ 54 68 unsigned handle_count; 55 69 56 - /** Related drm device */ 70 + /** 71 + * @dev: DRM dev this object belongs to. 72 + */ 57 73 struct drm_device *dev; 58 74 59 - /** File representing the shmem storage */ 75 + /** 76 + * @filp: 77 + * 78 + * SHMEM file node used as backing storage for swappable buffer objects. 79 + * GEM also supports driver private objects with driver-specific backing 80 + * storage (contiguous CMA memory, special reserved blocks). In this 81 + * case @filp is NULL. 82 + */ 60 83 struct file *filp; 61 84 62 - /* Mapping info for this object */ 85 + /** 86 + * @vma_node: 87 + * 88 + * Mapping info for this object to support mmap. Drivers are supposed to 89 + * allocate the mmap offset using drm_gem_create_mmap_offset(). The 90 + * offset itself can be retrieved using drm_vma_node_offset_addr(). 91 + * 92 + * Memory mapping itself is handled by drm_gem_mmap(), which also checks 93 + * that userspace is allowed to access the object. 94 + */ 63 95 struct drm_vma_offset_node vma_node; 64 96 65 97 /** 98 + * @size: 99 + * 66 100 * Size of the object, in bytes. Immutable over the object's 67 101 * lifetime. 68 102 */ 69 103 size_t size; 70 104 71 105 /** 106 + * @name: 107 + * 72 108 * Global name for this object, starts at 1. 0 means unnamed. 73 - * Access is covered by the object_name_lock in the related drm_device 109 + * Access is covered by dev->object_name_lock. This is used by the GEM_FLINK 110 + * and GEM_OPEN ioctls. 74 111 */ 75 112 int name; 76 113 77 114 /** 78 - * Memory domains. These monitor which caches contain read/write data 115 + * @read_domains: 116 + * 117 + * Read memory domains. These monitor which caches contain read/write data 79 118 * related to the object. When transitioning from one set of domains 80 119 * to another, the driver is called to ensure that caches are suitably 81 - * flushed and invalidated 120 + * flushed and invalidated. 82 121 */ 83 122 uint32_t read_domains; 123 + 124 + /** 125 + * @write_domain: Corresponding unique write memory domain. 126 + */ 84 127 uint32_t write_domain; 85 128 86 129 /** 130 + * @pending_read_domains: 131 + * 87 132 * While validating an exec operation, the 88 133 * new read/write domain values are computed here. 89 134 * They will be transferred to the above values 90 135 * at the point that any cache flushing occurs 91 136 */ 92 137 uint32_t pending_read_domains; 138 + 139 + /** 140 + * @pending_write_domain: Write domain similar to @pending_read_domains. 141 + */ 93 142 uint32_t pending_write_domain; 94 143 95 144 /** 96 - * dma_buf - dma buf associated with this GEM object 145 + * @dma_buf: 146 + * 147 + * dma-buf associated with this GEM object. 97 148 * 98 149 * Pointer to the dma-buf associated with this gem object (either 99 150 * through importing or exporting). We break the resulting reference 100 151 * loop when the last gem handle for this object is released. 101 152 * 102 - * Protected by obj->object_name_lock 153 + * Protected by obj->object_name_lock. 103 154 */ 104 155 struct dma_buf *dma_buf; 105 156 106 157 /** 107 - * import_attach - dma buf attachment backing this object 158 + * @import_attach: 159 + * 160 + * dma-buf attachment backing this object. 108 161 * 109 162 * Any foreign dma_buf imported as a gem object has this set to the 110 163 * attachment point for the device. This is invariant over the lifetime ··· 186 133 struct vm_area_struct *vma); 187 134 int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); 188 135 136 + /** 137 + * drm_gem_object_reference - acquire a GEM BO reference 138 + * @obj: GEM buffer object 139 + * 140 + * This acquires additional reference to @obj. It is illegal to call this 141 + * without already holding a reference. No locks required. 142 + */ 189 143 static inline void 190 144 drm_gem_object_reference(struct drm_gem_object *obj) 191 145 { 192 146 kref_get(&obj->refcount); 193 147 } 194 148 149 + /** 150 + * drm_gem_object_unreference - release a GEM BO reference 151 + * @obj: GEM buffer object 152 + * 153 + * This releases a reference to @obj. Callers must hold the dev->struct_mutex 154 + * lock when calling this function, even when the driver doesn't use 155 + * dev->struct_mutex for anything. 156 + * 157 + * For drivers not encumbered with legacy locking use 158 + * drm_gem_object_unreference_unlocked() instead. 159 + */ 195 160 static inline void 196 161 drm_gem_object_unreference(struct drm_gem_object *obj) 197 162 { ··· 220 149 } 221 150 } 222 151 152 + /** 153 + * drm_gem_object_unreference_unlocked - release a GEM BO reference 154 + * @obj: GEM buffer object 155 + * 156 + * This releases a reference to @obj. Callers must not hold the 157 + * dev->struct_mutex lock when calling this function. 158 + */ 223 159 static inline void 224 160 drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) 225 161 {