diff mbox series

[1/4] drm/amdgpu: Move flush VCE idle_work during HW fini

Message ID 20210824210120.49812-2-andrey.grodzovsky@amd.com (mailing list archive)
State New, archived
Headers show
Series Various fixes to pass libdrm hotunplug tests | expand

Commit Message

Andrey Grodzovsky Aug. 24, 2021, 9:01 p.m. UTC
Attepmts to powergate after device is removed lead to crash.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 1 -
 drivers/gpu/drm/amd/amdgpu/vce_v2_0.c   | 4 ++++
 drivers/gpu/drm/amd/amdgpu/vce_v3_0.c   | 5 ++++-
 drivers/gpu/drm/amd/amdgpu/vce_v4_0.c   | 2 ++
 4 files changed, 10 insertions(+), 2 deletions(-)

Comments

Evan Quan Aug. 25, 2021, 1:41 a.m. UTC | #1
[AMD Official Use Only]

Hi Andrey,

I sent out a similar patch set to address S3 issue. And I believe it should be able to address the issue here too.
https://lists.freedesktop.org/archives/amd-gfx/2021-August/067972.html
https://lists.freedesktop.org/archives/amd-gfx/2021-August/067967.html

BR
Evan
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of
> Andrey Grodzovsky
> Sent: Wednesday, August 25, 2021 5:01 AM
> To: dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org
> Cc: ckoenig.leichtzumerken@gmail.com; Grodzovsky, Andrey
> <Andrey.Grodzovsky@amd.com>
> Subject: [PATCH 1/4] drm/amdgpu: Move flush VCE idle_work during HW fini
> 
> Attepmts to powergate after device is removed lead to crash.
> 
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 1 -
>  drivers/gpu/drm/amd/amdgpu/vce_v2_0.c   | 4 ++++
>  drivers/gpu/drm/amd/amdgpu/vce_v3_0.c   | 5 ++++-
>  drivers/gpu/drm/amd/amdgpu/vce_v4_0.c   | 2 ++
>  4 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> index 1ae7f824adc7..8e8dee9fac9f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> @@ -218,7 +218,6 @@ int amdgpu_vce_sw_fini(struct amdgpu_device
> *adev)
>  	if (adev->vce.vcpu_bo == NULL)
>  		return 0;
> 
> -	cancel_delayed_work_sync(&adev->vce.idle_work);
>  	drm_sched_entity_destroy(&adev->vce.entity);
> 
>  	amdgpu_bo_free_kernel(&adev->vce.vcpu_bo, &adev-
> >vce.gpu_addr,
> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> index c7d28c169be5..716dfdd020b4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> @@ -477,6 +477,10 @@ static int vce_v2_0_hw_init(void *handle)
> 
>  static int vce_v2_0_hw_fini(void *handle)
>  {
> +	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> +
> +	cancel_delayed_work_sync(&adev->vce.idle_work);
> +
>  	return 0;
>  }
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
> b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
> index 3b82fb289ef6..49581c6e0cea 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
> @@ -495,7 +495,10 @@ static int vce_v3_0_hw_fini(void *handle)
>  		return r;
> 
>  	vce_v3_0_stop(adev);
> -	return vce_v3_0_set_clockgating_state(adev,
> AMD_CG_STATE_GATE);
> +	r =  vce_v3_0_set_clockgating_state(adev, AMD_CG_STATE_GATE);
> +	cancel_delayed_work_sync(&adev->vce.idle_work);
> +
> +	return r;
>  }
> 
>  static int vce_v3_0_suspend(void *handle)
> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> index 90910d19db12..3297405fd32d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> @@ -550,6 +550,8 @@ static int vce_v4_0_hw_fini(void *handle)
>  		DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
>  	}
> 
> +	cancel_delayed_work_sync(&adev->vce.idle_work);
> +
>  	return 0;
>  }
> 
> --
> 2.25.1
Andrey Grodzovsky Aug. 25, 2021, 3:20 a.m. UTC | #2
Right, they will cover my use case, when are they landing ? I rebased 
today and haven't seen them.

Andrey

On 2021-08-24 9:41 p.m., Quan, Evan wrote:
> [AMD Official Use Only]
>
> Hi Andrey,
>
> I sent out a similar patch set to address S3 issue. And I believe it should be able to address the issue here too.
> https://lists.freedesktop.org/archives/amd-gfx/2021-August/067972.html
> https://lists.freedesktop.org/archives/amd-gfx/2021-August/067967.html
>
> BR
> Evan
>> -----Original Message-----
>> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of
>> Andrey Grodzovsky
>> Sent: Wednesday, August 25, 2021 5:01 AM
>> To: dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org
>> Cc: ckoenig.leichtzumerken@gmail.com; Grodzovsky, Andrey
>> <Andrey.Grodzovsky@amd.com>
>> Subject: [PATCH 1/4] drm/amdgpu: Move flush VCE idle_work during HW fini
>>
>> Attepmts to powergate after device is removed lead to crash.
>>
>> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 1 -
>>   drivers/gpu/drm/amd/amdgpu/vce_v2_0.c   | 4 ++++
>>   drivers/gpu/drm/amd/amdgpu/vce_v3_0.c   | 5 ++++-
>>   drivers/gpu/drm/amd/amdgpu/vce_v4_0.c   | 2 ++
>>   4 files changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
>> index 1ae7f824adc7..8e8dee9fac9f 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
>> @@ -218,7 +218,6 @@ int amdgpu_vce_sw_fini(struct amdgpu_device
>> *adev)
>>   	if (adev->vce.vcpu_bo == NULL)
>>   		return 0;
>>
>> -	cancel_delayed_work_sync(&adev->vce.idle_work);
>>   	drm_sched_entity_destroy(&adev->vce.entity);
>>
>>   	amdgpu_bo_free_kernel(&adev->vce.vcpu_bo, &adev-
>>> vce.gpu_addr,
>> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
>> b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
>> index c7d28c169be5..716dfdd020b4 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
>> @@ -477,6 +477,10 @@ static int vce_v2_0_hw_init(void *handle)
>>
>>   static int vce_v2_0_hw_fini(void *handle)
>>   {
>> +	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>> +
>> +	cancel_delayed_work_sync(&adev->vce.idle_work);
>> +
>>   	return 0;
>>   }
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
>> b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
>> index 3b82fb289ef6..49581c6e0cea 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
>> @@ -495,7 +495,10 @@ static int vce_v3_0_hw_fini(void *handle)
>>   		return r;
>>
>>   	vce_v3_0_stop(adev);
>> -	return vce_v3_0_set_clockgating_state(adev,
>> AMD_CG_STATE_GATE);
>> +	r =  vce_v3_0_set_clockgating_state(adev, AMD_CG_STATE_GATE);
>> +	cancel_delayed_work_sync(&adev->vce.idle_work);
>> +
>> +	return r;
>>   }
>>
>>   static int vce_v3_0_suspend(void *handle)
>> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
>> b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
>> index 90910d19db12..3297405fd32d 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
>> @@ -550,6 +550,8 @@ static int vce_v4_0_hw_fini(void *handle)
>>   		DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
>>   	}
>>
>> +	cancel_delayed_work_sync(&adev->vce.idle_work);
>> +
>>   	return 0;
>>   }
>>
>> --
>> 2.25.1
Evan Quan Aug. 25, 2021, 3:56 a.m. UTC | #3
[AMD Official Use Only]

Just landed.

