aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'freedreno/msm/msm_pipe.c')
-rw-r--r--freedreno/msm/msm_pipe.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/freedreno/msm/msm_pipe.c b/freedreno/msm/msm_pipe.c
index f872e245..f28778ef 100644
--- a/freedreno/msm/msm_pipe.c
+++ b/freedreno/msm/msm_pipe.c
@@ -26,10 +26,6 @@
26 * Rob Clark <robclark@freedesktop.org> 26 * Rob Clark <robclark@freedesktop.org>
27 */ 27 */
28 28
29#ifdef HAVE_CONFIG_H
30# include <config.h>
31#endif
32
33#include "msm_priv.h" 29#include "msm_priv.h"
34 30
35static int query_param(struct fd_pipe *pipe, uint32_t param, 31static int query_param(struct fd_pipe *pipe, uint32_t param,
@@ -71,6 +67,8 @@ static int msm_pipe_get_param(struct fd_pipe *pipe,
71 return query_param(pipe, MSM_PARAM_MAX_FREQ, value); 67 return query_param(pipe, MSM_PARAM_MAX_FREQ, value);
72 case FD_TIMESTAMP: 68 case FD_TIMESTAMP:
73 return query_param(pipe, MSM_PARAM_TIMESTAMP, value); 69 return query_param(pipe, MSM_PARAM_TIMESTAMP, value);
70 case FD_NR_RINGS:
71 return query_param(pipe, MSM_PARAM_NR_RINGS, value);
74 default: 72 default:
75 ERROR_MSG("invalid param id: %d", param); 73 ERROR_MSG("invalid param id: %d", param);
76 return -1; 74 return -1;
@@ -83,6 +81,7 @@ static int msm_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp,
83 struct fd_device *dev = pipe->dev; 81 struct fd_device *dev = pipe->dev;
84 struct drm_msm_wait_fence req = { 82 struct drm_msm_wait_fence req = {
85 .fence = timestamp, 83 .fence = timestamp,
84 .queueid = to_msm_pipe(pipe)->queue_id,
86 }; 85 };
87 int ret; 86 int ret;
88 87
@@ -97,9 +96,48 @@ static int msm_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp,
97 return 0; 96 return 0;
98} 97}
99 98
99static int open_submitqueue(struct fd_pipe *pipe, uint32_t prio)
100{
101 struct drm_msm_submitqueue req = {
102 .flags = 0,
103 .prio = prio,
104 };
105 uint64_t nr_rings = 1;
106 int ret;
107
108 if (fd_device_version(pipe->dev) < FD_VERSION_SUBMIT_QUEUES) {
109 to_msm_pipe(pipe)->queue_id = 0;
110 return 0;
111 }
112
113 msm_pipe_get_param(pipe, FD_NR_RINGS, &nr_rings);
114
115 req.prio = MIN2(req.prio, MAX2(nr_rings, 1) - 1);
116
117 ret = drmCommandWriteRead(pipe->dev->fd, DRM_MSM_SUBMITQUEUE_NEW,
118 &req, sizeof(req));
119 if (ret) {
120 ERROR_MSG("could not create submitqueue! %d (%s)", ret, strerror(errno));
121 return ret;
122 }
123
124 to_msm_pipe(pipe)->queue_id = req.id;
125 return 0;
126}
127
128static void close_submitqueue(struct fd_pipe *pipe, uint32_t queue_id)
129{
130 if (fd_device_version(pipe->dev) < FD_VERSION_SUBMIT_QUEUES)
131 return;
132
133 drmCommandWrite(pipe->dev->fd, DRM_MSM_SUBMITQUEUE_CLOSE,
134 &queue_id, sizeof(queue_id));
135}
136
100static void msm_pipe_destroy(struct fd_pipe *pipe) 137static void msm_pipe_destroy(struct fd_pipe *pipe)
101{ 138{
102 struct msm_pipe *msm_pipe = to_msm_pipe(pipe); 139 struct msm_pipe *msm_pipe = to_msm_pipe(pipe);
140 close_submitqueue(pipe, msm_pipe->queue_id);
103 free(msm_pipe); 141 free(msm_pipe);
104} 142}
105 143
@@ -122,7 +160,7 @@ static uint64_t get_param(struct fd_pipe *pipe, uint32_t param)
122} 160}
123 161
124drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev, 162drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev,
125 enum fd_pipe_id id) 163 enum fd_pipe_id id, uint32_t prio)
126{ 164{
127 static const uint32_t pipe_id[] = { 165 static const uint32_t pipe_id[] = {
128 [FD_PIPE_3D] = MSM_PIPE_3D0, 166 [FD_PIPE_3D] = MSM_PIPE_3D0,
@@ -157,6 +195,9 @@ drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev,
157 INFO_MSG(" Chip-id: 0x%08x", msm_pipe->chip_id); 195 INFO_MSG(" Chip-id: 0x%08x", msm_pipe->chip_id);
158 INFO_MSG(" GMEM size: 0x%08x", msm_pipe->gmem); 196 INFO_MSG(" GMEM size: 0x%08x", msm_pipe->gmem);
159 197
198 if (open_submitqueue(pipe, prio))
199 goto fail;
200
160 return pipe; 201 return pipe;
161fail: 202fail:
162 if (pipe) 203 if (pipe)