Skip to content

Commit 54a07c7

Browse files
committed
Revert "drm/probe-helpers: Drop locking from poll_enable"
This reverts commit 3846fd9. There were some precursor commits missing for this around connector locking, we should probably merge Lyude's nouveau avoid the problem patch.
1 parent 9327901 commit 54a07c7

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

drivers/gpu/drm/drm_probe_helper.c

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,27 +115,24 @@ 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 - re-enable output polling.
118+
* drm_kms_helper_poll_enable_locked - re-enable output polling.
119119
* @dev: drm_device
120120
*
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.
121+
* This function re-enables the output polling work without
122+
* locking the mode_config mutex.
124123
*
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.
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.
132127
*/
133-
void drm_kms_helper_poll_enable(struct drm_device *dev)
128+
void drm_kms_helper_poll_enable_locked(struct drm_device *dev)
134129
{
135130
bool poll = false;
136131
struct drm_connector *connector;
137132
unsigned long delay = DRM_OUTPUT_POLL_PERIOD;
138133

134+
WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
135+
139136
if (!dev->mode_config.poll_enabled || !drm_kms_helper_poll)
140137
return;
141138

@@ -163,7 +160,7 @@ void drm_kms_helper_poll_enable(struct drm_device *dev)
163160
if (poll)
164161
schedule_delayed_work(&dev->mode_config.output_poll_work, delay);
165162
}
166-
EXPORT_SYMBOL(drm_kms_helper_poll_enable);
163+
EXPORT_SYMBOL(drm_kms_helper_poll_enable_locked);
167164

168165
static enum drm_connector_status
169166
drm_connector_detect(struct drm_connector *connector, bool force)
@@ -290,7 +287,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
290287

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

295292
dev->mode_config.poll_running = drm_kms_helper_poll;
296293

@@ -482,12 +479,8 @@ static void output_poll_execute(struct work_struct *work)
482479
* This function disables the output polling work.
483480
*
484481
* Drivers can call this helper from their device suspend implementation. It is
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.
482+
* not an error to call this even when output polling isn't enabled or arlready
483+
* disabled.
491484
*/
492485
void drm_kms_helper_poll_disable(struct drm_device *dev)
493486
{
@@ -497,6 +490,24 @@ void drm_kms_helper_poll_disable(struct drm_device *dev)
497490
}
498491
EXPORT_SYMBOL(drm_kms_helper_poll_disable);
499492

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+
500511
/**
501512
* drm_kms_helper_poll_init - initialize and enable output polling
502513
* @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(dev);
183+
drm_kms_helper_poll_enable_locked(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(dev);
514+
drm_kms_helper_poll_enable_locked(dev);
515515

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

include/drm/drm_crtc_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,6 @@ 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);
7677

7778
#endif

0 commit comments

Comments
 (0)