Thanks,
Evan
> -----Original Message-----
> From: Grodzovsky, Andrey <Andrey.Grodzovsky@amd.com>
> Sent: Wednesday, August 25, 2021 11:20 AM
> To: Quan, Evan <Evan.Quan@amd.com>; dri-devel@lists.freedesktop.org;
> amd-gfx@lists.freedesktop.org
> Cc: ckoenig.leichtzumerken@gmail.com
> Subject: Re: [PATCH 1/4] drm/amdgpu: Move flush VCE idle_work during HW
> fini
> 
> Right, they will cover my use case, when are they landing ? I rebased today
> and haven't seen them.
> 
> Andrey
> 
> On 2021-08-24 9:41 p.m., Quan, Evan wrote:
> > [AMD Official Use Only]
> >
> > Hi Andrey,
> >
> > I sent out a similar patch set to address S3 issue. And I believe it should be
> able to address the issue here too.
> > https://lists.freedesktop.org/archives/amd-gfx/2021-August/067972.html
> > https://lists.freedesktop.org/archives/amd-gfx/2021-August/067967.html
> >
> > BR
> > Evan
> >> -----Original Message-----
> >> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of
> >> Andrey Grodzovsky
> >> Sent: Wednesday, August 25, 2021 5:01 AM
> >> To: dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org
> >> Cc: ckoenig.leichtzumerken@gmail.com; Grodzovsky, Andrey
> >> <Andrey.Grodzovsky@amd.com>
> >> Subject: [PATCH 1/4] drm/amdgpu: Move flush VCE idle_work during HW
> >> fini
> >>
> >> Attepmts to powergate after device is removed lead to crash.
> >>
> >> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 1 -
> >>   drivers/gpu/drm/amd/amdgpu/vce_v2_0.c   | 4 ++++
> >>   drivers/gpu/drm/amd/amdgpu/vce_v3_0.c   | 5 ++++-
> >>   drivers/gpu/drm/amd/amdgpu/vce_v4_0.c   | 2 ++
> >>   4 files changed, 10 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> >> index 1ae7f824adc7..8e8dee9fac9f 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> >> @@ -218,7 +218,6 @@ int amdgpu_vce_sw_fini(struct amdgpu_device
> >> *adev)
> >>   	if (adev->vce.vcpu_bo == NULL)
> >>   		return 0;
> >>
> >> -	cancel_delayed_work_sync(&adev->vce.idle_work);
> >>   	drm_sched_entity_destroy(&adev->vce.entity);
> >>
> >>   	amdgpu_bo_free_kernel(&adev->vce.vcpu_bo, &adev-
> >>> vce.gpu_addr,
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> >> b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> >> index c7d28c169be5..716dfdd020b4 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> >> @@ -477,6 +477,10 @@ static int vce_v2_0_hw_init(void *handle)
> >>
> >>   static int vce_v2_0_hw_fini(void *handle)
> >>   {
> >> +	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> >> +
> >> +	cancel_delayed_work_sync(&adev->vce.idle_work);
> >> +
> >>   	return 0;
> >>   }
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
> >> b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
> >> index 3b82fb289ef6..49581c6e0cea 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
> >> @@ -495,7 +495,10 @@ static int vce_v3_0_hw_fini(void *handle)
> >>   		return r;
> >>
> >>   	vce_v3_0_stop(adev);
> >> -	return vce_v3_0_set_clockgating_state(adev,
> >> AMD_CG_STATE_GATE);
> >> +	r =  vce_v3_0_set_clockgating_state(adev, AMD_CG_STATE_GATE);
> >> +	cancel_delayed_work_sync(&adev->vce.idle_work);
> >> +
> >> +	return r;
> >>   }
> >>
> >>   static int vce_v3_0_suspend(void *handle) diff --git
> >> a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> >> b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> >> index 90910d19db12..3297405fd32d 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> >> @@ -550,6 +550,8 @@ static int vce_v4_0_hw_fini(void *handle)
> >>   		DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
> >>   	}
> >>
> >> +	cancel_delayed_work_sync(&adev->vce.idle_work);
> >> +
> >>   	return 0;
> >>   }
> >>
> >> --
> >> 2.25.1
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
index 1ae7f824adc7..8e8dee9fac9f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -218,7 +218,6 @@  int amdgpu_vce_sw_fini(struct amdgpu_device *adev)
 	if (adev->vce.vcpu_bo == NULL)
 		return 0;
 
-	cancel_delayed_work_sync(&adev->vce.idle_work);
 	drm_sched_entity_destroy(&adev->vce.entity);
 
 	amdgpu_bo_free_kernel(&adev->vce.vcpu_bo, &adev->vce.gpu_addr,
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
index c7d28c169be5..716dfdd020b4 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
@@ -477,6 +477,10 @@  static int vce_v2_0_hw_init(void *handle)
 
 static int vce_v2_0_hw_fini(void *handle)
 {
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+	cancel_delayed_work_sync(&adev->vce.idle_work);
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
index 3b82fb289ef6..49581c6e0cea 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
@@ -495,7 +495,10 @@  static int vce_v3_0_hw_fini(void *handle)
 		return r;
 
 	vce_v3_0_stop(adev);
-	return vce_v3_0_set_clockgating_state(adev, AMD_CG_STATE_GATE);
+	r =  vce_v3_0_set_clockgating_state(adev, AMD_CG_STATE_GATE);
+	cancel_delayed_work_sync(&adev->vce.idle_work);
+
+	return r;
 }
 
 static int vce_v3_0_suspend(void *handle)
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
index 90910d19db12..3297405fd32d 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
@@ -550,6 +550,8 @@  static int vce_v4_0_hw_fini(void *handle)
 		DRM_DEBUG("For SRIOV client, shouldn't do anything.\n");
 	}
 
+	cancel_delayed_work_sync(&adev->vce.idle_work);
+
 	return 0;
 }