From: Matthew Brost <matthew.brost@intel.com>
To: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v6 17/20] drm/gpusvm: Introduce drm_gpusvm_find_vma_start() function
Date: Wed, 30 Apr 2025 08:03:23 -0700 [thread overview]
Message-ID: <aBI7u2iMvFJdcQcc@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250430121912.337601-18-himal.prasad.ghimiray@intel.com>
On Wed, Apr 30, 2025 at 05:49:09PM +0530, Himal Prasad Ghimiray wrote:
> The drm_gpusvm_find_vma_start() function is used to determine the starting
> address of a CPU VMA within a specified user range. If the range does not
> contain any VMA, the function returns ULONG_MAX.
>
> v2
> - Rename function as drm_gpusvm_find_vma_start() (Matthew Brost)
> - mmget/mmput
>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
> drivers/gpu/drm/drm_gpusvm.c | 32 ++++++++++++++++++++++++++++++++
> include/drm/drm_gpusvm.h | 5 +++++
> 2 files changed, 37 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c
> index c94a8d7a293d..48bb29b78b96 100644
> --- a/drivers/gpu/drm/drm_gpusvm.c
> +++ b/drivers/gpu/drm/drm_gpusvm.c
> @@ -980,6 +980,38 @@ static void drm_gpusvm_driver_lock_held(struct drm_gpusvm *gpusvm)
> }
> #endif
>
> +/**
> + * drm_gpusvm_find_vma_start() - Find start address for first VMA in range
> + * @gpusvm: Pointer to the GPU SVM structure
> + * @start: The inclusive start user address.
> + * @end: The exclusive end user address.
> + *
> + * Returns: The start address of first VMA within the provided range,
> + * ULONG_MAX otherwise. Assumes start_addr < end_addr.
> + */
> +unsigned long
> +drm_gpusvm_find_vma_start(struct drm_gpusvm *gpusvm,
> + unsigned long start,
> + unsigned long end)
> +{
> + struct mm_struct *mm = gpusvm->mm;
> + struct vm_area_struct *vma;
> + unsigned long addr = ULONG_MAX;
> +
> + mmget(mm);
The MM could be closed here, so:
if (!mmget_not_zero(mm))
return addr;
Matt
> + mmap_read_lock(mm);
> +
> + vma = find_vma_intersection(mm, start, end);
> + if (vma)
> + addr = vma->vm_start;
> +
> + mmap_read_unlock(mm);
> + mmput(mm);
> +
> + return addr;
> +}
> +EXPORT_SYMBOL_GPL(drm_gpusvm_find_vma_start);
> +
> /**
> * drm_gpusvm_range_find_or_insert() - Find or insert GPU SVM range
> * @gpusvm: Pointer to the GPU SVM structure
> diff --git a/include/drm/drm_gpusvm.h b/include/drm/drm_gpusvm.h
> index eaf704d3d05e..6a5156476bf4 100644
> --- a/include/drm/drm_gpusvm.h
> +++ b/include/drm/drm_gpusvm.h
> @@ -327,6 +327,11 @@ void drm_gpusvm_fini(struct drm_gpusvm *gpusvm);
>
> void drm_gpusvm_free(struct drm_gpusvm *gpusvm);
>
> +unsigned long
> +drm_gpusvm_find_vma_start(struct drm_gpusvm *gpusvm,
> + unsigned long start,
> + unsigned long end);
> +
> struct drm_gpusvm_range *
> drm_gpusvm_range_find_or_insert(struct drm_gpusvm *gpusvm,
> unsigned long fault_addr,
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-04-30 15:03 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 12:18 [PATCH v6 00/20] Prefetch Support for svm ranges Himal Prasad Ghimiray
2025-04-30 12:18 ` [PATCH v6 01/20] drm/gpusvm: Introduce devmem_only flag for allocation Himal Prasad Ghimiray
2025-04-30 12:18 ` [PATCH v6 02/20] drm/xe: Strict migration policy for atomic SVM faults Himal Prasad Ghimiray
2025-05-05 15:20 ` Thomas Hellström
2025-05-05 20:18 ` Matthew Brost
2025-05-06 10:13 ` Thomas Hellström
2025-05-06 14:59 ` Matthew Brost
2025-04-30 12:18 ` [PATCH v6 03/20] drm/gpusvm: Add timeslicing support to GPU SVM Himal Prasad Ghimiray
2025-04-30 12:18 ` [PATCH v6 04/20] drm/xe: Timeslice GPU on atomic SVM fault Himal Prasad Ghimiray
2025-04-30 12:18 ` [PATCH v6 05/20] drm/xe: Add atomic_svm_timeslice_ms debugfs entry Himal Prasad Ghimiray
2025-04-30 12:18 ` [PATCH v6 06/20] drm/xe: Introduce xe_vma_op_prefetch_range struct for prefetch of ranges Himal Prasad Ghimiray
2025-04-30 12:18 ` [PATCH v6 07/20] drm/xe: Make xe_svm_alloc_vram public Himal Prasad Ghimiray
2025-04-30 12:19 ` [PATCH v6 08/20] drm/xe/svm: Helper to add tile masks to svm ranges Himal Prasad Ghimiray
2025-04-30 12:19 ` [PATCH v6 09/20] drm/xe/svm: Make to_xe_range a public function Himal Prasad Ghimiray
2025-04-30 12:19 ` [PATCH v6 10/20] drm/xe/svm: Make xe_svm_range_* end/start/size public Himal Prasad Ghimiray
2025-04-30 12:19 ` [PATCH v6 11/20] drm/xe/vm: Update xe_vma_ops_incr_pt_update_ops to take an increment value Himal Prasad Ghimiray
2025-04-30 12:19 ` [PATCH v6 12/20] drm/xe/vm: Add an identifier in xe_vma_ops for svm prefetch Himal Prasad Ghimiray
2025-04-30 12:19 ` [PATCH v6 13/20] drm/xe: Rename lookup_vma function to xe_find_vma_by_addr Himal Prasad Ghimiray
2025-04-30 12:19 ` [PATCH v6 14/20] drm/xe/svm: Refactor usage of drm_gpusvm* function in xe_svm Himal Prasad Ghimiray
2025-04-30 12:19 ` [PATCH v6 15/20] drm/xe/svm: Make xe_svm_range_needs_migrate_to_vram() public Himal Prasad Ghimiray
2025-04-30 12:19 ` [PATCH v6 16/20] drm/xe/svm: Add xe_svm_range_validate() and xe_svm_range_migrate_to_smem() Himal Prasad Ghimiray
2025-04-30 14:50 ` Matthew Brost
2025-04-30 12:19 ` [PATCH v6 17/20] drm/gpusvm: Introduce drm_gpusvm_find_vma_start() function Himal Prasad Ghimiray
2025-04-30 15:03 ` Matthew Brost [this message]
2025-04-30 12:19 ` [PATCH v6 18/20] drm/xe/svm: Add xe_svm_find_vma_start() helper Himal Prasad Ghimiray
2025-04-30 16:35 ` Matthew Brost
2025-04-30 12:19 ` [PATCH v6 19/20] drm/xe/svm: Implement prefetch support for SVM ranges Himal Prasad Ghimiray
2025-05-02 13:42 ` Thomas Hellström
2025-05-02 14:35 ` Ghimiray, Himal Prasad
2025-05-02 14:39 ` Thomas Hellström
2025-05-02 16:11 ` Ghimiray, Himal Prasad
2025-05-07 11:39 ` Thomas Hellström
2025-05-12 12:48 ` Matthew Brost
2025-05-12 12:56 ` Ghimiray, Himal Prasad
2025-04-30 12:19 ` [PATCH v6 20/20] drm/xe/vm: Add debug prints for SVM range prefetch Himal Prasad Ghimiray
2025-04-30 12:45 ` ✓ CI.Patch_applied: success for Prefetch Support for svm ranges (rev5) Patchwork
2025-04-30 12:45 ` ✓ CI.checkpatch: " Patchwork
2025-04-30 12:46 ` ✓ CI.KUnit: " Patchwork
2025-04-30 13:06 ` ✓ CI.Build: " Patchwork
2025-04-30 13:08 ` ✓ CI.Hooks: " Patchwork
2025-04-30 13:10 ` ✓ CI.checksparse: " Patchwork
2025-04-30 20:06 ` ✗ Xe.CI.Full: failure " Patchwork
2025-05-06 7:55 ` ✓ Xe.CI.BAT: success " 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=aBI7u2iMvFJdcQcc@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=thomas.hellstrom@linux.intel.com \
/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.