]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amdgpu: Add a mutex lock to protect poison injection
authorCe Sun <cesun102@amd.com>
Tue, 19 Aug 2025 06:47:05 +0000 (14:47 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 Aug 2025 17:57:47 +0000 (13:57 -0400)
When poison is triggered multiple times, competition will occur.
Add a mutex lock to protect poison injection

Signed-off-by: Ce Sun <cesun102@amd.com>
Reviewed-by: Yang Wang <kevinyang.wang@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_ras.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h

index e6b8c2cf80ea88122877f084eede2534fc3a03bc..ff2b522d86c67bdd508ab79bfbe5e1362db521c2 100644 (file)
@@ -3512,6 +3512,7 @@ static int amdgpu_ras_page_retirement_thread(void *param)
                if (kthread_should_stop())
                        break;
 
+               mutex_lock(&con->poison_lock);
                gpu_reset = 0;
 
                do {
@@ -3568,6 +3569,7 @@ static int amdgpu_ras_page_retirement_thread(void *param)
                        /* Wake up work to save bad pages to eeprom */
                        schedule_delayed_work(&con->page_retirement_dwork, 0);
                }
+               mutex_unlock(&con->poison_lock);
        }
 
        return 0;
@@ -3648,6 +3650,7 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev, bool init_bp_info)
        }
 
        mutex_init(&con->recovery_lock);
+       mutex_init(&con->poison_lock);
        INIT_WORK(&con->recovery_work, amdgpu_ras_do_recovery);
        atomic_set(&con->in_recovery, 0);
        atomic_set(&con->rma_in_recovery, 0);
index ff63020f9c6c93c0d62664d42fc9bbfb261f460e..2a70782b07bfdc1a80ed445265bfaaf4fba99be0 100644 (file)
@@ -587,6 +587,8 @@ struct amdgpu_ras {
        struct list_head critical_region_head;
        struct mutex critical_region_lock;
 
+       /* Protect poison injection */
+       struct mutex poison_lock;
 };
 
 struct ras_fs_data {