@@ -1006,13 +1006,21 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_enables);
10061006 * drm_atomic_helper_wait_for_fences - wait for fences stashed in plane state
10071007 * @dev: DRM device
10081008 * @state: atomic state object with old state structures
1009- * @pre_swap: if true, do an interruptible wait
1009+ * @pre_swap: If true, do an interruptible wait, and @state is the new state.
1010+ * Otherwise @state is the old state.
10101011 *
10111012 * For implicit sync, driver should fish the exclusive fence out from the
10121013 * incoming fb's and stash it in the drm_plane_state. This is called after
10131014 * drm_atomic_helper_swap_state() so it uses the current plane state (and
10141015 * just uses the atomic state to find the changed planes)
10151016 *
1017+ * Note that @pre_swap is needed since the point where we block for fences moves
1018+ * around depending upon whether an atomic commit is blocking or
1019+ * non-blocking. For async commit all waiting needs to happen after
1020+ * drm_atomic_helper_swap_state() is called, but for synchronous commits we want
1021+ * to wait **before** we do anything that can't be easily rolled back. That is
1022+ * before we call drm_atomic_helper_swap_state().
1023+ *
10161024 * Returns zero if success or < 0 if dma_fence_wait() fails.
10171025 */
10181026int drm_atomic_helper_wait_for_fences (struct drm_device * dev ,
@@ -1147,7 +1155,7 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_vblanks);
11471155
11481156/**
11491157 * drm_atomic_helper_commit_tail - commit atomic update to hardware
1150- * @state: new modeset state to be committed
1158+ * @old_state: atomic state object with old state structures
11511159 *
11521160 * This is the default implemenation for the ->atomic_commit_tail() hook of the
11531161 * &drm_mode_config_helper_funcs vtable.
@@ -1158,53 +1166,53 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_vblanks);
11581166 *
11591167 * For drivers supporting runtime PM the recommended sequence is instead ::
11601168 *
1161- * drm_atomic_helper_commit_modeset_disables(dev, state );
1169+ * drm_atomic_helper_commit_modeset_disables(dev, old_state );
11621170 *
1163- * drm_atomic_helper_commit_modeset_enables(dev, state );
1171+ * drm_atomic_helper_commit_modeset_enables(dev, old_state );
11641172 *
1165- * drm_atomic_helper_commit_planes(dev, state ,
1173+ * drm_atomic_helper_commit_planes(dev, old_state ,
11661174 * DRM_PLANE_COMMIT_ACTIVE_ONLY);
11671175 *
11681176 * for committing the atomic update to hardware. See the kerneldoc entries for
11691177 * these three functions for more details.
11701178 */
1171- void drm_atomic_helper_commit_tail (struct drm_atomic_state * state )
1179+ void drm_atomic_helper_commit_tail (struct drm_atomic_state * old_state )
11721180{
1173- struct drm_device * dev = state -> dev ;
1181+ struct drm_device * dev = old_state -> dev ;
11741182
1175- drm_atomic_helper_commit_modeset_disables (dev , state );
1183+ drm_atomic_helper_commit_modeset_disables (dev , old_state );
11761184
1177- drm_atomic_helper_commit_planes (dev , state , 0 );
1185+ drm_atomic_helper_commit_planes (dev , old_state , 0 );
11781186
1179- drm_atomic_helper_commit_modeset_enables (dev , state );
1187+ drm_atomic_helper_commit_modeset_enables (dev , old_state );
11801188
1181- drm_atomic_helper_commit_hw_done (state );
1189+ drm_atomic_helper_commit_hw_done (old_state );
11821190
1183- drm_atomic_helper_wait_for_vblanks (dev , state );
1191+ drm_atomic_helper_wait_for_vblanks (dev , old_state );
11841192
1185- drm_atomic_helper_cleanup_planes (dev , state );
1193+ drm_atomic_helper_cleanup_planes (dev , old_state );
11861194}
11871195EXPORT_SYMBOL (drm_atomic_helper_commit_tail );
11881196
1189- static void commit_tail (struct drm_atomic_state * state )
1197+ static void commit_tail (struct drm_atomic_state * old_state )
11901198{
1191- struct drm_device * dev = state -> dev ;
1199+ struct drm_device * dev = old_state -> dev ;
11921200 struct drm_mode_config_helper_funcs * funcs ;
11931201
11941202 funcs = dev -> mode_config .helper_private ;
11951203
1196- drm_atomic_helper_wait_for_fences (dev , state , false);
1204+ drm_atomic_helper_wait_for_fences (dev , old_state , false);
11971205
1198- drm_atomic_helper_wait_for_dependencies (state );
1206+ drm_atomic_helper_wait_for_dependencies (old_state );
11991207
12001208 if (funcs && funcs -> atomic_commit_tail )
1201- funcs -> atomic_commit_tail (state );
1209+ funcs -> atomic_commit_tail (old_state );
12021210 else
1203- drm_atomic_helper_commit_tail (state );
1211+ drm_atomic_helper_commit_tail (old_state );
12041212
1205- drm_atomic_helper_commit_cleanup_done (state );
1213+ drm_atomic_helper_commit_cleanup_done (old_state );
12061214
1207- drm_atomic_state_put (state );
1215+ drm_atomic_state_put (old_state );
12081216}
12091217
12101218static void commit_work (struct work_struct * work )
@@ -1498,26 +1506,26 @@ static struct drm_crtc_commit *preceeding_commit(struct drm_crtc *crtc)
14981506
14991507/**
15001508 * drm_atomic_helper_wait_for_dependencies - wait for required preceeding commits
1501- * @state: new modeset state to be committed
1509+ * @old_state: atomic state object with old state structures
15021510 *
15031511 * This function waits for all preceeding commits that touch the same CRTC as
1504- * @state to both be committed to the hardware (as signalled by
1512+ * @old_state to both be committed to the hardware (as signalled by
15051513 * drm_atomic_helper_commit_hw_done) and executed by the hardware (as signalled
15061514 * by calling drm_crtc_vblank_send_event on the event member of
15071515 * &drm_crtc_state).
15081516 *
15091517 * This is part of the atomic helper support for nonblocking commits, see
15101518 * drm_atomic_helper_setup_commit() for an overview.
15111519 */
1512- void drm_atomic_helper_wait_for_dependencies (struct drm_atomic_state * state )
1520+ void drm_atomic_helper_wait_for_dependencies (struct drm_atomic_state * old_state )
15131521{
15141522 struct drm_crtc * crtc ;
15151523 struct drm_crtc_state * crtc_state ;
15161524 struct drm_crtc_commit * commit ;
15171525 int i ;
15181526 long ret ;
15191527
1520- for_each_crtc_in_state (state , crtc , crtc_state , i ) {
1528+ for_each_crtc_in_state (old_state , crtc , crtc_state , i ) {
15211529 spin_lock (& crtc -> commit_lock );
15221530 commit = preceeding_commit (crtc );
15231531 if (commit )
@@ -1548,7 +1556,7 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);
15481556
15491557/**
15501558 * drm_atomic_helper_commit_hw_done - setup possible nonblocking commit
1551- * @state: new modeset state to be committed
1559+ * @old_state: atomic state object with old state structures
15521560 *
15531561 * This function is used to signal completion of the hardware commit step. After
15541562 * this step the driver is not allowed to read or change any permanent software
@@ -1561,15 +1569,15 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);
15611569 * This is part of the atomic helper support for nonblocking commits, see
15621570 * drm_atomic_helper_setup_commit() for an overview.
15631571 */
1564- void drm_atomic_helper_commit_hw_done (struct drm_atomic_state * state )
1572+ void drm_atomic_helper_commit_hw_done (struct drm_atomic_state * old_state )
15651573{
15661574 struct drm_crtc * crtc ;
15671575 struct drm_crtc_state * crtc_state ;
15681576 struct drm_crtc_commit * commit ;
15691577 int i ;
15701578
1571- for_each_crtc_in_state (state , crtc , crtc_state , i ) {
1572- commit = state -> crtcs [i ].commit ;
1579+ for_each_crtc_in_state (old_state , crtc , crtc_state , i ) {
1580+ commit = old_state -> crtcs [i ].commit ;
15731581 if (!commit )
15741582 continue ;
15751583
@@ -1584,25 +1592,25 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_hw_done);
15841592
15851593/**
15861594 * drm_atomic_helper_commit_cleanup_done - signal completion of commit
1587- * @state: new modeset state to be committed
1595+ * @old_state: atomic state object with old state structures
15881596 *
1589- * This signals completion of the atomic update @state , including any cleanup
1590- * work. If used, it must be called right before calling
1597+ * This signals completion of the atomic update @old_state , including any
1598+ * cleanup work. If used, it must be called right before calling
15911599 * drm_atomic_state_put().
15921600 *
15931601 * This is part of the atomic helper support for nonblocking commits, see
15941602 * drm_atomic_helper_setup_commit() for an overview.
15951603 */
1596- void drm_atomic_helper_commit_cleanup_done (struct drm_atomic_state * state )
1604+ void drm_atomic_helper_commit_cleanup_done (struct drm_atomic_state * old_state )
15971605{
15981606 struct drm_crtc * crtc ;
15991607 struct drm_crtc_state * crtc_state ;
16001608 struct drm_crtc_commit * commit ;
16011609 int i ;
16021610 long ret ;
16031611
1604- for_each_crtc_in_state (state , crtc , crtc_state , i ) {
1605- commit = state -> crtcs [i ].commit ;
1612+ for_each_crtc_in_state (old_state , crtc , crtc_state , i ) {
1613+ commit = old_state -> crtcs [i ].commit ;
16061614 if (WARN_ON (!commit ))
16071615 continue ;
16081616
0 commit comments