<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">
<p style="font-family:Arial;font-size:10pt;color:#317100;margin:15pt;" align="Left">
[AMD Public Use]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Series is:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><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> Hawking Zhang <Hawking.Zhang@amd.com><br>
<b>Sent:</b> Monday, March 2, 2020 5:33 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Clements, John <John.Clements@amd.com>; Li, Dennis <Dennis.Li@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com><br>
<b>Cc:</b> Zhang, Hawking <Hawking.Zhang@amd.com><br>
<b>Subject:</b> [PATCH 4/4] drm/amdgpu: add reset_ras_error_count function for HDP</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">HDP ras error counters are dirty ones after cold reboot<br>
Read operation is needed to reset them to 0<br>
<br>
Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +<br>
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 1 -<br>
drivers/gpu/drm/amd/amdgpu/soc15.c | 14 ++++++++++++++<br>
3 files changed, 15 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
index a58b0cf9da51..b735e20888a7 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
@@ -595,6 +595,7 @@ struct amdgpu_asic_funcs {<br>
/* invalidate hdp read cache */<br>
void (*invalidate_hdp)(struct amdgpu_device *adev,<br>
struct amdgpu_ring *ring);<br>
+ void (*reset_hdp_ras_error_count)(struct amdgpu_device *adev);<br>
/* check if the asic needs a full reset of if soft reset will work */<br>
bool (*need_full_reset)(struct amdgpu_device *adev);<br>
/* initialize doorbell layout for specific asic*/<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
index b746f26f933c..efd52bcf8785 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
@@ -4149,7 +4149,6 @@ static const struct soc15_reg_entry gfx_v9_0_edc_counter_regs[] = {<br>
{ SOC15_REG_ENTRY(GC, 0, mmTCC_EDC_CNT2), 0, 1, 16},<br>
{ SOC15_REG_ENTRY(GC, 0, mmTCA_EDC_CNT), 0, 1, 2},<br>
{ SOC15_REG_ENTRY(GC, 0, mmSQC_EDC_CNT3), 0, 4, 6},<br>
- { SOC15_REG_ENTRY(HDP, 0, mmHDP_EDC_CNT), 0, 1, 1},<br>
};<br>
<br>
static int gfx_v9_0_do_edc_gds_workarounds(struct amdgpu_device *adev)<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
index 4aa5b9c8e43b..6b717691d554 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c<br>
@@ -827,6 +827,15 @@ static bool soc15_need_full_reset(struct amdgpu_device *adev)<br>
/* change this when we implement soft reset */<br>
return true;<br>
}<br>
+<br>
+static void vega20_reset_hdp_ras_error_count(struct amdgpu_device *adev)<br>
+{<br>
+ if (!amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__HDP))<br>
+ return;<br>
+ /*read back hdp ras counter to reset it to 0 */<br>
+ RREG32_SOC15(HDP, 0, mmHDP_EDC_CNT);<br>
+}<br>
+<br>
static void soc15_get_pcie_usage(struct amdgpu_device *adev, uint64_t *count0,<br>
uint64_t *count1)<br>
{<br>
@@ -994,6 +1003,7 @@ static const struct amdgpu_asic_funcs vega20_asic_funcs =<br>
.get_config_memsize = &soc15_get_config_memsize,<br>
.flush_hdp = &soc15_flush_hdp,<br>
.invalidate_hdp = &soc15_invalidate_hdp,<br>
+ .reset_hdp_ras_error_count = &vega20_reset_hdp_ras_error_count,<br>
.need_full_reset = &soc15_need_full_reset,<br>
.init_doorbell_index = &vega20_doorbell_index_init,<br>
.get_pcie_usage = &vega20_get_pcie_usage,<br>
@@ -1239,6 +1249,10 @@ static int soc15_common_late_init(void *handle)<br>
if (amdgpu_sriov_vf(adev))<br>
xgpu_ai_mailbox_get_irq(adev);<br>
<br>
+ if (adev->asic_funcs &&<br>
+ adev->asic_funcs->reset_hdp_ras_error_count)<br>
+ adev->asic_funcs->reset_hdp_ras_error_count(adev);<br>
+<br>
if (adev->nbio.funcs->ras_late_init)<br>
r = adev->nbio.funcs->ras_late_init(adev);<br>
<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>