<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<br>
<br>
<div class="moz-cite-prefix">Am 03.08.23 um 17:27 schrieb Yu, Lang:<br>
</div>
<blockquote type="cite" cite="mid:DM6PR12MB4250A5E1A001AC54DCC0F471FB08A@DM6PR12MB4250.namprd12.prod.outlook.com">
<p style="font-family:Arial;font-size:10pt;color:#008000;margin:15pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[Public]<br>
</p>
<br>
<div>
<div dir="ltr">
<div>
<div>
<div dir="ltr">
<div dir="ltr">Ping</div>
<div dir="ltr"><br>
<span id="ms-outlook-ios-cursor"></span></div>
</div>
</div>
<div id="mail-editor-reference-message-container" class="ms-outlook-mobile-reference-message">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri,
sans-serif"><b>发件人:</b> Yu, Lang
<a class="moz-txt-link-rfc2396E" href="mailto:Lang.Yu@amd.com"><Lang.Yu@amd.com></a><br>
<b>发送时间:</b> 星期二, 八月 1, 2023 15:16<br>
<b>收件人:</b> <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-rfc2396E" href="mailto:amd-gfx@lists.freedesktop.org"><amd-gfx@lists.freedesktop.org></a><br>
<b>抄送:</b> Koenig, Christian
<a class="moz-txt-link-rfc2396E" href="mailto:Christian.Koenig@amd.com"><Christian.Koenig@amd.com></a>; Paneer Selvam,
Arunpravin <a class="moz-txt-link-rfc2396E" href="mailto:Arunpravin.PaneerSelvam@amd.com"><Arunpravin.PaneerSelvam@amd.com></a>;
Zhang, Yifan <a class="moz-txt-link-rfc2396E" href="mailto:Yifan1.Zhang@amd.com"><Yifan1.Zhang@amd.com></a>; Yu, Lang
<a class="moz-txt-link-rfc2396E" href="mailto:Lang.Yu@amd.com"><Lang.Yu@amd.com></a><br>
<b>主题:</b> [PATCH v3] drm/amdgpu: refine
amdgpu_bo_create_kernel_at()
<div> </div>
</font></div>
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Use amdgpu_bo_create_reserved()
to create a BO in VRAM<br>
domain would fail if requested VRAM size is
large(>128MB)<br>
on APU which usually has a default 512MB VRAM.<br>
<br>
That's because VRAM is framgented after several
allocations.<br>
<br>
The approach is using amdgpu_bo_create_reserved() to<br>
create a BO in CPU domain first, it will always
succeed.<br>
<br>
v2: Don't overwrite the contents at specific offset.<br>
v3: Don't return GPU addr.<br>
<br>
Signed-off-by: Lang Yu <a class="moz-txt-link-rfc2396E" href="mailto:Lang.Yu@amd.com"><Lang.Yu@amd.com></a><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19
++++++++++++++-----<br>
1 file changed, 14 insertions(+), 5 deletions(-)<br>
<br>
diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
index ff73cc11d47e..df5ba9509a41 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
@@ -377,27 +377,36 @@ int
amdgpu_bo_create_kernel_at(struct amdgpu_device
*adev,<br>
size = ALIGN(size, PAGE_SIZE);<br>
<br>
r = amdgpu_bo_create_reserved(adev, size,
PAGE_SIZE,<br>
-
AMDGPU_GEM_DOMAIN_VRAM, bo_ptr, NULL,<br>
- cpu_addr);<br>
+
AMDGPU_GEM_DOMAIN_CPU,<br>
+ bo_ptr, NULL,
NULL);<br>
if (r)<br>
return r;<br>
<br>
if ((*bo_ptr) == NULL)<br>
return 0;<br>
<br>
+ (*bo_ptr)->preferred_domains =
AMDGPU_GEM_DOMAIN_VRAM;<br>
+ (*bo_ptr)->allowed_domains =
(*bo_ptr)->preferred_domains;<br>
+ (*bo_ptr)->flags =
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;<br>
+ (*bo_ptr)->flags |= cpu_addr ?
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED<br>
+ : AMDGPU_GEM_CREATE_NO_CPU_ACCESS;<br>
+<br>
/*<br>
* Remove the original mem node and create
a new one at the request<br>
* position.<br>
*/<br>
- if (cpu_addr)<br>
- amdgpu_bo_kunmap(*bo_ptr);<br>
-<br>
ttm_resource_free(&(*bo_ptr)->tbo,
&(*bo_ptr)->tbo.resource);<br>
</div>
</span></font></div>
</div>
</div>
</div>
</blockquote>
<br>
Thinking more about it. As far as I can see this change should be
unnecessary.<br>
<br>
We remove the BO resources anyway and this interface here is only
meant to be used for small reservations needed for BIOS handover.<br>
<br>
Might still be a nice cleanup, but not something we should be doing
easily.<br>
<br>
Christian.<br>
<br>
<blockquote type="cite" cite="mid:DM6PR12MB4250A5E1A001AC54DCC0F471FB08A@DM6PR12MB4250.namprd12.prod.outlook.com">
<div>
<div dir="ltr">
<div>
<div id="mail-editor-reference-message-container" class="ms-outlook-mobile-reference-message"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">
<br>
for (i = 0; i <
(*bo_ptr)->placement.num_placement; ++i) {<br>
(*bo_ptr)->placements[i].fpfn =
offset >> PAGE_SHIFT;<br>
(*bo_ptr)->placements[i].lpfn =
(offset + size) >> PAGE_SHIFT;<br>
+ (*bo_ptr)->placements[i].mem_type
= TTM_PL_VRAM;<br>
+ (*bo_ptr)->placements[i].flags =
TTM_PL_FLAG_CONTIGUOUS;<br>
+<br>
+ if (!((*bo_ptr)->flags &
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED))<br>
+
(*bo_ptr)->placements[i].flags |=
TTM_PL_FLAG_TOPDOWN;<br>
}<br>
+<br>
r =
ttm_bo_mem_space(&(*bo_ptr)->tbo,
&(*bo_ptr)->placement,<br>
&(*bo_ptr)->tbo.resource, &ctx);<br>
if (r)<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>