Skip to content

Commit f7ddbf5

Browse files
committed
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: Rob Clark <robdclark@chromium.org> Link: https://lore.kernel.org/r/20220304005317.776110-3-robdclark@gmail.com
1 parent 57cfe41 commit f7ddbf5

10 files changed

Lines changed: 54 additions & 12 deletions

File tree

drivers/gpu/drm/msm/adreno/a2xx_gpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ static u32 a2xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
471471
static const struct adreno_gpu_funcs funcs = {
472472
.base = {
473473
.get_param = adreno_get_param,
474+
.set_param = adreno_set_param,
474475
.hw_init = a2xx_hw_init,
475476
.pm_suspend = msm_gpu_pm_suspend,
476477
.pm_resume = msm_gpu_pm_resume,

drivers/gpu/drm/msm/adreno/a3xx_gpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ static u32 a3xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
486486
static const struct adreno_gpu_funcs funcs = {
487487
.base = {
488488
.get_param = adreno_get_param,
489+
.set_param = adreno_set_param,
489490
.hw_init = a3xx_hw_init,
490491
.pm_suspend = msm_gpu_pm_suspend,
491492
.pm_resume = msm_gpu_pm_resume,

drivers/gpu/drm/msm/adreno/a4xx_gpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ static u32 a4xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
621621
static const struct adreno_gpu_funcs funcs = {
622622
.base = {
623623
.get_param = adreno_get_param,
624+
.set_param = adreno_set_param,
624625
.hw_init = a4xx_hw_init,
625626
.pm_suspend = a4xx_pm_suspend,
626627
.pm_resume = a4xx_pm_resume,

drivers/gpu/drm/msm/adreno/a5xx_gpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,7 @@ static uint32_t a5xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
17001700
static const struct adreno_gpu_funcs funcs = {
17011701
.base = {
17021702
.get_param = adreno_get_param,
1703+
.set_param = adreno_set_param,
17031704
.hw_init = a5xx_hw_init,
17041705
.pm_suspend = a5xx_pm_suspend,
17051706
.pm_resume = a5xx_pm_resume,

drivers/gpu/drm/msm/adreno/a6xx_gpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@ static int a6xx_set_supported_hw(struct device *dev, struct adreno_rev rev)
18001800
static const struct adreno_gpu_funcs funcs = {
18011801
.base = {
18021802
.get_param = adreno_get_param,
1803+
.set_param = adreno_set_param,
18031804
.hw_init = a6xx_hw_init,
18041805
.pm_suspend = a6xx_pm_suspend,
18051806
.pm_resume = a6xx_pm_resume,

drivers/gpu/drm/msm/adreno/adreno_gpu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
283283
}
284284
}
285285

286+
int adreno_set_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
287+
uint32_t param, uint64_t value)
288+
{
289+
switch (param) {
290+
default:
291+
DBG("%s: invalid param: %u", gpu->name, param);
292+
return -EINVAL;
293+
}
294+
}
295+
286296
const struct firmware *
287297
adreno_request_fw(struct adreno_gpu *adreno_gpu, const char *fwname)
288298
{

drivers/gpu/drm/msm/adreno/adreno_gpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ static inline int adreno_is_a650_family(struct adreno_gpu *gpu)
282282

283283
int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
284284
uint32_t param, uint64_t *value);
285+
int adreno_set_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
286+
uint32_t param, uint64_t value);
285287
const struct firmware *adreno_request_fw(struct adreno_gpu *adreno_gpu,
286288
const char *fwname);
287289
struct drm_gem_object *adreno_fw_create_bo(struct msm_gpu *gpu,

drivers/gpu/drm/msm/msm_drv.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,25 @@ static int msm_ioctl_get_param(struct drm_device *dev, void *data,
613613
args->param, &args->value);
614614
}
615615

616+
static int msm_ioctl_set_param(struct drm_device *dev, void *data,
617+
struct drm_file *file)
618+
{
619+
struct msm_drm_private *priv = dev->dev_private;
620+
struct drm_msm_param *args = data;
621+
struct msm_gpu *gpu;
622+
623+
if (args->pipe != MSM_PIPE_3D0)
624+
return -EINVAL;
625+
626+
gpu = priv->gpu;
627+
628+
if (!gpu)
629+
return -ENXIO;
630+
631+
return gpu->funcs->set_param(gpu, file->driver_priv,
632+
args->param, args->value);
633+
}
634+
616635
static int msm_ioctl_gem_new(struct drm_device *dev, void *data,
617636
struct drm_file *file)
618637
{
@@ -898,6 +917,7 @@ static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data,
898917

899918
static const struct drm_ioctl_desc msm_ioctls[] = {
900919
DRM_IOCTL_DEF_DRV(MSM_GET_PARAM, msm_ioctl_get_param, DRM_RENDER_ALLOW),
920+
DRM_IOCTL_DEF_DRV(MSM_SET_PARAM, msm_ioctl_set_param, DRM_RENDER_ALLOW),
901921
DRM_IOCTL_DEF_DRV(MSM_GEM_NEW, msm_ioctl_gem_new, DRM_RENDER_ALLOW),
902922
DRM_IOCTL_DEF_DRV(MSM_GEM_INFO, msm_ioctl_gem_info, DRM_RENDER_ALLOW),
903923
DRM_IOCTL_DEF_DRV(MSM_GEM_CPU_PREP, msm_ioctl_gem_cpu_prep, DRM_RENDER_ALLOW),

drivers/gpu/drm/msm/msm_gpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct msm_gpu_config {
4444
struct msm_gpu_funcs {
4545
int (*get_param)(struct msm_gpu *gpu, struct msm_file_private *ctx,
4646
uint32_t param, uint64_t *value);
47+
int (*set_param)(struct msm_gpu *gpu, struct msm_file_private *ctx,
48+
uint32_t param, uint64_t value);
4749
int (*hw_init)(struct msm_gpu *gpu);
4850
int (*pm_suspend)(struct msm_gpu *gpu);
4951
int (*pm_resume)(struct msm_gpu *gpu);

include/uapi/drm/msm_drm.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,20 @@ struct drm_msm_timespec {
6767
__s64 tv_nsec; /* nanoseconds */
6868
};
6969

70-
#define MSM_PARAM_GPU_ID 0x01
71-
#define MSM_PARAM_GMEM_SIZE 0x02
72-
#define MSM_PARAM_CHIP_ID 0x03
73-
#define MSM_PARAM_MAX_FREQ 0x04
74-
#define MSM_PARAM_TIMESTAMP 0x05
75-
#define MSM_PARAM_GMEM_BASE 0x06
76-
#define MSM_PARAM_PRIORITIES 0x07 /* The # of priority levels */
77-
#define MSM_PARAM_PP_PGTABLE 0x08 /* => 1 for per-process pagetables, else 0 */
78-
#define MSM_PARAM_FAULTS 0x09
79-
#define MSM_PARAM_SUSPENDS 0x0a
70+
/* Below "RO" indicates a read-only param, "WO" indicates write-only, and
71+
* "RW" indicates a param that can be both read (GET_PARAM) and written
72+
* (SET_PARAM)
73+
*/
74+
#define MSM_PARAM_GPU_ID 0x01 /* RO */
75+
#define MSM_PARAM_GMEM_SIZE 0x02 /* RO */
76+
#define MSM_PARAM_CHIP_ID 0x03 /* RO */
77+
#define MSM_PARAM_MAX_FREQ 0x04 /* RO */
78+
#define MSM_PARAM_TIMESTAMP 0x05 /* RO */
79+
#define MSM_PARAM_GMEM_BASE 0x06 /* RO */
80+
#define MSM_PARAM_PRIORITIES 0x07 /* RO: The # of priority levels */
81+
#define MSM_PARAM_PP_PGTABLE 0x08 /* RO: Deprecated, always returns zero */
82+
#define MSM_PARAM_FAULTS 0x09 /* RO */
83+
#define MSM_PARAM_SUSPENDS 0x0a /* RO */
8084

8185
/* For backwards compat. The original support for preemption was based on
8286
* a single ring per priority level so # of priority levels equals the #
@@ -333,9 +337,7 @@ struct drm_msm_submitqueue_query {
333337
};
334338

335339
#define DRM_MSM_GET_PARAM 0x00
336-
/* placeholder:
337340
#define DRM_MSM_SET_PARAM 0x01
338-
*/
339341
#define DRM_MSM_GEM_NEW 0x02
340342
#define DRM_MSM_GEM_INFO 0x03
341343
#define DRM_MSM_GEM_CPU_PREP 0x04
@@ -351,6 +353,7 @@ struct drm_msm_submitqueue_query {
351353
#define DRM_MSM_SUBMITQUEUE_QUERY 0x0C
352354

353355
#define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
356+
#define DRM_IOCTL_MSM_SET_PARAM DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SET_PARAM, struct drm_msm_param)
354357
#define DRM_IOCTL_MSM_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
355358
#define DRM_IOCTL_MSM_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_INFO, struct drm_msm_gem_info)
356359
#define DRM_IOCTL_MSM_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_PREP, struct drm_msm_gem_cpu_prep)

0 commit comments

Comments
 (0)