From: YiPeng Chai <[email protected]>

Add a parameter to differentiate callers that need new error
count vs total count, ensuring the new count is only cleared
by the intended caller.

Signed-off-by: YiPeng Chai <[email protected]>
Reviewed-by: Tao Zhou <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/ras/core/cmd.c         | 3 ++-
 drivers/gpu/drm/amd/ras/core/core.c        | 4 ++--
 drivers/gpu/drm/amd/ras/core/ras.h         | 2 +-
 drivers/gpu/drm/amd/ras/core/ras_process.c | 3 ++-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/ras/core/cmd.c 
b/drivers/gpu/drm/amd/ras/core/cmd.c
index 0c5ca4bad5840..2c328116f339c 100644
--- a/drivers/gpu/drm/amd/ras/core/cmd.c
+++ b/drivers/gpu/drm/amd/ras/core/cmd.c
@@ -43,7 +43,8 @@ static int ras_get_block_ecc_info(struct ras_core_context 
*ras_core,
                return RAS_CMD__ERROR_INVALID_INPUT_SIZE;
 
        memset(&err_data, 0, sizeof(err_data));
-       ret = ras_aca_get_block_ecc_count(ras_core, input_data->block_id, 
&err_data);
+       ret = ras_core_query_block_ecc_data(ras_core,
+                               input_data->block_id, &err_data, false);
        if (ret)
                return RAS_CMD__ERROR_GENERIC;
 
diff --git a/drivers/gpu/drm/amd/ras/core/core.c 
b/drivers/gpu/drm/amd/ras/core/core.c
index 71c7c54ddb7c8..dc78e52de8869 100644
--- a/drivers/gpu/drm/amd/ras/core/core.c
+++ b/drivers/gpu/drm/amd/ras/core/core.c
@@ -554,7 +554,7 @@ int ras_core_update_ecc_info(struct ras_core_context 
*ras_core)
 }
 
 int ras_core_query_block_ecc_data(struct ras_core_context *ras_core,
-                       enum ras_block_id block, struct ras_ecc_count 
*ecc_count)
+               enum ras_block_id block, struct ras_ecc_count *ecc_count, bool 
clear)
 {
        int ret;
 
@@ -562,7 +562,7 @@ int ras_core_query_block_ecc_data(struct ras_core_context 
*ras_core,
                return -EINVAL;
 
        ret = ras_aca_get_block_ecc_count(ras_core, block, ecc_count);
-       if (!ret)
+       if (!ret && clear)
                ras_aca_clear_block_new_ecc_count(ras_core, block);
 
        return ret;
diff --git a/drivers/gpu/drm/amd/ras/core/ras.h 
b/drivers/gpu/drm/amd/ras/core/ras.h
index a2f0491e4062b..6aad1d8779e21 100644
--- a/drivers/gpu/drm/amd/ras/core/ras.h
+++ b/drivers/gpu/drm/amd/ras/core/ras.h
@@ -429,7 +429,7 @@ int ras_core_put_seqno(struct ras_core_context *ras_core,
 
 int ras_core_update_ecc_info(struct ras_core_context *ras_core);
 int ras_core_query_block_ecc_data(struct ras_core_context *ras_core,
-               enum ras_block_id block, struct ras_ecc_count *ecc_count);
+               enum ras_block_id block, struct ras_ecc_count *ecc_count, bool 
clear);
 
 bool ras_core_gpu_in_reset(struct ras_core_context *ras_core);
 bool ras_core_gpu_is_rma(struct ras_core_context *ras_core);
diff --git a/drivers/gpu/drm/amd/ras/core/ras_process.c 
b/drivers/gpu/drm/amd/ras/core/ras_process.c
index e7f95a82fb901..395d10c94b195 100644
--- a/drivers/gpu/drm/amd/ras/core/ras_process.c
+++ b/drivers/gpu/drm/amd/ras/core/ras_process.c
@@ -88,7 +88,8 @@ static int ras_process_umc_event(struct ras_core_context 
*ras_core,
                if (ret)
                        return ret;
 
-               ret = ras_core_query_block_ecc_data(ras_core, 
RAS_BLOCK_ID__UMC, &ecc_data);
+               ret = ras_core_query_block_ecc_data(ras_core,
+                               RAS_BLOCK_ID__UMC, &ecc_data, true);
                if (ret)
                        return ret;
 
-- 
2.55.0

Reply via email to