Skip to contentSkip to conversation

drm/amdkfd: Don't drain ih1 for APU

PATCH Superseded Yifan Zhang 2 participants 3 messages Aug 27, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkfd: Don't drain ih1 for APU

ih1 is not initialized for APUs. Don't drain it or NULL pointer error will be triggered.

Fixes 490fc21fe97c (drm/amdkfd: Change kfd/svm page fault drain handling)
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +7 -5
index b44dec90969f..1d08978955c7 100644
@@ -2458,11 +2458,13 @@ svm_range_unmap_from_cpu(struct mm_struct *mm, struct svm_range *prange,
 		adev = pdd->dev->adev;
 
 		/* Check and drain ih1 ring if cam not available */
-		ih = &adev->irq.ih1;
-		checkpoint_wptr = amdgpu_ih_get_wptr(adev, ih);
-		if (ih->rptr != checkpoint_wptr) {
-			svms->checkpoint_ts[i] = amdgpu_ih_decode_iv_ts(adev, ih, checkpoint_wptr, -1);
-			continue;
+		if (!(adev->flags & AMD_IS_APU)) {
+			ih = &adev->irq.ih1;
+			checkpoint_wptr = amdgpu_ih_get_wptr(adev, ih);
+			if (ih->rptr != checkpoint_wptr) {
+				svms->checkpoint_ts[i] = amdgpu_ih_decode_iv_ts(adev, ih, checkpoint_wptr, -1);
+				continue;
+			}
 		}
 
 		/* check if dev->irq.ih_soft is not empty */
Signature · 1 line
2.37.3
#1 lore raw
Quoted 15 lines · Yifan Zhang

ih1 is not initialized for APUs. Don't drain it or NULL pointer error will be triggered.

Fixes 490fc21fe97c (drm/amdkfd: Change kfd/svm page fault drain handling)
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +0 -0
index b44dec90969f..1d08978955c7 100644

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_unmap_from_cpu(struct mm_struct *mm, struct svm_range *prange, · line 2461

Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -5
@@ -2458,11 +2458,13 @@ svm_range_unmap_from_cpu(struct mm_struct *mm, struct svm_range *prange,
                adev = pdd->dev->adev;
 
                /* Check and drain ih1 ring if cam not available */
-               ih = &adev->irq.ih1;
-               checkpoint_wptr = amdgpu_ih_get_wptr(adev, ih);
-               if (ih->rptr != checkpoint_wptr) {
-                       svms->checkpoint_ts[i] = amdgpu_ih_decode_iv_ts(adev, ih, checkpoint_wptr, -1);
-                       continue;
+               if (!(adev->flags & AMD_IS_APU)) {

Would be better to check if the ih1 ring is valid rather than checking for APUs. E.g.,

if (adev->irq.ih1.ring_size)

Alex

Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +6 -1
+                       ih = &adev->irq.ih1;
+                       checkpoint_wptr = amdgpu_ih_get_wptr(adev, ih);
+                       if (ih->rptr != checkpoint_wptr) {
+                               svms->checkpoint_ts[i] = amdgpu_ih_decode_iv_ts(adev, ih, checkpoint_wptr, -1);
+                               continue;
+                       }
                }
 
                /* check if dev->irq.ih_soft is not empty */
--

2.37.3

#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Thanks. Will send V2.

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, August 27, 2024 9:08 PM
To: Zhang, Yifan <[email protected]>
Cc: [email protected]; Kuehling, Felix <[email protected]>; Yang, Philip <[email protected]>; Chen, Xiaogang <[email protected]>
Subject: Re: [PATCH] drm/amdkfd: Don't drain ih1 for APU

Quoted 17 lines · Yifan Zhang

ih1 is not initialized for APUs. Don't drain it or NULL pointer error will be triggered.

Fixes 490fc21fe97c (drm/amdkfd: Change kfd/svm page fault drain

handling)

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +0 -0
index b44dec90969f..1d08978955c7 100644

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_unmap_from_cpu(struct mm_struct *mm, struct svm_range *prange, · line 2461

Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -5
@@ -2458,11 +2458,13 @@ svm_range_unmap_from_cpu(struct mm_struct *mm, struct svm_range *prange,
                adev = pdd->dev->adev;
 
                /* Check and drain ih1 ring if cam not available */
-               ih = &adev->irq.ih1;
-               checkpoint_wptr = amdgpu_ih_get_wptr(adev, ih);
-               if (ih->rptr != checkpoint_wptr) {
-                       svms->checkpoint_ts[i] = amdgpu_ih_decode_iv_ts(adev, ih, checkpoint_wptr, -1);
-                       continue;
+               if (!(adev->flags & AMD_IS_APU)) {

Would be better to check if the ih1 ring is valid rather than checking for APUs. E.g.,

if (adev->irq.ih1.ring_size)

Alex

Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +6 -1
+                       ih = &adev->irq.ih1;
+                       checkpoint_wptr = amdgpu_ih_get_wptr(adev, ih);
+                       if (ih->rptr != checkpoint_wptr) {
+                               svms->checkpoint_ts[i] = amdgpu_ih_decode_iv_ts(adev, ih, checkpoint_wptr, -1);
+                               continue;
+                       }
                }
 
                /* check if dev->irq.ih_soft is not empty */
--

2.37.3