diff options
author | Joerg Roedel <jroedel@suse.de> | 2015-11-17 16:11:38 +0100 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2015-12-14 15:39:41 +0100 |
commit | 492e74594ec6285207f9db02d41c41cad5dbc6ab (patch) | |
tree | 3c2a7542d152f9fae1c1771d79df2f8f9719195e /drivers/iommu | |
parent | iommu/amd: Correctly set flags for handle_mm_fault call (diff) | |
download | linux-492e74594ec6285207f9db02d41c41cad5dbc6ab.tar.xz linux-492e74594ec6285207f9db02d41c41cad5dbc6ab.zip |
iommu/amd: Cleanup error handling in do_fault()
Get rid of the three error paths that look the same and move
error handling to a single place.
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Acked-By: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/amd_iommu_v2.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c index a7edbd6851c4..6a28b745521d 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c @@ -514,10 +514,10 @@ static void do_fault(struct work_struct *work) { struct fault *fault = container_of(work, struct fault, work); struct vm_area_struct *vma; + int ret = VM_FAULT_ERROR; unsigned int flags = 0; struct mm_struct *mm; u64 address; - int ret; mm = fault->state->mm; address = fault->address; @@ -529,31 +529,23 @@ static void do_fault(struct work_struct *work) down_read(&mm->mmap_sem); vma = find_extend_vma(mm, address); - if (!vma || address < vma->vm_start) { + if (!vma || address < vma->vm_start) /* failed to get a vma in the right range */ - up_read(&mm->mmap_sem); - handle_fault_error(fault); goto out; - } /* Check if we have the right permissions on the vma */ - if (access_error(vma, fault)) { - up_read(&mm->mmap_sem); - handle_fault_error(fault); + if (access_error(vma, fault)) goto out; - } ret = handle_mm_fault(mm, vma, address, flags); - if (ret & VM_FAULT_ERROR) { - /* failed to service fault */ - up_read(&mm->mmap_sem); - handle_fault_error(fault); - goto out; - } +out: up_read(&mm->mmap_sem); -out: + if (ret & VM_FAULT_ERROR) + /* failed to service fault */ + handle_fault_error(fault); + finish_pri_tag(fault->dev_state, fault->state, fault->tag); put_pasid_state(fault->state); |