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: 9587581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D1511601AE for ; Thu, 23 Feb 2017 00:56:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0AE528722 for ; Thu, 23 Feb 2017 00:56:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A42E928724; Thu, 23 Feb 2017 00:56:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DAC7528722 for ; Thu, 23 Feb 2017 00:56:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDA456E909; Thu, 23 Feb 2017 00:56:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x236.google.com (mail-pg0-x236.google.com [IPv6:2607:f8b0:400e:c05::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B9EE6E909 for ; Thu, 23 Feb 2017 00:56:34 +0000 (UTC) Received: by mail-pg0-x236.google.com with SMTP id 1so7636963pgi.1 for ; Wed, 22 Feb 2017 16:56:34 -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=ETJDvJHPgRMzW7+O5UeD3/jmNtmOHGiBQXxFwo/F31u1QnPpdFRFF/LHKMhCn/tgs1 wwCzbSYD2EL4c7hn4ZB6YLKj96DGv63Yh7urBSvrNfnG+GM85lvBM1+SMpeisd7GQxQy dFJmSWxB2+UP96bBj+eh+WQbVYUrRR/6u0kbUWETUY4ihRggG4qNEa7T+b3QdR66lXWB dvW+eaoJuDM71iI6kIhQ4XzBT6jjTstbF7/7tqA1fqp5hKQNgdIEDMOP/vb9EiHg91Ga Dzi46gSX/J9DactOPv2jNEDGLUcImb2uXk15dcEtBQm0/6aD2oJNQCDrfqfnCHkakWS7 c1Mg== X-Gm-Message-State: AMke39lFq2bRMpYL0xu9OsasHQLSkKlXoR4l9l6cOmmF4pFMY3M5OK9l0cG7hmDAyLL0gjO/ X-Received: by 10.98.10.216 with SMTP id 85mr28267375pfk.3.1487811393715; Wed, 22 Feb 2017 16:56:33 -0800 (PST) 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 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 Cc: Chen Feng , dri-devel@lists.freedesktop.org, Xinliang Liu , Xinwei Kong , Daniel Vetter , Rongrong Zou X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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