Skip to contentSkip to conversation

drm/radeon: Override fpfn for all VRAM placements in radeon_evict_flags

PATCH In review Michel Dänzer 5 participants 6 messages Mar 27, 2017 – Mar 28, 2017 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon: Override fpfn for all VRAM placements in radeon_evict_flags

From: Michel Dänzer <[email protected]>

We were accidentally only overriding the first VRAM placement. For BOs with the RADEON_GEM_NO_CPU_ACCESS flag set, radeon_ttm_placement_from_domain creates a second VRAM placment with fpfn == 0. If VRAM is almost full, the first VRAM placement with fpfn > 0 may not work, but the second one with fpfn == 0 always will (the BO's current location trivially satisfies it). Because "moving" the BO to its current location puts it back on the LRU list, this results in an infinite loop.

Fixes 2a85aedd117c ("drm/radeon: Try evicting from CPU accessible to

inaccessible VRAM first")

---
 drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +2 -2
index 5c7cf644ba1d..37d68cd1f272 100644
@@ -213,8 +213,8 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,
 			rbo->placement.num_busy_placement = 0;
 			for (i = 0; i < rbo->placement.num_placement; i++) {
 				if (rbo->placements[i].flags & TTM_PL_FLAG_VRAM) {
-					if (rbo->placements[0].fpfn < fpfn)
-						rbo->placements[0].fpfn = fpfn;
+					if (rbo->placements[i].fpfn < fpfn)
+						rbo->placements[i].fpfn = fpfn;
 				} else {
 					rbo->placement.busy_placement =
 						&rbo->placements[i];
Signature · 6 lines
2.11.0

_______________________________________________
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): 20170327005843.2009-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#2 lore raw

Am 27.03.2017 um 02:58 schrieb Michel Dänzer:

Quoted 11 lines

From: Michel Dänzer <[email protected]>

We were accidentally only overriding the first VRAM placement. For BOs with the RADEON_GEM_NO_CPU_ACCESS flag set, radeon_ttm_placement_from_domain creates a second VRAM placment with fpfn == 0. If VRAM is almost full, the first VRAM placement with fpfn > 0 may not work, but the second one with fpfn == 0 always will (the BO's current location trivially satisfies it). Because "moving" the BO to its current location puts it back on the LRU list, this results in an infinite loop.

Quoted 5 lines
Fixes 2a85aedd117c ("drm/radeon: Try evicting from CPU accessible to

inaccessible VRAM first")

Quoted 9 lines
---
  drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +0 -0
index 5c7cf644ba1d..37d68cd1f272 100644

drivers/gpu/drm/radeon/radeon_ttm.c static void radeon_evict_flags(struct ttm_buffer_object *bo, · line 220

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_ttm.c +2 -2
@@ -213,8 +213,8 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,
  			rbo->placement.num_busy_placement = 0;
  			for (i = 0; i < rbo->placement.num_placement; i++) {
  				if (rbo->placements[i].flags & TTM_PL_FLAG_VRAM) {
-					if (rbo->placements[0].fpfn < fpfn)
-						rbo->placements[0].fpfn = fpfn;
+					if (rbo->placements[i].fpfn < fpfn)
+						rbo->placements[i].fpfn = fpfn;
  				} else {
  					rbo->placement.busy_placement =
  						&rbo->placements[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): 9485c238-d562-c363-f108-0c736af440eb-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#4 lore raw

Hi Michel,

Great ! Would you mind to just add a note to mention that the infinite loop actually happens in ttm_bo_mem_force_space ? Thx!

Cheers
Julien

Quoted 48 lines · Christian König

Am 27.03.2017 um 02:58 schrieb Michel Dänzer:

Quoted 11 lines

From: Michel Dänzer <[email protected]>

We were accidentally only overriding the first VRAM placement. For BOs with the RADEON_GEM_NO_CPU_ACCESS flag set, radeon_ttm_placement_from_domain creates a second VRAM placment with fpfn == 0. If VRAM is almost full, the first VRAM placement with fpfn > 0 may not work, but the second one with fpfn == 0 always will (the BO's current location trivially satisfies it). Because "moving" the BO to its current location puts it back on the LRU list, this results in an infinite loop.

Quoted 6 lines
Fixes 2a85aedd117c ("drm/radeon: Try evicting from CPU accessible to

inaccessible VRAM first")

---

Quoted 25 lines
  drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +0 -2
index 5c7cf644ba1d..37d68cd1f272 100644
@@ -213,8 +213,8 @@ static void radeon_evict_flags(struct
 ttm_buffer_object *bo,
                        rbo->placement.num_busy_placement = 0;
                        for (i = 0; i < rbo->placement.num_placement;
 i++) {
                                if (rbo->placements[i].flags &
 TTM_PL_FLAG_VRAM) {
-                                       if (rbo->placements[0].fpfn <
 fpfn)
-                                               rbo->placements[0].fpfn =

fpfn;
+ if (rbo->placements[i].fpfn <
fpfn)
+ rbo->placements[i].fpfn =

fpfn;
                                } else {
                                        rbo->placement.busy_placement =
Quoted 9 lines
Quoted 2 lines
                                                &rbo->placements[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): CAHWPjbXtsgnbdFw1W0JPzVUDdtvUDmp+9_UFMicwCTGOedcZLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 4 lines · Julien Isorce

Hi Michel,

Great ! Would you mind to just add a note to mention that the infinite loop actually happens in ttm_bo_mem_force_space ? Thx!

I'm afraid it might be too late, as I already pushed the fix to the amd-staging-4.9 branch. I guess Alex could still add it before he includes the fix in a pull request though.

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
#7 lore raw
In reply to a message not in the archive

Thanks for the help and the quick turnaround!

Quoted 43 lines · Christian König

Am 27.03.2017 um 02:58 schrieb Michel Dänzer:

Quoted 11 lines

From: Michel Dänzer <[email protected]>

We were accidentally only overriding the first VRAM placement. For BOs with the RADEON_GEM_NO_CPU_ACCESS flag set, radeon_ttm_placement_from_domain creates a second VRAM placment with fpfn == 0. If VRAM is almost full, the first VRAM placement with fpfn > 0 may not work, but the second one with fpfn == 0 always will (the BO's current location trivially satisfies it). Because "moving" the BO to its current location puts it back on the LRU list, this results in an infinite loop.

Quoted 6 lines
Fixes 2a85aedd117c ("drm/radeon: Try evicting from CPU accessible to

inaccessible VRAM first")

---

Quoted 19 lines
  drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +0 -2
index 5c7cf644ba1d..37d68cd1f272 100644
@@ -213,8 +213,8 @@ static void radeon_evict_flags(struct
 ttm_buffer_object *bo,
                        rbo->placement.num_busy_placement = 0;
                        for (i = 0; i < rbo->placement.num_placement;
 i++) {
                                if (rbo->placements[i].flags &
 TTM_PL_FLAG_VRAM) {
-                                       if (rbo->placements[0].fpfn <
 fpfn)
-                                               rbo->placements[0].fpfn =

fpfn;

Quoted 11 lines
Quoted 8 lines

+ if (rbo->placements[i].fpfn <
fpfn)
+ rbo->placements[i].fpfn =

fpfn;
                                } else {
                                        rbo->placement.busy_placement =
                                                &rbo->placements[i];

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

Reviewed-by Alex Deucher
#8 lore raw
In reply to a message not in the archive
Quoted 21 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Sunday, March 26, 2017 8:59 PM
To: [email protected]
Cc: Zachary Michaels; Julien Isorce
Subject: [PATCH] drm/radeon: Override fpfn for all VRAM placements in radeon_evict_flags

From: Michel Dänzer <[email protected]>

We were accidentally only overriding the first VRAM placement. For BOs with the RADEON_GEM_NO_CPU_ACCESS flag set, radeon_ttm_placement_from_domain creates a second VRAM placment with
fpfn == 0. If VRAM is almost full, the first VRAM placement with fpfn > 0 may not work, but the second one with fpfn == 0 always will (the BO's current location trivially satisfies it). Because "moving" the BO to its current location puts it back on the LRU list, this results in an infinite loop.

Quoted 5 lines
Fixes 2a85aedd117c ("drm/radeon: Try evicting from CPU accessible to

inaccessible VRAM first")

Quoted 27 lines
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +2 -2
index 5c7cf644ba1d..37d68cd1f272 100644
@@ -213,8 +213,8 @@ static void radeon_evict_flags(struct
 ttm_buffer_object *bo,
 			rbo->placement.num_busy_placement = 0;
 			for (i = 0; i < rbo->placement.num_placement; i++) {
 				if (rbo->placements[i].flags &
 TTM_PL_FLAG_VRAM) {
-					if (rbo->placements[0].fpfn < fpfn)
-						rbo->placements[0].fpfn =
 fpfn;
+					if (rbo->placements[i].fpfn < fpfn)
+						rbo->placements[i].fpfn =

fpfn;

drivers/gpu/drm/radeon/radeon_ttm.c +0 -1
 				} else {
 					rbo->placement.busy_placement =
 						&rbo->placements[i];
--

2.11.0

Quoted 4 lines

_______________________________________________
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