From patchwork Fri Jul 16 07:41:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Lin X-Patchwork-Id: 479596 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 9258FC07E95 for ; Fri, 16 Jul 2021 07:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76663613E9 for ; Fri, 16 Jul 2021 07:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236137AbhGPHqU (ORCPT ); Fri, 16 Jul 2021 03:46:20 -0400 Received: from mail-dm6nam11on2053.outbound.protection.outlook.com ([40.107.223.53]:28648 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231482AbhGPHqP (ORCPT ); Fri, 16 Jul 2021 03:46:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oZWTsRkvZy9zDGQEZKzLV5BdLU8wZCF1fi++MfM32o/M3tD47cZIr2Iw9MYFsBZdRNB3RQ8oKBb3yIiKfFF83Q1ibFNryiw/7GIkSUKJIRuhhcRMZxfBS5yvgoj3AoE8SQEK/Rjp1YufJTy6/oZBQkq1+JI3n652089ctXgdDA0XoJGgCpjT8X/x+g8RmnOT6tWBr3RmeFgDcCIQjCzsHHZgWTXORoJjP0MmzWaj0udIM9IrNwsfwMjJTCdbLPocNN2aWdOF30BCxwW99miTW93zvnUg9M/+5ZDSWW7+DC6XOXifubBLx2Ucwt5h1JQr3K/hj/UoDIRQrN5q/9z14Q== 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=O9s/fIgSYtU61AA2XyGDRtdnGYEs3yXlUPNtC0eOTQU=; b=nxT97//WOeIecoFyrZ2JJsasN5HQmU6ID9uHCnxkX+XaOfLFzj9necaoNqnYfC7W4QArKLUYW3OFkL0a/nn2VN6YGUiPDgLRkRa2kg9FDtKGBh0NyCLYbpwsKoTyJMvUCL0S2MPFQFXMXrr6ElU36Z+Ntjga8P0YGwp9sY9ClkWO0X5MA40fQ4oLBYq1u8nwk0SIXNcZ1jR2MS0mCrEYHB+39yPW2MDwIHSV/lJZ91h7HnhyD/+/qZ09mH6FswumhKG8mVXHDqDvKpPTSmQ4eNmQcvD57FEtUA30UbtelK5Zf/R4i4sx6kDzYaCJBFE5uxeI5vfKHUu+nhR5hK7J7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.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=O9s/fIgSYtU61AA2XyGDRtdnGYEs3yXlUPNtC0eOTQU=; b=L8IT9h8oC+IsMYXewMFrdv3HtjAncBpXhGcjsseUgCNIAtg9KZ+CvMfkuwVM6Uop1YQI+TZ0YzWSG0AKfhYTc7K8acPfXQp04jr91uFeAbEn5C/NKDdD2OYpSe73ehjd/GW4uwqzDFz4wtT2/ssi4zFhbjVKwXIgF+tsHH229QE= Received: from DS7PR03CA0151.namprd03.prod.outlook.com (2603:10b6:5:3b2::6) by BN6PR12MB1508.namprd12.prod.outlook.com (2603:10b6:405:f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Fri, 16 Jul 2021 07:43:18 +0000 Received: from DM6NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b2:cafe::2) by DS7PR03CA0151.outlook.office365.com (2603:10b6:5:3b2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:43:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.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 DM6NAM11FT051.mail.protection.outlook.com (10.13.172.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:43:18 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 16 Jul 2021 02:43:17 -0500 Received: from wayne-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Fri, 16 Jul 2021 02:43:15 -0500 From: Wayne Lin To: , CC: , Wayne Lin , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Subject: [PATCH 1/3] drm/dp_mst: Do not set proposed vcpi directly Date: Fri, 16 Jul 2021 15:41:59 +0800 Message-ID: <20210716074201.28291-2-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210716074201.28291-1-Wayne.Lin@amd.com> References: <20210716074201.28291-1-Wayne.Lin@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2de51133-3c73-4769-dd70-08d9482d60aa X-MS-TrafficTypeDiagnostic: BN6PR12MB1508: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:31; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jNLH8+ILllexlMumciwb6qaCLTm+IW/jauNmDoKjCLXIK/WBuJvdGibXE39bcD9JpzAN+hvph9DoQ5cvgbo8WQVOu53OToklN/WaPHRGPfWDPlknAQ0cEALSg2E+mbMBgG8y4pwOBL2cZqfXmc4mLwd/NLqI4Nu9vUujN2nw3ZpLsSRDoezEPg1uQ0qqDfja0C3jgjLalVv6AO8usySWsugKZJMRId8Z1hG/ONWfVSy01aOYPz+vqFT6sXBPMsP0p+7QCFkKu3VNwfjqhd/4YGZASeyuWcmZ/BGy/SwXhgHhV9kQaT8LCE8o8Sr+ZHk1KwM6z//k4w6X4e/6tjc/JiSJ96oAPb8nFSv0SWigDHfP6er7qUbW+YxdnqaMTvMw8JhHUGN8IW/WZjB/+/CwAZc/4XTvE0cc1fFa42P3MlPpxF0K4mmVwmRQrFQ1YeeE05WSvfaTm6PTEIm4lUfJp8QbNw8RNJ2Gme+eDWWrP1HHnUPrzcfLAxKtcXDtjfiQd8PRBqtpBcWRRP+pPFWkVSgX+hcSsDNjI+wfNPUiKTN6NyHMkCwuvY+JdymsnbQL4XjVjsrZiMAOWqWlrxEr/VB71mGXX8qPHg/sOu+Mv37PQOOoQkwYMTztOcN+fNX2kJZ3j7NntU36cN/tA7IjZleyLHDuceVIE96DWNsplR8ybzs3fmThWIORq7cmsKyx3dXm9qFhV+rBUnHTqtlkcXfrOE/aub1VXscrShsiZaU= 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)(136003)(346002)(396003)(39860400002)(376002)(46966006)(36840700001)(47076005)(186003)(70586007)(8676002)(110136005)(83380400001)(6666004)(1076003)(8936002)(7696005)(5660300002)(70206006)(336012)(2906002)(36756003)(4326008)(86362001)(36860700001)(316002)(2616005)(26005)(82310400003)(966005)(426003)(478600001)(54906003)(81166007)(356005)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 07:43:18.1185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2de51133-3c73-4769-dd70-08d9482d60aa 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: DM6NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1508 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [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+ Signed-off-by: Lyude Paul Link: https://patchwork.freedesktop.org/patch/msgid/20210616035501.3776-2-Wayne.Lin@amd.com Reviewed-by: Lyude Paul --- 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 159014455fab..2495e2c014ac 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -2497,7 +2497,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; @@ -2529,7 +2529,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; @@ -2552,28 +2551,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) @@ -3404,8 +3381,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 Fri Jul 16 07:42:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Lin X-Patchwork-Id: 478782 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 DD78EC636CA for ; Fri, 16 Jul 2021 07:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CACB6613F1 for ; Fri, 16 Jul 2021 07:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235671AbhGPHqV (ORCPT ); Fri, 16 Jul 2021 03:46:21 -0400 Received: from mail-bn8nam11on2060.outbound.protection.outlook.com ([40.107.236.60]:31077 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231966AbhGPHqT (ORCPT ); Fri, 16 Jul 2021 03:46:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VDc1PhjKgD+UFGjStR+fUOio2Ox7ONtfWrKnKT8j9rmvUhaEplSMrmNT//tv9HyQN7l+x1ZW29TBvel802tbQ7eOznyEbwmvx9ODw4HFNeHbhzju4IX0s2pQkmgpgkqy2WOZ/kU7i8ptQjsZSbGsOHhpWCXrI3/G3ur4X3gxr9iMg8ogY3me1zeRXo6xvVAep7HBbV82QkCgYPd5PaKNy860pdWUIsUWUG2xL72owOvsl/a7dBzsFLJbERotaLyAI7JGMFIElYA25pE0irLdukj7v++s5//UjT1HKRfhv/ZKxeTL2W8UGJz3WeBPNmSZfVO4/F55D/BHmhqdfylgmg== 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=T1sxl3ff0huFdWlKsN3H5SYJhZYjkDKyknJ51i/YGo0=; b=cOlcTob3eY/pVMwWG1K4iUH6M31jlmNJWnqj7Oy1Lx7sMIQqvWauOJTtBO3QEEgOyZ3HEfBtnZiIpyhuyxnfQAYfoeH1XjiT5ambK3Y88mqEsF+GT0SWroVTlEGqHLLPX+oyAodPQv5oHFq5CqTylqj+JlPUME5237pLhSpckX93iREU3HvZ/20lOMvVmgxOe133BlIuN41WmvXdEtNbv6oc8zpwBhm6yWaHwsuOYi24z70RpX19Vay8i9Qcnko6wt3NIghST9lEtN3wvYhpUdTsqNn3cTFLeTaQeWe6vWIOegmCqueO7Oj+90pMGJWV/CHPRYLenjNOHlhe1RehCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.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=T1sxl3ff0huFdWlKsN3H5SYJhZYjkDKyknJ51i/YGo0=; b=uVk3L5DRfTuVoHOdzwK9p3LH88WHOHI6+cW3xoFu3bXyvIjmjwbhOw17sEuk6DYU0Tu7OoL2RrTLIKB0FTfLlTWzEAIcvO8RYVNUShHKuLDWQvCM7lsvkuYBh9b8Ksw9qHQqopF1WwL/5GlRyYoZ2jOCT6mcKZvaJM8KYnZWlqU= Received: from DM3PR03CA0016.namprd03.prod.outlook.com (2603:10b6:0:50::26) by SN1PR12MB2542.namprd12.prod.outlook.com (2603:10b6:802:26::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23; Fri, 16 Jul 2021 07:43:20 +0000 Received: from DM6NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:0:50:cafe::a8) by DM3PR03CA0016.outlook.office365.com (2603:10b6:0:50::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:43:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.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 DM6NAM11FT009.mail.protection.outlook.com (10.13.173.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:43:20 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 16 Jul 2021 02:43:19 -0500 Received: from wayne-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Fri, 16 Jul 2021 02:43:18 -0500 From: Wayne Lin To: , CC: , Wayne Lin Subject: [PATCH 2/3] drm/dp_mst: Avoid to mess up payload table by ports in stale topology Date: Fri, 16 Jul 2021 15:42:00 +0800 Message-ID: <20210716074201.28291-3-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210716074201.28291-1-Wayne.Lin@amd.com> References: <20210716074201.28291-1-Wayne.Lin@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7a187070-90bd-4c5c-eedd-08d9482d6207 X-MS-TrafficTypeDiagnostic: SN1PR12MB2542: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uCbLk6AsJbF5UQy1hw3ObiDfAbjbhJHsB2ANvdloLGwxZKCC8fiuMsqmN9kxE0hJDTzq8cPsP9vD1oKL8ET1IBVRThDQmjFe3z1EDfDXOV3ric0RWHajMkVBCTe8uNTkmoUDkvqFJ5C57WjyOAlCRIN9ZjmivVvUpKP0Z8VYz0RqBeTA/NMqy/z4BMxMU5+5OBvm6IFu7vpcygLAX5zYml+6gY0OnxHzcWJE2lt45Gf1lMs9rFbYh06MuUuT+rCo03CEYAOxoVfspwmFqH83Rg14ff8Go69d9Eu1VcmXqR7KJ9ViTer5+BEhL6s50a9n4NJZvzHpeJTDIYFz4m1CEOVbhDsHbk0FPrEq54K0+2bRldNah/M4Vf0YlVWzSPgx4s6f646c1fYlh98Ttfl1TvcowhEMJiRfH6ZUMpw4mBc0mL/UONOI1gv2dC++P5v1vZahChqjKVYZzvx+T1rT/pUNhmhfVJww5ELm5Ii/G4lg39qjzB+Ub/Pf8UZbSCCK//8tH+5byABRFSrYzFMCLL2we1nD3HiKrXn7FYLWczKYAWADOkcMstgINa5JQjA6eaxEgeJQjEggPKoajz1F4V1SKIeghWQtqJOKkU4I6ytqG8U0E3L0Ntek3WLOo8lssUG5t4LSHIURjyRXZKNYDo6Jy+PIAmX2dOIk5oSW13FZPncFbyaK7HRcse/vvX8eoKU3uMMedBZVdE2+QKO9tUaGFpiouf4Bl7JRZgjiEZ0= 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)(396003)(376002)(39860400002)(136003)(346002)(46966006)(36840700001)(426003)(110136005)(336012)(54906003)(2616005)(1076003)(2906002)(316002)(26005)(8936002)(6666004)(4326008)(5660300002)(186003)(8676002)(70586007)(7696005)(70206006)(36860700001)(82310400003)(966005)(82740400003)(81166007)(356005)(36756003)(47076005)(83380400001)(86362001)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 07:43:20.4031 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a187070-90bd-4c5c-eedd-08d9482d6207 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: DM6NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2542 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [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 Signed-off-by: Lyude Paul Link: https://patchwork.freedesktop.org/patch/msgid/20210616035501.3776-3-Wayne.Lin@amd.com Reviewed-by: Lyude Paul --- 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 2495e2c014ac..bf6fa98b4ab7 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 @@ -3360,6 +3363,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++) { @@ -3374,6 +3378,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 */ @@ -3473,6 +3485,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++) { @@ -3482,6 +3495,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_DEBUG_KMS("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]); @@ -4561,9 +4581,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; From patchwork Fri Jul 16 07:42:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wayne Lin X-Patchwork-Id: 479595 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 81BB6C07E95 for ; Fri, 16 Jul 2021 07:43:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66484613ED for ; Fri, 16 Jul 2021 07:43:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbhGPHq2 (ORCPT ); Fri, 16 Jul 2021 03:46:28 -0400 Received: from mail-mw2nam10on2060.outbound.protection.outlook.com ([40.107.94.60]:63329 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235441AbhGPHqY (ORCPT ); Fri, 16 Jul 2021 03:46:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L9TM1pXRz7Qyk2IxoE+Xm3Zn3Wn4z8arcHomNQ+g/u7pvKyJ4+m/m1QQnbVPHX7JKZpRYkbBDCMu0jFDD5PqkraxdPWxWajTsLrcKzjEqj33nHjlLNGc9R9u1gJ6sAV1Wy+24mbaWtk7YKYhFqsEMxvQnMK12LtByJrOYBGUj0FzWgaVTA7Vjhd8dL/3EIx9mHNH36AF/DsYWHgDfaoVHY/RefQD3ThqQsf9nuvb8O7tQwPiIvUejsGm7efB30nyEl028Kwd4MrWE8xw/zUNct1YxlW/uoqeVWImxHQRCHpiyUegA+J4E20xh/yfXQ+Mx4a1Io/Hfe0rKZIvqkHvJQ== 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=Sh1+17rFOL3vDQmi1Kk/4K/5RWZs63ouXslu4lsb9Bk=; b=KoTXTZ29/wfAIlB2u2XXJl+55bd0Dm3j5t49A61dLqxB3l/GpcbLDHr8UaogN54OY+ueWfNDDYZpVAPPHKzrN2bu8nInbcB9Ijv1T/uR2C+WEtdZCP+uwyXEKuVX12QABWfsQDQIsfrX5/0hMF2HOH7J+oMw/uPm+RfxD4/yeDMKX+3pEy47hx4ZXUSewzgLgjcvJvExxzZIDXvoXxVk3zmK723D8N5MFjvzbMLa015YOrhZwRzZzHf8Zj8r/kG3nHZp5tu9NH4ycLffOPAiI27KJ4Q1FlnzP+e5x4Q0WD6w5SVyk0oLZgbirX8AYnR/AElYJNkPhSlTSvLKuMSXVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.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=Sh1+17rFOL3vDQmi1Kk/4K/5RWZs63ouXslu4lsb9Bk=; b=r3OcoWUiVu4zAB880r/OQeDY47LbzERoegKQZKAt/TAngV5oA3UrgCEm7BSHEJAhCzhu9XXSjqTijWuJ9ltuf27gi5ElkKRg6fVv+mSnoPVeWW90LPe0MVoekqW89zXhw0IOhxTLWKZCwJWh5z0T2tmFuyvUWLLsmk3DaYYaFDE= Received: from DM5PR13CA0020.namprd13.prod.outlook.com (2603:10b6:3:23::30) by BN9PR12MB5289.namprd12.prod.outlook.com (2603:10b6:408:102::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Fri, 16 Jul 2021 07:43:28 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:3:23:cafe::b2) by DM5PR13CA0020.outlook.office365.com (2603:10b6:3:23::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.13 via Frontend Transport; Fri, 16 Jul 2021 07:43:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.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 DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 07:43:28 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 16 Jul 2021 02:43:27 -0500 Received: from wayne-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Fri, 16 Jul 2021 02:43:26 -0500 From: Wayne Lin To: , CC: , =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= , Wayne Lin , Subject: [PATCH 3/3] drm/dp_mst: Add missing drm parameters to recently added call to drm_dbg_kms() Date: Fri, 16 Jul 2021 15:42:01 +0800 Message-ID: <20210716074201.28291-4-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210716074201.28291-1-Wayne.Lin@amd.com> References: <20210716074201.28291-1-Wayne.Lin@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 491966ad-9bbf-4a99-e5bc-08d9482d66c4 X-MS-TrafficTypeDiagnostic: BN9PR12MB5289: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:127; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 42DO0NYCnxyRgPrhbJrha1vIj76j00m9/jAINXMQ/ydKrz5vsFcWMfhc1k9N5IhlzbDrqa5ycHEzIVtvB6B+CbYkdQo3DOAKV1UYnhy0u9CmjtAG48vxz91FwIa9OoI9trVdK1hJTFYFRw/fjZd8ZhqUDgrqfRtSPo+riTMfsxbhFXuG5jZZojoqKmY248J6k0K/X6Bg8tH0MjjwRhLv/ZlCPEgORSzIDq159jSdhdxVSnXfgME4vT/vajTVSDWRQ7P/ZmVvGXeNwjluQaNiXWd2ByOjxxzBerUgBdk3Alp1GKeFy50QTGjV2DkyGv995naI36GP3WCSByWD7SSlD6jZ0WEL7nL2+gjmcpK2yD4hVLMizZj1L8swsJ1H5trw+tKPTZkoYXNzvrSoOSuParWscFFZgG2JzOZbv8hFqqCzZwpdlT1F034Lw0SDd/YJDgHvjCKtBHwwmS3E2KbHKF0ueCJJKbyrRepmqw7hhRmTLcvwGJF3ecB3x8+xTRMAvrbbQ6veYKB8XGaHoM/GEaBrZ+/VN/hv5a+PbeM7w7b77f5RZu5zJLV/W34y0O0sNla9b9KjwTGhYpYEpsmjL36B2N8TPmvJ5o8wiJDsGbZznPOCthWZ9oRJHM7+68gWehILEinh7Ma0Qmij5HPNHV3VyT/h7Ny4X1fesu9135pXQ13IhbHJjo2SEdEQfxZFxMrPVyBm4cBOGIBELcyWQaJMf3k44QO51tAW8szWl/A= 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)(39860400002)(136003)(396003)(346002)(376002)(46966006)(36840700001)(426003)(8936002)(316002)(2616005)(4326008)(82310400003)(8676002)(2906002)(1076003)(70586007)(86362001)(36756003)(186003)(36860700001)(6666004)(70206006)(478600001)(26005)(7696005)(966005)(356005)(54906003)(82740400003)(83380400001)(5660300002)(336012)(110136005)(47076005)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 07:43:28.3514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 491966ad-9bbf-4a99-e5bc-08d9482d66c4 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: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5289 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: José Roberto de Souza Commit 3769e4c0af5b ("drm/dp_mst: Avoid to mess up payload table by ports in stale topology") added to calls to drm_dbg_kms() but it missed the first parameter, the drm device breaking the build. Fixes: 3769e4c0af5b ("drm/dp_mst: Avoid to mess up payload table by ports in stale topology") Cc: Wayne Lin Cc: Lyude Paul Cc: dri-devel@lists.freedesktop.org Cc: stable@vger.kernel.org Signed-off-by: José Roberto de Souza Reviewed-by: Lyude Paul Signed-off-by: Lyude Paul Link: https://patchwork.freedesktop.org/patch/msgid/20210616194415.36926-1-jose.souza@intel.com --- drivers/gpu/drm/drm_dp_mst_topology.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index bf6fa98b4ab7..a68dc25a19c6 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -3383,7 +3383,9 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr) mutex_unlock(&mgr->lock); if (skip) { - drm_dbg_kms("Virtual channel %d is not in current topology\n", i); + drm_dbg_kms(mgr->dev, + "Virtual channel %d is not in current topology\n", + i); continue; } /* Validated ports don't matter if we're releasing @@ -3398,7 +3400,8 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr) payload->start_slot = req_payload.start_slot; continue; } else { - drm_dbg_kms("Fail:set payload to invalid sink"); + drm_dbg_kms(mgr->dev, + "Fail:set payload to invalid sink"); mutex_unlock(&mgr->payload_lock); return -EINVAL; }