drm/amdgpu: Do error injection even vram reserve fails [Linux 5.3]

This Linux kernel change "drm/amdgpu: Do error injection even vram reserve fails" is included in the Linux 5.3 release. This change is authored by xinhui pan <xinhui.pan [at] amd.com> on Fri Jun 14 16:06:10 2019 +0800. The commit for this change in Linux stable tree is acb05f0 (patch).

drm/amdgpu: Do error injection even vram reserve fails

As long as the address is mapped with vram, we can do an error
injection.

Signed-off-by: xinhui pan <xinhui.pan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

There are 13 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 7efc4e0..614116c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -333,12 +333,13 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f, const char __user *
    case 2:
        ret = amdgpu_ras_reserve_vram(adev,
                data.inject.address, PAGE_SIZE, &bo);
-       /* This address might be used already on failure. In fact we can
-        * perform an injection in such case.
-        */
-       if (ret)
-           break;
-       data.inject.address = amdgpu_bo_gpu_offset(bo);
+       if (ret) {
+           /* address was offset, now it is absolute.*/
+           data.inject.address += adev->gmc.vram_start;
+           if (data.inject.address > adev->gmc.vram_end)
+               break;
+       } else
+           data.inject.address = amdgpu_bo_gpu_offset(bo);
        ret = amdgpu_ras_error_inject(adev, &data.inject);
        amdgpu_ras_release_vram(adev, &bo);
        break;

Leave a Reply

Your email address will not be published. Required fields are marked *