History

drm/msm: Support IO_PGTABLE_QUIRK_NO_WARN_ON

With user managed VMs and multiple queues, it is in theory possible to trigger map/unmap errors. These will (in a later patch) mark the VM as unusable. But we want to tell the io-pgtable helpers not to spam the log. In addition, in the unmap path, we don't want to bail early from the unmap, to ensure we don't leave some dangling pages mapped.

Rob Clark committed 1 year ago

Commit 2b93efe1 parent 92395af3 files · +20 −7Browse files

Unified · Split

3 files
  1. drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1 −1
  2. drivers/gpu/drm/msm/msm_iommu.c +18 −5
  3. drivers/gpu/drm/msm/msm_mmu.h +1 −1
drivers/gpu/drm/msm/adreno/a6xx_gpu.c+1−1
@@ -2280,7 +2280,7 @@ a6xx_create_private_vm(struct msm_gpu *gpu, bool kernel_managed) · 2279 unmodified lines
2280{2280{
2281 struct msm_mmu *mmu;2281 struct msm_mmu *mmu;
2282 2282
2283 mmu = msm_iommu_pagetable_create(to_msm_vm(gpu->vm)->mmu);2283 mmu = msm_iommu_pagetable_create(to_msm_vm(gpu->vm)->mmu, kernel_managed);
2284 2284
2285 if (IS_ERR(mmu))2285 if (IS_ERR(mmu))
2286 return ERR_CAST(mmu);2286 return ERR_CAST(mmu);
drivers/gpu/drm/msm/msm_iommu.c+18−5
@@ -94,15 +94,24 @@ static int msm_iommu_pagetable_unmap(struct msm_mmu *mmu, u64 iova, · 93 unmodified lines
94{94{
95 struct msm_iommu_pagetable *pagetable = to_pagetable(mmu);95 struct msm_iommu_pagetable *pagetable = to_pagetable(mmu);
96 struct io_pgtable_ops *ops = pagetable->pgtbl_ops;96 struct io_pgtable_ops *ops = pagetable->pgtbl_ops;
97 int ret = 0;
97 98
98 while (size) {99 while (size) {
99 size_t unmapped, pgsize, count;100 size_t pgsize, count;
101 ssize_t unmapped;
100 102
101 pgsize = calc_pgsize(pagetable, iova, iova, size, &count);103 pgsize = calc_pgsize(pagetable, iova, iova, size, &count);
102 104
103 unmapped = ops->unmap_pages(ops, iova, pgsize, count, NULL);105 unmapped = ops->unmap_pages(ops, iova, pgsize, count, NULL);
104 if (!unmapped)106 if (unmapped <= 0) {
105 break;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 iova += unmapped;116 iova += unmapped;
108 size -= unmapped;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 iommu_flush_iotlb_all(to_msm_iommu(pagetable->parent)->domain);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
116static int msm_iommu_pagetable_map_prr(struct msm_mmu *mmu, u64 iova, size_t len, int prot)125static 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
324static int msm_gpu_fault_handler(struct iommu_domain *domain, struct device *dev,333static int msm_gpu_fault_handler(struct iommu_domain *domain, struct device *dev,
325 unsigned long iova, int flags, void *arg);334 unsigned long iova, int flags, void *arg);
326 335
327struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent)336struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent, bool kernel_managed)
328{337{
329 struct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(parent->dev);338 struct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(parent->dev);
330 struct msm_iommu *iommu = to_msm_iommu(parent);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 ttbr0_cfg.quirks &= ~IO_PGTABLE_QUIRK_ARM_TTBR1;367 ttbr0_cfg.quirks &= ~IO_PGTABLE_QUIRK_ARM_TTBR1;
359 ttbr0_cfg.tlb = &tlb_ops;368 ttbr0_cfg.tlb = &tlb_ops;
360 369
370 if (!kernel_managed) {
371 ttbr0_cfg.quirks |= IO_PGTABLE_QUIRK_NO_WARN;
372 }
373
361 pagetable->pgtbl_ops = alloc_io_pgtable_ops(ARM_64_LPAE_S1,374 pagetable->pgtbl_ops = alloc_io_pgtable_ops(ARM_64_LPAE_S1,
362 &ttbr0_cfg, pagetable);375 &ttbr0_cfg, pagetable);
363 376
drivers/gpu/drm/msm/msm_mmu.h+1−1
@@ -51,7 +51,7 @@ static inline void msm_mmu_set_fault_handler(struct msm_mmu *mmu, void *arg, · 50 unmodified lines
51 mmu->handler = handler;51 mmu->handler = handler;
52}52}
53 53
54struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent);54struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent, bool kernel_managed);
55 55
56int msm_iommu_pagetable_params(struct msm_mmu *mmu, phys_addr_t *ttbr,56int msm_iommu_pagetable_params(struct msm_mmu *mmu, phys_addr_t *ttbr,
57 int *asid);57 int *asid);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t