Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5221557rwb; Wed, 17 Aug 2022 13:23:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR4NkJTpR3z9j0rDlDIfb19Xy9dYqAFPjaVSftkLqVdqKyCNqCtiZ0XYzq/AspSAbSB6G98E X-Received: by 2002:a05:6402:d73:b0:445:918c:5e77 with SMTP id ec51-20020a0564020d7300b00445918c5e77mr6803761edb.258.1660767822550; Wed, 17 Aug 2022 13:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660767822; cv=none; d=google.com; s=arc-20160816; b=LuWjkj2vi43CBkMjHWeXFXz48ODuKYoW87G9LOW0zgbURfz7PdyPcTDPd8l3bwS41o yzaJwFKuwwZaI4YEIUpuxwIPEUf6uCFDWNDPYgJOSHqVmhi27fhLakjlApxRaE8xk3+Z FjymQB8h9E93lb8ucIS++ljmmpAUS2klk2YC4sb3+oKz3XdJwwNIH1DxiurSQpMSxNXQ svwei1lgrS7AeNncb2mv7eGQMjkEUtds336iKfdy3UbLQdoBxb2lZS0lFdJHB1/IqN00 DsZBsouNc7vVmXetcOhK2Zg0Sr5giKDFvEnGA9nz9WAUkZbPDRf/ha2GzWM2lRxQTzmj +wFQ== 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=nRkEWxEO8DrSLjzrrLiKcOrYhMxWHkW7Qi7UVUSsLqo=; b=Pm8e/Nt0cxrTDFeeP9NdQRvSHCy+LUOkiHSAyxqML7J94MzIq27kcCVZd0Z91+YHbq H7HsEBlvicPH79fYKKPeYuZrwuB/zOo1dMcr/SK9Rk60LNDTFe2gts3h5wgtZ4ZD+RAJ pYH5JGj4NYFLjlISqL+Z5a/dwkHl9pMm/Z0w8zKkrbYplApLbppBJiOeuFyorA+GXo0B GBWo/TXodah1qnjNc9gampvl+xL093CpiZQf8qPkc7bkqJtsShZYgZcnzgVIG+XKD9+C qa+xgQ9xisXSLiMiLJTUuRzFNV1ap0qqoElAfoPSR0jvKU70Ap5TJNQfXL/PZbpxKTp9 z4AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qklq0kvb; 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 a26-20020a170906245a00b0072f22d91836si10981235ejb.541.2022.08.17.13.23.03; Wed, 17 Aug 2022 13:23:42 -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=Qklq0kvb; 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 S241592AbiHQTmA (ORCPT + 99 others); Wed, 17 Aug 2022 15:42:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241726AbiHQTkw (ORCPT ); Wed, 17 Aug 2022 15:40:52 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3670A4B09 for ; Wed, 17 Aug 2022 12:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660765250; 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=nRkEWxEO8DrSLjzrrLiKcOrYhMxWHkW7Qi7UVUSsLqo=; b=Qklq0kvbC0bxNVtNc1CYjbWilp22B0UDUKTbwSD2bkjvR8L/VLuvMWGT6nwsZ85441p2Go TIODlliekn38vEQqxrTl3Y0hOT0G/udDRH9VkF9cWOGPS1ZWlXgDVAfZG3WYF13avwEdl/ 9NDdkcWgDU1la7Een01VjpbpH+fjqRc= 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-661-WeTt46ojOsa886CMCTJ_Bg-1; Wed, 17 Aug 2022 15:40:48 -0400 X-MC-Unique: WeTt46ojOsa886CMCTJ_Bg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D7C2185A7BA; Wed, 17 Aug 2022 19:40:47 +0000 (UTC) Received: from emerald.redhat.com (unknown [10.22.18.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D1DE492C3B; Wed, 17 Aug 2022 19:40:46 +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 , David Airlie , Daniel Vetter , Thomas Zimmermann , Bhawanpreet Lakha , Alex Deucher , linux-kernel@vger.kernel.org (open list) Subject: [RFC v4 15/17] drm/display/dp_mst: Maintain time slot allocations when deleting payloads Date: Wed, 17 Aug 2022 15:38:44 -0400 Message-Id: <20220817193847.557945-16-lyude@redhat.com> In-Reply-To: <20220817193847.557945-1-lyude@redhat.com> References: <20220817193847.557945-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.9 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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 Currently, we set drm_dp_atomic_payload->time_slots to 0 in order to indicate that we're about to delete a payload in the current atomic state. Since we're going to be dropping all of the legacy code for handling the payload table however, we need to be able to ensure that we still keep track of the current time slot allocations for each payload so we can reuse this info when asking the root MST hub to delete payloads. We'll also be using it to recalculate the start slots of each VC. So, let's keep track of the intent of a payload in drm_dp_atomic_payload by adding ->delete, which we set whenever we're planning on deleting a payload during the current atomic commit. 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 --- drivers/gpu/drm/display/drm_dp_mst_topology.c | 14 +++++++------- include/drm/display/drm_dp_mst_helper.h | 5 ++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c index a5460cadf2c8..c4073d733c59 100644 --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c @@ -4407,7 +4407,7 @@ int drm_dp_atomic_find_time_slots(struct drm_atomic_state *state, * releasing and allocating the same timeslot allocation, * which is an error */ - if (WARN_ON(!prev_slots)) { + if (drm_WARN_ON(mgr->dev, payload->delete)) { drm_err(mgr->dev, "cannot allocate and release time slots on [MST PORT:%p] in the same state\n", port); @@ -4512,10 +4512,10 @@ int drm_dp_atomic_release_time_slots(struct drm_atomic_state *state, } drm_dbg_atomic(mgr->dev, "[MST PORT:%p] TU %d -> 0\n", port, payload->time_slots); - if (payload->time_slots) { + if (!payload->delete) { drm_dp_mst_put_port_malloc(port); - payload->time_slots = 0; payload->pbn = 0; + payload->delete = true; } return 0; @@ -5239,7 +5239,7 @@ drm_dp_mst_duplicate_state(struct drm_private_obj *obj) list_for_each_entry(pos, &old_state->payloads, next) { /* Prune leftover freed timeslot allocations */ - if (!pos->time_slots) + if (pos->delete) continue; payload = kmemdup(pos, sizeof(*payload), GFP_KERNEL); @@ -5271,8 +5271,8 @@ static void drm_dp_mst_destroy_state(struct drm_private_obj *obj, int i; list_for_each_entry_safe(pos, tmp, &mst_state->payloads, next) { - /* We only keep references to ports with non-zero VCPIs */ - if (pos->time_slots) + /* We only keep references to ports with active payloads */ + if (!pos->delete) drm_dp_mst_put_port_malloc(pos->port); kfree(pos); } @@ -5400,7 +5400,7 @@ drm_dp_mst_atomic_check_payload_alloc_limits(struct drm_dp_mst_topology_mgr *mgr list_for_each_entry(payload, &mst_state->payloads, next) { /* Releasing payloads is always OK-even if the port is gone */ - if (!payload->time_slots) { + if (payload->delete) { drm_dbg_atomic(mgr->dev, "[MST PORT:%p] releases all time slots\n", payload->port); continue; diff --git a/include/drm/display/drm_dp_mst_helper.h b/include/drm/display/drm_dp_mst_helper.h index b9c361b242ea..8b847836a0b4 100644 --- a/include/drm/display/drm_dp_mst_helper.h +++ b/include/drm/display/drm_dp_mst_helper.h @@ -560,8 +560,11 @@ struct drm_dp_mst_atomic_payload { int time_slots; /** @pbn: The payload bandwidth for this payload */ int pbn; + + /** @delete: Whether or not we intend to delete this payload during this atomic commit */ + bool delete : 1; /** @dsc_enabled: Whether or not this payload has DSC enabled */ - bool dsc_enabled; + bool dsc_enabled : 1; /** @next: The list node for this payload */ struct list_head next; -- 2.37.1