Skip to content

drm/msm: Fix VM_BIND job, queue and entity lifetimes

Jiwoo Kim dri-devel linux-arm-msm lkml stable 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest5 patches 0 repliesNew
  2. v33 patches 0 repliesSuperseded
  3. v23 patches 4 repliesSuperseded

Changes in v4 from the cover letter

- New patch 1, as Rob suggested: VM_BIND jobs add their fences to vm->last_fence, keeping the previous fence if the merge fails. Patch 4 is still needed for killed jobs, which the scheduler frees only after it has signalled their fences.
- New patch 2, for the ordering problem across VM_BIND queues that Sashiko found in v3 patch 2, and that v3 patch 1 also made reachable through killed jobs. Unmap errors are now handled like map errors, as Rob suggested, and so is an unmap that comes before the map it undoes. A job that fails in the ioctl after updating the VMAs now marks the VM unusable as well.
- Patch 3 (v3 patch 1): uses the checks of patch 2, and describes the window that Sashiko pointed out in v3, where a job that waits for a killed job applies its updates before the killed job's unmaps.
- Patch 4 (v3 patch 2): changelog updated for patch 1, and a second Fixes tag, for the commit that added VM_BIND jobs.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5drm/msm: Wait for VM_BIND jobs in msm_gem_vm_close()drivers/gpu/drm/msm/msm_gem_vma.c+13 -10 replies
2/5drm/msm: Mark the VM unusable on out-of-order VM_BIND unmapsdrivers/gpu/drm/msm/msm_gem.h drivers/gpu/drm/msm/msm_gem_vma.c+127 -60 replies
3/5drm/msm: Release the pins and ops of a killed VM_BIND jobdrivers/gpu/drm/msm/msm_gem_vma.c+81 -130 replies
4/5drm/msm: Destroy the VM_BIND entity when its queue is closeddrivers/gpu/drm/msm/msm_gem_vma.c drivers/gpu/drm/msm/msm_gpu.h drivers/gpu/drm/msm/msm_submitqueue.c+47 -140 replies
5/5drm/msm: Put the VM_BIND queue last when freeing a VM_BIND jobdrivers/gpu/drm/msm/msm_gem_vma.c+6 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/5] drm/msm: Fix VM_BIND job, queue and entity lifetimes

These fix what happens to VM_BIND jobs, queues and entities when the file or a VM_BIND queue is closed while jobs are still pending, and make the VM unusable when VM_BIND jobs of different queues apply an unmap before the map that it undoes.

Patch 1 makes msm_gem_vm_close() wait for VM_BIND jobs, as it does for submits. Patch 2 handles an unmap that finds part of its range not mapped, or that comes before the map it undoes, like a failed map. Patch 3 makes a VM_BIND job that the scheduler kills before it runs apply its queued unmaps before it drops its references to the unmapped objects, release its BO pins, and mark the VM unusable. Patch 4 destroys the VM_BIND entity when its queue is closed, instead of on the final put, which can come after the VM's scheduler has been torn down. Patch 5 puts the queue last when a job is freed, as the queue may hold the last reference to the VM.

Changes in v4:
- New patch 1, as Rob suggested: VM_BIND jobs add their fences to vm->last_fence, keeping the previous fence if the merge fails. Patch 4 is still needed for killed jobs, which the scheduler frees only after it has signalled their fences.
- New patch 2, for the ordering problem across VM_BIND queues that Sashiko found in v3 patch 2, and that v3 patch 1 also made reachable through killed jobs. Unmap errors are now handled like map errors, as Rob suggested, and so is an unmap that comes before the map it undoes. A job that fails in the ioctl after updating the VMAs now marks the VM unusable as well.
- Patch 3 (v3 patch 1): uses the checks of patch 2, and describes the window that Sashiko pointed out in v3, where a job that waits for a killed job applies its updates before the killed job's unmaps.
- Patch 4 (v3 patch 2): changelog updated for patch 1, and a second Fixes tag, for the commit that added VM_BIND jobs.

Changes in v3:
- Patch 1: only apply the queued ops of a job that the scheduler frees after killing it, once its dependencies and the previous job of its entity are done. The error path of msm_ioctl_vm_bind() frees the job right away, so v2 could apply its unmaps too early and out of order (Sashiko). That path is left as it is in mainline, and the title now says which jobs the patch is about.
- Patch 3: rebased on patch 1, title adjusted.

Changes in v2:
- New patch 1, for an issue that Sashiko reported on v1 patch 1, which that patch makes easier to hit.
- Patch 2: changelog refers to patch 1.

Review of v2 by Rob:
https://lore.kernel.org/r/CACSVV00ZppfBKwsHJ+NBYBB7a2f3g1O=6J4Gt1m_A74fudZQoQ@mail.gmail.com

v3: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
v1: https://lore.kernel.org/r/[email protected]

Jiwoo Kim (5):
drm/msm: Wait for VM_BIND jobs in msm_gem_vm_close() drm/msm: Mark the VM unusable on out-of-order VM_BIND unmaps drm/msm: Release the pins and ops of a killed VM_BIND job drm/msm: Destroy the VM_BIND entity when its queue is closed drm/msm: Put the VM_BIND queue last when freeing a VM_BIND job

 drivers/gpu/drm/msm/msm_gem.h         |   7 +
 drivers/gpu/drm/msm/msm_gem_vma.c     | 242 ++++++++++++++++++++++++--
 drivers/gpu/drm/msm/msm_gpu.h         |   6 +
 drivers/gpu/drm/msm/msm_submitqueue.c |  50 ++++--
 4 files changed, 272 insertions(+), 33 deletions(-)

base-commit: 1e59855738454b14021b64115f0090eafc7526ae

Signature · 1 line
2.43.0