Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions drivers/gpu/drm/msm/msm_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static void put_iova_spaces(struct drm_gem_object *obj, struct drm_gpuvm *vm,
static void msm_gem_close(struct drm_gem_object *obj, struct drm_file *file)
{
struct msm_context *ctx = file->driver_priv;
struct msm_drm_private *priv = obj->dev->dev_private;
struct drm_exec exec;

update_ctx_mem(file, -obj->size);
Expand All @@ -73,6 +74,16 @@ static void msm_gem_close(struct drm_gem_object *obj, struct drm_file *file)
if (msm_context_is_vmbind(ctx))
return;

/*
* GPUs without per-process pagetables (a2xx..a5xx) hand every context
* the global GPU VM. Tearing down the VMAs there on handle close
* unmaps buffers that other processes still use (e.g. a dma-buf shared
* with the compositor), which then fault on their stale iova.
* msm_gem_vma_put() above tears them down after the last user.
*/
if (priv->gpu && ctx->vm == priv->gpu->vm)
return;

/*
* TODO we might need to kick this to a queue to avoid blocking
* in CLOSE ioctl
Expand Down Expand Up @@ -101,6 +112,21 @@ void msm_gem_vma_put(struct drm_gem_object *obj)
if (atomic_dec_return(&to_msm_bo(obj)->vma_ref))
return;

/*
* Without per-process pagetables (a2xx..a5xx) every context maps the
* object in the shared GPU VM, see msm_gem_close(). Drop that mapping,
* and the reference it holds on the object, once the last user is gone.
*/
if (priv->gpu && priv->gpu->vm) {
struct drm_exec exec;

dma_resv_wait_timeout(obj->resv, DMA_RESV_USAGE_BOOKKEEP, false,
MAX_SCHEDULE_TIMEOUT);
msm_gem_lock_vm_and_obj(&exec, obj, priv->gpu->vm);
put_iova_spaces(obj, priv->gpu->vm, true, "vma_put");
drm_exec_fini(&exec); /* drop locks */
}

if (!priv->kms)
return;

Expand Down
Loading