]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amdkfd: Fix sparse __rcu annotation warnings
authorFelix Kuehling <felix.kuehling@amd.com>
Wed, 3 Jan 2024 23:13:04 +0000 (18:13 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 9 Jan 2024 20:44:13 +0000 (15:44 -0500)
Properly mark kfd_process->ef as __rcu and consistently use the right
accessor functions.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202312052245.yFpBSgNH-lkp@intel.com/
Signed-off-by: Felix Kuehling <felix.kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
drivers/gpu/drm/amd/amdkfd/kfd_process.c

index cf6ed5fce291f946854d329fa91e0fb6eedbc61a..f262b9d89541a8a971a394b5f0da0f6a1368ba65 100644 (file)
@@ -311,7 +311,7 @@ void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct kgd_mem *mem);
 int amdgpu_amdkfd_map_gtt_bo_to_gart(struct amdgpu_device *adev, struct amdgpu_bo *bo);
 
 int amdgpu_amdkfd_gpuvm_restore_process_bos(void *process_info,
-                                           struct dma_fence **ef);
+                                           struct dma_fence __rcu **ef);
 int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct amdgpu_device *adev,
                                              struct kfd_vm_fault_info *info);
 int amdgpu_amdkfd_gpuvm_import_dmabuf_fd(struct amdgpu_device *adev, int fd,
index d17b2452cb1f69df276dd95518cf0ca340539237..f183d7faeeece16cfc7c211f5a6a0232dce37c36 100644 (file)
@@ -2802,7 +2802,7 @@ unlock_out:
        put_task_struct(usertask);
 }
 
-static void replace_eviction_fence(struct dma_fence **ef,
+static void replace_eviction_fence(struct dma_fence __rcu **ef,
                                   struct dma_fence *new_ef)
 {
        struct dma_fence *old_ef = rcu_replace_pointer(*ef, new_ef, true
@@ -2837,7 +2837,7 @@ static void replace_eviction_fence(struct dma_fence **ef,
  * 7.  Add fence to all PD and PT BOs.
  * 8.  Unreserve all BOs
  */
-int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
+int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu **ef)
 {
        struct amdkfd_process_info *process_info = info;
        struct amdgpu_vm *peer_vm;
index 745024b313401261a73900360c3d50f62d8440d8..17fbedbf3651388edfcd0109a22d0fe9dfcd331f 100644 (file)
@@ -917,7 +917,7 @@ struct kfd_process {
         * fence will be triggered during eviction and new one will be created
         * during restore
         */
-       struct dma_fence *ef;
+       struct dma_fence __rcu *ef;
 
        /* Work items for evicting and restoring BOs */
        struct delayed_work eviction_work;
index 71df51fcc1b0d80f42899a0e15ae454b3f03f2bc..717a60d7a4ea953b8dfc369b09d855ad74b49659 100644 (file)
@@ -1110,6 +1110,7 @@ static void kfd_process_wq_release(struct work_struct *work)
 {
        struct kfd_process *p = container_of(work, struct kfd_process,
                                             release_work);
+       struct dma_fence *ef;
 
        kfd_process_dequeue_from_all_devices(p);
        pqm_uninit(&p->pqm);
@@ -1118,7 +1119,9 @@ static void kfd_process_wq_release(struct work_struct *work)
         * destroyed. This allows any BOs to be freed without
         * triggering pointless evictions or waiting for fences.
         */
-       dma_fence_signal(p->ef);
+       synchronize_rcu();
+       ef = rcu_access_pointer(p->ef);
+       dma_fence_signal(ef);
 
        kfd_process_remove_sysfs(p);
 
@@ -1127,7 +1130,7 @@ static void kfd_process_wq_release(struct work_struct *work)
        svm_range_list_fini(p);
 
        kfd_process_destroy_pdds(p);
-       dma_fence_put(p->ef);
+       dma_fence_put(ef);
 
        kfd_event_free_process(p);