Commit 5117bd89 authored by Daniel Vetter's avatar Daniel Vetter Committed by Tomi Valkeinen

drm/omap: gem: Fix mm_list locking

- None of the list walkings where protected.

- Switch to a mutex since the list walking at device resume time can
  sleep when pinning buffers through the tiler.

Only thing we need to be careful with here is that while we walk the
list we can't unreference any gem objects, since the final unref would
result in a recursive deadlock. But the only functions that walk the
list is the device resume and debugfs dumping, so all safe.
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 3cbd0c58
...@@ -32,7 +32,9 @@ static int gem_show(struct seq_file *m, void *arg) ...@@ -32,7 +32,9 @@ static int gem_show(struct seq_file *m, void *arg)
struct omap_drm_private *priv = dev->dev_private; struct omap_drm_private *priv = dev->dev_private;
seq_printf(m, "All Objects:\n"); seq_printf(m, "All Objects:\n");
mutex_lock(&priv->list_lock);
omap_gem_describe_objects(&priv->obj_list, m); omap_gem_describe_objects(&priv->obj_list, m);
mutex_unlock(&priv->list_lock);
return 0; return 0;
} }
......
...@@ -540,7 +540,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) ...@@ -540,7 +540,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
priv->omaprev = soc ? (unsigned int)soc->data : 0; priv->omaprev = soc ? (unsigned int)soc->data : 0;
priv->wq = alloc_ordered_workqueue("omapdrm", 0); priv->wq = alloc_ordered_workqueue("omapdrm", 0);
spin_lock_init(&priv->list_lock); mutex_init(&priv->list_lock);
INIT_LIST_HEAD(&priv->obj_list); INIT_LIST_HEAD(&priv->obj_list);
/* Allocate and initialize the DRM device. */ /* Allocate and initialize the DRM device. */
......
...@@ -71,7 +71,7 @@ struct omap_drm_private { ...@@ -71,7 +71,7 @@ struct omap_drm_private {
struct workqueue_struct *wq; struct workqueue_struct *wq;
/* lock for obj_list below */ /* lock for obj_list below */
spinlock_t list_lock; struct mutex list_lock;
/* list of GEM objects: */ /* list of GEM objects: */
struct list_head obj_list; struct list_head obj_list;
......
...@@ -1000,6 +1000,7 @@ int omap_gem_resume(struct drm_device *dev) ...@@ -1000,6 +1000,7 @@ int omap_gem_resume(struct drm_device *dev)
struct omap_gem_object *omap_obj; struct omap_gem_object *omap_obj;
int ret = 0; int ret = 0;
mutex_lock(&priv->list_lock);
list_for_each_entry(omap_obj, &priv->obj_list, mm_list) { list_for_each_entry(omap_obj, &priv->obj_list, mm_list) {
if (omap_obj->block) { if (omap_obj->block) {
struct drm_gem_object *obj = &omap_obj->base; struct drm_gem_object *obj = &omap_obj->base;
...@@ -1011,12 +1012,14 @@ int omap_gem_resume(struct drm_device *dev) ...@@ -1011,12 +1012,14 @@ int omap_gem_resume(struct drm_device *dev)
omap_obj->roll, true); omap_obj->roll, true);
if (ret) { if (ret) {
dev_err(dev->dev, "could not repin: %d\n", ret); dev_err(dev->dev, "could not repin: %d\n", ret);
return ret; goto done;
} }
} }
} }
return 0; done:
mutex_unlock(&priv->list_lock);
return ret;
} }
#endif #endif
...@@ -1086,9 +1089,9 @@ void omap_gem_free_object(struct drm_gem_object *obj) ...@@ -1086,9 +1089,9 @@ void omap_gem_free_object(struct drm_gem_object *obj)
omap_gem_evict(obj); omap_gem_evict(obj);
spin_lock(&priv->list_lock); mutex_lock(&priv->list_lock);
list_del(&omap_obj->mm_list); list_del(&omap_obj->mm_list);
spin_unlock(&priv->list_lock); mutex_unlock(&priv->list_lock);
/* /*
* We own the sole reference to the object at this point, but to keep * We own the sole reference to the object at this point, but to keep
...@@ -1218,9 +1221,9 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, ...@@ -1218,9 +1221,9 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev,
goto err_release; goto err_release;
} }
spin_lock(&priv->list_lock); mutex_lock(&priv->list_lock);
list_add(&omap_obj->mm_list, &priv->obj_list); list_add(&omap_obj->mm_list, &priv->obj_list);
spin_unlock(&priv->list_lock); mutex_unlock(&priv->list_lock);
return obj; return obj;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment