Finally fix watermarks
Subsystems (3)
v12 cover Finally fix watermarks
Patches that actually changed (please re-review:
drm/i915/gen6+: Interpret mailbox error flags drm/i915/skl: Add support for the SAGV, fix underrun hangs drm/i915/skl: Update DDB values atomically with wms/plane attrs
Everything else is the same. Updated version of
https://patchwork.freedesktop.org/series/10276/
Lyude (6):
drm/i915/gen6+: Interpret mailbox error flags drm/i915/skl: Add support for the SAGV, fix underrun hangs drm/i915/skl: Update plane watermarks atomically during plane updates drm/i915/skl: Ensure pipes with changed wms get added to the state drm/i915: Move CRTC updating in atomic_commit into it's own hook drm/i915/skl: Update DDB values atomically with wms/plane attrs
Matt Roper (1):
drm/i915/gen9: Only copy WM results for changed pipes to skl_hw
drivers/gpu/drm/i915/i915_drv.h | 9 + drivers/gpu/drm/i915/i915_reg.h | 13 + drivers/gpu/drm/i915/intel_display.c | 190 +++++++++++--- drivers/gpu/drm/i915/intel_drv.h | 15 ++ drivers/gpu/drm/i915/intel_pm.c | 473 +++++++++++++++++++++++------------ drivers/gpu/drm/i915/intel_sprite.c | 6 + 6 files changed, 512 insertions(+), 194 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v12 1/7 drm/i915/gen6+: Interpret mailbox error flags
In order to add proper support for the SAGV, we need to be able to know what the cause of a failure to change the SAGV through the pcode mailbox was. The reasoning for this is that some very early pre-release Skylake machines don't actually allow you to control the SAGV on them, and indicate an invalid mailbox command was sent.
This also might come in handy in the future for debugging.
Changes since v1:
- Add functions for interpreting gen6 mailbox error codes along with gen7+ error codes, and actually interpret those codes properly
- Renamed patch to reflect new behavior
--- drivers/gpu/drm/i915/i915_reg.h | 9 ++++++ drivers/gpu/drm/i915/intel_pm.c | 71 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +9 -0
@@ -7123,6 +7123,15 @@ enum {#define GEN6_PCODE_MAILBOX _MMIO(0x138124)#define GEN6_PCODE_READY (1<<31) +#define GEN6_PCODE_ERROR_MASK 0xFF +#define GEN6_PCODE_SUCCESS 0x0 +#define GEN6_PCODE_ILLEGAL_CMD 0x1 +#define GEN6_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x2 +#define GEN6_PCODE_TIMEOUT 0x3 +#define GEN6_PCODE_UNIMPLEMENTED_CMD 0xFF +#define GEN7_PCODE_TIMEOUT 0x2 +#define GEN7_PCODE_ILLEGAL_DATA 0x3 +#define GEN7_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x10#define GEN6_PCODE_WRITE_RC6VIDS 0x4#define GEN6_PCODE_READ_RC6VIDS 0x5#define GEN6_ENCODE_RC6_VID (mv) (((mv) - 245) / 5)
drivers/gpu/drm/i915/intel_pm.c +70 -1
96 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v12 2/7 drm/i915/skl: Add support for the SAGV, fix underrun hangs
In reply to LyudeSince the watermark calculations for Skylake are still broken, we're apt to hitting underruns very easily under multi-monitor configurations. While it would be lovely if this was fixed, it's not. Another problem that's been coming from this however, is the mysterious issue of underruns causing full system hangs. An easy way to reproduce this with a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to it
- Move the cursor from the built-in LCD to one of the external displays as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will just freeze.
After doing a lot of investigation and reading through the bspec, I found the existence of the SAGV, which is responsible for adjusting the system agent voltage and clock frequencies depending on how much power we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the GT-driver pcode mailbox to disable SAGV when the display engine is not able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave the SAGV enabled, and disable it when we use interlaced pipes/have more then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely fix that, it looks like it does improve the situation a little bit so it's likely this is going to be required to make watermarks on Skylake fully functional.
This will still need additional work in the future: we shouldn't be enabling the SAGV if any of the currently enabled planes can't enable WM levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable watermarks >= the SAGV engine block time. I was originally going to save this for later, but I recently managed to run into a machine that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads them back, despite it's misleading function name. This means we've been doing this mostly wrong and have been writing garbage to the SAGV control. Because of this, we no longer attempt to read the SAGV status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early pre-release Skylake machines, which apparently don't allow you to disable the SAGV. To prevent machines from failing tests due to SAGV errors, if the first time we try to control the SAGV results in the mailbox indicating an invalid command, we just disable future attempts to control the SAGV state by setting dev_priv->skl_sagv_status to I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This doesn't actually fix anything, but lets us release the lock a little sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1 pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0 enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
--- drivers/gpu/drm/i915/i915_drv.h | 7 ++ drivers/gpu/drm/i915/i915_reg.h | 4 + drivers/gpu/drm/i915/intel_display.c | 11 +++ drivers/gpu/drm/i915/intel_drv.h | 3 + drivers/gpu/drm/i915/intel_pm.c | 148 +++++++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +7 -0
@@ -1949,6 +1949,13 @@ struct drm_i915_private {struct i915_suspend_saved_registers regfile;struct vlv_s0ix_state vlv_s0ix_state; +enum { +I915_SKL_SAGV_UNKNOWN =0 , +I915_SKL_SAGV_DISABLED , +I915_SKL_SAGV_ENABLED , +I915_SKL_SAGV_NOT_CONTROLLED + } skl_sagv_status; +struct {/* * Raw watermark latency values:
drivers/gpu/drm/i915/i915_reg.h +4 -0
@@ -7153,6 +7153,10 @@ enum {#define HSW_PCODE_DE_WRITE_FREQ_REQ 0x17#define DISPLAY_IPS_CONTROL 0x19#define HSW_PCODE_DYNAMIC_DUTY_CYCLE_CONTROL 0x1A +#define GEN9_PCODE_SAGV_CONTROL 0x21 +#define GEN9_SAGV_DISABLE 0x0 +#define GEN9_SAGV_IS_DISABLED 0x1 +#define GEN9_SAGV_ENABLE 0x3#define GEN6_PCODE_DATA _MMIO(0x138128)#define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8#define GEN6_PCODE_FREQ_RING_RATIO_SHIFT 16
drivers/gpu/drm/i915/intel_display.c +11 -0
@@ -14156,6 +14156,13 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state) intel_state->cdclk_pll_vco != dev_priv->cdclk_pll.vco)) dev_priv->display.modeset_commit_cdclk(state); +/* +* SKL workaround: bspec recommends we disable the SAGV when we +* have more then one pipe enabled +*/ +if (IS_SKYLAKE (dev_priv) && !skl_can_enable_sagv (state)) +skl_disable_sagv (dev_priv); +intel_modeset_verify_disabled (dev); }
@@ -14229,6 +14236,10 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)intel_modeset_verify_crtc (crtc, old_crtc_state, crtc->state); } +if (IS_SKYLAKE (dev_priv) && intel_state->modeset && +skl_can_enable_sagv (state)) +skl_enable_sagv (dev_priv); +drm_atomic_helper_commit_hw_done (state);if (intel_state->modeset)
drivers/gpu/drm/i915/intel_drv.h +3 -0
@@ -1722,6 +1722,9 @@ void ilk_wm_get_hw_state(struct drm_device *dev);void skl_wm_get_hw_state (struct drm_device *dev);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv,struct skl_ddb_allocation *ddb/* out */ ); +bool skl_can_enable_sagv (struct drm_atomic_state *state); +int skl_enable_sagv (struct drm_i915_private *dev_priv); +int skl_disable_sagv (struct drm_i915_private *dev_priv);uint32_t ilk_pipe_pixel_rate (const struct intel_crtc_state *pipe_config);bool ilk_disable_lp_wm (struct drm_device *dev);int sanitize_rc6_option (struct drm_i915_private *dev_priv,int enable_rc6);
drivers/gpu/drm/i915/intel_pm.c +148 -0
160 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v12 2/7] drm/i915/skl: Add support for the SAGV, fix underrun hangs
Hey,
Op 17-08-16 om 21:55 schreef Lyude:
Quoted 339 lines
Since the watermark calculations for Skylake are still broken, we're apt to hitting underruns very easily under multi-monitor configurations. While it would be lovely if this was fixed, it's not. Another problem that's been coming from this however, is the mysterious issue of underruns causing full system hangs. An easy way to reproduce this with a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to it
- Move the cursor from the built-in LCD to one of the external displays as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will just freeze.After doing a lot of investigation and reading through the bspec, I found the existence of the SAGV, which is responsible for adjusting the system agent voltage and clock frequencies depending on how much power we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the GT-driver pcode mailbox to disable SAGV when the display engine is not able to tolerate the blocking time."The rest of the bspec goes on to explain that software can simply leave the SAGV enabled, and disable it when we use interlaced pipes/have more then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely fix that, it looks like it does improve the situation a little bit so it's likely this is going to be required to make watermarks on Skylake fully functional.This will still need additional work in the future: we shouldn't be enabling the SAGV if any of the currently enabled planes can't enable WM levels that introduce latencies >= 30 µs.
Changes since v11:
- Addskl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable watermarks >= the SAGV engine block time. I was originally going to save this for later, but I recently managed to run into a machine that was having problems with a single pipe configuration + SAGV.
- Make comparisons toI915_SKL_SAGV_NOT_CONTROLLEDexplicit
- ChangeI915_SAGV_DYNAMIC_FREQtoI915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparentlysandybridge_pcode_readactually writes values and reads them back, despite it's misleading function name. This means we've been doing this mostly wrong and have been writing garbage to the SAGV control. Because of this, we no longer attempt to read the SAGV status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early pre-release Skylake machines, which apparently don't allow you to disable the SAGV. To prevent machines from failing tests due to SAGV errors, if the first time we try to control the SAGV results in the mailbox indicating an invalid command, we just disable future attempts to control the SAGV state by settingdev_priv->skl_sagv_statustoI915_SKL_SAGV_NOT_CONTROLLEDand make a note of it in dmesg.
- Movemutex_unlock()a little higher inskl_enable_sagv(). This doesn't actually fix anything, but lets us release the lock a little sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Addintel_state->modesetguard to the conditional forskl_enable_sagv()
Changes since v7:
- RemoveGEN9_SAGV_LOW_FREQ, replace withGEN9_SAGV_IS_ENABLED(that's all we use it for anyway)
- UseGEN9_SAGV_IS_ENABLEDinstead of0x1for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protectskl_enable_sagv()withintel_state->modesetconditional inintel_atomic_commit_tail()
Changes since v5:
- Don't useis_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to enable/disable the sagv, use the new one
- Split the loop inskl_disable_sagvinto it's own function
- Move skl_sagv_enable/disable() calls intointel_atomic_commit_tail()
Changes since v4:
- Useis_power_of_2againstactive_crtcsto check whether we have > 1 pipe enabled
- Fixskl_sagv_get_hw_state(): (temp &0x1) indicates disabled,0x0enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Usetime_before()to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGVSigned-off-by Lyude <[email protected]>Cc Matt Roper <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 7 ++ drivers/gpu/drm/i915/i915_reg.h | 4 + drivers/gpu/drm/i915/intel_display.c | 11 +++ drivers/gpu/drm/i915/intel_drv.h | 3 + drivers/gpu/drm/i915/intel_pm.c | 148 +++++++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+)drivers/gpu/drm/i915/i915_drv.h +7
-0@@ -1949,6 +1949,13 @@ struct drm_i915_private {struct i915_suspend_saved_registers regfile;struct vlv_s0ix_state vlv_s0ix_state; +enum { +I915_SKL_SAGV_UNKNOWN =0 , +I915_SKL_SAGV_DISABLED , +I915_SKL_SAGV_ENABLED , +I915_SKL_SAGV_NOT_CONTROLLED + } skl_sagv_status; +struct {/* * Raw watermark latency values: drivers/gpu/drm/i915/i915_reg.h +4
-0@@ -7153,6 +7153,10 @@ enum {#define HSW_PCODE_DE_WRITE_FREQ_REQ 0x17#define DISPLAY_IPS_CONTROL 0x19#define HSW_PCODE_DYNAMIC_DUTY_CYCLE_CONTROL 0x1A +#define GEN9_PCODE_SAGV_CONTROL 0x21 +#define GEN9_SAGV_DISABLE 0x0 +#define GEN9_SAGV_IS_DISABLED 0x1 +#define GEN9_SAGV_ENABLE 0x3#define GEN6_PCODE_DATA _MMIO(0x138128)#define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8#define GEN6_PCODE_FREQ_RING_RATIO_SHIFT 16drivers/gpu/drm/i915/intel_display.c +11
-0@@ -14156,6 +14156,13 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state) intel_state->cdclk_pll_vco != dev_priv->cdclk_pll.vco)) dev_priv->display.modeset_commit_cdclk(state); +/* +* SKL workaround: bspec recommends we disable the SAGV when we +* have more then one pipe enabled +*/ +if (IS_SKYLAKE (dev_priv) && !skl_can_enable_sagv (state)) +skl_disable_sagv (dev_priv); +intel_modeset_verify_disabled (dev); }@@ -14229,6 +14236,10 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)intel_modeset_verify_crtc (crtc, old_crtc_state, crtc->state); } +if (IS_SKYLAKE (dev_priv) && intel_state->modeset && +skl_can_enable_sagv (state)) +skl_enable_sagv (dev_priv); +drm_atomic_helper_commit_hw_done (state);if (intel_state->modeset)drivers/gpu/drm/i915/intel_drv.h +3
-0@@ -1722,6 +1722,9 @@ void ilk_wm_get_hw_state(struct drm_device *dev);void skl_wm_get_hw_state (struct drm_device *dev);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv,struct skl_ddb_allocation *ddb/* out */ ); +bool skl_can_enable_sagv (struct drm_atomic_state *state); +int skl_enable_sagv (struct drm_i915_private *dev_priv); +int skl_disable_sagv (struct drm_i915_private *dev_priv);uint32_t ilk_pipe_pixel_rate (const struct intel_crtc_state *pipe_config);bool ilk_disable_lp_wm (struct drm_device *dev);int sanitize_rc6_option (struct drm_i915_private *dev_priv,int enable_rc6);drivers/gpu/drm/i915/intel_pm.c +133
-0@@ -2860,6 +2860,7 @@ bool ilk_disable_lp_wm(struct drm_device *dev)#define SKL_DDB_SIZE 896/* in blocks */ #define BXT_DDB_SIZE 512 +#define SKL_SAGV_BLOCK_TIME 30/* µs */ /* * Return the index of a plane in the SKL DDB and wm result arrays. Primary @@ -2883,6 +2884,153 @@ skl_wm_plane_id(const struct intel_plane *plane) } } +/* +* SAGV dynamically adjusts the system agent voltage and clock frequencies +* depending on power and performance requirements. The display engine access +* to system memory is blocked during the adjustment time. Because of the +* blocking time, having this enabled can cause full system hangs and/or pipe +* underruns if we don't meet all of the following requirements: +* +* - <= 1 pipe enabled +* - All planes can enable watermarks for latencies >= SAGV engine block time +* - We're not using an interlaced display configuration +*/ +int +skl_enable_sagv (struct drm_i915_private *dev_priv) +{ +int ret; + +if (dev_priv->skl_sagv_status ==I915_SKL_SAGV_NOT_CONTROLLED || + dev_priv->skl_sagv_status ==I915_SKL_SAGV_ENABLED ) +return 0 ; + +DRM_DEBUG_KMS ("Enabling the SAGV\n" ); +mutex_lock (&dev_priv->rps.hw_lock); + + ret =sandybridge_pcode_write (dev_priv,GEN9_PCODE_SAGV_CONTROL , +GEN9_SAGV_ENABLE ); + +/* We don't need to wait for the SAGV when enabling */ +mutex_unlock (&dev_priv->rps.hw_lock); + +/* +* Some skl systems, pre-release machines in particular, +* don't actually have an SAGV. +*/ +if (ret == -ENOSYS ) { +DRM_DEBUG_DRIVER ("No SAGV found on system, ignoring\n" ); + dev_priv->skl_sagv_status =I915_SKL_SAGV_NOT_CONTROLLED ; +return 0 ; + }else if (ret <0 ) { +DRM_ERROR ("Failed to enable the SAGV\n" ); +return ret; + } + + dev_priv->skl_sagv_status =I915_SKL_SAGV_ENABLED ; +return 0 ; +} + +static int +skl_do_sagv_disable (struct drm_i915_private *dev_priv) +{ +int ret; +uint32_t temp =GEN9_SAGV_DISABLE ; + + ret =sandybridge_pcode_read (dev_priv,GEN9_PCODE_SAGV_CONTROL , + &temp); +if (ret) +return ret; +else +return temp &GEN9_SAGV_IS_DISABLED ; +} + +int +skl_disable_sagv (struct drm_i915_private *dev_priv) +{ +int ret, result; + +if (dev_priv->skl_sagv_status ==I915_SKL_SAGV_NOT_CONTROLLED || + dev_priv->skl_sagv_status ==I915_SKL_SAGV_DISABLED ) +return 0 ; + +DRM_DEBUG_KMS ("Disabling the SAGV\n" ); +mutex_lock (&dev_priv->rps.hw_lock); + +/* bspec says to keep retrying for at least 1 ms */ + ret =wait_for (result =skl_do_sagv_disable (dev_priv),1 ); +mutex_unlock (&dev_priv->rps.hw_lock); + +if (ret == -ETIMEDOUT ) { +DRM_ERROR ("Request to disable SAGV timed out\n" ); +return -ETIMEDOUT ; + } + +/* +* Some skl systems, pre-release machines in particular, +* don't actually have an SAGV. +*/ +if (result == -ENOSYS ) { +DRM_DEBUG_DRIVER ("No SAGV found on system, ignoring\n" ); + dev_priv->skl_sagv_status =I915_SKL_SAGV_NOT_CONTROLLED ; +return 0 ; + }else if (result <0 ) { +DRM_ERROR ("Failed to disable the SAGV\n" ); +return result; + } + + dev_priv->skl_sagv_status =I915_SKL_SAGV_DISABLED ; +return 0 ; +} + +bool skl_can_enable_sagv (struct drm_atomic_state *state) +{ +struct drm_device *dev = state->dev; +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_atomic_state *intel_state =to_intel_atomic_state (state); +struct drm_crtc *crtc; +enum pipe pipe; +int level, plane; + +/* +* SKL workaround: bspec recommends we disable the SAGV when we have +* more then one pipe enabled +* +* If there are no active CRTCs, no additional checks need be performed +*/ +if (hweight32 (intel_state->active_crtcs) ==0 ) +return true; +else if (hweight32 (intel_state->active_crtcs) >1 ) +return false; + +/* Since we're now guaranteed to only have one active CRTC... */ + pipe =ffs (intel_state->active_crtcs) -1 ; + crtc = dev_priv->pipe_to_crtc_mapping[pipe]; + +if (crtc->state->mode.flags &DRM_MODE_FLAG_INTERLACE ) +return false; + +for_each_plane (dev_priv, pipe, plane) { +/* Skip this plane if it's not enabled */ +if (intel_state->wm_results.plane[pipe][plane][0 ] ==0 ) +continue ; + +/* Find the highest enabled wm level for this plane */ + for (level = ilk_wm_max_level(dev);
drivers/gpu/drm/i915/intel_pm.c skl_wm_plane_id(const struct intel_plane *plane) · line 3028
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10
-0+ intel_state->wm_results.plane[pipe][plane][level] ==0 ; + --level); + +/* +* If any of the planes on this pipe don't enable wm levels +* that incur memory latencies higher then 30µs we can't enable +* the SAGV +*/ +if (dev_priv->wm.skl_latency[level] <SKL_SAGV_BLOCK_TIME ) +return false;
Shouldn't this check be >= BLOCK_TIME?
~Maarten
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v12 2/7] drm/i915/skl: Add support for the SAGV, fix underrun hangs
Quoted 367 lines · Maarten Lankhorst
Hey,
Op 17-08-16 om 21:55 schreef Lyude:
Quoted 364 lines
Since the watermark calculations for Skylake are still broken, we're apt to hitting underruns very easily under multi-monitor configurations. While it would be lovely if this was fixed, it's not. Another problem that's been coming from this however, is the mysterious issue of underruns causing full system hangs. An easy way to reproduce this with a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to it
- Move the cursor from the built-in LCD to one of the external displays as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will just freeze.After doing a lot of investigation and reading through the bspec, I found the existence of the SAGV, which is responsible for adjusting the system agent voltage and clock frequencies depending on how much power we need. According to the bspec:
"The display engine access to system memory is blocked during the adjustment time. SAGV defaults to enabled. Software must use the GT-driver pcode mailbox to disable SAGV when the display engine is not able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave the SAGV enabled, and disable it when we use interlaced pipes/have more then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe
enabled
as a workaround for display underruns. While this patch doesn't entirely fix that, it looks like it does improve the situation a little bit so it's likely this is going to be required to make watermarks on Skylake fully functional.This will still need additional work in the future: we shouldn't be enabling the SAGV if any of the currently enabled planes can't enable WM levels that introduce latencies >= 30 µs.
Changes since v11:
- Addskl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable watermarks >= the SAGV engine block time. I was originally going to save this for later, but I recently managed to run into a machine that was having problems with a single pipe configuration + SAGV.
- Make comparisons toI915_SKL_SAGV_NOT_CONTROLLEDexplicit
- ChangeI915_SAGV_DYNAMIC_FREQtoI915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparentlysandybridge_pcode_readactually writes values and reads them back, despite it's misleading function name. This means we've been doing this mostly wrong and have been writing garbage to the SAGV control. Because of this, we no longer attempt to read the SAGV status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early pre-release Skylake machines, which apparently don't allow you to disable the SAGV. To prevent machines from failing tests due to SAGV errors, if the first time we try to control the SAGV results in the mailbox indicating an invalid command, we just disable future attempts to control the SAGV state by settingdev_priv->skl_sagv_statustoI915_SKL_SAGV_NOT_CONTROLLEDand make a note of it in dmesg.
- Movemutex_unlock()a little higher inskl_enable_sagv(). This doesn't actually fix anything, but lets us release the lock a little sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Addintel_state->modesetguard to the conditional forskl_enable_sagv()
Changes since v7:
- RemoveGEN9_SAGV_LOW_FREQ, replace withGEN9_SAGV_IS_ENABLED(that's all we use it for anyway)
- UseGEN9_SAGV_IS_ENABLEDinstead of0x1for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protectskl_enable_sagv()withintel_state->modesetconditional inintel_atomic_commit_tail()
Changes since v5:
- Don't useis_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to enable/disable the sagv, use the new one
- Split the loop inskl_disable_sagvinto it's own function
- Move skl_sagv_enable/disable() calls intointel_atomic_commit_tail()Changes since v4:
- Useis_power_of_2againstactive_crtcsto check whether we have > 1 pipe enabled
- Fixskl_sagv_get_hw_state(): (temp &0x1) indicates disabled,0x0enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates Changes since v3:
- Usetime_before()to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time Changes since v1:
- Added comments about this probably being one of the requirements to fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGVSigned-off-by Lyude <[email protected]>Cc Matt Roper <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>---
drivers/gpu/drm/i915/i915_drv.h | 7 ++
drivers/gpu/drm/i915/i915_reg.h | 4 +
drivers/gpu/drm/i915/intel_display.c | 11 +++
drivers/gpu/drm/i915/intel_drv.h | 3 +
drivers/gpu/drm/i915/intel_pm.c | 148
+++++++++++++++++++++++++++++++++++5 files changed, 173 insertions(+)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -1949,6 +1949,13 @@ struct drm_i915_private { struct i915_suspend_saved_registers regfile; struct vlv_s0ix_state vlv_s0ix_state;drivers/gpu/drm/i915/i915_drv.h +7
-0+enum { +I915_SKL_SAGV_UNKNOWN =0 , +I915_SKL_SAGV_DISABLED , +I915_SKL_SAGV_ENABLED , +I915_SKL_SAGV_NOT_CONTROLLED + } skl_sagv_status; +struct {
/*
* Raw watermark latency values:drivers/gpu/drm/i915/i915_reg.h +4
-0@@ -7153,6 +7153,10 @@ enum { #define HSW_PCODE_DE_WRITE_FREQ_REQ 0x17 #define DISPLAY_IPS_CONTROL 0x19 #define HSW_PCODE_DYNAMIC_DUTY_CYCLE_CONTROL 0x1A +#define GEN9_PCODE_SAGV_CONTROL 0x21 +#define GEN9_SAGV_DISABLE 0x0 +#define GEN9_SAGV_IS_DISABLED 0x1 +#define GEN9_SAGV_ENABLE 0x3 #define GEN6_PCODE_DATA _MMIO(0x138128) #define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8 #define GEN6_PCODE_FREQ_RING_RATIO_SHIFT 16drivers/gpu/drm/i915/intel_display.c +0
-0@@ -14156,6 +14156,13 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)intel_state->cdclk_pll_vco != dev_priv-
Quoted 1 line
cdclk_pll.vco))
dev_priv->display.modeset_commit_cdclk(state);drivers/gpu/drm/i915/intel_display.c +2
-0+/* +* SKL workaround: bspec recommends we disable the SAGV when we
drivers/gpu/drm/i915/intel_display.c +5
-0+* have more then one pipe enabled +*/ +if (IS_SKYLAKE (dev_priv) && !skl_can_enable_sagv (state)) +skl_disable_sagv (dev_priv); +
intel_modeset_verify_disabled(dev); }drivers/gpu/drm/i915/intel_display.c +0
-0@@ -14229,6 +14236,10 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)intel_modeset_verify_crtc(crtc,
old_crtc_state, crtc-Quoted 1 line
state);
}
drivers/gpu/drm/i915/intel_display.c +4
-0+if (IS_SKYLAKE (dev_priv) && intel_state->modeset && + skl_can_enable_sagv(state)) +skl_enable_sagv (dev_priv); +
drm_atomic_helper_commit_hw_done(state);
if (intel_state->modeset)drivers/gpu/drm/i915/intel_drv.h +3
-0@@ -1722,6 +1722,9 @@ void ilk_wm_get_hw_state(struct drm_device *dev); void skl_wm_get_hw_state(struct drm_device *dev); void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv, struct skl_ddb_allocation *ddb /* out */); +bool skl_can_enable_sagv (struct drm_atomic_state *state); +int skl_enable_sagv (struct drm_i915_private *dev_priv); +int skl_disable_sagv (struct drm_i915_private *dev_priv); uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config); bool ilk_disable_lp_wm(struct drm_device *dev); int sanitize_rc6_option(struct drm_i915_private *dev_priv, int enable_rc6);drivers/gpu/drm/i915/intel_pm.c +0
-0@@ -2860,6 +2860,7 @@ bool ilk_disable_lp_wm(struct drm_device *dev)
#defineSKL_DDB_SIZE896 /* in blocks */
#defineBXT_DDB_SIZE512
+#defineSKL_SAGV_BLOCK_TIME30 /* µs */
/*
* Return the index of a plane in the SKL DDB and wm result arrays. Primarydrivers/gpu/drm/i915/intel_pm.c +0
-0@@ -2883,6 +2884,153 @@ skl_wm_plane_id(const struct intel_plane *plane) } }
+/*
+ * SAGV dynamically adjusts the system agent voltage and clock frequencies
+ * depending on power and performance requirements. The display engine access
+ * to system memory is blocked during the adjustment time. Because of the
+ * blocking time, having this enabled can cause full system hangs and/or pipe
+ * underruns if we don't meet all of the following requirements:
+ *
+ * - <= 1 pipe enabled
+ * - All planes can enable watermarks for latencies >= SAGV engine block time
+ * - We're not using an interlaced display configuration
+ */drivers/gpu/drm/i915/intel_pm.c +92
-0+int +skl_enable_sagv (struct drm_i915_private *dev_priv) +{ +int ret; + +if (dev_priv->skl_sagv_status ==I915_SKL_SAGV_NOT_CONTROLLED || + dev_priv->skl_sagv_status == I915_SKL_SAGV_ENABLED) +return 0 ; + +DRM_DEBUG_KMS ("Enabling the SAGV\n" ); +mutex_lock (&dev_priv->rps.hw_lock); + + ret =sandybridge_pcode_write (dev_priv,GEN9_PCODE_SAGV_CONTROL , + GEN9_SAGV_ENABLE); + +/* We don't need to wait for the SAGV when enabling */ +mutex_unlock (&dev_priv->rps.hw_lock); + +/* +* Some skl systems, pre-release machines in particular, +* don't actually have an SAGV. +*/ +if (ret == -ENOSYS ) { +DRM_DEBUG_DRIVER ("No SAGV found on system, ignoring\n" ); + dev_priv->skl_sagv_status =I915_SKL_SAGV_NOT_CONTROLLED ; +return 0 ; + }else if (ret <0 ) { +DRM_ERROR ("Failed to enable the SAGV\n" ); +return ret; + } + + dev_priv->skl_sagv_status =I915_SKL_SAGV_ENABLED ; +return 0 ; +} + +static int +skl_do_sagv_disable (struct drm_i915_private *dev_priv) +{ +int ret; +uint32_t temp =GEN9_SAGV_DISABLE ; + + ret =sandybridge_pcode_read (dev_priv,GEN9_PCODE_SAGV_CONTROL , + &temp); +if (ret) +return ret; +else +return temp &GEN9_SAGV_IS_DISABLED ; +} + +int +skl_disable_sagv (struct drm_i915_private *dev_priv) +{ +int ret, result; + +if (dev_priv->skl_sagv_status ==I915_SKL_SAGV_NOT_CONTROLLED || + dev_priv->skl_sagv_status == I915_SKL_SAGV_DISABLED) +return 0 ; + +DRM_DEBUG_KMS ("Disabling the SAGV\n" ); +mutex_lock (&dev_priv->rps.hw_lock); + +/* bspec says to keep retrying for at least 1 ms */ + ret =wait_for (result =skl_do_sagv_disable (dev_priv),1 ); +mutex_unlock (&dev_priv->rps.hw_lock); + +if (ret == -ETIMEDOUT ) { +DRM_ERROR ("Request to disable SAGV timed out\n" ); +return -ETIMEDOUT ; + } + +/* +* Some skl systems, pre-release machines in particular, +* don't actually have an SAGV. +*/ +if (result == -ENOSYS ) { +DRM_DEBUG_DRIVER ("No SAGV found on system, ignoring\n" ); + dev_priv->skl_sagv_status =I915_SKL_SAGV_NOT_CONTROLLED ; +return 0 ; + }else if (result <0 ) { +DRM_ERROR ("Failed to disable the SAGV\n" ); +return result; + } + + dev_priv->skl_sagv_status =I915_SKL_SAGV_DISABLED ; +return 0 ; +} + +bool skl_can_enable_sagv (struct drm_atomic_state *state) +{ +struct drm_device *dev = state->dev; +struct drm_i915_private *dev_priv =to_i915 (dev); + struct intel_atomic_state *intel_state =
to_intel_atomic_state(state);drivers/gpu/drm/i915/intel_pm.c +6
-0+struct drm_crtc *crtc; +enum pipe pipe; +int level, plane; + +/* +* SKL workaround: bspec recommends we disable the SAGV when we have
drivers/gpu/drm/i915/intel_pm.c +3
-0+ * more then one pipe enabled + * + * If there are no active CRTCs, no additional checks need beperformed
drivers/gpu/drm/i915/intel_pm.c +21
-0+*/ +if (hweight32 (intel_state->active_crtcs) ==0 ) +return true; +else if (hweight32 (intel_state->active_crtcs) >1 ) +return false; + +/* Since we're now guaranteed to only have one active CRTC... */ + pipe =ffs (intel_state->active_crtcs) -1 ; + crtc = dev_priv->pipe_to_crtc_mapping[pipe]; + +if (crtc->state->mode.flags &DRM_MODE_FLAG_INTERLACE ) +return false; + +for_each_plane (dev_priv, pipe, plane) { +/* Skip this plane if it's not enabled */ +if (intel_state->wm_results.plane[pipe][plane][0 ] ==0 ) +continue ; + +/* Find the highest enabled wm level for this plane */ + for (level = ilk_wm_max_level(dev); + intel_state->wm_results.plane[pipe][plane][level] ==0;
drivers/gpu/drm/i915/intel_pm.c +3
-0+ --level); + +/*
Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c skl_wm_plane_id(const struct intel_plane *plane) · line 3028
Quoted 7 lines
drivers/gpu/drm/i915/intel_pm.c +2
-0+ * If any of the planes on this pipe don't enable wm levels + * that incur memory latencies higher then 30µs we can'tenable
drivers/gpu/drm/i915/intel_pm.c +4
-0+* the SAGV +*/ +if (dev_priv->wm.skl_latency[level] <SKL_SAGV_BLOCK_TIME ) +return false;Shouldn't this check be >=
BLOCK_TIME?
That's the requirement for the sagv but the conditional here is still correct.
WM0 - 2ms
WM1 - 5ms
WM2 - 10ms
WM3 - 20ms
WM4+- disabled
(20ms < BLOCK_TIME) == true, which indicates we don't have any watermark levels with latency values >= 30ms. We can't enable so return false.
WM0 - 2ms
WM1 - 5ms
WM2 - 10ms
WM3 - 20ms
WM4 - 33ms
WM5 - 50ms
WM6 - 70ms
WM7 - 99ms
(99ms < BLOCK_TIME) == false, and 99 >= BLOCK_TIME so we end up returning true to indicate it's safe to enable.
Quoted 5 lines
~Maarten
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v12 2/7] drm/i915/skl: Add support for the SAGV, fix underrun hangs
Op 18-08-16 om 16:05 schreef Lyude Paul:
Quoted 396 lines · Maarten Lankhorst
Quoted 366 lines
Hey,
Op 17-08-16 om 21:55 schreef Lyude:
Quoted 363 lines
Since the watermark calculations for Skylake are still broken, we're apt to hitting underruns very easily under multi-monitor configurations. While it would be lovely if this was fixed, it's not. Another problem that's been coming from this however, is the mysterious issue of underruns causing full system hangs. An easy way to reproduce this with a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to it
- Move the cursor from the built-in LCD to one of the external displays as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will just freeze.After doing a lot of investigation and reading through the bspec, I found the existence of the SAGV, which is responsible for adjusting the system agent voltage and clock frequencies depending on how much power we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the GT-driver pcode mailbox to disable SAGV when the display engine is not able to tolerate the blocking time."The rest of the bspec goes on to explain that software can simply leave the SAGV enabled, and disable it when we use interlaced pipes/have more then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe
enabled
as a workaround for display underruns. While this patch doesn't entirely fix that, it looks like it does improve the situation a little bit so it's likely this is going to be required to make watermarks on Skylake fully functional.This will still need additional work in the future: we shouldn't be enabling the SAGV if any of the currently enabled planes can't enable WM levels that introduce latencies >= 30 µs.
Changes since v11:
- Addskl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable watermarks >= the SAGV engine block time. I was originally going to save this for later, but I recently managed to run into a machine that was having problems with a single pipe configuration + SAGV.
- Make comparisons toI915_SKL_SAGV_NOT_CONTROLLEDexplicit
- ChangeI915_SAGV_DYNAMIC_FREQtoI915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparentlysandybridge_pcode_readactually writes values and reads them back, despite it's misleading function name. This means we've been doing this mostly wrong and have been writing garbage to the SAGV control. Because of this, we no longer attempt to read the SAGV status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early pre-release Skylake machines, which apparently don't allow you to disable the SAGV. To prevent machines from failing tests due to SAGV errors, if the first time we try to control the SAGV results in the mailbox indicating an invalid command, we just disable future attempts to control the SAGV state by settingdev_priv->skl_sagv_statustoI915_SKL_SAGV_NOT_CONTROLLEDand make a note of it in dmesg.
- Movemutex_unlock()a little higher inskl_enable_sagv(). This doesn't actually fix anything, but lets us release the lock a little sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Addintel_state->modesetguard to the conditional forskl_enable_sagv()
Changes since v7:
- RemoveGEN9_SAGV_LOW_FREQ, replace withGEN9_SAGV_IS_ENABLED(that's all we use it for anyway)
- UseGEN9_SAGV_IS_ENABLEDinstead of0x1for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protectskl_enable_sagv()withintel_state->modesetconditional inintel_atomic_commit_tail()
Changes since v5:
- Don't useis_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to enable/disable the sagv, use the new one
- Split the loop inskl_disable_sagvinto it's own function
- Move skl_sagv_enable/disable() calls intointel_atomic_commit_tail()
Changes since v4:
- Useis_power_of_2againstactive_crtcsto check whether we have > 1 pipe enabled
- Fixskl_sagv_get_hw_state(): (temp &0x1) indicates disabled,0x0enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Usetime_before()to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGVSigned-off-by Lyude <[email protected]>Cc Matt Roper <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 7 ++ drivers/gpu/drm/i915/i915_reg.h | 4 + drivers/gpu/drm/i915/intel_display.c | 11 +++ drivers/gpu/drm/i915/intel_drv.h | 3 + drivers/gpu/drm/i915/intel_pm.c | 148 +++++++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+)drivers/gpu/drm/i915/i915_drv.h +7
-0@@ -1949,6 +1949,13 @@ struct drm_i915_private {struct i915_suspend_saved_registers regfile;struct vlv_s0ix_state vlv_s0ix_state; +enum { +I915_SKL_SAGV_UNKNOWN =0 , +I915_SKL_SAGV_DISABLED , +I915_SKL_SAGV_ENABLED , +I915_SKL_SAGV_NOT_CONTROLLED + } skl_sagv_status; +struct {/* * Raw watermark latency values: drivers/gpu/drm/i915/i915_reg.h +4
-0@@ -7153,6 +7153,10 @@ enum {#define HSW_PCODE_DE_WRITE_FREQ_REQ 0x17#define DISPLAY_IPS_CONTROL 0x19#define HSW_PCODE_DYNAMIC_DUTY_CYCLE_CONTROL 0x1A +#define GEN9_PCODE_SAGV_CONTROL 0x21 +#define GEN9_SAGV_DISABLE 0x0 +#define GEN9_SAGV_IS_DISABLED 0x1 +#define GEN9_SAGV_ENABLE 0x3#define GEN6_PCODE_DATA _MMIO(0x138128)#define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8#define GEN6_PCODE_FREQ_RING_RATIO_SHIFT 16drivers/gpu/drm/i915/intel_display.c +2
-0@@ -14156,6 +14156,13 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state) intel_state->cdclk_pll_vco != dev_priv- > cdclk_pll.vco)) dev_priv->display.modeset_commit_cdclk(state); +/* +* SKL workaround: bspec recommends we disable the SAGV when we
drivers/gpu/drm/i915/intel_display.c +9
-0+* have more then one pipe enabled +*/ +if (IS_SKYLAKE (dev_priv) && !skl_can_enable_sagv (state)) +skl_disable_sagv (dev_priv); +intel_modeset_verify_disabled (dev); }@@ -14229,6 +14236,10 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state) intel_modeset_verify_crtc(crtc, old_crtc_state, crtc- > state); } +if (IS_SKYLAKE (dev_priv) && intel_state->modeset && +skl_can_enable_sagv (state)) +skl_enable_sagv (dev_priv); +drm_atomic_helper_commit_hw_done (state);drivers/gpu/drm/i915/intel_display.c +0
-0if (intel_state->modeset)drivers/gpu/drm/i915/intel_drv.h +3
-0@@ -1722,6 +1722,9 @@ void ilk_wm_get_hw_state(struct drm_device *dev);void skl_wm_get_hw_state (struct drm_device *dev);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv,struct skl_ddb_allocation *ddb/* out */ ); +bool skl_can_enable_sagv (struct drm_atomic_state *state); +int skl_enable_sagv (struct drm_i915_private *dev_priv); +int skl_disable_sagv (struct drm_i915_private *dev_priv);uint32_t ilk_pipe_pixel_rate (const struct intel_crtc_state *pipe_config);bool ilk_disable_lp_wm (struct drm_device *dev);int sanitize_rc6_option (struct drm_i915_private *dev_priv,int enable_rc6);drivers/gpu/drm/i915/intel_pm.c +1
-0@@ -2860,6 +2860,7 @@ bool ilk_disable_lp_wm(struct drm_device *dev)#define SKL_DDB_SIZE 896/* in blocks */ #define BXT_DDB_SIZE 512 +#define SKL_SAGV_BLOCK_TIME 30/* µs */ /* * Return the index of a plane in the SKL DDB and wm result arrays. Primary
drivers/gpu/drm/i915/intel_pm.c +3
-0@@ -2883,6 +2884,153 @@ skl_wm_plane_id(const struct intel_plane *plane) } } +/* +* SAGV dynamically adjusts the system agent voltage and clock frequencies +* depending on power and performance requirements. The display engine access
+ * to system memory is blocked during the adjustment time. Because of the
+ * blocking time, having this enabled can cause full system hangs and/or pipe
+ * underruns if we don't meet all of the following requirements:
+ *
+ * - <= 1 pipe enabled
+ * - All planes can enable watermarks for latencies >= SAGV engine block time
+ * - We're not using an interlaced display configuration
+ */drivers/gpu/drm/i915/intel_pm.c +92
-0+int +skl_enable_sagv (struct drm_i915_private *dev_priv) +{ +int ret; + +if (dev_priv->skl_sagv_status ==I915_SKL_SAGV_NOT_CONTROLLED || + dev_priv->skl_sagv_status ==I915_SKL_SAGV_ENABLED ) +return 0 ; + +DRM_DEBUG_KMS ("Enabling the SAGV\n" ); +mutex_lock (&dev_priv->rps.hw_lock); + + ret =sandybridge_pcode_write (dev_priv,GEN9_PCODE_SAGV_CONTROL , +GEN9_SAGV_ENABLE ); + +/* We don't need to wait for the SAGV when enabling */ +mutex_unlock (&dev_priv->rps.hw_lock); + +/* +* Some skl systems, pre-release machines in particular, +* don't actually have an SAGV. +*/ +if (ret == -ENOSYS ) { +DRM_DEBUG_DRIVER ("No SAGV found on system, ignoring\n" ); + dev_priv->skl_sagv_status =I915_SKL_SAGV_NOT_CONTROLLED ; +return 0 ; + }else if (ret <0 ) { +DRM_ERROR ("Failed to enable the SAGV\n" ); +return ret; + } + + dev_priv->skl_sagv_status =I915_SKL_SAGV_ENABLED ; +return 0 ; +} + +static int +skl_do_sagv_disable (struct drm_i915_private *dev_priv) +{ +int ret; +uint32_t temp =GEN9_SAGV_DISABLE ; + + ret =sandybridge_pcode_read (dev_priv,GEN9_PCODE_SAGV_CONTROL , + &temp); +if (ret) +return ret; +else +return temp &GEN9_SAGV_IS_DISABLED ; +} + +int +skl_disable_sagv (struct drm_i915_private *dev_priv) +{ +int ret, result; + +if (dev_priv->skl_sagv_status ==I915_SKL_SAGV_NOT_CONTROLLED || + dev_priv->skl_sagv_status ==I915_SKL_SAGV_DISABLED ) +return 0 ; + +DRM_DEBUG_KMS ("Disabling the SAGV\n" ); +mutex_lock (&dev_priv->rps.hw_lock); + +/* bspec says to keep retrying for at least 1 ms */ + ret =wait_for (result =skl_do_sagv_disable (dev_priv),1 ); +mutex_unlock (&dev_priv->rps.hw_lock); + +if (ret == -ETIMEDOUT ) { +DRM_ERROR ("Request to disable SAGV timed out\n" ); +return -ETIMEDOUT ; + } + +/* +* Some skl systems, pre-release machines in particular, +* don't actually have an SAGV. +*/ +if (result == -ENOSYS ) { +DRM_DEBUG_DRIVER ("No SAGV found on system, ignoring\n" ); + dev_priv->skl_sagv_status =I915_SKL_SAGV_NOT_CONTROLLED ; +return 0 ; + }else if (result <0 ) { +DRM_ERROR ("Failed to disable the SAGV\n" ); +return result; + } + + dev_priv->skl_sagv_status =I915_SKL_SAGV_DISABLED ; +return 0 ; +} + +bool skl_can_enable_sagv (struct drm_atomic_state *state) +{ +struct drm_device *dev = state->dev; +struct drm_i915_private *dev_priv =to_i915 (dev); + struct intel_atomic_state *intel_state =
to_intel_atomic_state(state);drivers/gpu/drm/i915/intel_pm.c +6
-0+struct drm_crtc *crtc; +enum pipe pipe; +int level, plane; + +/* +* SKL workaround: bspec recommends we disable the SAGV when we have
drivers/gpu/drm/i915/intel_pm.c +3
-0+* more then one pipe enabled +* +* If there are no active CRTCs, no additional checks need be performed
drivers/gpu/drm/i915/intel_pm.c +21
-0+*/ +if (hweight32 (intel_state->active_crtcs) ==0 ) +return true; +else if (hweight32 (intel_state->active_crtcs) >1 ) +return false; + +/* Since we're now guaranteed to only have one active CRTC... */ + pipe =ffs (intel_state->active_crtcs) -1 ; + crtc = dev_priv->pipe_to_crtc_mapping[pipe]; + +if (crtc->state->mode.flags &DRM_MODE_FLAG_INTERLACE ) +return false; + +for_each_plane (dev_priv, pipe, plane) { +/* Skip this plane if it's not enabled */ +if (intel_state->wm_results.plane[pipe][plane][0 ] ==0 ) +continue ; + +/* Find the highest enabled wm level for this plane */ + for (level = ilk_wm_max_level(dev); + intel_state->wm_results.plane[pipe][plane][level] ==0;
drivers/gpu/drm/i915/intel_pm.c +3
-0+ --level); + +/* Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c skl_wm_plane_id(const struct intel_plane *plane) · line 3028
Quoted 7 lines
drivers/gpu/drm/i915/intel_pm.c +2
-0+* If any of the planes on this pipe don't enable wm levels +* that incur memory latencies higher then 30µs we can't enable
drivers/gpu/drm/i915/intel_pm.c +4
-0+* the SAGV +*/ +if (dev_priv->wm.skl_latency[level] <SKL_SAGV_BLOCK_TIME ) +return false;Shouldn't this check be >=
BLOCK_TIME?That's the requirement for the sagv but the conditional here is still correct.
WM0 - 2ms
WM1 - 5ms
WM2 - 10ms
WM3 - 20ms
WM4+- disabled(20ms <
BLOCK_TIME) == true, which indicates we don't have any watermark levels with latency values >= 30ms. We can't enable so return false.WM0 - 2ms
WM1 - 5ms
WM2 - 10ms
WM3 - 20ms
WM4 - 33ms
WM5 - 50ms
WM6 - 70ms
WM7 - 99ms
Quoted 2 lines
(99ms <
BLOCK_TIME) == false, and 99 >=BLOCK_TIMEso we end up returning true to indicate it's safe to enable.
Ah right, thanks for explaining.
~Maarten
PATCH v12 3/7 drm/i915/gen9: Only copy WM results for changed pipes to skl_hw
In reply to LyudeFrom: Matt Roper <[email protected]>
When we write watermark values to the hardware, those values are stored in dev_priv->wm.skl_hw. However with recent watermark changes, the results structure we're copying from only contains valid watermark and DDB values for the pipes that are actually changing; the values for other pipes remain 0. Thus a blind copy of the entire skl_wm_values structure will clobber the values for unchanged pipes...we need to be more selective and only copy over the values for the changing pipes.
This mistake was hidden until recently due to another bug that caused us to erroneously re-calculate watermarks for all active pipes rather than changing pipes. Only when that bug was fixed was the impact of this bug discovered (e.g., modesets failing with "Requested display configuration exceeds system watermark limitations" messages and leaving watermarks non-functional, even ones initiated by intel_fbdev_restore_mode).
Changes since v1:
- Add a function for copying a pipe's wm values (skl_copy_wm_for_pipe()) so we can reuse this later
--- drivers/gpu/drm/i915/intel_pm.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +26 -2
@@ -4104,6 +4104,24 @@ skl_compute_ddb(struct drm_atomic_state *state)return 0 ; } +static void +skl_copy_wm_for_pipe (struct skl_wm_values *dst, +struct skl_wm_values *src, +enum pipe pipe) +{ + dst->wm_linetime[pipe] = src->wm_linetime[pipe]; +memcpy (dst->plane[pipe], src->plane[pipe], +sizeof (dst->plane[pipe])); +memcpy (dst->plane_trans[pipe], src->plane_trans[pipe], +sizeof (dst->plane_trans[pipe])); + + dst->ddb.pipe[pipe] = src->ddb.pipe[pipe]; +memcpy (dst->ddb.y_plane[pipe], src->ddb.y_plane[pipe], +sizeof (dst->ddb.y_plane[pipe])); +memcpy (dst->ddb.plane[pipe], src->ddb.plane[pipe], +sizeof (dst->ddb.plane[pipe])); +} +static int skl_compute_wm (struct drm_atomic_state *state) {
@@ -4176,8 +4194,10 @@ static void skl_update_wm(struct drm_crtc *crtc)struct drm_device *dev = crtc->dev;struct drm_i915_private *dev_priv =to_i915 (dev);struct skl_wm_values *results = &dev_priv->wm.skl_results; +struct skl_wm_values *hw_vals = &dev_priv->wm.skl_hw;struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);struct skl_pipe_wm *pipe_wm = &cstate->wm.skl.optimal; +int pipe;if ((results->dirty_pipes &drm_crtc_mask (crtc)) ==0 )return ;
@@ -4189,8 +4209,12 @@ static void skl_update_wm(struct drm_crtc *crtc)skl_write_wm_values (dev_priv, results);skl_flush_wm_values (dev_priv, results); -/* store the new configuration */ - dev_priv->wm.skl_hw = *results; +/* +* Store the new configuration (but only for the pipes that have +* changed; the other values weren't recomputed). +*/ +for_each_pipe_masked (dev_priv, pipe, results->dirty_pipes) +skl_copy_wm_for_pipe (hw_vals, results, pipe);mutex_unlock (&dev_priv->wm.wm_mutex); }
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v12 4/7 drm/i915/skl: Update plane watermarks atomically during plane updates
In reply to LyudeThanks to Ville for suggesting this as a potential solution to pipe underruns on Skylake.
On Skylake all of the registers for configuring planes, including the registers for configuring their watermarks, are double buffered. New values written to them won't take effect until said registers are "armed", which is done by writing to the PLANE_SURF (or in the case of cursor planes, the CURBASE register) register.
With this in mind, up until now we've been updating watermarks on skl like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
or
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
Now we update watermarks atomically like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks() (wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks() (actual wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
So this patch moves all of the watermark writes into the right place; inside of the vblank evasion where we update all of the registers for each plane. While this patch doesn't fix everything, it does allow us to update the watermark values in the way the hardware expects us to.
Changes since original patch series:
- Remove mutex_lock/mutex_unlock since they don't do anything and we're not touching global state
- Move skl_write_cursor_wm/skl_write_plane_wm functions into intel_pm.c, make externally visible
- Add skl_write_plane_wm calls to skl_update_plane
- Fix conditional for for loop in skl_write_plane_wm (level < max_level should be level <= max_level)
- Make diagram in commit more accurate to what's actually happening
- Add Fixes:
Changes since v1:
- Use IS_GEN9() instead of IS_SKYLAKE() since these fixes apply to more then just Skylake
- Update description to make it clear this patch doesn't fix everything
- Check if pipes were actually changed before writing watermarks
Changes since v2:
- Write PIPE_WM_LINETIME during vblank evasion
Changes since v3:
- Rebase against new SAGV patch changes
Changes since v4:
- Add a parameter to choose what skl_wm_values struct to use when writing new plane watermarks
Changes since v5:
- Remove cursor ddb entry write in skl_write_cursor_wm(), defer until patch 6
- Write WM_LINETIME in intel_begin_crtc_commit()
Changes since v6:
- Remove redundant dirty_pipes check in skl_write_plane_wm (we check this in all places where we call this function, and it was supposed to have been removed earlier anyway)
- In i9xx_update_cursor(), use dev_priv->info.gen >= 9 instead of IS_GEN9(dev_priv). We do this everywhere else and I'd imagine this needs to be done for gen10 as well
Changes since v7:
- Fix rebase fail (unused variable obj)
- Make struct skl_wm_values *wm const
- Fix indenting
- Use INTEL_GEN() instead of dev_priv->info.gen
--- drivers/gpu/drm/i915/intel_display.c | 16 +++++++++++- drivers/gpu/drm/i915/intel_drv.h | 5 ++++ drivers/gpu/drm/i915/intel_pm.c | 50 ++++++++++++++++++++++++------------ drivers/gpu/drm/i915/intel_sprite.c | 6 +++++ 4 files changed, 60 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/intel_display.c +15 -1
@@ -3390,6 +3390,7 @@ static void skylake_update_primary_plane(struct drm_plane *plane,struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc_state->base.crtc);struct drm_framebuffer *fb = plane_state->base.fb; +const struct skl_wm_values *wm = &dev_priv->wm.skl_results;int pipe = intel_crtc->pipe;u32 plane_ctl;unsigned int rotation = plane_state->base.rotation;
@@ -3423,6 +3424,9 @@ static void skylake_update_primary_plane(struct drm_plane *plane, intel_crtc->adjusted_x = src_x; intel_crtc->adjusted_y = src_y; +if (wm->dirty_pipes &drm_crtc_mask (&intel_crtc->base)) +skl_write_plane_wm (intel_crtc, wm,0 ); +I915_WRITE (PLANE_CTL (pipe,0 ), plane_ctl);I915_WRITE (PLANE_OFFSET (pipe,0 ), (src_y <<16 ) | src_x);I915_WRITE (PLANE_STRIDE (pipe,0 ), stride);
@@ -10705,9 +10709,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base,struct drm_device *dev = crtc->dev;struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +const struct skl_wm_values *wm = &dev_priv->wm.skl_results;int pipe = intel_crtc->pipe;uint32_t cntl =0 ; +if (INTEL_GEN (dev_priv) >=9 && wm->dirty_pipes &drm_crtc_mask (crtc)) +skl_write_cursor_wm (intel_crtc, wm); +if (plane_state && plane_state->base.visible) { cntl =MCURSOR_GAMMA_ENABLE ;switch (plane_state->base.crtc_w) {
@@ -14627,10 +14635,12 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) {struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *old_intel_state =to_intel_crtc_state (old_crtc_state);bool modeset =needs_modeset (crtc->state); +enum pipe pipe = intel_crtc->pipe;/* Perform vblank evasion around commit operation */ intel_pipe_update_start (intel_crtc);
@@ -14645,8 +14655,12 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,if (to_intel_crtc_state (crtc->state)->update_pipe)intel_update_pipe_config (intel_crtc, old_intel_state); -else if (INTEL_INFO (dev)->gen >=9 ) +else if (INTEL_INFO (dev)->gen >=9 ) {skl_detach_scalers (intel_crtc); + +I915_WRITE (PIPE_WM_LINETIME (pipe), + dev_priv->wm.skl_hw.wm_linetime[pipe]); + } } static void intel_finish_crtc_commit(struct drm_crtc *crtc,
drivers/gpu/drm/i915/intel_drv.h +5 -0
@@ -1725,6 +1725,11 @@ void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,bool skl_can_enable_sagv (struct drm_atomic_state *state);int skl_enable_sagv (struct drm_i915_private *dev_priv);int skl_disable_sagv (struct drm_i915_private *dev_priv); +void skl_write_cursor_wm (struct intel_crtc *intel_crtc, +const struct skl_wm_values *wm); +void skl_write_plane_wm (struct intel_crtc *intel_crtc, +const struct skl_wm_values *wm, +int plane);uint32_t ilk_pipe_pixel_rate (const struct intel_crtc_state *pipe_config);bool ilk_disable_lp_wm (struct drm_device *dev);int sanitize_rc6_option (struct drm_i915_private *dev_priv,int enable_rc6);
drivers/gpu/drm/i915/intel_pm.c +34 -16
68 lines not on this page · raw message
drivers/gpu/drm/i915/intel_sprite.c +6 -0
@@ -203,6 +203,9 @@ skl_update_plane(struct drm_plane *drm_plane,struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_plane *intel_plane =to_intel_plane (drm_plane);struct drm_framebuffer *fb = plane_state->base.fb; +const struct skl_wm_values *wm = &dev_priv->wm.skl_results; +struct drm_crtc *crtc = crtc_state->base.crtc; +struct intel_crtc *intel_crtc =to_intel_crtc (crtc);const int pipe = intel_plane->pipe;const int plane = intel_plane->plane +1 ;u32 plane_ctl;
@@ -228,6 +231,9 @@ skl_update_plane(struct drm_plane *drm_plane, plane_ctl |=skl_plane_ctl_rotation (rotation); +if (wm->dirty_pipes &drm_crtc_mask (crtc)) +skl_write_plane_wm (intel_crtc, wm, plane); +if (key->flags) {I915_WRITE (PLANE_KEYVAL (pipe, plane), key->min_value);I915_WRITE (PLANE_KEYMAX (pipe, plane), key->max_value);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v12 4/7] drm/i915/skl: Update plane watermarks atomically during plane updates
Op 17-08-16 om 21:55 schreef Lyude:
Quoted 11 lines
Thanks to Ville for suggesting this as a potential solution to pipe underruns on Skylake.
On Skylake all of the registers for configuring planes, including the registers for configuring their watermarks, are double buffered. New values written to them won't take effect until said registers are "armed", which is done by writing to the
PLANE_SURF(or in the case of cursor planes, the CURBASE register) register.With this in mind, up until now we've been updating watermarks on skl like this:
This patch breaks on plane disabling. I think that all the disable_plane hooks should zero all the watermark values. This might also make modeset more reliable
It's shown in this testcase that I wrote to expose this issue: kms_atomic_transition.plane-all-modeset-transition
I've applied patch 1, 2, 3 and 5 with some minor fixes.
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v13 4/7 drm/i915/skl: Update plane watermarks atomically during plane updates
Thanks to Ville for suggesting this as a potential solution to pipe underruns on Skylake.
On Skylake all of the registers for configuring planes, including the registers for configuring their watermarks, are double buffered. New values written to them won't take effect until said registers are "armed", which is done by writing to the PLANE_SURF (or in the case of cursor planes, the CURBASE register) register.
With this in mind, up until now we've been updating watermarks on skl like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
or
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
Now we update watermarks atomically like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks() (wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks() (actual wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
So this patch moves all of the watermark writes into the right place; inside of the vblank evasion where we update all of the registers for each plane. While this patch doesn't fix everything, it does allow us to update the watermark values in the way the hardware expects us to.
Changes since original patch series:
- Remove mutex_lock/mutex_unlock since they don't do anything and we're not touching global state
- Move skl_write_cursor_wm/skl_write_plane_wm functions into intel_pm.c, make externally visible
- Add skl_write_plane_wm calls to skl_update_plane
- Fix conditional for for loop in skl_write_plane_wm (level < max_level should be level <= max_level)
- Make diagram in commit more accurate to what's actually happening
- Add Fixes:
Changes since v1:
- Use IS_GEN9() instead of IS_SKYLAKE() since these fixes apply to more then just Skylake
- Update description to make it clear this patch doesn't fix everything
- Check if pipes were actually changed before writing watermarks
Changes since v2:
- Write PIPE_WM_LINETIME during vblank evasion
Changes since v3:
- Rebase against new SAGV patch changes
Changes since v4:
- Add a parameter to choose what skl_wm_values struct to use when writing new plane watermarks
Changes since v5:
- Remove cursor ddb entry write in skl_write_cursor_wm(), defer until patch 6
- Write WM_LINETIME in intel_begin_crtc_commit()
Changes since v6:
- Remove redundant dirty_pipes check in skl_write_plane_wm (we check this in all places where we call this function, and it was supposed to have been removed earlier anyway)
- In i9xx_update_cursor(), use dev_priv->info.gen >= 9 instead of IS_GEN9(dev_priv). We do this everywhere else and I'd imagine this needs to be done for gen10 as well
Changes since v7:
- Fix rebase fail (unused variable obj)
- Make struct skl_wm_values *wm const
- Fix indenting
- Use INTEL_GEN() instead of dev_priv->info.gen
Changes since v8:
- Don't forget calls to skl_write_plane_wm() when disabling planes
- Use INTEL_GEN(), not INTEL_INFO()->gen in intel_begin_crtc_commit()
---
Assuming the other patches apply cleanly still; this should be ready to go (passes the testcase you wrote now, unlike before).
drivers/gpu/drm/i915/intel_display.c | 21 +++++++++++++-- drivers/gpu/drm/i915/intel_drv.h | 5 ++++ drivers/gpu/drm/i915/intel_pm.c | 50 ++++++++++++++++++++++++------------ drivers/gpu/drm/i915/intel_sprite.c | 9 +++++++ 4 files changed, 67 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/intel_display.c +19 -2
@@ -3377,6 +3377,7 @@ static void skylake_update_primary_plane(struct drm_plane *plane,struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc_state->base.crtc);struct drm_framebuffer *fb = plane_state->base.fb; +const struct skl_wm_values *wm = &dev_priv->wm.skl_results;int pipe = intel_crtc->pipe;u32 plane_ctl;unsigned int rotation = plane_state->base.rotation;
@@ -3410,6 +3411,9 @@ static void skylake_update_primary_plane(struct drm_plane *plane, intel_crtc->adjusted_x = src_x; intel_crtc->adjusted_y = src_y; +if (wm->dirty_pipes &drm_crtc_mask (&intel_crtc->base)) +skl_write_plane_wm (intel_crtc, wm,0 ); +I915_WRITE (PLANE_CTL (pipe,0 ), plane_ctl);I915_WRITE (PLANE_OFFSET (pipe,0 ), (src_y <<16 ) | src_x);I915_WRITE (PLANE_STRIDE (pipe,0 ), stride);
@@ -3441,7 +3445,10 @@ static void skylake_disable_primary_plane(struct drm_plane *primary, {struct drm_device *dev = crtc->dev;struct drm_i915_private *dev_priv =to_i915 (dev); -int pipe =to_intel_crtc (crtc)->pipe; +struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +int pipe = intel_crtc->pipe; + +skl_write_plane_wm (intel_crtc, &dev_priv->wm.skl_results,0 );I915_WRITE (PLANE_CTL (pipe,0 ),0 );I915_WRITE (PLANE_SURF (pipe,0 ),0 );
@@ -10698,9 +10705,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base,struct drm_device *dev = crtc->dev;struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +const struct skl_wm_values *wm = &dev_priv->wm.skl_results;int pipe = intel_crtc->pipe;uint32_t cntl =0 ; +if (INTEL_GEN (dev_priv) >=9 && wm->dirty_pipes &drm_crtc_mask (crtc)) +skl_write_cursor_wm (intel_crtc, wm); +if (plane_state && plane_state->base.visible) { cntl =MCURSOR_GAMMA_ENABLE ;switch (plane_state->base.crtc_w) {
@@ -14628,10 +14639,12 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) {struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *old_intel_state =to_intel_crtc_state (old_crtc_state);bool modeset =needs_modeset (crtc->state); +enum pipe pipe = intel_crtc->pipe;/* Perform vblank evasion around commit operation */ intel_pipe_update_start (intel_crtc);
@@ -14646,8 +14659,12 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,if (to_intel_crtc_state (crtc->state)->update_pipe)intel_update_pipe_config (intel_crtc, old_intel_state); -else if (INTEL_INFO (dev)->gen >=9 ) +else if (INTEL_GEN (dev_priv) >=9 ) {skl_detach_scalers (intel_crtc); + +I915_WRITE (PIPE_WM_LINETIME (pipe), + dev_priv->wm.skl_hw.wm_linetime[pipe]); + } } static void intel_finish_crtc_commit(struct drm_crtc *crtc,
drivers/gpu/drm/i915/intel_drv.h +5 -0
@@ -1725,6 +1725,11 @@ void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,bool skl_can_enable_sagv (struct drm_atomic_state *state);int skl_enable_sagv (struct drm_i915_private *dev_priv);int skl_disable_sagv (struct drm_i915_private *dev_priv); +void skl_write_cursor_wm (struct intel_crtc *intel_crtc, +const struct skl_wm_values *wm); +void skl_write_plane_wm (struct intel_crtc *intel_crtc, +const struct skl_wm_values *wm, +int plane);uint32_t ilk_pipe_pixel_rate (const struct intel_crtc_state *pipe_config);bool ilk_disable_lp_wm (struct drm_device *dev);int sanitize_rc6_option (struct drm_i915_private *dev_priv,int enable_rc6);
drivers/gpu/drm/i915/intel_pm.c +34 -16
68 lines not on this page · raw message
drivers/gpu/drm/i915/intel_sprite.c +9 -0
@@ -203,6 +203,9 @@ skl_update_plane(struct drm_plane *drm_plane,struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_plane *intel_plane =to_intel_plane (drm_plane);struct drm_framebuffer *fb = plane_state->base.fb; +const struct skl_wm_values *wm = &dev_priv->wm.skl_results; +struct drm_crtc *crtc = crtc_state->base.crtc; +struct intel_crtc *intel_crtc =to_intel_crtc (crtc);const int pipe = intel_plane->pipe;const int plane = intel_plane->plane +1 ;u32 plane_ctl;
@@ -228,6 +231,9 @@ skl_update_plane(struct drm_plane *drm_plane, plane_ctl |=skl_plane_ctl_rotation (rotation); +if (wm->dirty_pipes &drm_crtc_mask (crtc)) +skl_write_plane_wm (intel_crtc, wm, plane); +if (key->flags) {I915_WRITE (PLANE_KEYVAL (pipe, plane), key->min_value);I915_WRITE (PLANE_KEYMAX (pipe, plane), key->max_value);
@@ -286,6 +292,9 @@ skl_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)const int pipe = intel_plane->pipe;const int plane = intel_plane->plane +1 ; +skl_write_plane_wm (to_intel_crtc (crtc), &dev_priv->wm.skl_results, + plane); +I915_WRITE (PLANE_CTL (pipe, plane),0 );I915_WRITE (PLANE_SURF (pipe, plane),0 );
Signature · 1 line
2.7.4
Maarten Lankhorst
AppliedRe: [PATCH v13 4/7] drm/i915/skl: Update plane watermarks atomically during plane updates
Op 22-08-16 om 18:50 schreef Lyude:
Quoted 8 lines
Thanks to Ville for suggesting this as a potential solution to pipe underruns on Skylake.
On Skylake all of the registers for configuring planes, including the registers for configuring their watermarks, are double buffered. New values written to them won't take effect until said registers are "armed", which is done by writing to the
PLANE_SURF(or in the case of cursor planes, the CURBASE register) register.
Applied, thanks.
Can you resend 6/7 and 7/7?
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH RESEND v13 6/7 drm/i915: Move CRTC updating in atomic_commit into it's own hook
Since we have to write ddb allocations at the same time as we do other plane updates, we're going to need to be able to control the order in which we execute modesets on each pipe. The easiest way to do this is to just factor this section of intel_atomic_commit_tail() (intel_atomic_commit() for stable branches) into it's own function, and add an appropriate display function hook for it.
Based off of Matt Rope's suggestions
Changes since v1:
- Drop pipe_config->base.active check in intel_update_crtcs() since we check that before calling the function
[omitting CC for stable, since this patch will need to be changed for such backports first]
Cc: Ville Syrjälä <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Radhakrishna Sripada <[email protected]>
Cc: Hans de Goede <[email protected]>
--- drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/intel_display.c | 74 +++++++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -514,6 +514,8 @@ struct drm_i915_display_funcs { struct drm_atomic_state *old_state);void (*crtc_disable)(struct intel_crtc_state *old_crtc_state,struct drm_atomic_state *old_state); +void (*update_crtcs)(struct drm_atomic_state *state, +unsigned int *crtc_vblank_mask);void (*audio_codec_enable)(struct drm_connector *connector,struct intel_encoder *encoder,const struct drm_display_mode *adjusted_mode);
drivers/gpu/drm/i915/intel_display.c +52 -22
102 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH RESEND v13 7/7 drm/i915/skl: Update DDB values atomically with wms/plane attrs
Now that we can hook into update_crtcs and control the order in which we update CRTCs at each modeset, we can finish the final step of fixing Skylake's watermark handling by performing DDB updates at the same time as plane updates and watermark updates.
The first major change in this patch is skl_update_crtcs(), which handles ensuring that we order each CRTC update in our atomic commits properly so that they honor the DDB flush order.
The second major change in this patch is the order in which we flush the pipes. While the previous order may have worked, it can't be used in this approach since it no longer will do the right thing. For example, using the old ddb flush order:
We have pipes A, B, and C enabled, and we're disabling C. Initial ddb allocation looks like this:
| A | B |xxxxxxx|
Since we're performing the ddb updates after performing any CRTC disablements in intel_atomic_commit_tail(), the space to the right of pipe B is unallocated.
1. Flush pipes with new allocation contained into old space. None apply, so we skip this
2. Flush pipes having their allocation reduced, but overlapping with a previous allocation. None apply, so we also skip this
3. Flush pipes that got more space allocated. This applies to A and B, giving us the following update order: A, B
This is wrong, since updating pipe A first will cause it to overlap with B and potentially burst into flames. Our new order (see the code comments for details) would update the pipes in the proper order: B, A.
As well, we calculate the order for each DDB update during the check phase, and reference it later in the commit phase when we hit skl_update_crtcs().
This long overdue patch fixes the rest of the underruns on Skylake.
Changes since v1:
- Add skl_ddb_entry_write() for cursor into skl_write_cursor_wm()
Changes since v2:
- Use the method for updating CRTCs that Ville suggested
- In skl_update_wm(), only copy the watermarks for the crtc that was passed to us
Changes since v3:
- Small comment fix in skl_ddb_allocation_overlaps()
Changes since v4:
- Remove the second loop in intel_update_crtcs() and use Ville's suggestion for updating the ddb allocations in the right order
- Get rid of the second loop and just use the ddb state as it updates to determine what order to update everything in (thanks for the suggestion Ville)
- Simplify skl_ddb_allocation_overlaps()
- Split actual overlap checking into it's own helper
[omitting CC for stable, since this patch will need to be changed for such backports first]
Testcase: kms_cursor_legacy
Testcase: plane-all-modeset-transition
--- drivers/gpu/drm/i915/intel_display.c | 93 +++++++++++++--- drivers/gpu/drm/i915/intel_drv.h | 7 ++ drivers/gpu/drm/i915/intel_pm.c | 200 ++++++++--------------------------- 3 files changed, 132 insertions(+), 168 deletions(-)
drivers/gpu/drm/i915/intel_display.c +81 -12
@@ -13483,16 +13483,23 @@ static void verify_wm_state(struct drm_crtc *crtc, hw_entry->start, hw_entry->end); } -/* cursor */ - hw_entry = &hw_ddb.plane[pipe][PLANE_CURSOR ]; - sw_entry = &sw_ddb->plane[pipe][PLANE_CURSOR ]; - -if (!skl_ddb_entry_equal (hw_entry, sw_entry)) { -DRM_ERROR ("mismatch in DDB state pipe %c cursor " -"(expected (%u,%u), found (%u,%u))\n" , -pipe_name (pipe), - sw_entry->start, sw_entry->end, - hw_entry->start, hw_entry->end); +/* +* cursor +* If the cursor plane isn't active, we may not have updated it's ddb +* allocation. In that case since the ddb allocation will be updated +* once the plane becomes visible, we can skip this check +*/ +if (intel_crtc->cursor_addr) { + hw_entry = &hw_ddb.plane[pipe][PLANE_CURSOR ]; + sw_entry = &sw_ddb->plane[pipe][PLANE_CURSOR ]; + +if (!skl_ddb_entry_equal (hw_entry, sw_entry)) { +DRM_ERROR ("mismatch in DDB state pipe %c cursor " +"(expected (%u,%u), found (%u,%u))\n" , +pipe_name (pipe), + sw_entry->start, sw_entry->end, + hw_entry->start, hw_entry->end); + } } }
@@ -14244,6 +14251,65 @@ static void intel_update_crtcs(struct drm_atomic_state *state, } } +static void skl_update_crtcs (struct drm_atomic_state *state, +unsigned int *crtc_vblank_mask) +{ +struct drm_device *dev = state->dev; +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_atomic_state *intel_state =to_intel_atomic_state (state); +struct drm_crtc *crtc; +struct drm_crtc_state *old_crtc_state; +struct skl_ddb_allocation *new_ddb = &intel_state->wm_results.ddb; +struct skl_ddb_allocation *cur_ddb = &dev_priv->wm.skl_hw.ddb; +unsigned int updated =0 ; +bool progress; +enum pipe pipe; + +/* +* Whenever the number of active pipes changes, we need to make sure we +* update the pipes in the right order so that their ddb allocations +* never overlap with eachother inbetween CRTC updates. Otherwise we'll +* cause pipe underruns and other bad stuff. +*/ +do { +int i; + progress = false; + +for_each_crtc_in_state (state, crtc, old_crtc_state, i) { +bool vbl_wait = false; +unsigned int cmask =drm_crtc_mask (crtc); + pipe =to_intel_crtc (crtc)->pipe; + +if (updated & cmask || !crtc->state->active) +continue ; +if (skl_ddb_allocation_overlaps (state, cur_ddb, new_ddb, + pipe)) +continue ; + + updated |= cmask; + +/* +* If this is an already active pipe, it's DDB changed, +* and this isn't the last pipe that needs updating +* then we need to wait for a vblank to pass for the +* new ddb allocation to take effect. +*/ +if (!skl_ddb_allocation_equals (cur_ddb, new_ddb, pipe) && + !crtc->state->active_changed && + intel_state->wm_results.dirty_pipes != updated) + vbl_wait = true; + +intel_update_crtc (crtc, state, old_crtc_state, + crtc_vblank_mask); + +if (vbl_wait) +intel_wait_for_vblank (dev, pipe); + + progress = true; + } + }while (progress); +} +static void intel_atomic_commit_tail (struct drm_atomic_state *state) {struct drm_device *dev = state->dev;
@@ -15883,8 +15949,6 @@ void intel_init_display_hooks(struct drm_i915_private *dev_priv) dev_priv->display.crtc_disable = i9xx_crtc_disable; } - dev_priv->display.update_crtcs = intel_update_crtcs; -/* Returns the core display clock speed */ if (IS_SKYLAKE (dev_priv) ||IS_KABYLAKE (dev_priv)) dev_priv->display.get_display_clock_speed =
@@ -15974,6 +16038,11 @@ void intel_init_display_hooks(struct drm_i915_private *dev_priv) skl_modeset_calc_cdclk; } +if (dev_priv->info.gen >=9 ) + dev_priv->display.update_crtcs = skl_update_crtcs; +else + dev_priv->display.update_crtcs = intel_update_crtcs; +switch (INTEL_INFO (dev_priv)->gen) {case 2 : dev_priv->display.queue_flip = intel_gen2_queue_flip;
drivers/gpu/drm/i915/intel_drv.h +7 -0
@@ -1743,6 +1743,13 @@ void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,bool skl_can_enable_sagv (struct drm_atomic_state *state);int skl_enable_sagv (struct drm_i915_private *dev_priv);int skl_disable_sagv (struct drm_i915_private *dev_priv); +bool skl_ddb_allocation_equals (const struct skl_ddb_allocation *old, +const struct skl_ddb_allocation *new, +enum pipe pipe); +bool skl_ddb_allocation_overlaps (struct drm_atomic_state *state, +const struct skl_ddb_allocation *old, +const struct skl_ddb_allocation *new, +enum pipe pipe);void skl_write_cursor_wm (struct intel_crtc *intel_crtc,const struct skl_wm_values *wm); void skl_write_plane_wm(struct intel_crtc *intel_crtc,
drivers/gpu/drm/i915/intel_pm.c +44 -156
242 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v12 5/7 drm/i915/skl: Ensure pipes with changed wms get added to the state
In reply to LyudeIf we're enabling a pipe, we'll need to modify the watermarks on all active planes. Since those planes won't be added to the state on their own, we need to add them ourselves.
--- drivers/gpu/drm/i915/intel_pm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
@@ -4117,6 +4117,10 @@ skl_compute_ddb(struct drm_atomic_state *state) ret =skl_allocate_pipe_ddb (cstate, ddb);if (ret)return ret; + + ret =drm_atomic_add_affected_planes (state, &intel_crtc->base); +if (ret) +return ret; }return 0 ;
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v12 5/7] drm/i915/skl: Ensure pipes with changed wms get added to the state
Hi
I've bisected back to this commit in the drm-intel-nightly branch
05a76d3d6ad1ee9f9814f88949cc9305fc165460 is the first bad commit commit 05a76d3d6ad1ee9f9814f88949cc9305fc165460
Author: Lyude <[email protected]> Date: Wed Aug 17 15:55:57 2016 -0400
drm/i915/skl: Ensure pipes with changed wms get added to the state
If we're enabling a pipe, we'll need to modify the watermarks on all active planes. Since those planes won't be added to the state on their own, we need to add them ourselves.
Link:
http://patchwork.freedesktop.org/patch/msgid/[email protected]
The symptoms I'm seeing look like tearing at the top of the screen and it's especially noticeable in Chrome - reverting this commit makes the issue go away
Let me know if you'd like me to raise a bug
Cheers
Mike
Quoted 32 lines · On Wed, 17 Aug 2016 at 20:56 Lyude <[email protected]> wrote:
If we're enabling a pipe, we'll need to modify the watermarks on all active planes. Since those planes won't be added to the state on their own, we need to add them ourselves.
Signed-off-by Lyude <[email protected]>Reviewed-by Matt Roper <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Daniel Vetter <[email protected]>Cc Radhakrishna Sripada <[email protected]>Cc Hans de Goede <[email protected]>--- drivers/gpu/drm/i915/intel_pm.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/i915/intel_pm.c +4
-0@@ -4117,6 +4117,10 @@ skl_compute_ddb(struct drm_atomic_state *state) ret =skl_allocate_pipe_ddb (cstate, ddb);if (ret)return ret; + + ret =drm_atomic_add_affected_planes (state, &intel_crtc->base); +if (ret) +return ret; }return 0;
Quoted 8 lines
--
2.7.4_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v12 5/7] drm/i915/skl: Ensure pipes with changed wms get added to the state
In reply to LyudeHi
I've bisected back to this commit in the drm-intel-nightly branch
05a76d3d6ad1ee9f9814f88949cc9305fc165460 is the first bad commit commit 05a76d3d6ad1ee9f9814f88949cc9305fc165460
Author: Lyude <[email protected]> Date: Wed Aug 17 15:55:57 2016 -0400
drm/i915/skl: Ensure pipes with changed wms get added to the state
If we're enabling a pipe, we'll need to modify the watermarks on all active planes. Since those planes won't be added to the state on their own, we need to add them ourselves.
The symptoms I'm seeing look like tearing at the top of the screen and it's especially noticeable in Chrome - reverting this commit makes the issue go away
Let me know if you'd like me to raise a bug
Cheers
Mike
(Re-sending from Gmail - as Inbox doesn't let me send as plain text)
Quoted 37 lines · Lyude
If we're enabling a pipe, we'll need to modify the watermarks on all active planes. Since those planes won't be added to the state on their own, we need to add them ourselves.
Signed-off-by Lyude <[email protected]>Reviewed-by Matt Roper <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Daniel Vetter <[email protected]>Cc Radhakrishna Sripada <[email protected]>Cc Hans de Goede <[email protected]>--- drivers/gpu/drm/i915/intel_pm.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/i915/intel_pm.c +4
-1@@ -4117,6 +4117,10 @@ skl_compute_ddb(struct drm_atomic_state *state) ret =skl_allocate_pipe_ddb (cstate, ddb);if (ret)return ret; + + ret =drm_atomic_add_affected_planes (state, &intel_crtc->base); +if (ret) +return ret; }return 0 ; --2.7.4
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v12 5/7] drm/i915/skl: Ensure pipes with changed wms get added to the state
Hey,
Op 20-09-16 om 20:45 schreef Mike Lothian:
Quoted 25 lines
Hi
I've bisected back to this commit in the drm-intel-nightly branch
05a76d3d6ad1ee9f9814f88949cc9305fc165460is the first bad commit commit05a76d3d6ad1ee9f9814f88949cc9305fc165460Author: Lyude <[email protected]> Date: Wed Aug 17 15:55:57 2016 -0400drm/i915/skl: Ensure pipes with changed wms get added to the state
If we're enabling a pipe, we'll need to modify the watermarks on all active planes. Since those planes won't be added to the state on their own, we need to add them ourselves.
Signed-off-by Lyude <[email protected]>Reviewed-by Matt Roper <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Daniel Vetter <[email protected]>Cc Radhakrishna Sripada <[email protected]>Cc Hans de Goede <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>
Quoted 5 lines
The symptoms I'm seeing look like tearing at the top of the screen and it's especially noticeable in Chrome - reverting this commit makes the issue go away
Let me know if you'd like me to raise a bug
Please do so, it's nice to refer to when making a fix for it.
Could you attach the contents of /sys/kernel/debug/dri/0/i915_ddb_info for working and not-working in it?
~Maarten
Re: [PATCH v12 5/7] drm/i915/skl: Ensure pipes with changed wms get added to the state
Will do.
Quoted 33 lines · On Wed, 21 Sep 2016 at 07:56 Maarten Lankhorst <…
Hey,
Op 20-09-16 om 20:45 schreef Mike Lothian:
Quoted 23 lines
Hi
I've bisected back to this commit in the drm-intel-nightly branch
05a76d3d6ad1ee9f9814f88949cc9305fc165460is the first bad commit commit05a76d3d6ad1ee9f9814f88949cc9305fc165460Author: Lyude <[email protected]> Date: Wed Aug 17 15:55:57 2016 -0400drm/i915/skl: Ensure pipes with changed wms get added to the state
If we're enabling a pipe, we'll need to modify the watermarks on all active planes. Since those planes won't be added to the state on their own, we need to add them ourselves.
Signed-off-by Lyude <[email protected]>Reviewed-by Matt Roper <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Daniel Vetter <[email protected]>Cc Radhakrishna Sripada <[email protected]>Cc Hans de Goede <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>Quoted 1 line
Link:
http://patchwork.freedesktop.org/patch/msgid/[email protected]
Quoted 5 lines
The symptoms I'm seeing look like tearing at the top of the screen and it's especially noticeable in Chrome - reverting this commit makes the issue go away
Quoted 8 lines
Quoted 1 line
Let me know if you'd like me to raise a bug
Please do so, it's nice to refer to when making a fix for it.
Could you attach the contents of
/sys/kernel/debug/dri/0/i915_ddb_infofor working and not-working in it?~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v12 5/7] drm/i915/skl: Ensure pipes with changed wms get added to the state
In reply to Maarten LankhorstI've raised https://bugs.freedesktop.org/show_bug.cgi?id=97888 I'll attach the info you requested once I get back to my machine
Quoted 38 lines · Maarten Lankhorst
Hey,
Op 20-09-16 om 20:45 schreef Mike Lothian:
Quoted 25 lines
Hi
I've bisected back to this commit in the drm-intel-nightly branch
05a76d3d6ad1ee9f9814f88949cc9305fc165460is the first bad commit commit05a76d3d6ad1ee9f9814f88949cc9305fc165460Author: Lyude <[email protected]> Date: Wed Aug 17 15:55:57 2016 -0400drm/i915/skl: Ensure pipes with changed wms get added to the state
If we're enabling a pipe, we'll need to modify the watermarks on all active planes. Since those planes won't be added to the state on their own, we need to add them ourselves.
Signed-off-by Lyude <[email protected]>Reviewed-by Matt Roper <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Daniel Vetter <[email protected]>Cc Radhakrishna Sripada <[email protected]>Cc Hans de Goede <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>Quoted 5 lines
The symptoms I'm seeing look like tearing at the top of the screen and it's especially noticeable in Chrome - reverting this commit makes the issue go away
Let me know if you'd like me to raise a bug
Please do so, it's nice to refer to when making a fix for it.
Could you attach the contents of
/sys/kernel/debug/dri/0/i915_ddb_infofor working and not-working in it?~Maarten
Re: [PATCH v12 5/7] drm/i915/skl: Ensure pipes with changed wms get added to the state
Hi
Is there any chance this could be removed from the upcoming drm-4.9 pull, at least until this issue has been fixed
Regards
Mike
Quoted 43 lines · Mike Lothian
I've raised https://bugs.freedesktop.org/show_bug.cgi?id=97888 I'll attach the info you requested once I get back to my machine
Quoted 38 lines · Maarten Lankhorst
Hey,
Op 20-09-16 om 20:45 schreef Mike Lothian:
Quoted 25 lines
Hi
I've bisected back to this commit in the drm-intel-nightly branch
05a76d3d6ad1ee9f9814f88949cc9305fc165460is the first bad commit commit05a76d3d6ad1ee9f9814f88949cc9305fc165460Author: Lyude <[email protected]> Date: Wed Aug 17 15:55:57 2016 -0400drm/i915/skl: Ensure pipes with changed wms get added to the state
If we're enabling a pipe, we'll need to modify the watermarks on all active planes. Since those planes won't be added to the state on their own, we need to add them ourselves.
Signed-off-by Lyude <[email protected]>Reviewed-by Matt Roper <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Daniel Vetter <[email protected]>Cc Radhakrishna Sripada <[email protected]>Cc Hans de Goede <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>Quoted 5 lines
The symptoms I'm seeing look like tearing at the top of the screen and it's especially noticeable in Chrome - reverting this commit makes the issue go away
Let me know if you'd like me to raise a bug
Please do so, it's nice to refer to when making a fix for it.
Could you attach the contents of
/sys/kernel/debug/dri/0/i915_ddb_infofor working and not-working in it?~Maarten
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v12 6/7 drm/i915: Move CRTC updating in atomic_commit into it's own hook
In reply to LyudeSince we have to write ddb allocations at the same time as we do other plane updates, we're going to need to be able to control the order in which we execute modesets on each pipe. The easiest way to do this is to just factor this section of intel_atomic_commit_tail() (intel_atomic_commit() for stable branches) into it's own function, and add an appropriate display function hook for it.
Based off of Matt Rope's suggestions
Changes since v1:
- Drop pipe_config->base.active check in intel_update_crtcs() since we check that before calling the function
[omitting CC for stable, since this patch will need to be changed for such backports first]
Cc: Ville Syrjälä <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Radhakrishna Sripada <[email protected]>
Cc: Hans de Goede <[email protected]>
--- drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/intel_display.c | 74 +++++++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -506,6 +506,8 @@ struct drm_i915_display_funcs { struct intel_crtc_state *crtc_state);void (*crtc_enable)(struct drm_crtc *crtc);void (*crtc_disable)(struct drm_crtc *crtc); +void (*update_crtcs)(struct drm_atomic_state *state, +unsigned int *crtc_vblank_mask);void (*audio_codec_enable)(struct drm_connector *connector,struct intel_encoder *encoder,const struct drm_display_mode *adjusted_mode);
drivers/gpu/drm/i915/intel_display.c +52 -22
102 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v12 7/7 drm/i915/skl: Update DDB values atomically with wms/plane attrs
In reply to LyudeNow that we can hook into update_crtcs and control the order in which we update CRTCs at each modeset, we can finish the final step of fixing Skylake's watermark handling by performing DDB updates at the same time as plane updates and watermark updates.
The first major change in this patch is skl_update_crtcs(), which handles ensuring that we order each CRTC update in our atomic commits properly so that they honor the DDB flush order.
The second major change in this patch is the order in which we flush the pipes. While the previous order may have worked, it can't be used in this approach since it no longer will do the right thing. For example, using the old ddb flush order:
We have pipes A, B, and C enabled, and we're disabling C. Initial ddb allocation looks like this:
| A | B |xxxxxxx|
Since we're performing the ddb updates after performing any CRTC disablements in intel_atomic_commit_tail(), the space to the right of pipe B is unallocated.
1. Flush pipes with new allocation contained into old space. None apply, so we skip this
2. Flush pipes having their allocation reduced, but overlapping with a previous allocation. None apply, so we also skip this
3. Flush pipes that got more space allocated. This applies to A and B, giving us the following update order: A, B
This is wrong, since updating pipe A first will cause it to overlap with B and potentially burst into flames. Our new order (see the code comments for details) would update the pipes in the proper order: B, A.
As well, we calculate the order for each DDB update during the check phase, and reference it later in the commit phase when we hit skl_update_crtcs().
This long overdue patch fixes the rest of the underruns on Skylake.
Changes since v1:
- Add skl_ddb_entry_write() for cursor into skl_write_cursor_wm()
Changes since v2:
- Use the method for updating CRTCs that Ville suggested
- In skl_update_wm(), only copy the watermarks for the crtc that was passed to us
Changes since v3:
- Small comment fix in skl_ddb_allocation_overlaps()
Changes since v4:
- Remove the second loop in intel_update_crtcs() and use Ville's suggestion for updating the ddb allocations in the right order
- Get rid of the second loop and just use the ddb state as it updates to determine what order to update everything in (thanks for the suggestion Ville)
- Simplify skl_ddb_allocation_overlaps()
- Split actual overlap checking into it's own helper
[omitting CC for stable, since this patch will need to be changed for such backports first]
Testcase: kms_cursor_legacy
--- drivers/gpu/drm/i915/intel_display.c | 93 +++++++++++++--- drivers/gpu/drm/i915/intel_drv.h | 7 ++ drivers/gpu/drm/i915/intel_pm.c | 200 ++++++++--------------------------- 3 files changed, 132 insertions(+), 168 deletions(-)
drivers/gpu/drm/i915/intel_display.c +81 -12
@@ -13361,16 +13361,23 @@ static void verify_wm_state(struct drm_crtc *crtc, hw_entry->start, hw_entry->end); } -/* cursor */ - hw_entry = &hw_ddb.plane[pipe][PLANE_CURSOR ]; - sw_entry = &sw_ddb->plane[pipe][PLANE_CURSOR ]; - -if (!skl_ddb_entry_equal (hw_entry, sw_entry)) { -DRM_ERROR ("mismatch in DDB state pipe %c cursor " -"(expected (%u,%u), found (%u,%u))\n" , -pipe_name (pipe), - sw_entry->start, sw_entry->end, - hw_entry->start, hw_entry->end); +/* +* cursor +* If the cursor plane isn't active, we may not have updated it's ddb +* allocation. In that case since the ddb allocation will be updated +* once the plane becomes visible, we can skip this check +*/ +if (intel_crtc->cursor_addr) { + hw_entry = &hw_ddb.plane[pipe][PLANE_CURSOR ]; + sw_entry = &sw_ddb->plane[pipe][PLANE_CURSOR ]; + +if (!skl_ddb_entry_equal (hw_entry, sw_entry)) { +DRM_ERROR ("mismatch in DDB state pipe %c cursor " +"(expected (%u,%u), found (%u,%u))\n" , +pipe_name (pipe), + sw_entry->start, sw_entry->end, + hw_entry->start, hw_entry->end); + } } }
@@ -14122,6 +14129,65 @@ static void intel_update_crtcs(struct drm_atomic_state *state, } } +static void skl_update_crtcs (struct drm_atomic_state *state, +unsigned int *crtc_vblank_mask) +{ +struct drm_device *dev = state->dev; +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_atomic_state *intel_state =to_intel_atomic_state (state); +struct drm_crtc *crtc; +struct drm_crtc_state *old_crtc_state; +struct skl_ddb_allocation *new_ddb = &intel_state->wm_results.ddb; +struct skl_ddb_allocation *cur_ddb = &dev_priv->wm.skl_hw.ddb; +unsigned int updated =0 ; +bool progress; +enum pipe pipe; + +/* +* Whenever the number of active pipes changes, we need to make sure we +* update the pipes in the right order so that their ddb allocations +* never overlap with eachother inbetween CRTC updates. Otherwise we'll +* cause pipe underruns and other bad stuff. +*/ +do { +int i; + progress = false; + +for_each_crtc_in_state (state, crtc, old_crtc_state, i) { +bool vbl_wait = false; +unsigned int cmask =drm_crtc_mask (crtc); + pipe =to_intel_crtc (crtc)->pipe; + +if (updated & cmask || !crtc->state->active) +continue ; +if (skl_ddb_allocation_overlaps (state, cur_ddb, new_ddb, + pipe)) +continue ; + + updated |= cmask; + +/* +* If this is an already active pipe, it's DDB changed, +* and this isn't the last pipe that needs updating +* then we need to wait for a vblank to pass for the +* new ddb allocation to take effect. +*/ +if (!skl_ddb_allocation_equals (cur_ddb, new_ddb, pipe) && + !crtc->state->active_changed && + intel_state->wm_results.dirty_pipes != updated) + vbl_wait = true; + +intel_update_crtc (crtc, state, old_crtc_state, + crtc_vblank_mask); + +if (vbl_wait) +intel_wait_for_vblank (dev, pipe); + + progress = true; + } + }while (progress); +} +static void intel_atomic_commit_tail (struct drm_atomic_state *state) {struct drm_device *dev = state->dev;
@@ -15761,8 +15827,6 @@ void intel_init_display_hooks(struct drm_i915_private *dev_priv) dev_priv->display.crtc_disable = i9xx_crtc_disable; } - dev_priv->display.update_crtcs = intel_update_crtcs; -/* Returns the core display clock speed */ if (IS_SKYLAKE (dev_priv) ||IS_KABYLAKE (dev_priv)) dev_priv->display.get_display_clock_speed =
@@ -15852,6 +15916,11 @@ void intel_init_display_hooks(struct drm_i915_private *dev_priv) skl_modeset_calc_cdclk; } +if (dev_priv->info.gen >=9 ) + dev_priv->display.update_crtcs = skl_update_crtcs; +else + dev_priv->display.update_crtcs = intel_update_crtcs; +switch (INTEL_INFO (dev_priv)->gen) {case 2 : dev_priv->display.queue_flip = intel_gen2_queue_flip;
drivers/gpu/drm/i915/intel_drv.h +7 -0
@@ -1725,6 +1725,13 @@ void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,bool skl_can_enable_sagv (struct drm_atomic_state *state);int skl_enable_sagv (struct drm_i915_private *dev_priv);int skl_disable_sagv (struct drm_i915_private *dev_priv); +bool skl_ddb_allocation_equals (const struct skl_ddb_allocation *old, +const struct skl_ddb_allocation *new, +enum pipe pipe); +bool skl_ddb_allocation_overlaps (struct drm_atomic_state *state, +const struct skl_ddb_allocation *old, +const struct skl_ddb_allocation *new, +enum pipe pipe);void skl_write_cursor_wm (struct intel_crtc *intel_crtc,const struct skl_wm_values *wm); void skl_write_plane_wm(struct intel_crtc *intel_crtc,
drivers/gpu/drm/i915/intel_pm.c +44 -156
242 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✗ Ro.CI.BAT: failure for Finally fix watermarks (rev10)
In reply to Lyude== Series Details ==
== Series Details ==
Series: Finally fix watermarks (rev10)
URL : https://patchwork.freedesktop.org/series/10276/
State : failure
== Summary ==
Series 10276v10 Finally fix watermarks
http://patchwork.freedesktop.org/api/1.0/series/10276/revisions/10/mbox
Test drv_module_reload_basic:
pass -> DMESG-WARN (fi-snb-i7-2600)
Test gem_exec_suspend:
Subgroup basic-s3:
pass -> DMESG-WARN (fi-snb-i7-2600)
Test kms_cursor_legacy:
Subgroup basic-flip-vs-cursor-legacy:
pass -> FAIL (ro-skl3-i5-6260u)
Subgroup basic-flip-vs-cursor-varying-size:
pass -> FAIL (ro-byt-n2820)
fail -> PASS (ro-skl3-i5-6260u)
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-a:
pass -> DMESG-WARN (ro-bdw-i7-5600u)
skip -> DMESG-WARN (ro-bdw-i7-5557U)
skip -> DMESG-WARN (ro-bdw-i5-5250u)
pass -> INCOMPLETE (fi-snb-i7-2600)
Subgroup suspend-read-crc-pipe-b:
dmesg-warn -> SKIP (ro-bdw-i7-5557U)
skip -> DMESG-WARN (ro-bdw-i5-5250u)
Subgroup suspend-read-crc-pipe-c:
pass -> DMESG-WARN (ro-bdw-i7-5600u)fi-kbl-qkkr total:244 pass:185 dwarn:30 dfail:0 fail:2 skip:27 fi-skl-i7-6700k total:244 pass:212 dwarn:0 dfail:0 fail:4 skip:28 fi-snb-i7-2600 total:201 pass:164 dwarn:2 dfail:0 fail:0 skip:34 ro-bdw-i5-5250u total:240 pass:219 dwarn:3 dfail:0 fail:1 skip:17 ro-bdw-i7-5557U total:240 pass:220 dwarn:2 dfail:0 fail:0 skip:18 ro-bdw-i7-5600u total:240 pass:205 dwarn:2 dfail:0 fail:1 skip:32 ro-bsw-n3050 total:240 pass:195 dwarn:0 dfail:0 fail:3 skip:42 ro-byt-n2820 total:240 pass:197 dwarn:0 dfail:0 fail:3 skip:40 ro-hsw-i3-4010u total:240 pass:214 dwarn:0 dfail:0 fail:0 skip:26 ro-hsw-i7-4770r total:240 pass:185 dwarn:0 dfail:0 fail:0 skip:55 ro-ilk1-i5-650 total:235 pass:174 dwarn:0 dfail:0 fail:1 skip:60 ro-ivb-i7-3770 total:240 pass:205 dwarn:0 dfail:0 fail:0 skip:35 ro-ivb2-i7-3770 total:240 pass:209 dwarn:0 dfail:0 fail:0 skip:31 ro-skl3-i5-6260u total:240 pass:223 dwarn:0 dfail:0 fail:3 skip:14
Results at /archive/results/CI_IGT_test/RO_Patchwork_1913/
e45fdef drm-intel-nightly: 2016y-08m-17d-13h-26m-04s UTC integration manifest 151bcaa drm/i915/skl: Update DDB values atomically with wms/plane attrs e30cd30 drm/i915: Move CRTC updating in atomic_commit into it's own hook 1761b51 drm/i915/skl: Ensure pipes with changed wms get added to the state 363c839 drm/i915/skl: Update plane watermarks atomically during plane updates afaab70 drm/i915/gen9: Only copy WM results for changed pipes to skl_hw eeb12a7 drm/i915/skl: Add support for the SAGV, fix underrun hangs 9f250a0 drm/i915/gen6+: Interpret mailbox error flags
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Ro.CI.BAT: failure for Finally fix watermarks (rev11)
In reply to Lyude== Series Details ==
== Series Details ==
Series: Finally fix watermarks (rev11)
URL : https://patchwork.freedesktop.org/series/10276/
State : failure
== Summary ==
Applying: drm/i915/gen6+: Interpret mailbox error flags Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/i915_reg.h
M drivers/gpu/drm/i915/intel_pm.c
Falling back to patching base and 3-way merge... Auto-merging drivers/gpu/drm/i915/intel_pm.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/intel_pm.c
error: Failed to merge in the changes.
Patch failed at 0001 drm/i915/gen6+: Interpret mailbox error flags The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx