Skip to contentSkip to conversation

drm/ttm:fix incorrect calculate on shrink_pages

PATCH NAK Monk Liu 4 participants 14 messages Dec 12, 2017 5 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/7 drm/ttm:fix incorrect calculate on shrink_pages

shrink_pages is in unit of Order after ttm_page_pool_free, but it is used by nr_free in next round so need change it into native page unit

Change-Id I33b77ac1616e24b1b881eee54c3bd7342cfa9ab8
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_page_alloc.c +1 -0
index 44343a2..71945cc 100644
@@ -455,6 +455,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 		freed += (nr_free_pool - shrink_pages) << pool->order;
 		if (freed >= sc->nr_to_scan)
 			break;
+		shrink_pages <<= pool->order;
 	}
 	mutex_unlock(&lock);
 	return freed;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1513072005-3477-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 2/7 drm/ttm:max_cpages is in unit of native page

Change-Id I7093791939fc1cccf2a13d8cc7ef7a6cca95351d
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +1 -1
index 71945cc..b5ba644 100644
@@ -544,7 +544,7 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags,
 	int r = 0;
 	unsigned i, j, cpages;
 	unsigned npages = 1 << order;
-	unsigned max_cpages = min(count, (unsigned)NUM_PAGES_TO_ALLOC);
+	unsigned max_cpages = min(count << order, (unsigned)NUM_PAGES_TO_ALLOC);
 
 	/* allocate array for page caching change */
 	caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#3 lore raw

PATCH 3/7 drm/amdgpu:no need to evict VRAM in device_fini

In reply to a message not in the archive
Change-Id I6d6004b8f84e4654b5c4da53b4ebdf3936602883
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
index 8d03baa..a269bbc 100644
@@ -2461,8 +2461,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 	adev->shutdown = true;
 	if (adev->mode_info.mode_config_initialized)
 		drm_crtc_force_disable_all(adev->ddev);
-	/* evict vram memory */
-	amdgpu_bo_evict_vram(adev);
+
 	amdgpu_ib_pool_fini(adev);
 	amdgpu_fence_driver_fini(adev);
 	amdgpu_fbdev_fini(adev);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#4 lore raw

PATCH 4/7 drm/amdgpu:return ETIME if really time out

In reply to a message not in the archive
Change-Id I7304577a500fc2d41482f2fe3f1692ae3797f576
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -2
index 44523a8..f62b07a 100644
@@ -1506,8 +1506,8 @@ static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev,
 
 	if (first < fence_count && array[first])
 		r = array[first]->error;
-	else
-		r = 0;
+	else if (r == 0)
+		r = -ETIME;
 
 err_free_fence_array:
 	for (i = 0; i < fence_count; i++)
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1513072005-3477-4-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

#6 lore raw

Re: [PATCH 4/7] drm/amdgpu:return ETIME if really time out

NAK, it does make sense but that would change the user space interface in a non backward compatible way, wouldn't it?

Christian.

Am 12.12.2017 um 10:46 schrieb Monk Liu:

Quoted 11 lines
Change-Id I7304577a500fc2d41482f2fe3f1692ae3797f576
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 44523a8..f62b07a 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev, · line 1513

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -2
@@ -1506,8 +1506,8 @@ static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev,
 
  	if (first < fence_count && array[first])
  		r = array[first]->error;
-	else
-		r = 0;
+	else if (r == 0)
+		r = -ETIME;
 
  err_free_fence_array:
  	for (i = 0; i < fence_count; i++)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 56d28355-f5e7-bfda-2413-3f85c8b1ea70-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author NAK
#8 lore raw

RE: [PATCH 4/7] drm/amdgpu:return ETIME if really time out

Without this patch a timed out submit will never be caught, is it really good ?

For the backward compatible why it's applied on incorrect logic ?

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: 2017年12月12日 18:20
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 4/7] drm/amdgpu:return ETIME if really time out

NAK, it does make sense but that would change the user space interface in a non backward compatible way, wouldn't it?

Christian.

Am 12.12.2017 um 10:46 schrieb Monk Liu:

