diff options
Diffstat (limited to 'drivers/iommu/iommu-debug.c')
-rw-r--r-- | drivers/iommu/iommu-debug.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/iommu/iommu-debug.c b/drivers/iommu/iommu-debug.c index b167cd30daee..566572ae051e 100644 --- a/drivers/iommu/iommu-debug.c +++ b/drivers/iommu/iommu-debug.c @@ -1720,6 +1720,7 @@ static ssize_t iommu_debug_map_write(struct file *file, const char __user *ubuf, if (kstrtoint(comma3 + 1, 0, &prot)) goto invalid_format; + mutex_lock(&ddev->dev_lock); ret = iommu_map(ddev->domain, iova, phys, size, prot); if (ret) { pr_err("iommu_map failed with %d\n", ret); @@ -1731,6 +1732,7 @@ static ssize_t iommu_debug_map_write(struct file *file, const char __user *ubuf, pr_err("Mapped %pa to %pa (len=0x%zx, prot=0x%x)\n", &iova, &phys, size, prot); out: + mutex_unlock(&ddev->dev_lock); return retval; invalid_format: @@ -1818,14 +1820,17 @@ static ssize_t iommu_debug_dma_map_write(struct file *file, else goto invalid_format; + mutex_lock(&ddev->dev_lock); iova = dma_map_single_attrs(dev, v_addr, size, DMA_TO_DEVICE, dma_attrs); if (dma_mapping_error(dev, iova)) { pr_err("Failed to perform dma_map_single\n"); ret = -EINVAL; + mutex_unlock(&ddev->dev_lock); goto out; } + mutex_unlock(&ddev->dev_lock); retval = count; pr_err("Mapped 0x%p to %pa (len=0x%zx)\n", @@ -1932,12 +1937,15 @@ static ssize_t iommu_debug_unmap_write(struct file *file, if (kstrtosize_t(comma1 + 1, 0, &size)) goto invalid_format; + mutex_lock(&ddev->dev_lock); unmapped = iommu_unmap(ddev->domain, iova, size); if (unmapped != size) { pr_err("iommu_unmap failed. Expected to unmap: 0x%zx, unmapped: 0x%zx", size, unmapped); + mutex_unlock(&ddev->dev_lock); return -EIO; } + mutex_unlock(&ddev->dev_lock); retval = count; pr_err("Unmapped %pa (len=0x%zx)\n", &iova, size); @@ -2023,7 +2031,9 @@ static ssize_t iommu_debug_dma_unmap_write(struct file *file, else goto invalid_format; + mutex_lock(&ddev->dev_lock); dma_unmap_single_attrs(dev, iova, size, DMA_TO_DEVICE, dma_attrs); + mutex_unlock(&ddev->dev_lock); retval = count; pr_err("Unmapped %pa (len=0x%zx)\n", &iova, size); |