Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4166584imm; Mon, 8 Oct 2018 16:25:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV60OMnnOvDDGhzN/ydbLliLGEPS2rJDgn1M64VtBLr2YuljteQREQza8zEFsucSfI5kS15cG X-Received: by 2002:a62:4586:: with SMTP id n6-v6mr26855963pfi.3.1539041135407; Mon, 08 Oct 2018 16:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539041135; cv=none; d=google.com; s=arc-20160816; b=Fyx1SuJi+p3SMG1eHgwhaznJSIUeulWPwHrgyFfzC9b6J+MZnw1RJP4nKC7j9NCH10 Tpq7G2SkheydpdlMt8U5O3HJxSI2EBiHgHP7KMMqF1g0DAswAYO8savinF8U570Kzy3G 6YSykfgNeSBYHLwLG4B4dwdwg0EBzyv8cV4SYBJqQKVFWU9J4mXpSP4s1yy820RQBJuX PmJbecQ9N7+3aDO6FW6BEwEMaCKlTVgCjFHBl1wlOghCOtOqsaN960cylBAdPwiupSmv SBxYNy8z9266sO5cqVB8uFyCqHpDXuiEw3TMnX7w+IjCkhqZnlHRHIAQ9Qd503oY1n0m tmDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=7FklGq6Xd4YqCfLkX9oy2O+1n4cpVO3qIvRitClfWX8=; b=y2hzv5OsrzJLyvsgmaUlFDLLcdDRBft0JbDQJTcoBfZBEgGHtLfezRDbw+fPera0LE HnVOKTSq5ch5NTT81PHtES6qV/3G5lwnKXhH/hgInL5jmN0Oj+woYh8Er58Wj/HxIdPM QvSLEQVYrGpjke8Xole8qS5UQfgpncqoryrF0zDC+u1VpMshN5SxhutIz1bIxfvbCF2r 9i/f6aXLeCj0c37CZLSgUWX61Z6bE7kMUN5tsU/8xTM5q0cVwItGS4u3dj/sD6P6kkS5 kEXiYPM7MK6zUWG7VDult2yAgAjQmWRX4ibtpdDUnjUx8lM/epXCtAkAQgL6rUHqYy0B gTdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6-v6si16121366pgp.42.2018.10.08.16.25.20; Mon, 08 Oct 2018 16:25:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726671AbeJIGi4 (ORCPT + 99 others); Tue, 9 Oct 2018 02:38:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48654 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725759AbeJIGiz (ORCPT ); Tue, 9 Oct 2018 02:38:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6946C308A94E; Mon, 8 Oct 2018 23:24:49 +0000 (UTC) Received: from malachite.bss.redhat.com (dhcp-10-20-1-11.bss.redhat.com [10.20.1.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D50F6888C; Mon, 8 Oct 2018 23:24:48 +0000 (UTC) From: Lyude Paul To: intel-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: stable@vger.kernel.org, Gustavo Padovan , Maarten Lankhorst , Sean Paul , David Airlie , linux-kernel@vger.kernel.org Subject: [PATCH v7 1/5] drm/atomic_helper: Disallow new modesets on unregistered connectors Date: Mon, 8 Oct 2018 19:24:30 -0400 Message-Id: <20181008232437.5571-2-lyude@redhat.com> In-Reply-To: <20181008232437.5571-1-lyude@redhat.com> References: <20181008232437.5571-1-lyude@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 08 Oct 2018 23:24:49 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the exception of modesets which would switch the DPMS state of a connector from on to off, we want to make sure that we disallow all modesets which would result in enabling a new monitor or a new mode configuration on a monitor if the connector for the display in question is no longer registered. This allows us to stop userspace from trying to enable new displays on connectors for an MST topology that were just removed from the system, without preventing userspace from disabling DPMS on those connectors. Changes since v5: - Fix typo in comment, nothing else Signed-off-by: Lyude Paul Reviewed-by: Daniel Vetter Cc: stable@vger.kernel.org --- drivers/gpu/drm/drm_atomic_helper.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 6f66777dca4b..e6a2cf72de5e 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -319,6 +319,26 @@ update_connector_routing(struct drm_atomic_state *state, return 0; } + crtc_state = drm_atomic_get_new_crtc_state(state, + new_connector_state->crtc); + /* + * For compatibility with legacy users, we want to make sure that + * we allow DPMS On->Off modesets on unregistered connectors. Modesets + * which would result in anything else must be considered invalid, to + * avoid turning on new displays on dead connectors. + * + * Since the connector can be unregistered at any point during an + * atomic check or commit, this is racy. But that's OK: all we care + * about is ensuring that userspace can't do anything but shut off the + * display on a connector that was destroyed after its been notified, + * not before. + */ + if (!READ_ONCE(connector->registered) && crtc_state->active) { + DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] is not registered\n", + connector->base.id, connector->name); + return -EINVAL; + } + funcs = connector->helper_private; if (funcs->atomic_best_encoder) @@ -363,7 +383,6 @@ update_connector_routing(struct drm_atomic_state *state, set_best_encoder(state, new_connector_state, new_encoder); - crtc_state = drm_atomic_get_new_crtc_state(state, new_connector_state->crtc); crtc_state->connectors_changed = true; DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] using [ENCODER:%d:%s] on [CRTC:%d:%s]\n", -- 2.17.1