drm: Add locking to resume_force_mode to prevent multiple
Subsystems (2)
PATCH 1/1 drm: Add locking to resume_force_mode to prevent multiple
Add a mutex to protect resume_force_mode from being called multiple times. This fixes a bug observed on SNB where two wake sources call resume_force_mode and the FDI training fails as a result. The user facing result of this is complete screen corruption.
--- drivers/gpu/drm/drm_crtc_helper.c | 8 ++++++++ drivers/gpu/drm/drm_stub.c | 1 + include/drm/drmP.h | 1 + 3 files changed, 10 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +8 -0
@@ -882,6 +882,13 @@ int drm_helper_resume_force_mode(struct drm_device *dev)struct drm_crtc_helper_funcs *crtc_funcs;int ret; +/* Make sure we're not already resuming, this can really screw +* things up! */ +if (mutex_trylock (&dev->resume_mutex) ==0 ) { +DRM_DEBUG ("Already in resume_force_mode\n" ); +return 0 ; + } +list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {if (!crtc->enabled)
@@ -914,6 +921,7 @@ int drm_helper_resume_force_mode(struct drm_device *dev) }/* disable the unused connectors while restoring the modesetting */ drm_helper_disable_unused_functions (dev); +mutex_unlock (&dev->resume_mutex);return 0 ; }EXPORT_SYMBOL (drm_helper_resume_force_mode);
drivers/gpu/drm/drm_stub.c +1 -0
@@ -273,6 +273,7 @@ int drm_fill_in_dev(struct drm_device *dev,spin_lock_init (&dev->count_lock);spin_lock_init (&dev->event_lock);mutex_init (&dev->struct_mutex); +mutex_init (&dev->resume_mutex);mutex_init (&dev->ctxlist_mutex);if (drm_ht_create (&dev->map_hash,12 )) {
include/drm/drmP.h +1 -0
@@ -1034,6 +1034,7 @@ struct drm_device {/*@{ */ spinlock_t count_lock;/**< For inuse, drm_device::open_count, drm_device::buf_use */ struct mutex struct_mutex;/**< For others */ +struct mutex resume_mutex;/**< For drm_helper_resume_force_mode */ /*@} */ /** \name Usage Counters */
Signature · 1 line
1.7.7.3
Quoted 4 lines · Sean Paul
Add a mutex to protect
resume_force_modefrom being called multiple times. This fixes a bug observed on SNB where two wake sources callresume_force_modeand the FDI training fails as a result. The user facing result of this is complete screen corruption.
Looks like a bug in i915_drv.c for calling that function without holding the mode_config.lock
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 8 lines · Chris Wilson
Quoted 4 lines · Sean Paul
Add a mutex to protect
resume_force_modefrom being called multiple times. This fixes a bug observed on SNB where two wake sources callresume_force_modeand the FDI training fails as a result. The user facing result of this is complete screen corruption.Looks like a bug in
i915_drv.cfor calling that function without holding the mode_config.lock
Good catch, thanks for the feedback Chris.
I'll submit a new patch to intel-gfx, please drop this one.
Sean
Quoted 4 lines
-Chris
--
Chris Wilson, Intel Open Source Technology Centre