<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I can send a patch for that.  Thanks!</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Alex<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Quan, Evan <Evan.Quan@amd.com><br>
<b>Sent:</b> Tuesday, November 12, 2019 9:09 PM<br>
<b>To:</b> Alex Deucher <alexdeucher@gmail.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com><br>
<b>Subject:</b> RE: [PATCH] drm/amdgpu: don't read registers if gfxoff is enabled (v2)</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">This patch is reviewed-by: Evan Quan <evan.quan@amd.com><br>
However, i just find we need a separate patch to clear PP_GFXOFF_MASK support from Arcturus.<br>
Can you do that or you want me to do that?<br>
<br>
> -----Original Message-----<br>
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex<br>
> Deucher<br>
> Sent: Tuesday, November 12, 2019 11:13 PM<br>
> To: amd-gfx@lists.freedesktop.org<br>
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com><br>
> Subject: [PATCH] drm/amdgpu: don't read registers if gfxoff is enabled (v2)<br>
> <br>
> When gfxoff is enabled, accessing gfx registers via MMIO<br>
> can lead to a hang.<br>
> <br>
> v2: return cached registers properly.<br>
> <br>
> Bug: <a href="https://bugzilla.kernel.org/show_bug.cgi?id=205497">https://bugzilla.kernel.org/show_bug.cgi?id=205497</a><br>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
> ---<br>
>  drivers/gpu/drm/amd/amdgpu/nv.c    | 27 ++++++++++++++++----------<br>
>  drivers/gpu/drm/amd/amdgpu/soc15.c | 31 ++++++++++++++++++------------<br>
>  2 files changed, 36 insertions(+), 22 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c<br>
> b/drivers/gpu/drm/amd/amdgpu/nv.c<br>
> index af68f9815f28..7283d6198b89 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/nv.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/nv.c<br>
> @@ -201,17 +201,25 @@ static uint32_t nv_read_indexed_register(struct<br>
> amdgpu_device *adev, u32 se_num,<br>
>        return val;<br>
>  }<br>
> <br>
> -static uint32_t nv_get_register_value(struct amdgpu_device *adev,<br>
> +static int nv_get_register_value(struct amdgpu_device *adev,<br>
>                                      bool indexed, u32 se_num,<br>
> -                                   u32 sh_num, u32 reg_offset)<br>
> +                                   u32 sh_num, u32 reg_offset,<br>
> +                                   u32 *value)<br>
>  {<br>
>        if (indexed) {<br>
> -             return nv_read_indexed_register(adev, se_num, sh_num,<br>
> reg_offset);<br>
> +             if (adev->pm.pp_feature & PP_GFXOFF_MASK)<br>
> +                     return -EINVAL;<br>
> +             *value = nv_read_indexed_register(adev, se_num, sh_num,<br>
> reg_offset);<br>
>        } else {<br>
> -             if (reg_offset == SOC15_REG_OFFSET(GC, 0,<br>
> mmGB_ADDR_CONFIG))<br>
> -                     return adev->gfx.config.gb_addr_config;<br>
> -             return RREG32(reg_offset);<br>
> +             if (reg_offset == SOC15_REG_OFFSET(GC, 0,<br>
> mmGB_ADDR_CONFIG)) {<br>
> +                     *value = adev->gfx.config.gb_addr_config;<br>
> +             } else {<br>
> +                     if (adev->pm.pp_feature & PP_GFXOFF_MASK)<br>
> +                             return -EINVAL;<br>
> +                     *value = RREG32(reg_offset);<br>
> +             }<br>
>        }<br>
> +     return 0;<br>
>  }<br>
> <br>
>  static int nv_read_register(struct amdgpu_device *adev, u32 se_num,<br>
> @@ -227,10 +235,9 @@ static int nv_read_register(struct amdgpu_device<br>
> *adev, u32 se_num,<br>
>                    (adev->reg_offset[en->hwip][en->inst][en->seg] + en-<br>
> >reg_offset))<br>
>                        continue;<br>
> <br>
> -             *value = nv_get_register_value(adev,<br>
> -<br>
> nv_allowed_read_registers[i].grbm_indexed,<br>
> -                                            se_num, sh_num, reg_offset);<br>
> -             return 0;<br>
> +             return nv_get_register_value(adev,<br>
> +<br>
> nv_allowed_read_registers[i].grbm_indexed,<br>
> +                                          se_num, sh_num, reg_offset, value);<br>
>        }<br>
>        return -EINVAL;<br>
>  }<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
> b/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
> index 305ad3eec987..2cc16e9f39fb 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
> @@ -363,19 +363,27 @@ static uint32_t soc15_read_indexed_register(struct<br>
> amdgpu_device *adev, u32 se_n<br>
>        return val;<br>
>  }<br>
> <br>
> -static uint32_t soc15_get_register_value(struct amdgpu_device *adev,<br>
> +static int soc15_get_register_value(struct amdgpu_device *adev,<br>
>                                         bool indexed, u32 se_num,<br>
> -                                      u32 sh_num, u32 reg_offset)<br>
> +                                      u32 sh_num, u32 reg_offset,<br>
> +                                      u32 *value)<br>
>  {<br>
>        if (indexed) {<br>
> -             return soc15_read_indexed_register(adev, se_num, sh_num,<br>
> reg_offset);<br>
> +             if (adev->pm.pp_feature & PP_GFXOFF_MASK)<br>
> +                     return -EINVAL;<br>
> +             *value = soc15_read_indexed_register(adev, se_num, sh_num,<br>
> reg_offset);<br>
>        } else {<br>
> -             if (reg_offset == SOC15_REG_OFFSET(GC, 0,<br>
> mmGB_ADDR_CONFIG))<br>
> -                     return adev->gfx.config.gb_addr_config;<br>
> -             else if (reg_offset == SOC15_REG_OFFSET(GC, 0,<br>
> mmDB_DEBUG2))<br>
> -                     return adev->gfx.config.db_debug2;<br>
> -             return RREG32(reg_offset);<br>
> +             if (reg_offset == SOC15_REG_OFFSET(GC, 0,<br>
> mmGB_ADDR_CONFIG)) {<br>
> +                     *value = adev->gfx.config.gb_addr_config;<br>
> +             } else if (reg_offset == SOC15_REG_OFFSET(GC, 0,<br>
> mmDB_DEBUG2)) {<br>
> +                     *value = adev->gfx.config.db_debug2;<br>
> +             } else {<br>
> +                     if (adev->pm.pp_feature & PP_GFXOFF_MASK)<br>
> +                             return -EINVAL;<br>
> +                     *value = RREG32(reg_offset);<br>
> +             }<br>
>        }<br>
> +     return 0;<br>
>  }<br>
> <br>
>  static int soc15_read_register(struct amdgpu_device *adev, u32 se_num,<br>
> @@ -391,10 +399,9 @@ static int soc15_read_register(struct amdgpu_device<br>
> *adev, u32 se_num,<br>
>                                        + en->reg_offset))<br>
>                        continue;<br>
> <br>
> -             *value = soc15_get_register_value(adev,<br>
> -<br>
> soc15_allowed_read_registers[i].grbm_indexed,<br>
> -                                               se_num, sh_num, reg_offset);<br>
> -             return 0;<br>
> +             return soc15_get_register_value(adev,<br>
> +<br>
>        soc15_allowed_read_registers[i].grbm_indexed,<br>
> +                                             se_num, sh_num, reg_offset,<br>
> value);<br>
>        }<br>
>        return -EINVAL;<br>
>  }<br>
> --<br>
> 2.23.0<br>
> <br>
> _______________________________________________<br>
> amd-gfx mailing list<br>
> amd-gfx@lists.freedesktop.org<br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>