AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: vitaly prosyak <vprosyak@amd.com>
To: christian.koenig@amd.com, Alexander.Deucher@amd.com,
	amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/4] drm/amdgpu: fix amdgpu_hmm_range_get_pages
Date: Tue, 12 May 2026 14:26:22 -0400	[thread overview]
Message-ID: <1baa9f2c-e282-4617-9c47-61c3f7fa40e0@amd.com> (raw)
In-Reply-To: <20260512162711.51118-1-christian.koenig@amd.com>

[-- Attachment #1: Type: text/plain, Size: 2708 bytes --]

Series is:
Reviewed-by: Vitaly Prosyak vitaly.prosyak@amd.com
Tested-by: Vitaly Prosyak vitaly.prosyak@amd.com

On 2026-05-12 12:27, Christian König wrote:
> The notifier sequence must only be read once or otherwise we could work
> with invalid pages.
>
> While at it also fix the coding style, e.g. drop the pre-initialized
> return value and use the common define for 2G range.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
> index 90d26d820bac..eb470e252399 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
> @@ -51,8 +51,6 @@
>  #include "amdgpu_amdkfd.h"
>  #include "amdgpu_hmm.h"
>  
> -#define MAX_WALK_BYTE	(2UL << 30)
> -
>  /**
>   * amdgpu_hmm_invalidate_gfx - callback to notify about mm change
>   *
> @@ -170,11 +168,13 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier,
>  			       void *owner,
>  			       struct amdgpu_hmm_range *range)
>  {
> -	unsigned long end;
> +	const u64 max_bytes = SZ_2G;
> +
> +	struct hmm_range *hmm_range = &range->hmm_range;
>  	unsigned long timeout;
>  	unsigned long *pfns;
> -	int r = 0;
> -	struct hmm_range *hmm_range = &range->hmm_range;
> +	unsigned long end;
> +	int r;
>  
>  	pfns = kvmalloc_array(npages, sizeof(*pfns), GFP_KERNEL);
>  	if (unlikely(!pfns)) {
> @@ -191,8 +191,9 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier,
>  	end = start + npages * PAGE_SIZE;
>  	hmm_range->dev_private_owner = owner;
>  
> +	hmm_range->notifier_seq = mmu_interval_read_begin(notifier);
>  	do {
> -		hmm_range->end = min(hmm_range->start + MAX_WALK_BYTE, end);
> +		hmm_range->end = min(hmm_range->start + max_bytes, end);
>  
>  		pr_debug("hmm range: start = 0x%lx, end = 0x%lx",
>  			hmm_range->start, hmm_range->end);
> @@ -200,7 +201,6 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier,
>  		timeout = jiffies + msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT);
>  
>  retry:
> -		hmm_range->notifier_seq = mmu_interval_read_begin(notifier);
>  		r = hmm_range_fault(hmm_range);
>  		if (unlikely(r)) {
>  			if (r == -EBUSY && !time_after(jiffies, timeout))
> @@ -210,7 +210,7 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier,
>  
>  		if (hmm_range->end == end)
>  			break;
> -		hmm_range->hmm_pfns += MAX_WALK_BYTE >> PAGE_SHIFT;
> +		hmm_range->hmm_pfns += max_bytes >> PAGE_SHIFT;
>  		hmm_range->start = hmm_range->end;
>  	} while (hmm_range->end < end);
>  

[-- Attachment #2: Type: text/html, Size: 5040 bytes --]

      parent reply	other threads:[~2026-05-12 18:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 16:27 [PATCH 1/4] drm/amdgpu: fix amdgpu_hmm_range_get_pages Christian König
2026-05-12 16:27 ` [PATCH 2/4] drm/amdgpu: fix calling VM invalidation in amdgpu_hmm_invalidate_gfx Christian König
2026-05-12 16:27 ` [PATCH 3/4] drm/amdgpu: fix waiting for all submissions for userptrs Christian König
2026-05-12 16:27 ` [PATCH 4/4] drm/amdgpu: restart the CS if some parts of the VM are still invalidated Christian König
2026-05-12 18:29   ` Alex Deucher
2026-05-12 18:26 ` vitaly prosyak [this message]

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=1baa9f2c-e282-4617-9c47-61c3f7fa40e0@amd.com \
    --to=vprosyak@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox