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?TJpJoh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EalNw2D2yc66jW6GuulQbmm9sw7S2P1SSwJ0+iQWLtfiJZ8egXj?= =?utf-8?q?/aSL0l16Y24ApthdPKAtIEFyZJcbivzaKRD5Je83AtgN1InBsui5TY=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) {