Skip to content

Commit dbd9f78

Browse files
committed
Merge tag 'drm-misc-fixes-2019-06-05' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
- Allow fb changes in async commits (fixes igt failures) (Helen) - Actually unmap the scatterlist when unmapping udmabuf (Lucas) Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Helen Koike <helen.koike@collabora.com> Signed-off-by: Dave Airlie <airlied@redhat.com> From: Sean Paul <sean@poorly.run> Link: https://patchwork.freedesktop.org/patch/msgid/20190605210335.GA35431@art_vandelay
2 parents 75cb377 + 283f1e3 commit dbd9f78

7 files changed

Lines changed: 53 additions & 38 deletions

File tree

‎drivers/dma-buf/udmabuf.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static void unmap_udmabuf(struct dma_buf_attachment *at,
7777
struct sg_table *sg,
7878
enum dma_data_direction direction)
7979
{
80+
dma_unmap_sg(at->dev, sg->sgl, sg->nents, direction);
8081
sg_free_table(sg);
8182
kfree(sg);
8283
}

‎drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,8 +4232,7 @@ static void dm_plane_atomic_async_update(struct drm_plane *plane,
42324232
struct drm_plane_state *old_state =
42334233
drm_atomic_get_old_plane_state(new_state->state, plane);
42344234

4235-
if (plane->state->fb != new_state->fb)
4236-
drm_atomic_set_fb_for_plane(plane->state, new_state->fb);
4235+
swap(plane->state->fb, new_state->fb);
42374236

42384237
plane->state->src_x = new_state->src_x;
42394238
plane->state->src_y = new_state->src_y;

‎drivers/gpu/drm/drm_atomic_helper.c‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,15 +1607,6 @@ int drm_atomic_helper_async_check(struct drm_device *dev,
16071607
old_plane_state->crtc != new_plane_state->crtc)
16081608
return -EINVAL;
16091609

1610-
/*
1611-
* FIXME: Since prepare_fb and cleanup_fb are always called on
1612-
* the new_plane_state for async updates we need to block framebuffer
1613-
* changes. This prevents use of a fb that's been cleaned up and
1614-
* double cleanups from occuring.
1615-
*/
1616-
if (old_plane_state->fb != new_plane_state->fb)
1617-
return -EINVAL;
1618-
16191610
funcs = plane->helper_private;
16201611
if (!funcs->atomic_async_update)
16211612
return -EINVAL;
@@ -1646,6 +1637,8 @@ EXPORT_SYMBOL(drm_atomic_helper_async_check);
16461637
* drm_atomic_async_check() succeeds. Async commits are not supposed to swap
16471638
* the states like normal sync commits, but just do in-place changes on the
16481639
* current state.
1640+
*
1641+
* TODO: Implement full swap instead of doing in-place changes.
16491642
*/
16501643
void drm_atomic_helper_async_commit(struct drm_device *dev,
16511644
struct drm_atomic_state *state)
@@ -1656,6 +1649,9 @@ void drm_atomic_helper_async_commit(struct drm_device *dev,
16561649
int i;
16571650

16581651
for_each_new_plane_in_state(state, plane, plane_state, i) {
1652+
struct drm_framebuffer *new_fb = plane_state->fb;
1653+
struct drm_framebuffer *old_fb = plane->state->fb;
1654+
16591655
funcs = plane->helper_private;
16601656
funcs->atomic_async_update(plane, plane_state);
16611657

@@ -1664,11 +1660,17 @@ void drm_atomic_helper_async_commit(struct drm_device *dev,
16641660
* plane->state in-place, make sure at least common
16651661
* properties have been properly updated.
16661662
*/
1667-
WARN_ON_ONCE(plane->state->fb != plane_state->fb);
1663+
WARN_ON_ONCE(plane->state->fb != new_fb);
16681664
WARN_ON_ONCE(plane->state->crtc_x != plane_state->crtc_x);
16691665
WARN_ON_ONCE(plane->state->crtc_y != plane_state->crtc_y);
16701666
WARN_ON_ONCE(plane->state->src_x != plane_state->src_x);
16711667
WARN_ON_ONCE(plane->state->src_y != plane_state->src_y);
1668+
1669+
/*
1670+
* Make sure the FBs have been swapped so that cleanups in the
1671+
* new_state performs a cleanup in the old FB.
1672+
*/
1673+
WARN_ON_ONCE(plane_state->fb != old_fb);
16721674
}
16731675
}
16741676
EXPORT_SYMBOL(drm_atomic_helper_async_commit);

‎drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,8 @@ static int mdp5_plane_atomic_async_check(struct drm_plane *plane,
502502
static void mdp5_plane_atomic_async_update(struct drm_plane *plane,
503503
struct drm_plane_state *new_state)
504504
{
505+
struct drm_framebuffer *old_fb = plane->state->fb;
506+
505507
plane->state->src_x = new_state->src_x;
506508
plane->state->src_y = new_state->src_y;
507509
plane->state->crtc_x = new_state->crtc_x;
@@ -524,6 +526,8 @@ static void mdp5_plane_atomic_async_update(struct drm_plane *plane,
524526

525527
*to_mdp5_plane_state(plane->state) =
526528
*to_mdp5_plane_state(new_state);
529+
530+
new_state->fb = old_fb;
527531
}
528532

529533
static const struct drm_plane_helper_funcs mdp5_plane_helper_funcs = {

‎drivers/gpu/drm/rockchip/rockchip_drm_vop.c‎

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -924,29 +924,17 @@ static void vop_plane_atomic_async_update(struct drm_plane *plane,
924924
struct drm_plane_state *new_state)
925925
{
926926
struct vop *vop = to_vop(plane->state->crtc);
927-
struct drm_plane_state *plane_state;
928-
929-
plane_state = plane->funcs->atomic_duplicate_state(plane);
930-
plane_state->crtc_x = new_state->crtc_x;
931-
plane_state->crtc_y = new_state->crtc_y;
932-
plane_state->crtc_h = new_state->crtc_h;
933-
plane_state->crtc_w = new_state->crtc_w;
934-
plane_state->src_x = new_state->src_x;
935-
plane_state->src_y = new_state->src_y;
936-
plane_state->src_h = new_state->src_h;
937-
plane_state->src_w = new_state->src_w;
938-
939-
if (plane_state->fb != new_state->fb)
940-
drm_atomic_set_fb_for_plane(plane_state, new_state->fb);
941-
942-
swap(plane_state, plane->state);
943-
944-
if (plane->state->fb && plane->state->fb != new_state->fb) {
945-
drm_framebuffer_get(plane->state->fb);
946-
WARN_ON(drm_crtc_vblank_get(plane->state->crtc) != 0);
947-
drm_flip_work_queue(&vop->fb_unref_work, plane->state->fb);
948-
set_bit(VOP_PENDING_FB_UNREF, &vop->pending);
949-
}
927+
struct drm_framebuffer *old_fb = plane->state->fb;
928+
929+
plane->state->crtc_x = new_state->crtc_x;
930+
plane->state->crtc_y = new_state->crtc_y;
931+
plane->state->crtc_h = new_state->crtc_h;
932+
plane->state->crtc_w = new_state->crtc_w;
933+
plane->state->src_x = new_state->src_x;
934+
plane->state->src_y = new_state->src_y;
935+
plane->state->src_h = new_state->src_h;
936+
plane->state->src_w = new_state->src_w;
937+
swap(plane->state->fb, new_state->fb);
950938

951939
if (vop->is_enabled) {
952940
rockchip_drm_psr_inhibit_get_state(new_state->state);
@@ -955,9 +943,22 @@ static void vop_plane_atomic_async_update(struct drm_plane *plane,
955943
vop_cfg_done(vop);
956944
spin_unlock(&vop->reg_lock);
957945
rockchip_drm_psr_inhibit_put_state(new_state->state);
958-
}
959946

960-
plane->funcs->atomic_destroy_state(plane, plane_state);
947+
/*
948+
* A scanout can still be occurring, so we can't drop the
949+
* reference to the old framebuffer. To solve this we get a
950+
* reference to old_fb and set a worker to release it later.
951+
* FIXME: if we perform 500 async_update calls before the
952+
* vblank, then we can have 500 different framebuffers waiting
953+
* to be released.
954+
*/
955+
if (old_fb && plane->state->fb != old_fb) {
956+
drm_framebuffer_get(old_fb);
957+
WARN_ON(drm_crtc_vblank_get(plane->state->crtc) != 0);
958+
drm_flip_work_queue(&vop->fb_unref_work, old_fb);
959+
set_bit(VOP_PENDING_FB_UNREF, &vop->pending);
960+
}
961+
}
961962
}
962963

963964
static const struct drm_plane_helper_funcs plane_helper_funcs = {

‎drivers/gpu/drm/vc4/vc4_plane.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ static void vc4_plane_atomic_async_update(struct drm_plane *plane,
10251025
{
10261026
struct vc4_plane_state *vc4_state, *new_vc4_state;
10271027

1028-
drm_atomic_set_fb_for_plane(plane->state, state->fb);
1028+
swap(plane->state->fb, state->fb);
10291029
plane->state->crtc_x = state->crtc_x;
10301030
plane->state->crtc_y = state->crtc_y;
10311031
plane->state->crtc_w = state->crtc_w;

‎include/drm/drm_modeset_helper_vtables.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,14 @@ struct drm_plane_helper_funcs {
11851185
* current one with the new plane configurations in the new
11861186
* plane_state.
11871187
*
1188+
* Drivers should also swap the framebuffers between current plane
1189+
* state (&drm_plane.state) and new_state.
1190+
* This is required since cleanup for async commits is performed on
1191+
* the new state, rather than old state like for traditional commits.
1192+
* Since we want to give up the reference on the current (old) fb
1193+
* instead of our brand new one, swap them in the driver during the
1194+
* async commit.
1195+
*
11881196
* FIXME:
11891197
* - It only works for single plane updates
11901198
* - Async Pageflips are not supported yet

0 commit comments

Comments
 (0)