All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/amdgpu: Cancel delay work before unload driver
@ 2019-11-07  7:36 ` Jesse Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Jesse Zhang @ 2019-11-07  7:36 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: 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@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);
+	cancel_delayed_work_sync(&adev->uvd.idle_work);
+	cancel_delayed_work_sync(&adev->vce.idle_work);
+
 	/* 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;
 		/* KIQ rings don't have an IB test because we never submit IBs
 		 * to them and they have no interrupt support.
 		 */
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH] drm/amd/amdgpu: Cancel delay work before unload driver
@ 2019-11-07  7:36 ` Jesse Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Jesse Zhang @ 2019-11-07  7:36 UTC (permalink / raw)
  To: amd-gfx; +Cc: 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@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);
+	cancel_delayed_work_sync(&adev->uvd.idle_work);
+	cancel_delayed_work_sync(&adev->vce.idle_work);
+
 	/* 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;
 		/* KIQ rings don't have an IB test because we never submit IBs
 		 * to them and they have no interrupt support.
 		 */
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amd/amdgpu: Cancel delay work before unload driver
@ 2019-11-07  9:35     ` Christian König
  0 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2019-11-07  9:35 UTC (permalink / raw)
  To: Jesse Zhang, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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@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.
>   		 */

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amd/amdgpu: Cancel delay work before unload driver
@ 2019-11-07  9:35     ` Christian König
  0 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2019-11-07  9:35 UTC (permalink / raw)
  To: Jesse Zhang, amd-gfx

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@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.
>   		 */

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2019-11-07  9:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07  7:36 [PATCH] drm/amd/amdgpu: Cancel delay work before unload driver Jesse Zhang
2019-11-07  7:36 ` Jesse Zhang
     [not found] ` <1573112184-14195-1-git-send-email-zhexi.zhang-5C7GfCeVMHo@public.gmane.org>
2019-11-07  9:35   ` Christian König
2019-11-07  9:35     ` Christian König

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.