All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: change gfx8 ib test to use WB
@ 2018-06-08  4:54 Shirish S
       [not found] ` <1528433693-10399-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Shirish S @ 2018-06-08  4:54 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	alexander.deucher-5C7GfCeVMHo, christian.koenig-5C7GfCeVMHo,
	Monk.Liu-5C7GfCeVMHo, Harry.Wentland-5C7GfCeVMHo
  Cc: Shirish S

This patch is extends the usage of WB in
gfx8's ib test which was originally
implemented in the below upstream patch:
"ed9324a drm/amdgpu: change gfx9 ib test to use WB"

Signed-off-by: Shirish S <shirish.s@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 818874b..61452c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -866,26 +866,32 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
 	struct amdgpu_device *adev = ring->adev;
 	struct amdgpu_ib ib;
 	struct dma_fence *f = NULL;
-	uint32_t scratch;
-	uint32_t tmp = 0;
+
+	unsigned int index;
+	uint64_t gpu_addr;
+	uint32_t tmp;
 	long r;
 
-	r = amdgpu_gfx_scratch_get(adev, &scratch);
+	r = amdgpu_device_wb_get(adev, &index);
 	if (r) {
-		DRM_ERROR("amdgpu: failed to get scratch reg (%ld).\n", r);
+		dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r);
 		return r;
 	}
-	WREG32(scratch, 0xCAFEDEAD);
+
+	gpu_addr = adev->wb.gpu_addr + (index * 4);
+	adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
 	memset(&ib, 0, sizeof(ib));
-	r = amdgpu_ib_get(adev, NULL, 256, &ib);
+	r = amdgpu_ib_get(adev, NULL, 16, &ib);
 	if (r) {
 		DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r);
 		goto err1;
 	}
-	ib.ptr[0] = PACKET3(PACKET3_SET_UCONFIG_REG, 1);
-	ib.ptr[1] = ((scratch - PACKET3_SET_UCONFIG_REG_START));
-	ib.ptr[2] = 0xDEADBEEF;
-	ib.length_dw = 3;
+	ib.ptr[0] = PACKET3(PACKET3_WRITE_DATA, 3);
+	ib.ptr[1] = WRITE_DATA_DST_SEL(5) | WR_CONFIRM;
+	ib.ptr[2] = lower_32_bits(gpu_addr);
+	ib.ptr[3] = upper_32_bits(gpu_addr);
+	ib.ptr[4] = 0xDEADBEEF;
+	ib.length_dw = 5;
 
 	r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f);
 	if (r)
@@ -900,20 +906,21 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
 		DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r);
 		goto err2;
 	}
-	tmp = RREG32(scratch);
+
+	tmp = adev->wb.wb[index];
 	if (tmp == 0xDEADBEEF) {
 		DRM_DEBUG("ib test on ring %d succeeded\n", ring->idx);
 		r = 0;
 	} else {
-		DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n",
-			  scratch, tmp);
+		DRM_ERROR("ib test on ring %d failed\n", ring->idx);
 		r = -EINVAL;
 	}
+
 err2:
 	amdgpu_ib_free(adev, &ib, NULL);
 	dma_fence_put(f);
 err1:
-	amdgpu_gfx_scratch_free(adev, scratch);
+	amdgpu_device_wb_free(adev, index);
 	return r;
 }
 
-- 
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] 6+ messages in thread

* Re: [PATCH] drm/amdgpu: change gfx8 ib test to use WB
       [not found] ` <1528433693-10399-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
@ 2018-06-08  5:23   ` zhoucm1
       [not found]     ` <e8858d26-60c5-58d6-dcc3-6cd4b6a32aaf-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: zhoucm1 @ 2018-06-08  5:23 UTC (permalink / raw)
  To: Shirish S, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	alexander.deucher-5C7GfCeVMHo, christian.koenig-5C7GfCeVMHo,
	Monk.Liu-5C7GfCeVMHo, Harry.Wentland-5C7GfCeVMHo



