freedreno/drm: Add SYSPROF param

Add new param for putting kernel in system-profiling mode and add
corresponding fd_pipe_set_param() mechanism.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15236>
This commit is contained in:
Rob Clark 2022-03-03 15:34:36 -08:00
parent f925794b16
commit af4b7f74b2
4 changed files with 39 additions and 0 deletions

View File

@ -62,6 +62,7 @@ enum fd_param_id {
FD_CTX_FAULTS, /* # of per context faults */
FD_GLOBAL_FAULTS, /* # of global (all context) faults */
FD_SUSPEND_COUNT, /* # of times the GPU has suspended, and potentially lost state */
FD_SYSPROF, /* Settable (for CAP_SYS_ADMIN) param for system profiling */
};
/**
@ -149,6 +150,8 @@ void fd_pipe_purge(struct fd_pipe *pipe);
const struct fd_dev_id * fd_pipe_dev_id(struct fd_pipe *pipe);
int fd_pipe_get_param(struct fd_pipe *pipe, enum fd_param_id param,
uint64_t *value);
int fd_pipe_set_param(struct fd_pipe *pipe, enum fd_param_id param,
uint64_t value);
int fd_pipe_wait(struct fd_pipe *pipe, const struct fd_fence *fence);
/* timeout in nanosec */
int fd_pipe_wait_timeout(struct fd_pipe *pipe, const struct fd_fence *fence,

View File

@ -164,6 +164,12 @@ fd_pipe_get_param(struct fd_pipe *pipe, enum fd_param_id param, uint64_t *value)
return pipe->funcs->get_param(pipe, param, value);
}
int
fd_pipe_set_param(struct fd_pipe *pipe, enum fd_param_id param, uint64_t value)
{
return pipe->funcs->set_param(pipe, param, value);
}
const struct fd_dev_id *
fd_pipe_dev_id(struct fd_pipe *pipe)
{

View File

@ -198,6 +198,8 @@ struct fd_pipe_funcs {
int (*get_param)(struct fd_pipe *pipe, enum fd_param_id param,
uint64_t *value);
int (*set_param)(struct fd_pipe *pipe, enum fd_param_id param,
uint64_t value);
int (*wait)(struct fd_pipe *pipe, const struct fd_fence *fence,
uint64_t timeout);
void (*destroy)(struct fd_pipe *pipe);

View File

@ -107,6 +107,32 @@ msm_pipe_get_param(struct fd_pipe *pipe, enum fd_param_id param,
}
}
static int
set_param(struct fd_pipe *pipe, uint32_t param, uint64_t value)
{
struct msm_pipe *msm_pipe = to_msm_pipe(pipe);
struct drm_msm_param req = {
.pipe = msm_pipe->pipe,
.param = param,
.value = value,
};
return drmCommandWriteRead(pipe->dev->fd, DRM_MSM_SET_PARAM,
&req, sizeof(req));
}
static int
msm_pipe_set_param(struct fd_pipe *pipe, enum fd_param_id param, uint64_t value)
{
switch (param) {
case FD_SYSPROF:
return set_param(pipe, MSM_PARAM_SYSPROF, value);
default:
ERROR_MSG("invalid param id: %d", param);
return -1;
}
}
static int
msm_pipe_wait(struct fd_pipe *pipe, const struct fd_fence *fence, uint64_t timeout)
{
@ -182,6 +208,7 @@ static const struct fd_pipe_funcs sp_funcs = {
.submit_new = msm_submit_sp_new,
.flush = msm_pipe_sp_flush,
.get_param = msm_pipe_get_param,
.set_param = msm_pipe_set_param,
.wait = msm_pipe_wait,
.destroy = msm_pipe_destroy,
};
@ -190,6 +217,7 @@ static const struct fd_pipe_funcs legacy_funcs = {
.ringbuffer_new_object = msm_ringbuffer_new_object,
.submit_new = msm_submit_new,
.get_param = msm_pipe_get_param,
.set_param = msm_pipe_set_param,
.wait = msm_pipe_wait,
.destroy = msm_pipe_destroy,
};