linux/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
/**
 * amdgpu_gem_map_detach - &dma_buf_ops.detach implementation
 * @dma_buf: shared DMA buffer
 * @attach: DMA-buf attachment
 *
 * This is called when a shared DMA buffer no longer needs to be accessible by
 * the other device. For now, simply unpins the buffer from GTT.
 */
&dma_buf_ops.detach implementation
@dma_buf: shared DMA buffer
@attach: DMA-buf attachment

This is called when a shared DMA buffer no longer needs to be accessible by
the other device. For now, simply unpins the buffer from GTT.
&dma_buf_ops . detach implementation @dma_buf : shared DMA buffer @attach : DMA - buf attachment This is called when a shared DMA buffer no longer needs to be accessible by the other device . For now simply unpins the buffer from GTT .
static void amdgpu_gem_map_detach(struct dma_buf *dma_buf,
				  struct dma_buf_attachment *attach)
{
	struct drm_gem_object *obj = dma_buf->priv;
	struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
	int ret = 0;
	ret = amdgpu_bo_reserve(bo, true);
	if (unlikely(ret != 0))
		goto error;
	amdgpu_bo_unpin(bo);
	if (attach->dev->driver != adev->dev->driver && bo->prime_shared_count)
		bo->prime_shared_count--;
	amdgpu_bo_unreserve(bo);
error:
	drm_gem_map_detach(dma_buf, attach);
}
static void amdgpu_gem_map_detach ( struct dma_buf * dma_buf , struct dma_buf_attachment * attach ) { struct drm_gem_object * obj = dma_buf -> priv ; struct amdgpu_bo * bo = gem_to_amdgpu_bo ( obj ) ; struct amdgpu_device * adev = amdgpu_ttm_adev ( bo -> tbo . bdev ) ; int ret = 0 ; ret = amdgpu_bo_reserve ( bo , true ) ; if ( unlikely ( ret != 0 ) ) goto error ; amdgpu_bo_unpin ( bo ) ; if ( attach -> dev -> driver != adev -> dev -> driver && bo -> prime_shared_count ) bo -> prime_shared_count -- ; amdgpu_bo_unreserve ( bo ) ; error : drm_gem_map_detach ( dma_buf , attach ) ; }
amdgpu_gem_map_detach - &dma_buf_ops.detach implementation
 @dma_buf: shared DMA buffer
 @attach: DMA-buf attachment
amdgpu_gem_map_detach - &dma_buf_ops . detach implementation @dma_buf : shared DMA buffer @attach : DMA - buf attachment