On 2018年06月08日 12:54, Shirish S wrote:
> This patch is extends the usage of WB in
> gfx8's ib test which was originally
> implemented in the below upstream patch:
> "ed9324a drm/amdgpu: change gfx9 ib test to use WB"
>
> Signed-off-by: Shirish S <shirish.s@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 35 +++++++++++++++++++++--------------
>   1 file changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> index 818874b..61452c7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> @@ -866,26 +866,32 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
>   	struct amdgpu_device *adev = ring->adev;
>   	struct amdgpu_ib ib;
>   	struct dma_fence *f = NULL;
> -	uint32_t scratch;
> -	uint32_t tmp = 0;
> +
> +	unsigned int index;
> +	uint64_t gpu_addr;
> +	uint32_t tmp;
>   	long r;
>   
> -	r = amdgpu_gfx_scratch_get(adev, &scratch);
> +	r = amdgpu_device_wb_get(adev, &index);
>   	if (r) {
> -		DRM_ERROR("amdgpu: failed to get scratch reg (%ld).\n", r);
> +		dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r);
>   		return r;
>   	}
> -	WREG32(scratch, 0xCAFEDEAD);
> +
> +	gpu_addr = adev->wb.gpu_addr + (index * 4);
> +	adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
>   	memset(&ib, 0, sizeof(ib));
> -	r = amdgpu_ib_get(adev, NULL, 256, &ib);
> +	r = amdgpu_ib_get(adev, NULL, 16, &ib);
>   	if (r) {
>   		DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r);
>   		goto err1;
>   	}
> -	ib.ptr[0] = PACKET3(PACKET3_SET_UCONFIG_REG, 1);
> -	ib.ptr[1] = ((scratch - PACKET3_SET_UCONFIG_REG_START));
> -	ib.ptr[2] = 0xDEADBEEF;
> -	ib.length_dw = 3;
> +	ib.ptr[0] = PACKET3(PACKET3_WRITE_DATA, 3);
> +	ib.ptr[1] = WRITE_DATA_DST_SEL(5) | WR_CONFIRM;
> +	ib.ptr[2] = lower_32_bits(gpu_addr);
> +	ib.ptr[3] = upper_32_bits(gpu_addr);
> +	ib.ptr[4] = 0xDEADBEEF;
> +	ib.length_dw = 5;
>   
>   	r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f);
>   	if (r)
> @@ -900,20 +906,21 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
>   		DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r);
>   		goto err2;
>   	}
> -	tmp = RREG32(scratch);
> +
> +	tmp = adev->wb.wb[index];
>   	if (tmp == 0xDEADBEEF) {
>   		DRM_DEBUG("ib test on ring %d succeeded\n", ring->idx);
>   		r = 0;
>   	} else {
> -		DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n",
> -			  scratch, tmp);
> +		DRM_ERROR("ib test on ring %d failed\n", ring->idx);
>   		r = -EINVAL;
>   	}
> +
>   err2:
>   	amdgpu_ib_free(adev, &ib, NULL);
>   	dma_fence_put(f);
>   err1:
> -	amdgpu_gfx_scratch_free(adev, scratch);
> +	amdgpu_device_wb_free(adev, index);
>   	return r;
>   }
>   

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

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

