freedreno/drm: Add SYSPROF param
authorRob Clark <robdclark@chromium.org>
Thu, 3 Mar 2022 23:34:36 +0000 (15:34 -0800)
committerRob Clark <robdclark@chromium.org>
Sat, 5 Mar 2022 00:06:34 +0000 (16:06 -0800)
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>

src/freedreno/drm/freedreno_drmif.h
src/freedreno/drm/freedreno_pipe.c
src/freedreno/drm/freedreno_priv.h
src/freedreno/drm/msm_pipe.c

index 5c2b1d9..074f475 100644 (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,
index 83052b9..579c98c 100644 (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)
 {
index bb165b8..dbdfd80 100644 (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);
index 4a71a9f..49587fc 100644 (file)
@@ -108,6 +108,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)
 {
    struct fd_device *dev = pipe->dev;
@@ -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,
 };