From patchwork Mon Dec 23 04:07:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wayne Lin X-Patchwork-Id: 13918452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 52EA2E7718B for ; Mon, 23 Dec 2024 04:08:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B376E10E305; Mon, 23 Dec 2024 04:08:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="oxvfkor/"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2053.outbound.protection.outlook.com [40.107.237.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3D2A610E305 for ; Mon, 23 Dec 2024 04:07:59 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tblIvTSgbFQKqmokmRHNQJ5/IzQnUA1ove4XqMVxO/Tw3ybYG8eU1+CnF+kYGIBvM+iVIYt/hpsAd4FnyzPeHkY4QedG9hm4hwOwlmq1NxkJMs1lT74mYlnyZq2fMLJaeqmWrT/8JOqZW2TgZgRcEt/ze93p0Qw1mJrVfDx2Qwe5nmtG5if3C4EcWy1tJs4k/eimMlvSL59kSZxLs1mZNa5M+s6Lr9ngSWCIBfd6B3GgB/MBBQY7ffQHopu8b0Z+RX2ZQF2ZY4JpyhkZvK/At2e4jujoaBDUtIcxGB0v4eOhD2EfRtlAcD2XmELnOjh4ruUm0QuP4GKsuoj7jSVB+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/R23bSjhIq9Jih2KvGNQlTFNHaoe9PrWK5xqQb3FWKQ=; b=arfs/fGRbQYYjGulqjxHVAOj47y6Fnda7iSXJ6Z9vYEiLbjTgCAQoO+oETl/iVO3ek9EBJ0IKLo/kH44fA23lY+0wb8v49u/WpYseAbDn0bSGBAdNhKV7Pb9B958SBUPIco5xo7eM3N4t5tdTRjMWgnZ2IibrpAEho2z4vO0ji59+zYFB5D5Nz69oI+AT1ru2dCNf45cN+BJSQB2DmnZDndbYGiSJazFvm71nwktgj1g7zm/DTDoRvveTGCwB6H4djmmURE9qk5cgrgiLjJ78uHNARxxYvgC1VEflD6+e1+O7bc44JMWy3F+yGiz/aN1aRBXLnoXro7suo90KvyzKQ== 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 (0) 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=/R23bSjhIq9Jih2KvGNQlTFNHaoe9PrWK5xqQb3FWKQ=; b=oxvfkor/6jE4N+1GWHWFdR9KuvNElGhdnFsCPUC7IRKis0RyLIcNc8zFx7HieCuRmLr72Q1CQ/caCVhLqluqV8BY0UWewO7wQ1AKFKEfrv4y7SbtfQlULNJvKc/aropP/tuG+rfzsPjv1e8aNheu3dVArsOGZyHkum4X+869tis= Received: from DS7PR03CA0283.namprd03.prod.outlook.com (2603:10b6:5:3ad::18) by PH7PR12MB7987.namprd12.prod.outlook.com (2603:10b6:510:27c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.17; Mon, 23 Dec 2024 04:07:51 +0000 Received: from DS3PEPF0000C37E.namprd04.prod.outlook.com (2603:10b6:5:3ad:cafe::16) by DS7PR03CA0283.outlook.office365.com (2603:10b6:5:3ad::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.20 via Frontend Transport; Mon, 23 Dec 2024 04:07:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;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; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DS3PEPF0000C37E.mail.protection.outlook.com (10.167.23.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8293.12 via Frontend Transport; Mon, 23 Dec 2024 04:07:51 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.2507.39; Sun, 22 Dec 2024 22:07:34 -0600 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Sun, 22 Dec 2024 22:07:32 -0600 From: Wayne Lin To: CC: , , , , Wayne Lin Subject: [PATCH v2 1/2] drm/dp_mst: Fix drm RAD print Date: Mon, 23 Dec 2024 12:07:25 +0800 Message-ID: <20241223040726.3985676-2-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20241223040726.3985676-1-Wayne.Lin@amd.com> References: <20241223040726.3985676-1-Wayne.Lin@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: Wayne.Lin@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF0000C37E:EE_|PH7PR12MB7987:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f87ee9b-4e09-484a-670b-08dd23075ea4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?/Xbtx/lLfwrkMp161NGUGWSqOx5mihc?= =?utf-8?q?p3RoqtNzgvoCeMoLzmoGm+CNByNBiC5JEYwSHurBucQt+2bcq09rRen5PlcM1C7Ee?= =?utf-8?q?zzOT9GN3xoDb/rCBPXSFC6JFN/7SYGI6LA11WKFmXqq/C+pMJ+DOhX4zXSL8kcHrE?= =?utf-8?q?iZsnJitmBTkxjy2pSzBajLejTsvryrfYnXrGdpMBpdDeBMagZgZb6IUARXyfhH0BO?= =?utf-8?q?87Q5qnlvBLg1QJfR9Jxu60x9X8D6wEQmReAdad28OoM6081cHG/wLCIlRzy1WXb4H?= =?utf-8?q?Ohd0OeTILUwv+tTFjgjquKlRkqk2L4WTSVlukMPKBK3jhFjK0Yne/sJUVC40L2MjD?= =?utf-8?q?u8OY7MFG/ild/rE9bxAk79vd17XnznnFbxqSO2OT4YeCs6ZVri7W3WC3tZFUy6EhN?= =?utf-8?q?CXnIQHQiHm5hEHHtRborhYh4Mci1oNLryguW9YBIzgK2/RZUBmzjUVnQq34RSAtT4?= =?utf-8?q?Jb7vwqQ7HhNkHSMdipzzxxeiZXXOCwnYNbHOZHlu33F+IJxQ4a5Ep1qqMx3DF8DS5?= =?utf-8?q?X5NjwOdVpbgdNz/AzH6Ee47A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UD4S6nvUT8aOiHR3kqJjN23p5waLmJbg4s=3D?= 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:(13230040)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2024 04:07:51.4960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f87ee9b-4e09-484a-670b-08dd23075ea4 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: DS3PEPF0000C37E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7987 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" [Why] The RAD of sideband message printed today is incorrect. For RAD stored within MST branch - If MST branch LCT is 1, it's RAD array is untouched and remained as 0. - If MST branch LCT is larger than 1, use nibble to store the up facing port number in cascaded sequence as illustrated below: u8 RAD[0] = (LCT_2_UFP << 4) | LCT_3_UFP RAD[1] = (LCT_4_UFP << 4) | LCT_5_UFP ... In drm_dp_mst_rad_to_str(), it wrongly to use BIT_MASK(4) to fetch the port number of one nibble. [How] Adjust the code by: - RAD array items are valuable only for LCT >= 1. - Use 0xF as the mask to replace BIT_MASK(4) V2: - Document how RAD is constructed (Imre) Fixes: 2f015ec6eab6 ("drm/dp_mst: Add sideband down request tracing + selftests") Cc: Imre Deak Cc: Ville Syrjälä Cc: Harry Wentland Cc: Lyude Paul Signed-off-by: Wayne Lin --- drivers/gpu/drm/display/drm_dp_mst_topology.c | 8 ++++---- include/drm/display/drm_dp_mst_helper.h | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c index f8cd094efa3c..271a00b81264 100644 --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c @@ -175,13 +175,13 @@ static int drm_dp_mst_rad_to_str(const u8 rad[8], u8 lct, char *out, size_t len) { int i; - u8 unpacked_rad[16]; + u8 unpacked_rad[16] = {}; - for (i = 0; i < lct; i++) { + for (i = 1; i < lct; i++) { if (i % 2) - unpacked_rad[i] = rad[i / 2] >> 4; + unpacked_rad[i] = rad[(i - 1) / 2] >> 4; else - unpacked_rad[i] = rad[i / 2] & BIT_MASK(4); + unpacked_rad[i] = rad[(i - 1) / 2] & 0xF; } /* TODO: Eventually add something to printk so we can format the rad diff --git a/include/drm/display/drm_dp_mst_helper.h b/include/drm/display/drm_dp_mst_helper.h index a80ba457a858..fdf9b8647592 100644 --- a/include/drm/display/drm_dp_mst_helper.h +++ b/include/drm/display/drm_dp_mst_helper.h @@ -222,6 +222,13 @@ struct drm_dp_mst_branch { */ struct list_head destroy_next; + /** + * @rad: Relative Address of the MST branch. + * For drm_dp_mst_topology_mgr::mst_primary, it's rad[8] are all 0, + * unset and unused. For MST branches connected after mst_primary, + * in each element of rad[] the nibbles are ordered by the most + * signifcant 4 bits first and the least significant 4 bits second. + */ u8 rad[8]; u8 lct; int num_ports; From patchwork Mon Dec 23 04:07:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wayne Lin X-Patchwork-Id: 13918453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3DFC0E7718B for ; Mon, 23 Dec 2024 04:08:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B3C7910E307; Mon, 23 Dec 2024 04:08:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="KjGGKW+n"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8B5B310E307 for ; Mon, 23 Dec 2024 04:08:02 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r6CsqP8/yQnHBCowH/O/uALFicSLUpFhoq6P+Ts31an911dHzdgidzKkx3eg2F9J1tfsVCPTd8Ir/4pq9SYxmwrT17dRUt1SIly5ctFoVXzQff69y10zGToOQOdtXaX7fd7nq0ee0CgmCqxSw9oPHSXce9i5KIMhvv4vXhU+aUS1DyqzrwU7CusrTHXHsE2a7Tkx+07qm/0oTMtL35FWsU4fXX+Z+86JPPeeq2WzH4oP57VesfoKhPbgQIkZql/NJ4O/zNbUyLtSqxECR2svXGnOrhaJWkqY0fZXPqJm0yTDzop30iGM3pZyBoXHlhn6eGrPMjncyFg9idd8syVetA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UNo3dUdeYBS+4Tm7aeJBLT49XhrMlGTTyv5D2nQYUOc=; b=J3Wy0283VJocJrJtiRk6Aq4cVH/X5yjTd31z97/mtYuPiMZSrMobXXPQh5dNoXXhCLdissPW5CJDFpoV2myONChsJRVOUbaa+JhbabLah7z2Ulx4LWZkjlQotR7QLiot7vBUq5ygPBJyKSz0Z51IudaRW9UyblxzQGq7KdpyeNqbX51r8cq+UofDVlqfS7ro4ZjvdbQufknFp525ccr1dwjTvl9466njQ5y7dtGqxNL9IzgbiABWnnzcTe4SFKgJ308DLqHy6xDgYlewH82ujgn6Wcyb6RQe36Lrkj2+DQBsi7Px/YR/IwEqiI/kKgl0qtbVFJEJMBRD6Zis5PqHrw== 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 (0) 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=UNo3dUdeYBS+4Tm7aeJBLT49XhrMlGTTyv5D2nQYUOc=; b=KjGGKW+nsAb8ip4vIsDs39c1UTjoFAF/rflEA5OVRGkLXh7oRKk59rxF5EHrEv9SLVlXnr8L7U0j5cE8yJZJU+MCuTcBJ/tn+a7/hk0/Guv9gLlXqi1oPPuvqDAV/JZzMNiqWgnJ8vz9hbGW7r6rxzzfvE41m59vbdx5RaABMwk= Received: from BYAPR02CA0069.namprd02.prod.outlook.com (2603:10b6:a03:54::46) by SA1PR12MB6797.namprd12.prod.outlook.com (2603:10b6:806:259::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.20; Mon, 23 Dec 2024 04:07:56 +0000 Received: from SJ1PEPF00002318.namprd03.prod.outlook.com (2603:10b6:a03:54:cafe::ed) by BYAPR02CA0069.outlook.office365.com (2603:10b6:a03:54::46) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.17 via Frontend Transport; Mon, 23 Dec 2024 04:07:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00002318.mail.protection.outlook.com (10.167.242.228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8293.12 via Frontend Transport; Mon, 23 Dec 2024 04:07:55 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.2507.39; Sun, 22 Dec 2024 22:07:54 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 22 Dec 2024 22:07:53 -0600 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Sun, 22 Dec 2024 22:07:51 -0600 From: Wayne Lin To: CC: , , , , Wayne Lin Subject: [PATCH v2 2/2] drm/dp_mst: Add helper to get port number at specific LCT from RAD Date: Mon, 23 Dec 2024 12:07:26 +0800 Message-ID: <20241223040726.3985676-3-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20241223040726.3985676-1-Wayne.Lin@amd.com> References: <20241223040726.3985676-1-Wayne.Lin@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002318:EE_|SA1PR12MB6797:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f95948e-e290-4bb4-1d45-08dd23076127 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?zPv7ooplvCOm+aEMX+T5YrWQbhVPk4A?= =?utf-8?q?Ka9Mz5hriySWiYrh9JkNpAkneoZpS4FhCtzlA0Q3mphuBLltnaEVFktV2f4jm5dGy?= =?utf-8?q?pZV379EJ9ClaIix5yP2ErzO0Ni4AoFTjhmhVzyuLyApV63jKQ/3SENRbEMJomrMlE?= =?utf-8?q?nC6lnd/chV+XBT6ZLE3yVAQZvpgDU5bgwal4Uv4Wp1BmSt5jOS7VoMspErWeaqQEo?= =?utf-8?q?96C6JEkEpH3q7xPzDYHnEHbtcOAsQev5xQ8yBOEmxtrnPEbQarw/sSREPtnbyYwjz?= =?utf-8?q?NNWAXzp6Yrjma55ieT0GZCK/fsHNeXUFQ3C9N9YBHG0GEmhKf1ES+sDjm+VhmdC2h?= =?utf-8?q?SBco4f71ujPOLn3wIy8uf7U//QHDs3cyECA5XPuOr0njiNHpXKD/OlHhGxEVJS9Yq?= =?utf-8?q?GfsLAYuR8HuK1DMzc6C2vLQdmIkEjXcn3+lgkqdzQOSyIsTeW2cXFfrXW/USw5pBO?= =?utf-8?q?TJpJohAQKeXKLLVvcevZ9lTgMqBByEcEi5POzMi7ggooRrz6eVpT4oB9jR1AE6oBl?= =?utf-8?q?T55Czq1hDwlT3Id/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ZJcbivzaKRD5Je83AtgN1InBsui5TY=3D?= 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:(13230040)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2024 04:07:55.5675 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f95948e-e290-4bb4-1d45-08dd23076127 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: SJ1PEPF00002318.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6797 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a helper drm_dp_mst_get_ufp_num_at_lct_from_rad() to extract the up facing port number at specific link count from the RAD. Use the added helper in drm_dp_mst_rad_to_str() & drm_dp_get_mst_branch_device() to unify the implementation. Cc: Imre Deak Cc: Ville Syrjälä Cc: Harry Wentland Cc: Lyude Paul Signed-off-by: Wayne Lin --- drivers/gpu/drm/display/drm_dp_mst_topology.c | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c index 271a00b81264..dd11040af22c 100644 --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c @@ -171,18 +171,30 @@ static const char *drm_dp_mst_sideband_tx_state_str(int state) return sideband_reason_str[state]; } +static inline u8 +drm_dp_mst_get_ufp_num_at_lct_from_rad(u8 lct, u8 *rad) +{ + int idx = (lct / 2) - 1; + int shift = (lct % 2) ? 0 : 4; + u8 ufp_num; + + /* mst_primary, it's rad is unset*/ + if (lct == 1) + return 0; + + ufp_num = (rad[idx] >> shift) & 0xf; + + return ufp_num; +} + static int drm_dp_mst_rad_to_str(const u8 rad[8], u8 lct, char *out, size_t len) { int i; u8 unpacked_rad[16] = {}; - for (i = 1; i < lct; i++) { - if (i % 2) - unpacked_rad[i] = rad[(i - 1) / 2] >> 4; - else - unpacked_rad[i] = rad[(i - 1) / 2] & 0xF; - } + for (i = 0; i < lct; i++) + unpacked_rad[i] = drm_dp_mst_get_ufp_num_at_lct_from_rad(i + 1, rad); /* TODO: Eventually add something to printk so we can format the rad * like this: 1.2.3 @@ -2544,9 +2556,9 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_ if (!mstb) goto out; - for (i = 0; i < lct - 1; i++) { - int shift = (i % 2) ? 0 : 4; - int port_num = (rad[i / 2] >> shift) & 0xf; + for (i = 1; i < lct; i++) { + int port_num = + drm_dp_mst_get_ufp_num_at_lct_from_rad(i + 1, rad); list_for_each_entry(port, &mstb->ports, next) { if (port->port_num == port_num) {