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: 94509 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp44516qgi; Fri, 24 Feb 2017 17:25:24 -0800 (PST) X-Received: by 10.84.133.36 with SMTP id 33mr6124035plf.87.1487985924528; Fri, 24 Feb 2017 17:25:24 -0800 (PST) Return-Path: Received: from mail-pg0-x22c.google.com (mail-pg0-x22c.google.com. [2607:f8b0:400e:c05::22c]) by mx.google.com with ESMTPS id d20si8795805pfj.250.2017.02.24.17.25.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 17:25:24 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22c as permitted sender) client-ip=2607:f8b0:400e:c05::22c; 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::22c 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-x22c.google.com with SMTP id z128so18086413pgb.0 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=pSV5aqS6slusiFdbLSDB+eKYXyVXpSIHzv6dbzb2zuG+GD/oGX3Ra3BAmvI2NvSwrU 0Ii7yIbHn1RpCCXtNXQuc2sm/hzDAZ7rj6bpK+IdBwG4KQL5GAim3ipDSFDMaYBK+HPs Fpbh64kzl131PNzydUMBdopqABUuSujLUa+kpFThAwvkNkg3EhfxxJgEyUslBH5Zu3M9 mMbcHzQcTUXjkbHhsfD7rejZ2gXiYrVIjAXPVR3Cbo/9eUMm8iJRbuDymN3sWc3hQNuZ NNCC+iEaF/2RGF0B4d8A/Vw+N83FZ/Gu5i5SaLV41Y11DAiz0jEaEdgmMa8dMouUUwIJ BpGA== X-Gm-Message-State: AMke39nR1VwuIwftj3KFvoDzhCKszzWlaKpp3kH77NV6y6iTvJWHe68zxtqMmNLN2uzYs0g041E= X-Received: by 10.99.124.10 with SMTP id x10mr7094573pgc.25.1487985924215; Fri, 24 Feb 2017 17:25:24 -0800 (PST) Return-Path: 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 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 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 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(+) -- 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 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;