Skip to content
Snippets Groups Projects
Commit b2e852b5 authored by Jordan Crouse's avatar Jordan Crouse Committed by Rob Clark
Browse files

drm/msm: Add support for address space instances


Add support for allocating an address space instance. Targets that support
per-instance pagetables should implement their own function to allocate a
new instance. The default will return the existing generic address space.

Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 56ec0eb0
No related merge requests found
...@@ -599,7 +599,7 @@ static int context_init(struct drm_device *dev, struct drm_file *file) ...@@ -599,7 +599,7 @@ static int context_init(struct drm_device *dev, struct drm_file *file)
msm_submitqueue_init(dev, ctx); msm_submitqueue_init(dev, ctx);
ctx->aspace = priv->gpu ? priv->gpu->aspace : NULL; ctx->aspace = msm_gpu_address_space_instance(priv->gpu);
file->driver_priv = ctx; file->driver_priv = ctx;
return 0; return 0;
...@@ -618,6 +618,8 @@ static int msm_open(struct drm_device *dev, struct drm_file *file) ...@@ -618,6 +618,8 @@ static int msm_open(struct drm_device *dev, struct drm_file *file)
static void context_close(struct msm_file_private *ctx) static void context_close(struct msm_file_private *ctx)
{ {
msm_submitqueue_close(ctx); msm_submitqueue_close(ctx);
msm_gem_address_space_put(ctx->aspace);
kfree(ctx); kfree(ctx);
} }
...@@ -782,18 +784,19 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, ...@@ -782,18 +784,19 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,
} }
static int msm_ioctl_gem_info_iova(struct drm_device *dev, static int msm_ioctl_gem_info_iova(struct drm_device *dev,
struct drm_gem_object *obj, uint64_t *iova) struct drm_file *file, struct drm_gem_object *obj,
uint64_t *iova)
{ {
struct msm_drm_private *priv = dev->dev_private; struct msm_file_private *ctx = file->driver_priv;
if (!priv->gpu) if (!ctx->aspace)
return -EINVAL; return -EINVAL;
/* /*
* Don't pin the memory here - just get an address so that userspace can * Don't pin the memory here - just get an address so that userspace can
* be productive * be productive
*/ */
return msm_gem_get_iova(obj, priv->gpu->aspace, iova); return msm_gem_get_iova(obj, ctx->aspace, iova);
} }
static int msm_ioctl_gem_info(struct drm_device *dev, void *data, static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
...@@ -832,7 +835,7 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data, ...@@ -832,7 +835,7 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
args->value = msm_gem_mmap_offset(obj); args->value = msm_gem_mmap_offset(obj);
break; break;
case MSM_INFO_GET_IOVA: case MSM_INFO_GET_IOVA:
ret = msm_ioctl_gem_info_iova(dev, obj, &args->value); ret = msm_ioctl_gem_info_iova(dev, file, obj, &args->value);
break; break;
case MSM_INFO_SET_NAME: case MSM_INFO_SET_NAME:
/* length check should leave room for terminating null: */ /* length check should leave room for terminating null: */
......
...@@ -249,6 +249,10 @@ int msm_gem_map_vma(struct msm_gem_address_space *aspace, ...@@ -249,6 +249,10 @@ int msm_gem_map_vma(struct msm_gem_address_space *aspace,
void msm_gem_close_vma(struct msm_gem_address_space *aspace, void msm_gem_close_vma(struct msm_gem_address_space *aspace,
struct msm_gem_vma *vma); struct msm_gem_vma *vma);
struct msm_gem_address_space *
msm_gem_address_space_get(struct msm_gem_address_space *aspace);
void msm_gem_address_space_put(struct msm_gem_address_space *aspace); void msm_gem_address_space_put(struct msm_gem_address_space *aspace);
struct msm_gem_address_space * struct msm_gem_address_space *
......
...@@ -27,6 +27,15 @@ void msm_gem_address_space_put(struct msm_gem_address_space *aspace) ...@@ -27,6 +27,15 @@ void msm_gem_address_space_put(struct msm_gem_address_space *aspace)
kref_put(&aspace->kref, msm_gem_address_space_destroy); kref_put(&aspace->kref, msm_gem_address_space_destroy);
} }
struct msm_gem_address_space *
msm_gem_address_space_get(struct msm_gem_address_space *aspace)
{
if (!IS_ERR_OR_NULL(aspace))
kref_get(&aspace->kref);
return aspace;
}
/* Actually unmap memory for the vma */ /* Actually unmap memory for the vma */
void msm_gem_purge_vma(struct msm_gem_address_space *aspace, void msm_gem_purge_vma(struct msm_gem_address_space *aspace,
struct msm_gem_vma *vma) struct msm_gem_vma *vma)
......
...@@ -821,6 +821,23 @@ static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu) ...@@ -821,6 +821,23 @@ static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu)
return 0; return 0;
} }
/* Return a new address space instance */
struct msm_gem_address_space *
msm_gpu_address_space_instance(struct msm_gpu *gpu)
{
if (!gpu)
return NULL;
/*
* If the GPU doesn't support instanced address spaces return the
* default address space
*/
if (!gpu->funcs->address_space_instance)
return msm_gem_address_space_get(gpu->aspace);
return gpu->funcs->address_space_instance(gpu);
}
int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev, int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs, struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs,
const char *name, struct msm_gpu_config *config) const char *name, struct msm_gpu_config *config)
......
...@@ -64,6 +64,8 @@ struct msm_gpu_funcs { ...@@ -64,6 +64,8 @@ struct msm_gpu_funcs {
void (*gpu_set_freq)(struct msm_gpu *gpu, unsigned long freq); void (*gpu_set_freq)(struct msm_gpu *gpu, unsigned long freq);
struct msm_gem_address_space *(*create_address_space) struct msm_gem_address_space *(*create_address_space)
(struct msm_gpu *gpu, struct platform_device *pdev); (struct msm_gpu *gpu, struct platform_device *pdev);
struct msm_gem_address_space *(*address_space_instance)
(struct msm_gpu *gpu);
}; };
struct msm_gpu { struct msm_gpu {
...@@ -286,6 +288,9 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev, ...@@ -286,6 +288,9 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs, struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs,
const char *name, struct msm_gpu_config *config); const char *name, struct msm_gpu_config *config);
struct msm_gem_address_space *
msm_gpu_address_space_instance(struct msm_gpu *gpu);
void msm_gpu_cleanup(struct msm_gpu *gpu); void msm_gpu_cleanup(struct msm_gpu *gpu);
struct msm_gpu *adreno_load_gpu(struct drm_device *dev); struct msm_gpu *adreno_load_gpu(struct drm_device *dev);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment