<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;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>I don't know if compiler is smart enough to optimize the following for statement out...</p>
<p><br>
</p>
<p><font size="2"><span style="font-size:10pt;">+               for (i = 0; i < ttm->num_pages; i++) {<br>
+                       trace_amdgpu_ttm_tt_populate(<br>
+                               adev,<br>
+                               gtt->ttm.dma_address[i],<br>
+                               page_to_phys(ttm->pages[i]));<br>
+               }</span></font></p>
<br>
<p>-Alex Bin<br>
</p>
<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 style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Christian König <deathsimple@vodafone.de><br>
<b>Sent:</b> Tuesday, August 1, 2017 11:41 AM<br>
<b>To:</b> Xie, AlexBin; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH] drm/amd/amdgpu: Add tracepoint for DMA page mapping</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">We can turn of the trace subsystem during compile time already.<br>
<br>
Additional to that the trace points use self modifying code to make sure <br>
that they don't have any overhead as long as they are turned off. But I <br>
don't think this works with the "if (trace_*_enabled()" as well.<br>
<br>
Anyway, not a performance critical code path so I don't really bother.<br>
<br>
Christian.<br>
<br>
Am 01.08.2017 um 17:00 schrieb axie:<br>
> Because this is used by a debug tool, can we use a macro to <br>
> conditionally compile this feature?<br>
><br>
><br>
> On 2017-08-01 10:54 AM, Christian König wrote:<br>
>> Am 01.08.2017 um 16:26 schrieb Tom St Denis:<br>
>>> On 01/08/17 10:10 AM, Christian König wrote:<br>
>>><br>
>>>> You need to cover multiple code path here:<br>
>>>> 1. The one you currently implemented which uses ttm_dma_populate() <br>
>>>> and pci_map_page().<br>
>>>> 2. The one using ttm_dma_populate().<br>
>>><br>
>>> I'll have to look into this one though it's my understanding that <br>
>>> code path is only followed if there's no (hardware) IOMMU right?<br>
>><br>
>> Wrong, that one is used when "anything" in the system used the <br>
>> SWIOTLB path once. So the detection doesn't always work reliable.<br>
>><br>
>>> This one seems rather straight forward but the only catch is I don't <br>
>>> have access to "adev" inside that drm function.<br>
>><br>
>> When you have a ttm you can always do "amdgpu_ttm_adev(ttm->bdev)" to <br>
>> get the adev.<br>
>><br>
>>>   Would it be taboo to do something like<br>
>>><br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c <br>
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>> index 376078334f54..cd97ef2144c9 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>> @@ -916,6 +916,12 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt <br>
>>> *ttm)<br>
>>>                 drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,<br>
>>> gtt->ttm.dma_address, ttm->num_pages);<br>
>>>                 ttm->state = tt_unbound;<br>
>>> +               for (i = 0; i < ttm->num_pages; i++) {<br>
>>> +                       trace_amdgpu_ttm_tt_populate(<br>
>>> +                               adev,<br>
>>> +                               gtt->ttm.dma_address[i],<br>
>>> + page_to_phys(ttm->pages[i]));<br>
>>> +               }<br>
>>>                 return 0;<br>
>>>         }<br>
>>><br>
>>> This would normally result in a for loop around a nop which <br>
>>> shouldn't be a huge performance hit but is one none the less.<br>
>><br>
>> Try using trace_trace_amdgpu_ttm_tt_populate_enabled(), those <br>
>> functions are generated by the trace subsystem automatically when you <br>
>> define a trace point.<br>
>><br>
>> It just doesn't use those nice tricks to modify the compiled binary <br>
>> on the fly.<br>
>><br>
>> Christian.<br>
>><br>
>>><br>
>>>> 4. The in amdgpu_ttm_tt_pin_userptr() which uses dma_map_sg() for <br>
>>>> userptrs.<br>
>>>><br>
>>>> Basically all just take gtt->ttm.ttm.pages and fill <br>
>>>> gtt->ttm.dma_address.<br>
>>><br>
>>> Same comment as #3.  I can tackle this with a for loop around the <br>
>>> trace if that is ok.<br>
>>><br>
>>>> I suggest to add a helper you can call to trace all <br>
>>>> pages->dma_address mappings inside a ttm.<br>
>>><br>
>>> One thing at a time :-).  That would probably be a bit better since <br>
>>> the trace log gets filled with remappings (which is why my <br>
>>> proof-of-concept umr patch only grabs the latest mapping as it reads <br>
>>> the trace).<br>
>>><br>
>>> Is there a handy place we can grab a list of ttm_tt's bound to our <br>
>>> device?  If so then in theory I could write a debugfs interface <br>
>>> instead.<br>
>>><br>
>>> Thanks for your patience as I'm definitely less familiar with the VM <br>
>>> side of things :-)<br>
>>><br>
>>> Cheers,<br>
>>> Tom<br>
>>> _______________________________________________<br>
>>> amd-gfx mailing list<br>
>>> amd-gfx@lists.freedesktop.org<br>
>>> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk518445" previewremoved="true">
https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_15016027613140.08295823990357198" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15016027613110.1813202064689361" style="width: 90%; background-color: rgb(255, 255, 255); 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);" role="presentation" cellspacing="0">
<tbody>
<tr style="border-spacing: 0px;" valign="top">
<td id="TextCell_15016027613120.5421751103538535" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;" colspan="2">
<div id="LPRemovePreviewContainer_15016027613120.2548737792421861"></div>
<div id="LPTitle_15016027613120.23212871138685842" style="top: 0px; color: rgb(0, 120, 215); font-weight: 400; 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_15016027613130.2533724279446574" style="text-decoration: none;" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank">amd-gfx Info Page - freedesktop.org</a></div>
<div id="LPMetadata_15016027613130.7874404914990427" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: 400; 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_15016027613130.5169047949058398" style="display: block; color: rgb(102, 102, 102); font-weight: 400; 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;">
Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following form. Use of all freedesktop.org lists is subject to our Code of ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<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="LPlnk434060" previewremoved="true">
https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_15016027613220.7871711856219648" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15016027613190.2615781169078024" style="width: 90%; background-color: rgb(255, 255, 255); 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);" role="presentation" cellspacing="0">
<tbody>
<tr style="border-spacing: 0px;" valign="top">
<td id="TextCell_15016027613200.08716742963535162" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;" colspan="2">
<div id="LPRemovePreviewContainer_15016027613200.6016969126942272"></div>
<div id="LPTitle_15016027613200.1704710881698085" style="top: 0px; color: rgb(0, 120, 215); font-weight: 400; 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_15016027613210.1055556852355326" style="text-decoration: none;" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank">amd-gfx Info Page - freedesktop.org</a></div>
<div id="LPMetadata_15016027613210.07358644878449205" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: 400; 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_15016027613210.74097043846146" style="display: block; color: rgb(102, 102, 102); font-weight: 400; 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;">
Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following form. Use of all freedesktop.org lists is subject to our Code of ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<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="LPlnk374752" previewremoved="true">
https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_15016028208780.5931683559589285" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15016028208740.92491337649414" style="width: 90%; background-color: rgb(255, 255, 255); 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);" role="presentation" cellspacing="0">
<tbody>
<tr style="border-spacing: 0px;" valign="top">
<td id="TextCell_15016028208750.5039491761540736" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;" colspan="2">
<div id="LPRemovePreviewContainer_15016028208750.8435103435108974"></div>
<div id="LPTitle_15016028208750.3076890768275301" style="top: 0px; color: rgb(0, 120, 215); font-weight: 400; 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_15016028208760.5932119976653863" style="text-decoration: none;" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank">amd-gfx Info Page - freedesktop.org</a></div>
<div id="LPMetadata_15016028208760.3609779223258601" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: 400; 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_15016028208770.6822461316553391" style="display: block; color: rgb(102, 102, 102); font-weight: 400; 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;">
Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following form. Use of all freedesktop.org lists is subject to our Code of ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>