* Re: [PATCH] drm/amdgpu: change gfx8 ib test to use WB
       [not found]     ` <e8858d26-60c5-58d6-dcc3-6cd4b6a32aaf-5C7GfCeVMHo@public.gmane.org>
@ 2018-06-08  7:38       ` Christian König
       [not found]         ` <a7b2b2cc-44e4-41e0-8c65-9fc09bfd44ec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Christian König @ 2018-06-08  7:38 UTC (permalink / raw)
  To: zhoucm1, Shirish S, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	alexander.deucher-5C7GfCeVMHo, christian.koenig-5C7GfCeVMHo,
	Monk.Liu-5C7GfCeVMHo, Harry.Wentland-5C7GfCeVMHo

Am 08.06.2018 um 07:23 schrieb zhoucm1:
>
>
> On 2018年06月08日 12:54, Shirish S wrote:
>> This patch is extends the usage of WB in
>> gfx8's ib test which was originally
>> implemented in the below upstream patch:
>> "ed9324a drm/amdgpu: change gfx9 ib test to use WB"

You could copy the commit message from ed9324a to better explain why we 
do it, but that is only nice to have.

>>
>> Signed-off-by: Shirish S <shirish.s@amd.com>
> Reviewed-by: Chunming Zhou <david1.zhou@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 35 
>> +++++++++++++++++++++--------------
>>   1 file changed, 21 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c 
>> b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
>> index 818874b..61452c7 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
>> @@ -866,26 +866,32 @@ static int gfx_v8_0_ring_test_ib(struct 
>> amdgpu_ring *ring, long timeout)
>>       struct amdgpu_device *adev = ring->adev;
>>       struct amdgpu_ib ib;
>>       struct dma_fence *f = NULL;
>> -    uint32_t scratch;
>> -    uint32_t tmp = 0;
>> +
>> +    unsigned int index;
>> +    uint64_t gpu_addr;
>> +    uint32_t tmp;
>>       long r;
>>   -    r = amdgpu_gfx_scratch_get(adev, &scratch);
>> +    r = amdgpu_device_wb_get(adev, &index);
>>       if (r) {
>> -        DRM_ERROR("amdgpu: failed to get scratch reg (%ld).\n", r);
>> +        dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r);
>>           return r;
>>       }
>> -    WREG32(scratch, 0xCAFEDEAD);
>> +
>> +    gpu_addr = adev->wb.gpu_addr + (index * 4);
>> +    adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
>>       memset(&ib, 0, sizeof(ib));
>> -    r = amdgpu_ib_get(adev, NULL, 256, &ib);
>> +    r = amdgpu_ib_get(adev, NULL, 16, &ib);
>>       if (r) {
>>           DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r);
>>           goto err1;
>>       }
>> -    ib.ptr[0] = PACKET3(PACKET3_SET_UCONFIG_REG, 1);
>> -    ib.ptr[1] = ((scratch - PACKET3_SET_UCONFIG_REG_START));
>> -    ib.ptr[2] = 0xDEADBEEF;
>> -    ib.length_dw = 3;
>> +    ib.ptr[0] = PACKET3(PACKET3_WRITE_DATA, 3);
>> +    ib.ptr[1] = WRITE_DATA_DST_SEL(5) | WR_CONFIRM;
>> +    ib.ptr[2] = lower_32_bits(gpu_addr);
>> +    ib.ptr[3] = upper_32_bits(gpu_addr);
>> +    ib.ptr[4] = 0xDEADBEEF;
>> +    ib.length_dw = 5;
>>         r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f);
>>       if (r)
>> @@ -900,20 +906,21 @@ static int gfx_v8_0_ring_test_ib(struct 
>> amdgpu_ring *ring, long timeout)
>>           DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r);
>>           goto err2;
>>       }
>> -    tmp = RREG32(scratch);
>> +
>> +    tmp = adev->wb.wb[index];
>>       if (tmp == 0xDEADBEEF) {
>>           DRM_DEBUG("ib test on ring %d succeeded\n", ring->idx);
>>           r = 0;
>>       } else {
>> -        DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n",
>> -              scratch, tmp);
>> +        DRM_ERROR("ib test on ring %d failed\n", ring->idx);
>>           r = -EINVAL;
>>       }
>> +
>>   err2:
>>       amdgpu_ib_free(adev, &ib, NULL);
>>       dma_fence_put(f);
>>   err1:
>> -    amdgpu_gfx_scratch_free(adev, scratch);
>> +    amdgpu_device_wb_free(adev, index);
>>       return r;
>>   }
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

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

* Re: [PATCH] drm/amdgpu: change gfx8 ib test to use WB
       [not found]             ` <4cb1a5d1-bcf9-7564-6e29-136ad565350e-5C7GfCeVMHo@public.gmane.org>
