Re: [Intel-gfx] [PATCH 06/10] drm/i915: Use the memory latency based WM computation on VLV too

2015-06-26 Thread Clint Taylor

On 06/24/2015 12:00 PM, ville.syrj...@linux.intel.com wrote:

From: Ville Syrjälä 

In order to get decnet memory self refresh residency on VLV, flip it
over to the new CHV way of doing things. VLV doesn't do PM5 or DDR DVFS
so it's a bit simpler.

I'm not sure the currently memory latency used for CHV is really
appropriate for VLV. Some further testing will probably be needed to
figure that out.

Signed-off-by: Ville Syrjälä 
---
  drivers/gpu/drm/i915/intel_display.c |   2 +-
  drivers/gpu/drm/i915/intel_pm.c  | 223 +--
  drivers/gpu/drm/i915/intel_sprite.c  |   6 -
  3 files changed, 6 insertions(+), 225 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 1424320..d67b5f1 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -15476,7 +15476,7 @@ void intel_modeset_setup_hw_state(struct drm_device 
*dev,
pll->on = false;
}

-   if (IS_CHERRYVIEW(dev))
+   if (IS_VALLEYVIEW(dev))
vlv_wm_get_hw_state(dev);
else if (IS_GEN9(dev))
skl_wm_get_hw_state(dev);
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index ffdca62..c7c90ce 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -931,77 +931,6 @@ static void vlv_write_wm_values(struct intel_crtc *crtc,

  #undef FW_WM_VLV

-static uint8_t vlv_compute_drain_latency(struct drm_crtc *crtc,
-struct drm_plane *plane)
-{
-   struct drm_device *dev = crtc->dev;
-   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-   int entries, prec_mult, drain_latency, pixel_size;
-   int clock = intel_crtc->config->base.adjusted_mode.crtc_clock;
-   const int high_precision = IS_CHERRYVIEW(dev) ? 16 : 64;
-
-   /*
-* FIXME the plane might have an fb
-* but be invisible (eg. due to clipping)
-*/
-   if (!intel_crtc->active || !plane->state->fb)
-   return 0;
-
-   if (WARN(clock == 0, "Pixel clock is zero!\n"))
-   return 0;
-
-   pixel_size = drm_format_plane_cpp(plane->state->fb->pixel_format, 0);
-
-   if (WARN(pixel_size == 0, "Pixel size is zero!\n"))
-   return 0;
-
-   entries = DIV_ROUND_UP(clock, 1000) * pixel_size;
-
-   prec_mult = high_precision;
-   drain_latency = 64 * prec_mult * 4 / entries;
-
-   if (drain_latency > DRAIN_LATENCY_MASK) {
-   prec_mult /= 2;
-   drain_latency = 64 * prec_mult * 4 / entries;
-   }
-
-   if (drain_latency > DRAIN_LATENCY_MASK)
-   drain_latency = DRAIN_LATENCY_MASK;
-
-   return drain_latency | (prec_mult == high_precision ?
-   DDL_PRECISION_HIGH : DDL_PRECISION_LOW);
-}
-
-static int vlv_compute_wm(struct intel_crtc *crtc,
- struct intel_plane *plane,
- int fifo_size)
-{
-   int clock, entries, pixel_size;
-
-   /*
-* FIXME the plane might have an fb
-* but be invisible (eg. due to clipping)
-*/
-   if (!crtc->active || !plane->base.state->fb)
-   return 0;
-
-   pixel_size = drm_format_plane_cpp(plane->base.state->fb->pixel_format, 
0);
-   clock = crtc->config->base.adjusted_mode.crtc_clock;
-
-   entries = DIV_ROUND_UP(clock, 1000) * pixel_size;
-
-   /*
-* Set up the watermark such that we don't start issuing memory
-* requests until we are within PND's max deadline value (256us).
-* Idea being to be idle as long as possible while still taking
-* advatange of PND's deadline scheduling. The limit of 8
-* cachelines (used when the FIFO will anyway drain in less time
-* than 256us) should match what we would be done if trickle
-* feed were enabled.
-*/
-   return fifo_size - clamp(DIV_ROUND_UP(256 * entries, 64), 0, fifo_size 
- 8);
-}
-
  enum vlv_wm_level {
VLV_WM_LEVEL_PM2,
VLV_WM_LEVEL_PM5,
@@ -1076,101 +1005,6 @@ static uint16_t vlv_compute_wm_level(struct intel_plane 
*plane,
return min_t(int, wm, USHRT_MAX);
  }

-static bool vlv_compute_sr_wm(struct drm_device *dev,
- struct vlv_wm_values *wm)
-{
-   struct drm_i915_private *dev_priv = to_i915(dev);
-   struct drm_crtc *crtc;
-   enum pipe pipe = INVALID_PIPE;
-   int num_planes = 0;
-   int fifo_size = 0;
-   struct intel_plane *plane;
-
-   wm->sr.cursor = wm->sr.plane = 0;
-
-   crtc = single_enabled_crtc(dev);
-   /* maxfifo not supported on pipe C */
-   if (crtc && to_intel_crtc(crtc)->pipe != PIPE_C) {
-   pipe = to_intel_crtc(crtc)->pipe;
-   num_planes = !!wm->pipe[pipe].primary +
-   !!wm->pipe[pipe].sprite[0] +
-   !!wm->pipe[pipe].

[Intel-gfx] [PATCH 06/10] drm/i915: Use the memory latency based WM computation on VLV too

2015-06-24 Thread ville . syrjala
From: Ville Syrjälä 

In order to get decnet memory self refresh residency on VLV, flip it
over to the new CHV way of doing things. VLV doesn't do PM5 or DDR DVFS
so it's a bit simpler.

I'm not sure the currently memory latency used for CHV is really
appropriate for VLV. Some further testing will probably be needed to
figure that out.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/i915/intel_display.c |   2 +-
 drivers/gpu/drm/i915/intel_pm.c  | 223 +--
 drivers/gpu/drm/i915/intel_sprite.c  |   6 -
 3 files changed, 6 insertions(+), 225 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 1424320..d67b5f1 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -15476,7 +15476,7 @@ void intel_modeset_setup_hw_state(struct drm_device 
*dev,
pll->on = false;
}
 
-   if (IS_CHERRYVIEW(dev))
+   if (IS_VALLEYVIEW(dev))
vlv_wm_get_hw_state(dev);
else if (IS_GEN9(dev))
skl_wm_get_hw_state(dev);
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index ffdca62..c7c90ce 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -931,77 +931,6 @@ static void vlv_write_wm_values(struct intel_crtc *crtc,
 
 #undef FW_WM_VLV
 
-static uint8_t vlv_compute_drain_latency(struct drm_crtc *crtc,
-struct drm_plane *plane)
-{
-   struct drm_device *dev = crtc->dev;
-   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-   int entries, prec_mult, drain_latency, pixel_size;
-   int clock = intel_crtc->config->base.adjusted_mode.crtc_clock;
-   const int high_precision = IS_CHERRYVIEW(dev) ? 16 : 64;
-
-   /*
-* FIXME the plane might have an fb
-* but be invisible (eg. due to clipping)
-*/
-   if (!intel_crtc->active || !plane->state->fb)
-   return 0;
-
-   if (WARN(clock == 0, "Pixel clock is zero!\n"))
-   return 0;
-
-   pixel_size = drm_format_plane_cpp(plane->state->fb->pixel_format, 0);
-
-   if (WARN(pixel_size == 0, "Pixel size is zero!\n"))
-   return 0;
-
-   entries = DIV_ROUND_UP(clock, 1000) * pixel_size;
-
-   prec_mult = high_precision;
-   drain_latency = 64 * prec_mult * 4 / entries;
-
-   if (drain_latency > DRAIN_LATENCY_MASK) {
-   prec_mult /= 2;
-   drain_latency = 64 * prec_mult * 4 / entries;
-   }
-
-   if (drain_latency > DRAIN_LATENCY_MASK)
-   drain_latency = DRAIN_LATENCY_MASK;
-
-   return drain_latency | (prec_mult == high_precision ?
-   DDL_PRECISION_HIGH : DDL_PRECISION_LOW);
-}
-
-static int vlv_compute_wm(struct intel_crtc *crtc,
- struct intel_plane *plane,
- int fifo_size)
-{
-   int clock, entries, pixel_size;
-
-   /*
-* FIXME the plane might have an fb
-* but be invisible (eg. due to clipping)
-*/
-   if (!crtc->active || !plane->base.state->fb)
-   return 0;
-
-   pixel_size = drm_format_plane_cpp(plane->base.state->fb->pixel_format, 
0);
-   clock = crtc->config->base.adjusted_mode.crtc_clock;
-
-   entries = DIV_ROUND_UP(clock, 1000) * pixel_size;
-
-   /*
-* Set up the watermark such that we don't start issuing memory
-* requests until we are within PND's max deadline value (256us).
-* Idea being to be idle as long as possible while still taking
-* advatange of PND's deadline scheduling. The limit of 8
-* cachelines (used when the FIFO will anyway drain in less time
-* than 256us) should match what we would be done if trickle
-* feed were enabled.
-*/
-   return fifo_size - clamp(DIV_ROUND_UP(256 * entries, 64), 0, fifo_size 
- 8);
-}
-
 enum vlv_wm_level {
VLV_WM_LEVEL_PM2,
VLV_WM_LEVEL_PM5,
@@ -1076,101 +1005,6 @@ static uint16_t vlv_compute_wm_level(struct intel_plane 
*plane,
return min_t(int, wm, USHRT_MAX);
 }
 
-static bool vlv_compute_sr_wm(struct drm_device *dev,
- struct vlv_wm_values *wm)
-{
-   struct drm_i915_private *dev_priv = to_i915(dev);
-   struct drm_crtc *crtc;
-   enum pipe pipe = INVALID_PIPE;
-   int num_planes = 0;
-   int fifo_size = 0;
-   struct intel_plane *plane;
-
-   wm->sr.cursor = wm->sr.plane = 0;
-
-   crtc = single_enabled_crtc(dev);
-   /* maxfifo not supported on pipe C */
-   if (crtc && to_intel_crtc(crtc)->pipe != PIPE_C) {
-   pipe = to_intel_crtc(crtc)->pipe;
-   num_planes = !!wm->pipe[pipe].primary +
-   !!wm->pipe[pipe].sprite[0] +
-   !!wm->pipe[pipe].sprite[1];
-   fifo_size = INTEL_INFO(dev_priv)->num_p