drm/i915: Set primary plane enable at dpcntrl.
Subsystems (2)
PATCH 1/4 drm/i915: Set primary plane enable at dpcntrl.
This patch allows system to safely recover after kms_psr_sink_crc check or any other similar case that might fail when PSR is enabled.
Ville made and sent me this patch after noticing that primary plane enabled bit was set during test case and unset after failure. What was causing a hard and non-recoverable blank screen.
After the failure when alternating from fbcon to x section it was possible to see and move mouse cursor, but nothing else. Everything else was fully black. A for dpms off/on also haleped to get screen back. But this patch seeting primary plane enabled bit propertly seemed more clean.
--- drivers/gpu/drm/i915/intel_display.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/i915/intel_display.c +10 -0
@@ -2095,6 +2095,9 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,if (IS_G4X (dev)) dspcntr |=DISPPLANE_TRICKLE_FEED_DISABLE ; +if (intel_crtc->primary_enabled) + dspcntr |=DISPLAY_PLANE_ENABLE ; +I915_WRITE (reg, dspcntr); linear_offset = y * fb->pitches[0 ] + x * (fb->bits_per_pixel /8 );
@@ -2192,6 +2195,9 @@ static int ironlake_update_plane(struct drm_crtc *crtc,else dspcntr |=DISPPLANE_TRICKLE_FEED_DISABLE ; +if (intel_crtc->primary_enabled) + dspcntr |=DISPLAY_PLANE_ENABLE ; +I915_WRITE (reg, dspcntr); linear_offset = y * fb->pitches[0 ] + x * (fb->bits_per_pixel /8 );
@@ -8586,6 +8592,10 @@ static int intel_gen7_queue_flip(struct drm_device *dev,intel_ring_emit (ring,i915_gem_obj_ggtt_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring, (MI_NOOP )); +if (IS_VALLEYVIEW (dev) && intel_crtc->primary_enabled) +I915_WRITE (DSPCNTR (intel_crtc->plane), +I915_READ (DSPCNTR (intel_crtc->plane)) |DISPLAY_PLANE_ENABLE ); +intel_mark_page_flip_active (intel_crtc);__intel_ring_advance (ring);return 0 ;
Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 drm/i915: move psr_setup_done to psr struct
v2: Avoid more than one setup. Removing initialization
and trusting allocation. (By Paulo Zanoni).
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_dp.c | 6 ++---- drivers/gpu/drm/i915/intel_drv.h | 1 - 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -744,6 +744,7 @@ struct i915_fbc {struct i915_psr {bool sink_support;bool source_ok; +bool setup_done; };enum intel_pch {
drivers/gpu/drm/i915/intel_dp.c +2 -4
@@ -1568,7 +1568,7 @@ static void intel_edp_psr_setup(struct intel_dp *intel_dp)struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; -if (intel_dp->psr_setup_done) +if (dev_priv->psr.setup_done)return ;/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */
@@ -1583,7 +1583,7 @@ static void intel_edp_psr_setup(struct intel_dp *intel_dp)I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP |EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); - intel_dp->psr_setup_done = true; + dev_priv->psr.setup_done = true; }static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp)
@@ -3733,8 +3733,6 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,WARN (error,"intel_dp_i2c_init failed with error %d for port %c\n" , error,port_name (port)); - intel_dp->psr_setup_done = false; -if (!intel_edp_init_connector (intel_dp, intel_connector)) {i2c_del_adapter (&intel_dp->adapter);if (is_edp (intel_dp)) {
drivers/gpu/drm/i915/intel_drv.h +0 -1
@@ -487,7 +487,6 @@ struct intel_dp {int backlight_off_delay;struct delayed_work panel_vdd_work;bool want_panel_vdd; -bool psr_setup_done;struct intel_connector *attached_connector; };
Signature · 1 line
1.8.1.2
Re: [PATCH 2/4] drm/i915: move psr_setup_done to psr struct
Quoted 2 lines · Rodrigo Vivi
v2: Avoid more than one setup. Removing initialization
and trusting allocation. (By Paulo Zanoni).
And what about doing PSR w/ two eDP panels on VLV? The hardware should support it.
Quoted 71 lines
Cc Paulo Zanoni <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_dp.c | 6 ++---- drivers/gpu/drm/i915/intel_drv.h | 1 - 3 files changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -744,6 +744,7 @@ struct i915_fbc {struct i915_psr {bool sink_support;bool source_ok; +bool setup_done; };enum intel_pch {drivers/gpu/drm/i915/intel_dp.c +2
-4@@ -1568,7 +1568,7 @@ static void intel_edp_psr_setup(struct intel_dp *intel_dp)struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; -if (intel_dp->psr_setup_done) +if (dev_priv->psr.setup_done)return ;/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ @@ -1583,7 +1583,7 @@ static void intel_edp_psr_setup(struct intel_dp *intel_dp)I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP |EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); - intel_dp->psr_setup_done = true; + dev_priv->psr.setup_done = true; }static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp)@@ -3733,8 +3733,6 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,WARN (error,"intel_dp_i2c_init failed with error %d for port %c\n" , error,port_name (port)); - intel_dp->psr_setup_done = false; -if (!intel_edp_init_connector (intel_dp, intel_connector)) {i2c_del_adapter (&intel_dp->adapter);if (is_edp (intel_dp)) {drivers/gpu/drm/i915/intel_drv.h +0
-1@@ -487,7 +487,6 @@ struct intel_dp {int backlight_off_delay;struct delayed_work panel_vdd_work;bool want_panel_vdd; -bool psr_setup_done;struct intel_connector *attached_connector; };Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 2/4] drm/i915: move psr_setup_done to psr struct
Quoted 6 lines · Ville Syrjälä
Quoted 2 lines · Rodrigo Vivi
v2: Avoid more than one setup. Removing initialization
and trusting allocation. (By Paulo Zanoni).And what about doing PSR w/ two eDP panels on VLV? The hardware should support it.
I'm afraid my comment here wasn't clear, sorry.
What I meant was to avoid restart setup_done status.... setup_done should be called only once but this initializatio was in a place been called more than once.
Nothing to do with more than one panel here.
Quoted 76 lines
Quoted 68 lines
Cc Paulo Zanoni <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_dp.c | 6 ++---- drivers/gpu/drm/i915/intel_drv.h | 1 - 3 files changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -744,6 +744,7 @@ struct i915_fbc {struct i915_psr {bool sink_support;bool source_ok; +bool setup_done; };enum intel_pch {drivers/gpu/drm/i915/intel_dp.c +2
-4@@ -1568,7 +1568,7 @@ static void intel_edp_psr_setup(struct intel_dp *intel_dp)struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; -if (intel_dp->psr_setup_done) +if (dev_priv->psr.setup_done)return ;/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ @@ -1583,7 +1583,7 @@ static void intel_edp_psr_setup(struct intel_dp *intel_dp)I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP |EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); - intel_dp->psr_setup_done = true; + dev_priv->psr.setup_done = true; }static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp)@@ -3733,8 +3733,6 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,WARN (error,"intel_dp_i2c_init failed with error %d for port %c\n" , error,port_name (port)); - intel_dp->psr_setup_done = false; -if (!intel_edp_init_connector (intel_dp, intel_connector)) {i2c_del_adapter (&intel_dp->adapter);if (is_edp (intel_dp)) {drivers/gpu/drm/i915/intel_drv.h +0
-2@@ -487,7 +487,6 @@ struct intel_dp {int backlight_off_delay;struct delayed_work panel_vdd_work;bool want_panel_vdd; -bool psr_setup_done;struct intel_connector *attached_connector; }; --1.8.1.2
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Ville Syrjälä
Intel OTC
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
PATCH 3/4 drm/i915: Update PSR on resume.
In reply to Rodrigo Vivi--- drivers/gpu/drm/i915/i915_suspend.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/i915_suspend.c +3 -0
@@ -298,6 +298,9 @@ static void i915_restore_display(struct drm_device *dev)I915_WRITE (PP_CONTROL , dev_priv->regfile.savePP_CONTROL); } + dev_priv->psr.setup_done = false; +intel_edp_psr_update (dev); +/* only restore FBC info on the platform that supports FBC*/ intel_disable_fbc (dev);if (HAS_FBC (dev)) {
Signature · 1 line
1.8.1.2
PATCH 1/2 drm/i915: Update PSR on resume.
Since now on update is also been called out of set_base let's use a mutex to protec psr state changes.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_suspend.c | 4 ++++ drivers/gpu/drm/i915/intel_dp.c | 17 ++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +struct mutex lock; };enum intel_pch {
drivers/gpu/drm/i915/i915_suspend.c +4 -0
@@ -288,6 +288,10 @@ static void i915_restore_display(struct drm_device *dev)I915_WRITE (PP_CONTROL , dev_priv->regfile.savePP_CONTROL); } +/* Force a full PSR setup on resume */ + dev_priv->psr.setup_done = false; +intel_edp_psr_update (dev); +/* only restore FBC info on the platform that supports FBC*/ intel_disable_fbc (dev);
drivers/gpu/drm/i915/intel_dp.c +14 -3
@@ -1633,6 +1633,8 @@ static void intel_edp_psr_setup(struct intel_dp *intel_dp)if (dev_priv->psr.setup_done)return ; +mutex_init (&dev_priv->psr.lock); +/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ memset (&psr_vsc,0 ,sizeof (psr_vsc)); psr_vsc.sdp_header.HB0 =0 ;
@@ -1777,9 +1779,6 @@ static void intel_edp_psr_do_enable(struct intel_dp *intel_dp) intel_edp_is_psr_enabled(dev))return ; -/* Setup PSR once */ -intel_edp_psr_setup (intel_dp); -/* Enable PSR on the panel */ intel_edp_psr_enable_sink (intel_dp);
@@ -1790,10 +1789,16 @@ static void intel_edp_psr_do_enable(struct intel_dp *intel_dp)void intel_edp_psr_enable (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct drm_i915_private *dev_priv = dev->dev_private; +/* Setup PSR once */ +intel_edp_psr_setup (intel_dp); + +mutex_lock (&dev_priv->psr.lock);if (intel_edp_psr_match_conditions (intel_dp) && !intel_edp_is_psr_enabled (dev))intel_edp_psr_do_enable (intel_dp); +mutex_unlock (&dev_priv->psr.lock); }void intel_edp_psr_disable (struct intel_dp *intel_dp)
@@ -1815,9 +1820,13 @@ void intel_edp_psr_disable(struct intel_dp *intel_dp)void intel_edp_psr_update (struct drm_device *dev) { +struct drm_i915_private *dev_priv = dev->dev_private;struct intel_encoder *encoder;struct intel_dp *intel_dp =NULL ; +if (!dev_priv->psr.setup_done) +return ; +list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head)if (encoder->type ==INTEL_OUTPUT_EDP ) { intel_dp =enc_to_intel_dp (&encoder->base);
@@ -1825,11 +1834,13 @@ void intel_edp_psr_update(struct drm_device *dev)if (!is_edp_psr (dev))return ; +mutex_lock (&dev_priv->psr.lock);if (!intel_edp_psr_match_conditions (intel_dp))intel_edp_psr_disable (intel_dp);else if (!intel_edp_is_psr_enabled (dev))intel_edp_psr_do_enable (intel_dp); +mutex_unlock (&dev_priv->psr.lock); } }
Signature · 1 line
1.8.1.2
PATCH 4/4 drm/i915: Add Baytrail PSR Support.
In reply to Rodrigo ViviThis patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {busy_ioctl, set_domain, sw_finish and mark_busy and update to enable it back on next display mark_idle.
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR on mark_busy, dset_domain and sw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
--- drivers/gpu/drm/i915/i915_debugfs.c | 18 +++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 9 ++ drivers/gpu/drm/i915/i915_reg.h | 34 ++++++++ drivers/gpu/drm/i915/intel_ddi.c | 3 +- drivers/gpu/drm/i915/intel_display.c | 14 ++++ drivers/gpu/drm/i915/intel_dp.c | 154 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 8 files changed, 206 insertions(+), 31 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +14 -4
@@ -1902,6 +1902,7 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 psrstatus;bool enabled = false;intel_runtime_pm_get (dev_priv);
@@ -1909,14 +1910,23 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + psrstatus =I915_READ (VLV_EDP_PSR_STATUS_CTL ) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((psrstatus ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (psrstatus ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + }seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); -if (HAS_PSR (dev)) +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -745,6 +745,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {
@@ -1871,7 +1872,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))
drivers/gpu/drm/i915/i915_gem.c +9 -0
@@ -1256,6 +1256,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped.
@@ -1299,6 +1302,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
@@ -4047,6 +4053,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
drivers/gpu/drm/i915/i915_reg.h +34 -0
@@ -1969,6 +1969,40 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define VLV_EDP_PSR_CTL (VLV_DISPLAY_BASE + 0x60090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) + +#define VLV_PIPEA_VSC_SDP_REG (VLV_DISPLAY_BASE + 0x600a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) + +#define VLV_EDP_PSR_STATUS_CTL (VLV_DISPLAY_BASE + 0x60094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) + +#define VLV_PSR_CLK_GATE_DISABLE (VLV_DISPLAY_BASE + 0x6204) +#define VLV_CLK_DISABLE_PIPE_B (1<<30) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
@@ -1281,7 +1281,8 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder)intel_dp_stop_link_train (intel_dp);ironlake_edp_backlight_on (intel_dp); -intel_edp_psr_enable (intel_dp); +if (!IS_VALLEYVIEW (dev)) +intel_edp_psr_enable (intel_dp); }if (intel_crtc->eld_vld && type !=INTEL_OUTPUT_EDP ) {
drivers/gpu/drm/i915/intel_display.c +14 -0
@@ -7474,6 +7474,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;
@@ -8175,6 +8178,9 @@ void intel_mark_idle(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct drm_crtc *crtc; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); +hsw_package_c8_gpu_idle (dev_priv);if (!i915_powersave)
@@ -8191,12 +8197,16 @@ void intel_mark_idle(struct drm_device *dev)gen6_rps_idle (dev->dev_private); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (!i915_powersave)return ;
@@ -8646,6 +8656,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;
drivers/gpu/drm/i915/intel_dp.c +129 -25
233 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -735,6 +735,7 @@ void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);/* intel_dsi.c */
Signature · 1 line
1.8.1.2
PATCH 1/1 drm/i915: Add Baytrail PSR Support.
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {busy_ioctl, set_domain, sw_finish and mark_busy and update to enable it back on next display mark_idle.
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR on mark_busy, dset_domain and sw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
--- drivers/gpu/drm/i915/i915_debugfs.c | 18 +++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 9 ++ drivers/gpu/drm/i915/i915_reg.h | 34 ++++++++ drivers/gpu/drm/i915/intel_ddi.c | 3 +- drivers/gpu/drm/i915/intel_display.c | 14 ++++ drivers/gpu/drm/i915/intel_dp.c | 154 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 8 files changed, 206 insertions(+), 31 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +14 -4
@@ -1902,6 +1902,7 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 psrstatus;bool enabled = false;intel_runtime_pm_get (dev_priv);
@@ -1909,14 +1910,23 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + psrstatus =I915_READ (VLV_EDP_PSR_STATUS_CTL ) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((psrstatus ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (psrstatus ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + }seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); -if (HAS_PSR (dev)) +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -745,6 +745,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {
@@ -1871,7 +1872,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))
drivers/gpu/drm/i915/i915_gem.c +9 -0
@@ -1256,6 +1256,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped.
@@ -1299,6 +1302,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
@@ -4047,6 +4053,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
drivers/gpu/drm/i915/i915_reg.h +34 -0
@@ -1969,6 +1969,40 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define VLV_EDP_PSR_CTL (VLV_DISPLAY_BASE + 0x60090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) + +#define VLV_PIPEA_VSC_SDP_REG (VLV_DISPLAY_BASE + 0x600a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) + +#define VLV_EDP_PSR_STATUS_CTL (VLV_DISPLAY_BASE + 0x60094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) + +#define VLV_PSR_CLK_GATE_DISABLE (VLV_DISPLAY_BASE + 0x6204) +#define VLV_CLK_DISABLE_PIPE_B (1<<30) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
@@ -1281,7 +1281,8 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder)intel_dp_stop_link_train (intel_dp);ironlake_edp_backlight_on (intel_dp); -intel_edp_psr_enable (intel_dp); +if (!IS_VALLEYVIEW (dev)) +intel_edp_psr_enable (intel_dp); }if (intel_crtc->eld_vld && type !=INTEL_OUTPUT_EDP ) {
drivers/gpu/drm/i915/intel_display.c +14 -0
@@ -7474,6 +7474,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;
@@ -8175,6 +8178,9 @@ void intel_mark_idle(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct drm_crtc *crtc; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); +hsw_package_c8_gpu_idle (dev_priv);if (!i915_powersave)
@@ -8191,12 +8197,16 @@ void intel_mark_idle(struct drm_device *dev)gen6_rps_idle (dev->dev_private); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (!i915_powersave)return ;
@@ -8647,6 +8657,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;
drivers/gpu/drm/i915/intel_dp.c +129 -25
233 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -735,6 +735,7 @@ void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);/* intel_dsi.c */
Signature · 1 line
1.8.1.2
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
On Thu, Jan 23, 2014 at 05:19:53PM -0200, Rodrigo Vivi wrote:
<snip>
drivers/gpu/drm/i915/i915_reg.h line 1973
Quoted 9 lines
index 76126e0..f5501ab 100644
drivers/gpu/drm/i915/i915_reg.h +2
-0@@ -1969,6 +1969,40 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define VLV_EDP_PSR_CTL (VLV_DISPLAY_BASE + 0x60090)
VLV has per-pipe PSR registers. The ones you have here are just for pipe A. Seems like some rework is needed to make it work on either pipe.
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 9 lines · Ville Syrjälä
On Thu, Jan 23, 2014 at 05:19:53PM -0200, Rodrigo Vivi wrote:
<snip>Quoted 7 lines
index 76126e0..f5501ab 100644
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -1969,6 +1969,40 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B)
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h line 1973
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+/* VLV eDP PSR registers */ +#define VLV_EDP_PSR_CTL (VLV_DISPLAY_BASE + 0x60090)VLV has per-pipe PSR registers. The ones you have here are just for pipe A. Seems like some rework is needed to make it work on either pipe.
Yes, but since I don't have any hw with two eDPs here I decided to let the limitation we had for HSW, PSR only on pipe A.
In my point of view we could go ahead with this one eDP scenario and implement psr on pipe b support later.
Quoted 5 lines
--
Ville Syrjälä
Intel OTC
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 18 lines · Rodrigo Vivi
Quoted 9 lines · Ville Syrjälä
On Thu, Jan 23, 2014 at 05:19:53PM -0200, Rodrigo Vivi wrote:
<snip>Quoted 7 lines
index 76126e0..f5501ab 100644
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -1969,6 +1969,40 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B)Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h line 1973
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+/* VLV eDP PSR registers */ +#define VLV_EDP_PSR_CTL (VLV_DISPLAY_BASE + 0x60090)VLV has per-pipe PSR registers. The ones you have here are just for pipe A. Seems like some rework is needed to make it work on either pipe.
Quoted 4 lines
Yes, but since I don't have any hw with two eDPs here I decided to let the limitation we had for HSW, PSR only on pipe A.
In my point of view we could go ahead with this one eDP scenario and implement psr on pipe b support later.
I don't see any pipe checks in the code, so you will happily enable PSR on pipe A even if eDP is being fed by pipe B at the time.
Also even if you enable PSR on pipe A, you set the trunk clock gate disable for pipe B, which seems weird. Setting that bit might actually be the reason the pipe, port and PLL remain enabled during PSR.
Signature · 2 lines
Ville Syrjälä Intel OTC
PATCH 4/4 drm/i915: Add Baytrail PSR Support.
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {busy_ioctl, set_domain, sw_finish and mark_busy and update to enable it back on next display mark_idle.
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR on mark_busy, dset_domain and sw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leaving PIPE_B
support disabled by for now since it isn't working properly yet.
--- drivers/gpu/drm/i915/i915_debugfs.c | 36 +++++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 9 ++ drivers/gpu/drm/i915/i915_reg.h | 40 +++++++ drivers/gpu/drm/i915/intel_display.c | 15 ++- drivers/gpu/drm/i915/intel_dp.c | 208 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 7 files changed, 274 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +31 -5
@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);
@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {
@@ -1866,7 +1867,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))
drivers/gpu/drm/i915/i915_gem.c +9 -0
@@ -1256,6 +1256,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped.
@@ -1299,6 +1302,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
@@ -4059,6 +4065,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
drivers/gpu/drm/i915/i915_reg.h +40 -0
@@ -1968,6 +1968,46 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_EDP_PSR_CTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB) + +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_EDP_VSC_SDP_REG (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_EDP_PSR_STATUS_CTL (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) + +#define VLV_PSR_CLK_GATE_DISABLE (VLV_DISPLAY_BASE + 0x6204) +#define VLV_CLK_DISABLE_PIPE_B (1<<30) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)
drivers/gpu/drm/i915/intel_display.c +13 -2
@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;
@@ -8228,16 +8231,20 @@ void intel_mark_idle(struct drm_device *dev)if (dev_priv->info->gen >=6 )gen6_rps_idle (dev->dev_private); + +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; -if (!i915.powersave) -return ; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {if (!crtc->fb)
@@ -8688,6 +8695,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;
drivers/gpu/drm/i915/intel_dp.c +177 -31
311 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);/* intel_dsi.c */
Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: Add Baytrail PSR Support.
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {busy_ioctl, set_domain, sw_finish and mark_busy and update to enable it back on next display mark_idle.
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR on mark_busy, dset_domain and sw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leaving PIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 9 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++++ drivers/gpu/drm/i915/intel_display.c | 15 ++- drivers/gpu/drm/i915/intel_dp.c | 204 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 7 files changed, 267 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +31 -5
@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);
@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {
@@ -1866,7 +1867,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))
drivers/gpu/drm/i915/i915_gem.c +9 -0
@@ -1256,6 +1256,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped.
@@ -1299,6 +1302,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
@@ -4059,6 +4065,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
drivers/gpu/drm/i915/i915_reg.h +37 -0
@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_EDP_PSR_CTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB) + +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_EDP_VSC_SDP_REG (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_EDP_PSR_STATUS_CTL (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)
drivers/gpu/drm/i915/intel_display.c +13 -2
@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;
@@ -8228,16 +8231,20 @@ void intel_mark_idle(struct drm_device *dev)if (dev_priv->info->gen >=6 )gen6_rps_idle (dev->dev_private); + +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; -if (!i915.powersave) -return ; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {if (!crtc->fb)
@@ -8688,6 +8695,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;
drivers/gpu/drm/i915/intel_dp.c +173 -31
307 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);/* intel_dsi.c */
Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 6 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.
Quoted 8 lines
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
Not set-domain. This is semantically a flush and so should be after the damage is done.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 16 lines · Chris Wilson
Quoted 6 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.Quoted 8 lines
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
Quoted 2 lines
Not set-domain. This is semantically a flush and so should be after the damage is done.
Yep, I semantically I agree, but if we let to inactivate psr after damage is done we will miss screen updates.
This was the safest way to get psr enabled and fully working and passing crc tests.
If you have another place to suggest i'd be glad in do some tests here, but for now this is the more stable place I know about.
Quoted 4 lines
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 20 lines · Rodrigo Vivi
Quoted 16 lines · Chris Wilson
Quoted 6 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.Quoted 8 lines
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.Quoted 2 lines
Not set-domain. This is semantically a flush and so should be after the damage is done.
Quoted 6 lines
Yep, I semantically I agree, but if we let to inactivate psr after damage is done we will miss screen updates.
This was the safest way to get psr enabled and fully working and passing crc tests.
If you have another place to suggest i'd be glad in do some tests here, but for now this is the more stable place I know about.
It's the test that are at fault here for not following the established ABI imo.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 28 lines · Chris Wilson
Quoted 20 lines · Rodrigo Vivi
Quoted 16 lines · Chris Wilson
Quoted 6 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.Quoted 8 lines
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.Quoted 2 lines
Not set-domain. This is semantically a flush and so should be after the damage is done.
Quoted 6 lines
Yep, I semantically I agree, but if we let to inactivate psr after damage is done we will miss screen updates.
This was the safest way to get psr enabled and fully working and passing crc tests.
If you have another place to suggest i'd be glad in do some tests here, but for now this is the more stable place I know about.
Quoted 2 lines
It's the test that are at fault here for not following the established ABI imo.
this makes sense.
do we have this established ABI documented somewhere?
and what is missing on test? is it a busy ioctl in the end?
but anyway, doing this on set_domain we could fix the psr on environments that doesn't follow this abi like KDE.
Quoted 4 lines
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 29 lines · Rodrigo Vivi
Quoted 28 lines · Chris Wilson
Quoted 26 lines · Rodrigo Vivi
Quoted 16 lines · Chris Wilson
Quoted 6 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.Quoted 8 lines
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.Quoted 2 lines
Not set-domain. This is semantically a flush and so should be after the damage is done.
Yep, I semantically I agree, but if we let to inactivate psr after damage is done we will miss screen updates.
This was the safest way to get psr enabled and fully working and passing crc tests.
If you have another place to suggest i'd be glad in do some tests here, but for now this is the more stable place I know about.
Quoted 6 lines
Quoted 2 lines
It's the test that are at fault here for not following the established ABI imo.
this makes sense.
do we have this established ABI documented somewhere?
Only what was established as required to make things work a few years ago...
Quoted 1 line
and what is missing on test? is it a busy ioctl in the end?
busy or even a sw_finish. I see it already did the sw_finish. We have in the past talked about formalizing the gap in the documentation with a new call...
Quoted 2 lines
but anyway, doing this on
set_domainwe could fix the psr on environments that doesn't follow this abi like KDE.
As we have discussed in the past, that is an issue in the ddx that short-circuits the required flush if there was only GTT damage. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
ok, got it.
So, the correct here is to remove inactivate from set_domain and add gem_bo_busy call on MMAP_GTT testcase?
Quoted 55 lines · Chris Wilson
Quoted 29 lines · Rodrigo Vivi
Quoted 28 lines · Chris Wilson
Quoted 26 lines · Rodrigo Vivi
Quoted 16 lines · Chris Wilson
Quoted 6 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.Quoted 8 lines
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.Quoted 2 lines
Not set-domain. This is semantically a flush and so should be after the damage is done.
Yep, I semantically I agree, but if we let to inactivate psr after damage is done we will miss screen updates.
This was the safest way to get psr enabled and fully working and passing crc tests.
If you have another place to suggest i'd be glad in do some tests here, but for now this is the more stable place I know about.Quoted 6 lines
Quoted 2 lines
It's the test that are at fault here for not following the established ABI imo.
this makes sense.
do we have this established ABI documented somewhere?
Only what was established as required to make things work a few years ago...
Quoted 1 line
and what is missing on test? is it a busy ioctl in the end?
busy or even a
sw_finish. I see it already did thesw_finish. We have in the past talked about formalizing the gap in the documentation with a new call...Quoted 2 lines
but anyway, doing this on
set_domainwe could fix the psr on environments that doesn't follow this abi like KDE.As we have discussed in the past, that is an issue in the ddx that short-circuits the required flush if there was only GTT damage. -Chris
--
Chris Wilson, Intel Open Source Technology Centre
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 4 lines · Rodrigo Vivi
ok, got it.
So, the correct here is to remove inactivate from
set_domainand addgem_bo_busycall onMMAP_GTTtestcase?
That would match what we should do today. It's just whether we take the opportunity to define a consistent behaviour...
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 8 lines · Chris Wilson
Quoted 4 lines · Rodrigo Vivi
ok, got it.
So, the correct here is to remove inactivate from
set_domainand addgem_bo_busycall onMMAP_GTTtestcase?That would match what we should do today. It's just whether we take the opportunity to define a consistent behaviour...
Afaik we don't do a gem_bo_busy after gtt access, at least no everwhere. Which sucks, but meh. At least I've thought that the busy is just after gpu rendering.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/1 drm/i915: Add Baytrail PSR Support.
In reply to Chris WilsonThis patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {busy_ioctl, sw_finish and mark_busy} and update to enable it back on next display mark_idle.
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR on mark_busy, dset_domain and sw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leaving PIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
v7: Remove inactivate from set_domain. Chris warned this was semanticaly
wrong.
--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 6 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++++ drivers/gpu/drm/i915/intel_display.c | 15 ++- drivers/gpu/drm/i915/intel_dp.c | 204 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 7 files changed, 264 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +31 -5
@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);
@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {
@@ -1866,7 +1867,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))
drivers/gpu/drm/i915/i915_gem.c +6 -0
@@ -1299,6 +1299,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
@@ -4059,6 +4062,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
drivers/gpu/drm/i915/i915_reg.h +37 -0
@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_EDP_PSR_CTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB) + +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_EDP_VSC_SDP_REG (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_EDP_PSR_STATUS_CTL (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)
drivers/gpu/drm/i915/intel_display.c +13 -2
@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;
@@ -8228,16 +8231,20 @@ void intel_mark_idle(struct drm_device *dev)if (dev_priv->info->gen >=6 )gen6_rps_idle (dev->dev_private); + +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; -if (!i915.powersave) -return ; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {if (!crtc->fb)
@@ -8688,6 +8695,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;
drivers/gpu/drm/i915/intel_dp.c +173 -31
307 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);/* intel_dsi.c */
Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 6 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,sw_finishandmark_busy} and update to enable it back on next displaymark_idle.
Quoted 10 lines
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
v7: Remove inactivate fromset_domain. Chris warned this was semanticaly
wrong.
Like I've said I agree that it's not pretty, but I also think it's the only thing we can do atm. For fbc we have the hardware-based fence tracking, but it sounds like that's busted for psr on byt. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 18 lines · Daniel Vetter
Quoted 6 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,sw_finishandmark_busy} and update to enable it back on next displaymark_idle.Quoted 10 lines
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
v7: Remove inactivate fromset_domain. Chris warned this was semanticaly
wrong.
Quoted 3 lines
Like I've said I agree that it's not pretty, but I also think it's the only thing we can do atm. For fbc we have the hardware-based fence tracking, but it sounds like that's busted for psr on byt.
No, it also does not match current userspace.
X will :
1. take a GTT mapping of the frontbufer
2. call set-to-domain write=GTT
3. write into mmap
4. go to sleep for a second or more
5. goto 3.
Once it has a write=GTT mmapping and it has not been used for anything else, it will not inform the kernel that it needs to change domain again, because as far as it is aware the memory is still in the correct domain and perfectly coherent.
Besides which I keep asking for a PSR property so X can switch to an alternative rendering strategy that should be more power efficient and PSR friendly.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 32 lines · Chris Wilson
Quoted 18 lines · Daniel Vetter
Quoted 6 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,sw_finishandmark_busy} and update to enable it back on next displaymark_idle.Quoted 10 lines
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
v7: Remove inactivate fromset_domain. Chris warned this was semanticaly
wrong.Quoted 3 lines
Like I've said I agree that it's not pretty, but I also think it's the only thing we can do atm. For fbc we have the hardware-based fence tracking, but it sounds like that's busted for psr on byt.
No, it also does not match current userspace.
X will :
1. take a GTT mapping of the frontbufer
2. call set-to-domain write=GTT
3. write into mmap
4. go to sleep for a second or more
5. goto 3.
Quoted 4 lines
Once it has a write=GTT mmapping and it has not been used for anything else, it will not inform the kernel that it needs to change domain again, because as far as it is aware the memory is still in the correct domain and perfectly coherent.
Oops, sounds like we need to have another testcase which does this, both for fbc and psr. It sounds like we'd need to nuke psr completely for this case in set_domain (when gtt writes are enforced) and only re-enable it on the next pageflip. If that's too shitty for some platforms we care about we could have a timer in place to shoot down gtt mmappings and restore psr after one second or something like this. Ofc that means we also need to frob the page fault paths a bit then.
This is getting less pretty by the minute :(
While we discuss rendering models: Can you please double-check the fbc/psr testcase and look for any insane sequence/cornercase (like the above one) that we've missed thus far?
Quoted 3 lines
Besides which I keep asking for a PSR property so X can switch to an alternative rendering strategy that should be more power efficient and PSR friendly.
Agreed on that, but imo we need to first get the legacy crap going without regressions. Once we have that in solid shape we can extend things with all kinds of fancy madness (I'm also thinking of explicit damage flushing and things like this). But we've never had a solid baseline for fbc/psr ever ...
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
In reply to Rodrigo ViviQuoted 131 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.Cc Ville Syrjälä <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 9 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++++ drivers/gpu/drm/i915/intel_display.c | 15 ++- drivers/gpu/drm/i915/intel_dp.c | 204 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 7 files changed, 267 insertions(+), 39 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +31
-5@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;drivers/gpu/drm/i915/i915_drv.h +3
-1@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {@@ -1866,7 +1867,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))drivers/gpu/drm/i915/i915_gem.c +6
-0@@ -1256,6 +1256,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped. @@ -1299,6 +1302,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
drivers/gpu/drm/i915/i915_gem.c i915_gem_busy_ioctl(struct drm_device *dev, void *data, · line 4069
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0@@ -4059,6 +4065,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);
The locking for PSR seems to be as fubar as for FBC. Also the front buffer tracking is missing, but I guess I need to make that work for FBC first, and then we need to figure out how to tie it in w/ PSR.
Quoted 18 lines
drivers/gpu/drm/i915/i915_gem.c +1
-0+ obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;drivers/gpu/drm/i915/i915_reg.h +6
-0@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2)
drivers/gpu/drm/i915/i915_reg.h line 1986
Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +10
-0+#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_EDP_PSR_CTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB)
Can we just name the PSR registers like in the spec? Eg. just VLV_PSRCTL(). Would make it easier to compare things w/ the spec.
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_page_flip(struct drm_crtc *crtc,
Quoted 62 lines
drivers/gpu/drm/i915/i915_reg.h +21
-0+ +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_EDP_VSC_SDP_REG (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_EDP_PSR_STATUS_CTL (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)drivers/gpu/drm/i915/intel_display.c +9
-2@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;@@ -8228,16 +8231,20 @@ void intel_mark_idle(struct drm_device *dev)if (dev_priv->info->gen >=6 )gen6_rps_idle (dev->dev_private); + +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; -if (!i915.powersave) -return ; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {if (!crtc->fb)@@ -8688,6 +8695,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
nav> if (work == NULL)
Quoted 100 lines
drivers/gpu/drm/i915/intel_display.c +4
-0return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;drivers/gpu/drm/i915/intel_dp.c +43
-16@@ -1578,21 +1578,35 @@ static void intel_dp_get_config(struct intel_encoder *encoder, } } -static bool is_edp_psr (struct drm_device *dev) +static bool is_edp_psr (struct intel_dp *intel_dp) +{ +return intel_dp->psr_dpcd[0 ] &DP_PSR_IS_SUPPORTED ; +} + +static bool vlv_edp_is_psr_enabled_on_pipe (struct drm_device *dev,int pipe) {struct drm_i915_private *dev_priv = dev->dev_private; +uint32_t val; -return dev_priv->psr.sink_support; + val =I915_READ (VLV_EDP_PSR_STATUS_CTL (pipe)) & +VLV_EDP_PSR_CURR_STATE_MASK ; +return (val ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (val ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ); }static bool intel_edp_is_psr_enabled (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (!HAS_PSR (dev)) -return false; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) +return vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_A ) || +vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_B ); +else +return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } -return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +return false; } static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,@@ -1626,28 +1640,49 @@ static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,static void intel_edp_psr_setup (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; +uint32_t val;if (dev_priv->psr.setup_done)return ; -/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; -intel_edp_psr_write_vsc (intel_dp, &psr_vsc); +if (IS_VALLEYVIEW (dev)) { + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_A )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_A ), val); + + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_B )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_B ), val); + }else { +/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; +intel_edp_psr_write_vsc (intel_dp, &psr_vsc); -/* Avoid continuous PSR exit by masking memup and hpd */ -I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | -EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); +/* Avoid continuous PSR exit by masking memup and hpd */ +I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | +EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP );
drivers/gpu/drm/i915/intel_dp.c static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp, · line 1683
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +6
-0+ } dev_priv->psr.setup_done = true; } +static void vlv_edp_psr_enable_sink (struct intel_dp *intel_dp) +{ +/* Enable PSR in sink */ +intel_dp_aux_native_write_1 (intel_dp,DP_PSR_EN_CFG , +DP_PSR_ENABLE );
Don't we want the same main-link poweroff logic as HSW? Or maybe we should just keep the main link on always as long as we can't enter the low power states w/ DPLL/pipe/port off.
Did you already figure out why that's not happening? Looking at the PSRSTAT registers, my guess is that D0i1 is where we end up currently, and that doesn't actually turn off anything but the planes (to stop memory fetches). D0i2 would turn off everything.
But I guess we should anyway do this in steps. First getting the current stuff in, then trying to get into D0i2 state, and finally getting the display power well turned off when in PSR.
I think once we get to working on D0i2, we'll need to move the PSR wakeup to happen from a workqueue since it essentially requires a full modeset. Even now in your code it's somewhat questionable since you're doing stuff like aux transfers while holding struct_mutex.
Quoted 11 lines
drivers/gpu/drm/i915/intel_dp.c +4
-0+} +static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1678,6 +1713,28 @@ static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT)); } +static void vlv_edp_psr_enable_source (struct intel_dp *intel_dp) +{
drivers/gpu/drm/i915/intel_dp.c static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) · line 1727
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +10
-0+struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); + +uint32_t idle_frames =1 ; +uint32_t val; + + val =I915_READ (VLV_EDP_PSR_CTL (intel_crtc->pipe));
I don't think we want to preserve anything here. We need to make sure everything is initialized correctly rather than trusting some old junk in the register.
Quoted 96 lines
drivers/gpu/drm/i915/intel_dp.c +49
-11+ val |=VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; + + val |=VLV_EDP_PSR_MODE_HW_TIMER ; + val &= ~VLV_EDP_PSR_FRAME_COUNT_MASK ; + val |= idle_frames <<EDP_PSR_IDLE_FRAME_SHIFT ; + +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), val); +} +static void intel_edp_psr_enable_source (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1719,8 +1776,8 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } -if ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || - (dig_port->port !=PORT_A )) { +if (HAS_DDI (dev) && ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || + (dig_port->port !=PORT_A ))) {DRM_DEBUG_KMS ("HSW ties PSR to DDI A (eDP)\n" );return false; }@@ -1765,37 +1822,83 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } +/* Baytrail supports per-pipe PSR configuration, however PSR on +* PIPE_B isn't working properly. So let's keep it disabled for now. */ +if (IS_VALLEYVIEW (dev) && intel_crtc->pipe !=PIPE_A ) { +DRM_DEBUG_KMS ("PSR on BYT isn't enabled on pipe B.\n" ); +return false; + } + dev_priv->psr.source_ok = true;return true; }static void intel_edp_psr_do_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); -if (!intel_edp_psr_match_conditions (intel_dp) || -intel_edp_is_psr_enabled (dev)) -return ; +if (IS_VALLEYVIEW (dev)) { +if (vlv_edp_is_psr_enabled_on_pipe (dev, intel_crtc->pipe)) +return ; + }else +if (intel_edp_is_psr_enabled (dev)) +return ;/* Setup PSR once */ intel_edp_psr_setup (intel_dp);/* Enable PSR on the panel */ -intel_edp_psr_enable_sink (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_sink (intel_dp); +else +intel_edp_psr_enable_sink (intel_dp);/* Enable PSR on the host */ -intel_edp_psr_enable_source (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_source (intel_dp); +else +intel_edp_psr_enable_source (intel_dp); + + dev_priv->psr.active = true; }void intel_edp_psr_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +if (!is_edp_psr (intel_dp)) +return ; -if (intel_edp_psr_match_conditions (intel_dp) && - !intel_edp_is_psr_enabled (dev)) +if (intel_edp_psr_match_conditions (intel_dp))intel_edp_psr_do_enable (intel_dp); } +void vlv_edp_psr_disable (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_crtc *intel_crtc =
drivers/gpu/drm/i915/intel_dp.c static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp) · line 1893
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +10
-0+to_intel_crtc (intel_dig_port->base.base.crtc); +uint32_t val =I915_READ (VLV_EDP_PSR_STATUS_CTL (intel_crtc->pipe)); + +if (!dev_priv->psr.setup_done) +return ; + +intel_edp_psr_inactivate (dev); + +if (val &VLV_EDP_PSR_IN_TRANS ) +udelay (250 );
Might we want a warning if the bit doesn't go down in expected time?
Quoted 104 lines
drivers/gpu/drm/i915/intel_dp.c +51
-4+ + val =I915_READ (VLV_EDP_PSR_CTL (intel_crtc->pipe)); + val &= ~VLV_EDP_PSR_ACTIVE_ENTRY ; + val &= ~VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), val); +} +void intel_edp_psr_disable (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1817,28 +1920,66 @@ void intel_edp_psr_update(struct drm_device *dev) {struct intel_encoder *encoder;struct intel_dp *intel_dp =NULL ; +struct intel_crtc *intel_crtc;list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head)if (encoder->type ==INTEL_OUTPUT_EDP ) { intel_dp =enc_to_intel_dp (&encoder->base); -if (!is_edp_psr (dev)) +if (!is_edp_psr (intel_dp))return ; -if (!intel_edp_psr_match_conditions (intel_dp)) -intel_edp_psr_disable (intel_dp); -else + intel_crtc =to_intel_crtc (encoder->base.crtc); + +if (!intel_edp_psr_match_conditions (intel_dp)) { +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +else +intel_edp_psr_disable (intel_dp); + }else if (!intel_edp_is_psr_enabled (dev))intel_edp_psr_do_enable (intel_dp); } } +void intel_edp_psr_inactivate (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_encoder *encoder; +struct intel_crtc *intel_crtc; +struct intel_dp *intel_dp =NULL ; + +if (!dev_priv->psr.setup_done || !dev_priv->psr.active) +return ; + +list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head) +if (encoder->type ==INTEL_OUTPUT_EDP ) { + intel_dp =enc_to_intel_dp (&encoder->base); + intel_crtc =to_intel_crtc (encoder->base.crtc); + +if (!vlv_edp_is_psr_enabled_on_pipe (dev, + intel_crtc->pipe)) +continue ; + + dev_priv->psr.active = false; +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), +VLV_EDP_PSR_RESET ); +/* WaClearPSRReset:vlv */ +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe),0 ); + +intel_dp_sink_dpms (intel_dp,DRM_MODE_DPMS_ON ); + } +} +static void intel_disable_dp (struct intel_encoder *encoder) {struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);enum port port =dp_to_dig_port (intel_dp)->port;struct drm_device *dev = encoder->base.dev; +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +/* Make sure the panel is off before trying to change the mode. But also * ensure that we have vdd while we switch off the panel. */ intel_edp_backlight_off (intel_dp);@@ -1895,6 +2036,7 @@ static void vlv_enable_dp(struct intel_encoder *encoder)struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);intel_edp_backlight_on (intel_dp); +intel_edp_psr_enable (intel_dp); }static void g4x_pre_enable_dp (struct intel_encoder *encoder)drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);/* intel_dsi.c */ Signature · 1 line
1.8.1.2
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 135 lines · Ville Syrjälä
Quoted 134 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.Cc Ville Syrjälä <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 9 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++++ drivers/gpu/drm/i915/intel_display.c | 15 ++- drivers/gpu/drm/i915/intel_dp.c | 204 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 7 files changed, 267 insertions(+), 39 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +31
-5@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;drivers/gpu/drm/i915/i915_drv.h +3
-1@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {@@ -1866,7 +1867,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))drivers/gpu/drm/i915/i915_gem.c +6
-0@@ -1256,6 +1256,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped. @@ -1299,6 +1302,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;@@ -4059,6 +4065,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret;
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c i915_gem_busy_ioctl(struct drm_device *dev, void *data, · line 4069
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);The locking for PSR seems to be as fubar as for FBC. Also the front buffer tracking is missing, but I guess I need to make that work for FBC first, and then we need to figure out how to tie it in w/ PSR.
agree... I'll wait your fbc work.
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/i915_gem.c +1
-0+ obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;drivers/gpu/drm/i915/i915_reg.h +11
-0@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9)
Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h line 1986
Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +5
-0+#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_EDP_PSR_CTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB)Can we just name the PSR registers like in the spec? Eg. just
VLV_PSRCTL(). Would make it easier to compare things w/ the spec.
Done.
Quoted 59 lines
Quoted 59 lines
drivers/gpu/drm/i915/i915_reg.h +21
-0+ +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_EDP_VSC_SDP_REG (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_EDP_PSR_STATUS_CTL (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)drivers/gpu/drm/i915/intel_display.c +9
-2@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;@@ -8228,16 +8231,20 @@ void intel_mark_idle(struct drm_device *dev)if (dev_priv->info->gen >=6 )gen6_rps_idle (dev->dev_private); + +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; -if (!i915.powersave) -return ; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_page_flip(struct drm_crtc *crtc,
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +0
-0list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {if (!crtc->fb)@@ -8688,6 +8695,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,nav> if (work == NULL)
sorry, I didn't get this..
what did you mean?
Quoted 105 lines
Quoted 105 lines
drivers/gpu/drm/i915/intel_display.c +4
-0return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;drivers/gpu/drm/i915/intel_dp.c +44
-16@@ -1578,21 +1578,35 @@ static void intel_dp_get_config(struct intel_encoder *encoder, } } -static bool is_edp_psr (struct drm_device *dev) +static bool is_edp_psr (struct intel_dp *intel_dp) +{ +return intel_dp->psr_dpcd[0 ] &DP_PSR_IS_SUPPORTED ; +} + +static bool vlv_edp_is_psr_enabled_on_pipe (struct drm_device *dev,int pipe) {struct drm_i915_private *dev_priv = dev->dev_private; +uint32_t val; -return dev_priv->psr.sink_support; + val =I915_READ (VLV_EDP_PSR_STATUS_CTL (pipe)) & +VLV_EDP_PSR_CURR_STATE_MASK ; +return (val ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (val ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ); }static bool intel_edp_is_psr_enabled (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (!HAS_PSR (dev)) -return false; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) +return vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_A ) || +vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_B ); +else +return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } -return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +return false; } static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,@@ -1626,28 +1640,49 @@ static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,static void intel_edp_psr_setup (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; +uint32_t val;if (dev_priv->psr.setup_done)return ; -/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; -intel_edp_psr_write_vsc (intel_dp, &psr_vsc); +if (IS_VALLEYVIEW (dev)) { + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_A )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_A ), val); + + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_B )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_B ), val); + }else { +/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; +intel_edp_psr_write_vsc (intel_dp, &psr_vsc); -/* Avoid continuous PSR exit by masking memup and hpd */ -I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | -EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); +/* Avoid continuous PSR exit by masking memup and hpd */ +I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | +EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); + } dev_priv->psr.setup_done = true; }
Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp, · line 1683
Quoted 5 lines
drivers/gpu/drm/i915/intel_dp.c +5
-0+static void vlv_edp_psr_enable_sink (struct intel_dp *intel_dp) +{ +/* Enable PSR in sink */ +intel_dp_aux_native_write_1 (intel_dp,DP_PSR_EN_CFG , +DP_PSR_ENABLE );Don't we want the same main-link poweroff logic as HSW?
I can't remember why I'm not disabling main link here... So I did a quickly try now and failure on tests was huge... so let's keep it simple for now ;)
Quoted 8 lines
Or maybe we
should just keep the main link on always as long as we can't enter the low power states w/ DPLL/pipe/port off.Did you already figure out why that's not happening? Looking at the PSRSTAT registers, my guess is that D0i1 is where we end up currently, and that doesn't actually turn off anything but the planes (to stop memory fetches). D0i2 would turn off everything.
no idea.. :(
Quoted 3 lines
But I guess we should anyway do this in steps. First getting the current stuff in, then trying to get into D0i2 state, and finally getting the display power well turned off when in PSR.
Agree.
Quoted 6 lines
I think once we get to working on D0i2, we'll need to move the PSR wakeup to happen from a workqueue since it essentially requires a full modeset. Even now in your code it's somewhat questionable since you're doing stuff like aux transfers while holding
struct_mutex.
uhm... anything we should try now to improve?
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +2
-0+} +static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1678,6 +1713,28 @@ static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT)); }
Quoted 16 lines
drivers/gpu/drm/i915/intel_dp.c static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) · line 1727
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp.c +12
-0+static void vlv_edp_psr_enable_source (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); + +uint32_t idle_frames =1 ; +uint32_t val; + + val =I915_READ (VLV_EDP_PSR_CTL (intel_crtc->pipe));I don't think we want to preserve anything here. We need to make sure everything is initialized correctly rather than trusting some old junk in the register.
Done.
Quoted 101 lines
Quoted 101 lines
drivers/gpu/drm/i915/intel_dp.c +53
-11+ val |=VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; + + val |=VLV_EDP_PSR_MODE_HW_TIMER ; + val &= ~VLV_EDP_PSR_FRAME_COUNT_MASK ; + val |= idle_frames <<EDP_PSR_IDLE_FRAME_SHIFT ; + +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), val); +} +static void intel_edp_psr_enable_source (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1719,8 +1776,8 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } -if ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || - (dig_port->port !=PORT_A )) { +if (HAS_DDI (dev) && ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || + (dig_port->port !=PORT_A ))) {DRM_DEBUG_KMS ("HSW ties PSR to DDI A (eDP)\n" );return false; }@@ -1765,37 +1822,83 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } +/* Baytrail supports per-pipe PSR configuration, however PSR on +* PIPE_B isn't working properly. So let's keep it disabled for now. */ +if (IS_VALLEYVIEW (dev) && intel_crtc->pipe !=PIPE_A ) { +DRM_DEBUG_KMS ("PSR on BYT isn't enabled on pipe B.\n" ); +return false; + } + dev_priv->psr.source_ok = true;return true; }static void intel_edp_psr_do_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); -if (!intel_edp_psr_match_conditions (intel_dp) || -intel_edp_is_psr_enabled (dev)) -return ; +if (IS_VALLEYVIEW (dev)) { +if (vlv_edp_is_psr_enabled_on_pipe (dev, intel_crtc->pipe)) +return ; + }else +if (intel_edp_is_psr_enabled (dev)) +return ;/* Setup PSR once */ intel_edp_psr_setup (intel_dp);/* Enable PSR on the panel */ -intel_edp_psr_enable_sink (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_sink (intel_dp); +else +intel_edp_psr_enable_sink (intel_dp);/* Enable PSR on the host */ -intel_edp_psr_enable_source (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_source (intel_dp); +else +intel_edp_psr_enable_source (intel_dp); + + dev_priv->psr.active = true; }void intel_edp_psr_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +if (!is_edp_psr (intel_dp)) +return ; -if (intel_edp_psr_match_conditions (intel_dp) && - !intel_edp_is_psr_enabled (dev)) +if (intel_edp_psr_match_conditions (intel_dp))intel_edp_psr_do_enable (intel_dp); } +void vlv_edp_psr_disable (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); +uint32_t val =I915_READ (VLV_EDP_PSR_STATUS_CTL (intel_crtc->pipe)); + +if (!dev_priv->psr.setup_done)
Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp) · line 1893
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp.c +6
-0+return ; + +intel_edp_psr_inactivate (dev); + +if (val &VLV_EDP_PSR_IN_TRANS ) +udelay (250 );Might we want a warning if the bit doesn't go down in expected time?
Done.
Quoted 102 lines
Quoted 102 lines
drivers/gpu/drm/i915/intel_dp.c +51
-4+ + val =I915_READ (VLV_EDP_PSR_CTL (intel_crtc->pipe)); + val &= ~VLV_EDP_PSR_ACTIVE_ENTRY ; + val &= ~VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), val); +} +void intel_edp_psr_disable (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1817,28 +1920,66 @@ void intel_edp_psr_update(struct drm_device *dev) {struct intel_encoder *encoder;struct intel_dp *intel_dp =NULL ; +struct intel_crtc *intel_crtc;list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head)if (encoder->type ==INTEL_OUTPUT_EDP ) { intel_dp =enc_to_intel_dp (&encoder->base); -if (!is_edp_psr (dev)) +if (!is_edp_psr (intel_dp))return ; -if (!intel_edp_psr_match_conditions (intel_dp)) -intel_edp_psr_disable (intel_dp); -else + intel_crtc =to_intel_crtc (encoder->base.crtc); + +if (!intel_edp_psr_match_conditions (intel_dp)) { +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +else +intel_edp_psr_disable (intel_dp); + }else if (!intel_edp_is_psr_enabled (dev))intel_edp_psr_do_enable (intel_dp); } } +void intel_edp_psr_inactivate (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_encoder *encoder; +struct intel_crtc *intel_crtc; +struct intel_dp *intel_dp =NULL ; + +if (!dev_priv->psr.setup_done || !dev_priv->psr.active) +return ; + +list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head) +if (encoder->type ==INTEL_OUTPUT_EDP ) { + intel_dp =enc_to_intel_dp (&encoder->base); + intel_crtc =to_intel_crtc (encoder->base.crtc); + +if (!vlv_edp_is_psr_enabled_on_pipe (dev, + intel_crtc->pipe)) +continue ; + + dev_priv->psr.active = false; +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), +VLV_EDP_PSR_RESET ); +/* WaClearPSRReset:vlv */ +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe),0 ); + +intel_dp_sink_dpms (intel_dp,DRM_MODE_DPMS_ON ); + } +} +static void intel_disable_dp (struct intel_encoder *encoder) {struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);enum port port =dp_to_dig_port (intel_dp)->port;struct drm_device *dev = encoder->base.dev; +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +/* Make sure the panel is off before trying to change the mode. But also * ensure that we have vdd while we switch off the panel. */ intel_edp_backlight_off (intel_dp);@@ -1895,6 +2036,7 @@ static void vlv_enable_dp(struct intel_encoder *encoder)struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);intel_edp_backlight_on (intel_dp); +intel_edp_psr_enable (intel_dp); }static void g4x_pre_enable_dp (struct intel_encoder *encoder)drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);
Quoted 7 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_drv.h +0
-1/* intel_dsi.c */ --1.8.1.2
--
Ville Syrjälä
Intel OTC
Thank you very much!
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 241 lines · Rodrigo Vivi
Quoted 135 lines · Ville Syrjälä
Quoted 134 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.Cc Ville Syrjälä <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 9 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++++ drivers/gpu/drm/i915/intel_display.c | 15 ++- drivers/gpu/drm/i915/intel_dp.c | 204 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 7 files changed, 267 insertions(+), 39 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +31
-5@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;drivers/gpu/drm/i915/i915_drv.h +3
-1@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {@@ -1866,7 +1867,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))drivers/gpu/drm/i915/i915_gem.c +6
-0@@ -1256,6 +1256,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped. @@ -1299,6 +1302,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;@@ -4059,6 +4065,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret;Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c i915_gem_busy_ioctl(struct drm_device *dev, void *data, · line 4069
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);The locking for PSR seems to be as fubar as for FBC. Also the front buffer tracking is missing, but I guess I need to make that work for FBC first, and then we need to figure out how to tie it in w/ PSR.
agree... I'll wait your fbc work.
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/i915_gem.c +1
-0+ obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;drivers/gpu/drm/i915/i915_reg.h +11
-0@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9)Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h line 1986
Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +5
-0+#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_EDP_PSR_CTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB)Can we just name the PSR registers like in the spec? Eg. just
VLV_PSRCTL(). Would make it easier to compare things w/ the spec.Done.
Quoted 59 lines
Quoted 59 lines
drivers/gpu/drm/i915/i915_reg.h +21
-0+ +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_EDP_VSC_SDP_REG (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_EDP_PSR_STATUS_CTL (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)drivers/gpu/drm/i915/intel_display.c +9
-2@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;@@ -8228,16 +8231,20 @@ void intel_mark_idle(struct drm_device *dev)if (dev_priv->info->gen >=6 )gen6_rps_idle (dev->dev_private); + +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; -if (!i915.powersave) -return ; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);
Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_page_flip(struct drm_crtc *crtc,
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +0
-0list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {if (!crtc->fb)@@ -8688,6 +8695,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,nav> if (work == NULL)
sorry, I didn't get this..
what did you mean?
Nothing. Just managed to misplace a few characters here I guess. I blame vim :)
Quoted 115 lines
Quoted 106 lines
Quoted 106 lines
drivers/gpu/drm/i915/intel_display.c +4
-0return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;drivers/gpu/drm/i915/intel_dp.c +44
-16@@ -1578,21 +1578,35 @@ static void intel_dp_get_config(struct intel_encoder *encoder, } } -static bool is_edp_psr (struct drm_device *dev) +static bool is_edp_psr (struct intel_dp *intel_dp) +{ +return intel_dp->psr_dpcd[0 ] &DP_PSR_IS_SUPPORTED ; +} + +static bool vlv_edp_is_psr_enabled_on_pipe (struct drm_device *dev,int pipe) {struct drm_i915_private *dev_priv = dev->dev_private; +uint32_t val; -return dev_priv->psr.sink_support; + val =I915_READ (VLV_EDP_PSR_STATUS_CTL (pipe)) & +VLV_EDP_PSR_CURR_STATE_MASK ; +return (val ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (val ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ); }static bool intel_edp_is_psr_enabled (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (!HAS_PSR (dev)) -return false; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) +return vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_A ) || +vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_B ); +else +return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } -return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +return false; } static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,@@ -1626,28 +1640,49 @@ static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,static void intel_edp_psr_setup (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; +uint32_t val;if (dev_priv->psr.setup_done)return ; -/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; -intel_edp_psr_write_vsc (intel_dp, &psr_vsc); +if (IS_VALLEYVIEW (dev)) { + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_A )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_A ), val); + + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_B )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_B ), val); + }else { +/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; +intel_edp_psr_write_vsc (intel_dp, &psr_vsc); -/* Avoid continuous PSR exit by masking memup and hpd */ -I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | -EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); +/* Avoid continuous PSR exit by masking memup and hpd */ +I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | +EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); + } dev_priv->psr.setup_done = true; }Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp, · line 1683
Quoted 5 lines
drivers/gpu/drm/i915/intel_dp.c +5
-0+static void vlv_edp_psr_enable_sink (struct intel_dp *intel_dp) +{ +/* Enable PSR in sink */ +intel_dp_aux_native_write_1 (intel_dp,DP_PSR_EN_CFG , +DP_PSR_ENABLE );Don't we want the same main-link poweroff logic as HSW?
Quoted 3 lines
I can't remember why I'm not disabling main link here... So I did a quickly try now and failure on tests was huge... so let's keep it simple for now ;)
I think you are disabling the main link currently. Or at least you're telling the sink that main link is going to be turned off, and you also leave the VLV_EDP_PSR_SRC_TRANSMITTER_STATE bit unset, so I think that should make the main link turn off. Well, since the pipe and port remain active, I don't know if the link actually turns off.
I would assume that if you don't turn off the link, it would be easier to keep things happy. A bit weird that you had the opposite result.
BTW now that I look at the HSW code, it seems buggy. When the sink doesn't require link training, we tell it that we're going to turn the link off, otherwise we tell it link will be on. But then we actually do the opposite in intel_edp_psr_enable_source().
Quoted 11 lines
Quoted 9 lines
Or maybe we
should just keep the main link on always as long as we can't enter the low power states w/ DPLL/pipe/port off.Did you already figure out why that's not happening? Looking at the PSRSTAT registers, my guess is that D0i1 is where we end up currently, and that doesn't actually turn off anything but the planes (to stop memory fetches). D0i2 would turn off everything.
no idea.. :(
Did you check the status bit BTW? Does it say D0i1 or D0i2 when you're in PSR?
Quoted 8 lines
Quoted 4 lines
But I guess we should anyway do this in steps. First getting the current stuff in, then trying to get into D0i2 state, and finally getting the display power well turned off when in PSR.
Agree.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
I think once we get to working on D0i2, we'll need to move the PSR wakeup to happen from a workqueue since it essentially requires a full modeset. Even now in your code it's somewhat questionable since you're doing stuff like aux transfers while holding
struct_mutex.uhm... anything we should try now to improve?
Hmm. We already seem to do some PSR setup while holding struct_mutex, but we don't hold it always. Although I think w/ HSW we end up protecting the PSR state w/ the modeset locks since we only fiddle with it during modesets. So for HSW we should just move the PSR update call in set_base outside struct_mutex.
But then for VLV, you want to call it from various places that already hold struct_mutex, so it's getting messy. Just moving it to a workqueue would seem like the easiest option here, and then you could grab the modeset locks in the work function.
Quoted 257 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_dp.c +2
-0+} +static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1678,6 +1713,28 @@ static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT)); }Quoted 16 lines
drivers/gpu/drm/i915/intel_dp.c static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) · line 1727
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp.c +12
-0+static void vlv_edp_psr_enable_source (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); + +uint32_t idle_frames =1 ; +uint32_t val; + + val =I915_READ (VLV_EDP_PSR_CTL (intel_crtc->pipe));I don't think we want to preserve anything here. We need to make sure everything is initialized correctly rather than trusting some old junk in the register.
Done.
Quoted 101 lines
Quoted 101 lines
drivers/gpu/drm/i915/intel_dp.c +53
-11+ val |=VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; + + val |=VLV_EDP_PSR_MODE_HW_TIMER ; + val &= ~VLV_EDP_PSR_FRAME_COUNT_MASK ; + val |= idle_frames <<EDP_PSR_IDLE_FRAME_SHIFT ; + +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), val); +} +static void intel_edp_psr_enable_source (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1719,8 +1776,8 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } -if ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || - (dig_port->port !=PORT_A )) { +if (HAS_DDI (dev) && ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || + (dig_port->port !=PORT_A ))) {DRM_DEBUG_KMS ("HSW ties PSR to DDI A (eDP)\n" );return false; }@@ -1765,37 +1822,83 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } +/* Baytrail supports per-pipe PSR configuration, however PSR on +* PIPE_B isn't working properly. So let's keep it disabled for now. */ +if (IS_VALLEYVIEW (dev) && intel_crtc->pipe !=PIPE_A ) { +DRM_DEBUG_KMS ("PSR on BYT isn't enabled on pipe B.\n" ); +return false; + } + dev_priv->psr.source_ok = true;return true; }static void intel_edp_psr_do_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); -if (!intel_edp_psr_match_conditions (intel_dp) || -intel_edp_is_psr_enabled (dev)) -return ; +if (IS_VALLEYVIEW (dev)) { +if (vlv_edp_is_psr_enabled_on_pipe (dev, intel_crtc->pipe)) +return ; + }else +if (intel_edp_is_psr_enabled (dev)) +return ;/* Setup PSR once */ intel_edp_psr_setup (intel_dp);/* Enable PSR on the panel */ -intel_edp_psr_enable_sink (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_sink (intel_dp); +else +intel_edp_psr_enable_sink (intel_dp);/* Enable PSR on the host */ -intel_edp_psr_enable_source (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_source (intel_dp); +else +intel_edp_psr_enable_source (intel_dp); + + dev_priv->psr.active = true; }void intel_edp_psr_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +if (!is_edp_psr (intel_dp)) +return ; -if (intel_edp_psr_match_conditions (intel_dp) && - !intel_edp_is_psr_enabled (dev)) +if (intel_edp_psr_match_conditions (intel_dp))intel_edp_psr_do_enable (intel_dp); } +void vlv_edp_psr_disable (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); +uint32_t val =I915_READ (VLV_EDP_PSR_STATUS_CTL (intel_crtc->pipe)); + +if (!dev_priv->psr.setup_done)Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp) · line 1893
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp.c +6
-0+return ; + +intel_edp_psr_inactivate (dev); + +if (val &VLV_EDP_PSR_IN_TRANS ) +udelay (250 );Might we want a warning if the bit doesn't go down in expected time?
Done.
Quoted 102 lines
Quoted 102 lines
drivers/gpu/drm/i915/intel_dp.c +51
-4+ + val =I915_READ (VLV_EDP_PSR_CTL (intel_crtc->pipe)); + val &= ~VLV_EDP_PSR_ACTIVE_ENTRY ; + val &= ~VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), val); +} +void intel_edp_psr_disable (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1817,28 +1920,66 @@ void intel_edp_psr_update(struct drm_device *dev) {struct intel_encoder *encoder;struct intel_dp *intel_dp =NULL ; +struct intel_crtc *intel_crtc;list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head)if (encoder->type ==INTEL_OUTPUT_EDP ) { intel_dp =enc_to_intel_dp (&encoder->base); -if (!is_edp_psr (dev)) +if (!is_edp_psr (intel_dp))return ; -if (!intel_edp_psr_match_conditions (intel_dp)) -intel_edp_psr_disable (intel_dp); -else + intel_crtc =to_intel_crtc (encoder->base.crtc); + +if (!intel_edp_psr_match_conditions (intel_dp)) { +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +else +intel_edp_psr_disable (intel_dp); + }else if (!intel_edp_is_psr_enabled (dev))intel_edp_psr_do_enable (intel_dp); } } +void intel_edp_psr_inactivate (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_encoder *encoder; +struct intel_crtc *intel_crtc; +struct intel_dp *intel_dp =NULL ; + +if (!dev_priv->psr.setup_done || !dev_priv->psr.active) +return ; + +list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head) +if (encoder->type ==INTEL_OUTPUT_EDP ) { + intel_dp =enc_to_intel_dp (&encoder->base); + intel_crtc =to_intel_crtc (encoder->base.crtc); + +if (!vlv_edp_is_psr_enabled_on_pipe (dev, + intel_crtc->pipe)) +continue ; + + dev_priv->psr.active = false; +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), +VLV_EDP_PSR_RESET ); +/* WaClearPSRReset:vlv */ +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe),0 ); + +intel_dp_sink_dpms (intel_dp,DRM_MODE_DPMS_ON ); + } +} +static void intel_disable_dp (struct intel_encoder *encoder) {struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);enum port port =dp_to_dig_port (intel_dp)->port;struct drm_device *dev = encoder->base.dev; +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +/* Make sure the panel is off before trying to change the mode. But also * ensure that we have vdd while we switch off the panel. */ intel_edp_backlight_off (intel_dp);@@ -1895,6 +2036,7 @@ static void vlv_enable_dp(struct intel_encoder *encoder)struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);intel_edp_backlight_on (intel_dp); +intel_edp_psr_enable (intel_dp); }static void g4x_pre_enable_dp (struct intel_encoder *encoder)drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);Quoted 7 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_drv.h +0
-1/* intel_dsi.c */ --1.8.1.2
--
Ville Syrjälä
Intel OTCThank you very much!
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 378 lines · Ville Syrjälä
Quoted 241 lines · Rodrigo Vivi
Quoted 135 lines · Ville Syrjälä
Quoted 134 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.Cc Ville Syrjälä <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 9 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++++ drivers/gpu/drm/i915/intel_display.c | 15 ++- drivers/gpu/drm/i915/intel_dp.c | 204 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 7 files changed, 267 insertions(+), 39 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +31
-5@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;drivers/gpu/drm/i915/i915_drv.h +3
-1@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {@@ -1866,7 +1867,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))drivers/gpu/drm/i915/i915_gem.c +6
-0@@ -1256,6 +1256,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped. @@ -1299,6 +1302,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;@@ -4059,6 +4065,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret;Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c i915_gem_busy_ioctl(struct drm_device *dev, void *data, · line 4069
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);The locking for PSR seems to be as fubar as for FBC. Also the front buffer tracking is missing, but I guess I need to make that work for FBC first, and then we need to figure out how to tie it in w/ PSR.
agree... I'll wait your fbc work.
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/i915_gem.c +1
-0+ obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;drivers/gpu/drm/i915/i915_reg.h +11
-0@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9)Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h line 1986
Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +5
-0+#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_EDP_PSR_CTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB)Can we just name the PSR registers like in the spec? Eg. just
VLV_PSRCTL(). Would make it easier to compare things w/ the spec.Done.
Quoted 59 lines
Quoted 59 lines
drivers/gpu/drm/i915/i915_reg.h +21
-0+ +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_EDP_VSC_SDP_REG (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_EDP_PSR_STATUS_CTL (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)drivers/gpu/drm/i915/intel_display.c +9
-2@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;@@ -8228,16 +8231,20 @@ void intel_mark_idle(struct drm_device *dev)if (dev_priv->info->gen >=6 )gen6_rps_idle (dev->dev_private); + +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; -if (!i915.powersave) -return ; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_page_flip(struct drm_crtc *crtc,
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +0
-0list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {if (!crtc->fb)@@ -8688,6 +8695,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,nav> if (work == NULL)
sorry, I didn't get this..
what did you mean?Nothing. Just managed to misplace a few characters here I guess. I blame vim :)
Quoted 115 lines
Quoted 106 lines
Quoted 106 lines
drivers/gpu/drm/i915/intel_display.c +4
-0return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;drivers/gpu/drm/i915/intel_dp.c +44
-16@@ -1578,21 +1578,35 @@ static void intel_dp_get_config(struct intel_encoder *encoder, } } -static bool is_edp_psr (struct drm_device *dev) +static bool is_edp_psr (struct intel_dp *intel_dp) +{ +return intel_dp->psr_dpcd[0 ] &DP_PSR_IS_SUPPORTED ; +} + +static bool vlv_edp_is_psr_enabled_on_pipe (struct drm_device *dev,int pipe) {struct drm_i915_private *dev_priv = dev->dev_private; +uint32_t val; -return dev_priv->psr.sink_support; + val =I915_READ (VLV_EDP_PSR_STATUS_CTL (pipe)) & +VLV_EDP_PSR_CURR_STATE_MASK ; +return (val ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (val ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ); }static bool intel_edp_is_psr_enabled (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (!HAS_PSR (dev)) -return false; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) +return vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_A ) || +vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_B ); +else +return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } -return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +return false; } static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,@@ -1626,28 +1640,49 @@ static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,static void intel_edp_psr_setup (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; +uint32_t val;if (dev_priv->psr.setup_done)return ; -/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; -intel_edp_psr_write_vsc (intel_dp, &psr_vsc); +if (IS_VALLEYVIEW (dev)) { + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_A )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_A ), val); + + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_B )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_B ), val); + }else { +/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; +intel_edp_psr_write_vsc (intel_dp, &psr_vsc); -/* Avoid continuous PSR exit by masking memup and hpd */ -I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | -EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); +/* Avoid continuous PSR exit by masking memup and hpd */ +I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | +EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); + } dev_priv->psr.setup_done = true; }Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp, · line 1683
Quoted 5 lines
drivers/gpu/drm/i915/intel_dp.c +5
-0+static void vlv_edp_psr_enable_sink (struct intel_dp *intel_dp) +{ +/* Enable PSR in sink */ +intel_dp_aux_native_write_1 (intel_dp,DP_PSR_EN_CFG , +DP_PSR_ENABLE );Don't we want the same main-link poweroff logic as HSW?
Quoted 3 lines
I can't remember why I'm not disabling main link here... So I did a quickly try now and failure on tests was huge... so let's keep it simple for now ;)
I think you are disabling the main link currently. Or at least you're telling the sink that main link is going to be turned off, and you also leave the
VLV_EDP_PSR_SRC_TRANSMITTER_STATEbit unset, so I think that should make the main link turn off. Well, since the pipe and port remain active, I don't know if the link actually turns off.
Quoted 7 lines
I would assume that if you don't turn off the link, it would be easier to keep things happy. A bit weird that you had the opposite result.
BTW now that I look at the HSW code, it seems buggy. When the sink doesn't require link training, we tell it that we're going to turn the link off, otherwise we tell it link will be on. But then we actually do the opposite in
intel_edp_psr_enable_source().
afaI-can-remember I followed hsw-pm guide on this... but I might be wrong... I'll comeback to psr hsw later anyway than I verify that and fix if needed.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Or maybe we
should just keep the main link on always as long as we can't enter the low power states w/ DPLL/pipe/port off.Did you already figure out why that's not happening? Looking at the PSRSTAT registers, my guess is that D0i1 is where we end up currently, and that doesn't actually turn off anything but the planes (to stop memory fetches). D0i2 would turn off everything.
Quoted 4 lines
Quoted 1 line
no idea.. :(
Did you check the status bit BTW? Does it say D0i1 or D0i2 when you're in PSR?
D0i1
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines
But I guess we should anyway do this in steps. First getting the current stuff in, then trying to get into D0i2 state, and finally getting the display power well turned off when in PSR.
Agree.
Quoted 6 lines
I think once we get to working on D0i2, we'll need to move the PSR wakeup to happen from a workqueue since it essentially requires a full modeset. Even now in your code it's somewhat questionable since you're doing stuff like aux transfers while holding
struct_mutex.
Quoted 7 lines
Quoted 1 line
uhm... anything we should try now to improve?
Hmm. We already seem to do some PSR setup while holding
struct_mutex, but we don't hold it always. Although I think w/ HSW we end up protecting the PSR state w/ the modeset locks since we only fiddle with it during modesets. So for HSW we should just move the PSR update call inset_baseoutsidestruct_mutex.
I'm planning to change it on HSW to allow a kind of inactivate as well...
Quoted 5 lines
But then for VLV, you want to call it from various places that already hold
struct_mutex, so it's getting messy. Just moving it to a workqueue would seem like the easiest option here, and then you could grab the modeset locks in the work function.
uhm... I'm not sure... I don't think we need to delay the psr_enable... the only issue I see here is double setup or psr-enable along with psr-reset (inactivate)... don't you think a simple mutex for psr_setup would solve in a simpler way?
Quoted 262 lines
Quoted 253 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp.c +2
-0+} +static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1678,6 +1713,28 @@ static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT)); }Quoted 16 lines
drivers/gpu/drm/i915/intel_dp.c static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) · line 1727
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp.c +12
-0+static void vlv_edp_psr_enable_source (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); + +uint32_t idle_frames =1 ; +uint32_t val; + + val =I915_READ (VLV_EDP_PSR_CTL (intel_crtc->pipe));I don't think we want to preserve anything here. We need to make sure everything is initialized correctly rather than trusting some old junk in the register.
Done.
Quoted 101 lines
Quoted 101 lines
drivers/gpu/drm/i915/intel_dp.c +53
-11+ val |=VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; + + val |=VLV_EDP_PSR_MODE_HW_TIMER ; + val &= ~VLV_EDP_PSR_FRAME_COUNT_MASK ; + val |= idle_frames <<EDP_PSR_IDLE_FRAME_SHIFT ; + +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), val); +} +static void intel_edp_psr_enable_source (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1719,8 +1776,8 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } -if ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || - (dig_port->port !=PORT_A )) { +if (HAS_DDI (dev) && ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || + (dig_port->port !=PORT_A ))) {DRM_DEBUG_KMS ("HSW ties PSR to DDI A (eDP)\n" );return false; }@@ -1765,37 +1822,83 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } +/* Baytrail supports per-pipe PSR configuration, however PSR on +* PIPE_B isn't working properly. So let's keep it disabled for now. */ +if (IS_VALLEYVIEW (dev) && intel_crtc->pipe !=PIPE_A ) { +DRM_DEBUG_KMS ("PSR on BYT isn't enabled on pipe B.\n" ); +return false; + } + dev_priv->psr.source_ok = true;return true; }static void intel_edp_psr_do_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); -if (!intel_edp_psr_match_conditions (intel_dp) || -intel_edp_is_psr_enabled (dev)) -return ; +if (IS_VALLEYVIEW (dev)) { +if (vlv_edp_is_psr_enabled_on_pipe (dev, intel_crtc->pipe)) +return ; + }else +if (intel_edp_is_psr_enabled (dev)) +return ;/* Setup PSR once */ intel_edp_psr_setup (intel_dp);/* Enable PSR on the panel */ -intel_edp_psr_enable_sink (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_sink (intel_dp); +else +intel_edp_psr_enable_sink (intel_dp);/* Enable PSR on the host */ -intel_edp_psr_enable_source (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_source (intel_dp); +else +intel_edp_psr_enable_source (intel_dp); + + dev_priv->psr.active = true; }void intel_edp_psr_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +if (!is_edp_psr (intel_dp)) +return ; -if (intel_edp_psr_match_conditions (intel_dp) && - !intel_edp_is_psr_enabled (dev)) +if (intel_edp_psr_match_conditions (intel_dp))intel_edp_psr_do_enable (intel_dp); } +void vlv_edp_psr_disable (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); +uint32_t val =I915_READ (VLV_EDP_PSR_STATUS_CTL (intel_crtc->pipe)); + +if (!dev_priv->psr.setup_done)Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp) · line 1893
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp.c +6
-0+return ; + +intel_edp_psr_inactivate (dev); + +if (val &VLV_EDP_PSR_IN_TRANS ) +udelay (250 );Might we want a warning if the bit doesn't go down in expected time?
Done.
Quoted 102 lines
Quoted 102 lines
drivers/gpu/drm/i915/intel_dp.c +51
-4+ + val =I915_READ (VLV_EDP_PSR_CTL (intel_crtc->pipe)); + val &= ~VLV_EDP_PSR_ACTIVE_ENTRY ; + val &= ~VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), val); +} +void intel_edp_psr_disable (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1817,28 +1920,66 @@ void intel_edp_psr_update(struct drm_device *dev) {struct intel_encoder *encoder;struct intel_dp *intel_dp =NULL ; +struct intel_crtc *intel_crtc;list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head)if (encoder->type ==INTEL_OUTPUT_EDP ) { intel_dp =enc_to_intel_dp (&encoder->base); -if (!is_edp_psr (dev)) +if (!is_edp_psr (intel_dp))return ; -if (!intel_edp_psr_match_conditions (intel_dp)) -intel_edp_psr_disable (intel_dp); -else + intel_crtc =to_intel_crtc (encoder->base.crtc); + +if (!intel_edp_psr_match_conditions (intel_dp)) { +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +else +intel_edp_psr_disable (intel_dp); + }else if (!intel_edp_is_psr_enabled (dev))intel_edp_psr_do_enable (intel_dp); } } +void intel_edp_psr_inactivate (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_encoder *encoder; +struct intel_crtc *intel_crtc; +struct intel_dp *intel_dp =NULL ; + +if (!dev_priv->psr.setup_done || !dev_priv->psr.active) +return ; + +list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head) +if (encoder->type ==INTEL_OUTPUT_EDP ) { + intel_dp =enc_to_intel_dp (&encoder->base); + intel_crtc =to_intel_crtc (encoder->base.crtc); + +if (!vlv_edp_is_psr_enabled_on_pipe (dev, + intel_crtc->pipe)) +continue ; + + dev_priv->psr.active = false; +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe), +VLV_EDP_PSR_RESET ); +/* WaClearPSRReset:vlv */ +I915_WRITE (VLV_EDP_PSR_CTL (intel_crtc->pipe),0 ); + +intel_dp_sink_dpms (intel_dp,DRM_MODE_DPMS_ON ); + } +} +static void intel_disable_dp (struct intel_encoder *encoder) {struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);enum port port =dp_to_dig_port (intel_dp)->port;struct drm_device *dev = encoder->base.dev; +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +/* Make sure the panel is off before trying to change the mode. But also * ensure that we have vdd while we switch off the panel. */ intel_edp_backlight_off (intel_dp);@@ -1895,6 +2036,7 @@ static void vlv_enable_dp(struct intel_encoder *encoder)struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);intel_edp_backlight_on (intel_dp); +intel_edp_psr_enable (intel_dp); }static void g4x_pre_enable_dp (struct intel_encoder *encoder)drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);Quoted 7 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_drv.h +0
-1/* intel_dsi.c */ --1.8.1.2
--
Ville Syrjälä
Intel OTCQuoted 5 lines
Thank you very much!
--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br--
Ville Syrjälä
Intel OTC
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 402 lines · Rodrigo Vivi
Quoted 378 lines · Ville Syrjälä
Quoted 241 lines · Rodrigo Vivi
Quoted 135 lines · Ville Syrjälä
Quoted 134 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busyand update to enable it back on next displaymark_idle.v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.Cc Ville Syrjälä <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 9 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++++ drivers/gpu/drm/i915/intel_display.c | 15 ++- drivers/gpu/drm/i915/intel_dp.c | 204 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 7 files changed, 267 insertions(+), 39 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +31
-5@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_EDP_PSR_STATUS_CTL (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;drivers/gpu/drm/i915/i915_drv.h +3
-1@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {@@ -1866,7 +1867,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))drivers/gpu/drm/i915/i915_gem.c +6
-0@@ -1256,6 +1256,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped. @@ -1299,6 +1302,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;@@ -4059,6 +4065,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret;Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c i915_gem_busy_ioctl(struct drm_device *dev, void *data, · line 4069
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);The locking for PSR seems to be as fubar as for FBC. Also the front buffer tracking is missing, but I guess I need to make that work for FBC first, and then we need to figure out how to tie it in w/ PSR.
agree... I'll wait your fbc work.
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/i915_gem.c +1
-0+ obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;drivers/gpu/drm/i915/i915_reg.h +11
-0@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9)Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h line 1986
Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +5
-0+#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_EDP_PSR_CTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB)Can we just name the PSR registers like in the spec? Eg. just
VLV_PSRCTL(). Would make it easier to compare things w/ the spec.Done.
Quoted 59 lines
Quoted 59 lines
drivers/gpu/drm/i915/i915_reg.h +21
-0+ +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_EDP_VSC_SDP_REG (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_EDP_PSR_STATUS_CTL (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)drivers/gpu/drm/i915/intel_display.c +9
-2@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;@@ -8228,16 +8231,20 @@ void intel_mark_idle(struct drm_device *dev)if (dev_priv->info->gen >=6 )gen6_rps_idle (dev->dev_private); + +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; -if (!i915.powersave) -return ; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev);Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_page_flip(struct drm_crtc *crtc,
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +0
-0list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {if (!crtc->fb)@@ -8688,6 +8695,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,nav> if (work == NULL)
sorry, I didn't get this..
what did you mean?Nothing. Just managed to misplace a few characters here I guess. I blame vim :)
Quoted 115 lines
Quoted 106 lines
Quoted 106 lines
drivers/gpu/drm/i915/intel_display.c +4
-0return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;drivers/gpu/drm/i915/intel_dp.c +44
-16@@ -1578,21 +1578,35 @@ static void intel_dp_get_config(struct intel_encoder *encoder, } } -static bool is_edp_psr (struct drm_device *dev) +static bool is_edp_psr (struct intel_dp *intel_dp) +{ +return intel_dp->psr_dpcd[0 ] &DP_PSR_IS_SUPPORTED ; +} + +static bool vlv_edp_is_psr_enabled_on_pipe (struct drm_device *dev,int pipe) {struct drm_i915_private *dev_priv = dev->dev_private; +uint32_t val; -return dev_priv->psr.sink_support; + val =I915_READ (VLV_EDP_PSR_STATUS_CTL (pipe)) & +VLV_EDP_PSR_CURR_STATE_MASK ; +return (val ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (val ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ); }static bool intel_edp_is_psr_enabled (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (!HAS_PSR (dev)) -return false; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) +return vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_A ) || +vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_B ); +else +return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } -return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +return false; } static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,@@ -1626,28 +1640,49 @@ static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,static void intel_edp_psr_setup (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; +uint32_t val;if (dev_priv->psr.setup_done)return ; -/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; -intel_edp_psr_write_vsc (intel_dp, &psr_vsc); +if (IS_VALLEYVIEW (dev)) { + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_A )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_A ), val); + + val =I915_READ (VLV_EDP_VSC_SDP_REG (PIPE_B )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_EDP_VSC_SDP_REG (PIPE_B ), val); + }else { +/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; +intel_edp_psr_write_vsc (intel_dp, &psr_vsc); -/* Avoid continuous PSR exit by masking memup and hpd */ -I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | -EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); +/* Avoid continuous PSR exit by masking memup and hpd */ +I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | +EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); + } dev_priv->psr.setup_done = true; }Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp, · line 1683
Quoted 5 lines
drivers/gpu/drm/i915/intel_dp.c +5
-0+static void vlv_edp_psr_enable_sink (struct intel_dp *intel_dp) +{ +/* Enable PSR in sink */ +intel_dp_aux_native_write_1 (intel_dp,DP_PSR_EN_CFG , +DP_PSR_ENABLE );Don't we want the same main-link poweroff logic as HSW?
Quoted 3 lines
I can't remember why I'm not disabling main link here... So I did a quickly try now and failure on tests was huge... so let's keep it simple for now ;)
I think you are disabling the main link currently. Or at least you're telling the sink that main link is going to be turned off, and you also leave the
VLV_EDP_PSR_SRC_TRANSMITTER_STATEbit unset, so I think that should make the main link turn off. Well, since the pipe and port remain active, I don't know if the link actually turns off.Quoted 7 lines
I would assume that if you don't turn off the link, it would be easier to keep things happy. A bit weird that you had the opposite result.
BTW now that I look at the HSW code, it seems buggy. When the sink doesn't require link training, we tell it that we're going to turn the link off, otherwise we tell it link will be on. But then we actually do the opposite in
intel_edp_psr_enable_source().afaI-can-remember I followed hsw-pm guide on this... but I might be wrong... I'll comeback to psr hsw later anyway than I verify that and fix if needed.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Or maybe we
should just keep the main link on always as long as we can't enter the low power states w/ DPLL/pipe/port off.Did you already figure out why that's not happening? Looking at the PSRSTAT registers, my guess is that D0i1 is where we end up currently, and that doesn't actually turn off anything but the planes (to stop memory fetches). D0i2 would turn off everything.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
no idea.. :(
Did you check the status bit BTW? Does it say D0i1 or D0i2 when you're in PSR?
D0i1
OK, as I suspected then.
Quoted 32 lines
Quoted 16 lines
Quoted 16 lines
Quoted 6 lines
But I guess we should anyway do this in steps. First getting the current stuff in, then trying to get into D0i2 state, and finally getting the display power well turned off when in PSR.
Agree.
Quoted 6 lines
I think once we get to working on D0i2, we'll need to move the PSR wakeup to happen from a workqueue since it essentially requires a full modeset. Even now in your code it's somewhat questionable since you're doing stuff like aux transfers while holding
struct_mutex.Quoted 7 lines
Quoted 1 line
uhm... anything we should try now to improve?
Hmm. We already seem to do some PSR setup while holding
struct_mutex, but we don't hold it always. Although I think w/ HSW we end up protecting the PSR state w/ the modeset locks since we only fiddle with it during modesets. So for HSW we should just move the PSR update call inset_baseoutsidestruct_mutex.I'm planning to change it on HSW to allow a kind of inactivate as well...
Quoted 5 lines
But then for VLV, you want to call it from various places that already hold
struct_mutex, so it's getting messy. Just moving it to a workqueue would seem like the easiest option here, and then you could grab the modeset locks in the work function.
Quoted 4 lines
uhm... I'm not sure... I don't think we need to delay the
psr_enable... the only issue I see here is double setup or psr-enable along with psr-reset (inactivate)... don't you think a simple mutex forpsr_setupwould solve in a simpler way?
intel_edp_psr_match_conditions() in its current definitely needs to be protected by crtc.mutex to not race w/ page flips and modesets. Currently you call it from the idle work, without any locks, so that's already a problem. And we can't simply grab modeset locks there since those are banned on the dev_priv->wq workqueue.
One idea might be to call intel_edp_psr_match_conditions() only from places where we already have the crtc mutex. That's actually just the modeset code, since we can't change tiling via page flips, so page flips don't need to call it. Hmm. Oh we'd also need to call it from the sprite code too. Anyways, then based on the result we'd set some per-crtc flag to remind us whether PSR can be enabled for the pipe. Then when we're ready to re-enable PSR we can just check the flag. That could be protected by some psr mutex.
Also we need to at least disable PSR from some places where we already hold struct_mutex, and holding that sucker needlessly is a bad idea. So offloading the PSR disable to a workqueue seems like the sane approach here since it already involves stuff like aux writes. So even if we have the psr mutex and flag thingy it would still need to be done from a workqueue.
Signature · 2 lines
Ville Syrjälä Intel OTC
PATCH 1/1 drm/i915: Add Baytrail PSR Support.
In reply to Ville SyrjäläThis patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {busy_ioctl, sw_finish and mark_busy} and update to enable it back on next display mark_idle.
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR on mark_busy, dset_domain and sw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leaving PIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
v7: Remove inactivate from set_domain. Chris warned this was semanticaly
wrong.
v8: Accept Ville's suggestions: Use register's names matching spec and
warn if transition took longer than it should.
--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++++- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem.c | 6 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++++ drivers/gpu/drm/i915/intel_display.c | 14 +++ drivers/gpu/drm/i915/intel_dp.c | 204 +++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 1 + 7 files changed, 265 insertions(+), 37 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +31 -5
@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);
@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_PSRSTAT (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_PSRSTAT (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -747,6 +747,7 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active; };enum intel_pch {
@@ -1866,7 +1867,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))
drivers/gpu/drm/i915/i915_gem.c +6 -0
@@ -1299,6 +1299,9 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
@@ -4059,6 +4062,9 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
drivers/gpu/drm/i915/i915_reg.h +37 -0
@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_PSRCTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB) + +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_VSCSDP (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_PSRSTAT (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)
drivers/gpu/drm/i915/intel_display.c +14 -0
@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (on) base = intel_crtc->cursor_addr;
@@ -8228,14 +8231,21 @@ void intel_mark_idle(struct drm_device *dev)if (dev_priv->info->gen >=6 )gen6_rps_idle (dev->dev_private); + +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_update (dev); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +if (!i915.powersave)return ;
@@ -8688,6 +8698,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;
drivers/gpu/drm/i915/intel_dp.c +173 -31
307 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev);/* intel_dsi.c */
Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
drivers/gpu/drm/i915/intel_display.c static void intel_crtc_update_cursor(struct drm_crtc *crtc, · line 7506
Quoted 7 lines · Rodrigo Vivi
drivers/gpu/drm/i915/intel_display.c +3
-0@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +
Inactivate means that we turn off PSR for some period of time until idle again, right? In the case of a moving cursor that means indefinitely.
Also it sounds overkill to have to disable PSR just for the cursor sprite. Is there not some preferrable alternatives or hw that dtrt? -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 11 lines · Chris Wilson
drivers/gpu/drm/i915/intel_display.c static void intel_crtc_update_cursor(struct drm_crtc *crtc, · line 7506
Quoted 7 lines · Rodrigo Vivi
drivers/gpu/drm/i915/intel_display.c +3
-0@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +Inactivate means that we turn off PSR for some period of time until idle again, right?
Yes, right.
Quoted 1 line
In the case of a moving cursor that means indefinitely.
That's true... So I think we really need a work queue delaying the enable. Or do you have any better idea?
Quoted 3 lines
Also it sounds overkill to have to disable PSR just for the cursor sprite. Is there not some preferrable alternatives or hw that dtrt?
Yeap, I totally agree. The other option implemented by other drivers is to use PSR SW control mode where driver controls all entry and exit flow, since Baytrail cannot do it right on HW mode. But even the force exit on this case was using the PSR_RESET that I'm using on inactivate function. and they exported that over ioctl.
So I preferred to let all this on kernel side using hardware as much as possible and workarounding the cases where hardware buggy on screen update detection, although it looks like an overkill for a single cursor update. :/
Quoted 4 lines
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 13 lines · Rodrigo Vivi
Quoted 11 lines · Chris Wilson
drivers/gpu/drm/i915/intel_display.c static void intel_crtc_update_cursor(struct drm_crtc *crtc, · line 7506
Quoted 7 lines · Rodrigo Vivi
drivers/gpu/drm/i915/intel_display.c +3
-0@@ -7501,6 +7501,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +if (IS_VALLEYVIEW (dev)) +intel_edp_psr_inactivate (dev); +Inactivate means that we turn off PSR for some period of time until idle again, right?
Quoted 5 lines
Yes, right.
Quoted 1 line
In the case of a moving cursor that means indefinitely.
That's true... So I think we really need a work queue delaying the enable. Or do you have any better idea?
Yeah, sounds like we need a delayed work-queue to re-enable psr, also for gtt mmap writes. See Chris' latest crazy example of what the X server is currently allowed to do.
Quoted 12 lines
Quoted 2 lines
Also it sounds overkill to have to disable PSR just for the cursor sprite. Is there not some preferrable alternatives or hw that dtrt?
Yeap, I totally agree. The other option implemented by other drivers is to use PSR SW control mode where driver controls all entry and exit flow, since Baytrail cannot do it right on HW mode. But even the force exit on this case was using the
PSR_RESETthat I'm using on inactivate function. and they exported that over ioctl.
So I preferred to let all this on kernel side using hardware as much as possible and workarounding the cases where hardware buggy on screen update detection, although it looks like an overkill for a single cursor update. :/
Yeah, exporting psr to userspace is imo a complete no-go. We can give userspace hints and eventually go to an explicit damage tracking model, but it's ultimately the kernel's responsibility to shovel pixels to the screen.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
In the case of a moving cursor that means indefinitely.
That's true... So I think we really need a work queue delaying the enable. Or do you have any better idea?
Yeah, sounds like we need a delayed work-queue to re-enable psr, also for gtt mmap writes. See Chris' latest crazy example of what the X server is currently allowed to do.
But I'm not sure if I should do all with delayed schedule or still calling this psr_update on mark_idle and just schedule work on cursor. what do you think?
Please notice that besides the wq it also has mutex psr added on this:
Quoted 7 lines
Oops, sounds like we need to have another testcase which does this, both for fbc and psr. It sounds like we'd need to nuke psr completely for this case in
set_domain(when gtt writes are enforced) and only re-enable it on the next pageflip. If that's too shitty for some platforms we care about we could have a timer in place to shoot down gtt mmappings and restore psr after one second or something like this. Ofc that means we also need to frob the page fault paths a bit then.
To be honest this passed on my mind and I did a local test with sleep after set_domain, but test worked so I didn't mind with that... but seems that it was only a conincidence or I put the sleep on a wrong place...
Anyway I will include more test cases...
Anyway, do you think that above delayed work with 5 seconds would sove this case? or do you still want I do something to avoid it getting back between set_doamin and next page_flip?
But in this case isn't there a risk to get it disabled forever? like in the old cursor without the delayed work?
Quoted 9 lines
Quoted 3 lines
Besides which I keep asking for a PSR property so X can switch to an alternative rendering strategy that should be more power efficient and PSR friendly.
Agreed on that, but imo we need to first get the legacy crap going without regressions. Once we have that in solid shape we can extend things with all kinds of fancy madness (I'm also thinking of explicit damage flushing and things like this). But we've never had a solid baseline for fbc/psr ever ...
I agree with Daniel, mainly for the big pressure on getting PSR Baytrail in asap.
I'm considering yet that full PSR rework to get it tied to pipe config... But will do this later.
First I'd like to have one working with minimal userspace interaction needed.
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
Quoted 8 lines · Rodrigo Vivi
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
In the case of a moving cursor that means indefinitely.
That's true... So I think we really need a work queue delaying the enable. Or do you have any better idea?
Yeah, sounds like we need a delayed work-queue to re-enable psr, also for gtt mmap writes. See Chris' latest crazy example of what the X server is currently allowed to do.
Quoted 5 lines
But I'm not sure if I should do all with delayed schedule or still calling this
psr_updateonmark_idleand just schedule work on cursor. what do you think?
You also need to tear down gtt mmaps to make sure we catch them, at least for the gtt mmap write case. And add a bit of code to gem_fault to invalidate psr if needed.
Quoted 3 lines
Please notice that besides the wq it also has mutex psr added on this:
tbh I haven't thought much yet about locking, but iirc the current stuff is hapzardous. Ville looked into fixing this, but it seems to be fairly complicated. Not sure whether we should aim for a common locking between fbc/psr or not (since they both are closely related wrt their interactions between modeset code and gem stuff).
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 2/2 drm/i915: Add Baytrail PSR Support.
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {busy_ioctl, set_domain, sw_finish and mark_busy} and update to enable it back on next display mark_idle.
v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR on mark_busy, dset_domain and sw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leaving PIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
v7: Remove inactivate from set_domain. Chris warned this was semanticaly
wrong.
v8: Accept Ville's suggestions: Use register's names matching spec and
warn if transition took longer than it should.
v9: New version with delayed work to get PSR back. Disabling it on
set_domain but not rescheduing it back until next finish_page_flip.
--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++- drivers/gpu/drm/i915/i915_drv.h | 5 +- drivers/gpu/drm/i915/i915_gem.c | 12 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++ drivers/gpu/drm/i915/i915_suspend.c | 2 +- drivers/gpu/drm/i915/intel_display.c | 18 ++- drivers/gpu/drm/i915/intel_dp.c | 256 ++++++++++++++++++++++++++++++----- drivers/gpu/drm/i915/intel_drv.h | 1 + 8 files changed, 323 insertions(+), 44 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +31 -5
@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);
@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_PSRSTAT (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_PSRSTAT (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;
drivers/gpu/drm/i915/i915_drv.h +4 -1
@@ -747,7 +747,9 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active;struct mutex lock; +struct delayed_work work; };enum intel_pch {
@@ -1867,7 +1869,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))
drivers/gpu/drm/i915/i915_gem.c +12 -0
@@ -1256,6 +1256,14 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +/* Here we don't reschedule work to get PSR back because userspace +* can set domain and take as much as time it wants to write it. +* We only reschedule it back on next finish_page_flip. There is the +* risk of PSR be inactive forever depending on how compositor works, +* but this is the safest way to avoid loosing screen updates. +*/ +intel_edp_psr_inactivate (dev, false); +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped.
@@ -1299,6 +1307,8 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +intel_edp_psr_inactivate (dev, true); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
@@ -4059,6 +4069,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +intel_edp_psr_inactivate (dev, true); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;
drivers/gpu/drm/i915/i915_reg.h +37 -0
@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_PSRCTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB) + +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_VSCSDP (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_PSRSTAT (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)
drivers/gpu/drm/i915/i915_suspend.c +1 -1
@@ -289,8 +289,8 @@ static void i915_restore_display(struct drm_device *dev) }/* Force a full PSR setup on resume */ +intel_edp_psr_inactivate (dev, false); dev_priv->psr.setup_done = false; -intel_edp_psr_update (dev);/* only restore FBC info on the platform that supports FBC*/ intel_disable_fbc (dev);
drivers/gpu/drm/i915/intel_display.c +17 -1
@@ -4451,9 +4451,13 @@ static void intel_connector_check_state(struct intel_connector *connector)* consider. */ void intel_connector_dpms (struct drm_connector *connector,int mode) { +struct drm_device *dev = connector->dev; +/* All the simple cases only support two dpms states. */ -if (mode !=DRM_MODE_DPMS_ON ) +if (mode !=DRM_MODE_DPMS_ON ) { mode =DRM_MODE_DPMS_OFF ; +intel_edp_psr_inactivate (dev, false); + }if (mode == connector->dpms)return ;
@@ -7501,6 +7505,8 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +intel_edp_psr_inactivate (dev, true); +if (on) base = intel_crtc->cursor_addr;
@@ -8230,12 +8236,15 @@ void intel_mark_idle(struct drm_device *dev)gen6_rps_idle (dev->dev_private); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; +intel_edp_psr_inactivate (dev, true); +if (!i915.powersave)return ;
@@ -8336,6 +8345,10 @@ static void do_intel_finish_page_flip(struct drm_device *dev,queue_work (dev_priv->wq, &work->work);trace_i915_flip_complete (intel_crtc->plane, work->pending_flip_obj); + +/* Get PSR back after set_domain inactivated it without rescheduling +* it back. */ +schedule_delayed_work (&dev_priv->psr.work,msecs_to_jiffies (5000 )); }void intel_finish_page_flip (struct drm_device *dev,int pipe)
@@ -8688,6 +8701,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +intel_edp_psr_inactivate (dev, true); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;
drivers/gpu/drm/i915/intel_dp.c +220 -36
372 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev,bool schedule_back);/* intel_dsi.c */
Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: Add Baytrail PSR Support.
Quoted 121 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busy} and update to enable it back on next displaymark_idle.v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
v7: Remove inactivate fromset_domain. Chris warned this was semanticaly
wrong.
v8: Accept Ville's suggestions: Use register's names matching spec and
warn if transition took longer than it should.
v9: New version with delayed work to get PSR back. Disabling it on
set_domainbut not rescheduing it back until nextfinish_page_flip.Cc Chris Wilson <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++- drivers/gpu/drm/i915/i915_drv.h | 5 +- drivers/gpu/drm/i915/i915_gem.c | 12 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++ drivers/gpu/drm/i915/i915_suspend.c | 2 +- drivers/gpu/drm/i915/intel_display.c | 18 ++- drivers/gpu/drm/i915/intel_dp.c | 256 ++++++++++++++++++++++++++++++----- drivers/gpu/drm/i915/intel_drv.h | 1 + 8 files changed, 323 insertions(+), 44 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +31
-5@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_PSRSTAT (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_PSRSTAT (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;drivers/gpu/drm/i915/i915_drv.h +4
-1@@ -747,7 +747,9 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active;struct mutex lock; +struct delayed_work work; };enum intel_pch {@@ -1867,7 +1869,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))drivers/gpu/drm/i915/i915_gem.c +0
-0
drivers/gpu/drm/i915/i915_gem.c i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, · line 1265
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +7
-0@@ -1256,6 +1256,14 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; } +/* Here we don't reschedule work to get PSR back because userspace +* can set domain and take as much as time it wants to write it. +* We only reschedule it back on next finish_page_flip. There is the +* risk of PSR be inactive forever depending on how compositor works, +* but this is the safest way to avoid loosing screen updates. +*/ +intel_edp_psr_inactivate (dev, false);
This will still block until PSR is deactivated (aux communication and all). That still seems like a bad idea to do while holding struct_mutex.
Quoted 89 lines
drivers/gpu/drm/i915/i915_gem.c +5
-0+/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped. @@ -1299,6 +1307,8 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +intel_edp_psr_inactivate (dev, true); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;@@ -4059,6 +4069,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +intel_edp_psr_inactivate (dev, true); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;drivers/gpu/drm/i915/i915_reg.h +37
-0@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_PSRCTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB) + +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_VSCSDP (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_PSRSTAT (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)drivers/gpu/drm/i915/i915_suspend.c +1
-1@@ -289,8 +289,8 @@ static void i915_restore_display(struct drm_device *dev) }/* Force a full PSR setup on resume */ +intel_edp_psr_inactivate (dev, false); dev_priv->psr.setup_done = false; -intel_edp_psr_update (dev);/* only restore FBC info on the platform that supports FBC*/ intel_disable_fbc (dev);drivers/gpu/drm/i915/intel_display.c +0
-0
drivers/gpu/drm/i915/intel_display.c static void intel_connector_check_state(struct intel_connector *connector) · line 4459
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +4
-1@@ -4451,9 +4451,13 @@ static void intel_connector_check_state(struct intel_connector *connector)* consider. */ void intel_connector_dpms (struct drm_connector *connector,int mode) { +struct drm_device *dev = connector->dev; +/* All the simple cases only support two dpms states. */ -if (mode !=DRM_MODE_DPMS_ON ) +if (mode !=DRM_MODE_DPMS_ON ) { mode =DRM_MODE_DPMS_OFF ; +intel_edp_psr_inactivate (dev, false);
Maybe check if this connector even has PSR enabled?
drivers/gpu/drm/i915/intel_display.c static void intel_crtc_update_cursor(struct drm_crtc *crtc, · line 7508
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +2
-0+ }if (mode == connector->dpms)return ;@@ -7501,6 +7505,8 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible; +intel_edp_psr_inactivate (dev, true);
Don't need to inactivate unless the cursor is or was visible.
Quoted 340 lines
drivers/gpu/drm/i915/intel_display.c +11
-0+if (on) base = intel_crtc->cursor_addr;@@ -8230,12 +8236,15 @@ void intel_mark_idle(struct drm_device *dev)gen6_rps_idle (dev->dev_private); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; +intel_edp_psr_inactivate (dev, true); +if (!i915.powersave)return ;@@ -8336,6 +8345,10 @@ static void do_intel_finish_page_flip(struct drm_device *dev,queue_work (dev_priv->wq, &work->work);trace_i915_flip_complete (intel_crtc->plane, work->pending_flip_obj); + +/* Get PSR back after set_domain inactivated it without rescheduling +* it back. */ +schedule_delayed_work (&dev_priv->psr.work,msecs_to_jiffies (5000 )); }void intel_finish_page_flip (struct drm_device *dev,int pipe)@@ -8688,6 +8701,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +intel_edp_psr_inactivate (dev, true); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;drivers/gpu/drm/i915/intel_dp.c +158
-35@@ -1578,21 +1578,35 @@ static void intel_dp_get_config(struct intel_encoder *encoder, } } -static bool is_edp_psr (struct drm_device *dev) +static bool is_edp_psr (struct intel_dp *intel_dp) +{ +return intel_dp->psr_dpcd[0 ] &DP_PSR_IS_SUPPORTED ; +} + +static bool vlv_edp_is_psr_enabled_on_pipe (struct drm_device *dev,int pipe) {struct drm_i915_private *dev_priv = dev->dev_private; +uint32_t val; -return dev_priv->psr.sink_support; + val =I915_READ (VLV_PSRSTAT (pipe)) & +VLV_EDP_PSR_CURR_STATE_MASK ; +return (val ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (val ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ); }static bool intel_edp_is_psr_enabled (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (!HAS_PSR (dev)) -return false; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) +return vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_A ) || +vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_B ); +else +return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } -return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +return false; } static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,@@ -1624,32 +1638,60 @@ static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,POSTING_READ (ctl_reg); } +static void intel_edp_psr_work (struct work_struct *work) +{ +struct drm_i915_private *dev_priv = +container_of (work,typeof (*dev_priv), psr.work.work); +struct drm_device *dev = dev_priv->dev; + +intel_edp_psr_update (dev); +} +static void intel_edp_psr_setup (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; +uint32_t val;if (dev_priv->psr.setup_done)return ; -mutex_init (&dev_priv->psr.lock); - -/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; -intel_edp_psr_write_vsc (intel_dp, &psr_vsc); - -/* Avoid continuous PSR exit by masking memup and hpd */ -I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | -EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); +if (IS_VALLEYVIEW (dev)) { + val =I915_READ (VLV_VSCSDP (PIPE_A )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_VSCSDP (PIPE_A ), val); + + val =I915_READ (VLV_VSCSDP (PIPE_B )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_VSCSDP (PIPE_B ), val); + }else { +/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; +intel_edp_psr_write_vsc (intel_dp, &psr_vsc); + +/* Avoid continuous PSR exit by masking memup and hpd */ +I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | +EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); + } dev_priv->psr.setup_done = true; } +static void vlv_edp_psr_enable_sink (struct intel_dp *intel_dp) +{ +/* Enable PSR in sink */ +intel_dp_aux_native_write_1 (intel_dp,DP_PSR_EN_CFG , +DP_PSR_ENABLE ); +} +static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1680,6 +1722,27 @@ static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT)); } +static void vlv_edp_psr_enable_source (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); + +uint32_t idle_frames =1 ; +uint32_t val =0 ; + + val |=VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; + + val |=VLV_EDP_PSR_MODE_HW_TIMER ; + val &= ~VLV_EDP_PSR_FRAME_COUNT_MASK ; + val |= idle_frames <<EDP_PSR_IDLE_FRAME_SHIFT ; + +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe), val); +} +static void intel_edp_psr_enable_source (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1721,8 +1784,8 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } -if ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || - (dig_port->port !=PORT_A )) { +if (HAS_DDI (dev) && ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || + (dig_port->port !=PORT_A ))) {DRM_DEBUG_KMS ("HSW ties PSR to DDI A (eDP)\n" );return false; }@@ -1767,23 +1830,45 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } +/* Baytrail supports per-pipe PSR configuration, however PSR on +* PIPE_B isn't working properly. So let's keep it disabled for now. */ +if (IS_VALLEYVIEW (dev) && intel_crtc->pipe !=PIPE_A ) { +DRM_DEBUG_KMS ("PSR on BYT isn't enabled on pipe B.\n" ); +return false; + } + dev_priv->psr.source_ok = true;return true; }static void intel_edp_psr_do_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); -if (!intel_edp_psr_match_conditions (intel_dp) || -intel_edp_is_psr_enabled (dev)) -return ; +if (IS_VALLEYVIEW (dev)) { +if (vlv_edp_is_psr_enabled_on_pipe (dev, intel_crtc->pipe)) +return ; + }else +if (intel_edp_is_psr_enabled (dev)) +return ;/* Enable PSR on the panel */ -intel_edp_psr_enable_sink (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_sink (intel_dp); +else +intel_edp_psr_enable_sink (intel_dp);/* Enable PSR on the host */ -intel_edp_psr_enable_source (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_source (intel_dp); +else +intel_edp_psr_enable_source (intel_dp); + + dev_priv->psr.active = true; }void intel_edp_psr_enable (struct intel_dp *intel_dp)@@ -1791,16 +1876,43 @@ void intel_edp_psr_enable(struct intel_dp *intel_dp)struct drm_device *dev =intel_dp_to_dev (intel_dp);struct drm_i915_private *dev_priv = dev->dev_private; +if (!is_edp_psr (intel_dp)) +return ; +/* Setup PSR once */ intel_edp_psr_setup (intel_dp);mutex_lock (&dev_priv->psr.lock); -if (intel_edp_psr_match_conditions (intel_dp) && - !intel_edp_is_psr_enabled (dev)) +if (intel_edp_psr_match_conditions (intel_dp))intel_edp_psr_do_enable (intel_dp);mutex_unlock (&dev_priv->psr.lock); } +void vlv_edp_psr_disable (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); +uint32_t val; + +if (!dev_priv->psr.setup_done) +return ; + +intel_edp_psr_inactivate (dev, false); + +if (wait_for ((I915_READ (VLV_PSRSTAT (intel_crtc->pipe)) & +VLV_EDP_PSR_IN_TRANS ) ==0 ,250 )) +WARN (1 ,"PSR transition took longer than expected\n" ); + + val =I915_READ (VLV_PSRCTL (intel_crtc->pipe)); + val &= ~VLV_EDP_PSR_ACTIVE_ENTRY ; + val &= ~VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe), val); +} +void intel_edp_psr_disable (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1823,6 +1935,7 @@ void intel_edp_psr_update(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct intel_encoder *encoder;struct intel_dp *intel_dp =NULL ; +struct intel_crtc *intel_crtc;if (!dev_priv->psr.setup_done)return ;@@ -1830,26 +1943,93 @@ void intel_edp_psr_update(struct drm_device *dev)list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head)if (encoder->type ==INTEL_OUTPUT_EDP ) { intel_dp =enc_to_intel_dp (&encoder->base); - -if (!is_edp_psr (dev)) -return ; + intel_crtc =to_intel_crtc (encoder->base.crtc);mutex_lock (&dev_priv->psr.lock); -if (!intel_edp_psr_match_conditions (intel_dp)) -intel_edp_psr_disable (intel_dp); -else +if (!intel_edp_psr_match_conditions (intel_dp)) { +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +else +intel_edp_psr_disable (intel_dp); + }else if (!intel_edp_is_psr_enabled (dev))intel_edp_psr_do_enable (intel_dp);mutex_unlock (&dev_priv->psr.lock); } } +void intel_edp_psr_do_inactivate (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_connector *connector; +struct intel_encoder *encoder; +struct intel_crtc *intel_crtc; +struct intel_dp *intel_dp =NULL ; + + list_for_each_entry(connector, &dev->mode_config.connector_list,
drivers/gpu/drm/i915/intel_dp.c void intel_edp_psr_update(struct drm_device *dev) · line 1979
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +10
-0+ base.head) { + +if (connector->base.dpms !=DRM_MODE_DPMS_ON ) +continue ; + + encoder =to_intel_encoder (connector->base.encoder); +if (encoder->type ==INTEL_OUTPUT_EDP ) { + + intel_dp =enc_to_intel_dp (&encoder->base); + intel_crtc =to_intel_crtc (encoder->base.crtc);
Still digging through the encoder and crtc pointers w/o holding any modeset locks. Feels dangerous. intel_edp_psr_match_conditions() does the same kind of stuff, and that too now gets called outside modeset codepaths.
Quoted 24 lines
drivers/gpu/drm/i915/intel_dp.c +24
-0+ +if (!vlv_edp_is_psr_enabled_on_pipe (dev, + intel_crtc->pipe)) +continue ; + + dev_priv->psr.active = false; + +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe), +VLV_EDP_PSR_RESET ); +/* WaClearPSRReset:vlv */ +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe),0 ); + +intel_dp_sink_dpms (intel_dp,DRM_MODE_DPMS_ON ); + } + } +} + +void intel_edp_psr_inactivate (struct drm_device *dev,bool schedule_back) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +if (!IS_VALLEYVIEW (dev)) +return ; +
drivers/gpu/drm/i915/intel_dp.c void intel_edp_psr_update(struct drm_device *dev) · line 2013
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +10
-0+if (!dev_priv->psr.setup_done) +return ; + +/* If it was requested to not turn psr back delayed work must be +* canceled even if it is already on inactivated state. */ +if (!schedule_back) +cancel_delayed_work_sync (&dev_priv->psr.work); + +if (!dev_priv->psr.active) +return ;
What if psr gets re-activated just after you checked above?
Quoted 31 lines
drivers/gpu/drm/i915/intel_dp.c +14
-0+ +cancel_delayed_work_sync (&dev_priv->psr.work); + +intel_edp_psr_do_inactivate (dev); + +if (schedule_back) +schedule_delayed_work (&dev_priv->psr.work, +msecs_to_jiffies (5000 )); +} +static void intel_disable_dp (struct intel_encoder *encoder) {struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);enum port port =dp_to_dig_port (intel_dp)->port;struct drm_device *dev = encoder->base.dev; +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +/* Make sure the panel is off before trying to change the mode. But also * ensure that we have vdd while we switch off the panel. */ intel_edp_backlight_off (intel_dp);@@ -1906,6 +2086,7 @@ static void vlv_enable_dp(struct intel_encoder *encoder)struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);intel_edp_backlight_on (intel_dp); +intel_edp_psr_enable (intel_dp); }static void g4x_pre_enable_dp (struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_dp.c intel_dp_init_connector(struct intel_digital_port *intel_dig_port, · line 4033
Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c +3
-1@@ -3846,8 +4027,11 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,BUG (); } -if (is_edp (intel_dp)) +if (is_edp (intel_dp)) {intel_dp_init_panel_power_sequencer (dev, intel_dp, &power_seq); +INIT_DELAYED_WORK (&dev_priv->psr.work, intel_edp_psr_work); +mutex_init (&dev_priv->psr.lock);
Initializing global state from a per-connector init function seems a bit weird.
Quoted 18 lines
drivers/gpu/drm/i915/intel_dp.c +1
-0+ } error =intel_dp_i2c_init (intel_dp, intel_connector, name); WARN(error, "intel_dp_i2c_init failed with error %d for port %c\n",drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev,bool schedule_back);/* intel_dsi.c */ Signature · 1 line
1.8.1.2
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 2/2] drm/i915: Add Baytrail PSR Support.
Quoted 125 lines · Ville Syrjälä
Quoted 124 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busy} and update to enable it back on next displaymark_idle.v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
v7: Remove inactivate fromset_domain. Chris warned this was semanticaly
wrong.
v8: Accept Ville's suggestions: Use register's names matching spec and
warn if transition took longer than it should.
v9: New version with delayed work to get PSR back. Disabling it on
set_domainbut not rescheduing it back until nextfinish_page_flip.Cc Chris Wilson <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++- drivers/gpu/drm/i915/i915_drv.h | 5 +- drivers/gpu/drm/i915/i915_gem.c | 12 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++ drivers/gpu/drm/i915/i915_suspend.c | 2 +- drivers/gpu/drm/i915/intel_display.c | 18 ++- drivers/gpu/drm/i915/intel_dp.c | 256 ++++++++++++++++++++++++++++++----- drivers/gpu/drm/i915/intel_drv.h | 1 + 8 files changed, 323 insertions(+), 44 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +31
-5@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_PSRSTAT (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_PSRSTAT (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;drivers/gpu/drm/i915/i915_drv.h +4
-1@@ -747,7 +747,9 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active;struct mutex lock; +struct delayed_work work; };enum intel_pch {@@ -1867,7 +1869,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -1256,6 +1256,14 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; }
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, · line 1265
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c +7
-0+/* Here we don't reschedule work to get PSR back because userspace +* can set domain and take as much as time it wants to write it. +* We only reschedule it back on next finish_page_flip. There is the +* risk of PSR be inactive forever depending on how compositor works, +* but this is the safest way to avoid loosing screen updates. +*/ +intel_edp_psr_inactivate (dev, false);This will still block until PSR is deactivated (aux communication and all). That still seems like a bad idea to do while holding
struct_mutex.
So, what do you suggest here?
Quoted 94 lines
Quoted 94 lines
drivers/gpu/drm/i915/i915_gem.c +5
-0+/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped. @@ -1299,6 +1307,8 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +intel_edp_psr_inactivate (dev, true); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;@@ -4059,6 +4069,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +intel_edp_psr_inactivate (dev, true); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;drivers/gpu/drm/i915/i915_reg.h +37
-0@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_PSRCTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB) + +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_VSCSDP (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_PSRSTAT (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)drivers/gpu/drm/i915/i915_suspend.c +1
-1@@ -289,8 +289,8 @@ static void i915_restore_display(struct drm_device *dev) }/* Force a full PSR setup on resume */ +intel_edp_psr_inactivate (dev, false); dev_priv->psr.setup_done = false; -intel_edp_psr_update (dev);/* only restore FBC info on the platform that supports FBC*/ intel_disable_fbc (dev);drivers/gpu/drm/i915/intel_display.c +1
-0@@ -4451,9 +4451,13 @@ static void intel_connector_check_state(struct intel_connector *connector)* consider. */ void intel_connector_dpms (struct drm_connector *connector,int mode) { +struct drm_device *dev = connector->dev;
Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c static void intel_connector_check_state(struct intel_connector *connector) · line 4459
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +3
-1+/* All the simple cases only support two dpms states. */ -if (mode !=DRM_MODE_DPMS_ON ) +if (mode !=DRM_MODE_DPMS_ON ) { mode =DRM_MODE_DPMS_OFF ; +intel_edp_psr_inactivate (dev, false);Maybe check if this connector even has PSR enabled?
the psr_inactivate already does that by checking psr.setup_done and psr.active.
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +1
-0+ }if (mode == connector->dpms)return ;@@ -7501,6 +7505,8 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible;
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c static void intel_crtc_update_cursor(struct drm_crtc *crtc, · line 7508
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +1
-0+intel_edp_psr_inactivate (dev, true);Don't need to inactivate unless the cursor is or was visible.
so, below next retur after check visible and cursor_visible should be enough, right?
Quoted 348 lines
Quoted 348 lines
drivers/gpu/drm/i915/intel_display.c +11
-0+if (on) base = intel_crtc->cursor_addr;@@ -8230,12 +8236,15 @@ void intel_mark_idle(struct drm_device *dev)gen6_rps_idle (dev->dev_private); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; +intel_edp_psr_inactivate (dev, true); +if (!i915.powersave)return ;@@ -8336,6 +8345,10 @@ static void do_intel_finish_page_flip(struct drm_device *dev,queue_work (dev_priv->wq, &work->work);trace_i915_flip_complete (intel_crtc->plane, work->pending_flip_obj); + +/* Get PSR back after set_domain inactivated it without rescheduling +* it back. */ +schedule_delayed_work (&dev_priv->psr.work,msecs_to_jiffies (5000 )); }void intel_finish_page_flip (struct drm_device *dev,int pipe)@@ -8688,6 +8701,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +intel_edp_psr_inactivate (dev, true); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;drivers/gpu/drm/i915/intel_dp.c +165
-35@@ -1578,21 +1578,35 @@ static void intel_dp_get_config(struct intel_encoder *encoder, } } -static bool is_edp_psr (struct drm_device *dev) +static bool is_edp_psr (struct intel_dp *intel_dp) +{ +return intel_dp->psr_dpcd[0 ] &DP_PSR_IS_SUPPORTED ; +} + +static bool vlv_edp_is_psr_enabled_on_pipe (struct drm_device *dev,int pipe) {struct drm_i915_private *dev_priv = dev->dev_private; +uint32_t val; -return dev_priv->psr.sink_support; + val =I915_READ (VLV_PSRSTAT (pipe)) & +VLV_EDP_PSR_CURR_STATE_MASK ; +return (val ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (val ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ); }static bool intel_edp_is_psr_enabled (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (!HAS_PSR (dev)) -return false; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) +return vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_A ) || +vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_B ); +else +return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } -return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +return false; } static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,@@ -1624,32 +1638,60 @@ static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,POSTING_READ (ctl_reg); } +static void intel_edp_psr_work (struct work_struct *work) +{ +struct drm_i915_private *dev_priv = +container_of (work,typeof (*dev_priv), psr.work.work); +struct drm_device *dev = dev_priv->dev; + +intel_edp_psr_update (dev); +} +static void intel_edp_psr_setup (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; +uint32_t val;if (dev_priv->psr.setup_done)return ; -mutex_init (&dev_priv->psr.lock); - -/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; -intel_edp_psr_write_vsc (intel_dp, &psr_vsc); - -/* Avoid continuous PSR exit by masking memup and hpd */ -I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | -EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); +if (IS_VALLEYVIEW (dev)) { + val =I915_READ (VLV_VSCSDP (PIPE_A )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_VSCSDP (PIPE_A ), val); + + val =I915_READ (VLV_VSCSDP (PIPE_B )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_VSCSDP (PIPE_B ), val); + }else { +/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; +intel_edp_psr_write_vsc (intel_dp, &psr_vsc); + +/* Avoid continuous PSR exit by masking memup and hpd */ +I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | +EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); + } dev_priv->psr.setup_done = true; } +static void vlv_edp_psr_enable_sink (struct intel_dp *intel_dp) +{ +/* Enable PSR in sink */ +intel_dp_aux_native_write_1 (intel_dp,DP_PSR_EN_CFG , +DP_PSR_ENABLE ); +} +static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1680,6 +1722,27 @@ static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT)); } +static void vlv_edp_psr_enable_source (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); + +uint32_t idle_frames =1 ; +uint32_t val =0 ; + + val |=VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; + + val |=VLV_EDP_PSR_MODE_HW_TIMER ; + val &= ~VLV_EDP_PSR_FRAME_COUNT_MASK ; + val |= idle_frames <<EDP_PSR_IDLE_FRAME_SHIFT ; + +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe), val); +} +static void intel_edp_psr_enable_source (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1721,8 +1784,8 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } -if ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || - (dig_port->port !=PORT_A )) { +if (HAS_DDI (dev) && ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || + (dig_port->port !=PORT_A ))) {DRM_DEBUG_KMS ("HSW ties PSR to DDI A (eDP)\n" );return false; }@@ -1767,23 +1830,45 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } +/* Baytrail supports per-pipe PSR configuration, however PSR on +* PIPE_B isn't working properly. So let's keep it disabled for now. */ +if (IS_VALLEYVIEW (dev) && intel_crtc->pipe !=PIPE_A ) { +DRM_DEBUG_KMS ("PSR on BYT isn't enabled on pipe B.\n" ); +return false; + } + dev_priv->psr.source_ok = true;return true; }static void intel_edp_psr_do_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); -if (!intel_edp_psr_match_conditions (intel_dp) || -intel_edp_is_psr_enabled (dev)) -return ; +if (IS_VALLEYVIEW (dev)) { +if (vlv_edp_is_psr_enabled_on_pipe (dev, intel_crtc->pipe)) +return ; + }else +if (intel_edp_is_psr_enabled (dev)) +return ;/* Enable PSR on the panel */ -intel_edp_psr_enable_sink (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_sink (intel_dp); +else +intel_edp_psr_enable_sink (intel_dp);/* Enable PSR on the host */ -intel_edp_psr_enable_source (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_source (intel_dp); +else +intel_edp_psr_enable_source (intel_dp); + + dev_priv->psr.active = true; }void intel_edp_psr_enable (struct intel_dp *intel_dp)@@ -1791,16 +1876,43 @@ void intel_edp_psr_enable(struct intel_dp *intel_dp)struct drm_device *dev =intel_dp_to_dev (intel_dp);struct drm_i915_private *dev_priv = dev->dev_private; +if (!is_edp_psr (intel_dp)) +return ; +/* Setup PSR once */ intel_edp_psr_setup (intel_dp);mutex_lock (&dev_priv->psr.lock); -if (intel_edp_psr_match_conditions (intel_dp) && - !intel_edp_is_psr_enabled (dev)) +if (intel_edp_psr_match_conditions (intel_dp))intel_edp_psr_do_enable (intel_dp);mutex_unlock (&dev_priv->psr.lock); } +void vlv_edp_psr_disable (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); +uint32_t val; + +if (!dev_priv->psr.setup_done) +return ; + +intel_edp_psr_inactivate (dev, false); + +if (wait_for ((I915_READ (VLV_PSRSTAT (intel_crtc->pipe)) & +VLV_EDP_PSR_IN_TRANS ) ==0 ,250 )) +WARN (1 ,"PSR transition took longer than expected\n" ); + + val =I915_READ (VLV_PSRCTL (intel_crtc->pipe)); + val &= ~VLV_EDP_PSR_ACTIVE_ENTRY ; + val &= ~VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe), val); +} +void intel_edp_psr_disable (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1823,6 +1935,7 @@ void intel_edp_psr_update(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct intel_encoder *encoder;struct intel_dp *intel_dp =NULL ; +struct intel_crtc *intel_crtc;if (!dev_priv->psr.setup_done)return ;@@ -1830,26 +1943,93 @@ void intel_edp_psr_update(struct drm_device *dev)list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head)if (encoder->type ==INTEL_OUTPUT_EDP ) { intel_dp =enc_to_intel_dp (&encoder->base); - -if (!is_edp_psr (dev)) -return ; + intel_crtc =to_intel_crtc (encoder->base.crtc);mutex_lock (&dev_priv->psr.lock); -if (!intel_edp_psr_match_conditions (intel_dp)) -intel_edp_psr_disable (intel_dp); -else +if (!intel_edp_psr_match_conditions (intel_dp)) { +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +else +intel_edp_psr_disable (intel_dp); + }else if (!intel_edp_is_psr_enabled (dev))intel_edp_psr_do_enable (intel_dp);mutex_unlock (&dev_priv->psr.lock); } } +void intel_edp_psr_do_inactivate (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_connector *connector; +struct intel_encoder *encoder; +struct intel_crtc *intel_crtc; +struct intel_dp *intel_dp =NULL ; + +list_for_each_entry (connector, &dev->mode_config.connector_list, + base.head) { + +if (connector->base.dpms !=DRM_MODE_DPMS_ON ) +continue ; + + encoder =to_intel_encoder (connector->base.encoder); +if (encoder->type ==INTEL_OUTPUT_EDP ) {
Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c void intel_edp_psr_update(struct drm_device *dev) · line 1979
Quoted 3 lines
drivers/gpu/drm/i915/intel_dp.c +3
-0+ + intel_dp =enc_to_intel_dp (&encoder->base); + intel_crtc =to_intel_crtc (encoder->base.crtc);Still digging through the encoder and crtc pointers w/o holding any modeset locks. Feels dangerous.
intel_edp_psr_match_conditions()does the same kind of stuff, and that too now gets called outside modeset codepaths.
I don't see an easy way to solve this with current sturcture here since we need the pipe and intel_dp pointer.
Maybe on the future rework putiing psr inside pipe_config and in a scruct with all needed info without require to interate anywhere. But on the current structure I don't see an easy solution, do you?
Quoted 28 lines
Quoted 28 lines
drivers/gpu/drm/i915/intel_dp.c +28
-0+ +if (!vlv_edp_is_psr_enabled_on_pipe (dev, + intel_crtc->pipe)) +continue ; + + dev_priv->psr.active = false; + +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe), +VLV_EDP_PSR_RESET ); +/* WaClearPSRReset:vlv */ +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe),0 ); + +intel_dp_sink_dpms (intel_dp,DRM_MODE_DPMS_ON ); + } + } +} + +void intel_edp_psr_inactivate (struct drm_device *dev,bool schedule_back) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +if (!IS_VALLEYVIEW (dev)) +return ; + +if (!dev_priv->psr.setup_done) +return ; + +/* If it was requested to not turn psr back delayed work must be
Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c void intel_edp_psr_update(struct drm_device *dev) · line 2013
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp.c +6
-0+* canceled even if it is already on inactivated state. */ +if (!schedule_back) +cancel_delayed_work_sync (&dev_priv->psr.work); + +if (!dev_priv->psr.active) +return ;What if psr gets re-activated just after you checked above?
Shouldn't be dangerus... psr.activate idea is to minimize I915_WRITE, mainly when calling busy ioctls in sequence...
But I'm open to suggestions.
Quoted 35 lines
Quoted 35 lines
drivers/gpu/drm/i915/intel_dp.c +14
-0+ +cancel_delayed_work_sync (&dev_priv->psr.work); + +intel_edp_psr_do_inactivate (dev); + +if (schedule_back) +schedule_delayed_work (&dev_priv->psr.work, +msecs_to_jiffies (5000 )); +} +static void intel_disable_dp (struct intel_encoder *encoder) {struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);enum port port =dp_to_dig_port (intel_dp)->port;struct drm_device *dev = encoder->base.dev; +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +/* Make sure the panel is off before trying to change the mode. But also * ensure that we have vdd while we switch off the panel. */ intel_edp_backlight_off (intel_dp);@@ -1906,6 +2086,7 @@ static void vlv_enable_dp(struct intel_encoder *encoder)struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);intel_edp_backlight_on (intel_dp); +intel_edp_psr_enable (intel_dp); }static void g4x_pre_enable_dp (struct intel_encoder *encoder)@@ -3846,8 +4027,11 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,BUG (); }
Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c intel_dp_init_connector(struct intel_digital_port *intel_dig_port, · line 4033
Quoted 5 lines
drivers/gpu/drm/i915/intel_dp.c +3
-1-if (is_edp (intel_dp)) +if (is_edp (intel_dp)) {intel_dp_init_panel_power_sequencer (dev, intel_dp, &power_seq); +INIT_DELAYED_WORK (&dev_priv->psr.work, intel_edp_psr_work); +mutex_init (&dev_priv->psr.lock);Initializing global state from a per-connector init function seems a bit weird.
I thought it as well, but didn't find another place. My first attempt was at psr_setup, but it is called again after suspend/resume and it was breaking things up. suggestions?
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/i915/intel_dp.c +1
-0+ } error =intel_dp_i2c_init (intel_dp, intel_connector, name); WARN(error, "intel_dp_i2c_init failed with error %d for port %c\n",drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev,bool schedule_back);
Quoted 7 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_drv.h +0
-1/* intel_dsi.c */ --1.8.1.2
--
Ville Syrjälä
Intel OTC
Hi Ville, thank you very much for your comments. Coding is improving a lot along with stability here.
Please help me to get this structure merged than we rework all psr later to avoid that loop over connectors and encoders....
Thanks,
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Re: [PATCH 2/2] drm/i915: Add Baytrail PSR Support.
Quoted 138 lines · Rodrigo Vivi
Quoted 125 lines · Ville Syrjälä
Quoted 124 lines · Rodrigo Vivi
This patch adds PSR Support to Baytrail.
Baytrail cannot easily detect screen updates and force PSR exit. So we inactivate it on {
busy_ioctl,set_domain,sw_finishandmark_busy} and update to enable it back on next displaymark_idle.v2: Also inactivate PSR on cursor update.
v3: Inactivate PSR onmark_busy,dset_domainandsw_finish_ioctl, and
early on page flip besides avoid initializing inactive/active flag more than once.
v4: Fix identation issues.
v5: Rebase and add Baytrail per pipe support although leavingPIPE_B
support disabled by for now since it isn't working properly yet.
v6: Removing forgotten comment and useless clkgating definition.
v7: Remove inactivate fromset_domain. Chris warned this was semanticaly
wrong.
v8: Accept Ville's suggestions: Use register's names matching spec and
warn if transition took longer than it should.
v9: New version with delayed work to get PSR back. Disabling it on
set_domainbut not rescheduing it back until nextfinish_page_flip.Cc Chris Wilson <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 36 ++++- drivers/gpu/drm/i915/i915_drv.h | 5 +- drivers/gpu/drm/i915/i915_gem.c | 12 ++ drivers/gpu/drm/i915/i915_reg.h | 37 +++++ drivers/gpu/drm/i915/i915_suspend.c | 2 +- drivers/gpu/drm/i915/intel_display.c | 18 ++- drivers/gpu/drm/i915/intel_dp.c | 256 ++++++++++++++++++++++++++++++----- drivers/gpu/drm/i915/intel_drv.h | 1 + 8 files changed, 323 insertions(+), 44 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +31
-5@@ -1900,6 +1900,8 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 psrperf =0 ; +u32 statA =0 ; +u32 statB =0 ;bool enabled = false;intel_runtime_pm_get (dev_priv);@@ -1907,14 +1909,38 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)seq_printf (m,"Sink_Support: %s\n" ,yesno (dev_priv->psr.sink_support));seq_printf (m,"Source_OK: %s\n" ,yesno (dev_priv->psr.source_ok)); - enabled =HAS_PSR (dev) && -I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; -seq_printf (m,"Enabled: %s\n" ,yesno (enabled)); +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) { + statA =I915_READ (VLV_PSRSTAT (PIPE_A )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + statB =I915_READ (VLV_PSRSTAT (PIPE_B )) & +VLV_EDP_PSR_CURR_STATE_MASK ; + enabled = ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ) || + (statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )); + }else + enabled =I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } +seq_printf (m,"Enabled: %s" ,yesno (enabled)); -if (HAS_PSR (dev)) +if (IS_VALLEYVIEW (dev)) { +if ((statA ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statA ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe A" ); +if ((statB ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (statB ==VLV_EDP_PSR_ACTIVE_SF_UPDATE )) +seq_puts (m," pipe B" ); + } + +seq_puts (m,"\n" ); + +/* VLV PSR has no kind of performance counter */ +if (HAS_PSR (dev) && !IS_VALLEYVIEW (dev)) { psrperf =I915_READ (EDP_PSR_PERF_CNT (dev)) &EDP_PSR_PERF_CNT_MASK ; -seq_printf (m,"Performance_Counter: %u\n" , psrperf); +seq_printf (m,"Performance_Counter: %u\n" , psrperf); + }intel_runtime_pm_put (dev_priv);return 0 ;drivers/gpu/drm/i915/i915_drv.h +4
-1@@ -747,7 +747,9 @@ struct i915_psr {bool sink_support;bool source_ok;bool setup_done; +bool active;struct mutex lock; +struct delayed_work work; };enum intel_pch {@@ -1867,7 +1869,8 @@ struct drm_i915_file_private {#define HAS_DDI (dev) (INTEL_INFO(dev)->has_ddi)#define HAS_FPGA_DBG_UNCLAIMED (dev) (INTEL_INFO(dev)->has_fpga_dbg) -#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev)) +#define HAS_PSR (dev) (IS_HASWELL(dev) || IS_BROADWELL(dev) || \ + IS_VALLEYVIEW(dev))#define HAS_PC8 (dev) (IS_HASWELL(dev))/* XXX HSW:ULX */ #define HAS_RUNTIME_PM (dev) (IS_HASWELL(dev))drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -1256,6 +1256,14 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, goto unlock; }Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, · line 1265
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c +7
-0+/* Here we don't reschedule work to get PSR back because userspace +* can set domain and take as much as time it wants to write it. +* We only reschedule it back on next finish_page_flip. There is the +* risk of PSR be inactive forever depending on how compositor works, +* but this is the safest way to avoid loosing screen updates. +*/ +intel_edp_psr_inactivate (dev, false);This will still block until PSR is deactivated (aux communication and all). That still seems like a bad idea to do while holding
struct_mutex.
Quoted 1 line
So, what do you suggest here?
Same as before. The disabling could be done from a workqueue.
Quoted 104 lines
Quoted 95 lines
Quoted 95 lines
drivers/gpu/drm/i915/i915_gem.c +5
-0+/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped. @@ -1299,6 +1307,8 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +intel_edp_psr_inactivate (dev, true); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;@@ -4059,6 +4069,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,if (ret)return ret; +intel_edp_psr_inactivate (dev, true); + obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle));if (&obj->base ==NULL ) { ret = -ENOENT ;drivers/gpu/drm/i915/i915_reg.h +37
-0@@ -1968,6 +1968,43 @@#define BCLRPAT (pipe) _PIPE(pipe, _BCLRPAT_A, _BCLRPAT_B)#define VSYNCSHIFT (trans) _TRANSCODER(trans, _VSYNCSHIFT_A, _VSYNCSHIFT_B) +/* VLV eDP PSR registers */ +#define _PSRCTLA (VLV_DISPLAY_BASE + 0x60090) +#define _PSRCTLB (VLV_DISPLAY_BASE + 0x61090) +#define VLV_EDP_PSR_ENABLE (1<<0) +#define VLV_EDP_PSR_RESET (1<<1) +#define VLV_EDP_PSR_MODE_MASK (7<<2) +#define VLV_EDP_PSR_MODE_HW_TIMER (1<<3) +#define VLV_EDP_PSR_MODE_SW_TIMER (1<<2) +#define VLV_EDP_PSR_SINGLE_FRAME_UPDATE (1<<7) +#define VLV_EDP_PSR_ACTIVE_ENTRY (1<<8) +#define VLV_EDP_PSR_SRC_TRANSMITTER_STATE (1<<9) +#define VLV_EDP_PSR_DBL_FRAME (1<<10) +#define VLV_EDP_PSR_FRAME_COUNT_MASK (0xff<<16) +#define VLV_EDP_PSR_IDLE_FRAME_SHIFT 16 +#define VLV_EDP_PSR_INT_TRANSITION (1<<24) +#define VLV_PSRCTL (pipe) _PIPE(pipe, _PSRCTLA, _PSRCTLB) + +#define _VSCSDPA (VLV_DISPLAY_BASE + 0x600a0) +#define _VSCSDPB (VLV_DISPLAY_BASE + 0x610a0) +#define VLV_EDP_PSR_SDP_FREQ_MASK (3<<30) +#define VLV_EDP_PSR_SDP_FREQ_ONCE (1<<31) +#define VLV_EDP_PSR_SDP_FREQ_EVFRAME (1<<30) +#define VLV_VSCSDP (pipe) _PIPE(pipe, _VSCSDPA, _VSCSDPB) + +#define _PSRSTATA (VLV_DISPLAY_BASE + 0x60094) +#define _PSRSTATB (VLV_DISPLAY_BASE + 0x61094) +#define VLV_EDP_PSR_LAST_STATE_MASK (7<<3) +#define VLV_EDP_PSR_CURR_STATE_MASK 7 +#define VLV_EDP_PSR_DISABLED (0<<0) +#define VLV_EDP_PSR_INACTIVE (1<<0) +#define VLV_EDP_PSR_IN_TRANS_TO_ACTIVE (2<<0) +#define VLV_EDP_PSR_ACTIVE_NORFB_UP (3<<0) +#define VLV_EDP_PSR_ACTIVE_SF_UPDATE (4<<0) +#define VLV_EDP_PSR_EXIT (5<<0) +#define VLV_EDP_PSR_IN_TRANS (1<<7) +#define VLV_PSRSTAT (pipe) _PIPE(pipe, _PSRSTATA, _PSRSTATB) +/* HSW+ eDP PSR registers */ #define EDP_PSR_BASE (dev) (IS_HASWELL(dev) ? 0x64800 : 0x6f800)#define EDP_PSR_CTL (dev) (EDP_PSR_BASE(dev) + 0)drivers/gpu/drm/i915/i915_suspend.c +1
-1@@ -289,8 +289,8 @@ static void i915_restore_display(struct drm_device *dev) }/* Force a full PSR setup on resume */ +intel_edp_psr_inactivate (dev, false); dev_priv->psr.setup_done = false; -intel_edp_psr_update (dev);/* only restore FBC info on the platform that supports FBC*/ intel_disable_fbc (dev);drivers/gpu/drm/i915/intel_display.c +1
-0@@ -4451,9 +4451,13 @@ static void intel_connector_check_state(struct intel_connector *connector)* consider. */ void intel_connector_dpms (struct drm_connector *connector,int mode) { +struct drm_device *dev = connector->dev;Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c static void intel_connector_check_state(struct intel_connector *connector) · line 4459
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +3
-1+/* All the simple cases only support two dpms states. */ -if (mode !=DRM_MODE_DPMS_ON ) +if (mode !=DRM_MODE_DPMS_ON ) { mode =DRM_MODE_DPMS_OFF ; +intel_edp_psr_inactivate (dev, false);Maybe check if this connector even has PSR enabled?
Quoted 1 line
the
psr_inactivatealready does that by checking psr.setup_done and psr.active.
I meant that it will now disable PSR for all displays even if the DPMS mode was changed for some other display. Well, I guess it's somewhat rare to only do DPMS for a subset of active displays.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +1
-0+ }if (mode == connector->dpms)return ;@@ -7501,6 +7505,8 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,u32 base =0 , pos =0 ;bool visible;
Quoted 6 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c static void intel_crtc_update_cursor(struct drm_crtc *crtc, · line 7508
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +1
-0+intel_edp_psr_inactivate (dev, true);Don't need to inactivate unless the cursor is or was visible.
so, below next retur after check visible and
cursor_visibleshould be enough, right?
Yeah that should be fine.
Quoted 357 lines
Quoted 348 lines
Quoted 348 lines
drivers/gpu/drm/i915/intel_display.c +11
-0+if (on) base = intel_crtc->cursor_addr;@@ -8230,12 +8236,15 @@ void intel_mark_idle(struct drm_device *dev)gen6_rps_idle (dev->dev_private); } +void intel_mark_fb_busy (struct drm_i915_gem_object *obj,struct intel_ring_buffer *ring) {struct drm_device *dev = obj->base.dev;struct drm_crtc *crtc; +intel_edp_psr_inactivate (dev, true); +if (!i915.powersave)return ;@@ -8336,6 +8345,10 @@ static void do_intel_finish_page_flip(struct drm_device *dev,queue_work (dev_priv->wq, &work->work);trace_i915_flip_complete (intel_crtc->plane, work->pending_flip_obj); + +/* Get PSR back after set_domain inactivated it without rescheduling +* it back. */ +schedule_delayed_work (&dev_priv->psr.work,msecs_to_jiffies (5000 )); }void intel_finish_page_flip (struct drm_device *dev,int pipe)@@ -8688,6 +8701,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,if (work ==NULL )return -ENOMEM ; +/* Inactivate PSR early in page flip */ +intel_edp_psr_inactivate (dev, true); + work->event = event; work->crtc = crtc; work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;drivers/gpu/drm/i915/intel_dp.c +165
-35@@ -1578,21 +1578,35 @@ static void intel_dp_get_config(struct intel_encoder *encoder, } } -static bool is_edp_psr (struct drm_device *dev) +static bool is_edp_psr (struct intel_dp *intel_dp) +{ +return intel_dp->psr_dpcd[0 ] &DP_PSR_IS_SUPPORTED ; +} + +static bool vlv_edp_is_psr_enabled_on_pipe (struct drm_device *dev,int pipe) {struct drm_i915_private *dev_priv = dev->dev_private; +uint32_t val; -return dev_priv->psr.sink_support; + val =I915_READ (VLV_PSRSTAT (pipe)) & +VLV_EDP_PSR_CURR_STATE_MASK ; +return (val ==VLV_EDP_PSR_ACTIVE_NORFB_UP ) || + (val ==VLV_EDP_PSR_ACTIVE_SF_UPDATE ); }static bool intel_edp_is_psr_enabled (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (!HAS_PSR (dev)) -return false; +if (HAS_PSR (dev)) { +if (IS_VALLEYVIEW (dev)) +return vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_A ) || +vlv_edp_is_psr_enabled_on_pipe (dev,PIPE_B ); +else +return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; + } -return I915_READ (EDP_PSR_CTL (dev)) &EDP_PSR_ENABLE ; +return false; } static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,@@ -1624,32 +1638,60 @@ static void intel_edp_psr_write_vsc(struct intel_dp *intel_dp,POSTING_READ (ctl_reg); } +static void intel_edp_psr_work (struct work_struct *work) +{ +struct drm_i915_private *dev_priv = +container_of (work,typeof (*dev_priv), psr.work.work); +struct drm_device *dev = dev_priv->dev; + +intel_edp_psr_update (dev); +} +static void intel_edp_psr_setup (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct edp_vsc_psr psr_vsc; +uint32_t val;if (dev_priv->psr.setup_done)return ; -mutex_init (&dev_priv->psr.lock); - -/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; -intel_edp_psr_write_vsc (intel_dp, &psr_vsc); - -/* Avoid continuous PSR exit by masking memup and hpd */ -I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | -EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); +if (IS_VALLEYVIEW (dev)) { + val =I915_READ (VLV_VSCSDP (PIPE_A )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_VSCSDP (PIPE_A ), val); + + val =I915_READ (VLV_VSCSDP (PIPE_B )); + val &= ~VLV_EDP_PSR_SDP_FREQ_MASK ; + val |=VLV_EDP_PSR_SDP_FREQ_EVFRAME ; +I915_WRITE (VLV_VSCSDP (PIPE_B ), val); + }else { +/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; +intel_edp_psr_write_vsc (intel_dp, &psr_vsc); + +/* Avoid continuous PSR exit by masking memup and hpd */ +I915_WRITE (EDP_PSR_DEBUG_CTL (dev),EDP_PSR_DEBUG_MASK_MEMUP | +EDP_PSR_DEBUG_MASK_HPD |EDP_PSR_DEBUG_MASK_LPSP ); + } dev_priv->psr.setup_done = true; } +static void vlv_edp_psr_enable_sink (struct intel_dp *intel_dp) +{ +/* Enable PSR in sink */ +intel_dp_aux_native_write_1 (intel_dp,DP_PSR_EN_CFG , +DP_PSR_ENABLE ); +} +static void intel_edp_psr_enable_sink (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1680,6 +1722,27 @@ static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp) (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT)); } +static void vlv_edp_psr_enable_source (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); + +uint32_t idle_frames =1 ; +uint32_t val =0 ; + + val |=VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; + + val |=VLV_EDP_PSR_MODE_HW_TIMER ; + val &= ~VLV_EDP_PSR_FRAME_COUNT_MASK ; + val |= idle_frames <<EDP_PSR_IDLE_FRAME_SHIFT ; + +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe), val); +} +static void intel_edp_psr_enable_source (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1721,8 +1784,8 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } -if ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || - (dig_port->port !=PORT_A )) { +if (HAS_DDI (dev) && ((intel_encoder->type !=INTEL_OUTPUT_EDP ) || + (dig_port->port !=PORT_A ))) {DRM_DEBUG_KMS ("HSW ties PSR to DDI A (eDP)\n" );return false; }@@ -1767,23 +1830,45 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)return false; } +/* Baytrail supports per-pipe PSR configuration, however PSR on +* PIPE_B isn't working properly. So let's keep it disabled for now. */ +if (IS_VALLEYVIEW (dev) && intel_crtc->pipe !=PIPE_A ) { +DRM_DEBUG_KMS ("PSR on BYT isn't enabled on pipe B.\n" ); +return false; + } + dev_priv->psr.source_ok = true;return true; }static void intel_edp_psr_do_enable (struct intel_dp *intel_dp) { -struct drm_device *dev =intel_dp_to_dev (intel_dp); +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); -if (!intel_edp_psr_match_conditions (intel_dp) || -intel_edp_is_psr_enabled (dev)) -return ; +if (IS_VALLEYVIEW (dev)) { +if (vlv_edp_is_psr_enabled_on_pipe (dev, intel_crtc->pipe)) +return ; + }else +if (intel_edp_is_psr_enabled (dev)) +return ;/* Enable PSR on the panel */ -intel_edp_psr_enable_sink (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_sink (intel_dp); +else +intel_edp_psr_enable_sink (intel_dp);/* Enable PSR on the host */ -intel_edp_psr_enable_source (intel_dp); +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_enable_source (intel_dp); +else +intel_edp_psr_enable_source (intel_dp); + + dev_priv->psr.active = true; }void intel_edp_psr_enable (struct intel_dp *intel_dp)@@ -1791,16 +1876,43 @@ void intel_edp_psr_enable(struct intel_dp *intel_dp)struct drm_device *dev =intel_dp_to_dev (intel_dp);struct drm_i915_private *dev_priv = dev->dev_private; +if (!is_edp_psr (intel_dp)) +return ; +/* Setup PSR once */ intel_edp_psr_setup (intel_dp);mutex_lock (&dev_priv->psr.lock); -if (intel_edp_psr_match_conditions (intel_dp) && - !intel_edp_is_psr_enabled (dev)) +if (intel_edp_psr_match_conditions (intel_dp))intel_edp_psr_do_enable (intel_dp);mutex_unlock (&dev_priv->psr.lock); } +void vlv_edp_psr_disable (struct intel_dp *intel_dp) +{ +struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); +struct drm_device *dev = intel_dig_port->base.base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_crtc *intel_crtc = +to_intel_crtc (intel_dig_port->base.base.crtc); +uint32_t val; + +if (!dev_priv->psr.setup_done) +return ; + +intel_edp_psr_inactivate (dev, false); + +if (wait_for ((I915_READ (VLV_PSRSTAT (intel_crtc->pipe)) & +VLV_EDP_PSR_IN_TRANS ) ==0 ,250 )) +WARN (1 ,"PSR transition took longer than expected\n" ); + + val =I915_READ (VLV_PSRCTL (intel_crtc->pipe)); + val &= ~VLV_EDP_PSR_ACTIVE_ENTRY ; + val &= ~VLV_EDP_PSR_ENABLE ; + val &= ~VLV_EDP_PSR_MODE_MASK ; +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe), val); +} +void intel_edp_psr_disable (struct intel_dp *intel_dp) {struct drm_device *dev =intel_dp_to_dev (intel_dp);@@ -1823,6 +1935,7 @@ void intel_edp_psr_update(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct intel_encoder *encoder;struct intel_dp *intel_dp =NULL ; +struct intel_crtc *intel_crtc;if (!dev_priv->psr.setup_done)return ;@@ -1830,26 +1943,93 @@ void intel_edp_psr_update(struct drm_device *dev)list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head)if (encoder->type ==INTEL_OUTPUT_EDP ) { intel_dp =enc_to_intel_dp (&encoder->base); - -if (!is_edp_psr (dev)) -return ; + intel_crtc =to_intel_crtc (encoder->base.crtc);mutex_lock (&dev_priv->psr.lock); -if (!intel_edp_psr_match_conditions (intel_dp)) -intel_edp_psr_disable (intel_dp); -else +if (!intel_edp_psr_match_conditions (intel_dp)) { +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +else +intel_edp_psr_disable (intel_dp); + }else if (!intel_edp_is_psr_enabled (dev))intel_edp_psr_do_enable (intel_dp);mutex_unlock (&dev_priv->psr.lock); } } +void intel_edp_psr_do_inactivate (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_connector *connector; +struct intel_encoder *encoder; +struct intel_crtc *intel_crtc; +struct intel_dp *intel_dp =NULL ; + +list_for_each_entry (connector, &dev->mode_config.connector_list, + base.head) { + +if (connector->base.dpms !=DRM_MODE_DPMS_ON ) +continue ; + + encoder =to_intel_encoder (connector->base.encoder); +if (encoder->type ==INTEL_OUTPUT_EDP ) {Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c void intel_edp_psr_update(struct drm_device *dev) · line 1979
Quoted 3 lines
drivers/gpu/drm/i915/intel_dp.c +3
-0+ + intel_dp =enc_to_intel_dp (&encoder->base); + intel_crtc =to_intel_crtc (encoder->base.crtc);Still digging through the encoder and crtc pointers w/o holding any modeset locks. Feels dangerous.
intel_edp_psr_match_conditions()does the same kind of stuff, and that too now gets called outside modeset codepaths.
Quoted 5 lines
I don't see an easy way to solve this with current sturcture here since we need the pipe and
intel_dppointer.
Maybe on the future rework putiing psr insidepipe_configand in a scruct with all needed info without require to interate anywhere. But on the current structure I don't see an easy solution, do you?
Well, if it was done from a workqueue anyway, it could just grab all modeset locks. Would just need to make sure we wouldn't cause deadlocks by doing that.
Quoted 38 lines
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/i915/intel_dp.c +28
-0+ +if (!vlv_edp_is_psr_enabled_on_pipe (dev, + intel_crtc->pipe)) +continue ; + + dev_priv->psr.active = false; + +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe), +VLV_EDP_PSR_RESET ); +/* WaClearPSRReset:vlv */ +I915_WRITE (VLV_PSRCTL (intel_crtc->pipe),0 ); + +intel_dp_sink_dpms (intel_dp,DRM_MODE_DPMS_ON ); + } + } +} + +void intel_edp_psr_inactivate (struct drm_device *dev,bool schedule_back) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +if (!IS_VALLEYVIEW (dev)) +return ; + +if (!dev_priv->psr.setup_done) +return ; + +/* If it was requested to not turn psr back delayed work must be Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c void intel_edp_psr_update(struct drm_device *dev) · line 2013
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp.c +6
-0+* canceled even if it is already on inactivated state. */ +if (!schedule_back) +cancel_delayed_work_sync (&dev_priv->psr.work); + +if (!dev_priv->psr.active) +return ;What if psr gets re-activated just after you checked above?
Quoted 3 lines
Shouldn't be dangerus... psr.activate idea is to minimize
I915_WRITE, mainly when calling busy ioctls in sequence...
But I'm open to suggestions.
I think if this did happen and there are no more updates to the screen for a while, this would leave PSR enabled, with potentially stale screen contents.
Quoted 45 lines
Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/i915/intel_dp.c +14
-0+ +cancel_delayed_work_sync (&dev_priv->psr.work); + +intel_edp_psr_do_inactivate (dev); + +if (schedule_back) +schedule_delayed_work (&dev_priv->psr.work, +msecs_to_jiffies (5000 )); +} +static void intel_disable_dp (struct intel_encoder *encoder) {struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);enum port port =dp_to_dig_port (intel_dp)->port;struct drm_device *dev = encoder->base.dev; +if (IS_VALLEYVIEW (dev)) +vlv_edp_psr_disable (intel_dp); +/* Make sure the panel is off before trying to change the mode. But also * ensure that we have vdd while we switch off the panel. */ intel_edp_backlight_off (intel_dp);@@ -1906,6 +2086,7 @@ static void vlv_enable_dp(struct intel_encoder *encoder)struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);intel_edp_backlight_on (intel_dp); +intel_edp_psr_enable (intel_dp); }static void g4x_pre_enable_dp (struct intel_encoder *encoder)@@ -3846,8 +4027,11 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,BUG (); }Quoted 8 lines
drivers/gpu/drm/i915/intel_dp.c intel_dp_init_connector(struct intel_digital_port *intel_dig_port, · line 4033
Quoted 5 lines
drivers/gpu/drm/i915/intel_dp.c +3
-1-if (is_edp (intel_dp)) +if (is_edp (intel_dp)) {intel_dp_init_panel_power_sequencer (dev, intel_dp, &power_seq); +INIT_DELAYED_WORK (&dev_priv->psr.work, intel_edp_psr_work); +mutex_init (&dev_priv->psr.lock);Initializing global state from a per-connector init function seems a bit weird.
Quoted 4 lines
I thought it as well, but didn't find another place. My first attempt was at
psr_setup, but it is called again after suspend/resume and it was breaking things up. suggestions?
Some modeset init function sounds like the right place.
Quoted 35 lines
Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/i915/intel_dp.c +1
-0+ } error =intel_dp_i2c_init (intel_dp, intel_connector, name); WARN(error, "intel_dp_i2c_init failed with error %d for port %c\n",drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -748,6 +748,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);void intel_edp_psr_enable (struct intel_dp *intel_dp);void intel_edp_psr_disable (struct intel_dp *intel_dp);void intel_edp_psr_update (struct drm_device *dev); +void intel_edp_psr_inactivate (struct drm_device *dev,bool schedule_back);Quoted 7 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_drv.h +0
-1/* intel_dsi.c */ --1.8.1.2
--
Ville Syrjälä
Intel OTCHi Ville, thank you very much for your comments. Coding is improving a lot along with stability here.
Please help me to get this structure merged than we rework all psr later to avoid that loop over connectors and encoders....Thanks,
Signature · 2 lines
Rodrigo Vivi Blog: http://blog.vivi.eng.br
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH] drm/i915: Add Baytrail PSR Support.
In reply to Ville SyrjäläQuoted 5 lines · Ville Syrjälä
I think once we get to working on D0i2, we'll need to move the PSR wakeup to happen from a workqueue since it essentially requires a full modeset. Even now in your code it's somewhat questionable since you're doing stuff like aux transfers while holding
struct_mutex.
Imo we can fix this up later on by pushing it into a workqueue. It's not great that we block while hodling struct_mutex, but imo there's too many loose pieces around psr so I prefer we start by merging something pessimistic, but known to work properly. Then we can tune and improve with the knowledge that the crc testcase will catch regressions.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/1 drm/i915: Set primary plane enable at dpcntrl.
In reply to Rodrigo ViviThis patch allows system to safely recover after kms_psr_sink_crc check or any other similar case that might fail when PSR is enabled.
Ville made and sent me this patch after noticing that primary plane enabled bit was set during test case and unset after failure. What was causing a hard and non-recoverable blank screen.
After the failure when alternating from fbcon to x section it was possible to see and move mouse cursor, but nothing else. Everything else was fully black. A for dpms off/on also haleped to get screen back. But this patch seeting primary plane enabled bit propertly seemed more clean.
v2: Fix identation issue.
--- drivers/gpu/drm/i915/intel_display.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/intel_display.c +11 -0
@@ -2095,6 +2095,9 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,if (IS_G4X (dev)) dspcntr |=DISPPLANE_TRICKLE_FEED_DISABLE ; +if (intel_crtc->primary_enabled) + dspcntr |=DISPLAY_PLANE_ENABLE ; +I915_WRITE (reg, dspcntr); linear_offset = y * fb->pitches[0 ] + x * (fb->bits_per_pixel /8 );
@@ -2192,6 +2195,9 @@ static int ironlake_update_plane(struct drm_crtc *crtc,else dspcntr |=DISPPLANE_TRICKLE_FEED_DISABLE ; +if (intel_crtc->primary_enabled) + dspcntr |=DISPLAY_PLANE_ENABLE ; +I915_WRITE (reg, dspcntr); linear_offset = y * fb->pitches[0 ] + x * (fb->bits_per_pixel /8 );
@@ -8586,6 +8592,11 @@ static int intel_gen7_queue_flip(struct drm_device *dev,intel_ring_emit (ring,i915_gem_obj_ggtt_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring, (MI_NOOP )); +if (IS_VALLEYVIEW (dev) && intel_crtc->primary_enabled) +I915_WRITE (DSPCNTR (intel_crtc->plane), +I915_READ (DSPCNTR (intel_crtc->plane)) + |DISPLAY_PLANE_ENABLE ); +intel_mark_page_flip_active (intel_crtc);__intel_ring_advance (ring);return 0 ;
Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 45 lines · Rodrigo Vivi
This patch allows system to safely recover after
kms_psr_sink_crccheck or any other similar case that might fail when PSR is enabled.Ville made and sent me this patch after noticing that primary plane enabled bit was set during test case and unset after failure. What was causing a hard and non-recoverable blank screen.
After the failure when alternating from fbcon to x section it was possible to see and move mouse cursor, but nothing else. Everything else was fully black. A for dpms off/on also haleped to get screen back. But this patch seeting primary plane enabled bit propertly seemed more clean.
v2: Fix identation issue.
Cc Ville Syrjälä <[email protected]>Signed-off-by Rodrigo Vivi <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/gpu/drm/i915/intel_display.c +6
-0@@ -2095,6 +2095,9 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,if (IS_G4X (dev)) dspcntr |=DISPPLANE_TRICKLE_FEED_DISABLE ; +if (intel_crtc->primary_enabled) + dspcntr |=DISPLAY_PLANE_ENABLE ; +I915_WRITE (reg, dspcntr); linear_offset = y * fb->pitches[0 ] + x * (fb->bits_per_pixel /8 );@@ -2192,6 +2195,9 @@ static int ironlake_update_plane(struct drm_crtc *crtc,else dspcntr |=DISPPLANE_TRICKLE_FEED_DISABLE ; +if (intel_crtc->primary_enabled) + dspcntr |=DISPLAY_PLANE_ENABLE ; +I915_WRITE (reg, dspcntr); linear_offset = y * fb->pitches[0 ] + x * (fb->bits_per_pixel /8 );
drivers/gpu/drm/i915/intel_display.c static int intel_gen7_queue_flip(struct drm_device *dev, · line 8598
Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +4
-0@@ -8586,6 +8592,11 @@ static int intel_gen7_queue_flip(struct drm_device *dev,intel_ring_emit (ring,i915_gem_obj_ggtt_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring, (MI_NOOP )); +if (IS_VALLEYVIEW (dev) && intel_crtc->primary_enabled) +I915_WRITE (DSPCNTR (intel_crtc->plane), +I915_READ (DSPCNTR (intel_crtc->plane)) + |DISPLAY_PLANE_ENABLE );
We should add some kind of big comment that this ugly hack is here for PSR. I assume we're going to remove it eventually once someone figures out why the port/pipe/PLL aren't shutting down during PSR. To wake the hardware back from that state takes a lot more than just flipping a plane enable bit.
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +1
-0+intel_mark_page_flip_active (intel_crtc);__intel_ring_advance (ring);return 0 ;Signature · 1 line
1.8.1.2
Signature · 2 lines
Ville Syrjälä Intel OTC
PATCH 1/4 drm/i915: Set primary plane enable at dpcntrl.
This patch allows system to safely recover after kms_psr_sink_crc check or any other similar case that might fail when PSR is enabled.
Ville made and sent me this patch after noticing that primary plane enabled bit was set during test case and unset after failure. What was causing a hard and non-recoverable blank screen.
After the failure when alternating from fbcon to x section it was possible to see and move mouse cursor, but nothing else. Everything else was fully black. A for dpms off/on also haleped to get screen back. But this patch seeting primary plane enabled bit propertly seemed more clean.
v2: Fix identation issue.
v3: Add the XXX comment.
--- drivers/gpu/drm/i915/intel_display.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/intel_display.c +13 -0
@@ -2095,6 +2095,9 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,if (IS_G4X (dev)) dspcntr |=DISPPLANE_TRICKLE_FEED_DISABLE ; +if (intel_crtc->primary_enabled) + dspcntr |=DISPLAY_PLANE_ENABLE ; +I915_WRITE (reg, dspcntr); linear_offset = y * fb->pitches[0 ] + x * (fb->bits_per_pixel /8 );
@@ -2192,6 +2195,9 @@ static int ironlake_update_plane(struct drm_crtc *crtc,else dspcntr |=DISPPLANE_TRICKLE_FEED_DISABLE ; +if (intel_crtc->primary_enabled) + dspcntr |=DISPLAY_PLANE_ENABLE ; +I915_WRITE (reg, dspcntr); linear_offset = y * fb->pitches[0 ] + x * (fb->bits_per_pixel /8 );
@@ -8625,6 +8631,13 @@ static int intel_gen7_queue_flip(struct drm_device *dev,intel_ring_emit (ring,i915_gem_obj_ggtt_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring, (MI_NOOP )); +/* XXX: Ugly hack to avoid PSR test case eventually breaking things up +* to be removed whenever it is fixed. */ +if (IS_VALLEYVIEW (dev) && intel_crtc->primary_enabled) +I915_WRITE (DSPCNTR (intel_crtc->plane), +I915_READ (DSPCNTR (intel_crtc->plane)) + |DISPLAY_PLANE_ENABLE ); +intel_mark_page_flip_active (intel_crtc);__intel_ring_advance (ring);return 0 ;
Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx