mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 15:12:13 +02:00
drm/ttm: Add ttm_bo_access
Non-contiguous VRAM cannot easily be mapped in TTM nor can non-visible VRAM easily be accessed. Add ttm_bo_access, which is similar to ttm_bo_vm_access, to access such memory. v4: - Fix checkpatch warnings (CI) v5: - Fix checkpatch warnings (CI) v6: - Fix kernel doc (Auld) v7: - Move ttm_bo_access to ttm_bo_vm.c (Christian) Cc: Christian König <christian.koenig@amd.com> Reported-by: Christoph Manszewski <christoph.manszewski@intel.com> Suggested-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Tested-by: Mika Kuoppala <mika.kuoppala@linux.intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241126174615.2665852-3-matthew.brost@intel.com
This commit is contained in:
parent
f85dc3c5ab
commit
7d08df5d0b
|
|
@ -405,13 +405,25 @@ static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo,
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
|
/**
|
||||||
void *buf, int len, int write)
|
* ttm_bo_access - Helper to access a buffer object
|
||||||
|
*
|
||||||
|
* @bo: ttm buffer object
|
||||||
|
* @offset: access offset into buffer object
|
||||||
|
* @buf: pointer to caller memory to read into or write from
|
||||||
|
* @len: length of access
|
||||||
|
* @write: write access
|
||||||
|
*
|
||||||
|
* Utility function to access a buffer object. Useful when buffer object cannot
|
||||||
|
* be easily mapped (non-contiguous, non-visible, etc...). Should not directly
|
||||||
|
* be exported to user space via a peak / poke interface.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* @len if successful, negative error code on failure.
|
||||||
|
*/
|
||||||
|
int ttm_bo_access(struct ttm_buffer_object *bo, unsigned long offset,
|
||||||
|
void *buf, int len, int write)
|
||||||
{
|
{
|
||||||
struct ttm_buffer_object *bo = vma->vm_private_data;
|
|
||||||
unsigned long offset = (addr) - vma->vm_start +
|
|
||||||
((vma->vm_pgoff - drm_vma_node_start(&bo->base.vma_node))
|
|
||||||
<< PAGE_SHIFT);
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (len < 1 || (offset + len) > bo->base.size)
|
if (len < 1 || (offset + len) > bo->base.size)
|
||||||
|
|
@ -429,8 +441,8 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (bo->bdev->funcs->access_memory)
|
if (bo->bdev->funcs->access_memory)
|
||||||
ret = bo->bdev->funcs->access_memory(
|
ret = bo->bdev->funcs->access_memory
|
||||||
bo, offset, buf, len, write);
|
(bo, offset, buf, len, write);
|
||||||
else
|
else
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
}
|
}
|
||||||
|
|
@ -439,6 +451,18 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(ttm_bo_access);
|
||||||
|
|
||||||
|
int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
|
||||||
|
void *buf, int len, int write)
|
||||||
|
{
|
||||||
|
struct ttm_buffer_object *bo = vma->vm_private_data;
|
||||||
|
unsigned long offset = (addr) - vma->vm_start +
|
||||||
|
((vma->vm_pgoff - drm_vma_node_start(&bo->base.vma_node))
|
||||||
|
<< PAGE_SHIFT);
|
||||||
|
|
||||||
|
return ttm_bo_access(bo, offset, buf, len, write);
|
||||||
|
}
|
||||||
EXPORT_SYMBOL(ttm_bo_vm_access);
|
EXPORT_SYMBOL(ttm_bo_vm_access);
|
||||||
|
|
||||||
static const struct vm_operations_struct ttm_bo_vm_ops = {
|
static const struct vm_operations_struct ttm_bo_vm_ops = {
|
||||||
|
|
|
||||||
|
|
@ -421,6 +421,8 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo);
|
||||||
int ttm_bo_evict_first(struct ttm_device *bdev,
|
int ttm_bo_evict_first(struct ttm_device *bdev,
|
||||||
struct ttm_resource_manager *man,
|
struct ttm_resource_manager *man,
|
||||||
struct ttm_operation_ctx *ctx);
|
struct ttm_operation_ctx *ctx);
|
||||||
|
int ttm_bo_access(struct ttm_buffer_object *bo, unsigned long offset,
|
||||||
|
void *buf, int len, int write);
|
||||||
vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,
|
vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,
|
||||||
struct vm_fault *vmf);
|
struct vm_fault *vmf);
|
||||||
vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
|
vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user