<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Ok no worries I'll fix it up and push it later today.<br>
<br>
Btw I didn't use an inline cast because the macro kept breaking. I tried variants of parentheses and nothing worked.... Odd...<br>
<br>
<br>
Thanks,<br>
Tom<br>
<br>
<div class="gmail_quote">On June 17, 2019 3:32:03 PM EDT, "Kuehling, Felix" <Felix.Kuehling@amd.com> wrote:
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On 2019-06-17 3:28 p.m., Christian König wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Am 17.06.19 um 21:15 schrieb Kuehling, Felix:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> Looks good to me. One cosmetic comment inline. With that fixed this<br> patch is Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com><br><br> On 2019-06-14 12:51 p.m., StDenis, Tom wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #8ae234; 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 <tom.stdenis@amd.com><hr> 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 <br> 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 <br> ttm_mem_type_manager *man,<br> uint64_t vis_usage = 0;<br> unsigned i;<br> int r;<br> + uint64_t mem_bytes;<br></blockquote>Christian likes the "upside-down christmas tree" to help readability of<br>local variable declarations.<br></blockquote><br> Ah, yeah. Thanks for the note.<br><br> I actually don't care about that much, but I always get rejects from <br> upstream subsystem maintainers if I don't do this.<br><br> It's most likely not even documented somewhere,<br></blockquote><br>Right. The fact that I even noticed it probably means that I have a mild <br>case of OCD myself. If it was a strict requirement, it should be caught <br>by checkpatch.pl.<br><br>Cheers,<br> Felix<br><br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> Christian.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"><br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #8ae234; padding-left: 1ex;"> lpfn = place->lpfn;<br> if (!lpfn)<br> lpfn = man->size;<br> /* bail out quickly if there's likely not enough VRAM for <br>this BO */<br>- if (atomic64_add_return(mem->num_pages << PAGE_SHIFT, <br>&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) > <br>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 <br>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></blockquote><hr>amd-gfx mailing list<br>amd-gfx@lists.freedesktop.org<br><a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br></blockquote><br></blockquote></pre>
</blockquote>
</div>
</body>
</html>