[PATCH] drm/amdgpu: Zero-initialize mqd backup memory

Wang, Yang(Kevin) KevinYang.Wang at amd.com
Tue Oct 15 06:09:02 UTC 2024


[AMD Official Use Only - AMD Internal Distribution Only]

Reviewed-by: Yang Wang <kevinyang.wang at amd.com>

Best Regards,
Kevin

-----Original Message-----
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Lijo Lazar
Sent: Tuesday, October 15, 2024 1:34 PM
To: amd-gfx at lists.freedesktop.org
Cc: Zhang, Hawking <Hawking.Zhang at amd.com>; Deucher, Alexander <Alexander.Deucher at amd.com>; Koenig, Christian <Christian.Koenig at amd.com>
Subject: [PATCH] drm/amdgpu: Zero-initialize mqd backup memory

Zero-initialize mqd backup memory, otherwise the check for 'already-backed-up' could go wrong.

Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index b6acbe923b6b..e96984c53e72 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -405,7 +405,7 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev,
                }

                /* prepare MQD backup */
-               kiq->mqd_backup = kmalloc(mqd_size, GFP_KERNEL);
+               kiq->mqd_backup = kzalloc(mqd_size, GFP_KERNEL);
                if (!kiq->mqd_backup) {
                        dev_warn(adev->dev,
                                 "no memory to create MQD backup for ring %s\n", ring->name); @@ -428,7 +428,7 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev,

                                ring->mqd_size = mqd_size;
                                /* prepare MQD backup */
-                               adev->gfx.me.mqd_backup[i] = kmalloc(mqd_size, GFP_KERNEL);
+                               adev->gfx.me.mqd_backup[i] = kzalloc(mqd_size, GFP_KERNEL);
                                if (!adev->gfx.me.mqd_backup[i]) {
                                        dev_warn(adev->dev, "no memory to create MQD backup for ring %s\n", ring->name);
                                        return -ENOMEM;
@@ -452,7 +452,7 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev,

                        ring->mqd_size = mqd_size;
                        /* prepare MQD backup */
-                       adev->gfx.mec.mqd_backup[j] = kmalloc(mqd_size, GFP_KERNEL);
+                       adev->gfx.mec.mqd_backup[j] = kzalloc(mqd_size, GFP_KERNEL);
                        if (!adev->gfx.mec.mqd_backup[j]) {
                                dev_warn(adev->dev, "no memory to create MQD backup for ring %s\n", ring->name);
                                return -ENOMEM;
--
2.25.1



More information about the amd-gfx mailing list