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 B5F6A606A329 for ; Tue, 1 Dec 2026 19:03:37 +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=i349C4Nq Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D85C10FC01; Tue, 1 Dec 2026 19:03:32 +0000 (UTC) Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012027.outbound.protection.outlook.com [40.107.200.27]) by gabe.freedesktop.org (Postfix) with ESMTPS id C35B110FC12 for ; Tue, 1 Dec 2026 19:03:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xZhJ7wpLtSWvcniCS5pfhV4AJEkHb59TZ5pwYAVhlgDToMkyDKB9f+/Hty/UyVaPG3bU9tBh6CTXdxj20d9O6EoFAkXXV2oZqu/kPLxS9aXA8AAcvbCDxGq+N2Et5IHdN5b1JEcFkPb82UZph3DOBYNca7wi9Iy7n8x85i1b/4mwYYlEMdoYLCh6ANcXMV5Qt531oVYfIF/+3w6yUHflWq+NSF2SuDwYYKHJ4Tp9FDr/HBIyWyPtnzDIAllw9DbkPftMgOfrFdk0qGeGWSxD+FQX82q8ewd0WtD/Wo6dqlkucZyXGxoyBx8tWIYQVFa6rKgCpquQtz5KIr7mF8mPoQ== 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=hMarxPXpMA8HjeeDt7UAFDSaUyif8n3TnwBmZCi4r+0=; b=XVzlrPmCgybTPmNHT+/WsrbkZ+YFfbcjnKkJG+8aMfTvwOyd/LcMs7ctPsW+FXsEAkUTiOqAsiE36fAnchY0NWP3I7b4uDtZGWi3OVKuryaCv032OJ3Wfi3Km6RJjnJJ8tTfG7b727sjZB6DgBf8raieeW+r9S0bYL7ybB6eSFDq25HI2WSOrK+BZBAuuVT37xN0NxkgM5bB0PBl3vMQNWFbYQWBI46Bag2ImBhhxmvaaeCUp8SW8Df7ZvB3CW9U3vrHm/LkMMecJ/BzvIHcVA+z/jzWpJLno79I/PrtBw/GwZGWlFx65V9tX4grxm6sCoCaPIN04WCN+7AKZQR9yg== 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=hMarxPXpMA8HjeeDt7UAFDSaUyif8n3TnwBmZCi4r+0=; b=i349C4NqiLaNRGsnHJVFrpq3bqbVlGlU5OyZi42fiy/ZuJ5c/+z5lpAUEgl+wZcNjyRrjihFUBPO2Aptebyiw05VlisXflUNNbxrYwiqNtt4rHVAC6GuFKuAu5/Bc7lky9hdhb+tUas09o4Z1qr3sm85C/XClC+XLsrOulO1aGY= Received: from DS7P220CA0078.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:259::12) by SN7PR12MB6911.namprd12.prod.outlook.com (2603:10b6:806:261::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Tue, 1 Dec 2026 19:03:17 +0000 Received: from DM3PEPF000265B2.namprd02.prod.outlook.com (2603:10b6:8:259:cafe::16) by DS7P220CA0078.outlook.office365.com (2603:10b6:8:259::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Tue, 1 Dec 2026 19:03:16 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DM3PEPF000265B2.mail.protection.outlook.com (10.167.23.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.3 via Frontend Transport; Tue, 1 Dec 2026 19:03:16 +0000 Received: from georzhanmkm.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 13:03:13 -0600 From: George Zhang To: CC: Harry Wentland , Leo Li , Aurabindo Pillai , Roman Li , Wayne Lin , Tom Chung , "Fangzhi Zuo" , Dan Wheeler , Ray Wu , Ivan Lipski , Alex Hung , James Lin , Chenyu Chen , Ray Wu , George Zhang Subject: [PATCH 06/30] drm/amd/display: test the DMUB AUX write status reply copy Date: Tue, 1 Dec 2026 13:57:42 -0500 Message-ID: <20261201190245.360906-7-george.zhang@amd.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201190245.360906-1-george.zhang@amd.com> References: <20261201190245.360906-1-george.zhang@amd.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PEPF000265B2:EE_|SN7PR12MB6911:EE_ X-MS-Office365-Filtering-Correlation-Id: fba31cd2-a78a-4a04-3ed7-08df4fddc1ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|1800799024|376014|23010399003|82310400026|10067099003|56012099006|261026121527099003|261021121427099003|261102123227099003|261009223027099003|22082099003|18002099003|11063799006|3023799007; X-Microsoft-Antispam-Message-Info: zBeX9catNjiBA7GEh9sd+KAoKlbc+YxYEQ76B58Uca/AqnTmsHf/ETGEsfmyKmM2XNi7ZhlKa7oZ3BBTF1pTAX8h8y9XxdAYshXHPiezbx0MAd9tjE9fOtWnqFeZ1hJ8R/1fkYuzDWJZor85jFyf7pJVSTsnxxaGupE3Id2Up3lKoy3FqG1hM7NEZxyEaM63dOCFjG4V2YMZO14PtzPD6TaxJ7Q2tY5XNoms76t0VLjgA/5GfrQflWbJ0GUbgeZY6dEtsUT8DXLUyRu1AiHOsS4PzJWVZblbC8pO3o2Ir8/WTJlpGH1j9Aa1zfJUUBfvv1Lw5rS80nmMYAGU/9y3vPexeMSD3+KJYPYMoKql91zOQ+bPlHxJAiSIN9tJeiCRXfNC2ox0lFbYEldS2V85YA9hZ7gwh0bi3Bh4k30SfF3iHuAtdu0A7gntidvf+XfEJu2NwoDXl3s0XzXQ6/HO9IncE8xlA/8LJE7TC5/mMW5/8zWfgKUXfo/sWphO9AqEA5jofYa49bT2FaSfOnDd+q35KJj9PEoV4UmiTIqTM9x9/qgG3vxoS75QMjHE8wrtQd8nODXKl/rXI4nuoPae0w+iL3xN6Z5bAKUnyBL64JpaQzvaGo6gjY3i2g3umyHg8sGElG3CTYo5Eo0Sol3FuHQPixIR88RVder0pMx/e7zkXPiQZmIIomR1u5Bjgy+6ABcpfkqi/yj9P3w0b0elJA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(1800799024)(376014)(23010399003)(82310400026)(10067099003)(56012099006)(261026121527099003)(261021121427099003)(261102123227099003)(261009223027099003)(22082099003)(18002099003)(11063799006)(3023799007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3oJKdXLXwxnWvjopbtxQefOeLu69ae04d6Tknx65e7a6aUk4/XnU31oDngI43puw+5Rmzk8t5dvRjvOG/3lnhqv7XrhXZewhsweETt5/ZEgZbaEWTE8T9ywMuq40LFtN6U1VjoAVfO+Y2kGDpAkPJKff37I8A1gHO3D/lsb3aiJj2Gl75RfB+4ledYp6pbubPozPFj5dOpvWPGFyAQopFz04rAYZF7ShC0Jh3ez7zF5OkI5fRvjEx+qG5745YOPRk23c5sqb39r1TOHrSkn0DB9rLYwbjmvB4TE4eP7/9xywZ170WwZFjdYzsaak5lbi0Zb44Eyx50BuztuWpUTBq23wUFpPPXabuBMWZqaGuqb1zZFu6ktvWnMS7f+8Fk2/oxWjEO8Ui5fWVjE638rlH9twd49xDbUZhCdnfkz/gvuhD86fphMgTqLdO8FV5Dab X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 19:03:16.9057 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fba31cd2-a78a-4a04-3ed7-08df4fddc1ed 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM3PEPF000265B2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6911 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=-18.8 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 From: Tom Chung [why] No test covered the write status retry path fixed in the previous commit, where a 16 byte reply overwrote the caller's buffer. [how] Add a KUnit case that answers a write status retry with a 16 byte reply and checks that the call returns 1 and copies only the status byte. Cc: Ray Wu Signed-off-by: Tom Chung Signed-off-by: George Zhang --- .../amdgpu_dm/tests/amdgpu_dm_dmub_test.c | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c index 9c0171b86c67..b2b4bb6df0a0 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c @@ -1335,6 +1335,86 @@ static void dm_test_process_dmub_aux_transfer_sync_copies_data(struct kunit *tes KUNIT_EXPECT_EQ(test, data[2], 0x33); } +/** + * dm_test_process_dmub_aux_transfer_sync_write_status - Test AUX write status reply + * @test: The KUnit test context + * + * A write-status-update retry still points payload->data at the caller's write + * buffer, with payload->length zeroed. Only the partial-write status byte may + * be copied there, however long a reply the sink sends. + */ +static void dm_test_process_dmub_aux_transfer_sync_write_status(struct kunit *test) +{ + struct amdgpu_device *adev; + struct dc_context *ctx; + struct dc_context *dc_ctx; + struct dc *dc; + struct dc_link *link; + struct ddc_service *ddc; + struct aux_payload *payload; + struct dmub_notification *notify; + enum aux_return_code_type result = AUX_RET_ERROR_UNKNOWN; + u8 data[16] = { 0 }; + u8 reply = 0; + int ret; + int i; + + adev = kunit_kzalloc(test, sizeof(*adev), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, adev); + + ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, ctx); + + dc_ctx = kunit_kzalloc(test, sizeof(*dc_ctx), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, dc_ctx); + + dc = kunit_kzalloc(test, sizeof(*dc), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, dc); + + link = kunit_kzalloc(test, sizeof(*link), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, link); + + ddc = kunit_kzalloc(test, sizeof(*ddc), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, ddc); + + payload = kunit_kzalloc(test, sizeof(*payload), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, payload); + + notify = kunit_kzalloc(test, sizeof(*notify), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, notify); + + link->ddc = ddc; + dc->ctx = dc_ctx; + dc->link_count = 1; + dc->links[0] = link; + dc_ctx->dc = dc; + dc_ctx->driver_context = adev; + dc_ctx->dmub_srv = NULL; + ctx->dc = dc; + ctx->driver_context = adev; + spin_lock_init(&adev->dm.dmub_lock); + adev->dm.dmub_notify = notify; + mutex_init(&adev->dm.dpia_aux_lock); + init_completion(&adev->dm.dmub_aux_transfer_done); + complete(&adev->dm.dmub_aux_transfer_done); + payload->data = data; + payload->reply = &reply; + payload->length = 0; + payload->i2c_over_aux = true; + payload->write_status_update = true; + notify->result = AUX_RET_SUCCESS; + notify->aux_reply.length = sizeof(notify->aux_reply.data); + memset(notify->aux_reply.data, 0x5A, sizeof(notify->aux_reply.data)); + + ret = amdgpu_dm_process_dmub_aux_transfer_sync(ctx, 0, payload, &result); + + KUNIT_EXPECT_EQ(test, ret, 1); + KUNIT_EXPECT_EQ(test, result, AUX_RET_SUCCESS); + KUNIT_EXPECT_EQ(test, data[0], 0x5A); + for (i = 1; i < ARRAY_SIZE(data); i++) + KUNIT_EXPECT_EQ(test, data[i], 0); +} + /** * dm_test_process_dmub_aux_transfer_sync_zero_length - Test AUX reply with no data * @test: The KUnit test context @@ -2253,6 +2333,7 @@ static struct kunit_case amdgpu_dm_dmub_tests[] = { KUNIT_CASE(dm_test_process_dmub_aux_transfer_sync_engine_acquire), KUNIT_CASE(dm_test_process_dmub_aux_transfer_sync_protocol_error), KUNIT_CASE(dm_test_process_dmub_aux_transfer_sync_copies_data), + KUNIT_CASE(dm_test_process_dmub_aux_transfer_sync_write_status), KUNIT_CASE(dm_test_process_dmub_aux_transfer_sync_zero_length), KUNIT_CASE_SLOW(dm_test_process_dmub_aux_transfer_sync_timeout), /* amdgpu_dm_process_dmub_set_config_sync() */ -- 2.56.1