[PATCH] drm/amd/amdgpu: Cancel delay work before unload driver

Christian König ckoenig.leichtzumerken at gmail.com
Thu Nov 7 09:35:29 UTC 2019


Am 07.11.19 um 08:36 schrieb Jesse Zhang:
> move cancel_delayed_work_sync() to the begining
> of amdgpu_device_fini() to cancel unfinished
> works which are no longer needed.
>
> Change-Id: I8831935b797c78b971aa7233697c36140374f1ac
> Signed-off-by: Jesse Zhang <zhexi.zhang at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 ++++++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c     | 2 ++
>   2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index f0ad05d..5b8af69 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -3115,6 +3115,12 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>   
>   	DRM_INFO("amdgpu: finishing device.\n");
>   	adev->shutdown = true;
> +
> +	/* Cancel unfinished delay work before unload driver */
> +	cancel_delayed_work_sync(&adev->delayed_init_work);

Goes into the right direction, but I would rather go with 
flush_delayed_work() to make sure the delayed init work is actually run.

> +	cancel_delayed_work_sync(&adev->uvd.idle_work);
> +	cancel_delayed_work_sync(&adev->vce.idle_work);
> +

This belongs into the UVD/VCE code since the idle work handlers are not 
initialized if the device doesn't have an UVD/VCE block.

>   	/* disable all interrupts */
>   	amdgpu_irq_disable_all(adev);
>   	if (adev->mode_info.mode_config_initialized){
> @@ -3134,7 +3140,6 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>   		adev->firmware.gpu_info_fw = NULL;
>   	}
>   	adev->accel_working = false;
> -	cancel_delayed_work_sync(&adev->delayed_init_work);
>   	/* free i2c buses */
>   	if (!amdgpu_device_has_dc_support(adev))
>   		amdgpu_i2c_fini(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
> index d121bbd..fc6c949 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
> @@ -364,6 +364,8 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev)
>   		struct amdgpu_ring *ring = adev->rings[i];
>   		long tmo;
>   
> +		if (adev->shutdown)
> +			return 0;

That looks rather superfluous, is that really necessary?

Regards,
Christian.

>   		/* KIQ rings don't have an IB test because we never submit IBs
>   		 * to them and they have no interrupt support.
>   		 */



More information about the amd-gfx mailing list