From nobody Mon Feb 9 04:59:03 2026 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012034.outbound.protection.outlook.com [40.107.200.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7699B318139 for ; Tue, 3 Feb 2026 10:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.200.34 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770114347; cv=fail; b=AT5xwyzPF4a6yN8irQQYnNE1tHCt5KnmpPg3HCtqPKnoUu6jRdrVmfBxOkVyI0G+ZDAAukQWpNMOI2W/nTEYPCyQjqkPiWUDUzxuYhskYqen0z5jW4eEW8mi9a+8/UHZQI2DkXdqqf4yQb8XTXLQ4oFlNw1chSir36Mcqvul01o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770114347; c=relaxed/simple; bh=ZgxqYi4XKqUhRVruPKwRiZVKMc0QA8D+w0kUDpzezUA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nf81lwVns1Ej8H2CAnTeJiHC3G+WpDDuRAmIHyos0f4PNqQWEZvrEKq0u1BgF16hdZouqa0jZF2nYBxEfz6KQv9wVwTSHkkKThjoxErlQAnXHyk4Uwv0czm96gcEipckdm2kXKcLA20w8B0D3aO1CnBD4HMeXEQeGdqVwJhbiX0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=vNQ6debL; arc=fail smtp.client-ip=40.107.200.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="vNQ6debL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LFoqKNhB6StP9+FUkT4TQrYSiooeDSIuqohnKrUo7e/uYl0Xk0pjd8kmRPbBasWpIDKNGeHDFCZmDXLa4AhEI4j1D+xPiaG4V4GLrVX55I+sADVFt45vdvspDoNSuLPzx/HPplxlwBkZbron8QCdPoFaWwd1BWgBs6Y22/Lc72ou6CZxz7BYh/ACU7tSnDPdtFFXZPczZSN3/qls4rc74y9Et17D7UqtALW6YEOr/UBWRPFYYxmXtLWOx7nQIumml/AKbUUkauYBvLQfkXXK4SnxSy5BstCnXQXzxITgfVzRUZmi9P3uANplJGBNGHJxVPND7XrlGFHZ4pnVH4f7cA== 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=VjbVLUNhXPpr2Oq9zndV8exMO0QthHxjyx7kaDC+tvs=; b=sbYrJ7MINMeH9JdUg5Kw0jRJrwmMVaq7d9Pjeb5VSL0rVEg3F/GCQIMgv1/2+MLHDEammzehG3OC/kPu58bjUi6MrwVGHgB8YYtqHGo8nBxZNaaQHGLY+/fuKkuoncTG3pkLCMwAMJgPTXaQW6Tgg32dQdXAIvcc9xlePS4kZfbUzZvO77KbC+SP/B3HLd90NoTssKrbm5pCoXe8VgCigSbg8Fzq8UQyW+I1bFTPxP4vuQTA1qfN8AOcPSCzJpfJceTjupbLq65u5sL34L8NLuMIGs2AwB4zq9OkHER1Tm8IbtCPsjSTWwuDQbGDNY9JdIfEaaGz0ljBLB2lFUCFUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com 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=VjbVLUNhXPpr2Oq9zndV8exMO0QthHxjyx7kaDC+tvs=; b=vNQ6debLetSS5FuR9BLf3QoF/TvtRu9uj+czkLodKBTjWG2z5ZqdKd8nT99DBJtup+79oh6l+xm4qresYZn4fzVEyuXmAeO59+2p3ULD10aLIPOrhysyM/pyIG6csucNn/1YbdvZM8wvBSJyK2pZihZ7mzIdjWVBB/mHZWBm4ys= Received: from BYAPR11CA0037.namprd11.prod.outlook.com (2603:10b6:a03:80::14) by DS0PR12MB8813.namprd12.prod.outlook.com (2603:10b6:8:14e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.15; Tue, 3 Feb 2026 10:25:41 +0000 Received: from CO1PEPF000075ED.namprd03.prod.outlook.com (2603:10b6:a03:80:cafe::b0) by BYAPR11CA0037.outlook.office365.com (2603:10b6:a03:80::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9564.16 via Frontend Transport; Tue, 3 Feb 2026 10:25:41 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000075ED.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9587.10 via Frontend Transport; Tue, 3 Feb 2026 10:25:41 +0000 Received: from FRAPPELLOUX01-WSLPUB.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.17; Tue, 3 Feb 2026 04:25:38 -0600 From: Pierre-Eric Pelloux-Prayer To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Simona Vetter , Felix Kuehling CC: Pierre-Eric Pelloux-Prayer , "Felix Kuehling" , , , Subject: [PATCH v4 02/12] drm/amdgpu: allocate move entities dynamically Date: Tue, 3 Feb 2026 11:22:09 +0100 Message-ID: <20260203102236.3456-3-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260203102236.3456-1-pierre-eric.pelloux-prayer@amd.com> References: <20260203102236.3456-1-pierre-eric.pelloux-prayer@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CO1PEPF000075ED:EE_|DS0PR12MB8813:EE_ X-MS-Office365-Filtering-Correlation-Id: ff6f0ec9-41b1-455b-849c-08de630e9505 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rHsbyInGb5tdMipnKCm/Q2Ddwy4ZrA532ehCB794YMp3NhMpYltMnzwGE3xx?= =?us-ascii?Q?9/3vBFtjyIKjU7yQkTBuPIOfOV+PO8lorvLAKP4YIREuBORXygVXdtom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/ZA6cu7YIq/DH0VvS+t9pzxCUjcR4SI4gm?= =?us-ascii?Q?NzYRnjXzxxA3o1iXjGn2ucP26apZXESLEWGEvwTk2qwjbKZjQn2d3DjW+yHr?= =?us-ascii?Q?hEKDt2knSQvmCpHsw7fYVtViDXNBnG2TLxLqW5lcYlxfuIYvVbKPMCDbmORF?= =?us-ascii?Q?O0+5BblEs/w0YJa4Yb7RBenuNATA8wIVBCKLkPz1R1MYzVtldDlBdlDqBHTF?= =?us-ascii?Q?gCyyoZnFnjfdlP7tzNzqwpRFdSgsv5T9zisFiGQPL+AGBKnxyEPUqeWfutdT?= =?us-ascii?Q?lL1KzExSMckGfRQtNc0dxQe3itDuX4SWFtnWP759W7UBrkCRPVPPMWBCE+/Z?= =?us-ascii?Q?qg9nlvNfeS7m2z/3zg8aLchOTtbpIxSOyWDQzHdOuf1JTRt6BXIYGJUbcIO6?= =?us-ascii?Q?jFNpko7Q8/l/ubU/xkcqMlCt1gUEwAP0xBpryy7zHJfFE2qh68cCod+MMolx?= =?us-ascii?Q?VjV/TMU39BJ4TTdanDtDkQVaJPisGm3+wLsoo4eHmt9wTUpcQPjOC5zzAYWI?= =?us-ascii?Q?OA77iJW//6EWH5iDsWykhVlSNlFG3X4knLUYm4XULfpbmXYtrPOYH/Kb/HBz?= =?us-ascii?Q?DDMfPEIby6kFBG3dnzBv0XgogAZyOG+FE41x3CW64bnfJBp8y3s3tnMA8FQr?= =?us-ascii?Q?lgAhAWZ7oLw3tnSnaYKVFwuc8uNyhI8+/n9ZrR7kDKLafsLOYZY4V6TDkm08?= =?us-ascii?Q?kmqbxQ=3D=3D?= 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)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BMenX1U9A1OFWONh2LMFIpv4dZ4Mzm7yL2pqrDNzfcAsaJ80q5strgNyD6O38YgqXqvwoRz5FbvsZntXmlahGbQ5YY0fi9vLsDLIvkVCjtigmXcAUN1HPj4lcVgbL1cnUJ+w/wplm9NfYYsEH2LuUQ6vRE7sqZVMaw9jvViXKiLtD3xC6dgOoDcIZwq400ROKpAXjaQHK0EVmppf0vuE/J9Byw1kKI5fo7gMs/WJlfHjRpNCfOOG+45N0q/W9eUIv29v+2UPEeCqy4EmQ4XhHpiyi/83y3u8yiX+q5Rxy2gUGyQDuFCGJxcCvvHTkuTRF17WvlnpPN8z8GfaGCPk/HU5d2G3oulYaN+KqVcQgQdvd7sDgTeEgouYpg2d1e/M2c4QQtAd42Ya3KICZxooUzNbLwyXvFdK8FAmC78qtEoCq+Dc5nCcwvDY1Ho7d7Pp X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2026 10:25:41.2697 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff6f0ec9-41b1-455b-849c-08de630e9505 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: CO1PEPF000075ED.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8813 Content-Type: text/plain; charset="utf-8" No functional change for now, as we always allocate a single entity. Acked-by: Felix Kuehling --- v4: stop using adev->sdma.num_instances --- Signed-off-by: Pierre-Eric Pelloux-Prayer Acked-by: Felix Kuehling --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 35 +++++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 2 +- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_ttm.c index 71316b3d4a29..75cb354084a0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -399,7 +399,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *b= o, dst.offset =3D 0; =20 r =3D amdgpu_ttm_copy_mem_to_mem(adev, - &adev->mman.move_entity, + &adev->mman.move_entities[0], &src, &dst, new_mem->size, amdgpu_bo_encrypted(abo), @@ -412,7 +412,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *b= o, (abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) { struct dma_fence *wipe_fence =3D NULL; =20 - r =3D amdgpu_fill_buffer(&adev->mman.move_entity, + r =3D amdgpu_fill_buffer(&adev->mman.move_entities[0], abo, 0, NULL, &wipe_fence, AMDGPU_KERNEL_JOB_ID_MOVE_BLIT); if (r) { @@ -2346,7 +2346,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool e= nable) { struct ttm_resource_manager *man =3D ttm_manager_type(&adev->mman.bdev, T= TM_PL_VRAM); - u32 num_clear_entities; + u32 num_clear_entities, num_move_entities; uint64_t size; int r, i, j; =20 @@ -2364,6 +2364,7 @@ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu= _device *adev, bool enable) } =20 num_clear_entities =3D 1; + num_move_entities =3D 1; ring =3D adev->mman.buffer_funcs_ring; sched =3D &ring->sched; r =3D amdgpu_ttm_buffer_entity_init(&adev->mman.gtt_mgr, @@ -2400,14 +2401,20 @@ void amdgpu_ttm_set_buffer_funcs_status(struct amdg= pu_device *adev, bool enable) } } =20 - r =3D amdgpu_ttm_buffer_entity_init(&adev->mman.gtt_mgr, - &adev->mman.move_entity, - DRM_SCHED_PRIORITY_NORMAL, - &sched, 1, 2); - if (r < 0) { - dev_err(adev->dev, - "Failed setting up TTM BO move entity (%d)\n", r); - goto error_free_clear_entities; + adev->mman.num_move_entities =3D num_move_entities; + for (i =3D 0; i < num_move_entities; i++) { + r =3D amdgpu_ttm_buffer_entity_init( + &adev->mman.gtt_mgr, + &adev->mman.move_entities[i], + DRM_SCHED_PRIORITY_NORMAL, &sched, 1, 2); + + if (r < 0) { + for (j =3D 0; j < i; j++) + amdgpu_ttm_buffer_entity_fini( + &adev->mman.gtt_mgr, &adev->mman.move_entities[j]); + adev->mman.num_move_entities =3D 0; + goto error_free_clear_entities; + } } } else { amdgpu_ttm_buffer_entity_fini(&adev->mman.gtt_mgr, @@ -2415,8 +2422,9 @@ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu= _device *adev, bool enable) for (i =3D 0; i < adev->mman.num_clear_entities; i++) amdgpu_ttm_buffer_entity_fini(&adev->mman.gtt_mgr, &adev->mman.clear_entities[i]); - amdgpu_ttm_buffer_entity_fini(&adev->mman.gtt_mgr, - &adev->mman.move_entity); + for (i =3D 0; i < adev->mman.num_move_entities; i++) + amdgpu_ttm_buffer_entity_fini(&adev->mman.gtt_mgr, + &adev->mman.move_entities[i]); /* Drop all the old fences since re-creating the scheduler entities * will allocate new contexts. */ @@ -2424,6 +2432,7 @@ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu= _device *adev, bool enable) kfree(adev->mman.clear_entities); adev->mman.clear_entities =3D NULL; adev->mman.num_clear_entities =3D 0; + adev->mman.num_move_entities =3D 0; } =20 /* this just adjusts TTM size idea, which sets lpfn to the correct value = */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/= amdgpu/amdgpu_ttm.h index e98d458b8029..cd24ca851b6d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -72,9 +72,10 @@ struct amdgpu_mman { =20 /* @default_entity: for workarounds, has no gart windows */ struct amdgpu_ttm_buffer_entity default_entity; - struct amdgpu_ttm_buffer_entity move_entity; struct amdgpu_ttm_buffer_entity *clear_entities; u32 num_clear_entities; + struct amdgpu_ttm_buffer_entity move_entities[TTM_NUM_MOVE_FENCES]; + u32 num_move_entities; =20 struct amdgpu_vram_mgr vram_mgr; struct amdgpu_gtt_mgr gtt_mgr; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd= /amdkfd/kfd_migrate.c index b3d304aab686..7b089d22c367 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -136,7 +136,7 @@ svm_migrate_copy_memory_gart(struct amdgpu_device *adev= , dma_addr_t *sys, u64 size; int r; =20 - entity =3D &adev->mman.move_entity; + entity =3D &adev->mman.move_entities[0]; =20 mutex_lock(&entity->lock); =20 --=20 2.43.0