Quoted 22 lines
Change-Id I7304577a500fc2d41482f2fe3f1692ae3797f576
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -2
index 44523a8..f62b07a 100644
@@ -1506,8 +1506,8 @@ static int amdgpu_cs_wait_any_fence(struct 
 amdgpu_device *adev,
 
  	if (first < fence_count && array[first])
  		r = array[first]->error;
-	else
-		r = 0;
+	else if (r == 0)
+		r = -ETIME;
 
  err_free_fence_array:
Quoted 1 line

for (i = 0; i < fence_count; i++)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BLUPR12MB04499CC592DA04879EE123DE84340-7LeqcoF/[email protected]

#10 lore raw

Re: [PATCH 4/7] drm/amdgpu:return ETIME if really time out

dma_fence_wait_any_timeout() return 1 when some fences was signaled even when the timeout parameter is 0.

And later on we check for "wait->out.status = (r > 0);". So the logic should actually work correct.

If it doesn't we need to fix something else.

Christian.

Am 12.12.2017 um 11:23 schrieb Liu, Monk:

Quoted 36 lines

Without this patch a timed out submit will never be caught, is it really good ?

For the backward compatible why it's applied on incorrect logic ?

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: 2017年12月12日 18:20
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 4/7] drm/amdgpu:return ETIME if really time out

NAK, it does make sense but that would change the user space interface in a non backward compatible way, wouldn't it?

Christian.

Am 12.12.2017 um 10:46 schrieb Monk Liu:

Quoted 21 lines
Change-Id I7304577a500fc2d41482f2fe3f1692ae3797f576
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -2
index 44523a8..f62b07a 100644
@@ -1506,8 +1506,8 @@ static int amdgpu_cs_wait_any_fence(struct
 amdgpu_device *adev,
 
   	if (first < fence_count && array[first])
   		r = array[first]->error;
-	else
-		r = 0;
+	else if (r == 0)
+		r = -ETIME;
 
Quoted 6 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
   err_free_fence_array:
   	for (i = 0; i < fence_count; i++)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 8b735e84-4d9e-4804-bf63-aa1be54de011-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#12 lore raw

RE: [PATCH 4/7] drm/amdgpu:return ETIME if really time out

Okay

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: 2017年12月12日 18:44
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH 4/7] drm/amdgpu:return ETIME if really time out

dma_fence_wait_any_timeout() return 1 when some fences was signaled even when the timeout parameter is 0.

And later on we check for "wait->out.status = (r > 0);". So the logic should actually work correct.

If it doesn't we need to fix something else.

Christian.

Am 12.12.2017 um 11:23 schrieb Liu, Monk:

Quoted 36 lines

Without this patch a timed out submit will never be caught, is it really good ?

For the backward compatible why it's applied on incorrect logic ?

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: 2017年12月12日 18:20
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 4/7] drm/amdgpu:return ETIME if really time out

NAK, it does make sense but that would change the user space interface in a non backward compatible way, wouldn't it?

Christian.

Am 12.12.2017 um 10:46 schrieb Monk Liu:

Quoted 21 lines
Change-Id I7304577a500fc2d41482f2fe3f1692ae3797f576
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -2
index 44523a8..f62b07a 100644
@@ -1506,8 +1506,8 @@ static int amdgpu_cs_wait_any_fence(struct 
 amdgpu_device *adev,
 
   	if (first < fence_count && array[first])
   		r = array[first]->error;
-	else
-		r = 0;
+	else if (r == 0)
+		r = -ETIME;
 
Quoted 6 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
   err_free_fence_array:
   	for (i = 0; i < fence_count; i++)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#13 lore raw

PATCH 5/7 drm/amdgpu:no need with INT for fence polling

In reply to a message not in the archive
Change-Id Ia13f12207d2e563f1f0c5d62cee74e0ae7d62e83
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1 -1
index 1469963..7cb71a8 100644
@@ -187,7 +187,7 @@ int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s)
 
 	seq = ++ring->fence_drv.sync_seq;
 	amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
-			       seq, AMDGPU_FENCE_FLAG_INT);
+			       seq, 0);
 
 	*s = seq;
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#14 lore raw

PATCH 6/7 drm/amdgpu:fix MAP_QUEUES paramter

In reply to a message not in the archive
Change-Id I03fbf3ffb67f40a88769fac1b66fa1707479a3ea
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
index 50a1edb..468aed5 100644
@@ -2405,7 +2405,7 @@ static int gfx_v9_0_kiq_kcq_enable(struct amdgpu_device *adev)
 				  PACKET3_MAP_QUEUES_PIPE(ring->pipe) |
 				  PACKET3_MAP_QUEUES_ME((ring->me == 1 ? 0 : 1)) |
 				  PACKET3_MAP_QUEUES_QUEUE_TYPE(0) | /*queue_type: normal compute queue */
-				  PACKET3_MAP_QUEUES_ALLOC_FORMAT(1) | /* alloc format: all_on_one_pipe */
+				  PACKET3_MAP_QUEUES_ALLOC_FORMAT(0) | /* alloc format: all_on_one_pipe */
 				  PACKET3_MAP_QUEUES_ENGINE_SEL(0) | /* engine_sel: compute */
 				  PACKET3_MAP_QUEUES_NUM_QUEUES(1)); /* num_queues: must be 1 */
 		amdgpu_ring_write(kiq_ring, PACKET3_MAP_QUEUES_DOORBELL_OFFSET(ring->doorbell_index));
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#15 lore raw

PATCH 7/7 drm/amdgpu:correct vce fw data and stack size config

In reply to a message not in the archive

From: Frank Min <[email protected]>

Change-Id Ic1bc49c21d3a90c477d11162f9d6d9e2073fbbd3
---
 drivers/gpu/drm/amd/amdgpu/vce_v4_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +1 -1
index 55f0186..e98f548 100755
@@ -423,7 +423,7 @@ static int vce_v4_0_sw_init(void *handle)
 	if (r)
 		return r;
 
-	size  = (VCE_V4_0_STACK_SIZE + VCE_V4_0_DATA_SIZE) * 2;
+	size  = VCE_V4_0_STACK_SIZE + VCE_V4_0_DATA_SIZE;
 	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
 		size += VCE_V4_0_FW_SIZE;
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by Roger He
#16 lore raw
In reply to a message not in the archive

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Tuesday, December 12, 2017 5:47 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>
Subject: [PATCH 1/7] drm/ttm:fix incorrect calculate on shrink_pages

shrink_pages is in unit of Order after ttm_page_pool_free, but it is used by nr_free in next round so need change it into native page unit

Change-Id I33b77ac1616e24b1b881eee54c3bd7342cfa9ab8
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_page_alloc.c +1 -0
index 44343a2..71945cc 100644
@@ -455,6 +455,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 		freed += (nr_free_pool - shrink_pages) << pool->order;
 		if (freed >= sc->nr_to_scan)
 			break;
+		shrink_pages <<= pool->order;
 	}
 	mutex_unlock(&lock);
 	return freed;

--
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#17 lore raw
In reply to a message not in the archive

Patch #1-#3 and #5 are Reviewed-by: Christian König <[email protected]>.

Patch #6 and #7 are Acked-by: Christian König <[email protected]>.

Regards,
Christian.

Am 12.12.2017 um 10:46 schrieb Monk Liu:

Quoted 15 lines

shrink_pages is in unit of Order after ttm_page_pool_free, but it is used by nr_free in next round so need change it into native page unit

Change-Id I33b77ac1616e24b1b881eee54c3bd7342cfa9ab8
---
  drivers/gpu/drm/ttm/ttm_page_alloc.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_page_alloc.c +0 -0
index 44343a2..71945cc 100644

drivers/gpu/drm/ttm/ttm_page_alloc.c ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) · line 461

Quoted 7 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +1 -0
@@ -455,6 +455,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
  		freed += (nr_free_pool - shrink_pages) << pool->order;
  		if (freed >= sc->nr_to_scan)
  			break;
+		shrink_pages <<= pool->order;
  	}
  	mutex_unlock(&lock);
  	return freed;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#18 lore raw
In reply to a message not in the archive

BTW, in the shortlog (subject) there should always be a space after the prefix's ":".

Quoted 16 lines · Monk Liu

shrink_pages is in unit of Order after ttm_page_pool_free, but it is used by nr_free in next round so need change it into native page unit

Change-Id I33b77ac1616e24b1b881eee54c3bd7342cfa9ab8
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_page_alloc.c +0 -0
index 44343a2..71945cc 100644

drivers/gpu/drm/ttm/ttm_page_alloc.c ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) · line 461

Quoted 7 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +1 -0
@@ -455,6 +455,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 		freed += (nr_free_pool - shrink_pages) << pool->order;
 		if (freed >= sc->nr_to_scan)
 			break;
+		shrink_pages <<= pool->order;
 	}
 	mutex_unlock(&lock);
 	return freed;

TTM patches need to be sent to the dri-devel list as well for review. It's better not to mix TTM and amdgpu patches in the same series unless absolutely necessary.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx