[PATCH 1/1] amdgpu: va allocation may fall to the range outside of requested [min,max]

Wang, Qingqing Qingqing.Wang at amd.com
Wed Jun 29 05:42:11 UTC 2016


Change-Id: I55e90ae63dd653463817df351050370fc7e896ca
Signed-off-by: David Mao <david.mao at amd.com>
---
 amdgpu/amdgpu_vamgr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
index 82653e9..bc2d302 100644
--- a/amdgpu/amdgpu_vamgr.c
+++ b/amdgpu/amdgpu_vamgr.c
@@ -192,10 +192,14 @@ static uint64_t amdgpu_vamgr_find_va_in_range(struct amdgpu_bo_va_mgr *mgr, uint
             (hole->offset < range_min && range_min + size > hole->offset + hole->size) ||
             hole->size < size)
             continue;
-        offset = hole->offset;
+        // it is possible that the hole covers more than one range,
+        // thus we need to respect the range_min
+        offset = MAX2(hole->offset, range_min);
         waste = offset % alignment;
         waste = waste ? alignment - waste : 0;
         offset += waste;
+        // the gap between the range_min and hole->offset need to be covered as well
+        waste = offset - hole->offset;
         if (offset >= (hole->offset + hole->size)) {
             continue;
         }
--

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20160629/cd395364/attachment.html>


More information about the amd-gfx mailing list