diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c index 1c5d97f4b4dd..e45e929aaab5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | 35 | ||
| 36 | #include "amdgpu.h" | 36 | #include "amdgpu.h" |
| 37 | #include "amdgpu_display.h" | 37 | #include "amdgpu_display.h" |
| 38 | #include "amdgpu_gem.h" | ||
| 38 | #include <drm/amdgpu_drm.h> | 39 | #include <drm/amdgpu_drm.h> |
| 39 | #include <linux/dma-buf.h> | 40 | #include <linux/dma-buf.h> |
| 40 | 41 | ||
| @@ -43,10 +44,10 @@ static const struct dma_buf_ops amdgpu_dmabuf_ops; | |||
| 43 | /** | 44 | /** |
| 44 | * amdgpu_gem_prime_get_sg_table - &drm_driver.gem_prime_get_sg_table | 45 | * amdgpu_gem_prime_get_sg_table - &drm_driver.gem_prime_get_sg_table |
| 45 | * implementation | 46 | * implementation |
| 46 | * @obj: GEM buffer object | 47 | * @obj: GEM buffer object (BO) |
| 47 | * | 48 | * |
| 48 | * Returns: | 49 | * Returns: |
| 49 | * A scatter/gather table for the pinned pages of the buffer object's memory. | 50 | * A scatter/gather table for the pinned pages of the BO's memory. |
| 50 | */ | 51 | */ |
| 51 | struct sg_table *amdgpu_gem_prime_get_sg_table(struct drm_gem_object *obj) | 52 | struct sg_table *amdgpu_gem_prime_get_sg_table(struct drm_gem_object *obj) |
| 52 | { | 53 | { |
| @@ -58,9 +59,9 @@ struct sg_table *amdgpu_gem_prime_get_sg_table(struct drm_gem_object *obj) | |||
| 58 | 59 | ||
| 59 | /** | 60 | /** |
| 60 | * amdgpu_gem_prime_vmap - &dma_buf_ops.vmap implementation | 61 | * amdgpu_gem_prime_vmap - &dma_buf_ops.vmap implementation |
| 61 | * @obj: GEM buffer object | 62 | * @obj: GEM BO |
| 62 | * | 63 | * |
| 63 | * Sets up an in-kernel virtual mapping of the buffer object's memory. | 64 | * Sets up an in-kernel virtual mapping of the BO's memory. |
| 64 | * | 65 | * |
| 65 | * Returns: | 66 | * Returns: |
| 66 | * The virtual address of the mapping or an error pointer. | 67 | * The virtual address of the mapping or an error pointer. |
| @@ -80,10 +81,10 @@ void *amdgpu_gem_prime_vmap(struct drm_gem_object *obj) | |||
| 80 | 81 | ||
| 81 | /** | 82 | /** |
| 82 | * amdgpu_gem_prime_vunmap - &dma_buf_ops.vunmap implementation | 83 | * amdgpu_gem_prime_vunmap - &dma_buf_ops.vunmap implementation |
| 83 | * @obj: GEM buffer object | 84 | * @obj: GEM BO |
| 84 | * @vaddr: virtual address (unused) | 85 | * @vaddr: Virtual address (unused) |
| 85 | * | 86 | * |
| 86 | * Tears down the in-kernel virtual mapping of the buffer object's memory. | 87 | * Tears down the in-kernel virtual mapping of the BO's memory. |
| 87 | */ | 88 | */ |
| 88 | void amdgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) | 89 | void amdgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) |
| 89 | { | 90 | { |
| @@ -94,14 +95,14 @@ void amdgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) | |||
| 94 | 95 | ||
| 95 | /** | 96 | /** |
| 96 | * amdgpu_gem_prime_mmap - &drm_driver.gem_prime_mmap implementation | 97 | * amdgpu_gem_prime_mmap - &drm_driver.gem_prime_mmap implementation |
| 97 | * @obj: GEM buffer object | 98 | * @obj: GEM BO |
| 98 | * @vma: virtual memory area | 99 | * @vma: Virtual memory area |
| 99 | * | 100 | * |
| 100 | * Sets up a userspace mapping of the buffer object's memory in the given | 101 | * Sets up a userspace mapping of the BO's memory in the given |
| 101 | * virtual memory area. | 102 | * virtual memory area. |
| 102 | * | 103 | * |
| 103 | * Returns: | 104 | * Returns: |
| 104 | * 0 on success or negative error code. | 105 | * 0 on success or a negative error code on failure. |
| 105 | */ | 106 | */ |
| 106 | int amdgpu_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) | 107 | int amdgpu_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) |
| 107 | { | 108 | { |
| @@ -144,10 +145,10 @@ int amdgpu_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma | |||
| 144 | * @attach: DMA-buf attachment | 145 | * @attach: DMA-buf attachment |
| 145 | * @sg: Scatter/gather table | 146 | * @sg: Scatter/gather table |
| 146 | * | 147 | * |
| 147 | * Import shared DMA buffer memory exported by another device. | 148 | * Imports shared DMA buffer memory exported by another device. |
| 148 | * | 149 | * |
| 149 | * Returns: | 150 | * Returns: |
| 150 | * A new GEM buffer object of the given DRM device, representing the memory | 151 | * A new GEM BO of the given DRM device, representing the memory |
| 151 | * described by the given DMA-buf attachment and scatter/gather table. | 152 | * described by the given DMA-buf attachment and scatter/gather table. |
| 152 | */ | 153 | */ |
| 153 | struct drm_gem_object * | 154 | struct drm_gem_object * |
| @@ -190,7 +191,7 @@ error: | |||
| 190 | 191 | ||
| 191 | /** | 192 | /** |
| 192 | * amdgpu_gem_map_attach - &dma_buf_ops.attach implementation | 193 | * amdgpu_gem_map_attach - &dma_buf_ops.attach implementation |
| 193 | * @dma_buf: shared DMA buffer | 194 | * @dma_buf: Shared DMA buffer |
| 194 | * @attach: DMA-buf attachment | 195 | * @attach: DMA-buf attachment |
| 195 | * | 196 | * |
| 196 | * Makes sure that the shared DMA buffer can be accessed by the target device. | 197 | * Makes sure that the shared DMA buffer can be accessed by the target device. |
| @@ -198,7 +199,7 @@ error: | |||
| 198 | * all DMA devices. | 199 | * all DMA devices. |
| 199 | * | 200 | * |
| 200 | * Returns: | 201 | * Returns: |
| 201 | * 0 on success or negative error code. | 202 | * 0 on success or a negative error code on failure. |
| 202 | */ | 203 | */ |
| 203 | static int amdgpu_gem_map_attach(struct dma_buf *dma_buf, | 204 | static int amdgpu_gem_map_attach(struct dma_buf *dma_buf, |
| 204 | struct dma_buf_attachment *attach) | 205 | struct dma_buf_attachment *attach) |
| @@ -250,11 +251,11 @@ error_detach: | |||
| 250 | 251 | ||
| 251 | /** | 252 | /** |
| 252 | * amdgpu_gem_map_detach - &dma_buf_ops.detach implementation | 253 | * amdgpu_gem_map_detach - &dma_buf_ops.detach implementation |
| 253 | * @dma_buf: shared DMA buffer | 254 | * @dma_buf: Shared DMA buffer |
| 254 | * @attach: DMA-buf attachment | 255 | * @attach: DMA-buf attachment |
| 255 | * | 256 | * |
| 256 | * This is called when a shared DMA buffer no longer needs to be accessible by | 257 | * This is called when a shared DMA buffer no longer needs to be accessible by |
| 257 | * the other device. For now, simply unpins the buffer from GTT. | 258 | * another device. For now, simply unpins the buffer from GTT. |
| 258 | */ | 259 | */ |
| 259 | static void amdgpu_gem_map_detach(struct dma_buf *dma_buf, | 260 | static void amdgpu_gem_map_detach(struct dma_buf *dma_buf, |
| 260 | struct dma_buf_attachment *attach) | 261 | struct dma_buf_attachment *attach) |
| @@ -279,10 +280,10 @@ error: | |||
| 279 | 280 | ||
| 280 | /** | 281 | /** |
| 281 | * amdgpu_gem_prime_res_obj - &drm_driver.gem_prime_res_obj implementation | 282 | * amdgpu_gem_prime_res_obj - &drm_driver.gem_prime_res_obj implementation |
| 282 | * @obj: GEM buffer object | 283 | * @obj: GEM BO |
| 283 | * | 284 | * |
| 284 | * Returns: | 285 | * Returns: |
| 285 | * The buffer object's reservation object. | 286 | * The BO's reservation object. |
| 286 | */ | 287 | */ |
| 287 | struct reservation_object *amdgpu_gem_prime_res_obj(struct drm_gem_object *obj) | 288 | struct reservation_object *amdgpu_gem_prime_res_obj(struct drm_gem_object *obj) |
| 288 | { | 289 | { |
| @@ -293,15 +294,15 @@ struct reservation_object *amdgpu_gem_prime_res_obj(struct drm_gem_object *obj) | |||
| 293 | 294 | ||
| 294 | /** | 295 | /** |
| 295 | * amdgpu_gem_begin_cpu_access - &dma_buf_ops.begin_cpu_access implementation | 296 | * amdgpu_gem_begin_cpu_access - &dma_buf_ops.begin_cpu_access implementation |
| 296 | * @dma_buf: shared DMA buffer | 297 | * @dma_buf: Shared DMA buffer |
| 297 | * @direction: direction of DMA transfer | 298 | * @direction: Direction of DMA transfer |
| 298 | * | 299 | * |
| 299 | * This is called before CPU access to the shared DMA buffer's memory. If it's | 300 | * This is called before CPU access to the shared DMA buffer's memory. If it's |
| 300 | * a read access, the buffer is moved to the GTT domain if possible, for optimal | 301 | * a read access, the buffer is moved to the GTT domain if possible, for optimal |
| 301 | * CPU read performance. | 302 | * CPU read performance. |
| 302 | * | 303 | * |
| 303 | * Returns: | 304 | * Returns: |
| 304 | * 0 on success or negative error code. | 305 | * 0 on success or a negative error code on failure. |
| 305 | */ | 306 | */ |
| 306 | static int amdgpu_gem_begin_cpu_access(struct dma_buf *dma_buf, | 307 | static int amdgpu_gem_begin_cpu_access(struct dma_buf *dma_buf, |
| 307 | enum dma_data_direction direction) | 308 | enum dma_data_direction direction) |
| @@ -348,14 +349,14 @@ static const struct dma_buf_ops amdgpu_dmabuf_ops = { | |||
| 348 | /** | 349 | /** |
| 349 | * amdgpu_gem_prime_export - &drm_driver.gem_prime_export implementation | 350 | * amdgpu_gem_prime_export - &drm_driver.gem_prime_export implementation |
| 350 | * @dev: DRM device | 351 | * @dev: DRM device |
| 351 | * @gobj: GEM buffer object | 352 | * @gobj: GEM BO |
| 352 | * @flags: flags like DRM_CLOEXEC and DRM_RDWR | 353 | * @flags: Flags such as DRM_CLOEXEC and DRM_RDWR. |
| 353 | * | 354 | * |
| 354 | * The main work is done by the &drm_gem_prime_export helper, which in turn | 355 | * The main work is done by the &drm_gem_prime_export helper, which in turn |
| 355 | * uses &amdgpu_gem_prime_res_obj. | 356 | * uses &amdgpu_gem_prime_res_obj. |
| 356 | * | 357 | * |
| 357 | * Returns: | 358 | * Returns: |
| 358 | * Shared DMA buffer representing the GEM buffer object from the given device. | 359 | * Shared DMA buffer representing the GEM BO from the given device. |
