Commit 7c13132c authored by Maíra Canal's avatar Maíra Canal

drm/v3d: Enable BO mapping

For the indirect CSD CPU job, we will need to access the internal
contents of the BO with the dispatch parameters. Therefore, create
methods to allow the mapping and unmapping of the BO.
Signed-off-by: default avatarMaíra Canal <mcanal@igalia.com>
Reviewed-by: default avatarIago Toral Quiroga <itoral@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231130164420.932823-13-mcanal@igalia.com
parent 369b0596
...@@ -33,6 +33,9 @@ void v3d_free_object(struct drm_gem_object *obj) ...@@ -33,6 +33,9 @@ void v3d_free_object(struct drm_gem_object *obj)
struct v3d_dev *v3d = to_v3d_dev(obj->dev); struct v3d_dev *v3d = to_v3d_dev(obj->dev);
struct v3d_bo *bo = to_v3d_bo(obj); struct v3d_bo *bo = to_v3d_bo(obj);
if (bo->vaddr)
v3d_put_bo_vaddr(bo);
v3d_mmu_remove_ptes(bo); v3d_mmu_remove_ptes(bo);
mutex_lock(&v3d->bo_lock); mutex_lock(&v3d->bo_lock);
...@@ -134,6 +137,7 @@ struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv, ...@@ -134,6 +137,7 @@ struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv,
if (IS_ERR(shmem_obj)) if (IS_ERR(shmem_obj))
return ERR_CAST(shmem_obj); return ERR_CAST(shmem_obj);
bo = to_v3d_bo(&shmem_obj->base); bo = to_v3d_bo(&shmem_obj->base);
bo->vaddr = NULL;
ret = v3d_bo_create_finish(&shmem_obj->base); ret = v3d_bo_create_finish(&shmem_obj->base);
if (ret) if (ret)
...@@ -167,6 +171,20 @@ v3d_prime_import_sg_table(struct drm_device *dev, ...@@ -167,6 +171,20 @@ v3d_prime_import_sg_table(struct drm_device *dev,
return obj; return obj;
} }
void v3d_get_bo_vaddr(struct v3d_bo *bo)
{
struct drm_gem_shmem_object *obj = &bo->base;
bo->vaddr = vmap(obj->pages, obj->base.size >> PAGE_SHIFT, VM_MAP,
pgprot_writecombine(PAGE_KERNEL));
}
void v3d_put_bo_vaddr(struct v3d_bo *bo)
{
vunmap(bo->vaddr);
bo->vaddr = NULL;
}
int v3d_create_bo_ioctl(struct drm_device *dev, void *data, int v3d_create_bo_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv) struct drm_file *file_priv)
{ {
......
...@@ -202,6 +202,8 @@ struct v3d_bo { ...@@ -202,6 +202,8 @@ struct v3d_bo {
* v3d_render_job->unref_list * v3d_render_job->unref_list
*/ */
struct list_head unref_head; struct list_head unref_head;
void *vaddr;
}; };
static inline struct v3d_bo * static inline struct v3d_bo *
...@@ -391,6 +393,8 @@ struct drm_gem_object *v3d_create_object(struct drm_device *dev, size_t size); ...@@ -391,6 +393,8 @@ struct drm_gem_object *v3d_create_object(struct drm_device *dev, size_t size);
void v3d_free_object(struct drm_gem_object *gem_obj); void v3d_free_object(struct drm_gem_object *gem_obj);
struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv, struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv,
size_t size); size_t size);
void v3d_get_bo_vaddr(struct v3d_bo *bo);
void v3d_put_bo_vaddr(struct v3d_bo *bo);
int v3d_create_bo_ioctl(struct drm_device *dev, void *data, int v3d_create_bo_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data, int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment