| @@ -94,15 +94,24 @@ static int msm_iommu_pagetable_unmap(struct msm_mmu *mmu, u64 iova, · 93 unmodified lines |
| 94 | 94 | { |
| 95 | 95 | struct msm_iommu_pagetable *pagetable = to_pagetable(mmu); |
| 96 | 96 | struct io_pgtable_ops *ops = pagetable->pgtbl_ops; |
| 97 | + int ret = 0; |
| 97 | 98 | |
| 98 | 99 | while (size) { |
| 99 | | − size_t unmapped, pgsize, count; |
| 100 | + size_t pgsize, count; |
| 101 | + ssize_t unmapped; |
| 100 | 102 | |
| 101 | 103 | pgsize = calc_pgsize(pagetable, iova, iova, size, &count); |
| 102 | 104 | |
| 103 | 105 | unmapped = ops->unmap_pages(ops, iova, pgsize, count, NULL); |
| 104 | | − if (!unmapped) |
| 105 | | − break; |
| 106 | + if (unmapped <= 0) { |
| 107 | + ret = -EINVAL; |
| 108 | + /* |
| 109 | + * Continue attempting to unamp the remained of the |
| 110 | + * range, so we don't end up with some dangling |
| 111 | + * mapped pages |
| 112 | + */ |
| 113 | + unmapped = PAGE_SIZE; |
| 114 | + } |
| 106 | 115 | |
| 107 | 116 | iova += unmapped; |
| 108 | 117 | size -= unmapped; |
| @@ -110,7 +119,7 @@ static int msm_iommu_pagetable_unmap(struct msm_mmu *mmu, u64 iova, · 1 unmodified line |
| 110 | 119 | |
| 111 | 120 | iommu_flush_iotlb_all(to_msm_iommu(pagetable->parent)->domain); |
| 112 | 121 | |
| 113 | | − return (size == 0) ? 0 : -EINVAL; |
| 122 | + return ret; |
| 114 | 123 | } |
| 115 | 124 | |
| 116 | 125 | static int msm_iommu_pagetable_map_prr(struct msm_mmu *mmu, u64 iova, size_t len, int prot) |
| @@ -324,7 +333,7 @@ static const struct iommu_flush_ops tlb_ops = { · 207 unmodified lines |
| 324 | 333 | static int msm_gpu_fault_handler(struct iommu_domain *domain, struct device *dev, |
| 325 | 334 | unsigned long iova, int flags, void *arg); |
| 326 | 335 | |
| 327 | | −struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent) |
| 336 | +struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent, bool kernel_managed) |
| 328 | 337 | { |
| 329 | 338 | struct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(parent->dev); |
| 330 | 339 | struct msm_iommu *iommu = to_msm_iommu(parent); |
| @@ -358,6 +367,10 @@ struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent) · 27 unmodified lines |
| 358 | 367 | ttbr0_cfg.quirks &= ~IO_PGTABLE_QUIRK_ARM_TTBR1; |
| 359 | 368 | ttbr0_cfg.tlb = &tlb_ops; |
| 360 | 369 | |
| 370 | + if (!kernel_managed) { |
| 371 | + ttbr0_cfg.quirks |= IO_PGTABLE_QUIRK_NO_WARN; |
| 372 | + } |
| 373 | + |
| 361 | 374 | pagetable->pgtbl_ops = alloc_io_pgtable_ops(ARM_64_LPAE_S1, |
| 362 | 375 | &ttbr0_cfg, pagetable); |
| 363 | 376 | |