[RFC][PATCH] drm: kirin: Add a mutex to avoid fb initialization race
John Stultz
john.stultz at linaro.org
Thu Feb 23 00:56:23 UTC 2017
In some cases I've been seeing a race where two framebuffers
would be initialized, as kirin_fbdev_output_poll_changed()
might get called quickly in succession, resulting in the fb
initialization happening twice. This could cause the system
to boot up with a blank screen.
This patch adds a simple mutex to serialize it and seems to
avoid the race.
Obviously I suspect this patch isn't the best solution, but
I wanted to send it out as something concrete to discuss the
bug.
Suggestions or feedback for a better solution would be greatly
appreciated.
Cc: Xinliang Liu <z.liuxinliang at hisilicon.com>
Cc: Rongrong Zou <zourongrong at gmail.com>
Cc: Xinwei Kong <kong.kongxinwei at hisilicon.com>
Cc: Chen Feng <puck.chen at hisilicon.com>
Cc: David Airlie <airlied at linux.ie>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Sean Paul <seanpaul at chromium.org>
Cc: dri-devel at lists.freedesktop.org
Signed-off-by: John Stultz <john.stultz at linaro.org>
---
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index ebd5f4f..80c607f 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -50,11 +50,13 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev)
return 0;
}
+static DEFINE_MUTEX(fb_lock);
#ifdef CONFIG_DRM_FBDEV_EMULATION
static void kirin_fbdev_output_poll_changed(struct drm_device *dev)
{
struct kirin_drm_private *priv = dev->dev_private;
+ mutex_lock(&fb_lock);
if (priv->fbdev) {
drm_fbdev_cma_hotplug_event(priv->fbdev);
} else {
@@ -64,6 +66,7 @@ static void kirin_fbdev_output_poll_changed(struct drm_device *dev)
if (IS_ERR(priv->fbdev))
priv->fbdev = NULL;
}
+ mutex_unlock(&fb_lock);
}
#endif
--
2.7.4
More information about the dri-devel
mailing list