From patchwork Tue Feb 28 13:53:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9595697 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 0131B60453 for ; Tue, 28 Feb 2017 13:54:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E474E27FBC for ; Tue, 28 Feb 2017 13:54:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D960228518; Tue, 28 Feb 2017 13:54:14 +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 8CCC927FBC for ; Tue, 28 Feb 2017 13:54:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DECAB6E70A; Tue, 28 Feb 2017 13:54:13 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 46FB86E700 for ; Tue, 28 Feb 2017 13:54:10 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id u48so1745265wrc.1 for ; Tue, 28 Feb 2017 05:54:10 -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=VsVWadw/tljD8z6e8Ay7U2/r6eOcgjKXXcvQgGPfZiQ=; b=WpGzQYkt34A7JF5GZcYxeC3PLrUSzlSzhYPw6R3v9lXsN0Zelna3gWSnaRmMVwytv7 Ahngpao1rez3CL5SRgk1ekA4Ogd4tEte+5Z8JIDCgms+SNlEo/3YGWn+DYwh/evzi0NB yHWN1RH1U1ugHD98DwMdz7pFlQE9g3g7OiBoI= 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=VsVWadw/tljD8z6e8Ay7U2/r6eOcgjKXXcvQgGPfZiQ=; b=UUtdi1QcAfaYxVvJFz5Y+nfpUXMUNzLfy1/wG0y3/CzrN5iJvnPPIgAdW+tGWlzq4T 9hA3xUx9YIyGU4bYaX5a6uqQmFWQL0QfOPhajurLgJ+tcO7btrFbpXxIQ/QdJO93VAbd +1Mnf/dLuD1gkssQiiiLSxBHU+t7gUkfSjf9bIvFG/cRrW1IJeWA7vXHuRYOVi/Hr6WV SOn7WOoXXvJ3+upHCKtS2l3IU0tZ3FibINE5ymzwsgJtKRHKvBUSAkdIdApOBGn/iNPN UDyZfRkFR1UAXSlushVWowLSLyf76mPYplcAeXmZzloerOR1Mp0l8oIFe9ezBxeMMn1r BtOA== X-Gm-Message-State: AMke39m2rHHeF/ipk2X4Nx+STsp9C6Q4KUgpf2nGNZrlyh2g3WjVSEPFjtIxcWUrMkgWsw== X-Received: by 10.223.170.146 with SMTP id h18mr2311132wrc.113.1488290048915; Tue, 28 Feb 2017 05:54:08 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:56c9:0:decc:6e78:7e96:b452]) by smtp.gmail.com with ESMTPSA id s26sm2432033wra.66.2017.02.28.05.54.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Feb 2017 05:54:08 -0800 (PST) From: Daniel Vetter To: Intel Graphics Development Date: Tue, 28 Feb 2017 14:53:56 +0100 Message-Id: <20170228135356.18757-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170228135356.18757-1-daniel.vetter@ffwll.ch> References: <20170228135356.18757-1-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , 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). Cc: Maarten Lankhorst Signed-off-by: Daniel Vetter --- 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 8dedf82c1c27..62ed706f94fd 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_get(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_put(&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); }