From patchwork Wed Oct 2 19:37:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 2978701 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 1B546BFF0B for ; Wed, 2 Oct 2013 19:41:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0CD4B20257 for ; Wed, 2 Oct 2013 19:41:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C4F74201BA for ; Wed, 2 Oct 2013 19:41:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D0344E6E46 for ; Wed, 2 Oct 2013 12:41:33 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f51.google.com (mail-bk0-f51.google.com [209.85.214.51]) by gabe.freedesktop.org (Postfix) with ESMTP id 11178E6090 for ; Wed, 2 Oct 2013 12:39:36 -0700 (PDT) Received: by mail-bk0-f51.google.com with SMTP id mx10so562769bkb.10 for ; Wed, 02 Oct 2013 12:39:33 -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; bh=ctwBos4q/QJGR5ttajY2omagw8YKE1cANlsQtke7J+Q=; b=MGnrg6QJfp6jCEZza43Hi78xEotU5xtXA97EvxxVR4nCypQbSrj6xqjlXmi5Duaj25 26c2lug0yC5w0Wj3eh9rCgdn546RRAmh2aQRyR4fwutQjqLUttW60teEFaNSnAJICczN zmNTw6WE/jzcG1w8iUdHSVhlamMh6SwwMEALyjA84IX47vhaAijbjopufjMQn+Q4imRK tJdY5XF3WGey4I943LBpG1Fd3dNfhjOpRKM9wXnisDRVtDwco3f3ud7dtwjibNcwVejA /EvU2T7Q2dWPzu/MB+er5F13qqZOg0H+EtqH671fVOw9ali+cdL4fr4/8hxIH6IJAdHD dHfg== X-Received: by 10.205.35.15 with SMTP id su15mr3880191bkb.21.1380742773039; Wed, 02 Oct 2013 12:39:33 -0700 (PDT) Received: from localhost (port-9699.pppoe.wtnet.de. [84.46.38.9]) by mx.google.com with ESMTPSA id kk2sm2405907bkb.10.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 12:39:32 -0700 (PDT) From: Thierry Reding To: David Airlie Subject: [PATCH] drm: Track the proper DPMS mode of connectors Date: Wed, 2 Oct 2013 21:37:46 +0200 Message-Id: <1380742666-2438-1-git-send-email-treding@nvidia.com> X-Mailer: git-send-email 1.8.4 Cc: linux-kernel@vger.kernel.org, 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+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.7 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 When userspace removes the active framebuffer using DRM_IOCTL_MODE_RMFB, or explicitly disables the CRTC (by calling drmModeSetCrtc(..., NULL) for example), a NULL framebuffer will be passed to the .set_config() implementation of a CRTC. The drm_crtc_helper_set_config() helper will decide to disable a CRTC when that happens. To do so, it calls drm_crtc_helper_disable(), which in turn will iterate over all encoders and decouple them from their connectors and finally call drm_helper_disable_unused_functions() to clean up and call the .disable() or .dpms() implementation for each encoder. However, at no point during this sequence does it track the DPMS mode of a connector, so it will usually remain on after this. When a connector is enabled again, drm_helper_connector_dpms() will not notice that the DPMS mode actually changed and won't do anything, which causes the connector to stay disabled indefinitely. To prevent this from happening, explicitly set the connector's DPMS mode to off when the CRTC is disabled. That way it reflects the correct state and can be enabled again. This solves an issue observed when terminating an X server running on the xf86-video-modesetting driver. Without this patch, the connector would not be enabled properly and the screen would stay dark. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_crtc_helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 4280e37..7964948 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -563,6 +563,14 @@ drm_crtc_helper_disable(struct drm_crtc *crtc) continue; connector->encoder = NULL; + + /* + * drm_helper_disable_unused_functions() ought to be + * doing this, but since we've decoupled the encoder + * from the connector above, the required connection + * between them is henceforth no longer available. + */ + connector->dpms = DRM_MODE_DPMS_OFF; } }