From patchwork Sat Feb 25 01:25:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 9591413 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 86DFD60578 for ; Sat, 25 Feb 2017 01:25:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69DC12863D for ; Sat, 25 Feb 2017 01:25:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E528286EF; Sat, 25 Feb 2017 01:25:29 +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 D005A2863D for ; Sat, 25 Feb 2017 01:25:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8316B6E05F; Sat, 25 Feb 2017 01:25:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x229.google.com (mail-pg0-x229.google.com [IPv6:2607:f8b0:400e:c05::229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9BB2B6E05F for ; Sat, 25 Feb 2017 01:25:24 +0000 (UTC) Received: by mail-pg0-x229.google.com with SMTP id 1so18057189pgi.1 for ; Fri, 24 Feb 2017 17:25:24 -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=FbcvVnyXinKrEl6kIBVUN4LIhGersLYHSt1QeWs39Yc=; b=HgO3SFomDaIEqGctNdhcK2PVU3lCUOsz+NlXmRfMxBwUARwsOKU9Rx3wYpTCDZzmNI 8S5Pjg4EJvgAQQtsMcn9WqxjzBabaVGsHcq6RJOiaPV6Dw1sWTEDsAK59TmESTJvym3Y SDD0Y7UMe+v+Kr/F4erp8IIDqBwZn5ToZup5s= 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=FbcvVnyXinKrEl6kIBVUN4LIhGersLYHSt1QeWs39Yc=; b=l3ci9CjBeVC9ERWYQ+oFqG+y3vTI7v0bq8H0+QnrDPCFVg4zVvO+76BfozLuVxLDh1 0E5GWZt2U8xlw/kaukX8g4ZuRw7aSVZ5jwyQp+4LABHug4KNYE/rujaeoetWgsMwa6MB pQwQCYx6YBEi9zkTUU3j5qdlQfc0ZkclmF++HGjglVPbNaLKp/7f8kvnfRV/CoZF1RcZ 7bcXl4SzynJIHrrXAzZbhzXcDtDJ7xxojvUUQncgbr0Tz0I6gR5PLE1zhg8K82YZL273 MBPtku0QIBb5LKS1pcGLRL1UnH82LJqb6WnolZyBLqsfLlceKF2lh8vM3PnxnHq44JSK P6wQ== X-Gm-Message-State: AMke39n2kc0u2osdw7HNwRgNHDouoeLs/M1d1Fpz/D+hHlu28r78hTtfz9anglVIeSZFmNa6 X-Received: by 10.99.124.10 with SMTP id x10mr7094573pgc.25.1487985924215; Fri, 24 Feb 2017 17:25:24 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id j62sm17187786pgc.54.2017.02.24.17.25.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Feb 2017 17:25:23 -0800 (PST) From: John Stultz To: lkml Subject: [RFC][PATCH v2] drm: kirin: Add a mutex to avoid fb initialization race Date: Fri, 24 Feb 2017 17:25:16 -0800 Message-Id: <1487985916-29450-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 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. Suggestions or feedback 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 | 4 ++++ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 7ec93ae..b83556a 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -55,6 +55,7 @@ static void kirin_fbdev_output_poll_changed(struct drm_device *dev) { struct kirin_drm_private *priv = dev->dev_private; + mutex_lock(&priv->fb_lock); if (priv->fbdev) { drm_fbdev_cma_hotplug_event(priv->fbdev); } else { @@ -63,6 +64,7 @@ static void kirin_fbdev_output_poll_changed(struct drm_device *dev) if (IS_ERR(priv->fbdev)) priv->fbdev = NULL; } + mutex_unlock(&priv->fb_lock); } #endif @@ -95,6 +97,8 @@ static int kirin_drm_kms_init(struct drm_device *dev) if (!priv) return -ENOMEM; + mutex_init(&priv->fb_lock); + dev->dev_private = priv; dev_set_drvdata(dev->dev, dev); diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 7f60c649..9b6d2b1 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -23,6 +23,7 @@ struct kirin_drm_private { #ifdef CONFIG_DRM_FBDEV_EMULATION struct drm_fbdev_cma *fbdev; #endif + struct mutex fb_lock; }; extern const struct kirin_dc_ops ade_dc_ops;