All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/amdgpu/gfx8: fix driver reload with KIQ
@ 2017-07-04  6:00 Alex Deucher
       [not found] ` <1499148001-11497-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Deucher @ 2017-07-04  6:00 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Drop the deactivation in KIQ init and drop the KCQ disabling
via KIQ.  We disable the MEC shortly after anyway, so there is
no need to wait for all of this.  Doing so seems to leave the
MEC in a bad way.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 69 +----------------------------------
 1 file changed, 1 insertion(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 1ca642b..4bb12ee 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -4636,56 +4636,6 @@ static int gfx_v8_0_kiq_kcq_enable(struct amdgpu_device *adev)
 	return r;
 }
 
-static int gfx_v8_0_kiq_kcq_disable(struct amdgpu_device *adev)
-{
-	struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring;
-	uint32_t scratch, tmp = 0;
-	int r, i;
-
-	r = amdgpu_gfx_scratch_get(adev, &scratch);
-	if (r) {
-		DRM_ERROR("Failed to get scratch reg (%d).\n", r);
-		return r;
-	}
-	WREG32(scratch, 0xCAFEDEAD);
-
-	r = amdgpu_ring_alloc(kiq_ring, 6 + 3);
-	if (r) {
-		DRM_ERROR("Failed to lock KIQ (%d).\n", r);
-		amdgpu_gfx_scratch_free(adev, scratch);
-		return r;
-	}
-	/* unmap queues */
-	amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_UNMAP_QUEUES, 4));
-	amdgpu_ring_write(kiq_ring,
-			  PACKET3_UNMAP_QUEUES_ACTION(1)| /* RESET_QUEUES */
-			  PACKET3_UNMAP_QUEUES_QUEUE_SEL(2)); /* select all queues */
-	amdgpu_ring_write(kiq_ring, 0);
-	amdgpu_ring_write(kiq_ring, 0);
-	amdgpu_ring_write(kiq_ring, 0);
-	amdgpu_ring_write(kiq_ring, 0);
-	/* write to scratch for completion */
-	amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1));
-	amdgpu_ring_write(kiq_ring, (scratch - PACKET3_SET_UCONFIG_REG_START));
-	amdgpu_ring_write(kiq_ring, 0xDEADBEEF);
-	amdgpu_ring_commit(kiq_ring);
-
-	for (i = 0; i < adev->usec_timeout; i++) {
-		tmp = RREG32(scratch);
-		if (tmp == 0xDEADBEEF)
-			break;
-		DRM_UDELAY(1);
-	}
-	if (i >= adev->usec_timeout) {
-		DRM_ERROR("KCQ disabled failed (scratch(0x%04X)=0x%08X)\n",
-			  scratch, tmp);
-		r = -EINVAL;
-	}
-	amdgpu_gfx_scratch_free(adev, scratch);
-
-	return r;
-}
-
 static int gfx_v8_0_deactivate_hqd(struct amdgpu_device *adev, u32 req)
 {
 	int i, r = 0;
@@ -4891,7 +4841,6 @@ int gfx_v8_0_mqd_commit(struct amdgpu_device *adev,
 
 static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
 {
-	int r = 0;
 	struct amdgpu_device *adev = ring->adev;
 	struct vi_mqd *mqd = ring->mqd_ptr;
 	int mqd_idx = AMDGPU_MAX_COMPUTE_RINGS;
@@ -4908,11 +4857,6 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
 		amdgpu_ring_clear_ring(ring);
 		mutex_lock(&adev->srbm_mutex);
 		vi_srbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
-		r = gfx_v8_0_deactivate_hqd(adev, 1);
-		if (r) {
-			dev_err(adev->dev, "failed to deactivate ring %s\n", ring->name);
-			goto out_unlock;
-		}
 		gfx_v8_0_mqd_commit(adev, mqd);
 		vi_srbm_select(adev, 0, 0, 0, 0);
 		mutex_unlock(&adev->srbm_mutex);
@@ -4923,11 +4867,6 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
 		mutex_lock(&adev->srbm_mutex);
 		vi_srbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
 		gfx_v8_0_mqd_init(ring);
-		r = gfx_v8_0_deactivate_hqd(adev, 1);
-		if (r) {
-			dev_err(adev->dev, "failed to deactivate ring %s\n", ring->name);
-			goto out_unlock;
-		}
 		gfx_v8_0_mqd_commit(adev, mqd);
 		vi_srbm_select(adev, 0, 0, 0, 0);
 		mutex_unlock(&adev->srbm_mutex);
@@ -4936,12 +4875,7 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
 			memcpy(adev->gfx.mec.mqd_backup[mqd_idx], mqd, sizeof(struct vi_mqd_allocation));
 	}
 
-	return r;
-
-out_unlock:
-	vi_srbm_select(adev, 0, 0, 0, 0);
-	mutex_unlock(&adev->srbm_mutex);
-	return r;
+	return 0;
 }
 
 static int gfx_v8_0_kcq_init_queue(struct amdgpu_ring *ring)
@@ -5145,7 +5079,6 @@ static int gfx_v8_0_hw_fini(void *handle)
 		pr_debug("For SRIOV client, shouldn't do anything.\n");
 		return 0;
 	}
-	gfx_v8_0_kiq_kcq_disable(adev);
 	gfx_v8_0_cp_enable(adev, false);
 	gfx_v8_0_rlc_stop(adev);
 
-- 
2.5.5

_______________________________________________
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 2/2] drm/amdgpu/gfx9: fix driver reload with KIQ
       [not found] ` <1499148001-11497-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2017-07-04  6:00   ` Alex Deucher
  2017-07-04  6:57   ` [PATCH 1/2] drm/amdgpu/gfx8: " Michel Dänzer
  2017-07-04  7:51   ` Christian König
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2017-07-04  6:00 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Drop the KCQ disabling via KIQ.  We disable the MEC shortly
after anyway, so there is no need to wait for all of this.
Doing so seems to leave the MEC in a bad way.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 51 -----------------------------------
 1 file changed, 51 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 2034592..3a0b69b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -2502,56 +2502,6 @@ static int gfx_v9_0_kiq_kcq_enable(struct amdgpu_device *adev)
 	return r;
 }
 
-static int gfx_v9_0_kiq_kcq_disable(struct amdgpu_device *adev)
-{
-	struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring;
-	uint32_t scratch, tmp = 0;
-	int r, i;
-
-	r = amdgpu_gfx_scratch_get(adev, &scratch);
-	if (r) {
-		DRM_ERROR("Failed to get scratch reg (%d).\n", r);
-		return r;
-	}
-	WREG32(scratch, 0xCAFEDEAD);
-
-	r = amdgpu_ring_alloc(kiq_ring, 6 + 3);
-	if (r) {
-		DRM_ERROR("Failed to lock KIQ (%d).\n", r);
-		amdgpu_gfx_scratch_free(adev, scratch);
-		return r;
-	}
-	/* unmap queues */
-	amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_UNMAP_QUEUES, 4));
-	amdgpu_ring_write(kiq_ring,
-			  PACKET3_UNMAP_QUEUES_ACTION(1)| /* RESET_QUEUES */
-			  PACKET3_UNMAP_QUEUES_QUEUE_SEL(2)); /* select all queues */
-	amdgpu_ring_write(kiq_ring, 0);
-	amdgpu_ring_write(kiq_ring, 0);
-	amdgpu_ring_write(kiq_ring, 0);
-	amdgpu_ring_write(kiq_ring, 0);
-	/* write to scratch for completion */
-	amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1));
-	amdgpu_ring_write(kiq_ring, (scratch - PACKET3_SET_UCONFIG_REG_START));
-	amdgpu_ring_write(kiq_ring, 0xDEADBEEF);
-	amdgpu_ring_commit(kiq_ring);
-
-	for (i = 0; i < adev->usec_timeout; i++) {
-		tmp = RREG32(scratch);
-		if (tmp == 0xDEADBEEF)
-			break;
-		DRM_UDELAY(1);
-	}
-	if (i >= adev->usec_timeout) {
-		DRM_ERROR("KCQ disable failed (scratch(0x%04X)=0x%08X)\n",
-			  scratch, tmp);
-		r = -EINVAL;
-	}
-	amdgpu_gfx_scratch_free(adev, scratch);
-
-	return r;
-}
-
 static int gfx_v9_0_mqd_init(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
@@ -2996,7 +2946,6 @@ static int gfx_v9_0_hw_fini(void *handle)
 		pr_debug("For SRIOV client, shouldn't do anything.\n");
 		return 0;
 	}
-	gfx_v9_0_kiq_kcq_disable(adev);
 	gfx_v9_0_cp_enable(adev, false);
 	gfx_v9_0_rlc_stop(adev);
 
-- 
2.5.5

_______________________________________________
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 1/2] drm/amdgpu/gfx8: fix driver reload with KIQ
       [not found] ` <1499148001-11497-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2017-07-04  6:00   ` [PATCH 2/2] drm/amdgpu/gfx9: " Alex Deucher
@ 2017-07-04  6:57   ` Michel Dänzer
  2017-07-04  7:51   ` Christian König
  2 siblings, 0 replies; 4+ messages in thread
From: Michel Dänzer @ 2017-07-04  6:57 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 04/07/17 03:00 PM, Alex Deucher wrote:
> Drop the deactivation in KIQ init and drop the KCQ disabling
> via KIQ.  We disable the MEC shortly after anyway, so there is
> no need to wait for all of this.  Doing so seems to leave the
> MEC in a bad way.
> 
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Tested-by: Michel Dänzer <michel.daenzer@amd.com>


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
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 1/2] drm/amdgpu/gfx8: fix driver reload with KIQ
       [not found] ` <1499148001-11497-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2017-07-04  6:00   ` [PATCH 2/2] drm/amdgpu/gfx9: " Alex Deucher
  2017-07-04  6:57   ` [PATCH 1/2] drm/amdgpu/gfx8: " Michel Dänzer
