From patchwork Tue Aug 7 19:39:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10559117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD7F415A6 for ; Tue, 7 Aug 2018 19:49:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C97902A392 for ; Tue, 7 Aug 2018 19:49:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB7B62A3B7; Tue, 7 Aug 2018 19:49:54 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 C32E52A392 for ; Tue, 7 Aug 2018 19:49:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 064A86E033; Tue, 7 Aug 2018 19:49:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 578 seconds by postgrey-1.36 at gabe; Tue, 07 Aug 2018 19:49:50 UTC Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B4A36E033 for ; Tue, 7 Aug 2018 19:49:50 +0000 (UTC) Received: from gagarine.paulk.fr (gagarine [192.168.1.127]) by leonov.paulk.fr (Postfix) with ESMTPS id C3ED9BFD5B for ; Tue, 7 Aug 2018 21:40:07 +0200 (CEST) Received: by gagarine.paulk.fr (Postfix, from userid 114) id 94931C0F1D; Tue, 7 Aug 2018 21:40:06 +0200 (CEST) Received: from localhost.localdomain (collins [192.168.1.129]) by gagarine.paulk.fr (Postfix) with ESMTP id 72150BFB30; Tue, 7 Aug 2018 21:39:40 +0200 (CEST) From: Paul Kocialkowski To: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/sun4i: Avoid failing to init fbdev without any connector Date: Tue, 7 Aug 2018 21:39:19 +0200 Message-Id: <20180807193919.4800-1-contact@paulk.fr> X-Mailer: git-send-email 2.18.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , David Airlie , Chen-Yu Tsai , linux-sunxi@googlegroups.com, Paul Kocialkowski MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Initializing and registering fbdev requires at least one DRM connector and will fail otherwise. In order to support headless setups (for instance for GPU rendering with the GBM backend, where a DRI card node is required to provide GEM memory reservation), add a check on the number of registered connectors before initializing fbdev. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c index 5f29850ef8ac..19a265e4a93a 100644 --- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c +++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c @@ -49,6 +49,8 @@ static struct drm_mode_config_helper_funcs sun4i_de_mode_config_helpers = { int sun4i_framebuffer_init(struct drm_device *drm) { + int ret; + drm_mode_config_reset(drm); drm->mode_config.max_width = 8192; @@ -57,7 +59,13 @@ int sun4i_framebuffer_init(struct drm_device *drm) drm->mode_config.funcs = &sun4i_de_mode_config_funcs; drm->mode_config.helper_private = &sun4i_de_mode_config_helpers; - return drm_fb_cma_fbdev_init(drm, 32, 0); + if (drm->mode_config.num_connector > 0) { + ret = drm_fb_cma_fbdev_init(drm, 32, 0); + if (ret) + return ret; + } + + return 0; } void sun4i_framebuffer_free(struct drm_device *drm)