OSDN Git Service

drm/amdgpu: Introduce another ras enable function
authorxinhui pan <xinhui.pan@amd.com>
Mon, 8 Apr 2019 06:49:37 +0000 (14:49 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 10 Apr 2019 18:49:15 +0000 (13:49 -0500)
Many parts of the whole SW stack can program the ras enablement state
during the boot. Now we handle that case by adding one function which
check the ras flags and choose different code path.

Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: xinhui pan <xinhui.pan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h

index a0e34f6..22bd21e 100644 (file)
@@ -530,6 +530,33 @@ int amdgpu_ras_feature_enable(struct amdgpu_device *adev,
        return 0;
 }
 
+/* Only used in device probe stage and called only once. */
+int amdgpu_ras_feature_enable_on_boot(struct amdgpu_device *adev,
+               struct ras_common_if *head, bool enable)
+{
+       struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+       int ret;
+
+       if (!con)
+               return -EINVAL;
+
+       if (con->flags & AMDGPU_RAS_FLAG_INIT_BY_VBIOS) {
+               /* If ras is enabled by vbios, we set up ras object first in
+                * both case. For enable, that is all what we need do. For
+                * disable, we need perform a ras TA disable cmd after that.
+                */
+               ret = __amdgpu_ras_feature_enable(adev, head, 1);
+               if (ret)
+                       return ret;
+
+               if (!enable)
+                       ret = amdgpu_ras_feature_enable(adev, head, 0);
+       } else
+               ret = amdgpu_ras_feature_enable(adev, head, enable);
+
+       return ret;
+}
+
 static int amdgpu_ras_disable_all_features(struct amdgpu_device *adev,
                bool bypass)
 {
index 682f2be..eaef5ed 100644 (file)
@@ -262,6 +262,9 @@ int amdgpu_ras_pre_fini(struct amdgpu_device *adev);
 int amdgpu_ras_feature_enable(struct amdgpu_device *adev,
                struct ras_common_if *head, bool enable);
 
+int amdgpu_ras_feature_enable_on_boot(struct amdgpu_device *adev,
+               struct ras_common_if *head, bool enable);
+
 int amdgpu_ras_sysfs_create(struct amdgpu_device *adev,
                struct ras_fs_if *head);