Skip to contentSkip to conversation

drm/amdkfd: remove redundant iommu cleanup code

PATCH In review Yifan Zhang 4 participants 14 messages Sep 28, 2021 – Oct 11, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdkfd: remove redundant iommu cleanup code

kfd_resume doesn't involve iommu operation, remove redundant iommu cleanup code.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +1 -7
index c2a4d920da40..4a416231b24c 100644
@@ -1085,18 +1085,12 @@ static int kfd_resume(struct kfd_dev *kfd)
 	int err = 0;
 
 	err = kfd->dqm->ops.start(kfd->dqm);
-	if (err) {
+	if (err)
 		dev_err(kfd_device,
 			"Error starting queue manager for device %x:%x\n",
 			kfd->pdev->vendor, kfd->pdev->device);
-		goto dqm_start_error;
-	}
 
 	return err;
-
-dqm_start_error:
-	kfd_iommu_suspend(kfd);
-	return err;
 }
 
 static inline void kfd_queue_work(struct workqueue_struct *wq,
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 drm/amdgpu: init iommu after amdkfd device init

This patch is to fix clinfo failure in Raven/Picasso:

Number of platforms: 1
Platform Profile: FULL_PROFILE
Platform Version: OpenCL 2.2 AMD-APP (3364.0) Platform Name: AMD Accelerated Parallel Processing Platform Vendor: Advanced Micro Devices, Inc. Platform Extensions: cl_khr_icd cl_amd_event_callback

Platform Name: AMD Accelerated Parallel Processing Number of devices: 0

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -4
index 4c8f2f4647c0..89ed9b091386 100644
@@ -2393,10 +2393,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 	if (r)
 		goto init_failed;
 
-	r = amdgpu_amdkfd_resume_iommu(adev);
-	if (r)
-		goto init_failed;
-
 	r = amdgpu_device_ip_hw_init_phase1(adev);
 	if (r)
 		goto init_failed;
@@ -2435,6 +2431,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 	if (!adev->gmc.xgmi.pending_reset)
 		amdgpu_amdkfd_device_init(adev);
 
+	r = amdgpu_amdkfd_resume_iommu(adev);
+	if (r)
+		goto init_failed;
+
 	amdgpu_fru_get_product_info(adev);
 
 init_failed:
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[+James]

This basically undoes James's change "drm/amdgpu: move iommu_resume before ip init/resume". I assume James made his change for a reason. Can you please discuss the issue with him and determine a solution that solves both your problem and his?

If James' patch series was a mistake, I'd prefer to revert his patches, because his patches complicated the initialization sequence and exposed the iommu init sequence in amdgpu.

Thanks,
  Felix

Am 2021-09-28 um 4:28 a.m. schrieb Yifan Zhang:

Quoted 42 lines

This patch is to fix clinfo failure in Raven/Picasso:

Number of platforms: 1
Platform Profile: FULL_PROFILE
Platform Version: OpenCL 2.2 AMD-APP (3364.0) Platform Name: AMD Accelerated Parallel Processing Platform Vendor: Advanced Micro Devices, Inc. Platform Extensions: cl_khr_icd cl_amd_event_callback

Platform Name: AMD Accelerated Parallel Processing Number of devices: 0

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -4
index 4c8f2f4647c0..89ed9b091386 100644
@@ -2393,10 +2393,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 	if (r)
 		goto init_failed;
 
-	r = amdgpu_amdkfd_resume_iommu(adev);
-	if (r)
-		goto init_failed;
-
 	r = amdgpu_device_ip_hw_init_phase1(adev);
 	if (r)
 		goto init_failed;
@@ -2435,6 +2431,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 	if (!adev->gmc.xgmi.pending_reset)
 		amdgpu_amdkfd_device_init(adev);
 
+	r = amdgpu_amdkfd_resume_iommu(adev);
+	if (r)
+		goto init_failed;
+
 	amdgpu_fru_get_product_info(adev);
 
 init_failed:
#3 lore raw

Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[AMD Official Use Only]

H Felix,

Since the previous patch can help on PCO suspend/resume hung issue. Let me work with YiFan to see if there is proper way to cover both cases.

Thanks & Best Regards!

James Zhu

________________________________
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, September 28, 2021 11:41 AM
To: Zhang, Yifan <[email protected]>; [email protected] <[email protected]>; Zhu, James <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[+James]

This basically undoes James's change "drm/amdgpu: move iommu_resume before ip init/resume". I assume James made his change for a reason. Can you please discuss the issue with him and determine a solution that solves both your problem and his?

If James' patch series was a mistake, I'd prefer to revert his patches, because his patches complicated the initialization sequence and exposed the iommu init sequence in amdgpu.

Thanks,
Felix

Am 2021-09-28 um 4:28 a.m. schrieb Yifan Zhang:

Quoted 42 lines

This patch is to fix clinfo failure in Raven/Picasso:

Number of platforms: 1
Platform Profile: FULL_PROFILE
Platform Version: OpenCL 2.2 AMD-APP (3364.0) Platform Name: AMD Accelerated Parallel Processing Platform Vendor: Advanced Micro Devices, Inc. Platform Extensions: cl_khr_icd cl_amd_event_callback

Platform Name: AMD Accelerated Parallel Processing Number of devices: 0

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -4
index 4c8f2f4647c0..89ed9b091386 100644
@@ -2393,10 +2393,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
       if (r)
               goto init_failed;
 
-     r = amdgpu_amdkfd_resume_iommu(adev);
-     if (r)
-             goto init_failed;
-
       r = amdgpu_device_ip_hw_init_phase1(adev);
       if (r)
               goto init_failed;
@@ -2435,6 +2431,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
       if (!adev->gmc.xgmi.pending_reset)
               amdgpu_amdkfd_device_init(adev);
 
+     r = amdgpu_amdkfd_resume_iommu(adev);
+     if (r)
+             goto init_failed;
+
       amdgpu_fru_get_product_info(adev);
 
 init_failed:
#4 lore raw

RE: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[AMD Official Use Only]

Hi Felix,

After sync w/ James, we agree that this patch series could fix both our problems, and he verified this patch series will not cause regression of his previous issue. Do you have more comments regarding this patch series ? Thanks.

BRs,
Yifan

From: Zhu, James <[email protected]>
Sent: Wednesday, September 29, 2021 9:19 PM
To: Kuehling, Felix <[email protected]>; Zhang, Yifan <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[AMD Official Use Only]

H Felix,

Since the previous patch can help on PCO suspend/resume hung issue. Let me work with YiFan to see if there is proper way to cover both cases.

Thanks & Best Regards!

James Zhu

________________________________
From: Kuehling, Felix <[email protected]<mailto:[email protected]>>
Sent: Tuesday, September 28, 2021 11:41 AM
To: Zhang, Yifan <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Zhu, James <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[+James]

This basically undoes James's change "drm/amdgpu: move iommu_resume before ip init/resume". I assume James made his change for a reason. Can you please discuss the issue with him and determine a solution that solves both your problem and his?

If James' patch series was a mistake, I'd prefer to revert his patches, because his patches complicated the initialization sequence and exposed the iommu init sequence in amdgpu.

Thanks,
Felix

Am 2021-09-28 um 4:28 a.m. schrieb Yifan Zhang:

Quoted 42 lines

This patch is to fix clinfo failure in Raven/Picasso:

Number of platforms: 1
Platform Profile: FULL_PROFILE
Platform Version: OpenCL 2.2 AMD-APP (3364.0) Platform Name: AMD Accelerated Parallel Processing Platform Vendor: Advanced Micro Devices, Inc. Platform Extensions: cl_khr_icd cl_amd_event_callback

Platform Name: AMD Accelerated Parallel Processing Number of devices: 0

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -4
index 4c8f2f4647c0..89ed9b091386 100644
@@ -2393,10 +2393,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
       if (r)
               goto init_failed;
 
-     r = amdgpu_amdkfd_resume_iommu(adev);
-     if (r)
-             goto init_failed;
-
       r = amdgpu_device_ip_hw_init_phase1(adev);
       if (r)
               goto init_failed;
@@ -2435,6 +2431,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
       if (!adev->gmc.xgmi.pending_reset)
               amdgpu_amdkfd_device_init(adev);
 
+     r = amdgpu_amdkfd_resume_iommu(adev);
+     if (r)
+             goto init_failed;
+
       amdgpu_fru_get_product_info(adev);
 
 init_failed:
maintainer Acked-by
#5 lore raw

Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

I'm trying to understand what the end result is after James' and your patches. If I'm reading it correctly, we now initialize IOMMUv2 after kfd_device_init during initialization, but before kfd_device_init during resume from S3. Is  that the correct understanding?

My concern is, that we may run into related problems again if the root cause and the mechanism of the fix are poorly understood. Do you have an explanation why this different sequence is needed during init and resume?

That said, given that your patches are tested and reviewed by James, you can add my Acked-by to both patches. The series is

Thanks,
  Felix

Am 2021-10-04 um 5:42 a.m. schrieb Zhang, Yifan:

Quoted 130 lines

[AMD Official Use Only]

Hi Felix,

After sync w/ James, we agree that this patch series could fix both our problems, and he verified this patch series will not cause regression of his previous issue. Do you have more comments regarding this patch series ? Thanks.

BRs,

Yifan

*From:* Zhu, James <[email protected]>
*Sent:* Wednesday, September 29, 2021 9:19 PM
*To:* Kuehling, Felix <[email protected]>; Zhang, Yifan <[email protected]>; [email protected] *Subject:* Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[AMD Official Use Only]

H Felix,

Since the previous patch can help on PCO suspend/resume hung issue. Let me work with YiFan to see if

there is proper way to cover both cases.

Thanks & Best Regards!

James Zhu

------------------------------------------------------------------------

*From:*Kuehling, Felix <[email protected] <mailto:[email protected]>>
*Sent:* Tuesday, September 28, 2021 11:41 AM
*To:* Zhang, Yifan <[email protected] <mailto:[email protected]>>; [email protected] <mailto:[email protected]> <[email protected] <mailto:[email protected]>>; Zhu, James <[email protected] <mailto:[email protected]>>
*Subject:* Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[+James]

This basically undoes James's change "drm/amdgpu: move iommu_resume before ip init/resume". I assume James made his change for a reason. Can you please discuss the issue with him and determine a solution that solves both your problem and his?

If James' patch series was a mistake, I'd prefer to revert his patches, because his patches complicated the initialization sequence and exposed the iommu init sequence in amdgpu.

Thanks,
  Felix

Am 2021-09-28 um 4:28 a.m. schrieb Yifan Zhang:

Quoted 10 lines

This patch is to fix clinfo failure in Raven/Picasso:

Number of platforms: 1
   Platform Profile: FULL_PROFILE
   Platform Version: OpenCL 2.2 AMD-APP (3364.0) Platform Name: AMD Accelerated Parallel Processing Platform Vendor: Advanced Micro Devices, Inc. Platform Extensions: cl_khr_icd cl_amd_event_callback

   Platform Name: AMD Accelerated Parallel Processing Number of

devices: 0

Quoted 2 lines

<mailto:[email protected]>>

Review

Quoted 5 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

  1 file changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 4 lines

index 4c8f2f4647c0..89ed9b091386 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -2393,10 +2393,6 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
         if (r)
                 goto init_failed;


-     r = amdgpu_amdkfd_resume_iommu(adev); -     if (r)
-             goto init_failed;
-
        r = amdgpu_device_ip_hw_init_phase1(adev); if (r)
                goto init_failed;

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -2435,6 +2431,10 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
         if (!adev->gmc.xgmi.pending_reset)
                 amdgpu_amdkfd_device_init(adev);


+     r = amdgpu_amdkfd_resume_iommu(adev);
+     if (r)
+             goto init_failed;
+
        amdgpu_fru_get_product_info(adev);

  init_failed:

Reviewed-by Tested-by Acked-by Felix Kuehling
#6 lore raw

Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[AMD Official Use Only]

Hi Flelix,

I have tested YiFan's patch and pco s3 test can pass.

The original s3 issue always occurred on resume, And YiFan's patches are only related to initialization.

Hi YiFan,

Thanks & Best Regards!

James Zhu

________________________________
From: Kuehling, Felix <[email protected]>
Sent: Monday, October 4, 2021 11:00 AM
To: Zhang, Yifan <[email protected]>; Zhu, James <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

I'm trying to understand what the end result is after James' and your patches. If I'm reading it correctly, we now initialize IOMMUv2 after kfd_device_init during initialization, but before kfd_device_init during resume from S3. Is that the correct understanding?

My concern is, that we may run into related problems again if the root cause and the mechanism of the fix are poorly understood. Do you have an explanation why this different sequence is needed during init and resume?

That said, given that your patches are tested and reviewed by James, you can add my Acked-by to both patches. The series is

Thanks,
Felix

Am 2021-10-04 um 5:42 a.m. schrieb Zhang, Yifan:

Quoted 130 lines

[AMD Official Use Only]

Hi Felix,

After sync w/ James, we agree that this patch series could fix both our problems, and he verified this patch series will not cause regression of his previous issue. Do you have more comments regarding this patch series ? Thanks.

BRs,

Yifan

*From:* Zhu, James <[email protected]>
*Sent:* Wednesday, September 29, 2021 9:19 PM
*To:* Kuehling, Felix <[email protected]>; Zhang, Yifan <[email protected]>; [email protected] *Subject:* Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[AMD Official Use Only]

H Felix,

Since the previous patch can help on PCO suspend/resume hung issue. Let me work with YiFan to see if

there is proper way to cover both cases.

Thanks & Best Regards!

James Zhu

------------------------------------------------------------------------

*From:*Kuehling, Felix <[email protected] <mailto:[email protected]>>
*Sent:* Tuesday, September 28, 2021 11:41 AM
*To:* Zhang, Yifan <[email protected] <mailto:[email protected]>>; [email protected] <mailto:[email protected]> <[email protected] <mailto:[email protected]>>; Zhu, James <[email protected] <mailto:[email protected]>>
*Subject:* Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[+James]

This basically undoes James's change "drm/amdgpu: move iommu_resume before ip init/resume". I assume James made his change for a reason. Can you please discuss the issue with him and determine a solution that solves both your problem and his?

If James' patch series was a mistake, I'd prefer to revert his patches, because his patches complicated the initialization sequence and exposed the iommu init sequence in amdgpu.

Thanks,
Felix

Am 2021-09-28 um 4:28 a.m. schrieb Yifan Zhang:

Quoted 10 lines

This patch is to fix clinfo failure in Raven/Picasso:

Number of platforms: 1
Platform Profile: FULL_PROFILE
Platform Version: OpenCL 2.2 AMD-APP (3364.0) Platform Name: AMD Accelerated Parallel Processing Platform Vendor: Advanced Micro Devices, Inc. Platform Extensions: cl_khr_icd cl_amd_event_callback

Platform Name: AMD Accelerated Parallel Processing Number of

devices: 0

Quoted 2 lines

<mailto:[email protected]>>

Review

Quoted 5 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 4 lines

index 4c8f2f4647c0..89ed9b091386 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -2393,10 +2393,6 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
       if (r)
               goto init_failed;
 
-     r = amdgpu_amdkfd_resume_iommu(adev);
-     if (r)
-             goto init_failed;
-
       r = amdgpu_device_ip_hw_init_phase1(adev);
       if (r)
               goto init_failed;
@@ -2435,6 +2431,10 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
       if (!adev->gmc.xgmi.pending_reset)
               amdgpu_amdkfd_device_init(adev);
 
+     r = amdgpu_amdkfd_resume_iommu(adev);
+     if (r)
+             goto init_failed;
+
       amdgpu_fru_get_product_info(adev);
 
 init_failed:
#7 lore raw

Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

In reply to Yifan Zhang

my kernel config CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y.
linux kernel 5.15rc2 "drm/amdgpu: move iommu_resume before ip init/resume" cause my amd 3400g suspend to disk resume failed, have to press power button to force shutdown. linux kernel 5.15rc5 "drm/amdgpu: init iommu after amdkfd device init" cause my amd 3400g blackscreen when boot enter my userspace.
i need revert "drm/amdgpu: init iommu after amdkfd device init" and "drm/amdgpu: move iommu_resume before ip init/resume" for my userspace, running androidx86 with mesa21.3 on amdgpu.

#8 lore raw

Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

drm/amdgpu: init iommu after amdkfd device init
but CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y

[    0.203386] AMD-Vi: AMD IOMMUv2 driver by Joerg Roedel <[email protected]>
[    0.203387] AMD-Vi: AMD IOMMUv2 functionality not available on this system
[    7.622052] kfd kfd: amdgpu: Allocated 3969056 bytes on gart
[    7.622128] kfd kfd: amdgpu: error getting iommu info. is the iommu enabled?
[    7.622129] kfd kfd: amdgpu: Error initializing iommuv2
[    7.622430] kfd kfd: amdgpu: device 1002:15d8 NOT added due to errors

2021-10-11 14:13 GMT+08:00, youling257 <[email protected]>:

Quoted 10 lines

my kernel config CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y.
linux kernel 5.15rc2 "drm/amdgpu: move iommu_resume before ip init/resume" cause my amd 3400g suspend to disk resume failed, have to press power button to force shutdown.
linux kernel 5.15rc5 "drm/amdgpu: init iommu after amdkfd device init" cause my amd 3400g blackscreen when boot enter my userspace.
i need revert "drm/amdgpu: init iommu after amdkfd device init" and "drm/amdgpu: move iommu_resume before ip init/resume" for my userspace, running androidx86 with mesa21.3 on amdgpu.

#9 lore raw

RE: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[AMD Official Use Only]

Hi youling,

Would you please send out the full dmesg ?

BRs,
Yifan

-----Original Message-----
From: youling 257 <[email protected]>
Sent: Monday, October 11, 2021 2:18 PM
To: Zhang, Yifan <[email protected]>
Cc: Kuehling, Felix <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

drm/amdgpu: init iommu after amdkfd device init but CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y

[    0.203386] AMD-Vi: AMD IOMMUv2 driver by Joerg Roedel <[email protected]>
[    0.203387] AMD-Vi: AMD IOMMUv2 functionality not available on this system
[    7.622052] kfd kfd: amdgpu: Allocated 3969056 bytes on gart
[    7.622128] kfd kfd: amdgpu: error getting iommu info. is the iommu enabled?
[    7.622129] kfd kfd: amdgpu: Error initializing iommuv2
[    7.622430] kfd kfd: amdgpu: device 1002:15d8 NOT added due to errors

2021-10-11 14:13 GMT+08:00, youling257 <[email protected]>:

Quoted 10 lines

my kernel config CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y. linux kernel 5.15rc2 "drm/amdgpu: move iommu_resume before ip init/resume" cause my amd 3400g suspend to disk resume failed, have to press power button to force shutdown.
linux kernel 5.15rc5 "drm/amdgpu: init iommu after amdkfd device init" cause my amd 3400g blackscreen when boot enter my userspace.
i need revert "drm/amdgpu: init iommu after amdkfd device init" and "drm/amdgpu: move iommu_resume before ip init/resume" for my userspace, running androidx86 with mesa21.3 on amdgpu.

#10 lore raw

RE: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

In reply to youling 257

[Public]

Hi youling,

Would you pls try this patch ?

BRs,
Yifan

-----Original Message-----
From: youling 257 <[email protected]>
Sent: Monday, October 11, 2021 2:18 PM
To: Zhang, Yifan <[email protected]>
Cc: Kuehling, Felix <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

drm/amdgpu: init iommu after amdkfd device init but CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y

[    0.203386] AMD-Vi: AMD IOMMUv2 driver by Joerg Roedel <[email protected]>
[    0.203387] AMD-Vi: AMD IOMMUv2 functionality not available on this system
[    7.622052] kfd kfd: amdgpu: Allocated 3969056 bytes on gart
[    7.622128] kfd kfd: amdgpu: error getting iommu info. is the iommu enabled?
[    7.622129] kfd kfd: amdgpu: Error initializing iommuv2
[    7.622430] kfd kfd: amdgpu: device 1002:15d8 NOT added due to errors

2021-10-11 14:13 GMT+08:00, youling257 <[email protected]>:

Quoted 10 lines

my kernel config CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y. linux kernel 5.15rc2 "drm/amdgpu: move iommu_resume before ip init/resume" cause my amd 3400g suspend to disk resume failed, have to press power button to force shutdown.
linux kernel 5.15rc5 "drm/amdgpu: init iommu after amdkfd device init" cause my amd 3400g blackscreen when boot enter my userspace.
i need revert "drm/amdgpu: init iommu after amdkfd device init" and "drm/amdgpu: move iommu_resume before ip init/resume" for my userspace, running androidx86 with mesa21.3 on amdgpu.

From 5fe678b940c95608b52ff9145bc8fe761e0cbaec Mon Sep 17 00:00:00 2001
From: Yifan Zhang <[email protected]>
Date: Mon, 11 Oct 2021 17:53:15 +0800
Subject: [PATCH] drm/amdkfd: fix boot/resume error when iommuv2 disabled in
bios

draft patch to fix the issue.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ----
 drivers/gpu/drm/amd/amdkfd/kfd_device.c    | 4 ++++
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
index af9bdf16eefd..9dfcef2015c8 100644
@@ -2432,10 +2432,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 	if (!adev->gmc.xgmi.pending_reset)
 		amdgpu_amdkfd_device_init(adev);
 
-	r = amdgpu_amdkfd_resume_iommu(adev);
-	if (r)
-		goto init_failed;
-
 	amdgpu_fru_get_product_info(adev);
 
 init_failed:
drivers/gpu/drm/amd/amdkfd/kfd_device.c +4 -0
index 4a416231b24c..1fadc9fb168d 100644
@@ -916,10 +916,14 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
 	kfd_double_confirm_iommu_support(kfd);
 
 	if (kfd_iommu_device_init(kfd)) {
+		kfd->use_iommu_v2 = false;
 		dev_err(kfd_device, "Error initializing iommuv2\n");
 		goto device_iommu_error;
 	}
 
+	if(kgd2kfd_resume_iommu(kfd))
+		goto device_iommu_error;
+
 	kfd_cwsr_init(kfd);
 
 	svm_migrate_init((struct amdgpu_device *)kfd->kgd);
Signature · 1 line
2.25.1
#11 lore raw

Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

test this patch can fix my boot and suspend problem.

2021-10-11 18:03 GMT+08:00, Zhang, Yifan <[email protected]>:

Quoted 40 lines

[Public]

Hi youling,

Would you pls try this patch ?

BRs,
Yifan

-----Original Message-----
From: youling 257 <[email protected]>
Sent: Monday, October 11, 2021 2:18 PM
To: Zhang, Yifan <[email protected]>
Cc: Kuehling, Felix <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

drm/amdgpu: init iommu after amdkfd device init but CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y

[    0.203386] AMD-Vi: AMD IOMMUv2 driver by Joerg Roedel <[email protected]>
[    0.203387] AMD-Vi: AMD IOMMUv2 functionality not available on this
system
[    7.622052] kfd kfd: amdgpu: Allocated 3969056 bytes on gart
[    7.622128] kfd kfd: amdgpu: error getting iommu info. is the iommu
enabled?
[    7.622129] kfd kfd: amdgpu: Error initializing iommuv2
[    7.622430] kfd kfd: amdgpu: device 1002:15d8 NOT added due to errors

2021-10-11 14:13 GMT+08:00, youling257 <[email protected]>:

Quoted 11 lines

my kernel config CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y. linux kernel 5.15rc2 "drm/amdgpu: move iommu_resume before ip init/resume"
cause my amd 3400g suspend to disk resume failed, have to press power button to force shutdown.
linux kernel 5.15rc5 "drm/amdgpu: init iommu after amdkfd device init" cause my amd 3400g blackscreen when boot enter my userspace. i need revert "drm/amdgpu: init iommu after amdkfd device init" and "drm/amdgpu: move iommu_resume before ip init/resume" for my userspace, running androidx86 with mesa21.3 on amdgpu.

#12 lore raw

RE: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

[AMD Official Use Only]

Great. Thanks for testing.

-----Original Message-----
From: youling 257 <[email protected]>
Sent: Monday, October 11, 2021 6:20 PM
To: Zhang, Yifan <[email protected]>
Cc: Kuehling, Felix <[email protected]>; [email protected]; Zhu, James <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

test this patch can fix my boot and suspend problem.

2021-10-11 18:03 GMT+08:00, Zhang, Yifan <[email protected]>:

Quoted 42 lines

[Public]

Hi youling,

Would you pls try this patch ?

BRs,
Yifan

-----Original Message-----
From: youling 257 <[email protected]>
Sent: Monday, October 11, 2021 2:18 PM
To: Zhang, Yifan <[email protected]>
Cc: Kuehling, Felix <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: init iommu after amdkfd device init

drm/amdgpu: init iommu after amdkfd device init but CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y

[    0.203386] AMD-Vi: AMD IOMMUv2 driver by Joerg Roedel <[email protected]>
[    0.203387] AMD-Vi: AMD IOMMUv2 functionality not available on this
system
[    7.622052] kfd kfd: amdgpu: Allocated 3969056 bytes on gart
[    7.622128] kfd kfd: amdgpu: error getting iommu info. is the iommu
enabled?
[    7.622129] kfd kfd: amdgpu: Error initializing iommuv2
[    7.622430] kfd kfd: amdgpu: device 1002:15d8 NOT added due to errors

2021-10-11 14:13 GMT+08:00, youling257 <[email protected]>:

Quoted 11 lines

my kernel config CONFIG_AMD_IOMMU=y CONFIG_AMD_IOMMU_V2=y. linux kernel 5.15rc2 "drm/amdgpu: move iommu_resume before ip init/resume"
cause my amd 3400g suspend to disk resume failed, have to press power button to force shutdown.
linux kernel 5.15rc5 "drm/amdgpu: init iommu after amdkfd device init" cause my amd 3400g blackscreen when boot enter my userspace. i need revert "drm/amdgpu: init iommu after amdkfd device init" and "drm/amdgpu: move iommu_resume before ip init/resume" for my userspace, running androidx86 with mesa21.3 on amdgpu.

Reviewed-by on v1 1/2
#13 lore raw
In reply to Yifan Zhang

[AMD Official Use Only]

James Zhu

________________________________
From: amd-gfx <[email protected]> on behalf of Yifan Zhang <[email protected]>
Sent: Tuesday, September 28, 2021 4:28 AM
To: [email protected] <[email protected]>
Cc: Kuehling, Felix <[email protected]>; Zhang, Yifan <[email protected]>
Subject: [PATCH 1/2] drm/amdkfd: remove redundant iommu cleanup code

kfd_resume doesn't involve iommu operation, remove redundant iommu cleanup code.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +1 -7
index c2a4d920da40..4a416231b24c 100644
@@ -1085,18 +1085,12 @@ static int kfd_resume(struct kfd_dev *kfd)
         int err = 0;
 
         err = kfd->dqm->ops.start(kfd->dqm);
-       if (err) {
+       if (err)
                 dev_err(kfd_device,
                         "Error starting queue manager for device %x:%x\n",
                         kfd->pdev->vendor, kfd->pdev->device);
-               goto dqm_start_error;
-       }
 
         return err;
-
-dqm_start_error:
-       kfd_iommu_suspend(kfd);
-       return err;
 }
 
 static inline void kfd_queue_work(struct workqueue_struct *wq,

--
2.25.1