@ 2018-06-08  8:37               ` Christian König
  0 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2018-06-08  8:37 UTC (permalink / raw)
  To: S, Shirish, zhoucm1, Shirish S,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	alexander.deucher-5C7GfCeVMHo, Monk.Liu-5C7GfCeVMHo,
	Harry.Wentland-5C7GfCeVMHo

Am 08.06.2018 um 10:37 schrieb S, Shirish:
>
>
> On 6/8/2018 1:08 PM, Christian König wrote:
>> Am 08.06.2018 um 07:23 schrieb zhoucm1:
>>>
>>>
>>> On 2018年06月08日 12:54, Shirish S wrote:
>>>> This patch is extends the usage of WB in
>>>> gfx8's ib test which was originally
>>>> implemented in the below upstream patch:
>>>> "ed9324a drm/amdgpu: change gfx9 ib test to use WB"
>>
>> You could copy the commit message from ed9324a to better explain why 
>> we do it, but that is only nice to have.
>>
>>>>
>>>> Signed-off-by: Shirish S <shirish.s@amd.com>
>>> Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
>>
>> Reviewed-by: Christian König <christian.koenig@amd.com>
>>
> Thanks Christian & david, shall re-send with the updated commit 
> message and RB's.

Since you already gathered RB's from two people and haven't made any 
function change (only extended the commit message a bit) you can also go 
ahead and commit it.

Regards,
Christian.

>
> Regards,
> Shirish S
>>>
>>>> ---
>>>>   drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 35 
>>>> +++++++++++++++++++++--------------
>>>>   1 file changed, 21 insertions(+), 14 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c 
>>>> b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
>>>> index 818874b..61452c7 100644
>>>> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
>>>> @@ -866,26 +866,32 @@ static int gfx_v8_0_ring_test_ib(struct 
>>>> amdgpu_ring *ring, long timeout)
>>>>       struct amdgpu_device *adev = ring->adev;
>>>>       struct amdgpu_ib ib;
>>>>       struct dma_fence *f = NULL;
>>>> -    uint32_t scratch;
>>>> -    uint32_t tmp = 0;
>>>> +
>>>> +    unsigned int index;
>>>> +    uint64_t gpu_addr;
>>>> +    uint32_t tmp;
>>>>       long r;
>>>>   -    r = amdgpu_gfx_scratch_get(adev, &scratch);
>>>> +    r = amdgpu_device_wb_get(adev, &index);
>>>>       if (r) {
>>>> -        DRM_ERROR("amdgpu: failed to get scratch reg (%ld).\n", r);
>>>> +        dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r);
>>>>           return r;
>>>>       }
>>>> -    WREG32(scratch, 0xCAFEDEAD);
>>>> +
>>>> +    gpu_addr = adev->wb.gpu_addr + (index * 4);
>>>> +    adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
>>>>       memset(&ib, 0, sizeof(ib));
>>>> -    r = amdgpu_ib_get(adev, NULL, 256, &ib);
>>>> +    r = amdgpu_ib_get(adev, NULL, 16, &ib);
>>>>       if (r) {
>>>>           DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r);
>>>>           goto err1;
>>>>       }
>>>> -    ib.ptr[0] = PACKET3(PACKET3_SET_UCONFIG_REG, 1);
>>>> -    ib.ptr[1] = ((scratch - PACKET3_SET_UCONFIG_REG_START));
>>>> -    ib.ptr[2] = 0xDEADBEEF;
>>>> -    ib.length_dw = 3;
>>>> +    ib.ptr[0] = PACKET3(PACKET3_WRITE_DATA, 3);
>>>> +    ib.ptr[1] = WRITE_DATA_DST_SEL(5) | WR_CONFIRM;
>>>> +    ib.ptr[2] = lower_32_bits(gpu_addr);
>>>> +    ib.ptr[3] = upper_32_bits(gpu_addr);
>>>> +    ib.ptr[4] = 0xDEADBEEF;
>>>> +    ib.length_dw = 5;
>>>>         r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f);
>>>>       if (r)
>>>> @@ -900,20 +906,21 @@ static int gfx_v8_0_ring_test_ib(struct 
>>>> amdgpu_ring *ring, long timeout)
>>>>           DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r);
>>>>           goto err2;
>>>>       }
>>>> -    tmp = RREG32(scratch);
>>>> +
>>>> +    tmp = adev->wb.wb[index];
>>>>       if (tmp == 0xDEADBEEF) {
>>>>           DRM_DEBUG("ib test on ring %d succeeded\n", ring->idx);
>>>>           r = 0;
>>>>       } else {
>>>> -        DRM_ERROR("amdgpu: ib test failed 
>>>> (scratch(0x%04X)=0x%08X)\n",
>>>> -              scratch, tmp);
>>>> +        DRM_ERROR("ib test on ring %d failed\n", ring->idx);
>>>>           r = -EINVAL;
>>>>       }
>>>> +
>>>>   err2:
>>>>       amdgpu_ib_free(adev, &ib, NULL);
>>>>       dma_fence_put(f);
>>>>   err1:
>>>> -    amdgpu_gfx_scratch_free(adev, scratch);
>>>> +    amdgpu_device_wb_free(adev, index);
>>>>       return r;
>>>>   }
>>>
>>> _______________________________________________
>>> amd-gfx mailing list
>>> amd-gfx@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>>
>

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

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

* Re: [PATCH] drm/amdgpu: change gfx8 ib test to use WB
       [not found]         ` <a7b2b2cc-44e4-41e0-8c65-9fc09bfd44ec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2018-06-08  8:37           ` S, Shirish
       [not found]             ` <4cb1a5d1-bcf9-7564-6e29-136ad565350e-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: S, Shirish @ 2018-06-08  8:37 UTC (permalink / raw)
  To: christian.koenig-5C7GfCeVMHo, zhoucm1, Shirish S,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	alexander.deucher-5C7GfCeVMHo, Monk.Liu-5C7GfCeVMHo,
	Harry.Wentland-5C7GfCeVMHo



