Re: [PATCH 1/1] drm/amdgpu: fix usable gart size calculation

2020-11-14 Thread Christian König

Am 13.11.20 um 18:33 schrieb Nirmoy Das:

amdgpu_do_test_moves() is failing because of wrong
usable gart size calculation and throwing:

[drm:amdgpu_do_test_moves [amdgpu]] *ERROR* 20bdc9f3 bind failed

Signed-off-by: Nirmoy Das 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 13 -
  1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
index 6042b3b81a4c..7b230bcbf2c6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
@@ -42,16 +42,11 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
size = 1024 * 1024;
  
  	/* Number of tests =

-* (Total GTT - IB pool - writeback page - ring buffers) / test size
+* (Total GTT - gart_pin_size - (2 transfer windows for buffer moves)) 
/ test size
 */
-   n = adev->gmc.gart_size - AMDGPU_IB_POOL_SIZE;
-   for (i = 0; i < AMDGPU_MAX_RINGS; ++i)
-   if (adev->rings[i])
-   n -= adev->rings[i]->ring_size;
-   if (adev->wb.wb_obj)
-   n -= AMDGPU_GPU_PAGE_SIZE;
-   if (adev->irq.ih.ring_obj)
-   n -= adev->irq.ih.ring_size;
+   n = adev->gmc.gart_size - atomic64_read(>gart_pin_size);
+   n -= AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS *
+   AMDGPU_GPU_PAGE_SIZE;
n /= size;
  
  	gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);


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


Re: [PATCH 1/1] drm/amdgpu: fix usable gart size calculation

2020-11-13 Thread Alex Deucher
On Fri, Nov 13, 2020 at 12:34 PM Nirmoy Das  wrote:
>
> amdgpu_do_test_moves() is failing because of wrong
> usable gart size calculation and throwing:
>
> [drm:amdgpu_do_test_moves [amdgpu]] *ERROR* 20bdc9f3 bind failed
>
> Signed-off-by: Nirmoy Das 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 13 -
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
> index 6042b3b81a4c..7b230bcbf2c6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
> @@ -42,16 +42,11 @@ static void amdgpu_do_test_moves(struct amdgpu_device 
> *adev)
> size = 1024 * 1024;
>
> /* Number of tests =
> -* (Total GTT - IB pool - writeback page - ring buffers) / test size
> +* (Total GTT - gart_pin_size - (2 transfer windows for buffer 
> moves)) / test size
>  */
> -   n = adev->gmc.gart_size - AMDGPU_IB_POOL_SIZE;
> -   for (i = 0; i < AMDGPU_MAX_RINGS; ++i)
> -   if (adev->rings[i])
> -   n -= adev->rings[i]->ring_size;
> -   if (adev->wb.wb_obj)
> -   n -= AMDGPU_GPU_PAGE_SIZE;
> -   if (adev->irq.ih.ring_obj)
> -   n -= adev->irq.ih.ring_size;
> +   n = adev->gmc.gart_size - atomic64_read(>gart_pin_size);
> +   n -= AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS *
> +   AMDGPU_GPU_PAGE_SIZE;
> n /= size;
>
> gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
> --
> 2.29.0
>
> ___
> 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


[PATCH 1/1] drm/amdgpu: fix usable gart size calculation

2020-11-13 Thread Nirmoy Das
amdgpu_do_test_moves() is failing because of wrong
usable gart size calculation and throwing:

[drm:amdgpu_do_test_moves [amdgpu]] *ERROR* 20bdc9f3 bind failed

Signed-off-by: Nirmoy Das 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
index 6042b3b81a4c..7b230bcbf2c6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
@@ -42,16 +42,11 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
size = 1024 * 1024;
 
/* Number of tests =
-* (Total GTT - IB pool - writeback page - ring buffers) / test size
+* (Total GTT - gart_pin_size - (2 transfer windows for buffer moves)) 
/ test size
 */
-   n = adev->gmc.gart_size - AMDGPU_IB_POOL_SIZE;
-   for (i = 0; i < AMDGPU_MAX_RINGS; ++i)
-   if (adev->rings[i])
-   n -= adev->rings[i]->ring_size;
-   if (adev->wb.wb_obj)
-   n -= AMDGPU_GPU_PAGE_SIZE;
-   if (adev->irq.ih.ring_obj)
-   n -= adev->irq.ih.ring_size;
+   n = adev->gmc.gart_size - atomic64_read(>gart_pin_size);
+   n -= AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS *
+   AMDGPU_GPU_PAGE_SIZE;
n /= size;
 
gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
-- 
2.29.0

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


Re: [RFC PATCH 1/1] drm/amdgpu: fix usable gart size calculation

2020-11-13 Thread Nirmoy


On 11/13/20 5:21 PM, Christian König wrote:

Am 13.11.20 um 17:17 schrieb Nirmoy Das:

amdgpu_do_test_moves() is failing because of wrong
usable gart size calculation and throwing:

[drm:amdgpu_do_test_moves [amdgpu]] *ERROR* 20bdc9f3 bind failed

Signed-off-by: Nirmoy Das 
---

This still doesn't work. As per my calculation 1st 4MB of GART is not
accounted for in adev->gmc.gart_size - 
atomic64_read(>gart_pin_size).


