Skip to content

Commit 848a4e5

Browse files
lucacoelhojnikula
authored andcommitted
drm/i915: add a dedicated workqueue inside drm_i915_private
In order to avoid flush_scheduled_work() usage, add a dedicated workqueue in the drm_i915_private structure. In this way, we don't need to use the system queue anymore. This change is mostly mechanical and based on Tetsuo's original patch[1]. v6 by Jani: - Also create unordered_wq for mock device Link: https://patchwork.freedesktop.org/series/114608/ [1] Cc: Tetsuo Handa <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Ville Syrjälä <[email protected]> Reviewed-by: Jani Nikula <[email protected]> Reviewed-by: Tvrtko Ursulin <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Signed-off-by: Jani Nikula <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/c816ebe17ef08d363981942a096a586a7658a65e.1686231190.git.jani.nikula@intel.com
1 parent 8d208a5 commit 848a4e5

25 files changed

+110
-54
lines changed

drivers/gpu/drm/i915/display/intel_display.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7180,11 +7180,12 @@ intel_atomic_commit_ready(struct i915_sw_fence *fence,
71807180
break;
71817181
case FENCE_FREE:
71827182
{
7183+
struct drm_i915_private *i915 = to_i915(state->base.dev);
71837184
struct intel_atomic_helper *helper =
7184-
&to_i915(state->base.dev)->display.atomic_helper;
7185+
&i915->display.atomic_helper;
71857186

71867187
if (llist_add(&state->freed, &helper->free_list))
7187-
schedule_work(&helper->free_work);
7188+
queue_work(i915->unordered_wq, &helper->free_work);
71887189
break;
71897190
}
71907191
}

drivers/gpu/drm/i915/display/intel_display_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ void intel_display_driver_remove_noirq(struct drm_i915_private *i915)
442442
intel_unregister_dsm_handler();
443443

444444
/* flush any delayed tasks or pending work */
445-
flush_scheduled_work();
445+
flush_workqueue(i915->unordered_wq);
446446

447447
intel_hdcp_component_fini(i915);
448448

drivers/gpu/drm/i915/display/intel_dmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ void intel_dmc_init(struct drm_i915_private *i915)
10571057
i915->display.dmc.dmc = dmc;
10581058

10591059
drm_dbg_kms(&i915->drm, "Loading %s\n", dmc->fw_path);
1060-
schedule_work(&dmc->work);
1060+
queue_work(i915->unordered_wq, &dmc->work);
10611061

10621062
return;
10631063

drivers/gpu/drm/i915/display/intel_dp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5251,7 +5251,7 @@ static void intel_dp_oob_hotplug_event(struct drm_connector *connector)
52515251
spin_lock_irq(&i915->irq_lock);
52525252
i915->display.hotplug.event_bits |= BIT(encoder->hpd_pin);
52535253
spin_unlock_irq(&i915->irq_lock);
5254-
queue_delayed_work(system_wq, &i915->display.hotplug.hotplug_work, 0);
5254+
queue_delayed_work(i915->unordered_wq, &i915->display.hotplug.hotplug_work, 0);
52555255
}
52565256

52575257
static const struct drm_connector_funcs intel_dp_connector_funcs = {

drivers/gpu/drm/i915/display/intel_dp_link_training.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ static void intel_dp_schedule_fallback_link_training(struct intel_dp *intel_dp,
10641064
const struct intel_crtc_state *crtc_state)
10651065
{
10661066
struct intel_connector *intel_connector = intel_dp->attached_connector;
1067+
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
10671068

10681069
if (!intel_digital_port_connected(&dp_to_dig_port(intel_dp)->base)) {
10691070
lt_dbg(intel_dp, DP_PHY_DPRX, "Link Training failed on disconnected sink.\n");
@@ -1081,7 +1082,7 @@ static void intel_dp_schedule_fallback_link_training(struct intel_dp *intel_dp,
10811082
}
10821083

10831084
/* Schedule a Hotplug Uevent to userspace to start modeset */
1084-
schedule_work(&intel_connector->modeset_retry_work);
1085+
queue_work(i915->unordered_wq, &intel_connector->modeset_retry_work);
10851086
}
10861087

10871088
/* Perform the link training on all LTTPRs and the DPRX on a link. */

drivers/gpu/drm/i915/display/intel_drrs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ static void intel_drrs_set_state(struct intel_crtc *crtc,
111111

112112
static void intel_drrs_schedule_work(struct intel_crtc *crtc)
113113
{
114-
mod_delayed_work(system_wq, &crtc->drrs.work, msecs_to_jiffies(1000));
114+
struct drm_i915_private *i915 = to_i915(crtc->base.dev);
115+
116+
mod_delayed_work(i915->unordered_wq, &crtc->drrs.work, msecs_to_jiffies(1000));
115117
}
116118

117119
static unsigned int intel_drrs_frontbuffer_bits(const struct intel_crtc_state *crtc_state)

drivers/gpu/drm/i915/display/intel_fbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ static void __intel_fbc_handle_fifo_underrun_irq(struct intel_fbc *fbc)
16001600
if (READ_ONCE(fbc->underrun_detected))
16011601
return;
16021602

1603-
schedule_work(&fbc->underrun_work);
1603+
queue_work(fbc->i915->unordered_wq, &fbc->underrun_work);
16041604
}
16051605

16061606
/**

drivers/gpu/drm/i915/display/intel_fbdev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,8 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous
694694
/* Don't block our own workqueue as this can
695695
* be run in parallel with other i915.ko tasks.
696696
*/
697-
schedule_work(&dev_priv->display.fbdev.suspend_work);
697+
queue_work(dev_priv->unordered_wq,
698+
&dev_priv->display.fbdev.suspend_work);
698699
return;
699700
}
700701
}