On 6/8/2018 1:08 PM, Christian König wrote:
> Am 08.06.2018 um 07:23 schrieb zhoucm1:
>>
>>
>> On 2018年06月08日 12:54, Shirish S wrote:
>>> This patch is extends the usage of WB in
>>> gfx8's ib test which was originally
>>> implemented in the below upstream patch:
>>> "ed9324a drm/amdgpu: change gfx9 ib test to use WB"
>
> You could copy the commit message from ed9324a to better explain why 
> we do it, but that is only nice to have.
>
>>>
>>> Signed-off-by: Shirish S <shirish.s@amd.com>
>> Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
Thanks Christian & david, shall re-send with the updated commit message 
and RB's.

Regards,
Shirish S
>>
>>> ---
>>>   drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 35 
>>> +++++++++++++++++++++--------------
>>>   1 file changed, 21 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c 
>>> b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
>>> index 818874b..61452c7 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
>>> @@ -866,26 +866,32 @@ static int gfx_v8_0_ring_test_ib(struct 
>>> amdgpu_ring *ring, long timeout)
>>>       struct amdgpu_device *adev = ring->adev;
>>>       struct amdgpu_ib ib;
>>>       struct dma_fence *f = NULL;
>>> -    uint32_t scratch;
>>> -    uint32_t tmp = 0;
>>> +
>>> +    unsigned int index;
>>> +    uint64_t gpu_addr;
>>> +    uint32_t tmp;
>>>       long r;
>>>   -    r = amdgpu_gfx_scratch_get(adev, &scratch);
>>> +    r = amdgpu_device_wb_get(adev, &index);
>>>       if (r) {
>>> -        DRM_ERROR("amdgpu: failed to get scratch reg (%ld).\n", r);
>>> +        dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r);
>>>           return r;
>>>       }
>>> -    WREG32(scratch, 0xCAFEDEAD);
>>> +
>>> +    gpu_addr = adev->wb.gpu_addr + (index * 4);
>>> +    adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
>>>       memset(&ib, 0, sizeof(ib));
>>> -    r = amdgpu_ib_get(adev, NULL, 256, &ib);
>>> +    r = amdgpu_ib_get(adev, NULL, 16, &ib);
>>>       if (r) {
>>>           DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r);
>>>           goto err1;
>>>       }
>>> -    ib.ptr[0] = PACKET3(PACKET3_SET_UCONFIG_REG, 1);
>>> -    ib.ptr[1] = ((scratch - PACKET3_SET_UCONFIG_REG_START));
>>> -    ib.ptr[2] = 0xDEADBEEF;
>>> -    ib.length_dw = 3;
>>> +    ib.ptr[0] = PACKET3(PACKET3_WRITE_DATA, 3);
>>> +    ib.ptr[1] = WRITE_DATA_DST_SEL(5) | WR_CONFIRM;
>>> +    ib.ptr[2] = lower_32_bits(gpu_addr);
>>> +    ib.ptr[3] = upper_32_bits(gpu_addr);
>>> +    ib.ptr[4] = 0xDEADBEEF;
>>> +    ib.length_dw = 5;
>>>         r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f);
>>>       if (r)
>>> @@ -900,20 +906,21 @@ static int gfx_v8_0_ring_test_ib(struct 
>>> amdgpu_ring *ring, long timeout)
>>>           DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r);
>>>           goto err2;
>>>       }
>>> -    tmp = RREG32(scratch);
>>> +
>>> +    tmp = adev->wb.wb[index];
>>>       if (tmp == 0xDEADBEEF) {
>>>           DRM_DEBUG("ib test on ring %d succeeded\n", ring->idx);
>>>           r = 0;
>>>       } else {
>>> -        DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n",
>>> -              scratch, tmp);
>>> +        DRM_ERROR("ib test on ring %d failed\n", ring->idx);
>>>           r = -EINVAL;
>>>       }
>>> +
>>>   err2:
>>>       amdgpu_ib_free(adev, &ib, NULL);
>>>       dma_fence_put(f);
>>>   err1:
>>> -    amdgpu_gfx_scratch_free(adev, scratch);
>>> +    amdgpu_device_wb_free(adev, index);
>>>       return r;
>>>   }
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>

-- 
Regards,
Shirish S

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

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

* [PATCH] drm/amdgpu: change gfx8 ib test to use WB
@ 2018-06-08  8:28 Shirish S
  0 siblings, 0 replies; 6+ messages in thread
