Skip to content

Commit d39e48c

Browse files
committed
drm/atomic-helper: Set fence deadline for vblank
For an atomic commit updating a single CRTC (ie. a pageflip) calculate the next vblank time, and inform the fence(s) of that deadline. v2: Comment typo fix (danvet) v3: If there are multiple CRTCs, consider the time of the soonest vblank Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent b2c077d commit d39e48c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

drivers/gpu/drm/drm_atomic_helper.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,41 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
15111511
}
15121512
EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_enables);
15131513

1514+
/*
1515+
* For atomic updates which touch just a single CRTC, calculate the time of the
1516+
* next vblank, and inform all the fences of the deadline.
1517+
*/
1518+
static void set_fence_deadline(struct drm_device *dev,
1519+
struct drm_atomic_state *state)
1520+
{
1521+
struct drm_crtc *crtc;
1522+
struct drm_crtc_state *new_crtc_state;
1523+
struct drm_plane *plane;
1524+
struct drm_plane_state *new_plane_state;
1525+
ktime_t vbltime = 0;
1526+
int i;
1527+
1528+
for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) {
1529+
ktime_t v;
1530+
1531+
if (drm_crtc_next_vblank_start(crtc, &v))
1532+
continue;
1533+
1534+
if (!vbltime || ktime_before(v, vbltime))
1535+
vbltime = v;
1536+
}
1537+
1538+
/* If no CRTCs updated, then nothing to do: */
1539+
if (!vbltime)
1540+
return;
1541+
1542+
for_each_new_plane_in_state (state, plane, new_plane_state, i) {
1543+
if (!new_plane_state->fence)
1544+
continue;
1545+
dma_fence_set_deadline(new_plane_state->fence, vbltime);
1546+
}
1547+
}
1548+
15141549
/**
15151550
* drm_atomic_helper_wait_for_fences - wait for fences stashed in plane state
15161551
* @dev: DRM device
@@ -1540,6 +1575,8 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
15401575
struct drm_plane_state *new_plane_state;
15411576
int i, ret;
15421577

1578+
set_fence_deadline(dev, state);
1579+
15431580
for_each_new_plane_in_state(state, plane, new_plane_state, i) {
15441581
if (!new_plane_state->fence)
15451582
continue;

0 commit comments

Comments
 (0)