<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">You could make the wave decode a gfx callback and move the code into the IP modules.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Alex<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org]
<b>On Behalf Of </b>StDenis, Tom<br>
<b>Sent:</b> Friday, October 14, 2016 6:56 AM<br>
<b>To:</b> Nicolai Hähnle<br>
<b>Cc:</b> amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH 1/3] drm/amd/amdgpu: Add wave reader to debugfs<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div id="divtagdefaultwrapper">
<p><span style="font-family:"Calibri","sans-serif";color:black">Hi Nicolai,<o:p></o:p></span></p>
<p><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span style="font-family:"Calibri","sans-serif";color:black">I was trying to avoid having ASIC specific includes/etc in the amdgpu_device.c file.  Agreed that de-numberifying it would be nice.  Maybe we can add some /**/ comments to clear it up.  I imagine
 in the future we'll add more fields (upto 32 in this design) anyways.<o:p></o:p></span></p>
<p><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span style="font-family:"Calibri","sans-serif";color:black">Cheers,<o:p></o:p></span></p>
<p><span style="font-family:"Calibri","sans-serif";color:black">Tom<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<div>
<div>
<div class="MsoNormal" align="center" style="text-align:center"><span style="font-family:"Calibri","sans-serif";color:black">
<hr size="2" width="98%" align="center">
</span></div>
<div id="x_divRplyFwdMsg">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black"> Nicolai Hähnle <<a href="mailto:nhaehnle@gmail.com">nhaehnle@gmail.com</a>><br>
<b>Sent:</b> Friday, October 14, 2016 03:25<br>
<b>To:</b> Tom St Denis; <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<b>Cc:</b> StDenis, Tom<br>
<b>Subject:</b> Re: [PATCH 1/3] drm/amd/amdgpu: Add wave reader to debugfs</span><span style="font-family:"Calibri","sans-serif";color:black">
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"> <o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:black">On 11.10.2016 21:18, Tom St Denis wrote:<br>
> Currently supports CZ/VI.  Allows nearly atomic read<br>
> of wave data from GPU.<br>
><br>
> Signed-off-by: Tom St Denis <<a href="mailto:tom.stdenis@amd.com">tom.stdenis@amd.com</a>><br>
> ---<br>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 74 ++++++++++++++++++++++++++++++<br>
>  1 file changed, 74 insertions(+)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> index 89b353418195..b1ab6358fa0f 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> @@ -2914,6 +2914,72 @@ static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf,<br>
>        return !r ? 4 : r;<br>
>  }<br>
><br>
> +static uint32_t wave_read_ind(struct amdgpu_device *adev, uint32_t SQ_INDEX, uint32_t SQ_DATA, uint32_t simd, uint32_t wave, uint32_t address)<br>
> +{<br>
> +     WREG32(SQ_INDEX, (wave & 0xF) | ((simd & 0x3) << 4) | (address << 16) | (1 << 13));<br>
> +     return RREG32(SQ_DATA);<br>
> +}<br>
> +<br>
> +static ssize_t amdgpu_debugfs_wave_read(struct file *f, char __user *buf,<br>
> +                                     size_t size, loff_t *pos)<br>
> +{<br>
> +     struct amdgpu_device *adev = f->f_inode->i_private;<br>
> +     int r, x;<br>
> +     ssize_t result=0;<br>
> +     uint32_t offset, se, sh, cu, wave, simd, data[16];<br>
> +     <br>
> +     if (size & 3 || *pos & 3)<br>
> +             return -EINVAL;<br>
> +<br>
> +     /* decode offset */<br>
> +     offset = (*pos & 0x7F);<br>
> +     se = ((*pos >> 7) & 0xFF);<br>
> +     sh = ((*pos >> 15) & 0xFF);<br>
> +     cu = ((*pos >> 23) & 0xFF);<br>
> +     wave = ((*pos >> 31) & 0xFF);<br>
> +     simd = ((*pos >> 37) & 0xFF);<br>
> +     *pos &= 0x7F;<br>
> +<br>
> +     /* switch to the specific se/sh/cu */<br>
> +     mutex_lock(&adev->grbm_idx_mutex);<br>
> +     amdgpu_gfx_select_se_sh(adev, se, sh, cu);<br>
> +<br>
> +     x = 0;<br>
> +     if (adev->family == AMDGPU_FAMILY_CZ || adev->family == AMDGPU_FAMILY_VI) {<br>
> +             /* type 0 wave data */<br>
> +             data[x++] = 0;<br>
> +             data[x++] = wave_read_ind(adev, 0x2378, 0x2379, simd, wave, 0x12);<br>
> +             data[x++] = wave_read_ind(adev, 0x2378, 0x2379, simd, wave, 0x18);<br>
> +             data[x++] = wave_read_ind(adev, 0x2378, 0x2379, simd, wave, 0x19);<br>
> +             data[x++] = wave_read_ind(adev, 0x2378, 0x2379, simd, wave, 0x27E);<br>
> +             data[x++] = wave_read_ind(adev, 0x2378, 0x2379, simd, wave, 0x27F);<br>
> +             data[x++] = wave_read_ind(adev, 0x2378, 0x2379, simd, wave, 0x14);<br>
> +             data[x++] = wave_read_ind(adev, 0x2378, 0x2379, simd, wave, 0x1A);<br>
> +             data[x++] = wave_read_ind(adev, 0x2378, 0x2379, simd, wave, 0x1B);<br>
<br>
I know this is just debug code, but it's still annoying to have all <br>
these magic constants here, when there are perfectly good ixSQ_WAVE_* <br>
etc. defines in the asic_reg headers.<br>
<br>
Nicolai<br>
<br>
> +     } else {<br>
> +             return -EINVAL;<br>
> +     }<br>
> +<br>
> +     amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);<br>
> +     mutex_unlock(&adev->grbm_idx_mutex);<br>
> +<br>
> +     while (size && (*pos < x * 4)) {<br>
> +             uint32_t value;<br>
> +<br>
> +             value = data[*pos >> 2];<br>
> +             r = put_user(value, (uint32_t *)buf);<br>
> +             if (r)<br>
> +                     return r;<br>
> +<br>
> +             result += 4;<br>
> +             buf += 4;<br>
> +             *pos += 4;<br>
> +             size -= 4;<br>
> +     }<br>
> +<br>
> +     return result;<br>
> +}<br>
> +<br>
>  static const struct file_operations amdgpu_debugfs_regs_fops = {<br>
>        .owner = THIS_MODULE,<br>
>        .read = amdgpu_debugfs_regs_read,<br>
> @@ -2951,6 +3017,12 @@ static const struct file_operations amdgpu_debugfs_sensors_fops = {<br>
>        .llseek = default_llseek<br>
>  };<br>
><br>
> +static const struct file_operations amdgpu_debugfs_wave_fops = {<br>
> +     .owner = THIS_MODULE,<br>
> +     .read = amdgpu_debugfs_wave_read,<br>
> +     .llseek = default_llseek<br>
> +};<br>
> +<br>
>  static const struct file_operations *debugfs_regs[] = {<br>
>        &amdgpu_debugfs_regs_fops,<br>
>        &amdgpu_debugfs_regs_didt_fops,<br>
> @@ -2958,6 +3030,7 @@ static const struct file_operations *debugfs_regs[] = {<br>
>        &amdgpu_debugfs_regs_smc_fops,<br>
>        &amdgpu_debugfs_gca_config_fops,<br>
>        &amdgpu_debugfs_sensors_fops,<br>
> +     &amdgpu_debugfs_wave_fops,<br>
>  };<br>
><br>
>  static const char *debugfs_regs_names[] = {<br>
> @@ -2967,6 +3040,7 @@ static const char *debugfs_regs_names[] = {<br>
>        "amdgpu_regs_smc",<br>
>        "amdgpu_gca_config",<br>
>        "amdgpu_sensors",<br>
> +     "amdgpu_wave",<br>
>  };<br>
><br>
>  static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)<br>
><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>