All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm: Fix vblank refcount during modeset
@ 2022-07-22 21:52 Yunxiang Li
  2022-07-22 21:52 ` [PATCH 2/2] drm: get lock before accessing vblank refcount Yunxiang Li
  2022-08-02 14:51 ` [PATCH 1/2] drm: Fix vblank refcount during modeset Li, Yunxiang (Teddy)
  0 siblings, 2 replies; 6+ messages in thread
From: Yunxiang Li @ 2022-07-22 21:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Yunxiang Li

drm_crtc_vblank_off increments the refcount to prevent vblank from
getting enabled during modeset, but this causes the refcount elsewhere
to be off if they call drm_vblank_get without checking the return and
do a drm_vblank_put later. This can be reproduced by toggling vrr mode
on amdgpu.

Since drm_crtc_vblank_on later re-enables vblank if the refcount is not
zero, letting drm_vblank_get succeed during modeset should fix the behavior.

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/1380
Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com>
---
 drivers/gpu/drm/drm_vblank.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 2ff31717a3de..159d13b5d97b 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -1174,7 +1174,7 @@ int drm_vblank_get(struct drm_device *dev, unsigned int pipe)
 	if (atomic_add_return(1, &vblank->refcount) == 1) {
 		ret = drm_vblank_enable(dev, pipe);
 	} else {
-		if (!vblank->enabled) {
+		if (!vblank->enabled && !vblank->inmodeset) {
 			atomic_dec(&vblank->refcount);
 			ret = -EINVAL;
 		}
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-06 21:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 21:52 [PATCH 1/2] drm: Fix vblank refcount during modeset Yunxiang Li
2022-07-22 21:52 ` [PATCH 2/2] drm: get lock before accessing vblank refcount Yunxiang Li
2022-09-06 19:20   ` Daniel Vetter
2022-09-06 20:18     ` Li, Yunxiang (Teddy)
2022-09-06 21:58       ` Daniel Vetter
2022-08-02 14:51 ` [PATCH 1/2] drm: Fix vblank refcount during modeset Li, Yunxiang (Teddy)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.