UPSTREAM: drm/rockchip: Avoid race with vblank count increment
authorTomasz Figa <tfiga@chromium.org>
Wed, 14 Sep 2016 12:54:56 +0000 (21:54 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 19 Jul 2017 06:33:52 +0000 (14:33 +0800)
commitffa4516b09713bb5037800e1b56316f3f057136e
tree05815e95b648d6ca29960c104fe3ce22d912ee1f
parent773d46618b77d211e8e171f89c34f2cfa3638ae9
UPSTREAM: drm/rockchip: Avoid race with vblank count increment

Since VOP does not have a hardware vblank count register, the ongoing
commit might be racing with a requested vblank interrupt, which would
increment the software vblank counter before the changes being committed
actually happen.

To avoid this, we can extend .atomic_flush(), so after it sets cfg_done
bit, it polls the vblank interrupt bit until it's inactive to make sure
that any old vblank interrupt gets to the handler and then uses
synchronize_irq(vop->irq) to make sure the handler finishes running.

The polling case should happen very rarely, but even if, the total wait
time should be relatively low and in practice almost equal to the vop
hardirq handler running time.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
(cherry picked from commit 7caecdbec1128a934ee628f399110dff8a50c9a1)

Change-Id: Ic5f6231300214485ea569a2296c990aa123f6ff7
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/gpu/drm/rockchip/rockchip_drm_vop.c