drivers/gpu/drm/i915/display/intel_hdcp.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ static void intel_hdcp_update_value(struct intel_connector *connector,
983983
struct drm_device *dev = connector->base.dev;
984984
struct intel_digital_port *dig_port = intel_attached_dig_port(connector);
985985
struct intel_hdcp *hdcp = &connector->hdcp;
986+
struct drm_i915_private *i915 = to_i915(connector->base.dev);
986987

987988
drm_WARN_ON(connector->base.dev, !mutex_is_locked(&hdcp->mutex));
988989

@@ -1001,7 +1002,7 @@ static void intel_hdcp_update_value(struct intel_connector *connector,
10011002
hdcp->value = value;
10021003
if (update_property) {
10031004
drm_connector_get(&connector->base);
1004-
schedule_work(&hdcp->prop_work);
1005+
queue_work(i915->unordered_wq, &hdcp->prop_work);
10051006
}
10061007
}
10071008

@@ -2090,16 +2091,17 @@ static void intel_hdcp_check_work(struct work_struct *work)
20902091
struct intel_hdcp,
20912092
check_work);
20922093
struct intel_connector *connector = intel_hdcp_to_connector(hdcp);
2094+
struct drm_i915_private *i915 = to_i915(connector->base.dev);
20932095

20942096
if (drm_connector_is_unregistered(&connector->base))
20952097
return;
20962098

20972099
if (!intel_hdcp2_check_link(connector))
2098-
schedule_delayed_work(&hdcp->check_work,
2099-
DRM_HDCP2_CHECK_PERIOD_MS);
2100+
queue_delayed_work(i915->unordered_wq, &hdcp->check_work,
2101+
DRM_HDCP2_CHECK_PERIOD_MS);
21002102
else if (!intel_hdcp_check_link(connector))
2101-
schedule_delayed_work(&hdcp->check_work,
2102-
DRM_HDCP_CHECK_PERIOD_MS);
2103+
queue_delayed_work(i915->unordered_wq, &hdcp->check_work,
2104+
DRM_HDCP_CHECK_PERIOD_MS);
21032105
}
21042106

21052107
static int i915_hdcp_component_bind(struct device *i915_kdev,
@@ -2398,7 +2400,8 @@ int intel_hdcp_enable(struct intel_atomic_state *state,
23982400
}
23992401

24002402
if (!ret) {
2401-
schedule_delayed_work(&hdcp->check_work, check_link_interval);
2403+
queue_delayed_work(i915->unordered_wq, &hdcp->check_work,
2404+
check_link_interval);
24022405
intel_hdcp_update_value(connector,
24032406
DRM_MODE_CONTENT_PROTECTION_ENABLED,
24042407
true);
@@ -2447,6 +2450,7 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
24472450
to_intel_connector(conn_state->connector);
24482451
struct intel_hdcp *hdcp = &connector->hdcp;
24492452
bool content_protection_type_changed, desired_and_not_enabled = false;
2453+
struct drm_i915_private *i915 = to_i915(connector->base.dev);
24502454

24512455
if (!connector->hdcp.shim)
24522456
return;
@@ -2473,7 +2477,7 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
24732477
mutex_lock(&hdcp->mutex);
24742478
hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
24752479
drm_connector_get(&connector->base);
2476-
schedule_work(&hdcp->prop_work);
2480+
queue_work(i915->unordered_wq, &hdcp->prop_work);
24772481
mutex_unlock(&hdcp->mutex);
24782482
}
24792483

@@ -2490,7 +2494,7 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
24902494
*/
24912495
if (!desired_and_not_enabled && !content_protection_type_changed) {
24922496
drm_connector_get(&connector->base);
2493-
schedule_work(&hdcp->prop_work);
2497+
queue_work(i915->unordered_wq, &hdcp->prop_work);
24942498
}
24952499
}
24962500

