[PATCH] drm/amdgpu: check sdma ras funcs pointer before accessing

Das, Nirmoy Nirmoy.Das at amd.com
Thu Jan 9 15:24:35 UTC 2020


[AMD Official Use Only - Internal Distribution Only]

I just got hit by this bug.

Reviewed-by: Nirmoy Das <nirmoy.das at amd.com<mailto:Le.Ma at amd.com>>

Thanks,
Nirmoy
________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Hawking Zhang <Hawking.Zhang at amd.com>
Sent: Thursday, January 9, 2020 12:42:13 PM
To: amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
Cc: Zhang, Hawking <Hawking.Zhang at amd.com>
Subject: [PATCH] drm/amdgpu: check sdma ras funcs pointer before accessing

sdma ras funcs are not supported by ASIC prior
to vega20

Signed-off-by: Hawking Zhang <Hawking.Zhang at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
index f4107f9b75f3..c4b4caaf56fe 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
@@ -1810,7 +1810,10 @@ static int sdma_v4_0_late_init(void *handle)
                         RREG32_SDMA(i, mmSDMA0_EDC_COUNTER);
         }

-       return adev->sdma.funcs->ras_late_init(adev, &ih_info);
+       if (adev->sdma.funcs && adev->sdma.funcs->ras_late_init)
+               return adev->sdma.funcs->ras_late_init(adev, &ih_info);
+       else
+               return 0;
 }

 static int sdma_v4_0_sw_init(void *handle)
@@ -1882,7 +1885,8 @@ static int sdma_v4_0_sw_fini(void *handle)
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
         int i;

-       adev->sdma.funcs->ras_fini(adev);
+       if (adev->sdma.funcs && adev->sdma.funcs->ras_fini)
+               adev->sdma.funcs->ras_fini(adev);

         for (i = 0; i < adev->sdma.num_instances; i++) {
                 amdgpu_ring_fini(&adev->sdma.instance[i].ring);
--
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cnirmoy.das%40amd.com%7Cf443faf2f98f4135d8a408d794f8fdd0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637141669492821558&sdata=tKUUR%2BJwv8V19Q0zr0oQg48tG9j7goCQ7L6EzNuv6JI%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20200109/a1358fed/attachment-0001.htm>


More information about the amd-gfx mailing list