From patchwork Wed Nov 27 20:24:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 3250151 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A4ED0C045B for ; Wed, 27 Nov 2013 20:24:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D431720529 for ; Wed, 27 Nov 2013 20:24:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0B6FC20524 for ; Wed, 27 Nov 2013 20:24:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75F88FB6AC; Wed, 27 Nov 2013 12:24:29 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qa0-f41.google.com (mail-qa0-f41.google.com [209.85.216.41]) by gabe.freedesktop.org (Postfix) with ESMTP id C8948FB18A; Wed, 27 Nov 2013 12:24:27 -0800 (PST) Received: by mail-qa0-f41.google.com with SMTP id j5so6255043qaq.0 for ; Wed, 27 Nov 2013 12:24:27 -0800 (PST) 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=xYdzeMOBJiPC3ulqwYvQsrbfrRT/j8IoN+4yBUZkn3A=; b=we9+vA5Iq156di6YpQDtu01yWfNpa94STeWEKHsGARYiax9lbSolyJPnEBTBh2TVyV 5oHc4gyrxLi+ROHD+sCyFeQGI7dBuImZA9ltLkagKasSA9CcYQDqYCCG+fw/tf/NEMZ1 hcMUYxgy3HF1Qc6UmKOvAN43gwUnjLU/3klLmgwMWxcWfYbWraEc6z19UvAKFQM83n2Q l7OZdPE9beTuzFhREcvBzsP5ZvkuKWifUDllFoxfjczrwYwtykgMcO9ZuIolBD3SJOtH 9Gnaq1vRjvtcnlrnVDvrpl+7F4wZQDsAc9OQo6Xvev0L3nfTfWnbaT+zJwYSbRg1Tpdz LBxA== X-Received: by 10.224.66.5 with SMTP id l5mr71025096qai.31.1385583867378; Wed, 27 Nov 2013 12:24:27 -0800 (PST) Received: from localhost.localdomain (189.26.41.84.dynamic.adsl.gvt.net.br. [189.26.41.84]) by mx.google.com with ESMTPSA id p20sm95519870qay.0.2013.11.27.12.24.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Nov 2013 12:24:26 -0800 (PST) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Subject: [PATCH 13/19] drm: do not steal the display if we have a master Date: Wed, 27 Nov 2013 18:24:08 -0200 Message-Id: <1385583848-2805-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20131121160423.GF9515@nuc-i3427.alporthouse.com> References: <20131121160423.GF9515@nuc-i3427.alporthouse.com> Cc: Paulo Zanoni , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paulo Zanoni Sometimes we want to disable all the screens on a system, because that will allow the graphics card to be put into low-power states. The problem is that, for example, while all screens are disabled, if we get a hotplug interrupt, fbcon will decide to set a mode instead of keeping everything disabled, which will remove us from our low power states. Let's assume that if there's a DRM master, it will be able to do whatever is appropriate when we get the hotplug. This problem can be reproduced by the runtime PM test program from intel-gpu-tools: we disable all the screens so the graphics device can be put into D3, then something triggers a hotplug interrupt, fbcon sets a mode and breaks our test suite. The problem can be reproduced more easily by the "i2c" subtest. Other approaches considered for the problem: - Return "false" if "bound == 0" and the caller of drm_fb_helper_is_bound is a hotplug handler. This would break the case where the machine boots with no outputs connected, then the user plugs a monitor. - Add a new IOCTL to force fbcon to not set modes. This would keep all the current applications behaving the same, but adding a new IOCTL is not always the greatest idea. - Return false only if "dev->primary->master && bound == 0". This was my first implementation, but Chris suggested we should do the check irrespective of the "bound" variable. Thanks to Daniel Vetter for the investigation, ideas and the implementation of the hotplug alternative. v2: - Do the check first, irrespective of "bound". - Cc dri-devel Cc: dri-devel@lists.freedesktop.org Credits-to: Daniel Vetter Signed-off-by: Paulo Zanoni Reviewed-by: Daniel Vetter Reviewed-by: David Herrmann --- drivers/gpu/drm/drm_fb_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 0a19401..98a0363 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -359,6 +359,11 @@ static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper) struct drm_crtc *crtc; int bound = 0, crtcs_bound = 0; + /* Sometimes user space wants everything disabled, so don't steal the + * display if there's a master. */ + if (dev->primary->master) + return false; + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { if (crtc->fb) crtcs_bound++; @@ -368,6 +373,7 @@ static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper) if (bound < crtcs_bound) return false; + return true; }