From patchwork Tue Jan 7 16:55:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 3449251 Return-Path: X-Original-To: patchwork-intel-gfx@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 C47D6C02DC for ; Tue, 7 Jan 2014 16:56:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA02C2010E for ; Tue, 7 Jan 2014 16:56:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8976E2010C for ; Tue, 7 Jan 2014 16:56:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74DA2FAD9D; Tue, 7 Jan 2014 08:56:16 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qa0-f44.google.com (mail-qa0-f44.google.com [209.85.216.44]) by gabe.freedesktop.org (Postfix) with ESMTP id 8229CFAD9D for ; Tue, 7 Jan 2014 08:56:15 -0800 (PST) Received: by mail-qa0-f44.google.com with SMTP id o15so783530qap.31 for ; Tue, 07 Jan 2014 08:56:15 -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; bh=OTVr+1vwXnBT444NJpx1qztudccV8lbwmtxugF4Uzww=; b=mzALNy4X9UJgoLxDvpYZreBaj7NCGsZ56HgGVlBk5l1YJjTrTMuOuHDdp/JkKmisyB Mf8/iDjy0DcHh7+lQJjBBdV/AtinWnGpTrfgHxkXAjEZSLB07/NSRYOzNvTR83ipKmfk q+jh2fupdnT4mGACOk5gSJdccWcckgIUa3nivvkfWf6mOG2KUnB3Z9eeMHEkicjVOqmQ Q+uVSHyPPUfKQ4ZWyg/7JD6zkpWpZGPvHSkhlBoIMXK4afvLd3p/AvTgYSwQYlKkW2Tx tSRGJ9ao3p0//nX3SejaHyPCbtqgEjymqya807Awyx3I0Eqw9V9yBcEFOZNaR3JXXgZy /c9A== X-Received: by 10.224.128.134 with SMTP id k6mr192443798qas.68.1389113774976; Tue, 07 Jan 2014 08:56:14 -0800 (PST) Received: from localhost.localdomain ([177.42.20.97]) by mx.google.com with ESMTPSA id f5sm41755949qas.11.2014.01.07.08.56.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jan 2014 08:56:14 -0800 (PST) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 7 Jan 2014 14:55:53 -0200 Message-Id: <1389113755-2021-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.8.4.2 Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 1/3] drm/i915: don't set modes for 2 connectors on the same encoder X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-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 In some cases we have more than 1 connector associated to an encoder (e.g., SDVO, Haswell DP/HDMI) and we can only set a mode for one of these connectors. If we only allowed modesets for connected connectors we would never need this patch, but since we do allow modeset for disconnected connectors we may see user space trying to set modes on the two connectors attached to the same encoder, so we need to forbid that. This problem can be reproduced by running the following intel-gpu-tools test case: ./kms_setmode --run-subtest clone-exclusive-crtc Thanks to Daniel Vetter for providing a version of this patch on pastebin. Credits-to: Daniel Vetter Signed-off-by: Paulo Zanoni Reviewed-by: Damien Lespiau --- drivers/gpu/drm/i915/intel_display.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index a562eef..7cc67b3 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -9922,17 +9922,21 @@ intel_modeset_stage_output_state(struct drm_device *dev, /* Check for any encoders that needs to be disabled. */ list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) { + int num_connectors = 0; list_for_each_entry(connector, &dev->mode_config.connector_list, base.head) { if (connector->new_encoder == encoder) { WARN_ON(!connector->new_encoder->new_crtc); - - goto next_encoder; + num_connectors++; } } - encoder->new_crtc = NULL; -next_encoder: + + if (num_connectors == 0) + encoder->new_crtc = NULL; + else if (num_connectors > 1) + return -EINVAL; + /* Only now check for crtc changes so we don't miss encoders * that will be disabled. */ if (&encoder->new_crtc->base != encoder->base.crtc) {