<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p></p>
<div>Change-Id: I55e90ae63dd653463817df351050370fc7e896ca<br>
Signed-off-by: David Mao <david.mao@amd.com><br>
---<br>
amdgpu/amdgpu_vamgr.c | 6 +++++-<br>
1 file changed, 5 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c<br>
index 82653e9..23be1ff 100644<br>
--- a/amdgpu/amdgpu_vamgr.c<br>
+++ b/amdgpu/amdgpu_vamgr.c<br>
@@ -192,10 +192,14 @@ static uint64_t amdgpu_vamgr_find_va_in_range(struct amdgpu_bo_va_mgr *mgr, uint<br>
(hole->offset < range_min && range_min + size > hole->offset + hole->size) ||<br>
hole->size < size)<br>
continue;<br>
- offset = hole->offset;<br>
+ // it is possible that the hole covers more than one range,<br>
+ // thus we need to respect the range_min<br>
+ offset = MAX2(hole->offset, range_min);<br>
waste = offset % alignment;<br>
waste = waste ? alignment - waste : 0;<br>
offset += waste;<br>
+ // the gap between the range_min and hole->offset need to be covered as well<br>
+ waste += offset - hole->offset;<br>
if (offset >= (hole->offset + hole->size)) {<br>
continue;<br>
}</div>
<br>
<p></p>
</div>
</body>
</html>