drm/ttm: Don't evict BOs outside of the requested placement range
Subsystems (3)
PATCH 1/1 drm/ttm: Don't evict BOs outside of the requested placement range
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +17 -3
@@ -709,6 +709,7 @@ out:static int ttm_mem_evict_first (struct ttm_bo_device *bdev,uint32_t mem_type, +const struct ttm_place *place,bool interruptible,bool no_wait_gpu) {
@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);list_for_each_entry (bo, &man->lru, lru) { ret =__ttm_bo_reserve (bo, false, true, false,NULL ); -if (!ret) +if (!ret) { +if (place && (place->fpfn || place->lpfn)) { +/* Don't evict this BO if it's outside of the +* requested placement range +*/ +if (place->fpfn >= (bo->mem.start + bo->mem.size) || + (place->lpfn && place->lpfn <= bo->mem.start)) { +__ttm_bo_unreserve (bo); + ret = -EBUSY ; +continue ; + } + } +break ; + } }if (ret) {
@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,return ret;if (mem->mm_node)break ; - ret =ttm_mem_evict_first (bdev, mem_type, + ret =ttm_mem_evict_first (bdev, mem_type, place, interruptible, no_wait_gpu);if (unlikely (ret !=0 ))return ret;
@@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);while (!list_empty (&man->lru)) {spin_unlock (&glob->lru_lock); - ret =ttm_mem_evict_first (bdev, mem_type, false, false); + ret =ttm_mem_evict_first (bdev, mem_type,NULL , false, false);if (ret) {if (allow_errors) {return ret;
Signature · 6 lines
2.1.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 09.10.2014 um 08:02 schrieb Michel Dänzer:
Quoted 12 lines
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Quoted 6 lines
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Signed-off-by Michel Dänzer <[email protected]>
Quoted 49 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +16
-2@@ -709,6 +709,7 @@ out:static int ttm_mem_evict_first (struct ttm_bo_device *bdev,uint32_t mem_type, +const struct ttm_place *place,bool interruptible,bool no_wait_gpu) {@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);list_for_each_entry (bo, &man->lru, lru) { ret =__ttm_bo_reserve (bo, false, true, false,NULL ); -if (!ret) +if (!ret) { +if (place && (place->fpfn || place->lpfn)) { +/* Don't evict this BO if it's outside of the +* requested placement range +*/ +if (place->fpfn >= (bo->mem.start + bo->mem.size) || + (place->lpfn && place->lpfn <= bo->mem.start)) { +__ttm_bo_unreserve (bo); + ret = -EBUSY ; +continue ; + } + } +break ; + } }if (ret) {@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,return ret;if (mem->mm_node)break ; - ret =ttm_mem_evict_first (bdev, mem_type, + ret =ttm_mem_evict_first (bdev, mem_type, place, interruptible, no_wait_gpu);if (unlikely (ret !=0 ))return ret;
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, · line 1253
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);while (!list_empty (&man->lru)) {spin_unlock (&glob->lru_lock); - ret =ttm_mem_evict_first (bdev, mem_type, false, false); + ret =ttm_mem_evict_first (bdev, mem_type,NULL , false, false);if (ret) {if (allow_errors) {return ret;
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 77 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Signed-off-by Michel Dänzer <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +15
-1@@ -709,6 +709,7 @@ out:static int ttm_mem_evict_first (struct ttm_bo_device *bdev,uint32_t mem_type, +const struct ttm_place *place,bool interruptible,bool no_wait_gpu) {@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);list_for_each_entry (bo, &man->lru, lru) { ret =__ttm_bo_reserve (bo, false, true, false,NULL ); -if (!ret) +if (!ret) { +if (place && (place->fpfn || place->lpfn)) { +/* Don't evict this BO if it's outside of the +* requested placement range +*/ +if (place->fpfn >= (bo->mem.start + bo->mem.size) || + (place->lpfn && place->lpfn <= bo->mem.start)) { +__ttm_bo_unreserve (bo); + ret = -EBUSY ; +continue ; + } + } +break ; + } }drivers/gpu/drm/ttm/ttm_bo.c +1
-1if (ret) {@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(structttm_buffer_object *bo, return ret;if (mem->mm_node)break ; - ret =ttm_mem_evict_first (bdev, mem_type, + ret =ttm_mem_evict_first (bdev, mem_type, place, interruptible, no_wait_gpu);if (unlikely (ret !=0 ))drivers/gpu/drm/ttm/ttm_bo.c +1
-1return ret;@@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);while (!list_empty (&man->lru)) {spin_unlock (&glob->lru_lock); - ret =ttm_mem_evict_first (bdev, mem_type, false, false); + ret =ttm_mem_evict_first (bdev, mem_type,NULL , false, false);if (ret) {if (allow_errors) {
Quoted 1 line
return ret;
I believe you need to "s/place/placement/" over this patch.
Signature · 6 lines
Alan. _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 69 lines · Alan Swanson
Quoted 68 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Signed-off-by Michel Dänzer <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +15
-1@@ -709,6 +709,7 @@ out:static int ttm_mem_evict_first (struct ttm_bo_device *bdev,uint32_t mem_type, +const struct ttm_place *place,bool interruptible,bool no_wait_gpu) {@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);list_for_each_entry (bo, &man->lru, lru) { ret =__ttm_bo_reserve (bo, false, true, false,NULL ); -if (!ret) +if (!ret) { +if (place && (place->fpfn || place->lpfn)) { +/* Don't evict this BO if it's outside of the +* requested placement range +*/ +if (place->fpfn >= (bo->mem.start + bo->mem.size) || + (place->lpfn && place->lpfn <= bo->mem.start)) { +__ttm_bo_unreserve (bo); + ret = -EBUSY ; +continue ; + } + } +break ; + } }if (ret) {drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(structttm_buffer_object *bo, return ret;if (mem->mm_node)break ; - ret =ttm_mem_evict_first (bdev, mem_type, + ret =ttm_mem_evict_first (bdev, mem_type, place, interruptible, no_wait_gpu);if (unlikely (ret !=0 ))return ret;
[...]
Quoted 1 line
I believe you need to "s/place/placement/" over this patch.
The fpfn and lpfn members were moved from struct ttm_placement to a new struct ttm_place in f1217ed09f827e42a49ffa6a5aab672aa6f57a65.
If you mean something else, please elaborate.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 24 lines · Michel Dänzer
Quoted 16 lines · Alan Swanson
Quoted 15 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Quoted 7 lines
Quoted 7 lines
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Signed-off-by Michel Dänzer <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Quoted 8 lines
[...]
Quoted 1 line
I believe you need to "s/place/placement/" over this patch.
The fpfn and lpfn members were moved from struct
ttm_placementto a new structttm_placeinf1217ed09f827e42a49ffa6a5aab672aa6f57a65.If you mean something else, please elaborate.
This patch failed to build on 3.17.0 so wouldn't be a candidate for stable unless the currently drm-next only ttm_place patch also goes to stable (else replace ttm_place with ttm_placements in the patch for stable)?
Signature · 1 line
Alan.
Quoted 32 lines · Alan Swanson
Quoted 31 lines · Michel Dänzer
Quoted 23 lines · Alan Swanson
Quoted 22 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Signed-off-by Michel Dänzer <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)[...]
Quoted 1 line
I believe you need to "s/place/placement/" over this patch.
The fpfn and lpfn members were moved from struct
ttm_placementto a new structttm_placeinf1217ed09f827e42a49ffa6a5aab672aa6f57a65.
Quoted 6 lines
Quoted 1 line
If you mean something else, please elaborate.
This patch failed to build on 3.17.0 so wouldn't be a candidate for stable unless the currently drm-next only
ttm_placepatch also goes to stable (else replacettm_placewithttm_placementsin the patch for stable)?
Right, I guess I should drop the Cc: stable then and submit a manual backport of it to the stable list once it has landed in Linus' tree.
Signature · 2 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer
Quoted 35 lines · Michel Dänzer
Quoted 34 lines · Alan Swanson
Quoted 32 lines · Michel Dänzer
Quoted 23 lines · Alan Swanson
Quoted 22 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Signed-off-by Michel Dänzer <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)[...]
Quoted 1 line
I believe you need to "s/place/placement/" over this patch.
The fpfn and lpfn members were moved from struct
ttm_placementto a new structttm_placeinf1217ed09f827e42a49ffa6a5aab672aa6f57a65.If you mean something else, please elaborate.
Quoted 7 lines
Quoted 4 lines
This patch failed to build on 3.17.0 so wouldn't be a candidate for stable unless the currently drm-next only
ttm_placepatch also goes to stable (else replacettm_placewithttm_placementsin the patch for stable)?Right, I guess I should drop the Cc: stable then and submit a manual backport of it to the stable list once it has landed in Linus' tree.
I've thought it's ok to cc: stable a patch - Greg's scripts will send you a mail as a nice reminder if the patch fails to apply. At least we regularly pull this stunt with i915 patches. Cc'ing Greg for clarification.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 41 lines · Daniel Vetter
Quoted 40 lines · Michel Dänzer
Quoted 38 lines · Alan Swanson
Quoted 24 lines · Michel Dänzer
Quoted 16 lines · Alan Swanson
Quoted 15 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Quoted 7 lines
Quoted 7 lines
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Signed-off-by Michel Dänzer <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)Quoted 8 lines
[...]
Quoted 1 line
I believe you need to "s/place/placement/" over this patch.
The fpfn and lpfn members were moved from struct
ttm_placementto a new structttm_placeinf1217ed09f827e42a49ffa6a5aab672aa6f57a65.If you mean something else, please elaborate.
This patch failed to build on 3.17.0 so wouldn't be a candidate for stable unless the currently drm-next only
ttm_placepatch also goes to stable (else replacettm_placewithttm_placementsin the patch for stable)?
Quoted 7 lines
Quoted 2 lines
Right, I guess I should drop the Cc: stable then and submit a manual backport of it to the stable list once it has landed in Linus' tree.
I've thought it's ok to cc: stable a patch - Greg's scripts will send you a mail as a nice reminder if the patch fails to apply. At least we regularly pull this stunt with i915 patches. Cc'ing Greg for clarification.
Yup, that's fine to do, it's what the scripts are for :)
Quoted 45 lines · Greg KH
Quoted 44 lines · Daniel Vetter
Quoted 42 lines · Michel Dänzer
Quoted 32 lines · Alan Swanson
Quoted 31 lines · Michel Dänzer
Quoted 23 lines · Alan Swanson
Quoted 22 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Signed-off-by Michel Dänzer <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)[...]
Quoted 1 line
I believe you need to "s/place/placement/" over this patch.
The fpfn and lpfn members were moved from struct
ttm_placementto a new structttm_placeinf1217ed09f827e42a49ffa6a5aab672aa6f57a65.Quoted 6 lines
Quoted 1 line
If you mean something else, please elaborate.
This patch failed to build on 3.17.0 so wouldn't be a candidate for stable unless the currently drm-next only
ttm_placepatch also goes to stable (else replacettm_placewithttm_placementsin the patch for stable)?Right, I guess I should drop the Cc: stable then and submit a manual backport of it to the stable list once it has landed in Linus' tree.
Quoted 6 lines
Quoted 4 lines
I've thought it's ok to cc: stable a patch - Greg's scripts will send you a mail as a nice reminder if the patch fails to apply. At least we regularly pull this stunt with i915 patches. Cc'ing Greg for clarification.
Yup, that's fine to do, it's what the scripts are for :)
Okay, thanks guys for the clarification.
Signature · 2 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer
PATCH v2 1/1 drm/ttm: Don't evict BOs outside of the requested placement range
In reply to Michel DänzerFrom: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
---
v2: Dropped Cc: stable, will need to backport manually because the code
has changed since 3.17
drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +17 -3
@@ -709,6 +709,7 @@ out:static int ttm_mem_evict_first (struct ttm_bo_device *bdev,uint32_t mem_type, +const struct ttm_place *place,bool interruptible,bool no_wait_gpu) {
@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);list_for_each_entry (bo, &man->lru, lru) { ret =__ttm_bo_reserve (bo, false, true, false,NULL ); -if (!ret) +if (!ret) { +if (place && (place->fpfn || place->lpfn)) { +/* Don't evict this BO if it's outside of the +* requested placement range +*/ +if (place->fpfn >= (bo->mem.start + bo->mem.size) || + (place->lpfn && place->lpfn <= bo->mem.start)) { +__ttm_bo_unreserve (bo); + ret = -EBUSY ; +continue ; + } + } +break ; + } }if (ret) {
@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,return ret;if (mem->mm_node)break ; - ret =ttm_mem_evict_first (bdev, mem_type, + ret =ttm_mem_evict_first (bdev, mem_type, place, interruptible, no_wait_gpu);if (unlikely (ret !=0 ))return ret;
@@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);while (!list_empty (&man->lru)) {spin_unlock (&glob->lru_lock); - ret =ttm_mem_evict_first (bdev, mem_type, false, false); + ret =ttm_mem_evict_first (bdev, mem_type,NULL , false, false);if (ret) {if (allow_errors) {return ret;
Signature · 6 lines
2.1.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 12 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Quoted 6 lines
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Signed-off-by Michel Dänzer <[email protected]>
Thomas, do you want to pull this through the ttm tree or can I take it through radeon?
Alex
Quoted 60 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +17
-4@@ -709,6 +709,7 @@ out:static int ttm_mem_evict_first (struct ttm_bo_device *bdev,uint32_t mem_type, +const struct ttm_place *place,bool interruptible,bool no_wait_gpu) {@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);list_for_each_entry (bo, &man->lru, lru) { ret =__ttm_bo_reserve (bo, false, true, false,NULL ); -if (!ret) +if (!ret) { +if (place && (place->fpfn || place->lpfn)) { +/* Don't evict this BO if it's outside of the +* requested placement range +*/ +if (place->fpfn >= (bo->mem.start + bo->mem.size) || + (place->lpfn && place->lpfn <= bo->mem.start)) { +__ttm_bo_unreserve (bo); + ret = -EBUSY ; +continue ; + } + } +break ; + } }if (ret) {@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,return ret;if (mem->mm_node)break ; - ret =ttm_mem_evict_first (bdev, mem_type, + ret =ttm_mem_evict_first (bdev, mem_type, place, interruptible, no_wait_gpu);if (unlikely (ret !=0 ))return ret;@@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);while (!list_empty (&man->lru)) {spin_unlock (&glob->lru_lock); - ret =ttm_mem_evict_first (bdev, mem_type, false, false); + ret =ttm_mem_evict_first (bdev, mem_type,NULL , false, false);if (ret) {if (allow_errors) {return ret; --2.1.1
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Alex,
Please pull these patches through Radeon,
Thanks,
Thomas
Quoted 86 lines · Alex Deucher
Quoted 12 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault.
Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit.
Quoted 6 lines
Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before.
Signed-off-by Michel Dänzer <[email protected]>Reviewed-by Alex Deucher <[email protected]>Thomas, do you want to pull this through the ttm tree or can I take it through radeon?
Alex
Quoted 60 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +17
-4@@ -709,6 +709,7 @@ out:static int ttm_mem_evict_first (struct ttm_bo_device *bdev,uint32_t mem_type, +const struct ttm_place *place,bool interruptible,bool no_wait_gpu) {@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);list_for_each_entry (bo, &man->lru, lru) { ret =__ttm_bo_reserve (bo, false, true, false,NULL ); -if (!ret) +if (!ret) { +if (place && (place->fpfn || place->lpfn)) { +/* Don't evict this BO if it's outside of the +* requested placement range +*/ +if (place->fpfn >= (bo->mem.start + bo->mem.size) || + (place->lpfn && place->lpfn <= bo->mem.start)) { +__ttm_bo_unreserve (bo); + ret = -EBUSY ; +continue ; + } + } +break ; + } }if (ret) {@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,return ret;if (mem->mm_node)break ; - ret =ttm_mem_evict_first (bdev, mem_type, + ret =ttm_mem_evict_first (bdev, mem_type, place, interruptible, no_wait_gpu);if (unlikely (ret !=0 ))return ret;@@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);while (!list_empty (&man->lru)) {spin_unlock (&glob->lru_lock); - ret =ttm_mem_evict_first (bdev, mem_type, false, false); + ret =ttm_mem_evict_first (bdev, mem_type,NULL , false, false);if (ret) {if (allow_errors) {return ret; --2.1.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/dri-devel&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=l5Ago9ekmVFZ3c4M6eauqrJWGwjf6fTb%2BP3CxbBFkVM%3D%0A&m=fUnmlW1Tlnje4oNF3duZPPLcUcRvxyQZ%2BA%2Fyl5YOGBc%3D%0A&s=3c28f2dc220442e12a62cd069fd203cefbe4b157be43987cebd908d2084e32e9
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel