aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/imx/imx-drm-core.c
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2016-08-11 05:18:51 -0400
committerPhilipp Zabel <p.zabel@pengutronix.de>2016-08-29 06:45:05 -0400
commita40e65b76430a6ce0bb22ed8327c56dd5044a4a3 (patch)
tree902d0ca3636e8e7bf7b6f5bc6df9b223d7e41d8d /drivers/gpu/drm/imx/imx-drm-core.c
parentdf4b2233ab387fc508f4206cdf5546570136ebd0 (diff)
drm/imx: add exclusive fence to plane state
This allows the atomic helper to wait on them, instead of open-coding the same in the imx-drm driver. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers/gpu/drm/imx/imx-drm-core.c')
-rw-r--r--drivers/gpu/drm/imx/imx-drm-core.c63
1 files changed, 28 insertions, 35 deletions
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 3cc8e4ad639b..98df09c2b388 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -151,50 +151,43 @@ static int imx_drm_atomic_check(struct drm_device *dev,
151 return ret; 151 return ret;
152} 152}
153 153
154static int imx_drm_atomic_commit(struct drm_device *dev,
155 struct drm_atomic_state *state,
156 bool nonblock)
157{
158 struct drm_plane_state *plane_state;
159 struct drm_plane *plane;
160 struct dma_buf *dma_buf;
161 int i;
162
163 /*
164 * If the plane fb has an dma-buf attached, fish out the exclusive
165 * fence for the atomic helper to wait on.
166 */
167 for_each_plane_in_state(state, plane, plane_state, i) {
168 if ((plane->state->fb != plane_state->fb) && plane_state->fb) {
169 dma_buf = drm_fb_cma_get_gem_obj(plane_state->fb,
170 0)->base.dma_buf;
171 if (!dma_buf)
172 continue;
173 plane_state->fence =
174 reservation_object_get_excl_rcu(dma_buf->resv);
175 }
176 }
177
178 return drm_atomic_helper_commit(dev, state, nonblock);
179}
180
154static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { 181static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = {
155 .fb_create = drm_fb_cma_create, 182 .fb_create = drm_fb_cma_create,
156 .output_poll_changed = imx_drm_output_poll_changed, 183 .output_poll_changed = imx_drm_output_poll_changed,
157 .atomic_check = imx_drm_atomic_check, 184 .atomic_check = imx_drm_atomic_check,
158 .atomic_commit = drm_atomic_helper_commit, 185 .atomic_commit = imx_drm_atomic_commit,
159}; 186};
160 187
161static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state) 188static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state)
162{ 189{
163 struct drm_device *dev = state->dev; 190 struct drm_device *dev = state->dev;
164 struct drm_crtc *crtc;
165 struct drm_crtc_state *crtc_state;
166 struct drm_plane_state *plane_state;
167 struct drm_gem_cma_object *cma_obj;
168 struct fence *excl;
169 unsigned shared_count;
170 struct fence **shared;
171 unsigned int i, j;
172 int ret;
173
174 /* Wait for fences. */
175 for_each_crtc_in_state(state, crtc, crtc_state, i) {
176 plane_state = crtc->primary->state;
177 if (plane_state->fb) {
178 cma_obj = drm_fb_cma_get_gem_obj(plane_state->fb, 0);
179 if (cma_obj->base.dma_buf) {
180 ret = reservation_object_get_fences_rcu(
181 cma_obj->base.dma_buf->resv, &excl,
182 &shared_count, &shared);
183 if (unlikely(ret))
184 DRM_ERROR("failed to get fences "
185 "for buffer\n");
186
187 if (excl) {
188 fence_wait(excl, false);
189 fence_put(excl);
190 }
191 for (j = 0; j < shared_count; i++) {
192 fence_wait(shared[j], false);
193 fence_put(shared[j]);
194 }
195 }
196 }
197 }
198 191
199 drm_atomic_helper_commit_modeset_disables(dev, state); 192 drm_atomic_helper_commit_modeset_disables(dev, state);
200 193