From patchwork Wed Mar 1 09:52:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9598003 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 85040604DC for ; Wed, 1 Mar 2017 09:52:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 565C828306 for ; Wed, 1 Mar 2017 09:52:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B36628532; Wed, 1 Mar 2017 09:52:44 +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_SIGNED, 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]) (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 EFD6228306 for ; Wed, 1 Mar 2017 09:52:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 686616E8F0; Wed, 1 Mar 2017 09:52:42 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id D74A56E8EB for ; Wed, 1 Mar 2017 09:52:40 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id g10so4766577wrg.0 for ; Wed, 01 Mar 2017 01:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vzV6Cta3KgFoGFpYozbbp++EuNN8/Roft2mOtTl1aes=; b=Q/fxOr0i16F7bxfmxydNLn02kZw8P+UC2418HCYsuUMw7bR5zV3/yf+lLdqCcdCwYX 5I0rlPzMQfVEP+XR74IB2kkKDsMfbE5M3uNgTtYAN1VO5Rn+SDVbjRddxy5+CVy/61QO A9JsRbF7R9lIVape/vjpYGjXxPoyoY/hy5M6I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vzV6Cta3KgFoGFpYozbbp++EuNN8/Roft2mOtTl1aes=; b=FyufK2cIWGFILV8pArwsmaJSIeTEXf2uOdayU7w1eatW+FdjfwSv3RgHRuW1f3imCs O14P8q9He+ARz8thQf01sGowReS3UbSzhuwY9C5A8B3MEmbFqxzomKLuQdVTnw/JIh8w C/CPy1wXvar/erzn1JdH9osIv1NW/PU0osJSRKHaQGmXG942LDrOTAZ1pnXRdu6xDlrq ian0pS7pU4vYiCUVya7wm0lSHWbnGJqo87ZNa05tFgGwD01jTCglBiW+3KFk1rG5pRFw zWLLQW26cQp8r7MFPEITrvXQCudsVno2NiMqM0mHiGm0tJyVpq1BoG3//rg1jMH4aNul /6cQ== X-Gm-Message-State: AMke39kL6bmis72aG90c3+Y1c+QIYiSr3O33tqux3ctg25me24hHZKO4WmYwYNTsm+tShQ== X-Received: by 10.223.154.225 with SMTP id a88mr6181421wrc.5.1488361959494; Wed, 01 Mar 2017 01:52:39 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:56c9:0:decc:6e78:7e96:b452]) by smtp.gmail.com with ESMTPSA id 63sm6190479wmg.22.2017.03.01.01.52.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 01:52:38 -0800 (PST) From: Daniel Vetter To: Intel Graphics Development Date: Wed, 1 Mar 2017 10:52:26 +0100 Message-Id: <20170301095226.30584-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170301095226.30584-1-daniel.vetter@ffwll.ch> References: <20170301095226.30584-1-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Thierry Reding , Daniel Vetter Subject: [Intel-gfx] [PATCH 6/6] drm/i915: Fix up verify_encoder_state 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 The trouble here is that looking at all connector->state in the verifier isn't good, because that's run from the commit work, which doesn't hold the connection_mutex. Which means we're only allowed to look at states in our atomic update. The simple fix for future proofing would be to switch over to drm_for_each_connector_in_state, but that has the problem that the verification then fails if not all connectors are in the state. And we also need to be careful to check both old and new encoders, and not screw things up when an encoder gets reassigned. Note that this isn't the full fix, since we still look at connector->state. To fix that, we need Maarten's patch series to switch over to state pointers within drm_atomic_state, but that's a different series. v2: Use oldnew iterator (Maarten). v3: Rebase onto the iter_get/put->iter_begin/end rename. Cc: Thierry Reding Cc: Maarten Lankhorst Signed-off-by: Daniel Vetter Reviewed-by: Maarten Lankhorst --- drivers/gpu/drm/i915/intel_display.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index f6560ab3531d..958e68430ca3 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -11898,31 +11898,37 @@ verify_connector_state(struct drm_device *dev, } static void -verify_encoder_state(struct drm_device *dev) +verify_encoder_state(struct drm_device *dev, struct drm_atomic_state *state) { struct intel_encoder *encoder; - struct intel_connector *connector; - struct drm_connector_list_iter conn_iter; + struct drm_connector *connector; + struct drm_connector_state *old_conn_state, *new_conn_state; + int i; for_each_intel_encoder(dev, encoder) { - bool enabled = false; + bool enabled = false, found = false; enum pipe pipe; DRM_DEBUG_KMS("[ENCODER:%d:%s]\n", encoder->base.base.id, encoder->base.name); - drm_connector_list_iter_begin(dev, &conn_iter); - for_each_intel_connector_iter(connector, &conn_iter) { - if (connector->base.state->best_encoder != &encoder->base) + for_each_oldnew_connector_in_state(state, connector, old_conn_state, + new_conn_state, i) { + if (old_conn_state->best_encoder == &encoder->base) + found = true; + + if (new_conn_state->best_encoder != &encoder->base) continue; - enabled = true; + found = enabled = true; - I915_STATE_WARN(connector->base.state->crtc != + I915_STATE_WARN(new_conn_state->crtc != encoder->base.crtc, "connector's crtc doesn't match encoder crtc\n"); } - drm_connector_list_iter_end(&conn_iter); + + if (!found) + continue; I915_STATE_WARN(!!encoder->base.crtc != enabled, "encoder's enabled state mismatch " @@ -12124,7 +12130,7 @@ static void intel_modeset_verify_disabled(struct drm_device *dev, struct drm_atomic_state *state) { - verify_encoder_state(dev); + verify_encoder_state(dev, state); verify_connector_state(dev, state, NULL); verify_disabled_dpll_state(dev); }