@ 2017-07-04  7:51   ` Christian König
  2 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2017-07-04  7:51 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Am 04.07.2017 um 08:00 schrieb Alex Deucher:
> Drop the deactivation in KIQ init and drop the KCQ disabling
> via KIQ.  We disable the MEC shortly after anyway, so there is
> no need to wait for all of this.  Doing so seems to leave the
> MEC in a bad way.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Acked-by: Christian König <christian.koenig@amd.com> for this series.

> ---
>   drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 69 +----------------------------------
>   1 file changed, 1 insertion(+), 68 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> index 1ca642b..4bb12ee 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> @@ -4636,56 +4636,6 @@ static int gfx_v8_0_kiq_kcq_enable(struct amdgpu_device *adev)
>   	return r;
>   }
>   
> -static int gfx_v8_0_kiq_kcq_disable(struct amdgpu_device *adev)
> -{
> -	struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring;
> -	uint32_t scratch, tmp = 0;
> -	int r, i;
> -
> -	r = amdgpu_gfx_scratch_get(adev, &scratch);
> -	if (r) {
> -		DRM_ERROR("Failed to get scratch reg (%d).\n", r);
> -		return r;
> -	}
> -	WREG32(scratch, 0xCAFEDEAD);
> -
> -	r = amdgpu_ring_alloc(kiq_ring, 6 + 3);
> -	if (r) {
> -		DRM_ERROR("Failed to lock KIQ (%d).\n", r);
> -		amdgpu_gfx_scratch_free(adev, scratch);
> -		return r;
> -	}
> -	/* unmap queues */
> -	amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_UNMAP_QUEUES, 4));
> -	amdgpu_ring_write(kiq_ring,
> -			  PACKET3_UNMAP_QUEUES_ACTION(1)| /* RESET_QUEUES */
> -			  PACKET3_UNMAP_QUEUES_QUEUE_SEL(2)); /* select all queues */
> -	amdgpu_ring_write(kiq_ring, 0);
> -	amdgpu_ring_write(kiq_ring, 0);
> -	amdgpu_ring_write(kiq_ring, 0);
> -	amdgpu_ring_write(kiq_ring, 0);
> -	/* write to scratch for completion */
> -	amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1));
> -	amdgpu_ring_write(kiq_ring, (scratch - PACKET3_SET_UCONFIG_REG_START));
> -	amdgpu_ring_write(kiq_ring, 0xDEADBEEF);
> -	amdgpu_ring_commit(kiq_ring);
> -
> -	for (i = 0; i < adev->usec_timeout; i++) {
> -		tmp = RREG32(scratch);
> -		if (tmp == 0xDEADBEEF)
> -			break;
> -		DRM_UDELAY(1);
> -	}
> -	if (i >= adev->usec_timeout) {
> -		DRM_ERROR("KCQ disabled failed (scratch(0x%04X)=0x%08X)\n",
> -			  scratch, tmp);
> -		r = -EINVAL;
> -	}
> -	amdgpu_gfx_scratch_free(adev, scratch);
> -
> -	return r;
> -}
> -
>   static int gfx_v8_0_deactivate_hqd(struct amdgpu_device *adev, u32 req)
>   {
>   	int i, r = 0;
> @@ -4891,7 +4841,6 @@ int gfx_v8_0_mqd_commit(struct amdgpu_device *adev,
>   
>   static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
>   {
> -	int r = 0;
>   	struct amdgpu_device *adev = ring->adev;
>   	struct vi_mqd *mqd = ring->mqd_ptr;
>   	int mqd_idx = AMDGPU_MAX_COMPUTE_RINGS;
> @@ -4908,11 +4857,6 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
>   		amdgpu_ring_clear_ring(ring);
>   		mutex_lock(&adev->srbm_mutex);
>   		vi_srbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
> -		r = gfx_v8_0_deactivate_hqd(adev, 1);
> -		if (r) {
> -			dev_err(adev->dev, "failed to deactivate ring %s\n", ring->name);
> -			goto out_unlock;
> -		}
>   		gfx_v8_0_mqd_commit(adev, mqd);
>   		vi_srbm_select(adev, 0, 0, 0, 0);
>   		mutex_unlock(&adev->srbm_mutex);
> @@ -4923,11 +4867,6 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
>   		mutex_lock(&adev->srbm_mutex);
>   		vi_srbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
>   		gfx_v8_0_mqd_init(ring);
> -		r = gfx_v8_0_deactivate_hqd(adev, 1);
> -		if (r) {
> -			dev_err(adev->dev, "failed to deactivate ring %s\n", ring->name);
> -			goto out_unlock;
> -		}
>   		gfx_v8_0_mqd_commit(adev, mqd);
>   		vi_srbm_select(adev, 0, 0, 0, 0);
>   		mutex_unlock(&adev->srbm_mutex);
> @@ -4936,12 +4875,7 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)
>   			memcpy(adev->gfx.mec.mqd_backup[mqd_idx], mqd, sizeof(struct vi_mqd_allocation));
>   	}
>   
> -	return r;
> -
> -out_unlock:
> -	vi_srbm_select(adev, 0, 0, 0, 0);
> -	mutex_unlock(&adev->srbm_mutex);
> -	return r;
> +	return 0;
>   }
>   
>   static int gfx_v8_0_kcq_init_queue(struct amdgpu_ring *ring)
> @@ -5145,7 +5079,6 @@ static int gfx_v8_0_hw_fini(void *handle)
>   		pr_debug("For SRIOV client, shouldn't do anything.\n");
>   		return 0;
>   	}
> -	gfx_v8_0_kiq_kcq_disable(adev);
>   	gfx_v8_0_cp_enable(adev, false);
>   	gfx_v8_0_rlc_stop(adev);
>   


_______________________________________________
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:[~2017-07-04  7:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-04  6:00 [PATCH 1/2] drm/amdgpu/gfx8: fix driver reload with KIQ Alex Deucher
     [not found] ` <1499148001-11497-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2017-07-04  6:00   ` [PATCH 2/2] drm/amdgpu/gfx9: " Alex Deucher
2017-07-04  6:57   ` [PATCH 1/2] drm/amdgpu/gfx8: " Michel Dänzer
2017-07-04  7:51   ` 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.