The member gart_pin_size should probably be renamed to gtt_pin_size, 
but since a gtt pin is also automatically visible in the GART that 
should probably be ok for now.



What am I missing ?


The two 2MB windows in the GART which are used for buffer moves.

See AMDGPU_GTT_MAX_TRANSFER_SIZE and AMDGPU_GTT_NUM_TRANSFER_WINDOWS.



Thanks, I should've asked much earlier :)


Nirmoy



Regards,
Christian.



  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 11 ++-
  1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c

index 6042b3b81a4c..d983c729997f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
@@ -42,16 +42,9 @@ static void amdgpu_do_test_moves(struct 
amdgpu_device *adev)

  size = 1024 * 1024;

  /* Number of tests =
- * (Total GTT - IB pool - writeback page - ring buffers) / test 
size

+ * (Total GTT - gart_pin_size) / test size
   */
-    n = adev->gmc.gart_size - AMDGPU_IB_POOL_SIZE;
-    for (i = 0; i < AMDGPU_MAX_RINGS; ++i)
-    if (adev->rings[i])
-    n -= adev->rings[i]->ring_size;
-    if (adev->wb.wb_obj)
-    n -= AMDGPU_GPU_PAGE_SIZE;
-    if (adev->irq.ih.ring_obj)
-    n -= adev->irq.ih.ring_size;
+    n = adev->gmc.gart_size - atomic64_read(>gart_pin_size);
  n /= size;

  gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
--
2.29.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfxdata=04%7C01%7Cnirmoy.das%40amd.com%7Cc9c61fcfe5b744b494c208d887f0430e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637408813271687888%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=o9w4aKiHNAZvkcWPHTiZQZC5nrOYdjs7TqMpZ3d8AJ0%3Dreserved=0 




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


Re: [RFC PATCH 1/1] drm/amdgpu: fix usable gart size calculation

2020-11-13 Thread Christian König

Am 13.11.20 um 17:17 schrieb Nirmoy Das:

amdgpu_do_test_moves() is failing because of wrong
usable gart size calculation and throwing:

[drm:amdgpu_do_test_moves [amdgpu]] *ERROR* 20bdc9f3 bind failed

Signed-off-by: Nirmoy Das 
---

This still doesn't work. As per my calculation 1st 4MB of GART is not
accounted for in adev->gmc.gart_size - atomic64_read(>gart_pin_size).


The member gart_pin_size should probably be renamed to gtt_pin_size, but 
since a gtt pin is also automatically visible in the GART that should 
probably be ok for now.



What am I missing ?


The two 2MB windows in the GART which are used for buffer moves.

See AMDGPU_GTT_MAX_TRANSFER_SIZE and AMDGPU_GTT_NUM_TRANSFER_WINDOWS.

Regards,
Christian.



  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 11 ++-
  1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
index 6042b3b81a4c..d983c729997f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
@@ -42,16 +42,9 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
size = 1024 * 1024;

/* Number of tests =
-* (Total GTT - IB pool - writeback page - ring buffers) / test size
+* (Total GTT - gart_pin_size) / test size
 */
-   n = adev->gmc.gart_size - AMDGPU_IB_POOL_SIZE;
-   for (i = 0; i < AMDGPU_MAX_RINGS; ++i)
-   if (adev->rings[i])
-   n -= adev->rings[i]->ring_size;
-   if (adev->wb.wb_obj)
-   n -= AMDGPU_GPU_PAGE_SIZE;
-   if (adev->irq.ih.ring_obj)
-   n -= adev->irq.ih.ring_size;
+   n = adev->gmc.gart_size - atomic64_read(>gart_pin_size);
n /= size;

gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
--
2.29.0

___
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


[RFC PATCH 1/1] drm/amdgpu: fix usable gart size calculation

2020-11-13 Thread Nirmoy Das
amdgpu_do_test_moves() is failing because of wrong
usable gart size calculation and throwing:

[drm:amdgpu_do_test_moves [amdgpu]] *ERROR* 20bdc9f3 bind failed

Signed-off-by: Nirmoy Das 
---

This still doesn't work. As per my calculation 1st 4MB of GART is not
accounted for in adev->gmc.gart_size - atomic64_read(>gart_pin_size).
What am I missing ?

 drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
index 6042b3b81a4c..d983c729997f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
@@ -42,16 +42,9 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
size = 1024 * 1024;

/* Number of tests =
-* (Total GTT - IB pool - writeback page - ring buffers) / test size
+* (Total GTT - gart_pin_size) / test size
 */
-   n = adev->gmc.gart_size - AMDGPU_IB_POOL_SIZE;
-   for (i = 0; i < AMDGPU_MAX_RINGS; ++i)
-   if (adev->rings[i])
-   n -= adev->rings[i]->ring_size;
-   if (adev->wb.wb_obj)
-   n -= AMDGPU_GPU_PAGE_SIZE;
-   if (adev->irq.ih.ring_obj)
-   n -= adev->irq.ih.ring_size;
+   n = adev->gmc.gart_size - atomic64_read(>gart_pin_size);
n /= size;

gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
--
2.29.0

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