Commit e433d684 authored by Philip Yang's avatar Philip Yang Committed by Alex Deucher

Revert "drm/amdkfd: process_info lock not needed for svm"

This reverts commit 3abfe30d.

To fix deadlock in kFDSVMEvictTest when xnack off.
Signed-off-by: default avatarPhilip Yang <Philip.Yang@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent b8cb6ab6
...@@ -1629,6 +1629,7 @@ svm_range_list_lock_and_flush_work(struct svm_range_list *svms, ...@@ -1629,6 +1629,7 @@ svm_range_list_lock_and_flush_work(struct svm_range_list *svms,
static void svm_range_restore_work(struct work_struct *work) static void svm_range_restore_work(struct work_struct *work)
{ {
struct delayed_work *dwork = to_delayed_work(work); struct delayed_work *dwork = to_delayed_work(work);
struct amdkfd_process_info *process_info;
struct svm_range_list *svms; struct svm_range_list *svms;
struct svm_range *prange; struct svm_range *prange;
struct kfd_process *p; struct kfd_process *p;
...@@ -1645,6 +1646,7 @@ static void svm_range_restore_work(struct work_struct *work) ...@@ -1645,6 +1646,7 @@ static void svm_range_restore_work(struct work_struct *work)
pr_debug("restore svm ranges\n"); pr_debug("restore svm ranges\n");
p = container_of(svms, struct kfd_process, svms); p = container_of(svms, struct kfd_process, svms);
process_info = p->kgd_process_info;
/* Keep mm reference when svm_range_validate_and_map ranges */ /* Keep mm reference when svm_range_validate_and_map ranges */
mm = get_task_mm(p->lead_thread); mm = get_task_mm(p->lead_thread);
...@@ -1653,6 +1655,7 @@ static void svm_range_restore_work(struct work_struct *work) ...@@ -1653,6 +1655,7 @@ static void svm_range_restore_work(struct work_struct *work)
return; return;
} }
mutex_lock(&process_info->lock);
svm_range_list_lock_and_flush_work(svms, mm); svm_range_list_lock_and_flush_work(svms, mm);
mutex_lock(&svms->lock); mutex_lock(&svms->lock);
...@@ -1705,6 +1708,7 @@ static void svm_range_restore_work(struct work_struct *work) ...@@ -1705,6 +1708,7 @@ static void svm_range_restore_work(struct work_struct *work)
out_reschedule: out_reschedule:
mutex_unlock(&svms->lock); mutex_unlock(&svms->lock);
mmap_write_unlock(mm); mmap_write_unlock(mm);
mutex_unlock(&process_info->lock);
mmput(mm); mmput(mm);
/* If validation failed, reschedule another attempt */ /* If validation failed, reschedule another attempt */
...@@ -3209,6 +3213,7 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm, ...@@ -3209,6 +3213,7 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm,
uint64_t start, uint64_t size, uint32_t nattr, uint64_t start, uint64_t size, uint32_t nattr,
struct kfd_ioctl_svm_attribute *attrs) struct kfd_ioctl_svm_attribute *attrs)
{ {
struct amdkfd_process_info *process_info = p->kgd_process_info;
struct list_head update_list; struct list_head update_list;
struct list_head insert_list; struct list_head insert_list;
struct list_head remove_list; struct list_head remove_list;
...@@ -3226,6 +3231,8 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm, ...@@ -3226,6 +3231,8 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm,
svms = &p->svms; svms = &p->svms;
mutex_lock(&process_info->lock);
svm_range_list_lock_and_flush_work(svms, mm); svm_range_list_lock_and_flush_work(svms, mm);
r = svm_range_is_valid(p, start, size); r = svm_range_is_valid(p, start, size);
...@@ -3300,6 +3307,8 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm, ...@@ -3300,6 +3307,8 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm,
mutex_unlock(&svms->lock); mutex_unlock(&svms->lock);
mmap_read_unlock(mm); mmap_read_unlock(mm);
out: out:
mutex_unlock(&process_info->lock);
pr_debug("pasid 0x%x svms 0x%p [0x%llx 0x%llx] done, r=%d\n", p->pasid, pr_debug("pasid 0x%x svms 0x%p [0x%llx 0x%llx] done, r=%d\n", p->pasid,
&p->svms, start, start + size - 1, r); &p->svms, start, start + size - 1, r);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment