<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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>Why not be consistent and add a DRM_ERROR on all paths that include an error? e.g. instead of </p>
<p><br>
</p>
<p>if (r)</p>
<p> goto error_free;</p>
<p><br>
</p>
<p>Throw a DRM_ERROR("") in there.</p>
<p><br>
</p>
<p>Tom</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Christian König <deathsimple@vodafone.de><br>
<b>Sent:</b> Wednesday, August 17, 2016 10:04<br>
<b>To:</b> Zhou, David(ChunMing); amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH 0/8] shadow page table support V5 ---> shadow bo support</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Patch #1:<br>
<br>
Could be that we need to add another module parameter to control this, <br>
but I think for now that should be sufficient.<br>
<br>
Patch is Reviewed-by: Christian König <christian.koenig@amd.com><br>
<br>
Patch #2:<br>
<br>
> + if (direct_submit) {<br>
> + r = amdgpu_ib_schedule(ring, job->num_ibs, job->ibs,<br>
> + NULL, NULL, fence);<br>
> + job->fence = fence_get(*fence);<br>
> + if (r)<br>
> + DRM_ERROR("Error scheduling IBs (%d)\n", r);<br>
> + amdgpu_job_free(job);<br>
<br>
When there is an error you should return the code as well.<br>
<br>
> + } else {<br>
> + r = amdgpu_job_submit(job, ring, &adev->mman.entity,<br>
> + AMDGPU_FENCE_OWNER_UNDEFINED, fence);<br>
> + if (r)<br>
> + goto error_free;<br>
> + }<br>
> <br>
> return 0;<br>
<br>
Just changing this to to "return r;" should be sufficient.<br>
<br>
With that fixed the patch is Reviewed-by: Christian König <br>
<christian.koenig@amd.com> as well.<br>
<br>
Patch #3:<br>
<br>
You mentioned that this isn't used during command submission but rather <br>
during GPU reset, correct?<br>
<br>
In this case I would advise not to use a member in the BO structure to <br>
note the backup direction and instead have one function for back and one <br>
for restoring the content (or note that as a parameter to the function).<br>
<br>
Otherwise we could run into trouble when the CS wants to backup <br>
something the GPU reset wants to restore at the same time.<br>
<br>
Patch #4: Was already reviewed by me.<br>
<br>
Patch #5:<br>
<br>
> + pt = params->shadow ? vm->page_tables[pt_idx].entry.robj->shadow :<br>
> + vm->page_tables[pt_idx].entry.robj;<br>
You need to double check here if shadows are actually allocated or not. <br>
Otherwise we will crash on an APU.<br>
<br>
> + /* double ndw, since need to update shadow pt bo as well */<br>
> + ndw *= 2;<br>
> +<br>
We don't need to double the IB size, but only the number of commands in <br>
it (ncmds).<br>
<br>
The difference is when we want to write scattered GART entries. In this <br>
case I've added the PTEs to the end of the IB.<br>
<br>
Patch #6:<br>
> + spinlock_t shadow_list_lock;<br>
We might want to use a mutex here instead. Usually I would agree that a <br>
spin lock is better for a linked list, but during the restore process in <br>
a GPU reset we probably want to sleep here.<br>
<br>
Alternatively you could splice the list to a local version on the stack, <br>
grab references to the BOs and then drop the lock during the restore <br>
process.<br>
<br>
> @@ -541,6 +546,13 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo)<br>
> if ((*bo) == NULL)<br>
> return;<br>
> <br>
> + /* shadow must be freed before bo itself */<br>
> + if ((!(*bo)->shadow) && !list_empty(&(*bo)->shadow_list)) {<br>
> + spin_lock(&(*bo)->adev->shadow_list_lock);<br>
> + list_del_init(&(*bo)->shadow_list);<br>
> + spin_unlock(&(*bo)->adev->shadow_list_lock);<br>
> +<br>
> + }<br>
> tbo = &((*bo)->tbo);<br>
> ttm_bo_unref(&tbo);<br>
> if (tbo == NULL)<br>
That would trigger even when we take a temporary reference. I suggest to <br>
add a amdgpu_bo_unref_shadow() function instead, unreferencing both the <br>
shadow and the normal BO.<br>
<br>
This can then be used in the VM code to cleanup the shadow created.<br>
<br>
Going to skip patch #7 and #8 for now cause our team call begins in a <br>
moment.<br>
<br>
Regards,<br>
Christian.<br>
<br>
Am 17.08.2016 um 08:05 schrieb Chunming Zhou:<br>
> Since we cannot ensure VRAM is consistent after a GPU reset, page<br>
> table shadowing is necessary. Shadowed page tables are, in a sense, a<br>
> method to recover the consistent state of the page tables before the<br>
> reset occurred.<br>
><br>
> We need to allocate GTT bo as the shadow of VRAM bo when creating page table,<br>
> and make them the same. After gpu reset, we will need to use SDMA to copy GTT bo<br>
> content to VRAM bo, then page table will be recoveried.<br>
><br>
><br>
> V2:<br>
> Shadow bo uses a shadow entity running on normal run queue, after gpu reset,<br>
> we need to wait for all shadow jobs finished first, then recovery page table from shadow.<br>
><br>
> V3:<br>
> Addressed Christian comments for shadow bo part.<br>
><br>
> V4:<br>
> Switch back to update page table twice (one of two is for shadow)<br>
><br>
> V5:<br>
> make it be gerneic shadow bo support. Address Christian comments.<br>
><br>
> Chunming Zhou (8):<br>
> drm/amdgpu: add need backup function V2<br>
> drm/amdgpu: add direct submision option for copy_buffer<br>
> drm/amdgpu: sync bo and shadow V2<br>
> drm/amdgpu: update pd shadow while updating pd<br>
> drm/amdgpu: update pt shadow while updating pt V2<br>
> drm/amdgpu: link all shadow bo<br>
> drm/amdgpu: implement recovery vram bo from shadow<br>
> drm/amdgpu: recover vram bo from shadow after gpu reset<br>
><br>
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++-<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 +-<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 39 ++++++++++-<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 94 ++++++++++++++++++++++++++-<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 9 +++<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 4 +-<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 ++++--<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 69 ++++++++++++++------<br>
> 8 files changed, 215 insertions(+), 33 deletions(-)<br>
><br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk214970">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_14714429737800.4406300387876183" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_14714429737780.3993206472027586" cellspacing="0" style="width: 90%; position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200); background-color: rgb(255, 255, 255);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_14714429737790.7705126490415855" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_14714429737790.7102716663188782"></div>
<div id="LPTitle_14714429737790.7634184458877278" style="top: 0px; color: rgb(59, 87, 119); font-weight: normal; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_14714429737790.6135333253292945" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank" style="text-decoration: none;">amd-gfx Info Page - lists.freedesktop.org</a></div>
<div id="LPMetadata_14714429737790.9058058508163938" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
lists.freedesktop.org</div>
<div id="LPDescription_14714429737800.03199008072574672" style="display: block; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
To see the collection of prior postings to the list, visit the amd-gfx Archives. Using amd-gfx: To post a message to all the list members, send email ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>