All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	dri-devel@lists.freedesktop.org
Cc: linux-omap@vger.kernel.org, Rob Clark <robdclark@gmail.com>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH 19/21] drm/omap: fix race condition with dev->obj_list
Date: Thu, 26 Feb 2015 15:20:27 +0200	[thread overview]
Message-ID: <1424956829-22892-20-git-send-email-tomi.valkeinen@ti.com> (raw)
In-Reply-To: <1424956829-22892-1-git-send-email-tomi.valkeinen@ti.com>

omap_gem_objects are added to dev->obj_list in omap_gem_new, and removed
in omap_gem_free_object. Unfortunately there's no locking for
dev->obj_list, which eventually leads to a crash:

WARNING: CPU: 1 PID: 1123 at lib/list_debug.c:59 __list_del_entry+0xa4/0xe0()
list_del corruption. prev->next should be e9281344, but was ea722b84

Add a spinlock to protect dev->obj_list.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 1 +
 drivers/gpu/drm/omapdrm/omap_drv.h | 3 +++
 drivers/gpu/drm/omapdrm/omap_gem.c | 5 +++++
 3 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index d0b1aece8cc5..2a85221e0604 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -479,6 +479,7 @@ static int dev_load(struct drm_device *dev, unsigned long flags)
 
 	priv->wq = alloc_ordered_workqueue("omapdrm", 0);
 
+	spin_lock_init(&priv->list_lock);
 	INIT_LIST_HEAD(&priv->obj_list);
 
 	omap_gem_init(dev);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 60e47b33c801..dac9f8ef3b15 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -105,6 +105,9 @@ struct omap_drm_private {
 
 	struct workqueue_struct *wq;
 
+	/* lock for obj_list below */
+	spinlock_t list_lock;
+
 	/* list of GEM objects: */
 	struct list_head obj_list;
 
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index d37ee756a0b1..e9718b99a8a9 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -1273,13 +1273,16 @@ unlock:
 void omap_gem_free_object(struct drm_gem_object *obj)
 {
 	struct drm_device *dev = obj->dev;
+	struct omap_drm_private *priv = dev->dev_private;
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 
 	evict(obj);
 
 	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
 
+	spin_lock(&priv->list_lock);
 	list_del(&omap_obj->mm_list);
+	spin_unlock(&priv->list_lock);
 
 	drm_gem_free_mmap_offset(obj);
 
@@ -1377,7 +1380,9 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev,
 	if (!omap_obj)
 		goto fail;
 
+	spin_lock(&priv->list_lock);
 	list_add(&omap_obj->mm_list, &priv->obj_list);
+	spin_unlock(&priv->list_lock);
 
 	obj = &omap_obj->base;
 
-- 
2.3.0


  parent reply	other threads:[~2015-02-26 13:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 13:20 [PATCH 00/21] drm/omap: misc fixes/improvements Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 01/21] drm/omap: fix encoder-crtc mapping Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 02/21] drm/omap: page_flip: return -EBUSY if flip pending Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 03/21] drm/omap: clear omap_obj->paddr in omap_gem_put_paddr() Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 04/21] drm/omap: add pin refcounting to omap_framebuffer Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 05/21] drm/omap: add a comment why locking is missing Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 06/21] drm/omap: check CRTC color format earlier Tomi Valkeinen
2015-02-27 12:07   ` Daniel Vetter
2015-03-02  9:55     ` Tomi Valkeinen
2015-03-04 23:41       ` Laurent Pinchart
2015-03-04 23:53     ` Laurent Pinchart
2015-02-26 13:20 ` [PATCH 07/21] drm/omap: fix operation without fbdev Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 08/21] drm/omap: fix error handling in omap_framebuffer_create() Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 09/21] drm/omap: handle mismatching color format and buffer width Tomi Valkeinen
2015-02-27 13:01   ` Daniel Vetter
2015-02-27 14:40     ` Daniel Stone
2015-02-27 15:47       ` Daniel Vetter
2015-03-02  9:50       ` Tomi Valkeinen
2015-03-02 10:22         ` Daniel Stone
2015-03-02 10:32           ` Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 10/21] drm/omap: fix TILER on OMAP5 Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 11/21] drm/omap: fix plane's channel selection Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 12/21] drm/omap: tiler: fix race condition with engine->async Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 13/21] drm/omap: remove dummy PM functions Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 14/21] drm/omap: stop connector polling during suspend Tomi Valkeinen
2015-02-26 13:57   ` Grygorii.Strashko@linaro.org
2015-03-02 11:03     ` Tomi Valkeinen
2015-03-02 18:35       ` Grygorii Strashko
2015-02-26 13:20 ` [PATCH 15/21] drm/omap: use DRM_ERROR_RATELIMITED() for error irqs Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 16/21] drm/omap: fix race with error_irq Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 17/21] drm/omap: only ignore DIGIT SYNC LOST for TV output Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 18/21] drm/omap: do not use BUG_ON(!spin_is_locked(x)) Tomi Valkeinen
2015-02-26 13:20 ` Tomi Valkeinen [this message]
2015-02-26 13:20 ` [PATCH 20/21] drm/omap: fix race conditon in DMM Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 21/21] drm/omap: keep ref to old_fb Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1424956829-22892-20-git-send-email-tomi.valkeinen@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=robdclark@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.