From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77DC1606A322 for ; Fri, 4 Dec 2026 14:24:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=cZyfWoOa Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1676D112FBF; Fri, 4 Dec 2026 14:24:24 +0000 (UTC) Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012041.outbound.protection.outlook.com [40.107.200.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 46B78112FBF for ; Fri, 4 Dec 2026 14:24:18 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pJXL4WUXELDyUqnNvoMaRTWbY5/lAzRhtwuJgn1JioTrvED0mr7OYv0x43rAvL+iS6dAfuCam7sqcG34S3vGtCBajaxV9dYBiz7gORoR93MdCvgAlm0CPFavIGxWth2LPIU2H9gr5AA7GNKP3N3MpANnNjrFq8+72JB6MzgsHm32paPmCeTMPTCIH5zONR40HQG48gdoJ8piR+afmckEQ/bbh17+P9z8DQ/y1VN22k7T6ihKrLFFmsaq7eMJXMySk6pBEhgs11/8p3QNFDt9MfaAOYR01MflkPQW2pNnb+z7SJc5SYadqfUEhmralqgsVm0J2EILWVqK1oKLlnxd7w== 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=OKLypO/4W1HeE/GhzA5u+TvF45i2R/NFRLExp4KygmM=; b=Kwl/3qoG8BHmXiqzmXc8lVUQbttweRM8NXzXriezFnV+mknRZdLviyuPb22KYzNpt7iLzpicawauP8pPCr2mgshBRX+mKQXra3Rrn6Rt6TCcR5EM2aCT1rq1qp3AdE4d5GjECFWefvxNEJwiWWmTNrS563Dbz+vWTmIvmzUFTqzbMQaIKMIFRGg+eKAQH0ZwL9hYl6iXB1n5YBPLT09ha00pMyCMv2NbRpcY85ugr1pdYd+5umk/1Y8uCPCPjdyFj/jPCF7CtMGuOy8CrI7QRZsqu575rLRo9BDnbcHAwuvXzZ6m797towfTrlxP/1jb219V45SnNPX9SGZcF2LqTg== 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=OKLypO/4W1HeE/GhzA5u+TvF45i2R/NFRLExp4KygmM=; b=cZyfWoOaNL92Uu0TfEav8K20iAGlkOpdj5OY7DHbasxcfin260WRRzL8XvR3GO4932Q9eS1JN/EqMCdPPMd0oUhywjsLcNtp0NbCrIkST1RvqWFj0H1Ew4dO0Auxn3ng0ExnhXPs2DCf2PvLq/TnKXIykfNwhRtP5ms9+Dg42MA= Received: from BN9PR03CA0035.namprd03.prod.outlook.com (2603:10b6:408:fb::10) by SA0PR12MB7480.namprd12.prod.outlook.com (2603:10b6:806:24b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 14:24:14 +0000 Received: from BN6PEPF00000070.namprd03.prod.outlook.com (2603:10b6:408:fb:cafe::4b) by BN9PR03CA0035.outlook.office365.com (2603:10b6:408:fb::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.13 via Frontend Transport; Fri, 4 Dec 2026 14:24:13 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; 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=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by BN6PEPF00000070.mail.protection.outlook.com (10.167.248.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Fri, 4 Dec 2026 14:24:13 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 08:24:13 -0600 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 08:24:13 -0600 Received: from vbox-mint22-o.amd.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Fri, 4 Dec 2026 08:24:12 -0600 From: Frank Min To: CC: Frank Min , Hawking Zhang Subject: [PATCH 3/9] drm/amdgpu: update table info retrieval from discovery binary Date: Fri, 4 Dec 2026 22:24:02 +0800 Message-ID: <20261204142408.988734-3-Frank.Min@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261204142408.988734-1-Frank.Min@amd.com> References: <20261204142408.988734-1-Frank.Min@amd.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN6PEPF00000070:EE_|SA0PR12MB7480:EE_ X-MS-Office365-Filtering-Correlation-Id: 12ac89d9-53ae-4034-b96c-08df5212456a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|23010399003|1800799024|376014|82310400026|22082099003|18002099003|10067099003|56012099006|261021123027099003|261102123227099003|261021121427099003|261009223027099003|11063799006; X-Microsoft-Antispam-Message-Info: A0uo6H4ChQKj0TUZ5hGvpiJG4rsvDW+KhEATkN6xnEeXLU37AQZTy5L8MiWq0ejb5gH2iijB+4bObNXh8VQI9fl24aIZ/gfWVNVJ3Lj+tF97goz7i688Yv2s5pZOZY3HorLesUTA23xhwBgq4+tmQ2MRPa1c3NKuXMsKUZV4rwAcioYmGgu9AC+GXBPX/nFJsK4Ll7yQR5wWrbjh7eDbU8jrAzacveLP4zbVHIMnEl3KW57OzyEjAmk3WgbM4XmqszRLSvVbnC36Q/xi7yXUnA4GpFe3AkB1LBLq9iC0upozQgaUpiUJFyIaaEtnxzPwfJoAlfhAWHHYmshMgOJACm0lhSgcMOz2t1jFC+SLELuoSZams2gqZIfysBDC9to6uHGYB9bGBsb9EQNPoey5ad83tGEr4utBNK780Xt5kHrjg1k97qXvXgG6YeUFO3+MkZeigUc/EpMutefO05E+j4GtUcIUZFcIAYQAmXHb7IRmCxVru5lYc5ldsxRxDyty6oCTWTttkUnJumqImgFTxeT+gcH2BndziAkBccBbNksdJbjqN4v+5CxNJ1Kfphvk5XLhRtgaYJ4U4auMpioAge/FoxsZ4/zW2COBCQTd0Ce4eIh6ZFWoZGw98GijFqadubpC+dk8Urh1BJU2Bph1JiVjOUZHtovbo30TLYXea+wFTLb9eFj1CaqII5sWsypR6FeuPgD6SM7o8mxaAAh81w== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb08.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(23010399003)(1800799024)(376014)(82310400026)(22082099003)(18002099003)(10067099003)(56012099006)(261021123027099003)(261102123227099003)(261021121427099003)(261009223027099003)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7sZVc6xW6z7+5r+mt1pCXScfxcEUCqFIHy0L6QYte153FW1N8fEMmxDIt9BAVpZ+26V0ZDfgfGZhnK2K17wxRxcLQImY0n/hWC+0L0TYCGC0jtIDiVr81AeTB2DFsiWZnRL2PpbynCtrbQ+D08GBJjeDpV/VIW768ml1Z3JJQwjgb/cV3Z66L+gp9E3y0CoFw08v7Toxc7T2ZLmWS3SjzgCqEz0OP8VJtoXfXaZe9qen4d1NupJcdivQT6f+svS8Y3xpqkZXNMoJd3ozkUFDFrNivfn6bqhDIPSlVnKzPX8L259YEbrFoq+z9XLyJmoMBQcI+Hib/y+TNDIEnj4ArVDzs+hLNYRKXcSmbLDzXGKms7JVOZYdRx6P6hlndwZHxCDZkWH7KLjjblbZcl5MNXKw+i92nu4MWXzdbUW0op4Mvf+HNsuYl9FO0KAb+QlQ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 14:24:13.6972 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12ac89d9-53ae-4034-b96c-08df5212456a 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=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN6PEPF00000070.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7480 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "amd-gfx" X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Update table info retrieval from discovery binary to align with discovery table update. Signed-off-by: Frank Min Reviewed-By: Hawking Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c index 6fba2560a2abe..50b0112825c42 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c @@ -609,18 +609,36 @@ amdgpu_discovery_get_table_info_from_bin(uint8_t *discovery_bin, uint16_t table_id) { struct binary_header *bhdr = (struct binary_header *)discovery_bin; - struct binary_header_v2 *bhdrv2; - - switch (bhdr->version_major) { - case 2: - bhdrv2 = (struct binary_header_v2 *)discovery_bin; - return &bhdrv2->table_list[table_id]; - case 1: + struct binary_header_v2 *bhdrv2 = (struct binary_header_v2 *)discovery_bin; + uint16_t version = le16_to_cpu(bhdr->version_major); + uint16_t binary_size = le16_to_cpu(bhdr->binary_size); + struct table_info *table_list; + uint16_t num_tables, i; + size_t table_offset; + + switch (version) { case 0: - return &bhdr->table_list[table_id]; + case 1: + table_list = bhdr->table_list; + num_tables = ARRAY_SIZE(bhdr->table_list); + break; + case 2: + table_list = bhdrv2->table_list; + num_tables = le16_to_cpu(bhdrv2->num_tables); + break; default: return NULL; } + + table_offset = (uint8_t *)table_list - discovery_bin; + if (table_offset + num_tables * sizeof(*table_list) > binary_size) + return NULL; + + for (i = 0; i < num_tables; i++) + if (le16_to_cpu(table_list[i].table_id) == table_id) + return &table_list[i]; + + return NULL; } static int amdgpu_discovery_get_table_info(struct amdgpu_device *adev, @@ -633,8 +651,8 @@ static int amdgpu_discovery_get_table_info(struct amdgpu_device *adev, *info = amdgpu_discovery_get_table_info_from_bin(adev->discovery.bin, table_id); if (!*info) { - dev_err(adev->dev, "Invalid ip discovery table version %d\n", - bhdr->version_major); + dev_err(adev->dev, "Not found table for header version %d table id %d\n", + bhdr->version_major, table_id); return -EINVAL; } @@ -645,15 +663,16 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev, uint8_t *discovery_bin, uint16_t table_id) { - int r, act_val, exp_val, table_size; + int act_val, exp_val, table_size; uint16_t offset, checksum; struct table_info *info; bool check_table = true; char *table_name; - r = amdgpu_discovery_get_table_info(adev, &info, table_id); - if (r) - return r; + info = amdgpu_discovery_get_table_info_from_bin(discovery_bin, table_id); + if (!info) + return 0; + offset = le16_to_cpu(info->offset); checksum = le16_to_cpu(info->checksum); -- 2.43.0