Commit f7ddbf55 authored by Rob Clark's avatar Rob Clark

drm/msm: Add SET_PARAM ioctl

It was always expected to have a use for this some day, so we left a
placeholder.  Now we do.  (And I expect another use in the not too
distant future when we start allowing userspace to allocate GPU iova.)
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Link: https://lore.kernel.org/r/20220304005317.776110-3-robdclark@gmail.com
parent 57cfe41c
...@@ -471,6 +471,7 @@ static u32 a2xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring) ...@@ -471,6 +471,7 @@ static u32 a2xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
static const struct adreno_gpu_funcs funcs = { static const struct adreno_gpu_funcs funcs = {
.base = { .base = {
.get_param = adreno_get_param, .get_param = adreno_get_param,
.set_param = adreno_set_param,
.hw_init = a2xx_hw_init, .hw_init = a2xx_hw_init,
.pm_suspend = msm_gpu_pm_suspend, .pm_suspend = msm_gpu_pm_suspend,
.pm_resume = msm_gpu_pm_resume, .pm_resume = msm_gpu_pm_resume,
......
...@@ -486,6 +486,7 @@ static u32 a3xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring) ...@@ -486,6 +486,7 @@ static u32 a3xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
static const struct adreno_gpu_funcs funcs = { static const struct adreno_gpu_funcs funcs = {
.base = { .base = {
.get_param = adreno_get_param, .get_param = adreno_get_param,
.set_param = adreno_set_param,
.hw_init = a3xx_hw_init, .hw_init = a3xx_hw_init,
.pm_suspend = msm_gpu_pm_suspend, .pm_suspend = msm_gpu_pm_suspend,
.pm_resume = msm_gpu_pm_resume, .pm_resume = msm_gpu_pm_resume,
......
...@@ -621,6 +621,7 @@ static u32 a4xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring) ...@@ -621,6 +621,7 @@ static u32 a4xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
static const struct adreno_gpu_funcs funcs = { static const struct adreno_gpu_funcs funcs = {
.base = { .base = {
.get_param = adreno_get_param, .get_param = adreno_get_param,
.set_param = adreno_set_param,
.hw_init = a4xx_hw_init, .hw_init = a4xx_hw_init,
.pm_suspend = a4xx_pm_suspend, .pm_suspend = a4xx_pm_suspend,
.pm_resume = a4xx_pm_resume, .pm_resume = a4xx_pm_resume,
......
...@@ -1700,6 +1700,7 @@ static uint32_t a5xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring) ...@@ -1700,6 +1700,7 @@ static uint32_t a5xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
static const struct adreno_gpu_funcs funcs = { static const struct adreno_gpu_funcs funcs = {
.base = { .base = {
.get_param = adreno_get_param, .get_param = adreno_get_param,
.set_param = adreno_set_param,
.hw_init = a5xx_hw_init, .hw_init = a5xx_hw_init,
.pm_suspend = a5xx_pm_suspend, .pm_suspend = a5xx_pm_suspend,
.pm_resume = a5xx_pm_resume, .pm_resume = a5xx_pm_resume,
......
...@@ -1800,6 +1800,7 @@ static int a6xx_set_supported_hw(struct device *dev, struct adreno_rev rev) ...@@ -1800,6 +1800,7 @@ static int a6xx_set_supported_hw(struct device *dev, struct adreno_rev rev)
static const struct adreno_gpu_funcs funcs = { static const struct adreno_gpu_funcs funcs = {
.base = { .base = {
.get_param = adreno_get_param, .get_param = adreno_get_param,
.set_param = adreno_set_param,
.hw_init = a6xx_hw_init, .hw_init = a6xx_hw_init,
.pm_suspend = a6xx_pm_suspend, .pm_suspend = a6xx_pm_suspend,
.pm_resume = a6xx_pm_resume, .pm_resume = a6xx_pm_resume,
......
...@@ -283,6 +283,16 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx, ...@@ -283,6 +283,16 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
} }
} }
int adreno_set_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
uint32_t param, uint64_t value)
{
switch (param) {
default:
DBG("%s: invalid param: %u", gpu->name, param);
return -EINVAL;
}
}
const struct firmware * const struct firmware *
adreno_request_fw(struct adreno_gpu *adreno_gpu, const char *fwname) adreno_request_fw(struct adreno_gpu *adreno_gpu, const char *fwname)
{ {
......
...@@ -282,6 +282,8 @@ static inline int adreno_is_a650_family(struct adreno_gpu *gpu) ...@@ -282,6 +282,8 @@ static inline int adreno_is_a650_family(struct adreno_gpu *gpu)
int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx, int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
uint32_t param, uint64_t *value); uint32_t param, uint64_t *value);
int adreno_set_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
uint32_t param, uint64_t value);
const struct firmware *adreno_request_fw(struct adreno_gpu *adreno_gpu, const struct firmware *adreno_request_fw(struct adreno_gpu *adreno_gpu,
const char *fwname); const char *fwname);
struct drm_gem_object *adreno_fw_create_bo(struct msm_gpu *gpu, struct drm_gem_object *adreno_fw_create_bo(struct msm_gpu *gpu,
......
...@@ -613,6 +613,25 @@ static int msm_ioctl_get_param(struct drm_device *dev, void *data, ...@@ -613,6 +613,25 @@ static int msm_ioctl_get_param(struct drm_device *dev, void *data,
args->param, &args->value); args->param, &args->value);
} }
static int msm_ioctl_set_param(struct drm_device *dev, void *data,
struct drm_file *file)
{
struct msm_drm_private *priv = dev->dev_private;
struct drm_msm_param *args = data;
struct msm_gpu *gpu;
if (args->pipe != MSM_PIPE_3D0)
return -EINVAL;
gpu = priv->gpu;
if (!gpu)
return -ENXIO;
return gpu->funcs->set_param(gpu, file->driver_priv,
args->param, args->value);
}
static int msm_ioctl_gem_new(struct drm_device *dev, void *data, static int msm_ioctl_gem_new(struct drm_device *dev, void *data,
struct drm_file *file) struct drm_file *file)
{ {
...@@ -898,6 +917,7 @@ static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data, ...@@ -898,6 +917,7 @@ static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data,
static const struct drm_ioctl_desc msm_ioctls[] = { static const struct drm_ioctl_desc msm_ioctls[] = {
DRM_IOCTL_DEF_DRV(MSM_GET_PARAM, msm_ioctl_get_param, DRM_RENDER_ALLOW), DRM_IOCTL_DEF_DRV(MSM_GET_PARAM, msm_ioctl_get_param, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_SET_PARAM, msm_ioctl_set_param, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_GEM_NEW, msm_ioctl_gem_new, DRM_RENDER_ALLOW), DRM_IOCTL_DEF_DRV(MSM_GEM_NEW, msm_ioctl_gem_new, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_GEM_INFO, msm_ioctl_gem_info, DRM_RENDER_ALLOW), DRM_IOCTL_DEF_DRV(MSM_GEM_INFO, msm_ioctl_gem_info, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_GEM_CPU_PREP, msm_ioctl_gem_cpu_prep, DRM_RENDER_ALLOW), DRM_IOCTL_DEF_DRV(MSM_GEM_CPU_PREP, msm_ioctl_gem_cpu_prep, DRM_RENDER_ALLOW),
......
...@@ -44,6 +44,8 @@ struct msm_gpu_config { ...@@ -44,6 +44,8 @@ struct msm_gpu_config {
struct msm_gpu_funcs { struct msm_gpu_funcs {
int (*get_param)(struct msm_gpu *gpu, struct msm_file_private *ctx, int (*get_param)(struct msm_gpu *gpu, struct msm_file_private *ctx,
uint32_t param, uint64_t *value); uint32_t param, uint64_t *value);
int (*set_param)(struct msm_gpu *gpu, struct msm_file_private *ctx,
uint32_t param, uint64_t value);
int (*hw_init)(struct msm_gpu *gpu); int (*hw_init)(struct msm_gpu *gpu);
int (*pm_suspend)(struct msm_gpu *gpu); int (*pm_suspend)(struct msm_gpu *gpu);
int (*pm_resume)(struct msm_gpu *gpu); int (*pm_resume)(struct msm_gpu *gpu);
......
...@@ -67,16 +67,20 @@ struct drm_msm_timespec { ...@@ -67,16 +67,20 @@ struct drm_msm_timespec {
__s64 tv_nsec; /* nanoseconds */ __s64 tv_nsec; /* nanoseconds */
}; };
#define MSM_PARAM_GPU_ID 0x01 /* Below "RO" indicates a read-only param, "WO" indicates write-only, and
#define MSM_PARAM_GMEM_SIZE 0x02 * "RW" indicates a param that can be both read (GET_PARAM) and written
#define MSM_PARAM_CHIP_ID 0x03 * (SET_PARAM)
#define MSM_PARAM_MAX_FREQ 0x04 */
#define MSM_PARAM_TIMESTAMP 0x05 #define MSM_PARAM_GPU_ID 0x01 /* RO */
#define MSM_PARAM_GMEM_BASE 0x06 #define MSM_PARAM_GMEM_SIZE 0x02 /* RO */
#define MSM_PARAM_PRIORITIES 0x07 /* The # of priority levels */ #define MSM_PARAM_CHIP_ID 0x03 /* RO */
#define MSM_PARAM_PP_PGTABLE 0x08 /* => 1 for per-process pagetables, else 0 */ #define MSM_PARAM_MAX_FREQ 0x04 /* RO */
#define MSM_PARAM_FAULTS 0x09 #define MSM_PARAM_TIMESTAMP 0x05 /* RO */
#define MSM_PARAM_SUSPENDS 0x0a #define MSM_PARAM_GMEM_BASE 0x06 /* RO */
#define MSM_PARAM_PRIORITIES 0x07 /* RO: The # of priority levels */
#define MSM_PARAM_PP_PGTABLE 0x08 /* RO: Deprecated, always returns zero */
#define MSM_PARAM_FAULTS 0x09 /* RO */
#define MSM_PARAM_SUSPENDS 0x0a /* RO */
/* For backwards compat. The original support for preemption was based on /* For backwards compat. The original support for preemption was based on
* a single ring per priority level so # of priority levels equals the # * a single ring per priority level so # of priority levels equals the #
...@@ -333,9 +337,7 @@ struct drm_msm_submitqueue_query { ...@@ -333,9 +337,7 @@ struct drm_msm_submitqueue_query {
}; };
#define DRM_MSM_GET_PARAM 0x00 #define DRM_MSM_GET_PARAM 0x00
/* placeholder:
#define DRM_MSM_SET_PARAM 0x01 #define DRM_MSM_SET_PARAM 0x01
*/
#define DRM_MSM_GEM_NEW 0x02 #define DRM_MSM_GEM_NEW 0x02
#define DRM_MSM_GEM_INFO 0x03 #define DRM_MSM_GEM_INFO 0x03
#define DRM_MSM_GEM_CPU_PREP 0x04 #define DRM_MSM_GEM_CPU_PREP 0x04
...@@ -351,6 +353,7 @@ struct drm_msm_submitqueue_query { ...@@ -351,6 +353,7 @@ struct drm_msm_submitqueue_query {
#define DRM_MSM_SUBMITQUEUE_QUERY 0x0C #define DRM_MSM_SUBMITQUEUE_QUERY 0x0C
#define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param) #define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
#define DRM_IOCTL_MSM_SET_PARAM DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SET_PARAM, struct drm_msm_param)
#define DRM_IOCTL_MSM_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new) #define DRM_IOCTL_MSM_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
#define DRM_IOCTL_MSM_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_INFO, struct drm_msm_gem_info) #define DRM_IOCTL_MSM_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_INFO, struct drm_msm_gem_info)
#define DRM_IOCTL_MSM_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_PREP, struct drm_msm_gem_cpu_prep) #define DRM_IOCTL_MSM_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_PREP, struct drm_msm_gem_cpu_prep)
......
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