Skip to content

Commit ecbec53

Browse files
Hugh Dickinstorvalds
authored andcommitted
drm/i915: more struct_mutex locking
When auditing the locking in i915_gem.c (for a prospective change which I then abandoned), I noticed two places where struct_mutex is not held across GEM object manipulations that would usually require it. Since one is in initial setup and the other in driver unload, I'm guessing the mutex is not required for either; but post a patch in case it is. Signed-off-by: Hugh Dickins <hughd@google.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Keith Packard <keithp@keithp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e2377fe commit ecbec53

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎drivers/gpu/drm/i915/i915_dma.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,9 +2182,8 @@ int i915_driver_unload(struct drm_device *dev)
21822182
/* Flush any outstanding unpin_work. */
21832183
flush_workqueue(dev_priv->wq);
21842184

2185-
i915_gem_free_all_phys_object(dev);
2186-
21872185
mutex_lock(&dev->struct_mutex);
2186+
i915_gem_free_all_phys_object(dev);
21882187
i915_gem_cleanup_ringbuffer(dev);
21892188
mutex_unlock(&dev->struct_mutex);
21902189
if (I915_HAS_FBC(dev) && i915_powersave)

‎drivers/gpu/drm/i915/intel_overlay.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,8 @@ void intel_setup_overlay(struct drm_device *dev)
14161416
goto out_free;
14171417
overlay->reg_bo = reg_bo;
14181418

1419+
mutex_lock(&dev->struct_mutex);
1420+
14191421
if (OVERLAY_NEEDS_PHYSICAL(dev)) {
14201422
ret = i915_gem_attach_phys_object(dev, reg_bo,
14211423
I915_GEM_PHYS_OVERLAY_REGS,
@@ -1440,6 +1442,8 @@ void intel_setup_overlay(struct drm_device *dev)
14401442
}
14411443
}
14421444

1445+
mutex_unlock(&dev->struct_mutex);
1446+
14431447
/* init all values */
14441448
overlay->color_key = 0x0101fe;
14451449
overlay->brightness = -19;
@@ -1464,6 +1468,7 @@ void intel_setup_overlay(struct drm_device *dev)
14641468
i915_gem_object_unpin(reg_bo);
14651469
out_free_bo:
14661470
drm_gem_object_unreference(&reg_bo->base);
1471+
mutex_unlock(&dev->struct_mutex);
14671472
out_free:
14681473
kfree(overlay);
14691474
return;

0 commit comments

Comments
 (0)