All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdkfd: SVM map to gpus check vma boundary
@ 2021-09-13 20:11 Philip Yang
  2021-09-16 20:40 ` Felix Kuehling
  2021-09-16 21:11 ` [PATCH v2] " Philip Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Philip Yang @ 2021-09-13 20:11 UTC (permalink / raw)
  To: amd-gfx; +Cc: Philip Yang

SVM range may includes multiple VMAs with different vm_flags, if prange
page index is the last page of the VMA offset + npages, update GPU
mapping to create GPU page table with same VMA access permission.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 110c46cd7fac..2e3ee9c46a10 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1178,7 +1178,9 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	for (i = offset; i < offset + npages; i++) {
 		last_domain = dma_addr[i] & SVM_RANGE_VRAM_DOMAIN;
 		dma_addr[i] &= ~SVM_RANGE_VRAM_DOMAIN;
+
 		if ((prange->start + i) < prange->last &&
+		    i + 1 < offset + npages &&
 		    last_domain == (dma_addr[i + 1] & SVM_RANGE_VRAM_DOMAIN))
 			continue;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdkfd: SVM map to gpus check vma boundary
  2021-09-13 20:11 [PATCH] drm/amdkfd: SVM map to gpus check vma boundary Philip Yang
@ 2021-09-16 20:40 ` Felix Kuehling
  2021-09-16 21:11 ` [PATCH v2] " Philip Yang
  1 sibling, 0 replies; 4+ messages in thread
From: Felix Kuehling @ 2021-09-16 20:40 UTC (permalink / raw)
  To: amd-gfx, Philip Yang

On 2021-09-13 4:11 p.m., Philip Yang wrote:
> SVM range may includes multiple VMAs with different vm_flags, if prange
> page index is the last page of the VMA offset + npages, update GPU
> mapping to create GPU page table with same VMA access permission.
>
> Signed-off-by: Philip Yang <Philip.Yang@amd.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 110c46cd7fac..2e3ee9c46a10 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1178,7 +1178,9 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>   	for (i = offset; i < offset + npages; i++) {
>   		last_domain = dma_addr[i] & SVM_RANGE_VRAM_DOMAIN;
>   		dma_addr[i] &= ~SVM_RANGE_VRAM_DOMAIN;
> +
>   		if ((prange->start + i) < prange->last &&
> +		    i + 1 < offset + npages &&

I think this would be more intuitive: "i < offset + npages - 1" (meaning 
i is before the last page in the range)

Do we still need the the "(prange->start + i) < prange->last" condition 
at all now? I think it could just be replaced with "i < offset + npages 
- 1".

Regards,
   Felix


>   		    last_domain == (dma_addr[i + 1] & SVM_RANGE_VRAM_DOMAIN))
>   			continue;
>   

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] drm/amdkfd: SVM map to gpus check vma boundary
  2021-09-13 20:11 [PATCH] drm/amdkfd: SVM map to gpus check vma boundary Philip Yang
  2021-09-16 20:40 ` Felix Kuehling
@ 2021-09-16 21:11 ` Philip Yang
  2021-09-16 21:37   ` Felix Kuehling
  1 sibling, 1 reply; 4+ messages in thread
From: Philip Yang @ 2021-09-16 21:11 UTC (permalink / raw)
  To: amd-gfx; +Cc: Philip Yang

SVM range may includes multiple VMAs with different vm_flags, if prange
page index is the last page of the VMA offset + npages, update GPU
mapping to create GPU page table with same VMA access permission.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 110c46cd7fac..de91c7e83bb4 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1178,7 +1178,12 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	for (i = offset; i < offset + npages; i++) {
 		last_domain = dma_addr[i] & SVM_RANGE_VRAM_DOMAIN;
 		dma_addr[i] &= ~SVM_RANGE_VRAM_DOMAIN;
-		if ((prange->start + i) < prange->last &&
+
+		/*
+		 * If i is not the last page in the range and next page is in
+		 * same VRAM or CPU domain
+		 */
+		if (i < offset + npages - 1 &&
 		    last_domain == (dma_addr[i + 1] & SVM_RANGE_VRAM_DOMAIN))
 			continue;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/amdkfd: SVM map to gpus check vma boundary
  2021-09-16 21:11 ` [PATCH v2] " Philip Yang
@ 2021-09-16 21:37   ` Felix Kuehling
  0 siblings, 0 replies; 4+ messages in thread
From: Felix Kuehling @ 2021-09-16 21:37 UTC (permalink / raw)
  To: amd-gfx, Philip Yang

On 2021-09-16 5:11 p.m., Philip Yang wrote:
> SVM range may includes multiple VMAs with different vm_flags, if prange
> page index is the last page of the VMA offset + npages, update GPU
> mapping to create GPU page table with same VMA access permission.
>
> Signed-off-by: Philip Yang <Philip.Yang@amd.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 110c46cd7fac..de91c7e83bb4 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1178,7 +1178,12 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>   	for (i = offset; i < offset + npages; i++) {
>   		last_domain = dma_addr[i] & SVM_RANGE_VRAM_DOMAIN;
>   		dma_addr[i] &= ~SVM_RANGE_VRAM_DOMAIN;
> -		if ((prange->start + i) < prange->last &&
> +
> +		/*
> +		 * If i is not the last page in the range and next page is in
> +		 * same VRAM or CPU domain

This comment doesn't add any information. It basically just restates the 
condition below without explaining the intention. Maybe something like 
this would be helpful instead:

/* Collect all pages in the same address range and memory domain that can
  * be mapped with a single call to amdgpu_vm_bo_update_mapping.
  */

With that fixed, the patch is

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>

> +		 */
> +		if (i < offset + npages - 1 &&
>   		    last_domain == (dma_addr[i + 1] & SVM_RANGE_VRAM_DOMAIN))
>   			continue;
>   

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-16 21:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 20:11 [PATCH] drm/amdkfd: SVM map to gpus check vma boundary Philip Yang
2021-09-16 20:40 ` Felix Kuehling
2021-09-16 21:11 ` [PATCH v2] " Philip Yang
2021-09-16 21:37   ` Felix Kuehling

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.