Skip to content

Commit 3846fd9

Browse files
committed
drm/probe-helpers: Drop locking from poll_enable
It was only needed to protect the connector_list walking, see commit 8c4ccc4 Author: Daniel Vetter <[email protected]> Date: Thu Jul 9 23:44:26 2015 +0200 drm/probe-helper: Grab mode_config.mutex in poll_init/enable Unfortunately the commit message of that patch fails to mention that the new locking check was for the connector_list. But that requirement disappeared in commit c36a325 Author: Daniel Vetter <[email protected]> Date: Thu Dec 15 16:58:43 2016 +0100 drm: Convert all helpers to drm_connector_list_iter and so we can drop this again. This fixes a locking inversion on nouveau, where the rpm code needs to re-enable. But in other places the rpm_get() calls are nested within the big modeset locks. While at it, also improve the kerneldoc for these two functions a notch. v2: Update the kerneldoc even more to explain that these functions can't be called concurrently, or bad things happen (Chris). Cc: Dave Airlie <[email protected]> Reviewed-by: Chris Wilson <[email protected]> Cc: Chris Wilson <[email protected]> Tested-by: Lyude <[email protected]> Reviewed-by: Lyude <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent fdf35a6 commit 3846fd9

File tree

3 files changed

+22
-34
lines changed

3 files changed

+22
-34
lines changed

drivers/gpu/drm/drm_probe_helper.c

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,27 @@ static int drm_helper_probe_add_cmdline_mode(struct drm_connector *connector)
115115

116116
#define DRM_OUTPUT_POLL_PERIOD (10*HZ)
117117
/**
118-
* drm_kms_helper_poll_enable_locked - re-enable output polling.
118+
* drm_kms_helper_poll_enable - re-enable output polling.
119119
* @dev: drm_device
120120
*
121-
* This function re-enables the output polling work without
122-
* locking the mode_config mutex.
121+
* This function re-enables the output polling work, after it has been
122+
* temporarily disabled using drm_kms_helper_poll_disable(), for example over
123+
* suspend/resume.
123124
*
124-
* This is like drm_kms_helper_poll_enable() however it is to be
125-
* called from a context where the mode_config mutex is locked
126-
* already.
125+
* Drivers can call this helper from their device resume implementation. It is
126+
* an error to call this when the output polling support has not yet been set
127+
* up.
128+
*
129+
* Note that calls to enable and disable polling must be strictly ordered, which
130+
* is automatically the case when they're only call from suspend/resume
131+
* callbacks.
127132
*/
128-
void drm_kms_helper_poll_enable_locked(struct drm_device *dev)
133+
void drm_kms_helper_poll_enable(struct drm_device *dev)
129134
{
130135
bool poll = false;
131136
struct drm_connector *connector;
132137
unsigned long delay = DRM_OUTPUT_POLL_PERIOD;
133138

134-
WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
135-
136139
if (!dev->mode_config.poll_enabled || !drm_kms_helper_poll)
137140
return;
138141

@@ -160,7 +163,7 @@ void drm_kms_helper_poll_enable_locked(struct drm_device *dev)
160163
if (poll)
161164
schedule_delayed_work(&dev->mode_config.output_poll_work, delay);
162165
}
163-
EXPORT_SYMBOL(drm_kms_helper_poll_enable_locked);
166+
EXPORT_SYMBOL(drm_kms_helper_poll_enable);
164167

165168
static enum drm_connector_status
166169
drm_connector_detect(struct drm_connector *connector, bool force)
@@ -287,7 +290,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
287290

288291
/* Re-enable polling in case the global poll config changed. */
289292
if (drm_kms_helper_poll != dev->mode_config.poll_running)
290-
drm_kms_helper_poll_enable_locked(dev);
293+
drm_kms_helper_poll_enable(dev);
291294

292295
dev->mode_config.poll_running = drm_kms_helper_poll;
293296

@@ -479,8 +482,12 @@ static void output_poll_execute(struct work_struct *work)
479482
* This function disables the output polling work.
480483
*
481484
* Drivers can call this helper from their device suspend implementation. It is
482-
* not an error to call this even when output polling isn't enabled or arlready
483-
* disabled.
485+
* not an error to call this even when output polling isn't enabled or already
486+
* disabled. Polling is re-enabled by calling drm_kms_helper_poll_enable().
487+
*
488+
* Note that calls to enable and disable polling must be strictly ordered, which
489+
* is automatically the case when they're only call from suspend/resume
490+
* callbacks.
484491
*/
485492
void drm_kms_helper_poll_disable(struct drm_device *dev)
486493
{
@@ -490,24 +497,6 @@ void drm_kms_helper_poll_disable(struct drm_device *dev)
490497
}
491498
EXPORT_SYMBOL(drm_kms_helper_poll_disable);
492499

493-
/**
494-
* drm_kms_helper_poll_enable - re-enable output polling.
495-
* @dev: drm_device
496-
*
497-
* This function re-enables the output polling work.
498-
*
499-
* Drivers can call this helper from their device resume implementation. It is
500-
* an error to call this when the output polling support has not yet been set
501-
* up.
502-
*/
503-
void drm_kms_helper_poll_enable(struct drm_device *dev)
504-
{
505-
mutex_lock(&dev->mode_config.mutex);
506-
drm_kms_helper_poll_enable_locked(dev);
507-
mutex_unlock(&dev->mode_config.mutex);
508-
}
509-
EXPORT_SYMBOL(drm_kms_helper_poll_enable);
510-
511500
/**
512501
* drm_kms_helper_poll_init - initialize and enable output polling
513502
* @dev: drm_device

drivers/gpu/drm/i915/intel_hotplug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void intel_hpd_irq_storm_disable(struct drm_i915_private *dev_priv)
180180

181181
/* Enable polling and queue hotplug re-enabling. */
182182
if (hpd_disabled) {
183-
drm_kms_helper_poll_enable_locked(dev);
183+
drm_kms_helper_poll_enable(dev);
184184
mod_delayed_work(system_wq, &dev_priv->hotplug.reenable_work,
185185
msecs_to_jiffies(HPD_STORM_REENABLE_DELAY));
186186
}
@@ -511,7 +511,7 @@ static void i915_hpd_poll_init_work(struct work_struct *work)
511511
}
512512

513513
if (enabled)
514-
drm_kms_helper_poll_enable_locked(dev);
514+
drm_kms_helper_poll_enable(dev);
515515

516516
mutex_unlock(&dev->mode_config.mutex);
517517

include/drm/drm_crtc_helper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,5 @@ extern void drm_kms_helper_hotplug_event(struct drm_device *dev);
7373

7474
extern void drm_kms_helper_poll_disable(struct drm_device *dev);
7575
extern void drm_kms_helper_poll_enable(struct drm_device *dev);
76-
extern void drm_kms_helper_poll_enable_locked(struct drm_device *dev);
7776

7877
#endif

0 commit comments

Comments
 (0)