From patchwork Tue Jun 7 15:26:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 9161655 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 6592560571 for ; Tue, 7 Jun 2016 15:26:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5757B264F4 for ; Tue, 7 Jun 2016 15:26:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C0862723E; Tue, 7 Jun 2016 15:26:52 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4BB5264F4 for ; Tue, 7 Jun 2016 15:26:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80CC46E7E1; Tue, 7 Jun 2016 15:26:43 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB0086E7E1; Tue, 7 Jun 2016 15:26:40 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id m124so23993459wme.3; Tue, 07 Jun 2016 08:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p2bdscdYFZxZH79kBaoSkOXCfMWheNDmKqcVHsWOvvo=; b=qN12GexWl4FeqfDe20xcDvZYcbMhUSRVH1OjwT1UlBVZ56564pBBBpr2bfjAW/2tOJ xYJmOzDi3alMPjhDl29MAo6ASlK3kywPeE+DJY/NhGEdLg88qWT8zywPncouA9pjv+V1 V/MI/UsSVCQjodeJQNQyauqewU7D8BuyhKFQL6ZhkB0kIZjIy6gp/Y1gk9YKe6KdmIF8 ZJpS0A9f5nPOd5koMq80tYcoVPqezM73ZQEjR/+fldjR1J8UxMOOw7/WWq/HTj3aTxkb AgqhcdXQL45ZBmHJzZm0xwO8155pAtrunssSIE9HTujuckaIBhTxx/899eOkaXliZThZ +V2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p2bdscdYFZxZH79kBaoSkOXCfMWheNDmKqcVHsWOvvo=; b=SSeeAFGM/TNP4H5H6NWcZpdhUXit2w8ntd2kyhM3CvA5glUZw55mXo/68OujrCB+Al Tu+GjObv9M/dc4FEVlsVMi2+zvgca/tk6x3qEMbuKdsulL14zxRgFGuJLW0eXS+CE8T1 e2tcSQPa9RWQbrxuCC+eY8uTDCUCJrTeW7OkC1MLXrZuq5/TmWIBV4kVDTc4uWqZH2Ga 87vbljZbddYaqQqp0t/ZUZuc+rUIaczGExzxPux6vuJi1k308Ebmx9s0NgUuSvdRrebt 7yEgc3SewReL2RfxmTzDvzL9q1kd5p2rA6oHzkvzGJvDwc6BzKGmZDzcMOdFm+TQ6Ppc Ub9Q== X-Gm-Message-State: ALyK8tJFCBcmFCtq7h4SAZZsnEbZkoqvkJhfib2HatVb1MPwqunWq4ZH2C1Tdic9ApHkhQ== X-Received: by 10.28.3.70 with SMTP id 67mr3492815wmd.32.1465313198701; Tue, 07 Jun 2016 08:26:38 -0700 (PDT) Received: from localhost (port-9435.pppoe.wtnet.de. [84.46.36.255]) by smtp.gmail.com with ESMTPSA id b1sm26001548wjq.25.2016.06.07.08.26.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2016 08:26:37 -0700 (PDT) From: Thierry Reding To: Daniel Vetter Date: Tue, 7 Jun 2016 17:26:22 +0200 Message-Id: <20160607152625.9511-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160607152625.9511-1-thierry.reding@gmail.com> References: <20160607152625.9511-1-thierry.reding@gmail.com> Cc: Boris Brezillon , Joonyoung Shim , Xinliang Liu , Chen Feng , intel-gfx@lists.freedesktop.org, Seung-Woo Kim , Xinwei Kong , dri-devel@lists.freedesktop.org, Inki Dae , Kyungmin Park , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [Intel-gfx] [PATCH v2 6/9] drm/fb-helper: Support deferred setup X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding FB helper code falls back to a 1024x768 mode if no outputs are connected or don't report back any modes upon initialization. This can be annoying because outputs that are added to FB helper later on can't be used with FB helper if they don't support a matching mode. The fallback is in place because VGA connectors can happen to report an unknown connection status even when they are in fact connected. Some drivers have custom solutions in place to defer FB helper setup until at least one output is connected. But the logic behind these solutions is always the same and there is nothing driver-specific about it, so a better alterative is to fix the FB helper core and add support for all drivers automatically. This patch adds support for deferred FB helper setup. It checks all the connectors for their connection status, and if all of them report to be disconnected marks the FB helper as needing deferred setup. Whet setup is deferred, the FB helper core will automatically retry setup after a hotplug event, and it will keep trying until it succeeds. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_fb_helper.c | 36 ++++++++++++++++++++++++++++++++++++ include/drm/drm_fb_helper.h | 21 +++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index f7722bcb0064..0911b10c711c 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -487,6 +487,9 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper) if (!drm_fbdev_emulation) return -ENODEV; + if (fb_helper->deferred_setup) + return 0; + mutex_lock(&fb_helper->lock); drm_modeset_lock_all(dev); @@ -1452,6 +1455,23 @@ unlock: } EXPORT_SYMBOL(drm_fb_helper_pan_display); +static bool drm_fb_helper_maybe_connected(struct drm_fb_helper *helper) +{ + bool connected = false; + unsigned int i; + + for (i = 0; i < helper->connector_count; i++) { + struct drm_fb_helper_connector *fb = helper->connector_info[i]; + + if (fb->connector->status != connector_status_disconnected) { + connected = true; + break; + } + } + + return connected; +} + /* * Allocates the backing storage and sets up the fbdev info structure through * the ->fb_probe callback and then registers the fbdev and sets up the panic @@ -1554,6 +1574,17 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, sizes.fb_height = min_t(u32, desired_mode->vdisplay + y, sizes.fb_height); } + /* + * If everything's disconnected, there's no use in attempting to set + * up fbdev. + */ + if (!drm_fb_helper_maybe_connected(fb_helper)) { + DRM_INFO("No outputs connected, deferring setup\n"); + fb_helper->preferred_bpp = preferred_bpp; + fb_helper->deferred_setup = true; + return 0; + } + if (crtc_count == 0 || sizes.fb_width == -1 || sizes.fb_height == -1) { /* hmm everyone went away - assume VGA cable just fell out and will come back later. */ @@ -1593,6 +1624,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, list_add(&fb_helper->kernel_fb_list, &kernel_fb_helper_list); + fb_helper->deferred_setup = false; return 0; } @@ -2294,6 +2326,10 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) if (!drm_fbdev_emulation) return 0; + if (fb_helper->deferred_setup) + return drm_fb_helper_initial_config(fb_helper, + fb_helper->preferred_bpp); + mutex_lock(&fb_helper->lock); mutex_lock(&fb_helper->dev->mode_config.mutex); diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 7739be08ebca..dac155ad33f6 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -219,6 +219,27 @@ struct drm_fb_helper { bool delayed_hotplug; /** + * @deferred_setup: + * + * If no outputs are connected (disconnected or unknown) the FB helper + * code will defer setup until at least one of the outputs shows up. + * This field keeps track of the status so that setup can be retried + * at every hotplug event until it succeeds eventually. + */ + bool deferred_setup; + + /** + * @preferred_bpp: + * + * Temporary storage for the driver's preferred BPP setting passed to + * FB helper initialization. This needs to be tracked so that deferred + * FB helper setup can pass this on. + * + * See also: @deferred_setup + */ + int preferred_bpp; + + /** * @atomic: * * Use atomic updates for restore_fbdev_mode(), etc. This defaults to