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 5A1EEC61CE7 for ; Thu, 5 Jun 2025 15:30:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10C6A10E92F; Thu, 5 Jun 2025 15:30:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="EWmZ54CJ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id A2DA010E8A8 for ; Thu, 5 Jun 2025 15:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749137454; x=1780673454; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wDra8mzL2FPV4YzlWJkZmDbNkEkwuU5WVXIhrVT6sEg=; b=EWmZ54CJm72D3Mz3zWlO1DB90l4SsXXdzi6O1rigYlzekIf0c7XrMBJW G0va6FQtNlISEvbGoG6Miwz6GsJq2UYBxIHc4/Bo279B9EpkcEEjGgXHP O/xlfI3T/tL+LkrSD8PfJTjDQ8OAJL4QlJ8lufpQcz0M9h0BE+ZHsFQdR 13bVCNKMD5EFb4BSQwKY10vRUzdcc6wObty+gILY1ko91CeYn1okiiR0h z7+TH/k44eAyKZp8VBEoLF28KDMyIU0AxiL9zuDP7xe8VeHE2jN4Q6dUz GqTjMr8iMgFF9OOUCEwuR8yxT2iy08VeTldwkzMiH8MHVEYj5QysD1gHz w==; X-CSE-ConnectionGUID: 2XWaLATBSb6Lcc9Iwrl7qg== X-CSE-MsgGUID: wEGCUw8ERkmT0PguerJeaw== X-IronPort-AV: E=McAfee;i="6800,10657,11455"; a="61529484" X-IronPort-AV: E=Sophos;i="6.16,212,1744095600"; d="scan'208";a="61529484" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2025 08:30:51 -0700 X-CSE-ConnectionGUID: J6bbjB6YTKmtq53N8TIQNQ== X-CSE-MsgGUID: zvqiRxkqS2S5yi4hCKj4Rw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,212,1744095600"; d="scan'208";a="176502795" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2025 08:30:52 -0700 From: Matthew Brost To: intel-xe@lists.freedesktop.org Cc: francois.dugast@intel.com, thomas.hellstrom@linux.intel.com, himal.prasad.ghimiray@intel.com Subject: [PATCH 02/15] drm/xe: Add __xe_migrate_update_pgtables_cpu helper Date: Thu, 5 Jun 2025 08:32:10 -0700 Message-Id: <20250605153223.2789122-3-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250605153223.2789122-1-matthew.brost@intel.com> References: <20250605153223.2789122-1-matthew.brost@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" This will help implement CPU binds as the submision backend can call this helper when a bind jobs dependencies are resolved. Also add some asserts to the helper while here. Signed-off-by: Matthew Brost --- drivers/gpu/drm/xe/xe_migrate.c | 58 ++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c index d8b50305df87..9084f5cbc02d 100644 --- a/drivers/gpu/drm/xe/xe_migrate.c +++ b/drivers/gpu/drm/xe/xe_migrate.c @@ -1258,6 +1258,38 @@ struct migrate_test_params { container_of(_priv, struct migrate_test_params, base) #endif +static void +__xe_migrate_update_pgtables_cpu(struct xe_vm *vm, struct xe_tile *tile, + const struct xe_migrate_pt_update_ops *ops, + struct xe_vm_pgtable_update_op *pt_op, + int num_ops) +{ + u32 j, i; + + for (j = 0; j < num_ops; ++j, ++pt_op) { + for (i = 0; i < pt_op->num_entries; i++) { + const struct xe_vm_pgtable_update *update = + &pt_op->entries[i]; + + xe_tile_assert(tile, update); + xe_tile_assert(tile, update->pt_bo); + xe_tile_assert(tile, !iosys_map_is_null(&update->pt_bo->vmap)); + + if (pt_op->bind) + ops->populate(tile, &update->pt_bo->vmap, + NULL, update->ofs, update->qwords, + update); + else + ops->clear(vm, tile, &update->pt_bo->vmap, + NULL, update->ofs, update->qwords, + update); + } + } + + trace_xe_vm_cpu_bind(vm); + xe_device_wmb(vm->xe); +} + static struct dma_fence * xe_migrate_update_pgtables_cpu(struct xe_migrate *m, struct xe_migrate_pt_update *pt_update) @@ -1270,7 +1302,6 @@ xe_migrate_update_pgtables_cpu(struct xe_migrate *m, struct xe_vm_pgtable_update_ops *pt_update_ops = &pt_update->vops->pt_update_ops[pt_update->tile_id]; int err; - u32 i, j; if (XE_TEST_ONLY(test && test->force_gpu)) return ERR_PTR(-ETIME); @@ -1282,28 +1313,9 @@ xe_migrate_update_pgtables_cpu(struct xe_migrate *m, return ERR_PTR(err); } - for (i = 0; i < pt_update_ops->num_ops; ++i) { - const struct xe_vm_pgtable_update_op *pt_op = - &pt_update_ops->ops[i]; - - for (j = 0; j < pt_op->num_entries; j++) { - const struct xe_vm_pgtable_update *update = - &pt_op->entries[j]; - - if (pt_op->bind) - ops->populate(m->tile, - &update->pt_bo->vmap, NULL, - update->ofs, update->qwords, - update); - else - ops->clear(vm, m->tile, - &update->pt_bo->vmap, NULL, - update->ofs, update->qwords, update); - } - } - - trace_xe_vm_cpu_bind(vm); - xe_device_wmb(vm->xe); + __xe_migrate_update_pgtables_cpu(vm, m->tile, ops, + pt_update_ops->ops, + pt_update_ops->num_ops); return dma_fence_get_stub(); } -- 2.34.1