Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5320645rwb; Mon, 8 Aug 2022 16:57:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR5qK4xUmM3SjVs7uQ7S+2dHTsLop35+u/ThOBUfX5VP400CFgA2g9u2zOJXpcfWY0uu9S6o X-Received: by 2002:a05:6402:2547:b0:43e:4cc4:85d3 with SMTP id l7-20020a056402254700b0043e4cc485d3mr19408053edb.233.1660003060190; Mon, 08 Aug 2022 16:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660003060; cv=none; d=google.com; s=arc-20160816; b=OOCzuzioceUHaV3p6bUyQzG7z3qRgjm127yy3caEEGnI7BPNAbPsjNnpCYFraY/cQs wIuOtn/p7JuiXj45q84r+t55nMbi68cqmZHeSENSyByUA9uzShkWd37fYTFJZqfZy20H H87o+H5+gMrP+vbBv1XldbPPAj95v57FuqHsIzMqQTX24fbnSbG8TXyEfPba1YzJPWon Wuj5e/p1R3dggaEes+38mRqKjnSSxRS8RuuP/ZJA9pp8bja6lzA4N2KDgYsMDuZZ+pcA M/AJYfzjly+/UmVFAVaguAoxh1B7LanP47yP5B7MiP+BDkLk4hqkyWNFtu8Et38wBzBW w51Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=arx/gNMaBWSMzIFnbDvjSVEfRTMKGfLtAKbqa9ATj4s=; b=pXryV0Ufk5xB7AtAnDLQmlBfT1BvbrNLl6w8/UpLcWL5e4KasD/aPXGJGlrH8NmPx9 45CtZrS+AGcRFlfwVF/fncEzvUvLydc0NdjgOZlHVNNZrPW7opg8NrRI/nYzflNEe4np EmDC8TBvI3mcCeXFog/vQ5aPyGhoTKWpJD5v12NqC0nhCtjh4Bkz1vfYLDBDp3bFTo5i /E1Szn0QEJHORwOwGGyWhvVO+OxtO0V9yipdnkWI/qwCtXfpOsfMALG9q8xSWBUG/9yf 8m/W6E3DI0hfdHwiyiZlwTeZQ9UmYrWY30MctUpacKZaTOeeZZ8IuyAdrnwBhw+hcF1j RNsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HusVwXay; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky4-20020a170907778400b0072b12db5f1csi690577ejc.451.2022.08.08.16.57.14; Mon, 08 Aug 2022 16:57:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HusVwXay; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244666AbiHHXzU (ORCPT + 99 others); Mon, 8 Aug 2022 19:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244525AbiHHXzJ (ORCPT ); Mon, 8 Aug 2022 19:55:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9D6CC1CB0F for ; Mon, 8 Aug 2022 16:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660002890; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=arx/gNMaBWSMzIFnbDvjSVEfRTMKGfLtAKbqa9ATj4s=; b=HusVwXay1rnnH0xywt28zbj/6KXODwfT9omGNJS+ZW+wYAtmanlcLeX7kYYQAE//Wv+Wya BrdUe1mTY/FL+rixg5yMI+AEsmyji+Zoc6v9o8eKkdVajxTS6F6507apW0vvYAQBnfpUfp heceSV9fVwZ/0kas79DMuSViKxWftiA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-266-YoePtqdhNU-HVCsUWM1OVA-1; Mon, 08 Aug 2022 19:54:48 -0400 X-MC-Unique: YoePtqdhNU-HVCsUWM1OVA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E908318A6523; Mon, 8 Aug 2022 23:54:46 +0000 (UTC) Received: from emerald.lyude.net (unknown [10.22.17.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id B14AFC15BA1; Mon, 8 Aug 2022 23:54:45 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Wayne Lin , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Fangzhi Zuo , Jani Nikula , Imre Deak , Daniel Vetter , Sean Paul , Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Ben Skeggs , Karol Herbst , hersen wu , Roman Li , Thomas Zimmermann , Bhawanpreet Lakha , =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= , Hangyu Hua , He Ying , Dave Airlie , Sean Paul , Luo Jiaxing , Fernando Ramos , linux-kernel@vger.kernel.org (open list) Subject: [RFC v2 09/18] drm/display/dp_mst: Don't open code modeset checks for releasing time slots Date: Mon, 8 Aug 2022 19:51:54 -0400 Message-Id: <20220808235203.123892-10-lyude@redhat.com> In-Reply-To: <20220808235203.123892-1-lyude@redhat.com> References: <20220808235203.123892-1-lyude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I'm not sure why, but at the time I originally wrote the find/release time slot helpers I thought we should avoid keeping modeset tracking out of the MST helpers. In retrospect though there's no actual good reason to do this, and the logic has ended up being identical across all the drivers using the helpers. Also, it needs to be fixed anyway so we don't break things when going atomic-only with MST. So, let's just move this code into drm_dp_atomic_release_time_slots() and stop open coding it. Signed-off-by: Lyude Paul Cc: Wayne Lin Cc: Ville Syrjälä Cc: Fangzhi Zuo Cc: Jani Nikula Cc: Imre Deak Cc: Daniel Vetter Cc: Sean Paul Acked-by: Jani Nikula --- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 29 +++---------------- drivers/gpu/drm/display/drm_dp_mst_topology.c | 21 ++++++++++++-- drivers/gpu/drm/i915/display/intel_dp_mst.c | 24 +-------------- drivers/gpu/drm/nouveau/dispnv50/disp.c | 21 -------------- 4 files changed, 23 insertions(+), 72 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c index 655d63b20b33..7a0d6cfa77f5 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c @@ -447,34 +447,13 @@ dm_dp_mst_detect(struct drm_connector *connector, } static int dm_dp_mst_atomic_check(struct drm_connector *connector, - struct drm_atomic_state *state) + struct drm_atomic_state *state) { - struct drm_connector_state *new_conn_state = - drm_atomic_get_new_connector_state(state, connector); - struct drm_connector_state *old_conn_state = - drm_atomic_get_old_connector_state(state, connector); struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); - struct drm_crtc_state *new_crtc_state; - struct drm_dp_mst_topology_mgr *mst_mgr; - struct drm_dp_mst_port *mst_port; + struct drm_dp_mst_topology_mgr *mst_mgr = &aconnector->mst_port->mst_mgr; + struct drm_dp_mst_port *mst_port = aconnector->port; - mst_port = aconnector->port; - mst_mgr = &aconnector->mst_port->mst_mgr; - - if (!old_conn_state->crtc) - return 0; - - if (new_conn_state->crtc) { - new_crtc_state = drm_atomic_get_new_crtc_state(state, new_conn_state->crtc); - if (!new_crtc_state || - !drm_atomic_crtc_needs_modeset(new_crtc_state) || - new_crtc_state->enable) - return 0; - } - - return drm_dp_atomic_release_time_slots(state, - mst_mgr, - mst_port); + return drm_dp_atomic_release_time_slots(state, mst_mgr, mst_port); } static const struct drm_connector_helper_funcs dm_dp_mst_connector_helper_funcs = { diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c index d701e5b819b8..aa6dcd9ff6a5 100644 --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c @@ -4473,14 +4473,29 @@ int drm_dp_atomic_release_time_slots(struct drm_atomic_state *state, { struct drm_dp_mst_topology_state *topology_state; struct drm_dp_mst_atomic_payload *payload; - struct drm_connector_state *conn_state; + struct drm_connector_state *old_conn_state, *new_conn_state; + + old_conn_state = drm_atomic_get_old_connector_state(state, port->connector); + if (!old_conn_state->crtc) + return 0; + + /* If the CRTC isn't disabled by this state, don't release it's payload */ + new_conn_state = drm_atomic_get_new_connector_state(state, port->connector); + if (new_conn_state->crtc) { + struct drm_crtc_state *crtc_state = + drm_atomic_get_new_crtc_state(state, new_conn_state->crtc); + + if (!crtc_state || + !drm_atomic_crtc_needs_modeset(crtc_state) || + crtc_state->enable) + return 0; + } topology_state = drm_atomic_get_mst_topology_state(state, mgr); if (IS_ERR(topology_state)) return PTR_ERR(topology_state); - conn_state = drm_atomic_get_old_connector_state(state, port->connector); - topology_state->pending_crtc_mask |= drm_crtc_mask(conn_state->crtc); + topology_state->pending_crtc_mask |= drm_crtc_mask(old_conn_state->crtc); payload = drm_atomic_get_mst_payload_state(topology_state, port); if (WARN_ON(!payload)) { diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c index 1cebbc51d8fa..1b067cd73261 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c @@ -308,13 +308,10 @@ intel_dp_mst_atomic_check(struct drm_connector *connector, struct drm_atomic_state *_state) { struct intel_atomic_state *state = to_intel_atomic_state(_state); - struct drm_connector_state *new_conn_state = - drm_atomic_get_new_connector_state(&state->base, connector); struct drm_connector_state *old_conn_state = drm_atomic_get_old_connector_state(&state->base, connector); struct intel_connector *intel_connector = to_intel_connector(connector); - struct drm_crtc *new_crtc = new_conn_state->crtc; struct drm_dp_mst_topology_mgr *mgr; int ret; @@ -326,27 +323,8 @@ intel_dp_mst_atomic_check(struct drm_connector *connector, if (ret) return ret; - if (!old_conn_state->crtc) - return 0; - - /* We only want to free VCPI if this state disables the CRTC on this - * connector - */ - if (new_crtc) { - struct intel_crtc *crtc = to_intel_crtc(new_crtc); - struct intel_crtc_state *crtc_state = - intel_atomic_get_new_crtc_state(state, crtc); - - if (!crtc_state || - !drm_atomic_crtc_needs_modeset(&crtc_state->uapi) || - crtc_state->uapi.enable) - return 0; - } - mgr = &enc_to_mst(to_intel_encoder(old_conn_state->best_encoder))->primary->dp.mst_mgr; - ret = drm_dp_atomic_release_time_slots(&state->base, mgr, intel_connector->port); - - return ret; + return drm_dp_atomic_release_time_slots(&state->base, mgr, intel_connector->port); } static void clear_act_sent(struct intel_encoder *encoder, diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index c55af5d78ea2..5669c8d747d7 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -1255,27 +1255,6 @@ nv50_mstc_atomic_check(struct drm_connector *connector, { struct nv50_mstc *mstc = nv50_mstc(connector); struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; - struct drm_connector_state *new_conn_state = - drm_atomic_get_new_connector_state(state, connector); - struct drm_connector_state *old_conn_state = - drm_atomic_get_old_connector_state(state, connector); - struct drm_crtc_state *crtc_state; - struct drm_crtc *new_crtc = new_conn_state->crtc; - - if (!old_conn_state->crtc) - return 0; - - /* We only want to free VCPI if this state disables the CRTC on this - * connector - */ - if (new_crtc) { - crtc_state = drm_atomic_get_new_crtc_state(state, new_crtc); - - if (!crtc_state || - !drm_atomic_crtc_needs_modeset(crtc_state) || - crtc_state->enable) - return 0; - } return drm_dp_atomic_release_time_slots(state, mgr, mstc->port); } -- 2.37.1