@@ -2602,12 +2606,13 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
26022606
void intel_hdcp_handle_cp_irq(struct intel_connector *connector)
26032607
{
26042608
struct intel_hdcp *hdcp = &connector->hdcp;
2609+
struct drm_i915_private *i915 = to_i915(connector->base.dev);
26052610

26062611
if (!hdcp->shim)
26072612
return;
26082613

26092614
atomic_inc(&connector->hdcp.cp_irq_count);
26102615
wake_up_all(&connector->hdcp.cp_irq_queue);
26112616

2612-
schedule_delayed_work(&hdcp->check_work, 0);
2617+
queue_delayed_work(i915->unordered_wq, &hdcp->check_work, 0);
26132618
}

drivers/gpu/drm/i915/display/intel_hotplug.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ intel_hpd_irq_storm_switch_to_polling(struct drm_i915_private *dev_priv)
212212
/* Enable polling and queue hotplug re-enabling. */
213213
if (hpd_disabled) {
214214
drm_kms_helper_poll_enable(&dev_priv->drm);
215-
mod_delayed_work(system_wq, &dev_priv->display.hotplug.reenable_work,
215+
mod_delayed_work(dev_priv->unordered_wq,
216+
&dev_priv->display.hotplug.reenable_work,
216217
msecs_to_jiffies(HPD_STORM_REENABLE_DELAY));
217218
}
218219
}
@@ -339,7 +340,8 @@ static void i915_digport_work_func(struct work_struct *work)
339340
spin_lock_irq(&dev_priv->irq_lock);
340341
dev_priv->display.hotplug.event_bits |= old_bits;
341342
spin_unlock_irq(&dev_priv->irq_lock);
342-
queue_delayed_work(system_wq, &dev_priv->display.hotplug.hotplug_work, 0);
343+
queue_delayed_work(dev_priv->unordered_wq,
344+
&dev_priv->display.hotplug.hotplug_work, 0);
343345
}
344346
}
345347

@@ -446,7 +448,8 @@ static void i915_hotplug_work_func(struct work_struct *work)
446448
dev_priv->display.hotplug.retry_bits |= retry;
447449
spin_unlock_irq(&dev_priv->irq_lock);
448450

449-
mod_delayed_work(system_wq, &dev_priv->display.hotplug.hotplug_work,
451+
mod_delayed_work(dev_priv->unordered_wq,
452+
&dev_priv->display.hotplug.hotplug_work,
450453
msecs_to_jiffies(HPD_RETRY_DELAY));
451454
}
452455
}
@@ -577,7 +580,8 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
577580
if (queue_dig)
578581
queue_work(dev_priv->display.hotplug.dp_wq, &dev_priv->display.hotplug.dig_port_work);
579582
if (queue_hp)
580-
queue_delayed_work(system_wq, &dev_priv->display.hotplug.hotplug_work, 0);
583+
queue_delayed_work(dev_priv->unordered_wq,
584+
&dev_priv->display.hotplug.hotplug_work, 0);
581585
}
582586

583587
/**
@@ -687,7 +691,8 @@ void intel_hpd_poll_enable(struct drm_i915_private *dev_priv)
687691
* As well, there's no issue if we race here since we always reschedule
688692
* this worker anyway
689693
*/
690-
schedule_work(&dev_priv->display.hotplug.poll_init_work);
694+
queue_work(dev_priv->unordered_wq,
695+
&dev_priv->display.hotplug.poll_init_work);
691696
}
692697

693698
/**
@@ -715,7 +720,8 @@ void intel_hpd_poll_disable(struct drm_i915_private *dev_priv)
715720
return;
716721

717722
WRITE_ONCE(dev_priv->display.hotplug.poll_enabled, false);
718-
schedule_work(&dev_priv->display.hotplug.poll_init_work);
723+
queue_work(dev_priv->unordered_wq,
724+
&dev_priv->display.hotplug.poll_init_work);
719725
}
720726

721727
void intel_hpd_init_early(struct drm_i915_private *i915)

0 commit comments

Comments
 (0)