drm/amdgpu: Move mca debug mode decision to ras
authorLijo Lazar <lijo.lazar@amd.com>
Thu, 9 Nov 2023 05:20:38 +0000 (10:50 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 29 Nov 2023 21:49:01 +0000 (16:49 -0500)
Refactor code such that ras block decides the default mca debug mode,
and not swsmu block.

By default mca debug mode is set to false.

v2: squash in uninitialized value fix (Alex)

Signed-off-by: Lijo Lazar <lijo.lazar@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_mca.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c

index cf33eb219e25741bcbc27bda849b3642c70bd143..54f2f346579edc08264d7c52dd87cba4e33b9608 100644 (file)
@@ -377,7 +377,7 @@ static int amdgpu_mca_smu_debug_mode_set(void *data, u64 val)
        struct amdgpu_device *adev = (struct amdgpu_device *)data;
        int ret;
 
-       ret = amdgpu_mca_smu_set_debug_mode(adev, val ? true : false);
+       ret = amdgpu_ras_set_mca_debug_mode(adev, val ? true : false);
        if (ret)
                return ret;
 
index a3dc68e989108e52c71a24bd97fff44f6183f8db..f6b47ebce9d6219cc53aed040338a2aa1e609104 100644 (file)
@@ -3132,6 +3132,8 @@ int amdgpu_ras_late_init(struct amdgpu_device *adev)
        if (amdgpu_sriov_vf(adev))
                return 0;
 
+       amdgpu_ras_set_mca_debug_mode(adev, false);
+
        list_for_each_entry_safe(node, tmp, &adev->ras_list, node) {
                if (!node->ras_obj) {
                        dev_warn(adev->dev, "Warning: abnormal ras list node.\n");
@@ -3405,12 +3407,18 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)
        return 0;
 }
 
-void amdgpu_ras_set_mca_debug_mode(struct amdgpu_device *adev, bool enable)
+int amdgpu_ras_set_mca_debug_mode(struct amdgpu_device *adev, bool enable)
 {
        struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+       int ret = 0;
 
-       if (con)
-               con->is_mca_debug_mode = enable;
+       if (con) {
+               ret = amdgpu_mca_smu_set_debug_mode(adev, enable);
+               if (!ret)
+                       con->is_mca_debug_mode = enable;
+       }
+
+       return ret;
 }
 
 bool amdgpu_ras_get_mca_debug_mode(struct amdgpu_device *adev)
index 19161916ac46b904ee604e5ad23cd2dc6ff77701..6a941eb8fb8fd77e948e1bc170309e4a1418f2a2 100644 (file)
@@ -773,7 +773,7 @@ struct amdgpu_ras* amdgpu_ras_get_context(struct amdgpu_device *adev);
 
 int amdgpu_ras_set_context(struct amdgpu_device *adev, struct amdgpu_ras *ras_con);
 
-void amdgpu_ras_set_mca_debug_mode(struct amdgpu_device *adev, bool enable);
+int amdgpu_ras_set_mca_debug_mode(struct amdgpu_device *adev, bool enable);
 bool amdgpu_ras_get_mca_debug_mode(struct amdgpu_device *adev);
 bool amdgpu_ras_get_error_query_mode(struct amdgpu_device *adev,
                                     unsigned int *mode);
index 8ccb8354bb49687ac2965aa0dde3c86fa519351e..dda2249c4994f4566ae53c39887a69b36281cda3 100644 (file)
@@ -1516,7 +1516,6 @@ static int smu_v13_0_6_mca_set_debug_mode(struct smu_context *smu, bool enable)
        if (smu->smc_fw_version < 0x554800)
                return 0;
 
-       amdgpu_ras_set_mca_debug_mode(smu->adev, enable);
        return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_ClearMcaOnRead,
                                               enable ? 0 : ClearMcaOnRead_UE_FLAG_MASK | ClearMcaOnRead_CE_POLL_MASK,
                                               NULL);
@@ -2346,16 +2345,6 @@ static int smu_v13_0_6_smu_send_hbm_bad_page_num(struct smu_context *smu,
        return ret;
 }
 
-static int smu_v13_0_6_post_init(struct smu_context *smu)
-{
-       struct amdgpu_device *adev = smu->adev;
-
-       if (!amdgpu_sriov_vf(adev) && adev->ras_enabled)
-               return smu_v13_0_6_mca_set_debug_mode(smu, false);
-
-       return 0;
-}
-
 static int mca_smu_set_debug_mode(struct amdgpu_device *adev, bool enable)
 {
        struct smu_context *smu = adev->powerplay.pp_handle;
@@ -2920,7 +2909,6 @@ static const struct pptable_funcs smu_v13_0_6_ppt_funcs = {
        .i2c_init = smu_v13_0_6_i2c_control_init,
        .i2c_fini = smu_v13_0_6_i2c_control_fini,
        .send_hbm_bad_pages_num = smu_v13_0_6_smu_send_hbm_bad_page_num,
-       .post_init = smu_v13_0_6_post_init,
 };
 
 void smu_v13_0_6_set_ppt_funcs(struct smu_context *smu)