From patchwork Wed Jun 16 03:55:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Wayne" X-Patchwork-Id: 12323919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78606C48BE8 for ; Wed, 16 Jun 2021 03:55:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 415C061075 for ; Wed, 16 Jun 2021 03:55:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 415C061075 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9EE416E4A6; Wed, 16 Jun 2021 03:55:54 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2059.outbound.protection.outlook.com [40.107.94.59]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE8B76E4B3 for ; Wed, 16 Jun 2021 03:55:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q4mxiXDJfr+ZlpNDoXN+YOnf8gX5HbZZgZ9ykFnKDI3vWwx8TveLvUeVpTIy+c9CV1ZRuVrQBTqWoOjCMcrb33l3Dyzyq+lDBmgM8NB2RfA8TRAh+7dwxzsdM0hYoIgaSbFeqEwZ4zGMdNASij3l6Lo7cXr+D5AeI4Ifq9g3KrXRTXyRdqlqEuqDPS9iZ6wkOUHSOyuBzsTFnJ8XwYRT4qELb6chv4A++faSbkxAJh0FUeSTvCzPhKHviFn3sHO3O3Qt2Ci9x+MNsXF/zgJMf/IktBHUj7zb9KUZ/tYurHZeq7p0BcugZ2sGmh+RcFrqc8Wht/Aa6EY95+sdafp4Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bP1kudVf23kPjyJr2s9qVOX6XyzRFbMrmLQ3IsFonR4=; b=ExQpMXYwGyGA+e6MSpPo3y3z8ja7/aa1eRcO8GCbd1Zt208ai+49YI1csxZRavhFUIJlNefpmYL2WLdMq4HpKQSePu3ofV+LiLVN/B7UI346MlLmiC7APSGKACPVmfpBOgJMhS023i2glQ7vBKtYhOYNAZAafeCkR4itm92FdlN3x9wplAe3Wtn2MbYIbIELdh8e7oixZ4+hSI4kjmiI4ih0yt/Riz+PJqM+Oeqzv7y1vVxjiTMIQB+bZr6c2kjnPcB4dzkZiVfg35Tt98HcsSbe0abnVAe5a1NpX04UEzrvjA8TfTViQ6hBXIbmWkYz0nSJDO5ud4PGQ4qAOGsU4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bP1kudVf23kPjyJr2s9qVOX6XyzRFbMrmLQ3IsFonR4=; b=FxQsTiyVXyb2w08yrAp0uKiyqRGPsfxZcfv8tIuJ2mEsF6tTbEDUswQ8+N8gMTHha81K7TNABMoWQRz5bY4Jru9AFnb5+7UVe3RTorHEfHUHlIrdOTmJHnP2U/UsfDFW/KOQdJRdO0fOr/vGCDVNtgUDuJ6ymGHT6dU3xDBHEWY= Received: from BN6PR1101CA0013.namprd11.prod.outlook.com (2603:10b6:405:4a::23) by BL1PR12MB5176.namprd12.prod.outlook.com (2603:10b6:208:311::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.25; Wed, 16 Jun 2021 03:55:51 +0000 Received: from BN8NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:405:4a:cafe::5d) by BN6PR1101CA0013.outlook.office365.com (2603:10b6:405:4a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.22 via Frontend Transport; Wed, 16 Jun 2021 03:55:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT017.mail.protection.outlook.com (10.13.177.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4242.16 via Frontend Transport; Wed, 16 Jun 2021 03:55:51 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 15 Jun 2021 22:55:51 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 15 Jun 2021 20:55:50 -0700 Received: from wayne-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Tue, 15 Jun 2021 22:55:48 -0500 From: Wayne Lin To: Subject: [PATCH v2 1/2] drm/dp_mst: Do not set proposed vcpi directly Date: Wed, 16 Jun 2021 11:55:00 +0800 Message-ID: <20210616035501.3776-2-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210616035501.3776-1-Wayne.Lin@amd.com> References: <20210616035501.3776-1-Wayne.Lin@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a86e3b4b-97be-4ca3-57fa-08d9307aa235 X-MS-TrafficTypeDiagnostic: BL1PR12MB5176: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:31; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0FPWHemCr0nXGWtixQ2/Es/exOC52mKVP4edTQCSYtS/tjn7FDtp29fw/WCIITCDhFwZtjPJt+tZfHABFuXDa79CydA7Bewrq7KTOILmcV5U8LMYyRkUOOtyq39q+nD+OyfatKq6vlPO/as1QN3j+8wGtDWA/BNS67QNL5xM0FVSbAtNtiZWYc18GqssLjDC03SkLs834kJ+OAcnFF63hoi5GIs67cukseWFc5UDYXLCWfxlTgKkfZ9JR9+6hU4cTtio9WgmIkAeh0CNVBkd2t3aLmrCZ5m1WEY8jVVNUUhAp22VYbzwxVVz1ldf/CSHHVA3V24QJsWHzkpshK0Uz1HN+yTO1mdIXUXFs94BTtCFM3z5WkKcN2YtRMdmWmRXSozSK2G/7MzyFTyoQI+JQ13jUZFGsddm+YgkhjVr5UGtw68p8VHRJW1rHkgHxSB+rAB63vjxq9hjHD/BtO/bOL6LK+e9IrK1DL4qT4Qn5jyA1Fk3XWKtLZKk02gGHYyWMVNpiuZBz5T2LyewDkCwlL7cWozZhelhmS8d7F71WfvClFha/gn/jMoMBdZWkp/VLTMKyGPny/GdIz1Wzo+3UF33B2cscq8dK0fPrZt9OURVzXIOR9Yie5n7277BRRu1APRvU6bKaj+Gy124u4vSrXR+Ba43z4tBIeVM1OXhHZ7tiipp1I54TYQ8Z+XAJjP1 X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(346002)(39860400002)(396003)(136003)(376002)(36840700001)(46966006)(70586007)(6666004)(316002)(356005)(186003)(1076003)(47076005)(478600001)(26005)(81166007)(70206006)(2906002)(82740400003)(8936002)(426003)(336012)(83380400001)(2616005)(7696005)(5660300002)(82310400003)(4326008)(54906003)(8676002)(6916009)(36756003)(86362001)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 03:55:51.4744 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a86e3b4b-97be-4ca3-57fa-08d9307aa235 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5176 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jerry.zuo@amd.com, aurabindo.pillai@amd.com, stable@vger.kernel.org, Thomas Zimmermann , Wayne Lin , Nicholas.Kazlauskas@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" [Why] When we receive CSN message to notify one port is disconnected, we will implicitly set its corresponding num_slots to 0. Later on, we will eventually call drm_dp_update_payload_part1() to arrange down streams. In drm_dp_update_payload_part1(), we iterate over all proposed_vcpis[] to do the update. Not specific to a target sink only. For example, if we light up 2 monitors, Monitor_A and Monitor_B, and then we unplug Monitor_B. Later on, when we call drm_dp_update_payload_part1() to try to update payload for Monitor_A, we'll also implicitly clean payload for Monitor_B at the same time. And finally, when we try to call drm_dp_update_payload_part1() to clean payload for Monitor_B, we will do nothing at this time since payload for Monitor_B has been cleaned up previously. For StarTech 1to3 DP hub, it seems like if we didn't update DPCD payload ID table then polling for "ACT Handled"(BIT_1 of DPCD 002C0h) will fail and this polling will last for 3 seconds. Therefore, guess the best way is we don't set the proposed_vcpi[] diretly. Let user of these herlper functions to set the proposed_vcpi directly. [How] 1. Revert commit 7617e9621bf2 ("drm/dp_mst: clear time slots for ports invalid") 2. Tackle the issue in previous commit by skipping those trasient proposed VCPIs. These stale VCPIs shoulde be explicitly cleared by user later on. Changes since v1: * Change debug macro to use drm_dbg_kms() instead * Amend the commit message to add Fixed & Cc tags Signed-off-by: Wayne Lin Fixes: 7617e9621bf2 ("drm/dp_mst: clear time slots for ports invalid") Cc: Lyude Paul Cc: Wayne Lin Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org Cc: # v5.5+ --- drivers/gpu/drm/drm_dp_mst_topology.c | 36 ++++++++------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 32b7f8983b94..b41b837db66d 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -2501,7 +2501,7 @@ drm_dp_mst_handle_conn_stat(struct drm_dp_mst_branch *mstb, { struct drm_dp_mst_topology_mgr *mgr = mstb->mgr; struct drm_dp_mst_port *port; - int old_ddps, old_input, ret, i; + int old_ddps, ret; u8 new_pdt; bool new_mcs; bool dowork = false, create_connector = false; @@ -2533,7 +2533,6 @@ drm_dp_mst_handle_conn_stat(struct drm_dp_mst_branch *mstb, } old_ddps = port->ddps; - old_input = port->input; port->input = conn_stat->input_port; port->ldps = conn_stat->legacy_device_plug_status; port->ddps = conn_stat->displayport_device_plug_status; @@ -2555,28 +2554,6 @@ drm_dp_mst_handle_conn_stat(struct drm_dp_mst_branch *mstb, dowork = false; } - if (!old_input && old_ddps != port->ddps && !port->ddps) { - for (i = 0; i < mgr->max_payloads; i++) { - struct drm_dp_vcpi *vcpi = mgr->proposed_vcpis[i]; - struct drm_dp_mst_port *port_validated; - - if (!vcpi) - continue; - - port_validated = - container_of(vcpi, struct drm_dp_mst_port, vcpi); - port_validated = - drm_dp_mst_topology_get_port_validated(mgr, port_validated); - if (!port_validated) { - mutex_lock(&mgr->payload_lock); - vcpi->num_slots = 0; - mutex_unlock(&mgr->payload_lock); - } else { - drm_dp_mst_topology_put_port(port_validated); - } - } - } - if (port->connector) drm_modeset_unlock(&mgr->base.lock); else if (create_connector) @@ -3410,8 +3387,15 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr) port = drm_dp_mst_topology_get_port_validated( mgr, port); if (!port) { - mutex_unlock(&mgr->payload_lock); - return -EINVAL; + if (vcpi->num_slots == payload->num_slots) { + cur_slots += vcpi->num_slots; + payload->start_slot = req_payload.start_slot; + continue; + } else { + drm_dbg_kms("Fail:set payload to invalid sink"); + mutex_unlock(&mgr->payload_lock); + return -EINVAL; + } } put_port = true; } From patchwork Wed Jun 16 03:55:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Wayne" X-Patchwork-Id: 12323923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5ED1AC48BE6 for ; Wed, 16 Jun 2021 03:56:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D7C561075 for ; Wed, 16 Jun 2021 03:56:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D7C561075 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A6866E4AF; Wed, 16 Jun 2021 03:56:02 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2064.outbound.protection.outlook.com [40.107.93.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED61C6E49B for ; Wed, 16 Jun 2021 03:55:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kINpXXWUJMi0v74MQZpscoSCRccN1+U5ZQUTxWT+0Z3l4yr9HKNL4w0V5At8CzaGNdLaSgftyE+HuUPoFCYp+MpVybjsqpklBUIwvT4bSY/yg7K5FPFS1GzztSBUpL+IXa5Cehq02cAdKKWlDV4Xg8tf2E9PxJW7Yst6jKQ4F7ousWIS4e2UcDz2PZCHRKtHqSMx4gtcteuzXjHbkZ3kGyBp7dEggS7wH/58Rl03EHB37UoF/bT75e0H9sQh99ffNwt+viK1S6vShFZjk23KHRhGgkU9oed6eRDmrf86Np91QI07WCVIaDtVCXwPzKF5tRIR8c/7RdaQ/Yq911s9Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mln9HhtwWqUVJUt9shkU5clzS8X0D8nsD2B9afkXI6w=; b=fw5z8w2PsmhfJNQ6Q9H5BnsWVqr2xu82/6R2l5varkGeaShLN3nNd2VZkeAOULcjBxkLvc5K6gbtRNoQznyGLM4iRTziamzEaDc/o9D4LJJU9HRo8z12Bp5HtkRub6X8Xmidl0D+VkDrNiUchyCKMa4ZEhyggiaudmd9WOJI9CNKIaKKugKfYkLEnK8eywGsopYupyd27Qw33Q+y6hSiWnHNSf/RmfXo5gG6HgKZ7kvLJA4KfXzpkCDbNFoEEwfziBq92i4n2+/1fakuoUhU+efIB/uMoffhEVjZTq71kgzDxvH0J9rVNRrSM+QuEoa+nIN0XiBALAoJ0J/yLNpKqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mln9HhtwWqUVJUt9shkU5clzS8X0D8nsD2B9afkXI6w=; b=eakum4qR6nfzQtNrOPn8ASiF56gaGvdpqP7NVOsLBKyAY0lP9pbGT2P7GOnhw+F8W6YhQbMxXiqR+Af28MCIte0xwy+N2ERbdrskBTemAHt7+qp8xdl0cSEu0F71nF/iE0TyDBFsylFIusqwIpf6gHCMmVsc9KvQaH0gG9XoaI8= Received: from MWHPR2001CA0011.namprd20.prod.outlook.com (2603:10b6:301:15::21) by DM6PR12MB3290.namprd12.prod.outlook.com (2603:10b6:5:189::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 16 Jun 2021 03:55:56 +0000 Received: from CO1NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:301:15:cafe::af) by MWHPR2001CA0011.outlook.office365.com (2603:10b6:301:15::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 03:55:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT027.mail.protection.outlook.com (10.13.174.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4242.16 via Frontend Transport; Wed, 16 Jun 2021 03:55:55 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 15 Jun 2021 22:55:54 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 15 Jun 2021 20:55:54 -0700 Received: from wayne-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Tue, 15 Jun 2021 22:55:52 -0500 From: Wayne Lin To: Subject: [PATCH v2 2/2] drm/dp_mst: Avoid to mess up payload table by ports in stale topology Date: Wed, 16 Jun 2021 11:55:01 +0800 Message-ID: <20210616035501.3776-3-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210616035501.3776-1-Wayne.Lin@amd.com> References: <20210616035501.3776-1-Wayne.Lin@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ca4a5b5-14b4-4102-af1a-08d9307aa4dc X-MS-TrafficTypeDiagnostic: DM6PR12MB3290: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QStP8uaJYJaAcubfW53cBKReybExw8c1UQFhqpqvnUgd2LiMyeXyVMr+40KH/oFMnwHck6W/7A0Jld3rIgrozr8JsmhIqXWv+Xlx0M9Uxx89PWSlL2O/r+qsZK+EJJBfVIitdCPZeTatYPmghcgEM6buQhEgWqCy30VOlP2D1o9idRaPCWGpAuoBXBjE3jWvlShtQIdJ1Maq9KqBD5p+jLs6IZUacEgbHx0g4u9FLpiRDSyblLR/nbyHMergkFKwCz6sZtHAL3nNeXxFe/yxcQ1eKaYBQwj2kpNiLqY6MWbXA99/yCKE5AS5jy02X8nMFYBfnd3QIgN0n+ROpFsnwaKnU4+2LZKu1cuRDQBg1Qw8vAXiP+gpdnuhIHtJIup7g1DTCYmxi3fLHXpjHY6OJA7dXENrN1H+rzsQ8JpRiEeW7x1hbkjTrr0u+dtiGVTE9PQU5As1b3wYUcIiBkGaAqNqM45H8pEERj9GdNab1063nu7Ju53U6lFB6/j6z0LwcNwQC3p0q4ljdW6/raJg/4Zba0nlvj1ILQx8FMPOATJ9zxr273B7Ka4Puox9xi2vY3o9ETk5BP/u3RNygEwmfnyZ+CCtkc/vgav2oj1ik9fFIre1WPuilp+3+wU2azm32+gNLSmPuxkTeZEQzetPZHCXMeIcEK7cXMj/x3vldROq0bRPcUpc0AofTAL/BRoC X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(39860400002)(396003)(136003)(376002)(346002)(36840700001)(46966006)(4326008)(5660300002)(186003)(2906002)(70586007)(336012)(2616005)(82310400003)(8676002)(86362001)(26005)(1076003)(8936002)(426003)(356005)(6666004)(81166007)(83380400001)(7696005)(36860700001)(36756003)(54906003)(47076005)(70206006)(478600001)(82740400003)(316002)(6916009)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 03:55:55.7186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ca4a5b5-14b4-4102-af1a-08d9307aa4dc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3290 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stable@vger.kernel.org, jerry.zuo@amd.com, aurabindo.pillai@amd.com, Wayne Lin , Nicholas.Kazlauskas@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" [Why] After unplug/hotplug hub from the system, userspace might start to clear stale payloads gradually. If we call drm_dp_mst_deallocate_vcpi() to release stale VCPI of those ports which are not relating to current topology, we have chane to wrongly clear active payload table entry for current topology. E.g. We have allocated VCPI 1 in current payload table and we call drm_dp_mst_deallocate_vcpi() to clean VCPI 1 in stale topology. In drm_dp_mst_deallocate_vcpi(), it will call drm_dp_mst_put_payload_id() tp put VCPI 1 and which means ID 1 is available again. Thereafter, if we want to allocate a new payload stream, it will find ID 1 is available by drm_dp_mst_assign_payload_id(). However, ID 1 is being used [How] Check target sink is relating to current topology or not before doing any payload table update. Searching upward to find the target sink's relevant root branch device. If the found root branch device is not the same root of current topology, don't update payload table. Changes since v1: * Change debug macro to use drm_dbg_kms() instead * Amend the commit message to add Cc tag. Signed-off-by: Wayne Lin Cc: stable@vger.kernel.org --- drivers/gpu/drm/drm_dp_mst_topology.c | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index b41b837db66d..9ac148efd9e4 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -94,6 +94,9 @@ static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port); static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port); static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr); +static bool drm_dp_mst_port_downstream_of_branch(struct drm_dp_mst_port *port, + struct drm_dp_mst_branch *branch); + #define DBG_PREFIX "[dp_mst]" #define DP_STR(x) [DP_ ## x] = #x @@ -3366,6 +3369,7 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr) struct drm_dp_mst_port *port; int i, j; int cur_slots = 1; + bool skip; mutex_lock(&mgr->payload_lock); for (i = 0; i < mgr->max_payloads; i++) { @@ -3380,6 +3384,14 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr) port = container_of(vcpi, struct drm_dp_mst_port, vcpi); + mutex_lock(&mgr->lock); + skip = !drm_dp_mst_port_downstream_of_branch(port, mgr->mst_primary); + mutex_unlock(&mgr->lock); + + if (skip) { + drm_dbg_kms("Virtual channel %d is not in current topology\n", i); + continue; + } /* Validated ports don't matter if we're releasing * VCPI */ @@ -3479,6 +3491,7 @@ int drm_dp_update_payload_part2(struct drm_dp_mst_topology_mgr *mgr) struct drm_dp_mst_port *port; int i; int ret = 0; + bool skip; mutex_lock(&mgr->payload_lock); for (i = 0; i < mgr->max_payloads; i++) { @@ -3488,6 +3501,13 @@ int drm_dp_update_payload_part2(struct drm_dp_mst_topology_mgr *mgr) port = container_of(mgr->proposed_vcpis[i], struct drm_dp_mst_port, vcpi); + mutex_lock(&mgr->lock); + skip = !drm_dp_mst_port_downstream_of_branch(port, mgr->mst_primary); + mutex_unlock(&mgr->lock); + + if (skip) + continue; + drm_dbg_kms(mgr->dev, "payload %d %d\n", i, mgr->payloads[i].payload_state); if (mgr->payloads[i].payload_state == DP_PAYLOAD_LOCAL) { ret = drm_dp_create_payload_step2(mgr, port, mgr->proposed_vcpis[i]->vcpi, &mgr->payloads[i]); @@ -4574,9 +4594,18 @@ EXPORT_SYMBOL(drm_dp_mst_reset_vcpi_slots); void drm_dp_mst_deallocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port) { + bool skip; + if (!port->vcpi.vcpi) return; + mutex_lock(&mgr->lock); + skip = !drm_dp_mst_port_downstream_of_branch(port, mgr->mst_primary); + mutex_unlock(&mgr->lock); + + if (skip) + return; + drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi); port->vcpi.num_slots = 0; port->vcpi.pbn = 0;