From patchwork Fri Jan 10 02:36:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Lin, Wayne" X-Patchwork-Id: 13933461 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 75A5FE7719C for ; Fri, 10 Jan 2025 02:37:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3B7810EF78; Fri, 10 Jan 2025 02:37:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="iRi57Go2"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2056.outbound.protection.outlook.com [40.107.94.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 256E310EF78 for ; Fri, 10 Jan 2025 02:37:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Co67eNniETeXTrSyixPBG4mF+urpWCJ2ZBCIXaQNr0aN0S6469nck+qLWC/NQ1j9dnUqATx0fMFjnOMWrqNPCPMDQR9UtzZWECupuZPPERiC7nzkCkGwR6XZ7Eywc4Ci2vQsTkzPaNFYRPfkgcMYwGFYTm0mrBr86Cw0cmHlN+I79nz2FUPOQuFhWet4sdWq73+dAwYXXYfb84mAuQQYOBQ/tiaxkysrm/zLCZAhDSsXrRi/O677yMhx4SKnW3j/UGC2B8y8Z5dOIiMzth3hhheUgllQOXjryF5as/a0VXZvXb1Pj9/mgnAZOV1LLeIHS4js+EmRBJ6gmcJaRVRPPw== 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=CNBEuaAbmmu8Wrsdan6/ytwonMXA/06Ny5iPc0d3XQE=; b=trkngFWUclJFzzXUDE0X5uPGl/lPjBkUxjm8BdUGyeYl58l+pBMwPPxUyH9RvVD2yoDGq+HtOaN0BEJkCpYUM7K4x+z6rPZQIOeB8TsSStMMa1eAma4StUqFuBk2cehDCrHriIjmuMwgdyJEgWXOvf7Z2q5KqxaRA4aeB/NgJXQ9b2Ae5qhekqh0y1nFEAn1d940QoO2bLTM/plBf4n9OeipEF8UmJYReQ4T15o2IBdpxgboMaNzZMAZTJzNVvEZjAWSZYVGNMjtm/73zBX3S2OZeiJxCf+Ae5hzEms8jWXkgbM7zdo2HOiQu/CF3pNRXpjI/ECMPtE0WZaVFhXKdQ== 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=CNBEuaAbmmu8Wrsdan6/ytwonMXA/06Ny5iPc0d3XQE=; b=iRi57Go22vdbRMlVhlb6NXlbu2SM6tD8Y2ZLmTyRrC0OKUh5yMQHXEBTGG2rZjqBPSTtMPgsrer4Z8+B5Yw9NhF5fsK/sbwYJkGQR/Fq6h7Xic7EsNSvIsLWOVp4gcqnD7bvpKaMFVWqbq4DSOzhc5XJuZdq9Sbhx1gjDHZ8bCw= Received: from DS7PR03CA0320.namprd03.prod.outlook.com (2603:10b6:8:2b::15) by IA0PR12MB8255.namprd12.prod.outlook.com (2603:10b6:208:404::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.12; Fri, 10 Jan 2025 02:36:57 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:8:2b:cafe::34) by DS7PR03CA0320.outlook.office365.com (2603:10b6:8:2b::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.12 via Frontend Transport; Fri, 10 Jan 2025 02:36:57 +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 DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Fri, 10 Jan 2025 02:36:56 +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; Thu, 9 Jan 2025 20:36:56 -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; Thu, 9 Jan 2025 20:36:53 -0600 From: Wayne Lin To: CC: , , , , Wayne Lin , "Harry Wentland" Subject: [Patch v3 1/2] drm/dp_mst: Fix drm RAD print Date: Fri, 10 Jan 2025 10:36:17 +0800 Message-ID: <20250110023618.66401-2-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20250110023618.66401-1-Wayne.Lin@amd.com> References: <20250110023618.66401-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: DS1PEPF00017093:EE_|IA0PR12MB8255:EE_ X-MS-Office365-Filtering-Correlation-Id: 35a50b19-b853-4b7f-4950-08dd311fa6e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?WPHk1Oty1Ox0QfSqyHW7MhVyawF5F5P?= =?utf-8?q?+4QRAYkeTlF4Iksb3Ca2f5PCF7BbWZmfyE7gPEsHXmHK7OvXCrYv+0FJc+oROofK/?= =?utf-8?q?LU6xOnUEK8FC67gLnW8/MJBxKNddMO9VTZN49toryUMxFQORIrqhKZhwOHzzojSdS?= =?utf-8?q?y7juKv6y4QGPGl6Pxs/mmeSVqRp9cZ6SM1Irz1nd6fILdKNTp7YZHlwuDtiA4O4dY?= =?utf-8?q?GnAj3HXl9J5kYxB0VPneT2+71qATxEB6MfK5UzmkUS7lDKjIDulWfPFTPp52TRLvR?= =?utf-8?q?A4C7DbGnoqseQD5su8TTx1PUvx33X8gO9mGfFfbxghrZTlQu7t5Xe66nV9Jx7x7oD?= =?utf-8?q?y3VvFFVsJLPqRzETdgLE82Dv4M9OqMaxltz7g4S7pQ70CZp0E71SMF9D8IUe085Xu?= =?utf-8?q?XEtweEs1AlZ9n8y/fgv5Av4KMLpv5UMT+4VjyxaYN3H6AMa0ZGVj0/+vrIlHxWCE1?= =?utf-8?q?P1k4F736dLfL7MOBBJe1AIcT5DpMKt9y4AEQGjOzXe4+lewrA3CWscEMp5fRGWekT?= =?utf-8?q?M7M3byxr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iU8JnfVCcgYs5jDzYYEvl9SuJTOwBDaEqPlo=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)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 02:36:56.9151 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35a50b19-b853-4b7f-4950-08dd311fa6e7 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8255 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) V3: - Adjust the comment for rad[] so kdoc formats it properly (Lyude) Fixes: 2f015ec6eab6 ("drm/dp_mst: Add sideband down request tracing + selftests") Cc: Imre Deak Cc: Ville Syrjälä Cc: Harry Wentland Cc: Lyude Paul Reviewed-by: 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..6398a6b50bd1 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 Fri Jan 10 02:36:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Lin, Wayne" X-Patchwork-Id: 13933460 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 06EF9E7719C for ; Fri, 10 Jan 2025 02:37:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 85AE210EF7E; Fri, 10 Jan 2025 02:37:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Gqw/Swlh"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062c.outbound.protection.outlook.com [IPv6:2a01:111:f403:200a::62c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1DABA10EF78 for ; Fri, 10 Jan 2025 02:37:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Dbfj8lZ57lfd/0wPVDeob0fH7z1uCh8XOGMuHxgo3a43k/jtdx6096T2oTQd5sw0tPmb4uxaWe3jJeFKMu9YMgFBXXpluEjCKGsaxWm8TwyQNMTumG3vd160dIoZOfEcPRM0GNEJ9EdhjuDnzBrAqAprIM7BsvqriHPVnGQOK3bUmLJT281hKvooD7M1ba1METL6BNVGvrS5Wi3agudrxFNCSAJDjfFI+u2ih1eFPlZUdtfkf13RKMSWysqGFFgZVrBFd9oIABjFQljZePLzF0sc49XCGVxRBAyb4mJKECCKpjhkyNLPmMH/Nqk8K8+2HM63tlx8/qAQK2j+ZnF5jg== 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=97H6PzSnR86yqWSMiaeVW6M4BKmzR39NMex1olEyNdA=; b=QGfzkXcKVlKsT4wpacrCw/E29J7fl0QeObFs/tXLCnfMBcvT9mWIeYJxuGwEYFSpfvtcre/ghmH1souvguujTb2tfhOTK17y8i6zq0lO2eyFnR8Lho/wNGJSjWmiygDkxiRsYm2L/K1y/CtEfXKP+mo5C1Pi137i8/90QIpUU9Zyw6bAwxnbpGaZ86dY2zdIONNFd/g3Nze/412mVFf2vkQodMR4QG43pQXnIwHE9ApUxP28/DP0bm2sZ58EcVEmmykJHlrAyzkh4fHhjkfPDDf9sEE/vIYpeX93d9Y1Kad07qAz5oxTPK06/lEJPbcsdyEQ2hN0uxJgNr6XBf9a8g== 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=97H6PzSnR86yqWSMiaeVW6M4BKmzR39NMex1olEyNdA=; b=Gqw/SwlhQhT8XMesPnbVMNm7S8MA3YxBBMKvIKZDTXpbrpgfYeu7O+9tt4gvVDgrZTOMurEgMHFDXJXynmmH/kUmJLTd6AGtcRykWYc02S0NFGOKLhQzT2b07e+a/eOyGNSvR3Wh6tlFK3nDlr8O/6172X7BfFpEjRSjkm01mM4= Received: from DM6PR11CA0022.namprd11.prod.outlook.com (2603:10b6:5:190::35) by SN7PR12MB7835.namprd12.prod.outlook.com (2603:10b6:806:328::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.16; Fri, 10 Jan 2025 02:37:00 +0000 Received: from DS1PEPF00017091.namprd03.prod.outlook.com (2603:10b6:5:190:cafe::26) by DM6PR11CA0022.outlook.office365.com (2603:10b6:5:190::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.11 via Frontend Transport; Fri, 10 Jan 2025 02:37:00 +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 DS1PEPF00017091.mail.protection.outlook.com (10.167.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Fri, 10 Jan 2025 02:37:00 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Thu, 9 Jan 2025 20:36:59 -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; Thu, 9 Jan 2025 20:36:59 -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; Thu, 9 Jan 2025 20:36:56 -0600 From: Wayne Lin To: CC: , , , , Wayne Lin , "Harry Wentland" Subject: [Patch v3 2/2] drm/dp_mst: Add helper to get port number at specific LCT from RAD Date: Fri, 10 Jan 2025 10:36:18 +0800 Message-ID: <20250110023618.66401-3-Wayne.Lin@amd.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20250110023618.66401-1-Wayne.Lin@amd.com> References: <20250110023618.66401-1-Wayne.Lin@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017091:EE_|SN7PR12MB7835:EE_ X-MS-Office365-Filtering-Correlation-Id: 0083a16a-86e4-45d4-9541-08dd311fa8f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Hrp3YTw+jNgh4mUiaofWeom9+/aA6y4?= =?utf-8?q?w7Jdbd+mKK2cSKPcr6iGccQlLvnj1ELKUea52psVZ/YnVecMx+4FQ9DjdcEuBCFlw?= =?utf-8?q?cF+Gy9MK1SJnbjK2XvBi28rp+AmXJSi1w45MPhSvHjK4W03sOLmnUVWpTfejowAca?= =?utf-8?q?fbEyUMy4chxKcTcdpT5tlqMnzTygvYWcKFX/8WcRUo6EIps3jy7zKcpLFb+Xl9UaQ?= =?utf-8?q?uSErtk0Df8qQ3pAMUffs+z9cNk7cIoayZdUAc1CjwJdeCl5sYT+9roXuTWX89mid0?= =?utf-8?q?HRzB49eoB3o8Yv+L5b5y13iCTYGymMicB4i/2fIXTpA7YXnevqyohbhYCDqj7lVdX?= =?utf-8?q?JfDTMs+llqRppKN1LbMQFS6Mjld+xXYt3YXyz2AujQuLRIYSeYKVD+SBIEwyb4VFh?= =?utf-8?q?XZSawBwNv6L+JhKwCkS6Kee5Le5yzZsDuLQLq55DtADfw9nopOkvrCkg2yRogKf4x?= =?utf-8?q?4EdW7kSeyIyaIobCpGo3xmZT4Mrzuef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Qg8vts/CW3KdskSg38ah2dvxYhKFKEareHQ+ckprRrWatGZ33?= =?utf-8?q?cBSJYCuzw5i+rvnpwTCioaen554ikRkdg9t1HI/zcVwpBNo8D1sX1Q=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)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 02:37:00.3667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0083a16a-86e4-45d4-9541-08dd311fa8f3 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: DS1PEPF00017091.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7835 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. V2: - Adjust the code format (Lyude) Cc: Imre Deak Cc: Ville Syrjälä Cc: Harry Wentland Cc: Lyude Paul Reviewed-by: Lyude Paul Signed-off-by: Wayne Lin --- drivers/gpu/drm/display/drm_dp_mst_topology.c | 29 +++++++++++++------ 1 file changed, 20 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..0b9bb3a426a4 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,8 @@ 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) {