diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-07-24 16:40:23 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-07-25 09:30:54 -0400 |
commit | c20e835586c0e4d08f891362b3c829d45ef45f9d (patch) | |
tree | 991c9c15408fa756f26ab3aec5d2b6fb38384f74 | |
parent | ed71f1b48e95408d0b3ded014a15fb9d52ac5a86 (diff) |
drm/i915: fix the racy object accounting
Just use a spinlock to protect them.
v2: Rebase onto the new object create refcount fix patch.
v3: Don't kill dev_priv->mm.object_memory as requested by Chris and
hence just use a spinlock instead of atomic_t.
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67287
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 4 |
3 files changed, 6 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 8536acd0a85d..f48f1c476977 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -1478,6 +1478,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
1478 | spin_lock_init(&dev_priv->gpu_error.lock); | 1478 | spin_lock_init(&dev_priv->gpu_error.lock); |
1479 | spin_lock_init(&dev_priv->backlight.lock); | 1479 | spin_lock_init(&dev_priv->backlight.lock); |
1480 | spin_lock_init(&dev_priv->uncore.lock); | 1480 | spin_lock_init(&dev_priv->uncore.lock); |
1481 | spin_lock_init(&dev_priv->mm.object_stat_lock); | ||
1481 | mutex_init(&dev_priv->dpio_lock); | 1482 | mutex_init(&dev_priv->dpio_lock); |
1482 | mutex_init(&dev_priv->rps.hw_lock); | 1483 | mutex_init(&dev_priv->rps.hw_lock); |
1483 | mutex_init(&dev_priv->modeset_restore_lock); | 1484 | mutex_init(&dev_priv->modeset_restore_lock); |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 637e541c3b9d..82ea281b2182 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -935,6 +935,7 @@ struct i915_gem_mm { | |||
935 | struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT]; | 935 | struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT]; |
936 | 936 | ||
937 | /* accounting, useful for userland debugging */ | 937 | /* accounting, useful for userland debugging */ |
938 | spinlock_t object_stat_lock; | ||
938 | size_t object_memory; | 939 | size_t object_memory; |
939 | u32 object_count; | 940 | u32 object_count; |
940 | }; | 941 | }; |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index eceab96d76f5..35d17fb1b89b 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -75,15 +75,19 @@ static inline void i915_gem_object_fence_lost(struct drm_i915_gem_object *obj) | |||
75 | static void i915_gem_info_add_obj(struct drm_i915_private *dev_priv, | 75 | static void i915_gem_info_add_obj(struct drm_i915_private *dev_priv, |
76 | size_t size) | 76 | size_t size) |
77 | { | 77 | { |
78 | spin_lock(&dev_priv->mm.object_stat_lock); | ||
78 | dev_priv->mm.object_count++; | 79 | dev_priv->mm.object_count++; |
79 | dev_priv->mm.object_memory += size; | 80 | dev_priv->mm.object_memory += size; |
81 | spin_unlock(&dev_priv->mm.object_stat_lock); | ||
80 | } | 82 | } |
81 | 83 | ||
82 | static void i915_gem_info_remove_obj(struct drm_i915_private *dev_priv, | 84 | static void i915_gem_info_remove_obj(struct drm_i915_private *dev_priv, |
83 | size_t size) | 85 | size_t size) |
84 | { | 86 | { |
87 | spin_lock(&dev_priv->mm.object_stat_lock); | ||
85 | dev_priv->mm.object_count--; | 88 | dev_priv->mm.object_count--; |
86 | dev_priv->mm.object_memory -= size; | 89 | dev_priv->mm.object_memory -= size; |
90 | spin_unlock(&dev_priv->mm.object_stat_lock); | ||
87 | } | 91 | } |
88 | 92 | ||
89 | static int | 93 | static int |