[Freedreno] [PATCH 04/14] drm/msm: Add priv->mm_lock to protect active/inactive lists
Rob Clark
robdclark at gmail.com
Mon Oct 5 00:10:47 UTC 2020
On Sun, Oct 4, 2020 at 3:15 PM Daniel Vetter <daniel at ffwll.ch> wrote:
>
> On Sun, Oct 4, 2020 at 9:21 PM Rob Clark <robdclark at gmail.com> wrote:
> >
> > From: Rob Clark <robdclark at chromium.org>
> >
> > Rather than relying on the big dev->struct_mutex hammer, introduce a
> > more specific lock for protecting the bo lists.
> >
> > Signed-off-by: Rob Clark <robdclark at chromium.org>
> > ---
> > drivers/gpu/drm/msm/msm_debugfs.c | 7 +++++++
> > drivers/gpu/drm/msm/msm_drv.c | 1 +
> > drivers/gpu/drm/msm/msm_drv.h | 13 +++++++++++-
> > drivers/gpu/drm/msm/msm_gem.c | 28 +++++++++++++++-----------
> > drivers/gpu/drm/msm/msm_gem_shrinker.c | 12 +++++++++++
> > drivers/gpu/drm/msm/msm_gpu.h | 5 ++++-
> > 6 files changed, 52 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_debugfs.c
> > index ee2e270f464c..64afbed89821 100644
> > --- a/drivers/gpu/drm/msm/msm_debugfs.c
> > +++ b/drivers/gpu/drm/msm/msm_debugfs.c
> > @@ -112,6 +112,11 @@ 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);
> > + if (ret)
> > + return ret;
> >
> > if (gpu) {
> > seq_printf(m, "Active Objects (%s):\n", gpu->name);
> > @@ -121,6 +126,8 @@ static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
> > seq_printf(m, "Inactive Objects:\n");
> > msm_gem_describe_objects(&priv->inactive_list, m);
> >
> > + mutex_unlock(&priv->mm_lock);
> > +
> > return 0;
> > }
> >
> > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> > index 49685571dc0e..dc6efc089285 100644
> > --- a/drivers/gpu/drm/msm/msm_drv.c
> > +++ b/drivers/gpu/drm/msm/msm_drv.c
> > @@ -441,6 +441,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
> > init_llist_head(&priv->free_list);
> >
> > INIT_LIST_HEAD(&priv->inactive_list);
> > + mutex_init(&priv->mm_lock);
>
> I highly recommend you drop a
>
> fs_reclaim_acquire(GFP_KERNEL);
> might_lock(&priv->mm_lock);
> fs_reclaim_release(GFP_KERNEL);
>
> in here to teach lockdep about your ordering against the shrinker.
> Gives you full testing every boot, even if your shrinker never gets
> called.
Good idea..
(tbf, I have tested this with android+lockdep which pretty is great
shrinker exercise.. but immediate notification of future problems is a
good plan)
BR,
-R
More information about the Freedreno
mailing list