From: Shirish S @ 2018-06-08  8:28 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	alexander.deucher-5C7GfCeVMHo, christian.koenig-5C7GfCeVMHo,
	Monk.Liu-5C7GfCeVMHo, Harry.Wentland-5C7GfCeVMHo
  Cc: Shirish S

This patch is extends the usage of WB in
gfx8's ib test which was originally
implemented in the below upstream patch
"ed9324a drm/amdgpu: change gfx9 ib test to use WB"

For reference below are the reasons for switching
to WB:

1)Because when doing IB test we don't want to involve KIQ health
status affect, and since SCRATCH register access is go through
KIQ that way GFX IB test would failed due to KIQ fail.

2)acccessing SCRATCH register cost much more time than WB method
because SCRATCH register access runs through KIQ which at least could
begin after GPU world switch back to current Guest VF

Signed-off-by: Shirish S <shirish.s@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 818874b..61452c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -866,26 +866,32 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
 	struct amdgpu_device *adev = ring->adev;
 	struct amdgpu_ib ib;
 	struct dma_fence *f = NULL;
-	uint32_t scratch;
-	uint32_t tmp = 0;
+
+	unsigned int index;
+	uint64_t gpu_addr;
+	uint32_t tmp;
 	long r;
 
-	r = amdgpu_gfx_scratch_get(adev, &scratch);
+	r = amdgpu_device_wb_get(adev, &index);
 	if (r) {
-		DRM_ERROR("amdgpu: failed to get scratch reg (%ld).\n", r);
+		dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r);
 		return r;
 	}
-	WREG32(scratch, 0xCAFEDEAD);
+
+	gpu_addr = adev->wb.gpu_addr + (index * 4);
+	adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
 	memset(&ib, 0, sizeof(ib));
-	r = amdgpu_ib_get(adev, NULL, 256, &ib);
+	r = amdgpu_ib_get(adev, NULL, 16, &ib);
 	if (r) {
 		DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r);
 		goto err1;
 	}
-	ib.ptr[0] = PACKET3(PACKET3_SET_UCONFIG_REG, 1);
-	ib.ptr[1] = ((scratch - PACKET3_SET_UCONFIG_REG_START));
-	ib.ptr[2] = 0xDEADBEEF;
-	ib.length_dw = 3;
+	ib.ptr[0] = PACKET3(PACKET3_WRITE_DATA, 3);
+	ib.ptr[1] = WRITE_DATA_DST_SEL(5) | WR_CONFIRM;
+	ib.ptr[2] = lower_32_bits(gpu_addr);
+	ib.ptr[3] = upper_32_bits(gpu_addr);
+	ib.ptr[4] = 0xDEADBEEF;
+	ib.length_dw = 5;
 
 	r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f);
 	if (r)
@@ -900,20 +906,21 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
 		DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r);
 		goto err2;
 	}
-	tmp = RREG32(scratch);
+
+	tmp = adev->wb.wb[index];
 	if (tmp == 0xDEADBEEF) {
 		DRM_DEBUG("ib test on ring %d succeeded\n", ring->idx);
 		r = 0;
 	} else {
-		DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n",
-			  scratch, tmp);
+		DRM_ERROR("ib test on ring %d failed\n", ring->idx);
 		r = -EINVAL;
 	}
+
 err2:
 	amdgpu_ib_free(adev, &ib, NULL);
 	dma_fence_put(f);
 err1:
-	amdgpu_gfx_scratch_free(adev, scratch);
+	amdgpu_device_wb_free(adev, index);
 	return r;
 }
 
-- 
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] 6+ messages in thread

end of thread, other threads:[~2018-06-08  8:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-08  4:54 [PATCH] drm/amdgpu: change gfx8 ib test to use WB Shirish S
     [not found] ` <1528433693-10399-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
2018-06-08  5:23   ` zhoucm1
     [not found]     ` <e8858d26-60c5-58d6-dcc3-6cd4b6a32aaf-5C7GfCeVMHo@public.gmane.org>
2018-06-08  7:38       ` Christian König
     [not found]         ` <a7b2b2cc-44e4-41e0-8c65-9fc09bfd44ec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-06-08  8:37           ` S, Shirish
     [not found]             ` <4cb1a5d1-bcf9-7564-6e29-136ad565350e-5C7GfCeVMHo@public.gmane.org>
2018-06-08  8:37               ` Christian König
2018-06-08  8:28 Shirish S

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.