Re: [PATCH 3/4] drm/msm: Fix debugfs deadlock
From: Rob Clark
Date: Wed Mar 31 2021 - 19:29:22 EST
On Wed, Mar 31, 2021 at 4:13 PM Doug Anderson <dianders@xxxxxxxxxxxx> wrote:
>
> Hi,
>
> On Wed, Mar 31, 2021 at 3:14 PM Rob Clark <robdclark@xxxxxxxxx> wrote:
> >
> > @@ -111,23 +111,15 @@ static const struct file_operations msm_gpu_fops = {
> > static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
> > {
> > struct msm_drm_private *priv = dev->dev_private;
> > - struct msm_gpu *gpu = priv->gpu;
> > int ret;
> >
> > - ret = mutex_lock_interruptible(&priv->mm_lock);
> > + ret = mutex_lock_interruptible(&priv->obj_lock);
> > if (ret)
> > return ret;
> >
> > - if (gpu) {
> > - seq_printf(m, "Active Objects (%s):\n", gpu->name);
> > - msm_gem_describe_objects(&gpu->active_list, m);
> > - }
> > -
> > - seq_printf(m, "Inactive Objects:\n");
> > - msm_gem_describe_objects(&priv->inactive_dontneed, m);
> > - msm_gem_describe_objects(&priv->inactive_willneed, m);
> > + msm_gem_describe_objects(&priv->objects, m);
>
> I guess we no longer sort the by Active and Inactive but that doesn't
> really matter?
It turned out to be less useful to sort by active/inactive, as much as
just having the summary at the bottom that the last patch adds. We
can already tell from the per-object entries whether it is
active/purgable/purged.
I did initially try to come up with an approach that let me keep this,
but it would basically amount to re-writing the gem_submit path
(because you cannot do any memory allocation under mm_lock)
>
> > @@ -174,7 +174,13 @@ struct msm_drm_private {
> > struct msm_rd_state *hangrd; /* debugfs to dump hanging submits */
> > struct msm_perf_state *perf;
> >
> > - /*
> > + /**
> > + * List of all GEM objects (mainly for debugfs, protected by obj_lock
>
> It wouldn't hurt to talk about lock ordering here? Like: "If we need
> the "obj_lock" and a "gem_lock" at the same time we always grab the
> "obj_lock" first.
good point
>
> > @@ -60,13 +60,20 @@ struct msm_gem_object {
> > */
> > uint8_t vmap_count;
> >
> > - /* And object is either:
> > - * inactive - on priv->inactive_list
> > + /**
> > + * Node in list of all objects (mainly for debugfs, protected by
> > + * struct_mutex
>
> Not "struct_mutex" in comment, right? Maybe "obj_lock" I think?
oh, right, forgot to fix that from an earlier iteration
BR,
-R