drm/i915: make CRTC enable/disable asynchronous v2
Subsystems (2)
PATCH 1/2 drm/i915: make CRTC enable/disable asynchronous v2
This lets us return to userspace more quickly and should improve init and suspend/resume times as well, allowing us to return to userspace sooner.
This was initially motivated by slow resume time on some machines with very long panel power sequencing times, and it should also improve boot time when a full mode set is required.
v2: use a single enable/disable queue (Jesse/Chris)
fixup locking, test with lockdep (Jesse)
move hw state checks to sync_crtcs (Jesse)
make userspace initiated mode sets stay synchronous (Chris)
--- drivers/gpu/drm/i915/i915_drv.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 12 ++- drivers/gpu/drm/i915/intel_display.c | 170 +++++++++++++++++++++++++++++++---- drivers/gpu/drm/i915/intel_drv.h | 2 +- 4 files changed, 165 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -1
@@ -530,7 +530,7 @@ static int i915_drm_freeze(struct drm_device *dev)mutex_lock (&dev->mode_config.mutex);for_each_crtc (dev, crtc) {mutex_lock (&crtc->mutex); - dev_priv->display.crtc_disable (crtc); + dev_priv->display._crtc_disable (crtc);mutex_unlock (&crtc->mutex); }mutex_unlock (&dev->mode_config.mutex);
drivers/gpu/drm/i915/i915_drv.h +10 -2
@@ -447,8 +447,8 @@ struct drm_i915_display_funcs {int (*crtc_mode_set)(struct drm_crtc *crtc,int x,int y,struct drm_framebuffer *old_fb); -void (*crtc_enable)(struct drm_crtc *crtc); -void (*crtc_disable)(struct drm_crtc *crtc); +void (*_crtc_enable)(struct drm_crtc *crtc); +void (*_crtc_disable)(struct drm_crtc *crtc);void (*off)(struct drm_crtc *crtc); void (*write_eld)(struct drm_connector *connector, struct drm_crtc *crtc,
@@ -1432,6 +1432,14 @@ struct drm_i915_private {/* Display functions */ struct drm_i915_display_funcs display; +/** +* CRTC work queue handling. Enable/disable calls are queued +* into the list and processed by the CRTC work function at some +* later time, or inline by a call to intel_sync_crtcs(). +*/ +struct list_head crtc_work_queue; +struct work_struct crtc_work; +/* PCH chipset type */ enum intel_pch pch_type;unsigned short pch_id;
drivers/gpu/drm/i915/intel_display.c +153 -17
273 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -1
@@ -804,7 +804,7 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode, struct intel_crtc_config *pipe_config);int intel_format_to_fourcc (int format);void intel_crtc_wait_for_pending_flips (struct drm_crtc *crtc); - +void intel_queue_crtc_disable (struct drm_crtc *crtc);/* intel_dp.c */ void intel_dp_init (struct drm_device *dev,int output_reg,enum port port);
Signature · 1 line
1.9.1
PATCH 2/2 drm/i915: make userspace mode sets asynchronous
Now that we can queue CRTC enable/disable calls for later, we can allow userspace mode sets to return immediately. This may mean that userspace will draw into a buffer that's not yet displayed (which is fine) or that it may draw into a buffer it thinks is no longer displayed (which could lead to some visual artifacts until the mode set completes, but is otherwise harmless). Page flip and cursor activity will synchronize with any outstanding activity to avoid problems with the display being off for those operations.
It should be possible to queue those ops as well though and further de-couple driver updates of the hw state from userspace queueing of commands.
--- drivers/gpu/drm/i915/intel_display.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -4
@@ -10545,10 +10545,6 @@ static int intel_set_mode(struct drm_crtc *crtc, ret =__intel_set_mode (crtc, mode, x, y, fb); -intel_sync_crtcs (crtc->dev->dev_private); -if (ret ==0 ) -intel_modeset_check_state (crtc->dev); -return ret; }
Signature · 1 line
1.9.1
drivers/gpu/drm/i915/i915_drv.c static int i915_drm_freeze(struct drm_device *dev) · line 533
Quoted 10 lines · Jesse Barnes
drivers/gpu/drm/i915/i915_drv.c +1
-1@@ -530,7 +530,7 @@ static int i915_drm_freeze(struct drm_device *dev)mutex_lock (&dev->mode_config.mutex);for_each_crtc (dev, crtc) {mutex_lock (&crtc->mutex); - dev_priv->display.crtc_disable (crtc); + dev_priv->display._crtc_disable (crtc);
Don't you want to cancel the pending work here or it will be run on resume - but on resume, we just want to send the hotplug event and let userspace set itself up in the new configuration.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 15 lines · On Fri, 30 May 2014 19:47:56 +0100 Chris Wilson <[email protected]>…
drivers/gpu/drm/i915/i915_drv.c static int i915_drm_freeze(struct drm_device *dev) · line 533
Quoted 10 lines · Jesse Barnes
drivers/gpu/drm/i915/i915_drv.c +1
-1@@ -530,7 +530,7 @@ static int i915_drm_freeze(struct drm_device *dev)mutex_lock (&dev->mode_config.mutex);for_each_crtc (dev, crtc) {mutex_lock (&crtc->mutex); - dev_priv->display.crtc_disable (crtc); + dev_priv->display._crtc_disable (crtc);Don't you want to cancel the pending work here or it will be run on resume - but on resume, we just want to send the hotplug event and let userspace set itself up in the new configuration.
No you're right I need to cancel it here and in unload, thanks.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) · line 8303
Quoted 9 lines · Jesse Barnes
drivers/gpu/drm/i915/intel_display.c +2
-0@@ -8166,6 +8296,8 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) intel_crtc->cursor_x =clamp_t (int, x,SHRT_MIN ,SHRT_MAX ); intel_crtc->cursor_y =clamp_t (int, y,SHRT_MIN ,SHRT_MAX ); +intel_sync_crtcs (crtc->dev->dev_private); +if (intel_crtc->active)intel_crtc_update_cursor (crtc, intel_crtc->cursor_bo !=NULL );
Since the pending CRTC enable/disable will set the cursor anyway, this sync could be avoided if intel_crtc->active was accurate. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 9 lines · Jesse Barnes
drivers/gpu/drm/i915/intel_display.c +9
-0+static void intel_queue_crtc_enable (struct drm_crtc *crtc) +{ +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +struct intel_crtc_work *work; + +WARN (!mutex_is_locked (&dev->mode_config.mutex), +"need mode_config mutex\n" );
drivers/gpu/drm/i915/intel_display.c static void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv) · line 2099
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10
-0+ + work =kmalloc (sizeof (*work),GFP_KERNEL ); +if (!work) { + dev_priv->display._crtc_disable (&intel_crtc->base); +return ; + } + + work->enable = true; + work->intel_crtc = intel_crtc; +INIT_LIST_HEAD (&work->head);
(redundant, list_add doesn't care)
drivers/gpu/drm/i915/intel_display.c static void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv) · line 2072
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4
-0+ +list_add_tail (&dev_priv->crtc_work_queue, &work->head); +schedule_work (&dev_priv->crtc_work); +}
If we tracked one queued item per crtc, we could avoid the allocation and allow for elision of pending operations.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 13 lines · On Fri, 30 May 2014 19:56:22 +0100 Chris Wilson <[email protected]>…
Quoted 12 lines · Jesse Barnes
drivers/gpu/drm/i915/intel_display.c +12
-0+static void intel_queue_crtc_enable (struct drm_crtc *crtc) +{ +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +struct intel_crtc_work *work; + +WARN (!mutex_is_locked (&dev->mode_config.mutex), +"need mode_config mutex\n" ); + + work =kmalloc (sizeof (*work),GFP_KERNEL ); +if (!work) {
Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c static void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv) · line 2099
Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +7
-0+ dev_priv->display._crtc_disable (&intel_crtc->base); +return ; + } + + work->enable = true; + work->intel_crtc = intel_crtc; +INIT_LIST_HEAD (&work->head);(redundant,
list_adddoesn't care)
Will fix.
Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c static void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv) · line 2072
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4
-0+ +list_add_tail (&dev_priv->crtc_work_queue, &work->head); +schedule_work (&dev_priv->crtc_work); +}If we tracked one queued item per crtc, we could avoid the allocation and allow for elision of pending operations.
Yeah I thought about that too, might make for a good optimization, but I figured this was simplest to start with.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
PATCH 1/1 drm/i915: make CRTC enable/disable asynchronous v3
In reply to Jesse BarnesThis lets us return to userspace more quickly and should improve init and suspend/resume times as well, allowing us to return to userspace sooner.
This was initially motivated by slow resume time on some machines with very long panel power sequencing times, and it should also improve boot time when a full mode set is required.
v2: use a single enable/disable queue (Jesse/Chris)
fixup locking, test with lockdep (Jesse)
move hw state checks to sync_crtcs (Jesse)
make userspace initiated mode sets stay synchronous (Chris)
v3: take crtc lock around enable/disable (Jesse)
cancel work on suspend & unload (Chris)
complete work if alloc fails (Jesse)
drop unneeded list head init (Chris)
drop unneeded sync in cusor movement, rely on intel_crtc->active (Chris) take mode_config mutex around cursor_set sync call (Jesse) fix order of list_add_tail parameters (Jesse)
fix order of list add
take mutex around sync in cursor_set
--- drivers/gpu/drm/i915/i915_drv.c | 3 +- drivers/gpu/drm/i915/i915_drv.h | 12 ++- drivers/gpu/drm/i915/intel_display.c | 177 +++++++++++++++++++++++++++++++---- drivers/gpu/drm/i915/intel_drv.h | 2 +- 4 files changed, 173 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +2 -1
@@ -527,10 +527,11 @@ static int i915_drm_freeze(struct drm_device *dev)* Disable CRTCs directly since we want to preserve sw state * for _thaw. */ +cancel_work_sync (&dev_priv->crtc_work);mutex_lock (&dev->mode_config.mutex);for_each_crtc (dev, crtc) {mutex_lock (&crtc->mutex); - dev_priv->display.crtc_disable (crtc); + dev_priv->display._crtc_disable (crtc);mutex_unlock (&crtc->mutex); }mutex_unlock (&dev->mode_config.mutex);
drivers/gpu/drm/i915/i915_drv.h +10 -2
@@ -447,8 +447,8 @@ struct drm_i915_display_funcs {int (*crtc_mode_set)(struct drm_crtc *crtc,int x,int y,struct drm_framebuffer *old_fb); -void (*crtc_enable)(struct drm_crtc *crtc); -void (*crtc_disable)(struct drm_crtc *crtc); +void (*_crtc_enable)(struct drm_crtc *crtc); +void (*_crtc_disable)(struct drm_crtc *crtc);void (*off)(struct drm_crtc *crtc); void (*write_eld)(struct drm_connector *connector, struct drm_crtc *crtc,
@@ -1432,6 +1432,14 @@ struct drm_i915_private {/* Display functions */ struct drm_i915_display_funcs display; +/** +* CRTC work queue handling. Enable/disable calls are queued +* into the list and processed by the CRTC work function at some +* later time, or inline by a call to intel_sync_crtcs(). +*/ +struct list_head crtc_work_queue; +struct work_struct crtc_work; +/* PCH chipset type */ enum intel_pch pch_type;unsigned short pch_id;
drivers/gpu/drm/i915/intel_display.c +160 -17
280 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -1
@@ -804,7 +804,7 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode, struct intel_crtc_config *pipe_config);int intel_format_to_fourcc (int format);void intel_crtc_wait_for_pending_flips (struct drm_crtc *crtc); - +void intel_queue_crtc_disable (struct drm_crtc *crtc);/* intel_dp.c */ void intel_dp_init (struct drm_device *dev,int output_reg,enum port port);
Signature · 1 line
1.9.1
Re: [PATCH] drm/i915: make CRTC enable/disable asynchronous v3
drivers/gpu/drm/i915/intel_display.c static int __intel_set_mode(struct drm_crtc *crtc, · line 10470
Quoted 7 lines · Jesse Barnes
drivers/gpu/drm/i915/intel_display.c +1
-1@@ -10326,7 +10466,7 @@ static int __intel_set_mode(struct drm_crtc *crtc,for_each_intel_crtc_masked (dev, prepare_pipes, intel_crtc) {if (intel_crtc->base.enabled) - dev_priv->display.crtc_disable (&intel_crtc->base); +intel_queue_crtc_disable (&intel_crtc->base); }
This one looks odd. prepare_pipes are the pipes we have to turn off in order to perform the modeset - which needs to be synchronous.
intel_sync_crtcs(prepare_pipes) ?
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH] drm/i915: make CRTC enable/disable asynchronous v3
Quoted 12 lines · On Fri, 30 May 2014 23:02:18 +0100 Chris Wilson <[email protected]>…
drivers/gpu/drm/i915/intel_display.c static int __intel_set_mode(struct drm_crtc *crtc, · line 10470
Quoted 7 lines · Jesse Barnes
drivers/gpu/drm/i915/intel_display.c +1
-1@@ -10326,7 +10466,7 @@ static int __intel_set_mode(struct drm_crtc *crtc,for_each_intel_crtc_masked (dev, prepare_pipes, intel_crtc) {if (intel_crtc->base.enabled) - dev_priv->display.crtc_disable (&intel_crtc->base); +intel_queue_crtc_disable (&intel_crtc->base); }This one looks odd.
prepare_pipesare the pipes we have to turn off in order to perform the modeset - which needs to be synchronous.
Quoted 1 line
intel_sync_crtcs(prepare_pipes)?
Well, they'll happen in order. But I was just looking at this code and in cases where ->mode_set messes with regs rather than staging it for ->crtc_enable we'll lose stuff here.
Until we have that, doing the disables for the prepare_pipe synchronously is probably the right thing to do.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center