aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien DESSENNE <fabien.dessenne@st.com>2017-01-12 11:27:35 -0500
committerVincent Abriou <vincent.abriou@st.com>2017-02-10 03:34:39 -0500
commit5e60f595d6cad3279f4653ea43843a3db91b59e5 (patch)
treedfe8abe4d308feba1f9ada180a7d831ded5e155b
parent13f62f54d174d3417c3caaafedf5e22a0a03e442 (diff)
drm/sti: use atomic_helper for commit
Since nonblocking atomic commits are now supported, the driver can now use drm_atomic_helper_commit(). Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com> Acked-by: Vincent Abriou <vincent.abriou@st.com>
-rw-r--r--drivers/gpu/drm/sti/sti_drv.c84
-rw-r--r--drivers/gpu/drm/sti/sti_drv.h6
2 files changed, 6 insertions, 84 deletions
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 788feed208d7..9e4d96f7dd1c 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -115,50 +115,13 @@ err:
115 return ret; 115 return ret;
116} 116}
117 117
118static void sti_atomic_schedule(struct sti_private *private, 118static void sti_drm_dbg_cleanup(struct drm_minor *minor)
119 struct drm_atomic_state *state)
120{ 119{
121 private->commit.state = state; 120 drm_debugfs_remove_files(sti_drm_dbg_list,
122 schedule_work(&private->commit.work); 121 ARRAY_SIZE(sti_drm_dbg_list), minor);
123}
124
125static void sti_atomic_complete(struct sti_private *private,
126 struct drm_atomic_state *state)
127{
128 struct drm_device *drm = private->drm_dev;
129
130 /*
131 * Everything below can be run asynchronously without the need to grab
132 * any modeset locks at all under one condition: It must be guaranteed
133 * that the asynchronous work has either been cancelled (if the driver
134 * supports it, which at least requires that the framebuffers get
135 * cleaned up with drm_atomic_helper_cleanup_planes()) or completed
136 * before the new state gets committed on the software side with
137 * drm_atomic_helper_swap_state().
138 *
139 * This scheme allows new atomic state updates to be prepared and
140 * checked in parallel to the asynchronous completion of the previous
141 * update. Which is important since compositors need to figure out the
142 * composition of the next frame right after having submitted the
143 * current layout.
144 */
145
146 drm_atomic_helper_commit_modeset_disables(drm, state);
147 drm_atomic_helper_commit_planes(drm, state, 0);
148 drm_atomic_helper_commit_modeset_enables(drm, state);
149 122
150 drm_atomic_helper_wait_for_vblanks(drm, state); 123 drm_debugfs_remove_files((struct drm_info_list *)&sti_drm_fps_fops,
151 124 1, minor);
152 drm_atomic_helper_cleanup_planes(drm, state);
153 drm_atomic_state_put(state);
154}
155
156static void sti_atomic_work(struct work_struct *work)
157{
158 struct sti_private *private = container_of(work,
159 struct sti_private, commit.work);
160
161 sti_atomic_complete(private, private->commit.state);
162} 125}
163 126
164static int sti_atomic_check(struct drm_device *dev, 127static int sti_atomic_check(struct drm_device *dev,
@@ -181,38 +144,6 @@ static int sti_atomic_check(struct drm_device *dev,
181 return ret; 144 return ret;
182} 145}
183 146
184static int sti_atomic_commit(struct drm_device *drm,
185 struct drm_atomic_state *state, bool nonblock)
186{
187 struct sti_private *private = drm->dev_private;
188 int err;
189
190 err = drm_atomic_helper_prepare_planes(drm, state);
191 if (err)
192 return err;
193
194 /* serialize outstanding nonblocking commits */
195 mutex_lock(&private->commit.lock);
196 flush_work(&private->commit.work);
197
198 /*
199 * This is the point of no return - everything below never fails except
200 * when the hw goes bonghits. Which means we can commit the new state on
201 * the software side now.
202 */
203
204 drm_atomic_helper_swap_state(state, true);
205
206 drm_atomic_state_get(state);
207 if (nonblock)
208 sti_atomic_schedule(private, state);
209 else
210 sti_atomic_complete(private, state);
211
212 mutex_unlock(&private->commit.lock);
213 return 0;
214}
215
216static void sti_output_poll_changed(struct drm_device *ddev) 147static void sti_output_poll_changed(struct drm_device *ddev)
217{ 148{
218 struct sti_private *private = ddev->dev_private; 149 struct sti_private *private = ddev->dev_private;
@@ -224,7 +155,7 @@ static const struct drm_mode_config_funcs sti_mode_config_funcs = {
224 .fb_create = drm_fb_cma_create, 155 .fb_create = drm_fb_cma_create,
225 .output_poll_changed = sti_output_poll_changed, 156 .output_poll_changed = sti_output_poll_changed,
226 .atomic_check = sti_atomic_check, 157 .atomic_check = sti_atomic_check,
227 .atomic_commit = sti_atomic_commit, 158 .atomic_commit = drm_atomic_helper_commit,
228}; 159};
229 160
230static void sti_mode_config_init(struct drm_device *dev) 161static void sti_mode_config_init(struct drm_device *dev)
@@ -304,9 +235,6 @@ static int sti_init(struct drm_device *ddev)
304 dev_set_drvdata(ddev->dev, ddev); 235 dev_set_drvdata(ddev->dev, ddev);
305 private->drm_dev = ddev; 236 private->drm_dev = ddev;
306 237
307 mutex_init(&private->commit.lock);
308 INIT_WORK(&private->commit.work, sti_atomic_work);
309
310 drm_mode_config_init(ddev); 238 drm_mode_config_init(ddev);
311 239
312 sti_mode_config_init(ddev); 240 sti_mode_config_init(ddev);
diff --git a/drivers/gpu/drm/sti/sti_drv.h b/drivers/gpu/drm/sti/sti_drv.h
index 4c75845cc9ab..6502ed2d3351 100644
--- a/drivers/gpu/drm/sti/sti_drv.h
+++ b/drivers/gpu/drm/sti/sti_drv.h
@@ -25,12 +25,6 @@ struct sti_private {
25 struct drm_property *plane_zorder_property; 25 struct drm_property *plane_zorder_property;
26 struct drm_device *drm_dev; 26 struct drm_device *drm_dev;
27 struct drm_fbdev_cma *fbdev; 27 struct drm_fbdev_cma *fbdev;
28
29 struct {
30 struct drm_atomic_state *state;
31 struct work_struct work;
32 struct mutex lock;
33 } commit;
34}; 28};
35 29
36extern struct platform_driver sti_tvout_driver; 30extern struct platform_driver sti_tvout_driver;