<div dir="ltr">ping?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 14, 2019 at 12:51 PM StDenis, Tom <<a href="mailto:Tom.StDenis@amd.com">Tom.StDenis@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 32-bit hosts mem->num_pages is 32-bits and can overflow<br>
when shifted. Add a cast to avoid this.<br>
<br>
Signed-off-by: Tom St Denis <<a href="mailto:tom.stdenis@amd.com" target="_blank">tom.stdenis@amd.com</a>><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 8 +++++---<br>
1 file changed, 5 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c<br>
index c963ad86072e..31895d3c33de 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c<br>
@@ -279,14 +279,16 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,<br>
uint64_t vis_usage = 0;<br>
unsigned i;<br>
int r;<br>
+ uint64_t mem_bytes;<br>
<br>
lpfn = place->lpfn;<br>
if (!lpfn)<br>
lpfn = man->size;<br>
<br>
/* bail out quickly if there's likely not enough VRAM for this BO */<br>
- if (atomic64_add_return(mem->num_pages << PAGE_SHIFT, &mgr->usage) > adev->gmc.mc_vram_size) {<br>
- atomic64_sub(mem->num_pages << PAGE_SHIFT, &mgr->usage);<br>
+ mem_bytes = (u64)mem->num_pages << PAGE_SHIFT;<br>
+ if (atomic64_add_return(mem_bytes, &mgr->usage) > adev->gmc.mc_vram_size) {<br>
+ atomic64_sub(mem_bytes, &mgr->usage);<br>
mem->mm_node = NULL;<br>
return 0;<br>
}<br>
@@ -308,7 +310,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,<br>
nodes = kvmalloc_array((uint32_t)num_nodes, sizeof(*nodes),<br>
GFP_KERNEL | __GFP_ZERO);<br>
if (!nodes) {<br>
- atomic64_sub(mem->num_pages << PAGE_SHIFT, &mgr->usage);<br>
+ atomic64_sub(mem_bytes, &mgr->usage);<br>
return -ENOMEM;<br>
}<br>
<br>
-- <br>
2.21.0<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></blockquote></div>