<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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">I guess I don't really have a particularly strong opinion either way.  If others are ok with it, I'm fine with it.<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""> StDenis, Tom
<br>
<b>Sent:</b> Thursday, August 11, 2016 11:48 AM<br>
<b>To:</b> Deucher, Alexander; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH 3/4] drm/amd/amdgpu: VCE v2 register cleanup<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black">Just trying to make it easier to read.  <o:p></o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black">WREG32_FIELD(foo, FIELD, 1);<o:p></o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black">Is easier to read than<o:p></o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black">WREG32_P(foo, FOO__FIELD_MASK, ~FOO__FIELD_MASK);<o:p></o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black">(also I already pushed them after getting a RB by Christian this morning so we might need to hold a different discussion).<o:p></o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black">I agree it's not really a functional change but making things a bit more uniform and easier to read helps maintenance.  And I did find a bug in the process :-)<o:p></o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif";color:black">Tom<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt;background:white"><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;background:white">
<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" style="background:white"><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"> Deucher, Alexander<br>
<b>Sent:</b> Thursday, August 11, 2016 11:46<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 3/4] drm/amd/amdgpu: VCE v2 register cleanup</span><span style="font-family:"Calibri","sans-serif";color:black">
<o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-family:"Calibri","sans-serif";color:black"> <o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:black">> -----Original Message-----<br>
> From: amd-gfx [<a href="mailto:amd-gfx-bounces@lists.freedesktop.org">mailto:amd-gfx-bounces@lists.freedesktop.org</a>] On Behalf<br>
> Of Tom St Denis<br>
> Sent: Thursday, August 11, 2016 10:33 AM<br>
> To: <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
> Cc: StDenis, Tom<br>
> Subject: [PATCH 3/4] drm/amd/amdgpu: VCE v2 register cleanup<br>
> <br>
> Signed-off-by: Tom St Denis <<a href="mailto:tom.stdenis@amd.com">tom.stdenis@amd.com</a>><br>
<br>
A couple pieces of this patch could be split out as separate cleanups (see below).  However, I'm not sure how much value there is in switching WREG32_P for WREG_FIELD other than code churn.  They basically do the same thing. 
<br>
<br>
Alex<br>
<br>
> ---<br>
>  drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | 39 +++++++++++++-------------<br>
> ---------<br>
>  1 file changed, 14 insertions(+), 25 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c<br>
> b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c<br>
> index 80a37a602181..21ba219e943b 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c<br>
> @@ -127,15 +127,10 @@ static int vce_v2_0_start(struct amdgpu_device<br>
> *adev)<br>
>        WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));<br>
>        WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);<br>
> <br>
> -     WREG32_P(mmVCE_VCPU_CNTL,<br>
> VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);<br>
> -<br>
> -     WREG32_P(mmVCE_SOFT_RESET,<br>
> -              VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,<br>
> -              ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);<br>
> -<br>
> +     WREG32_FIELD(VCE_VCPU_CNTL, CLK_EN, 1);<br>
> +     WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 1);<br>
>        mdelay(100);<br>
> -<br>
> -     WREG32_P(mmVCE_SOFT_RESET, 0,<br>
> ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);<br>
> +     WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 0);<br>
> <br>
>        for (i = 0; i < 10; ++i) {<br>
>                uint32_t status;<br>
> @@ -150,10 +145,9 @@ static int vce_v2_0_start(struct amdgpu_device<br>
> *adev)<br>
>                        break;<br>
> <br>
>                DRM_ERROR("VCE not responding, trying to reset the<br>
> ECPU!!!\n");<br>
> -             WREG32_P(mmVCE_SOFT_RESET,<br>
> VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,<br>
> -<br>
>        ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);<br>
> +             WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 1);<br>
>                mdelay(10);<br>
> -             WREG32_P(mmVCE_SOFT_RESET, 0,<br>
> ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);<br>
> +             WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 0);<br>
>                mdelay(10);<br>
>                r = -1;<br>
>        }<br>
> @@ -345,13 +339,13 @@ static void vce_v2_0_set_dyn_cg(struct<br>
> amdgpu_device *adev, bool gated)<br>
>                        DRM_INFO("VCE is busy, Can't set clock gateing");<br>
>                        return;<br>
>                }<br>
> -             WREG32_P(mmVCE_VCPU_CNTL, 0,<br>
> ~VCE_VCPU_CNTL__CLK_EN_MASK);<br>
> -             WREG32_P(mmVCE_SOFT_RESET,<br>
> VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,<br>
> ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);<br>
> +             WREG32_FIELD(VCE_VCPU_CNTL, CLK_EN, 0);<br>
> +             WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 1);<br>
>                mdelay(100);<br>
>                WREG32(mmVCE_STATUS, 0);<br>
>        } else {<br>
> -             WREG32_P(mmVCE_VCPU_CNTL,<br>
> VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);<br>
> -             WREG32_P(mmVCE_SOFT_RESET,<br>
> VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,<br>
> ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);<br>
> +             WREG32_FIELD(VCE_VCPU_CNTL, CLK_EN, 1);<br>
> +             WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 1);<br>
>                mdelay(100);<br>
>        }<br>
> <br>
> @@ -458,9 +452,7 @@ static void vce_v2_0_mc_resume(struct<br>
> amdgpu_device *adev)<br>
>        WREG32(mmVCE_VCPU_CACHE_SIZE2, size);<br>
> <br>
>        WREG32_P(mmVCE_LMI_CTRL2, 0x0, ~0x100);<br>
> -<br>
> -     WREG32_P(mmVCE_SYS_INT_EN,<br>
> VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK,<br>
> -<br>
> ~VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK);<br>
> +     WREG32_FIELD(VCE_SYS_INT_EN,<br>
> VCE_SYS_INT_TRAP_INTERRUPT_EN, 1);<br>
> <br>
>        vce_v2_0_init_cg(adev);<br>
>  }<br>
> @@ -474,11 +466,11 @@ static bool vce_v2_0_is_idle(void *handle)<br>
> <br>
>  static int vce_v2_0_wait_for_idle(void *handle)<br>
>  {<br>
> -     unsigned i;<br>
>        struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
> +     unsigned i;<br>
> <br>
>        for (i = 0; i < adev->usec_timeout; i++) {<br>
> -             if (!(RREG32(mmSRBM_STATUS2) &<br>
> SRBM_STATUS2__VCE_BUSY_MASK))<br>
> +             if (vce_v2_0_is_idle(handle))<br>
>                        return 0;<br>
<br>
This could be split out as a separate patch.<br>
<br>
>        }<br>
>        return -ETIMEDOUT;<br>
> @@ -488,8 +480,7 @@ static int vce_v2_0_soft_reset(void *handle)<br>
>  {<br>
>        struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
> <br>
> -     WREG32_P(mmSRBM_SOFT_RESET,<br>
> SRBM_SOFT_RESET__SOFT_RESET_VCE_MASK,<br>
> -                     ~SRBM_SOFT_RESET__SOFT_RESET_VCE_MASK);<br>
> +     WREG32_FIELD(SRBM_SOFT_RESET, SOFT_RESET_VCE, 1);<br>
>        mdelay(5);<br>
> <br>
>        return vce_v2_0_start(adev);<br>
> @@ -516,10 +507,8 @@ static int vce_v2_0_process_interrupt(struct<br>
> amdgpu_device *adev,<br>
>        DRM_DEBUG("IH: VCE\n");<br>
>        switch (entry->src_data) {<br>
>        case 0:<br>
> -             amdgpu_fence_process(&adev->vce.ring[0]);<br>
> -             break;<br>
>        case 1:<br>
> -             amdgpu_fence_process(&adev->vce.ring[1]);<br>
> +             amdgpu_fence_process(&adev->vce.ring[entry->src_data]);<br>
>                break;<br>
>        default:<br>
>                DRM_ERROR("Unhandled interrupt: %d %d\n",<br>
<br>
This too.<br>
<br>
> --<br>
> 2.9.2<br>
> <br>
> _______________________________________________<br>
> amd-gfx mailing list<br>
> <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>