linux/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
/**
 * amdgpu_gem_prime_import_sg_table - &drm_driver.gem_prime_import_sg_table
 * implementation
 * @dev: DRM device
 * @attach: DMA-buf attachment
 * @sg: Scatter/gather table
 *
 * Import shared DMA buffer memory exported by another device.
 *
 * Returns:
 * A new GEM buffer object of the given DRM device, representing the memory
 * described by the given DMA-buf attachment and scatter/gather table.
 */
&drm_driver.gem_prime_import_sg_table
implementation
@dev: DRM device
@attach: DMA-buf attachment
@sg: Scatter/gather table

Import shared DMA buffer memory exported by another device.

A new GEM buffer object of the given DRM device, representing the memory
described by the given DMA-buf attachment and scatter/gather table.
&drm_driver . gem_prime_import_sg_table implementation @dev : DRM device @attach : DMA - buf attachment @sg : Scatter / gather table Import shared DMA buffer memory exported by another device . A new GEM buffer object of the given DRM device representing the memory described by the given DMA - buf attachment and scatter / gather table .
struct drm_gem_object *
amdgpu_gem_prime_import_sg_table(struct drm_device *dev,
				 struct dma_buf_attachment *attach,
				 struct sg_table *sg)
{
	struct reservation_object *resv = attach->dmabuf->resv;
	struct amdgpu_device *adev = dev->dev_private;
	struct amdgpu_bo *bo;
	struct amdgpu_bo_param bp;
	int ret;
	memset(&bp, 0, sizeof(bp));
	bp.size = attach->dmabuf->size;
	bp.byte_align = PAGE_SIZE;
	bp.domain = AMDGPU_GEM_DOMAIN_CPU;
	bp.flags = 0;
	bp.type = ttm_bo_type_sg;
	bp.resv = resv;
	ww_mutex_lock(&resv->lock, NULL);
	ret = amdgpu_bo_create(adev, &bp, &bo);
	if (ret)
		goto error;
	bo->tbo.sg = sg;
	bo->tbo.ttm->sg = sg;
	bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT;
	bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT;
	if (attach->dmabuf->ops != &amdgpu_dmabuf_ops)
		bo->prime_shared_count = 1;
	ww_mutex_unlock(&resv->lock);
	return &bo->gem_base;
error:
	ww_mutex_unlock(&resv->lock);
	return ERR_PTR(ret);
}
struct drm_gem_object * amdgpu_gem_prime_import_sg_table ( struct drm_device * dev , struct dma_buf_attachment * attach , struct sg_table * sg ) { struct reservation_object * resv = attach -> dmabuf -> resv ; struct amdgpu_device * adev = dev -> dev_private ; struct amdgpu_bo * bo ; struct amdgpu_bo_param bp ; int ret ; memset ( & bp , 0 , sizeof ( bp ) ) ; bp . size = attach -> dmabuf -> size ; bp . byte_align = PAGE_SIZE ; bp . domain = AMDGPU_GEM_DOMAIN_CPU ; bp . flags = 0 ; bp . type = ttm_bo_type_sg ; bp . resv = resv ; ww_mutex_lock ( & resv -> lock , NULL ) ; ret = amdgpu_bo_create ( adev , & bp , & bo ) ; if ( ret ) goto error ; bo -> tbo . sg = sg ; bo -> tbo . ttm -> sg = sg ; bo -> allowed_domains = AMDGPU_GEM_DOMAIN_GTT ; bo -> preferred_domains = AMDGPU_GEM_DOMAIN_GTT ; if ( attach -> dmabuf -> ops != & amdgpu_dmabuf_ops ) bo -> prime_shared_count = 1 ; ww_mutex_unlock ( & resv -> lock ) ; return & bo -> gem_base ; error : ww_mutex_unlock ( & resv -> lock ) ; return ERR_PTR ( ret ) ; }
amdgpu_gem_prime_import_sg_table - &drm_driver.gem_prime_import_sg_table
 implementation
 @dev: DRM device
 @attach: DMA-buf attachment
 @sg: Scatter/gather table
amdgpu_gem_prime_import_sg_table - &drm_driver . gem_prime_import_sg_table implementation @dev : DRM device @attach : DMA - buf attachment @sg : Scatter / gather table