From mboxrd@z Thu Jan 1 00:00:00 1970 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 B6E9FC4167D for ; Tue, 31 Oct 2023 14:22:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F8D510E4FE; Tue, 31 Oct 2023 14:22:00 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26DB310E501 for ; Tue, 31 Oct 2023 14:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698762111; x=1730298111; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=3vs0CsRMeUFVsrC0DyDJ5v4PytK+GJj5BI/hj1s3Sv0=; b=le3xMVuf81mp352yP5ulXC+jjgT4b/72/iNOh6nRvu2+RiycGGcDGuZE 7jvty5T2UKm6Nyp+51F6wMnPMgi9+/AoaBMthPx0XN6mEC0hBpH4knN9e QpPydo3X5056S49l8jXCjRX1cOiL25faAUqfgdCgx5vJdL6eFoWsud1yy DJUIvbDAdMe4jnlFwviBVPZMrXRqJKV1BTAr3FjbB1UPClQf1/XWvhU39 DKxzl2Oo3rmhnou4LJ3VjlcQxFGQKJI6hwyNFkJ+Gt/rvVJBFZqbmXq8+ bTc/Ph1Se4ooUAt41KcjF8Nr5Xpgm0JGV8Zav1u1f7EsIo3ZAGOr+6aaG Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="387183155" X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="387183155" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 07:21:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="934126081" X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="934126081" Received: from olindum-mobl1.ger.corp.intel.com (HELO fedora..) ([10.249.254.59]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 07:21:49 -0700 From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Date: Tue, 31 Oct 2023 15:21:29 +0100 Message-ID: <20231031142133.17129-7-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231031142133.17129-1-thomas.hellstrom@linux.intel.com> References: <20231031142133.17129-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Intel-xe] [CI 07/11] drm/xe: Adjust to commit "drm/gpuvm: add an abstraction for a VM/BO combination" 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" Signed-off-by: Thomas Hellström --- drivers/gpu/drm/xe/xe_bo.c | 11 +++++++---- drivers/gpu/drm/xe/xe_vm.c | 32 +++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index c56c94711f4e..58a16b1fc154 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -452,6 +452,7 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, struct dma_fence *fence; struct drm_gpuva *gpuva; struct drm_gem_object *obj = &bo->ttm.base; + struct drm_gpuvm_bo *vm_bo; int ret = 0; dma_resv_assert_held(bo->ttm.base.resv); @@ -464,11 +465,12 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, dma_resv_iter_end(&cursor); } - drm_gem_for_each_gpuva(gpuva, obj) { - struct xe_vma *vma = gpuva_to_vma(gpuva); - struct xe_vm *vm = xe_vma_vm(vma); + drm_gem_for_each_gpuvm_bo(vm_bo, obj) { + drm_gpuvm_bo_for_each_va(gpuva, vm_bo) { + struct xe_vma *vma = gpuva_to_vma(gpuva); + struct xe_vm *vm = xe_vma_vm(vma); - trace_xe_vma_evict(vma); + trace_xe_vma_evict(vma); if (xe_vm_in_fault_mode(vm)) { /* Wait for pending binds / unbinds. */ @@ -522,6 +524,7 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, if (vm_resv_locked) dma_resv_unlock(xe_vm_resv(vm)); } + } } return ret; diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c index 16ac77b67fe1..1b94736ef430 100644 --- a/drivers/gpu/drm/xe/xe_vm.c +++ b/drivers/gpu/drm/xe/xe_vm.c @@ -911,12 +911,21 @@ static struct xe_vma *xe_vma_create(struct xe_vm *vm, vma->gpuva.flags |= XE_VMA_ATOMIC_PTE_BIT; if (bo) { + struct drm_gpuvm_bo *vm_bo; + xe_bo_assert_held(bo); + vm_bo = drm_gpuvm_bo_obtain(vma->gpuva.vm, &bo->ttm.base); + if (IS_ERR(vm_bo)) { + kfree(vma); + return ERR_CAST(vm_bo); + } + drm_gem_object_get(&bo->ttm.base); vma->gpuva.gem.obj = &bo->ttm.base; vma->gpuva.gem.offset = bo_offset_or_userptr; - drm_gpuva_link(&vma->gpuva); + drm_gpuva_link(&vma->gpuva, vm_bo); + drm_gpuvm_bo_put(vm_bo); } else /* userptr or null */ { if (!is_null) { u64 size = end - start + 1; @@ -998,16 +1007,19 @@ static struct xe_vma * bo_has_vm_references_locked(struct xe_bo *bo, struct xe_vm *vm, struct xe_vma *ignore) { - struct drm_gpuva *gpuva; + struct drm_gpuvm_bo *vm_bo; + struct drm_gpuva *va; struct drm_gem_object *obj = &bo->ttm.base; xe_bo_assert_held(bo); - drm_gem_for_each_gpuva(gpuva, obj) { - struct xe_vma *vma = gpuva_to_vma(gpuva); + drm_gem_for_each_gpuvm_bo(vm_bo, obj) { + drm_gpuvm_bo_for_each_va(va, vm_bo) { + struct xe_vma *vma = gpuva_to_vma(va); - if (vma != ignore && xe_vma_vm(vma) == vm) - return vma; + if (vma != ignore && xe_vma_vm(vma) == vm) + return vma; + } } return NULL; @@ -2175,6 +2187,7 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo, struct drm_gpuva_ops *ops; struct drm_gpuva_op *__op; struct xe_vma_op *op; + struct drm_gpuvm_bo *vm_bo; int err; lockdep_assert_held_write(&vm->lock); @@ -2232,7 +2245,12 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo, err = xe_bo_lock(bo, true); if (err) return ERR_PTR(err); - ops = drm_gpuvm_gem_unmap_ops_create(&vm->gpuvm, obj); + + vm_bo = drm_gpuvm_bo_find(&vm->gpuvm, obj); + if (!vm_bo) + break; + + ops = drm_gpuvm_bo_unmap_ops_create(vm_bo); xe_bo_unlock(bo); if (IS_ERR(ops)) return ops; -- 2.41.0