From: Matthew Brost <matthew.brost@intel.com>
To: Farah Kassabri <farah.kassabri@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <ilia.levi@intel.com>
Subject: Re: [PATCH v2 2/2] drm/xe: add kernel VM BO unbind helper
Date: Tue, 20 Jan 2026 14:56:33 -0800 [thread overview]
Message-ID: <aXAIIRj3OaLgEMvU@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20260119150330.6537-2-farah.kassabri@intel.com>
On Mon, Jan 19, 2026 at 05:03:30PM +0200, Farah Kassabri wrote:
> Add xe_kernel_vm_unbind_bo() as the counterpart to
> xe_kernel_vm_bind_bo() to provide symmetry in the kernel VM BO
> lifecycle.
>
> The new helper allows explicit unbinding of buffer objects from
> the kernel VM, enabling proper cleanup and preventing stale
> kernel VM mappings when BOs are no longer needed.
>
> Signed-off-by: Farah Kassabri <farah.kassabri@intel.com>
> Reviewed-by: Ilia Levi <ilia.levi@intel.com>
>
> Changes in v2:
> pass cache_lvl argument to the map operation instead of 0.
> ---
> drivers/gpu/drm/xe/xe_vm.c | 59 ++++++++++++++++++++++++++++++++------
> drivers/gpu/drm/xe/xe_vm.h | 3 ++
> 2 files changed, 54 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index a27145a4137e..425f406712b8 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -3830,21 +3830,22 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> }
>
> /**
> - * xe_vm_kernel_bind_bo - bind a BO to a kernel owned VM
> + * __xe_kernel_vm_bind_bo - internal helper to bind/unbind a BO to/from kernel owned VM
> * @vm: VM to bind the BO to
> * @bo: BO to bind
> * @q: exec queue to use for the bind (optional)
> * @addr: address at which to bind the BO
> * @cache_lvl: PAT cache level to use
> + * @do_bind: true for bind, false for unbind
> *
> - * Execute a VM bind map operation on a BO to bind it into a kernel-owned VM.
> + * Common code for binding and un-binding a BO.
> *
> * Returns a dma_fence to track the binding completion if the job to do so was
> * successfully submitted, an error pointer otherwise.
> */
> -struct dma_fence *xe_vm_kernel_bind_bo(struct xe_vm *vm, struct xe_bo *bo,
> - struct xe_exec_queue *q, u64 addr,
> - enum xe_cache_level cache_lvl)
> +static struct dma_fence *__xe_kernel_vm_bind_bo(struct xe_vm *vm, struct xe_bo *bo,
> + struct xe_exec_queue *q, u64 addr,
> + enum xe_cache_level cache_lvl, bool do_bind)
> {
> struct xe_vma_ops vops;
> struct drm_gpuva_ops *ops = NULL;
> @@ -3860,9 +3861,13 @@ struct dma_fence *xe_vm_kernel_bind_bo(struct xe_vm *vm, struct xe_bo *bo,
>
> xe_vma_ops_init(&vops, vm, q, NULL, 0);
>
> - ops = vm_bind_ioctl_ops_create(vm, &vops, bo, 0, addr, xe_bo_size(bo),
> - DRM_XE_VM_BIND_OP_MAP, 0, 0,
> - vm->xe->pat.idx[cache_lvl]);
> + if (do_bind)
> + ops = vm_bind_ioctl_ops_create(vm, &vops, bo, 0, addr, xe_bo_size(bo),
> + DRM_XE_VM_BIND_OP_MAP, 0, 0,
> + vm->xe->pat.idx[cache_lvl]);
> + else
> + ops = vm_bind_ioctl_ops_create(vm, &vops, bo, 0, addr, xe_bo_size(bo),
> + DRM_XE_VM_BIND_OP_UNMAP, 0, 0, 0);
> if (IS_ERR(ops)) {
> err = PTR_ERR(ops);
> goto release_vm_lock;
> @@ -3903,6 +3908,44 @@ struct dma_fence *xe_vm_kernel_bind_bo(struct xe_vm *vm, struct xe_bo *bo,
> return fence;
> }
>
> +/**
> + * xe_vm_kernel_bind_bo - bind a BO to a kernel owned VM
> + * @vm: VM to bind the BO to
> + * @bo: BO to bind
> + * @q: exec queue to use for the bind (optional)
> + * @addr: address at which to bind the BO
> + * @cache_lvl: PAT cache level to use
> + *
> + * Execute a VM bind map operation on a BO to bind it into a kernel-owned VM.
> + *
> + * Returns a dma_fence to track the binding completion if the job to do so was
> + * successfully submitted, an error pointer otherwise.
> + */
> +struct dma_fence *xe_vm_kernel_bind_bo(struct xe_vm *vm, struct xe_bo *bo,
> + struct xe_exec_queue *q, u64 addr,
> + enum xe_cache_level cache_lvl)
> +{
> + return __xe_kernel_vm_bind_bo(vm, bo, q, addr, cache_lvl, true);
> +}
> +
> +/**
> + * xe_vm_kernel_unbind_bo - unbind a BO from a kernel owned VM
> + * @vm: VM to unbind the BO from
> + * @bo: BO to unbind
> + * @q: exec queue to use for the unbind (optional)
> + * @addr: address at which the BO was bound
> + *
> + * Execute a VM bind unmap operation on a BO to remove it from a kernel-owned VM.
> + *
> + * Returns a dma_fence to track the unbinding completion if the job to do so was
> + * successfully submitted, an error pointer otherwise.
> + */
> +struct dma_fence *xe_vm_kernel_unbind_bo(struct xe_vm *vm, struct xe_bo *bo,
> + struct xe_exec_queue *q, u64 addr)
> +{
> + return __xe_kernel_vm_bind_bo(vm, bo, q, addr, 0, false);
> +}
> +
> /**
> * xe_vm_lock() - Lock the vm's dma_resv object
> * @vm: The struct xe_vm whose lock is to be locked
> diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h
> index ff32f43aa1d8..b87e80227c79 100644
> --- a/drivers/gpu/drm/xe/xe_vm.h
> +++ b/drivers/gpu/drm/xe/xe_vm.h
> @@ -272,6 +272,9 @@ struct dma_fence *xe_vm_kernel_bind_bo(struct xe_vm *vm, struct xe_bo *bo,
> struct xe_exec_queue *q, u64 addr,
> enum xe_cache_level cache_lvl);
>
> +struct dma_fence *xe_vm_kernel_unbind_bo(struct xe_vm *vm, struct xe_bo *bo,
> + struct xe_exec_queue *q, u64 addr);
> +
> void xe_vm_resume_rebind_worker(struct xe_vm *vm);
>
> /**
> --
> 2.43.0
>
> ---------------------------------------------------------------------
> Intel Israel (74) Limited
>
You should remove your footer for public mailing list posts.
But patch LGTM.
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
next prev parent reply other threads:[~2026-01-20 22:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-19 15:03 [PATCH v2 1/2] drm/xe: s/xe_vm_bind_kernel_bo/xe_kernel_vm_bind_bo Farah Kassabri
2026-01-19 15:03 ` [PATCH v2 2/2] drm/xe: add kernel VM BO unbind helper Farah Kassabri
2026-01-20 22:56 ` Matthew Brost [this message]
2026-02-06 0:49 ` Matthew Brost
2026-01-19 15:10 ` ✗ CI.KUnit: failure for series starting with [v2,1/2] drm/xe: s/xe_vm_bind_kernel_bo/xe_kernel_vm_bind_bo Patchwork
2026-01-20 22:51 ` [PATCH v2 1/2] " Matthew Brost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aXAIIRj3OaLgEMvU@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=farah.kassabri@intel.com \
--cc=ilia.levi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox