drm/amdgpu: add new api to save error count into aca cache
authorYang Wang <kevinyang.wang@amd.com>
Tue, 6 Feb 2024 05:24:16 +0000 (13:24 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 20 Mar 2024 17:38:14 +0000 (13:38 -0400)
add new api to save error count into aca cache.

Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
drivers/gpu/drm/amd/amdgpu/amdgpu_aca.h

index 2ad2d874f42f713647aad9042c318aa33b09f1ac..7cbff74c0f2ff71a2424a45cdb383d4541b39926 100644 (file)
@@ -274,25 +274,25 @@ static struct aca_bank_error *get_bank_error(struct aca_error *aerr, struct aca_
        return new_bank_error(aerr, info);
 }
 
-static int aca_log_errors(struct aca_handle *handle, enum aca_error_type type,
-                         struct aca_bank_report *report)
+int aca_error_cache_log_bank_error(struct aca_handle *handle, struct aca_bank_info *info,
+                                  enum aca_error_type type, u64 count)
 {
        struct aca_error_cache *error_cache = &handle->error_cache;
        struct aca_bank_error *bank_error;
        struct aca_error *aerr;
 
-       if (!handle || !report)
+       if (!handle || !info || type >= ACA_ERROR_TYPE_COUNT)
                return -EINVAL;
 
-       if (!report->count[type])
+       if (!count)
                return 0;
 
        aerr = &error_cache->errors[type];
-       bank_error = get_bank_error(aerr, &report->info);
+       bank_error = get_bank_error(aerr, info);
        if (!bank_error)
                return -ENOMEM;
 
-       bank_error->count[type] += report->count[type];
+       bank_error->count += count;
 
        return 0;
 }
@@ -317,31 +317,12 @@ static int handler_aca_log_bank_error(struct aca_handle *handle, struct aca_bank
                                      enum aca_smu_type smu_type, void *data)
 {
        struct aca_bank_report report;
-       enum aca_error_type type;
        int ret;
 
-       switch (smu_type) {
-       case ACA_SMU_TYPE_UE:
-               type = ACA_ERROR_TYPE_UE;
-               break;
-       case ACA_SMU_TYPE_CE:
-               type = ACA_ERROR_TYPE_CE;
-               break;
-       default:
-               return -EINVAL;
-       }
-
        ret = aca_generate_bank_report(handle, bank, smu_type, &report);
        if (ret)
                return ret;
 
-       if (!report.count[type])
-               return 0;
-
-       ret = aca_log_errors(handle, type, &report);
-       if (ret)
-               return ret;
-
        return 0;
 }
 
@@ -440,7 +421,7 @@ static int aca_log_aca_error_data(struct aca_bank_error *bank_error, enum aca_er
        if (type >= ACA_ERROR_TYPE_COUNT)
                return -EINVAL;
 
-       count = bank_error->count[type];
+       count = bank_error->count;
        if (!count)
                return 0;
 
index a48f4abc345c3376b3016f575a5651cab1afc21d..470efefcde10b1ae9bb6f60627925bfb7b52403f 100644 (file)
@@ -130,7 +130,7 @@ struct aca_bank_report {
 struct aca_bank_error {
        struct list_head node;
        struct aca_bank_info info;
-       u64 count[ACA_ERROR_TYPE_COUNT];
+       u64 count;
 };
 
 struct aca_error {
@@ -206,4 +206,6 @@ int amdgpu_aca_get_error_data(struct amdgpu_device *adev, struct aca_handle *han
                                     enum aca_error_type type, void *data);
 int amdgpu_aca_smu_set_debug_mode(struct amdgpu_device *adev, bool en);
 void amdgpu_aca_smu_debugfs_init(struct amdgpu_device *adev, struct dentry *root);
+int aca_error_cache_log_bank_error(struct aca_handle *handle, struct aca_bank_info *info,
+                                  enum aca_error_type type, u64 count);
 #endif