All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arvind Yadav" <arvind.yadav@intel.com>,
	dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v2 1/2] drm/xe: Snapshot inline DMA addresses before staging page tables
Date: Fri, 04 Dec 2026 07:21:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-249304@kernel.org> (raw)
In-Reply-To: <20261204065318.1785149-2-arvind.yadav@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/xe: unconditional extra pt_op scan in
  xe_pt_update_ops_run()
--

commit ac07d47429f6fccce3b202a8348537d6d71f609b
Author: Arvind Yadav <arvind.yadav@intel.com>

drm/xe: Snapshot inline DMA addresses before staging page tables

This commit protects userptr DMA address lookups with notifier_lock and
copies inline DMA entries before staging page tables in xe_pt_stage_bind().
For invalidated userptrs outside fault mode, it stages cleared PTEs and
keeps the affected tiles marked invalidated at commit time.

> diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
> index 0e0bf428df0f7..4a6135ab2c8d3 100644
> --- a/drivers/gpu/drm/xe/xe_pt.c
> +++ b/drivers/gpu/drm/xe/xe_pt.c

[ ... ]

> @@ -2869,7 +2904,6 @@ xe_pt_update_ops_run(struct xe_device *xe, struct xe_vma_ops *vops)
>  			xe_pt_commit(pt_op->vma, pt_op->entries,
>  				     pt_op->num_entries,
>  				     &pt_update_ops->pt_job_ops->deferred);
> -			pt_op->vma = NULL;	/* skip in xe_pt_update_ops_abort */
>  			tile_mask |= BIT(tile->id);
>  		}
>  	}
> @@ -2905,6 +2939,38 @@ xe_pt_update_ops_run(struct xe_device *xe, struct xe_vma_ops *vops)
>  				  tile_mask);
>  	}
>  
> +	/*
> +	 * op_commit() assumes a normal bind installed valid PTEs. Restore the
> +	 * actual userptr state from the staged operations, in operation order,
> +	 * before releasing the notifier lock. With shared page tables, tile 0
> +	 * determines the state for all tiles.
> +	 */
> +	for_each_tile(tile, xe, j) {
> +		struct xe_vm_pgtable_update_ops *pt_update_ops =
> +			&vops->pt_update_ops[j];
> +		u8 mask = xe->info.has_pt_mirror ? BIT(tile->id) : tile_mask;
> +
> +		if (pt_mirroring_disabled_for_tile(vm, j))
> +			continue;
> +
> +		for (i = 0; i < get_current_op(pt_update_ops); ++i) {
> +			struct xe_vm_pgtable_update_op *pt_op =
> +				to_pt_op(pt_update_ops, i);
> +			struct xe_vma *vma = pt_op->vma;
> +
> +			if (pt_op->bind && xe_vma_is_userptr(vma)) {
> +				/* Pairs with READ_ONCE in xe_vm_has_valid_gpu_mapping(). */
> +				if (pt_op->pt_cleared)
> +					WRITE_ONCE(vma->tile_invalidated,
> +						   vma->tile_invalidated | mask);
> +				else
> +					WRITE_ONCE(vma->tile_invalidated,
> +						   vma->tile_invalidated & ~mask);
> +			}
> +			pt_op->vma = NULL; /* skip in xe_pt_update_ops_abort */
> +		}
> +	}
> +
>  	if (needs_svm_lock)
>  		xe_pt_svm_userptr_notifier_unlock(vm);

[Severity: Medium]
Can this second pass over pt_job_ops->ops be skipped when no userptr bind
staged cleared PTEs?

Moving pt_op->vma = NULL out of the xe_pt_commit() loop forces every
xe_pt_update_ops_run() call to stride across all 384-byte pt_op entries
again and dereference pt_op->vma on every bind, even for pure BO VM_BIND
batches where needs_svm_lock is false and no userptr ops exist.

When needs_svm_lock is true, such as multi-range SVM prefetches or normal
non-invalidated userptr batches, this extra scan also runs while holding
vm->svm.gpusvm.notifier_lock, extending the read-side hold window against
MMU notifier invalidations.

Recording a flag on pt_update_ops or vops when bind_op_prepare() stages a
userptr with pt_op->pt_cleared would let pt_op->vma = NULL stay in the
first loop and skip this post-op_commit() walk in the common case.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204065318.1785149-1-arvind.yadav@intel.com?part=1

  reply	other threads:[~2026-12-04  7:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  6:53 [PATCH v2 0/2] Fix invalidated inline DMA mappings in GPUSVM Arvind Yadav
2026-12-04  6:53 ` [PATCH v2 1/2] drm/xe: Snapshot inline DMA addresses before staging page tables Arvind Yadav
2026-12-04  7:21   ` sashiko-bot [this message]
2026-12-04  6:53 ` [PATCH v2 2/2] drm/gpusvm: Clear inline DMA mapping state on unmap Arvind Yadav
2026-12-04  7:39   ` sashiko-bot
2026-12-04  7:30 ` ✓ CI.KUnit: success for Fix invalidated inline DMA mappings in GPUSVM Patchwork
2026-12-04  8:04 ` ✓ Xe.CI.BAT: " Patchwork
2026-12-05  5:43 ` ✗ Xe.CI.FULL: failure " Patchwork

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=sashiko-outbox-249304@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arvind.yadav@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.