Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Add a non-locking version of drm_kms_helper_poll_enable(), v2

drm_kms_helper_poll_enable() was converted to lock the mode_config
mutex in commit 8c4ccc4ab6f64e859d4ff8d7c02c2ed2e956e07f
("drm/probe-helper: Grab mode_config.mutex in poll_init/enable").

This disregarded the cases where this function is called from a context
where this mutex is already locked.

Add a non-locking version as well.

Changes since v1:
- use function name suffix '_locked' for the function that
is to be called from a locked context.

Signed-off-by: Egbert Eich <eich@suse.de>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

authored by

Egbert Eich and committed by
Jani Nikula
4ad640e9 dfc53c5e

+17 -3
+16 -3
drivers/gpu/drm/drm_probe_helper.c
··· 94 94 } 95 95 96 96 #define DRM_OUTPUT_POLL_PERIOD (10*HZ) 97 - static void __drm_kms_helper_poll_enable(struct drm_device *dev) 97 + /** 98 + * drm_kms_helper_poll_enable_locked - re-enable output polling. 99 + * @dev: drm_device 100 + * 101 + * This function re-enables the output polling work without 102 + * locking the mode_config mutex. 103 + * 104 + * This is like drm_kms_helper_poll_enable() however it is to be 105 + * called from a context where the mode_config mutex is locked 106 + * already. 107 + */ 108 + void drm_kms_helper_poll_enable_locked(struct drm_device *dev) 98 109 { 99 110 bool poll = false; 100 111 struct drm_connector *connector; ··· 124 113 if (poll) 125 114 schedule_delayed_work(&dev->mode_config.output_poll_work, DRM_OUTPUT_POLL_PERIOD); 126 115 } 116 + EXPORT_SYMBOL(drm_kms_helper_poll_enable_locked); 117 + 127 118 128 119 static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connector *connector, 129 120 uint32_t maxX, uint32_t maxY, bool merge_type_bits) ··· 187 174 188 175 /* Re-enable polling in case the global poll config changed. */ 189 176 if (drm_kms_helper_poll != dev->mode_config.poll_running) 190 - __drm_kms_helper_poll_enable(dev); 177 + drm_kms_helper_poll_enable_locked(dev); 191 178 192 179 dev->mode_config.poll_running = drm_kms_helper_poll; 193 180 ··· 441 428 void drm_kms_helper_poll_enable(struct drm_device *dev) 442 429 { 443 430 mutex_lock(&dev->mode_config.mutex); 444 - __drm_kms_helper_poll_enable(dev); 431 + drm_kms_helper_poll_enable_locked(dev); 445 432 mutex_unlock(&dev->mode_config.mutex); 446 433 } 447 434 EXPORT_SYMBOL(drm_kms_helper_poll_enable);
+1
include/drm/drm_crtc_helper.h
··· 240 240 241 241 extern void drm_kms_helper_poll_disable(struct drm_device *dev); 242 242 extern void drm_kms_helper_poll_enable(struct drm_device *dev); 243 + extern void drm_kms_helper_poll_enable_locked(struct drm_device *dev); 243 244 244 245 #endif