<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">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Please ignore this email, the patch was accidentally sent twice.<br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>发件人:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Wang, Qingqing <Qingqing.Wang@amd.com><br>
<b>发送时间:</b> 2016年6月29日 12:26:02<br>
<b>收件人:</b> amd-gfx@lists.freedesktop.org<br>
<b>主题:</b> [PATCH 1/1] amdgpu: va allocation may fall to the range outside of requested [min,max]</font>
<div> </div>
</div>
<div>
<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>
</div>
</body>
</html>