From patchwork Thu Feb 23 00:56:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 94364 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp472qgi; Wed, 22 Feb 2017 16:56:34 -0800 (PST) X-Received: by 10.99.56.21 with SMTP id f21mr6844355pga.105.1487811394258; Wed, 22 Feb 2017 16:56:34 -0800 (PST) Return-Path: Received: from mail-pg0-x22f.google.com (mail-pg0-x22f.google.com. [2607:f8b0:400e:c05::22f]) by mx.google.com with ESMTPS id f12si2679264pgn.102.2017.02.22.16.56.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Feb 2017 16:56:34 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22f as permitted sender) client-ip=2607:f8b0:400e:c05::22f; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22f as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22f.google.com with SMTP id 1so7636962pgi.1 for ; Wed, 22 Feb 2017 16:56:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=boyNpz2lHaNtM4NiLZgyAsJk6cV685xwOm7FLbWeumg=; b=hZxu+DAQz1fwERFTkaIb/WBDxclExGsPkrTqX6ddb2PGhPHIXyUGf+4GVLH0ebjfcu wURFtBk7PQZ3BsNfm8vJGNYR1OLObag+oWIvoise8SwxE+mSnXUDG6v9i2wtOIeV4JPS PS3BzfzPMCwb2G86STuvEc4D/AKpZ1RSPbbeI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=boyNpz2lHaNtM4NiLZgyAsJk6cV685xwOm7FLbWeumg=; b=PoI0QLaUBJNYhKYM65EININOzaQiACWnBBvoNvjDsDKOsXvy3B0k2ygRwbUkqpFnYQ WWlgYAnbcfPT+WnpgujBvYKsAGeGY4oWjFh5uPnK8WCR7MzOyM6XUTnsNfkbGuiETXGz O2TjlNTPMVk5Yvy8bEUp7FQO2sjP6kMWoJPZlwW+Ex7rDYxn3yQbdge8ETh0Jzph3hkV bx8dgveNvOhnfQuOJHYrP/TN/gJZfX7rtQ8K46R27dm6Y5khcmAgmmOMHMW2eeG4e3pQ yaBc6PaYKcjK+Z1KxcjXsuoIGXuR+KKnO1chCavg/Eclza6FpxHndsK/cfVX3OJ/Ksl4 z4Vw== X-Gm-Message-State: AMke39ku6hHHdlG9fhI7zHXBl0urxNqJt8CLansDmoW55hoS4kPIs15ksLuEXkeEj0egxTK1QdI= X-Received: by 10.98.10.216 with SMTP id 85mr28267375pfk.3.1487811393715; Wed, 22 Feb 2017 16:56:33 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id n73sm5755829pfa.9.2017.02.22.16.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Feb 2017 16:56:32 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Xinliang Liu , Rongrong Zou , Xinwei Kong , Chen Feng , David Airlie , Daniel Vetter , Sean Paul , dri-devel@lists.freedesktop.org Subject: [RFC][PATCH] drm: kirin: Add a mutex to avoid fb initialization race Date: Wed, 22 Feb 2017 16:56:23 -0800 Message-Id: <1487811383-6915-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 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 Cc: Rongrong Zou Cc: Xinwei Kong Cc: Chen Feng Cc: David Airlie Cc: Daniel Vetter Cc: Sean Paul Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 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