drm/amdgpu: add a missing lock for AMDGPU_SCHED
authorjsg <jsg@openbsd.org>
Tue, 13 Jun 2023 02:54:09 +0000 (02:54 +0000)
committerjsg <jsg@openbsd.org>
Tue, 13 Jun 2023 02:54:09 +0000 (02:54 +0000)
From Chia-I Wu
7887397338a55a2439ba8db6d9a93cbe4094d912 in linux-6.1.y/6.1.29
2397e3d8d2e120355201a8310b61929f5a8bd2c0 in mainline linux

sys/dev/pci/drm/amd/amdgpu/amdgpu_sched.c

index 13b7d18..6f57e9c 100644 (file)
@@ -41,6 +41,7 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
 #ifdef notyet
        struct fd f = fdget(fd);
        struct amdgpu_fpriv *fpriv;
+       struct amdgpu_ctx_mgr *mgr;
        struct amdgpu_ctx *ctx;
        uint32_t id;
        int r;
@@ -54,8 +55,11 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
                return r;
        }
 
-       idr_for_each_entry(&fpriv->ctx_mgr.ctx_handles, ctx, id)
+       mgr = &fpriv->ctx_mgr;
+       mutex_lock(&mgr->lock);
+       idr_for_each_entry(&mgr->ctx_handles, ctx, id)
                amdgpu_ctx_priority_override(ctx, priority);
+       mutex_unlock(&mgr->lock);
 
        fdput(f);
        return 0;