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?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MW53M?= =?utf-8?q?SvIXcKnT8p/v5vNrQg8vts/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) {