[Intel-gfx] why two vertex buffers ?

2012-10-16 Thread baisheng_wang
 Dear All,

In intel 3D driver, It seems there are two vertex buffers: one is struct 
intel_buffer_object (VBO), which catches all vertex
building and drawing commands, such as glVertex3f; Another is struct prim in 
struct intel_context, into which functions like intel_draw_triangle 
accumulate vertex. So why exist two vertex buffers? What's the difference ?

Thanks,
Jacky

 
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 3/4] drm/i915: ILK also needs that last fix

2012-10-16 Thread Daniel Vetter
On Mon, Oct 15, 2012 at 08:21:41PM -0700, Ben Widawsky wrote:
 On Mon, 15 Oct 2012 20:59:22 +0200
 Daniel Vetter dan...@ffwll.ch wrote:
 
  On Wed, Oct 03, 2012 at 07:34:23PM -0700, Ben Widawsky wrote:
   That fix was the disable render deptch cache pipeline flush
   
   Signed-off-by: Ben Widawsky b...@bwidawsk.net
  
  I've stumbled over the same one, but my docs here suggest i965g/gm45
  need it, too:
  
  http://cgit.freedesktop.org/~danvet/drm/commit/?h=ilk-wa-pileid=37c4c82b8cdbcf5adccad97f0b45747ba37ed659
  
  Have you checked whether we don't need this on ivb/vlv/hsw, too?
 
 I did check whether the windows driver does it for those platforms, and
 the answer is no. So the answer to your question is maybe because who
 knows what exists in some other doc somewhere in the metaverse. I think
 this is a good enough start though since it seems SNB was definitely a
 bit buggier than IVB.

Yeah, I've noticed while checking w/as that they're not consistently named
on older platforms. E.g. the above definitely exists on eaglelake, too,
but named slightly different. So the w/a db doesn't pick up all uses.
Hoooray!

  Also, for w/a patches based on the vpg w/a database, please include
  the vpg w/a name tag both in the commit message and in a code comment
  somewhere.
 
 Good idea. If you're okay with longer commit message subjects, I'd even
 suggest putting it there to make it even a bit easier to search for.

Yeah, I'm fine with putting it into the commit head, I've put it there
myself. If the w/a only affects one platform we could try to squeeze the
platform name into the headline, too. But having to read the commit
message for that doesn't really hurt, either.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] DRM/i915: Don't delete DPLL Multiplier during DAC init.

2012-10-16 Thread Daniel Vetter
On Sun, Oct 14, 2012 at 04:33:11PM +0200, Egbert Eich wrote:
 The DPLL multipiler is set up in intel_display.c:i9xx_update_pll()
 called from i9xx_crtc_mode_set().
 There the DPLL multiplier is adjusted so that the SDVO gets a sufficient
 bus clock.
 When cloning a CRTC between an SDVO driven encoder and the standard
 DAC the DAC setup code reseted the multiplier value to 1 thus undoing
 the correct setup. There is no need to touch the multiplier in the DAC
 setup code: the correct value (i.e. 1 in case no SDVO encoder is used)
 is set by i9xx_update_pll() already.
 A comment at the code suggested that this code is a left over from the
 days when there was no setup for clone modes.
 
 Signed-off-by: Egbert Eich e...@suse.de
Picked up for -fixes, thanks for the patch.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] DRM/i915: Add QUIRK_INVERT_BRIGHTNESS for NCR machines.

2012-10-16 Thread Daniel Vetter
On Sun, Oct 14, 2012 at 03:46:38PM +0200, Egbert Eich wrote:
 NCR machines with LVDS panels using Intel chipsets need to have the
 QUIRK_INVERT_BRIGHTNESS bit set.
 Unfortunately NCR doesn't set a meaningful subvendor/subdevice ID,
 therefore we add a DMI dependent quirk list.
 
 Signed-off-by: Egbert Eich e...@suse.de

Meh, I've hoped that this invert-brightness quirk would just disappear.
Looks like it's here to stay. Thanks for the patch, applied to -fixes.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] DRM/i915: Don't clone SDVO LVDS with analog.

2012-10-16 Thread Daniel Vetter
On Sat, Oct 13, 2012 at 02:30:15PM +0200, Egbert Eich wrote:
 SDVO LVDS are not clonable as the input mode gets adjusted by
 the LVDS encoder.
 
 Signed-off-by: Egbert Eich e...@suse.de

Imo cloning should simply die outright. Patch applied, thanks.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] DRM/i915: Restore sdvo_flags after dtd-mode-dtd Roundrtrip.

2012-10-16 Thread Daniel Vetter
On Sat, Oct 13, 2012 at 02:29:31PM +0200, Egbert Eich wrote:
 For TV and LVDS encoders intel_sdvo_set_input_timings_for_mode()
 is called to pass a mode to the sdvo chip and retrieve a dtd
 containing information needed to calculate the adjusted_mode which
 is done by intel_sdvo_get_dtd_from_mode().
 To set this adjusted_mode as input mode for the sdvo chip, a dtd is
 recalculated using intel_sdvo_get_mode_from_dtd(). During this round
 trip the sdvo_flags contained in the dtd obtained from the hardware
 are lost.
 Since these flags cannot be ignored in all cases this patch preserves
 and restores them.
 
 This regression has been introduced in
 
 commit 6651819b4b4fc3caa6964c5d825eb4bb996f3905
 Author: Daniel Vetter daniel.vet...@ffwll.ch
 Date:   Sun Apr 1 19:16:18 2012 +0200
 
 drm/i915: handle input/output sdvo timings separately in mode_set
 
 Signed-off-by: Egbert Eich e...@suse.de

Long term we need to decently improve our adjusted_mode handling and stop
shoveling random state into random structures. Short-term this looks good
enough. Thanks for the patch, applied.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] IVB-eDP regression with on latest git

2012-10-16 Thread Daniel Vetter
On Mon, Oct 15, 2012 at 09:07:33PM +0200, Oleksij Rempel wrote:
 I'll repost it, looks like last message got lost.
 
 Am 14.10.2012 14:49, schrieb Oleksij Rempel:
 Am 14.10.2012 10:55, schrieb Daniel Vetter:
 On Sun, Oct 14, 2012 at 9:18 AM, Oleksij Rempel
 bug-tr...@fisher-privat.net wrote:
 With latest kernel (vanilla/master, or intel.drm-next) i do not have
 image
 on build in screen (eDP). Hardware Asus Zenbook UX32A. Vendor: 0x8086,
 Device: 0x0166, Revision: 0x09 (??)
 Is it know issue?
 
 Nope, this is a new one. Can you grab the dmesg with drm.debug=0xe of
 the broken kernel please? Also, a bisect usually helps a lot, too.
 
 Thanks, Daniel
 
 
 
 I can't access this laptop with broken kernel.
 
 The patch caused this regression is:
 commit 2477367083b3eaa97f87993ab26627a02f350551
 Author: Chris Wilson ch...@chris-wilson.co.uk
 Date:   Wed Sep 26 16:48:30 2012 +0100
 
  drm/i915: Try harder to complete DP training pattern 1
 
  In commit cdb0e95bf571dccc1f75fef9bdad21b167ef0b37
  Author: Keith Packard kei...@keithp.com
  Date:   Tue Nov 1 20:00:06 2011 -0700
 
  drm/i915: Try harder during dp pattern 1 link training
 
  extra passes were made to retry the same voltage and then retry a full
  clock reset. However, as coverity pointed out, we never tried the full
  clock reset as we broke out of the loop early.
 
  Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk
  Reviewed-by: Damien Lespiau damien.lesp...@intel.com
 
 
 Reverting it makes laptop work again.

Ok, I've reverted this in -fixes, we need to think a bit more about our dp
link training for -next. Thanks a lot for reporting and bisecting this
regression.

Yours, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 02/14] drm/i915: add intel_ddi_set_pipe_settings

2012-10-16 Thread Jani Nikula
On Mon, 15 Oct 2012, Paulo Zanoni przan...@gmail.com wrote:
 From: Paulo Zanoni paulo.r.zan...@intel.com

 In theory, all the DDI pipe settings should be set here, including
 timing and M/N registers. For now, let's just set the DP MSA
 attributes.

 Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
 ---
  drivers/gpu/drm/i915/i915_reg.h  | 10 ++
  drivers/gpu/drm/i915/intel_ddi.c | 34 ++
  drivers/gpu/drm/i915/intel_display.c |  4 +++-
  drivers/gpu/drm/i915/intel_drv.h |  1 +
  4 files changed, 48 insertions(+), 1 deletion(-)

 diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
 index 8200c31..7ca8b7d 100644
 --- a/drivers/gpu/drm/i915/i915_reg.h
 +++ b/drivers/gpu/drm/i915/i915_reg.h
 @@ -4533,6 +4533,16 @@
  #define  PIPE_CLK_SEL_DISABLED   (0x029)
  #define  PIPE_CLK_SEL_PORT(x)((x+1)29)
  
 +#define _PIPEA_MSA_MISC  0x60410
 +#define _PIPEB_MSA_MISC  0x61410
 +#define PIPE_MSA_MISC(pipe) _PIPE(pipe, _PIPEA_MSA_MISC, _PIPEB_MSA_MISC)
 +#define  PIPE_MSA_SYNC_CLK   (10)
 +#define  PIPE_MSA_6_BPC  (05)
 +#define  PIPE_MSA_8_BPC  (15)
 +#define  PIPE_MSA_10_BPC (25)
 +#define  PIPE_MSA_12_BPC (35)
 +#define  PIPE_MSA_16_BPC (35)

This should be (45) per DP 1.2a. Not that it matters now, unused as it
is.

BR,
Jani.

 +
  /* LCPLL Control */
  #define LCPLL_CTL0x130040
  #define  LCPLL_PLL_DISABLE   (131)
 diff --git a/drivers/gpu/drm/i915/intel_ddi.c 
 b/drivers/gpu/drm/i915/intel_ddi.c
 index 9659c227..e58df71 100644
 --- a/drivers/gpu/drm/i915/intel_ddi.c
 +++ b/drivers/gpu/drm/i915/intel_ddi.c
 @@ -827,6 +827,40 @@ bool intel_ddi_pll_mode_set(struct drm_crtc *crtc, int 
 clock)
   return true;
  }
  
 +void intel_ddi_set_pipe_settings(struct drm_crtc *crtc)
 +{
 + struct drm_i915_private *dev_priv = crtc-dev-dev_private;
 + struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 + struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 + enum pipe pipe = intel_crtc-pipe;
 + int type = intel_encoder-type;
 + uint32_t temp;
 +
 + if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) {
 +
 + temp = PIPE_MSA_SYNC_CLK;
 + switch (intel_crtc-bpp) {
 + case 18:
 + temp |= PIPE_MSA_6_BPC;
 + break;
 + case 24:
 + temp |= PIPE_MSA_8_BPC;
 + break;
 + case 30:
 + temp |= PIPE_MSA_10_BPC;
 + break;
 + case 36:
 + temp |= PIPE_MSA_12_BPC;
 + break;
 + default:
 + temp |= PIPE_MSA_8_BPC;
 + WARN(1, %d bpp unsupported by pipe DDI function\n,
 +  intel_crtc-bpp);
 + }
 + I915_WRITE(PIPE_MSA_MISC(pipe), temp);
 + }
 +}
 +
  void intel_ddi_enable_pipe_func(struct drm_crtc *crtc)
  {
   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 diff --git a/drivers/gpu/drm/i915/intel_display.c 
 b/drivers/gpu/drm/i915/intel_display.c
 index 705ed80..f48986b9 100644
 --- a/drivers/gpu/drm/i915/intel_display.c
 +++ b/drivers/gpu/drm/i915/intel_display.c
 @@ -3218,8 +3218,10 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
*/
   intel_crtc_load_lut(crtc);
  
 - if (IS_HASWELL(dev))
 + if (IS_HASWELL(dev)) {
 + intel_ddi_set_pipe_settings(crtc);
   intel_ddi_enable_pipe_func(crtc);
 + }
  
   intel_enable_pipe(dev_priv, pipe, is_pch_port);
   intel_enable_plane(dev_priv, plane, pipe);
 diff --git a/drivers/gpu/drm/i915/intel_drv.h 
 b/drivers/gpu/drm/i915/intel_drv.h
 index 7e1e670..ed75a36 100644
 --- a/drivers/gpu/drm/i915/intel_drv.h
 +++ b/drivers/gpu/drm/i915/intel_drv.h
 @@ -597,5 +597,6 @@ extern bool intel_ddi_pll_mode_set(struct drm_crtc *crtc, 
 int clock);
  extern void intel_ddi_pre_enable(struct intel_encoder *intel_encoder);
  extern void intel_ddi_post_disable(struct intel_encoder *intel_encoder);
  extern void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
 +extern void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  
  #endif /* __INTEL_DRV_H__ */
 -- 
 1.7.11.4

 ___
 Intel-gfx mailing list
 Intel-gfx@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915: Set DERRMR around batches required vblank events

2012-10-16 Thread Chris Wilson
In order for the Display Engine to send messages to the Render Engine,
that event must be unmasked in the Display Engine Render Response Mask
Register (DERRMR). By default all events are masked to prevent unwanted
messages to conserve power, and it is strongly recommended that only
single events be unmasked at any time. So in order to pipeline the
register writes around individual batchbuffers, userspace must notify
the kernel when it requires a vblank event, this patch implements an
interface to do so with an single (pipe, event) request through the
execbuffer flags.

Note that another workaround is required for IVB, in that we must also
prevent RC6 sleeps whilst waiting upon an event. To do that we also
pipeline a forcewake into the second MT slot.

There are a few unpleasant issues addressed by the patch. The first is
to only allow a single ring to process vsync requests at any time. This
is really a non-issue as the current hardware can only process those
requests on a single ring, but by serialising between rings we should
prevent our future selves from shooting their feet. The second ugly
issue is to handle unwind failures by disabling signals whilst queueing
a vsync request, perhaps a pleasant side-effect. The last issue is the
trick to enable vblank irqs which relies on the deferred vblank put.

References: https://bugs.freedesktop.org/show_bug.cgi?id=50244
Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk
---

I am still not convinced this fixes anything as at the moment I am
simply unable to detect any tearing on my ivb setup if I apply any form of
vblank throttling.

The other issue is that I think if I had a SECURE
(DRM_MASTER|DRM_ROOT_ONLY) batch buffer I could probably do all of this
in userspace.
-Chris

---
 drivers/gpu/drm/i915/i915_dma.c|3 ++
 drivers/gpu/drm/i915/i915_drv.h|3 ++
 drivers/gpu/drm/i915/i915_gem.c|2 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   76 
 drivers/gpu/drm/i915/i915_reg.h|1 +
 include/drm/i915_drm.h |   17 +++
 6 files changed, 102 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 5779e8f..759a5e6 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1015,6 +1015,9 @@ static int i915_getparam(struct drm_device *dev, void 
*data,
case I915_PARAM_HAS_PRIME_VMAP_FLUSH:
value = 1;
break;
+   case I915_PARAM_HAS_EXEC_VSYNC:
+   value = 1;
+   break;
default:
DRM_DEBUG_DRIVER(Unknown parameter %d\n,
 param-param);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index dda10c1..db2ca9f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -434,6 +434,9 @@ typedef struct drm_i915_private {
struct intel_ring_buffer ring[I915_NUM_RINGS];
uint32_t next_seqno;
 
+   struct intel_ring_buffer *vsync_ring;
+   uint32_t vsync_seqno;
+
drm_dma_handle_t *status_page_dmah;
uint32_t counter;
struct drm_i915_gem_object *pwrctx;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index f740535..7a5ab2c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2643,6 +2643,8 @@ int i915_gpu_idle(struct drm_device *dev)
return ret;
}
 
+   dev_priv-vsync_ring = NULL;
+   dev_priv-vsync_seqno = 0;
return 0;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index bcd5aa2..021b967 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -807,6 +807,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
   struct drm_i915_gem_exec_object2 *exec)
 {
drm_i915_private_t *dev_priv = dev-dev_private;
+   bool was_interruptible = dev_priv-mm.interruptible;
struct list_head objects;
struct eb_objects *eb;
struct drm_i915_gem_object *batch_obj;
@@ -1044,6 +1045,62 @@ i915_gem_do_execbuffer(struct drm_device *dev, void 
*data,
goto err;
}
 
+   if (args-flags  I915_EXEC_VSYNC_ENABLE  INTEL_INFO(dev)-gen = 6) {
+   u32 pipe, event;
+
+   if (dev_priv-vsync_seqno  dev_priv-vsync_ring != ring) {
+   ret = i915_wait_seqno(dev_priv-vsync_ring,
+ dev_priv-vsync_seqno);
+   if (ret)
+   goto err;
+
+   dev_priv-vsync_ring = NULL;
+   dev_priv-vsync_seqno = 0;
+   }
+
+   pipe = I915_EXEC_VSYNC_GET_PIPE(args-flags);
+   event = 

Re: [Intel-gfx] [PATCH 01/14] drm/i915: add DP support to intel_ddi_enable_pipe_func

2012-10-16 Thread Jani Nikula
On Mon, 15 Oct 2012, Paulo Zanoni przan...@gmail.com wrote:
 From: Paulo Zanoni paulo.r.zan...@intel.com

Reviewed-by: Jani Nikula jani.nik...@intel.com


 Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
 ---
  drivers/gpu/drm/i915/intel_ddi.c | 34 ++
  drivers/gpu/drm/i915/intel_dp.c  |  5 -
  drivers/gpu/drm/i915/intel_drv.h |  5 +
  3 files changed, 35 insertions(+), 9 deletions(-)

 diff --git a/drivers/gpu/drm/i915/intel_ddi.c 
 b/drivers/gpu/drm/i915/intel_ddi.c
 index a78860a..9659c227 100644
 --- a/drivers/gpu/drm/i915/intel_ddi.c
 +++ b/drivers/gpu/drm/i915/intel_ddi.c
 @@ -831,8 +831,10 @@ void intel_ddi_enable_pipe_func(struct drm_crtc *crtc)
  {
   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
   struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
 + struct drm_encoder *encoder = intel_encoder-base;
   struct drm_i915_private *dev_priv = crtc-dev-dev_private;
   enum pipe pipe = intel_crtc-pipe;
 + int type = intel_encoder-type;
   uint32_t temp;
  
   /* Enable PIPE_DDI_FUNC_CTL for the pipe to work in HDMI mode */
 @@ -861,9 +863,8 @@ void intel_ddi_enable_pipe_func(struct drm_crtc *crtc)
   if (crtc-mode.flags  DRM_MODE_FLAG_PHSYNC)
   temp |= PIPE_DDI_PHSYNC;
  
 - if (intel_encoder-type == INTEL_OUTPUT_HDMI) {
 - struct intel_hdmi *intel_hdmi =
 - enc_to_intel_hdmi(intel_encoder-base);
 + if (type == INTEL_OUTPUT_HDMI) {
 + struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
  
   if (intel_hdmi-has_hdmi_sink)
   temp |= PIPE_DDI_MODE_SELECT_HDMI;
 @@ -871,9 +872,34 @@ void intel_ddi_enable_pipe_func(struct drm_crtc *crtc)
   temp |= PIPE_DDI_MODE_SELECT_DVI;
  
   temp |= PIPE_DDI_SELECT_PORT(intel_hdmi-ddi_port);
 - } else if (intel_encoder-type == INTEL_OUTPUT_ANALOG) {
 +
 + } else if (type == INTEL_OUTPUT_ANALOG) {
   temp |= PIPE_DDI_MODE_SELECT_FDI;
   temp |= PIPE_DDI_SELECT_PORT(PORT_E);
 +
 + } else if (type == INTEL_OUTPUT_DISPLAYPORT ||
 +type == INTEL_OUTPUT_EDP) {
 + struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 +
 + temp |= PIPE_DDI_MODE_SELECT_DP_SST;
 + temp |= PIPE_DDI_SELECT_PORT(intel_dp-port);
 +
 + switch (intel_dp-lane_count) {
 + case 1:
 + temp |= PIPE_DDI_PORT_WIDTH_X1;
 + break;
 + case 2:
 + temp |= PIPE_DDI_PORT_WIDTH_X2;
 + break;
 + case 4:
 + temp |= PIPE_DDI_PORT_WIDTH_X4;
 + break;
 + default:
 + temp |= PIPE_DDI_PORT_WIDTH_X4;
 + WARN(1, Unsupported lane count %d\n,
 +  intel_dp-lane_count);
 + }
 +
   } else {
   WARN(1, Invalid encoder type %d for pipe %d\n,
intel_encoder-type, pipe);
 diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
 index fcce392..871bc17 100644
 --- a/drivers/gpu/drm/i915/intel_dp.c
 +++ b/drivers/gpu/drm/i915/intel_dp.c
 @@ -77,11 +77,6 @@ static bool is_cpu_edp(struct intel_dp *intel_dp)
   return is_edp(intel_dp)  !is_pch_edp(intel_dp);
  }
  
 -static struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
 -{
 - return container_of(encoder, struct intel_dp, base.base);
 -}
 -
  static struct intel_dp *intel_attached_dp(struct drm_connector *connector)
  {
   return container_of(intel_attached_encoder(connector),
 diff --git a/drivers/gpu/drm/i915/intel_drv.h 
 b/drivers/gpu/drm/i915/intel_drv.h
 index 245319a..7e1e670 100644
 --- a/drivers/gpu/drm/i915/intel_drv.h
 +++ b/drivers/gpu/drm/i915/intel_drv.h
 @@ -474,6 +474,11 @@ static inline struct intel_encoder 
 *intel_attached_encoder(struct drm_connector
   return to_intel_connector(connector)-encoder;
  }
  
 +static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
 +{
 + return container_of(encoder, struct intel_dp, base.base);
 +}
 +
  extern void intel_connector_attach_encoder(struct intel_connector *connector,
  struct intel_encoder *encoder);
  extern struct drm_encoder *intel_best_encoder(struct drm_connector 
 *connector);
 -- 
 1.7.11.4

 ___
 Intel-gfx mailing list
 Intel-gfx@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 04/14] drm/i915: add DP support to intel_ddi_disable_port

2012-10-16 Thread Jani Nikula
On Mon, 15 Oct 2012, Paulo Zanoni przan...@gmail.com wrote:
 From: Paulo Zanoni paulo.r.zan...@intel.com

 Just a missing register. There is no problem to run this code when the
 output is HDMI.

Reviewed-by: Jani Nikula jani.nik...@intel.com


 Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
 ---
  drivers/gpu/drm/i915/intel_ddi.c | 11 ++-
  1 file changed, 10 insertions(+), 1 deletion(-)

 diff --git a/drivers/gpu/drm/i915/intel_ddi.c 
 b/drivers/gpu/drm/i915/intel_ddi.c
 index 5071370..4f03b1b 100644
 --- a/drivers/gpu/drm/i915/intel_ddi.c
 +++ b/drivers/gpu/drm/i915/intel_ddi.c
 @@ -1105,14 +1105,23 @@ void intel_ddi_post_disable(struct intel_encoder 
 *intel_encoder)
   struct drm_i915_private *dev_priv = encoder-dev-dev_private;
   enum port port = intel_ddi_get_encoder_port(intel_encoder);
   uint32_t val;
 + bool wait = false;
  
   val = I915_READ(DDI_BUF_CTL(port));
   if (val  DDI_BUF_CTL_ENABLE) {
   val = ~DDI_BUF_CTL_ENABLE;
   I915_WRITE(DDI_BUF_CTL(port), val);
 - intel_wait_ddi_buf_idle(dev_priv, port);
 + wait = true;
   }
  
 + val = I915_READ(DP_TP_CTL(port));
 + val = ~(DP_TP_CTL_ENABLE | DP_TP_CTL_LINK_TRAIN_MASK);
 + val |= DP_TP_CTL_LINK_TRAIN_PAT1;
 + I915_WRITE(DP_TP_CTL(port), val);
 +
 + if (wait)
 + intel_wait_ddi_buf_idle(dev_priv, port);
 +
   I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE);
  }
  
 -- 
 1.7.11.4

 ___
 Intel-gfx mailing list
 Intel-gfx@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 06/14] drm/i915: add basic Haswell DP link train bits

2012-10-16 Thread Jani Nikula
On Mon, 15 Oct 2012, Paulo Zanoni przan...@gmail.com wrote:
 From: Paulo Zanoni paulo.r.zan...@intel.com

 Previously, the DP register was used for everything. On Haswell, it
 was split into DDI_BUF_CTL (which is the new intel_dp-DP register)
 and DP_TP_CTL.

 The logic behind this patch is based on a patch written by Shobhit
 Kumar, but the way the code was written is very different.

 Credits-to: Shobhit Kumar shobhit.ku...@intel.com
 Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
 ---
  drivers/gpu/drm/i915/i915_reg.h |   4 ++
  drivers/gpu/drm/i915/intel_dp.c | 104 
 +---
  2 files changed, 102 insertions(+), 6 deletions(-)

 diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
 index 7ca8b7d..68ce163 100644
 --- a/drivers/gpu/drm/i915/i915_reg.h
 +++ b/drivers/gpu/drm/i915/i915_reg.h
 @@ -4426,12 +4426,16 @@
  #define  DP_TP_CTL_LINK_TRAIN_MASK   (78)
  #define  DP_TP_CTL_LINK_TRAIN_PAT1   (08)
  #define  DP_TP_CTL_LINK_TRAIN_PAT2   (18)
 +#define  DP_TP_CTL_LINK_TRAIN_PAT3   (48)
 +#define  DP_TP_CTL_LINK_TRAIN_IDLE   (28)
  #define  DP_TP_CTL_LINK_TRAIN_NORMAL (38)
 +#define  DP_TP_CTL_SCRAMBLE_DISABLE  (17)
  
  /* DisplayPort Transport Status */
  #define DP_TP_STATUS_A   0x64044
  #define DP_TP_STATUS_B   0x64144
  #define DP_TP_STATUS(port) _PORT(port, DP_TP_STATUS_A, DP_TP_STATUS_B)
 +#define  DP_TP_STATUS_IDLE_DONE  (125)
  #define  DP_TP_STATUS_AUTOTRAIN_DONE (112)
  
  /* DDI Buffer Control */
 diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
 index 3fa71cd..b10f35b 100644
 --- a/drivers/gpu/drm/i915/intel_dp.c
 +++ b/drivers/gpu/drm/i915/intel_dp.c
 @@ -1476,7 +1476,19 @@ intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, 
 uint8_t voltage_swing)
  {
   struct drm_device *dev = intel_dp-base.base.dev;
  
 - if (IS_GEN7(dev)  is_cpu_edp(intel_dp)  !IS_VALLEYVIEW(dev)) {
 + if (IS_HASWELL(dev)) {
 + switch (voltage_swing  DP_TRAIN_VOLTAGE_SWING_MASK) {
 + case DP_TRAIN_VOLTAGE_SWING_400:
 + return DP_TRAIN_PRE_EMPHASIS_9_5;
 + case DP_TRAIN_VOLTAGE_SWING_600:
 + return DP_TRAIN_PRE_EMPHASIS_6;
 + case DP_TRAIN_VOLTAGE_SWING_800:
 + return DP_TRAIN_PRE_EMPHASIS_3_5;
 + case DP_TRAIN_VOLTAGE_SWING_1200:
 + default:
 + return DP_TRAIN_PRE_EMPHASIS_0;
 + }
 + } else if (IS_GEN7(dev)  is_cpu_edp(intel_dp)  !IS_VALLEYVIEW(dev)) 
 {
   switch (voltage_swing  DP_TRAIN_VOLTAGE_SWING_MASK) {
   case DP_TRAIN_VOLTAGE_SWING_400:
   return DP_TRAIN_PRE_EMPHASIS_6;
 @@ -1630,6 +1642,40 @@ intel_gen7_edp_signal_levels(uint8_t train_set)
   }
  }
  
 +/* Gen7.5's (HSW) DP voltage swing and pre-emphasis control */
 +static uint32_t
 +intel_dp_signal_levels_hsw(uint8_t train_set)
 +{
 + int signal_levels = train_set  (DP_TRAIN_VOLTAGE_SWING_MASK |
 +  DP_TRAIN_PRE_EMPHASIS_MASK);
 + switch (signal_levels) {
 + case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_0:
 + return DDI_BUF_EMP_400MV_0DB_HSW;
 + case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_3_5:
 + return DDI_BUF_EMP_400MV_3_5DB_HSW;
 + case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_6:
 + return DDI_BUF_EMP_400MV_6DB_HSW;
 + case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PRE_EMPHASIS_9_5:
 + return DDI_BUF_EMP_400MV_9_5DB_HSW;
 +
 + case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_0:
 + return DDI_BUF_EMP_600MV_0DB_HSW;
 + case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_3_5:
 + return DDI_BUF_EMP_600MV_3_5DB_HSW;
 + case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PRE_EMPHASIS_6:
 + return DDI_BUF_EMP_600MV_6DB_HSW;
 +
 + case DP_TRAIN_VOLTAGE_SWING_800 | DP_TRAIN_PRE_EMPHASIS_0:
 + return DDI_BUF_EMP_800MV_0DB_HSW;
 + case DP_TRAIN_VOLTAGE_SWING_800 | DP_TRAIN_PRE_EMPHASIS_3_5:
 + return DDI_BUF_EMP_800MV_3_5DB_HSW;
 + default:
 + DRM_DEBUG_KMS(Unsupported voltage swing/pre-emphasis level:
 +   0x%x\n, signal_levels);
 + return DDI_BUF_EMP_400MV_0DB_HSW;
 + }
 +}
 +
  static uint8_t
  intel_get_lane_status(uint8_t link_status[DP_LINK_STATUS_SIZE],
 int lane)
 @@ -1686,8 +1732,44 @@ intel_dp_set_link_train(struct intel_dp *intel_dp,
   struct drm_device *dev = intel_dp-base.base.dev;
   struct drm_i915_private *dev_priv = dev-dev_private;
   int ret;
 + uint32_t temp;
  
 - if (HAS_PCH_CPT(dev)  (IS_GEN7(dev) || !is_cpu_edp(intel_dp))) {
 + if (IS_HASWELL(dev)) {
 + temp = 

Re: [Intel-gfx] [PATCH 07/14] drm/i915: use TU_SIZE macro at intel_dp_set_m_n

2012-10-16 Thread Jani Nikula
On Mon, 15 Oct 2012, Paulo Zanoni przan...@gmail.com wrote:
 From: Paulo Zanoni paulo.r.zan...@intel.com

 Much simpler and looks more like the M/N code inside intel_display.c.

Reviewed-by: Jani Nikula jani.nik...@intel.com


 Signed-off-by: Paulo Zanoni paulo.r.zan...@intel.com
 ---
  drivers/gpu/drm/i915/intel_dp.c | 7 ++-
  1 file changed, 2 insertions(+), 5 deletions(-)

 diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
 index b10f35b..52b5453 100644
 --- a/drivers/gpu/drm/i915/intel_dp.c
 +++ b/drivers/gpu/drm/i915/intel_dp.c
 @@ -794,9 +794,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct 
 drm_display_mode *mode,
mode-clock, adjusted_mode-clock, m_n);
  
   if (HAS_PCH_SPLIT(dev)) {
 - I915_WRITE(TRANSDATA_M1(pipe),
 -((m_n.tu - 1)  PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
 -m_n.gmch_m);
 + I915_WRITE(TRANSDATA_M1(pipe), TU_SIZE(m_n.tu) | m_n.gmch_m);
   I915_WRITE(TRANSDATA_N1(pipe), m_n.gmch_n);
   I915_WRITE(TRANSDPLINK_M1(pipe), m_n.link_m);
   I915_WRITE(TRANSDPLINK_N1(pipe), m_n.link_n);
 @@ -807,8 +805,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct 
 drm_display_mode *mode,
   I915_WRITE(PIPE_LINK_N1(pipe), m_n.link_n);
   } else {
   I915_WRITE(PIPE_GMCH_DATA_M(pipe),
 -((m_n.tu - 1)  PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
 -m_n.gmch_m);
 +TU_SIZE(m_n.tu) | m_n.gmch_m);
   I915_WRITE(PIPE_GMCH_DATA_N(pipe), m_n.gmch_n);
   I915_WRITE(PIPE_DP_LINK_M(pipe), m_n.link_m);
   I915_WRITE(PIPE_DP_LINK_N(pipe), m_n.link_n);
 -- 
 1.7.11.4

 ___
 Intel-gfx mailing list
 Intel-gfx@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [BUG] i915 RC6 lockup

2012-10-16 Thread Jonas Jelten
Hi list!

I think i've got a problem with the intel driver:

Sometimes, I think especially after running graphics intense
applications, RC6 is disabled completely and heats up my Thinkpad X220t
to 90 degree celsius, while idling.

At first I thought that this is a CPU frequency scaling issue, as the
cpufreq_powersave claims to be running at 800 MHz, but i7z
(http://code.google.com/p/i7z/) shows all multipliers to be 25 - 2.5
GHz CPU clock.

Powertop 2.1 reveals that the GPU is 100% active, 0% RC6, 0% RC6p and 0%
RC6pp, and the CPU is 99,9% in C7-deep-sleep, at maximum frequency.
/sys/kernel/debug/dri/0/i915_ring_freq_table also pointed the issue to
being caused by the GPU.

intel_gpu_top shows a total idle.

I'm on ArchLinux, Kernel 3.6.2, xf86-video-intel-git
b42d81b63f5b6a571faffaadd42c74adce40128a, this is 2.20.10.
Problem first occured with Kernel 3.6.0.
Core i5-2520M HD 3000

cat /proc/cmdline
cryptdevice=/dev/sda2:cryptroot root=/dev/mapper/cryptroot ro vga=791
i915.i915_enable_rc6=7 i915.modeset=1 i915.lvds_downclock=1
i915.semaphores=1 drm.vblankoffdelay=1 init=/bin/systemd
initrd=../initramfs-linux.img BOOT_IMAGE=../vmlinuz-linux

Sometimes it can be fixed by going to pm-suspend and waking up. A reboot
always fixes it, until it randomly locks up the GPU again.

Please help me how i can do further investigation to catch the bug.

As this makes my Laptop consume ~40W, it would be really nice if this
gets fixed.


Cheers,

Jonas



signature.asc
Description: OpenPGP digital signature
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] hsw rps values regress RPS on Macbook Air

2012-10-16 Thread Jesse Barnes
On Fri, 12 Oct 2012 11:34:08 -0700
Eric Anholt e...@anholt.net wrote:

 Jesse Barnes jbar...@virtuousgeek.org writes:
 
  On Tue, 09 Oct 2012 13:05:54 -0700
  Eric Anholt e...@anholt.net wrote:
 
  On my new MBA with danvet's drm-intel-next-queued, I'm not getting
  working RPS.  vblank_mode=0 glxgears never ups the frequency, and
  vblank_mode=0 openarena only makes it up to 500mhz.  Reverting
  1ee9ae3244c4789f3184c5123f3b2d7e405b3f4c gets the machine to responsive
  RPS: fully on while the GPU is busy, fully lowered when it's not.
  
  Since we're always just looking for all-on or all-off and never see
  workloads that actually want to be somewhere in between, could we please
  just move to race to idle for RPS?
 
  Ramping to the max freq is fine for benchmarking.  But for normal
  vblank throttled activity, using the lowest freq (assuming it's
  above our nominal freq) that can hit the refresh is the right answer
  from a power perspective.
 
 Have you seen any workloads where a middle frequency value is actually
 chosen by the current RPS system?

I can't tell if this is a snarky response or not. :)  But either way it
misses my point: I think the current RPS system isn't ideal for many of
our workloads and the way our GL stack runs things.  I've thought we
could do better for awhile now but couldn't think of a way that would
let userspace request lower frequencies if it didn't need the extra
processing power, but if we collect a little data in Mesa maybe we can
do it.

I propose a new ioctl, I915_FREQ_REQUEST, with 3 different parameters,
I915_MAX_FREQ, I915_MORE_FREQ, and I915_LESS_FREQ.  The first would
tell the kernel the app would like to run at the maximum possible
speed, regardless of power or throttling considerations.  MORE
would simply tell the kernel the app needs a higher frequency to meet
its frame rate target, and LESS would tell the kernel it could run
slower and still hit its target.

In Mesa, we'd need to track the FPS target for the app, the current FPS
(e.g. over the last second, or using a decaying average with some
weight toward recent activity), and the time between swapbuffers calls
(as an approximation of how long it takes us to draw each frame).

Periodically (maybe every second when we update our current FPS), Mesa
would either request more frequency if it wasn't hitting its FPS
target, or less frequency if its frame draw time was less than 90% of
the maximum alloted frame time (the period for the frequency we're
trying to hit).  The FPS target would be based on the swap interval for
the app.

In a benchmarking mode (i.e. vblank_mode=0 or swapinterval set to 0),
we could just make a I915_MAX_FREQ request and be done with it.

Within the kernel, we'd evaluate every app's requests and choose the
max frequency requested, re-setting things on every ioctl call and when
apps close.

Any thoughts?  Would collecting the above info in Mesa be pretty easy?
I think we already collect FPS info if certain debug flags are set, and
frame time seems like a pretty trivial calculation based on some
timestamping in a couple of places...

Thanks,
Jesse
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: Set DERRMR around batches required vblank events

2012-10-16 Thread Daniel Vetter
On Tue, Oct 16, 2012 at 11:47 AM, Chris Wilson ch...@chris-wilson.co.uk wrote:

 I am still not convinced this fixes anything as at the moment I am
 simply unable to detect any tearing on my ivb setup if I apply any form of
 vblank throttling.

 The other issue is that I think if I had a SECURE
 (DRM_MASTER|DRM_ROOT_ONLY) batch buffer I could probably do all of this
 in userspace.

Yeah, I'm a bit torn between this approach and just allowing SECURE
batches. The big upside of secure batches is that it allows more
flexibility (if the LRI really work from secure batches and not just
from the ring). The only downside I can see is that we won't be able
to arbitrage the derrmr bits (since only one is allowed to be set at
any given time) between different userspace processes. But I don't see
mutliple concurrent display servers (with cooperative owenership of
the hw) happening anytime soon, so I won't worry about this before it
happens. Syncing against modeset should still work with our MI_WAIT
related waits on fbs before we disable the pipe.

The other issue (only on gen7) is that this will keep the gpu out of
rc6 (and hence the entire package) for long times, especially on
mostly-idle video playback. I don't think that massively increased
power consumption is what users will appreciated.

Now with the Tearfree option and you saying that vblank render
throttling mostly fixes this, do we have any unhappy bug reporters
left? In that case I'd prefer to just can this entirely (and suggest
to ppl to use a real compositor - the wasted bw issue on X also seems
to be on track to be solved).

Cheers, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 01/22] drmtest: add function to remove an DRM FB

2012-10-16 Thread Imre Deak
Signed-off-by: Imre Deak imre.d...@intel.com
---
 lib/drmtest.c |5 +
 lib/drmtest.h |1 +
 2 files changed, 6 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 125bfe9..c309851 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -829,6 +829,11 @@ unsigned int kmstest_create_fb(int fd, int width, int 
height, int bpp,
return fb_id;
 }
 
+void kmstest_remove_fb(int fd, int fb_id)
+{
+   do_or_die(drmModeRmFB(fd, fb_id));
+}
+
 void kmstest_dump_mode(drmModeModeInfo *mode)
 {
printf(  %s %d %d %d %d %d %d %d %d %d 0x%x 0x%x %d\n,
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 738d1a2..fcb10bb 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -105,6 +105,7 @@ unsigned int kmstest_create_fb(int fd, int width, int 
height, int bpp,
   struct kmstest_fb *fb_info,
   kmstest_paint_func paint_func,
   void *func_arg);
+void kmstest_remove_fb(int fd, int fb_id);
 void kmstest_dump_mode(drmModeModeInfo *mode);
 
 inline static void _do_or_die(const char *function, int line, int ret)
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 03/22] flip_test: reset the state for each test run

2012-10-16 Thread Imre Deak
Each test run needs a clean state.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index d018c50..b338448 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -546,11 +546,13 @@ static int run_test(int duration, int flags)
 
/* Find any connected displays */
for (c = 0; c  resources-count_connectors; c++) {
-   memset(o, 0, sizeof(o));
-   o.id = resources-connectors[c];
-   o.flags = flags;
-   for (i = 0; i  resources-count_crtcs; i++)
+   for (i = 0; i  resources-count_crtcs; i++) {
+   memset(o, 0, sizeof(o));
+   o.id = resources-connectors[c];
+   o.flags = flags;
+
flip_mode(o, resources-crtcs[i], duration);
+   }
}
 
drmModeFreeResources(resources);
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 04/22] flip_test: check drmHandleEvents()' return value

2012-10-16 Thread Imre Deak
Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index b338448..5e39db6 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -494,12 +494,14 @@ static void flip_mode(struct test_output *o, int crtc, 
int duration)
}
}
 
-   drmHandleEvent(drm_fd, evctx);
+   ret = drmHandleEvent(drm_fd, evctx);
+   assert(ret == 0);
}
 
/* and drain the event queue */
evctx.page_flip_handler = NULL;
-   drmHandleEvent(drm_fd, evctx);
+   ret = drmHandleEvent(drm_fd, evctx);
+   assert(ret == 0);
 
/* Verify we drop no frames, but only if it's not a TV encoder, since
 * those use some funny fake timings behind userspace's back. */
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 06/22] flip_test: store fb width, height in test context object

2012-10-16 Thread Imre Deak
We will need these in event handlers, so store them where the handlers
have access to them.

No functional change.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index ed8c12b..aa611f5 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -73,6 +73,8 @@ struct test_output {
int flags;
int count;
unsigned int current_fb_id;
+   unsigned int fb_width;
+   unsigned int fb_height;
unsigned int fb_ids[2];
struct kmstest_fb fb_info[2];
struct timeval last_flip_received;
@@ -391,7 +393,6 @@ static void flip_mode(struct test_output *o, int crtc, int 
duration)
int ret;
int bpp = 32, depth = 24;
drmEventContext evctx;
-   int width, height;
struct timeval end;
 
connector_find_preferred_mode(o, crtc);
@@ -401,17 +402,17 @@ static void flip_mode(struct test_output *o, int crtc, 
int duration)
fprintf(stdout, Beginning page flipping on crtc %d, connector %d\n,
crtc, o-id);
 
-   width = o-mode.hdisplay;
-   height = o-mode.vdisplay;
+   o-fb_width = o-mode.hdisplay;
+   o-fb_height = o-mode.vdisplay;
 
if (o-flags  TEST_PAN)
-   width *= 2;
+   o-fb_width *= 2;
 
-   o-fb_ids[0] = kmstest_create_fb(drm_fd, width, height, bpp, depth,
-false, o-fb_info[0],
+   o-fb_ids[0] = kmstest_create_fb(drm_fd, o-fb_width, o-fb_height, bpp,
+depth, false, o-fb_info[0],
 paint_flip_mode, (void *)false);
-   o-fb_ids[1] = kmstest_create_fb(drm_fd, width, height, bpp, depth,
-false, o-fb_info[1],
+   o-fb_ids[1] = kmstest_create_fb(drm_fd, o-fb_width, o-fb_height, bpp,
+depth, false, o-fb_info[1],
 paint_flip_mode, (void *)true);
 
if (!o-fb_ids[0] || !o-fb_ids[1]) {
@@ -423,7 +424,7 @@ static void flip_mode(struct test_output *o, int crtc, int 
duration)
if (drmModeSetCrtc(drm_fd, o-crtc, o-fb_ids[0], 0, 0,
   o-id, 1, o-mode)) {
fprintf(stderr, failed to set mode (%dx%d@%dHz): %s\n,
-   width, height, o-mode.vrefresh,
+   o-fb_width, o-fb_height, o-mode.vrefresh,
strerror(errno));
exit(3);
}
@@ -488,8 +489,8 @@ static void flip_mode(struct test_output *o, int crtc, int 
duration)
   x_ofs, 0,
   o-id, 1, o-mode)) {
fprintf(stderr, failed to pan (%dx%d@%dHz): 
%s\n,
-   width, height, o-mode.vrefresh,
-   strerror(errno));
+   o-fb_width, o-fb_height,
+   o-mode.vrefresh, strerror(errno));
exit(7);
}
}
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 05/22] test_flip: fix checking for delayed event reception

2012-10-16 Thread Imre Deak
The intent for the time limit seems to be 2ms, but the current condition
will result in a 1s limit and makes the check against tv_usec redundant.
Fix the condition to check for a 2ms limit.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 5e39db6..ed8c12b 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -183,7 +183,7 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
 
timersub(pageflip_ts, now, diff);
 
-   if (diff.tv_sec  0 || (diff.tv_sec  0  diff.tv_usec  2000)) {
+   if (diff.tv_sec  0 || (diff.tv_sec == 0  diff.tv_usec  2000)) {
fprintf(stderr, pageflip timestamp delayed for too long: %is, 
%iusec\n,
(int) diff.tv_sec, (int) diff.tv_usec);
exit(5);
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 07/22] flip_test: factor out drmModePageFlip

2012-10-16 Thread Imre Deak
For better readability and to prepare for the upcoming patch marking
pending flip events with a flag.

No functional change.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index aa611f5..06768a4 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -157,6 +157,12 @@ static int set_dpms(struct test_output *o, int mode)
return drmModeConnectorSetProperty(drm_fd, o-id, dpms, mode);
 }
 
+static int do_page_flip(struct test_output *o, int fb_id)
+{
+   return drmModePageFlip(drm_fd, o-crtc, fb_id, DRM_MODE_PAGE_FLIP_EVENT,
+   o);
+}
+
 static bool
 analog_tv_connector(struct test_output *o)
 {
@@ -220,8 +226,7 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
new_fb_id = o-fb_ids[o-current_fb_id];
 
if (o-flags  TEST_EINVAL  o-count  1)
-   assert(drmModePageFlip(drm_fd, o-crtc, new_fb_id,
-  DRM_MODE_PAGE_FLIP_EVENT, o) == 
expected_einval);
+   assert(do_page_flip(o, new_fb_id) == expected_einval);
 
if (o-flags  TEST_MODESET) {
if (drmModeSetCrtc(drm_fd, o-crtc,
@@ -240,12 +245,10 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
o-count++;
printf(.); fflush(stdout);
 
-   do_or_die(drmModePageFlip(drm_fd, o-crtc, new_fb_id,
- DRM_MODE_PAGE_FLIP_EVENT, o));
+   do_or_die(do_page_flip(o, new_fb_id));
 
if (o-flags  TEST_EBUSY)
-   assert(drmModePageFlip(drm_fd, o-crtc, new_fb_id,
-  DRM_MODE_PAGE_FLIP_EVENT, o) == -EBUSY);
+   assert(do_page_flip(o, new_fb_id) == -EBUSY);
 
if (o-flags  TEST_DPMS)
do_or_die(set_dpms(o, DRM_MODE_DPMS_OFF));
@@ -262,8 +265,7 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
}
 
if (o-flags  TEST_EINVAL)
-   assert(drmModePageFlip(drm_fd, o-crtc, new_fb_id,
-  DRM_MODE_PAGE_FLIP_EVENT, o) == 
expected_einval);
+   assert(do_page_flip(o, new_fb_id) == expected_einval);
 
o-last_flip_received = now;
o-last_flip_ts = pageflip_ts;
@@ -436,8 +438,7 @@ static void flip_mode(struct test_output *o, int crtc, int 
duration)
 
gettimeofday(o-last_flip_received, NULL);
 
-   if (drmModePageFlip(drm_fd, o-crtc, o-fb_ids[1],
- DRM_MODE_PAGE_FLIP_EVENT, o)) {
+   if (do_page_flip(o, o-fb_ids[1])) {
fprintf(stderr, failed to page flip: %s\n, strerror(errno));
exit(4);
}
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 08/22] flip_test: move output panning inside the flip_handler

2012-10-16 Thread Imre Deak
Move the panning to a more logical place where the rest of the test
steps are performed. This won't change things in practice, since the
first thing drmHandleEvent does is call the flip_handler.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 06768a4..0825cda 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -218,6 +218,20 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
}
}
 
+   /* pan before the flip completes */
+   if (o-flags  TEST_PAN) {
+   int x_ofs = o-count * 10  o-mode.hdisplay ?
+   o-mode.hdisplay : o-count * 10;
+
+   if (drmModeSetCrtc(drm_fd, o-crtc, o-fb_ids[o-current_fb_id],
+  x_ofs, 0, o-id, 1, o-mode)) {
+   fprintf(stderr, failed to pan (%dx%d@%dHz): %s\n,
+   o-fb_width, o-fb_height,
+   o-mode.vrefresh, strerror(errno));
+   exit(7);
+   }
+   }
+
if (o-flags  TEST_WITH_DUMMY_LOAD)
emit_dummy_load(o);
 
@@ -481,21 +495,6 @@ static void flip_mode(struct test_output *o, int crtc, int 
duration)
break;
}
 
-   /* pan before the flip completes */
-   if (o-flags  TEST_PAN) {
-   int x_ofs = o-count * 10  o-mode.hdisplay ? 
o-mode.hdisplay :
-   o-count * 10;
-
-   if (drmModeSetCrtc(drm_fd, o-crtc, 
o-fb_ids[o-current_fb_id],
-  x_ofs, 0,
-  o-id, 1, o-mode)) {
-   fprintf(stderr, failed to pan (%dx%d@%dHz): 
%s\n,
-   o-fb_width, o-fb_height,
-   o-mode.vrefresh, strerror(errno));
-   exit(7);
-   }
-   }
-
ret = drmHandleEvent(drm_fd, evctx);
assert(ret == 0);
}
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 09/22] flip_test: factor out the event loop/wait for event logic

2012-10-16 Thread Imre Deak
Needed by an upcoming patch where we want to wait for an event without
starting a new round of test run.

No functional change.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |  126 +
 1 file changed, 70 insertions(+), 56 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 0825cda..8f925d0 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -404,12 +404,77 @@ fb_is_bound(struct test_output *o, int fb)
return mode.mode_valid  mode.fb_id == fb;
 }
 
+static void wait_for_events(struct test_output *o)
+{
+   drmEventContext evctx;
+   struct timeval timeout = { .tv_sec = 3, .tv_usec = 0 };
+   fd_set fds;
+   int ret;
+
+   memset(evctx, 0, sizeof evctx);
+   evctx.version = DRM_EVENT_CONTEXT_VERSION;
+   evctx.vblank_handler = NULL;
+   evctx.page_flip_handler = page_flip_handler;
+
+   /* make timeout lax with the dummy load */
+   if (o-flags  TEST_WITH_DUMMY_LOAD)
+   timeout.tv_sec *= 10;
+
+   FD_ZERO(fds);
+   FD_SET(0, fds);
+   FD_SET(drm_fd, fds);
+   ret = select(drm_fd + 1, fds, NULL, NULL, timeout);
+
+   if (ret = 0) {
+   fprintf(stderr, select timed out or error (ret %d)\n,
+   ret);
+   exit(1);
+   } else if (FD_ISSET(0, fds)) {
+   fprintf(stderr, no fds active, breaking\n);
+   exit(2);
+   }
+
+   drmHandleEvent(drm_fd, evctx);
+}
+
+/* Returned the ellapsed time in us */
+static unsigned event_loop(struct test_output *o, unsigned duration_sec)
+{
+   drmEventContext evctx;
+   int ret;
+   struct timeval start, end;
+   struct timeval tv_dur;
+
+   gettimeofday(start, NULL);
+   end.tv_sec = start.tv_sec + duration_sec;
+   end.tv_usec = start.tv_usec;
+
+   while (1) {
+   struct timeval now;
+
+   wait_for_events(o);
+
+   gettimeofday(now, NULL);
+   if (!timercmp(now, end, ))
+   break;
+   }
+
+   gettimeofday(end, NULL);
+   timersub(end, start, tv_dur);
+
+   /* and drain the event queue */
+   memset(evctx, 0, sizeof evctx);
+   evctx.page_flip_handler = NULL;
+   ret = drmHandleEvent(drm_fd, evctx);
+   assert(ret == 0);
+
+   return tv_dur.tv_sec * 1000 * 1000 + tv_dur.tv_usec;
+}
+
 static void flip_mode(struct test_output *o, int crtc, int duration)
 {
-   int ret;
int bpp = 32, depth = 24;
-   drmEventContext evctx;
-   struct timeval end;
+   unsigned ellapsed;
 
connector_find_preferred_mode(o, crtc);
if (!o-mode_valid)
@@ -459,65 +524,14 @@ static void flip_mode(struct test_output *o, int crtc, 
int duration)
o-current_fb_id = 1;
o-count = 1; /* for the uncounted tail */
 
-   memset(evctx, 0, sizeof evctx);
-   evctx.version = DRM_EVENT_CONTEXT_VERSION;
-   evctx.vblank_handler = NULL;
-   evctx.page_flip_handler = page_flip_handler;
-
-   gettimeofday(end, NULL);
-   end.tv_sec += duration;
-
-   while (1) {
-   struct timeval now, timeout = { .tv_sec = 3, .tv_usec = 0 };
-   fd_set fds;
-
-   /* make timeout lax with the dummy load */
-   if (o-flags  TEST_WITH_DUMMY_LOAD)
-   timeout.tv_sec *= 10;
-
-   FD_ZERO(fds);
-   FD_SET(0, fds);
-   FD_SET(drm_fd, fds);
-   ret = select(drm_fd + 1, fds, NULL, NULL, timeout);
-
-   if (ret = 0) {
-   fprintf(stderr, select timed out or error (ret %d)\n,
-   ret);
-   exit(1);
-   } else if (FD_ISSET(0, fds)) {
-   fprintf(stderr, no fds active, breaking\n);
-   exit(2);
-   }
-
-   gettimeofday(now, NULL);
-   if (now.tv_sec  end.tv_sec ||
-   (now.tv_sec == end.tv_sec  now.tv_usec = end.tv_usec)) {
-   break;
-   }
-
-   ret = drmHandleEvent(drm_fd, evctx);
-   assert(ret == 0);
-   }
-
-   /* and drain the event queue */
-   evctx.page_flip_handler = NULL;
-   ret = drmHandleEvent(drm_fd, evctx);
-   assert(ret == 0);
+   ellapsed = event_loop(o, duration);
 
/* Verify we drop no frames, but only if it's not a TV encoder, since
 * those use some funny fake timings behind userspace's back. */
if (o-flags  TEST_CHECK_TS  !analog_tv_connector(o)) {
-   struct timeval now;
-   long us;
int expected;
 
-   gettimeofday(now, NULL);
-
-   us = duration * 1000 * 1000;
-   us += (now.tv_sec - end.tv_sec) * 1000 * 1000;
-   us += now.tv_usec - end.tv_usec;
-
-   

[Intel-gfx] [PATCH 10/22] flip_test: factor out the final state check

2012-10-16 Thread Imre Deak
Needed by an upcoming patch where we want to make a final state check
for both the flip and vblank events.

No functional change.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   29 +
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 8f925d0..9b7ac2b 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -404,6 +404,22 @@ fb_is_bound(struct test_output *o, int fb)
return mode.mode_valid  mode.fb_id == fb;
 }
 
+static void check_final_state(struct test_output *o, unsigned int ellapsed)
+{
+   /* Verify we drop no frames, but only if it's not a TV encoder, since
+* those use some funny fake timings behind userspace's back. */
+   if (o-flags  TEST_CHECK_TS  !analog_tv_connector(o)) {
+   int expected;
+
+   expected = ellapsed * o-mode.vrefresh / (1000 * 1000);
+   if (o-count  expected * 99/100) {
+   fprintf(stderr, dropped frames, expected %d, counted 
%d, encoder type %d\n,
+   expected, o-count, o-encoder-encoder_type);
+   exit(3);
+   }
+   }
+}
+
 static void wait_for_events(struct test_output *o)
 {
drmEventContext evctx;
@@ -526,18 +542,7 @@ static void flip_mode(struct test_output *o, int crtc, int 
duration)
 
ellapsed = event_loop(o, duration);
 
-   /* Verify we drop no frames, but only if it's not a TV encoder, since
-* those use some funny fake timings behind userspace's back. */
-   if (o-flags  TEST_CHECK_TS  !analog_tv_connector(o)) {
-   int expected;
-
-   expected = ellapsed * o-mode.vrefresh / (1000 * 1000);
-   if (o-count  expected * 99/100) {
-   fprintf(stderr, dropped frames, expected %d, counted 
%d, encoder type %d\n,
-   expected, o-count, o-encoder-encoder_type);
-   exit(3);
-   }
-   }
+   check_final_state(o, ellapsed);
 
fprintf(stdout, \npage flipping on crtc %d, connector %d: PASSED\n,
crtc, o-id);
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 11/22] flip_test: store current flip/received timestamps in the context obj

2012-10-16 Thread Imre Deak
This is needed by the next patch that splits the flip handler function
into logical parts. Make the timestamps accesible to these parts.

No functional change.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 9b7ac2b..f554818 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -77,6 +77,8 @@ struct test_output {
unsigned int fb_height;
unsigned int fb_ids[2];
struct kmstest_fb fb_info[2];
+   struct timeval current_flip_received;
+   struct timeval current_flip_ts;
struct timeval last_flip_received;
struct timeval last_flip_ts;
 };
@@ -179,17 +181,17 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
 {
struct test_output *o = data;
unsigned int new_fb_id;
-   struct timeval now, diff, pageflip_ts;
+   struct timeval diff;
double usec_interflip;
/* for funny reasons page_flip returns -EBUSY on disabled crtcs ... */
int expected_einval = o-flags  TEST_MODESET ? -EBUSY : -EINVAL;
 
-   pageflip_ts.tv_sec = sec;
-   pageflip_ts.tv_usec = usec;
+   o-current_flip_ts.tv_sec = sec;
+   o-current_flip_ts.tv_usec = usec;
 
-   gettimeofday(now, NULL);
+   gettimeofday(o-current_flip_received, NULL);
 
-   timersub(pageflip_ts, now, diff);
+   timersub(o-current_flip_ts, o-current_flip_received, diff);
 
if (diff.tv_sec  0 || (diff.tv_sec == 0  diff.tv_usec  2000)) {
fprintf(stderr, pageflip timestamp delayed for too long: %is, 
%iusec\n,
@@ -197,16 +199,16 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
exit(5);
}
 
-   if (!timercmp(o-last_flip_received, pageflip_ts, )) {
+   if (!timercmp(o-last_flip_received, o-current_flip_ts, )) {
fprintf(stderr, pageflip ts before the pageflip was 
issued!\n);
-   timersub(pageflip_ts, o-last_flip_received, diff);
+   timersub(o-current_flip_ts, o-last_flip_received, diff);
fprintf(stderr, timerdiff %is, %ius\n,
(int) diff.tv_sec, (int) diff.tv_usec);
exit(6);
}
 
if (o-count  1  o-flags  TEST_CHECK_TS  
!analog_tv_connector(o)) {
-   timersub(pageflip_ts, o-last_flip_ts, diff);
+   timersub(o-current_flip_ts, o-last_flip_ts, diff);
usec_interflip = 1.0 / ((double) o-mode.vrefresh) * 1000.0 * 
1000.0;
 
if (fabsdouble) diff.tv_usec) - usec_interflip) / 
usec_interflip)  0.005) {
@@ -281,8 +283,8 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
if (o-flags  TEST_EINVAL)
assert(do_page_flip(o, new_fb_id) == expected_einval);
 
-   o-last_flip_received = now;
-   o-last_flip_ts = pageflip_ts;
+   o-last_flip_received = o-current_flip_received;
+   o-last_flip_ts = o-current_flip_ts;
 }
 
 static void connector_find_preferred_mode(struct test_output *o, int crtc_id)
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 12/22] flip_test: split the flip handler into logical parts

2012-10-16 Thread Imre Deak
The handler consits of handle_event/run_test/check_state/update_state
logical steps, split the function accordingly. This is needed by the
following patches that need to do part of these steps for both flip and
vblank events.

No functional change.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index f554818..790463c 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -180,16 +180,17 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
  unsigned int usec, void *data)
 {
struct test_output *o = data;
-   unsigned int new_fb_id;
-   struct timeval diff;
-   double usec_interflip;
-   /* for funny reasons page_flip returns -EBUSY on disabled crtcs ... */
-   int expected_einval = o-flags  TEST_MODESET ? -EBUSY : -EINVAL;
 
o-current_flip_ts.tv_sec = sec;
o-current_flip_ts.tv_usec = usec;
 
gettimeofday(o-current_flip_received, NULL);
+}
+
+static void check_all_state(struct test_output *o)
+{
+   struct timeval diff;
+   double usec_interflip;
 
timersub(o-current_flip_ts, o-current_flip_received, diff);
 
@@ -219,6 +220,13 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
//exit(9);
}
}
+}
+
+static void run_test_step(struct test_output *o)
+{
+   unsigned int new_fb_id;
+   /* for funny reasons page_flip returns -EBUSY on disabled crtcs ... */
+   int expected_einval = o-flags  TEST_MODESET ? -EBUSY : -EINVAL;
 
/* pan before the flip completes */
if (o-flags  TEST_PAN) {
@@ -282,7 +290,10 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
 
if (o-flags  TEST_EINVAL)
assert(do_page_flip(o, new_fb_id) == expected_einval);
+}
 
+static void update_all_state(struct test_output *o)
+{
o-last_flip_received = o-current_flip_received;
o-last_flip_ts = o-current_flip_ts;
 }
@@ -471,6 +482,9 @@ static unsigned event_loop(struct test_output *o, unsigned 
duration_sec)
struct timeval now;
 
wait_for_events(o);
+   check_all_state(o);
+   run_test_step(o);
+   update_all_state(o);
 
gettimeofday(now, NULL);
if (!timercmp(now, end, ))
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 13/22] flip_test: swap the order of check state/run test step

2012-10-16 Thread Imre Deak
At the moment we first check the state then run the test step in our
test loop. Swapping the order makes the starting state of each iteration
better defined, allowing an easier extension of these steps in the
future.

Since now it's guaranteed that we exit the event loop with no pending
flips, we can also get rid of the final flushing of events.

We don't want the first initializing flip to affect the test loop other
than setting an initial FB, so before starting the test loop wait for it
to complete by calling wait_for_events() and leave the flip event
counter at zero.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 790463c..6cfc0ec 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -469,8 +469,6 @@ static void wait_for_events(struct test_output *o)
 /* Returned the ellapsed time in us */
 static unsigned event_loop(struct test_output *o, unsigned duration_sec)
 {
-   drmEventContext evctx;
-   int ret;
struct timeval start, end;
struct timeval tv_dur;
 
@@ -481,9 +479,9 @@ static unsigned event_loop(struct test_output *o, unsigned 
duration_sec)
while (1) {
struct timeval now;
 
+   run_test_step(o);
wait_for_events(o);
check_all_state(o);
-   run_test_step(o);
update_all_state(o);
 
gettimeofday(now, NULL);
@@ -494,12 +492,6 @@ static unsigned event_loop(struct test_output *o, unsigned 
duration_sec)
gettimeofday(end, NULL);
timersub(end, start, tv_dur);
 
-   /* and drain the event queue */
-   memset(evctx, 0, sizeof evctx);
-   evctx.page_flip_handler = NULL;
-   ret = drmHandleEvent(drm_fd, evctx);
-   assert(ret == 0);
-
return tv_dur.tv_sec * 1000 * 1000 + tv_dur.tv_usec;
 }
 
@@ -553,8 +545,9 @@ static void flip_mode(struct test_output *o, int crtc, int 
duration)
fprintf(stderr, failed to page flip: %s\n, strerror(errno));
exit(4);
}
+   wait_for_events(o);
+
o-current_fb_id = 1;
-   o-count = 1; /* for the uncounted tail */
 
ellapsed = event_loop(o, duration);
 
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 15/22] flip_test: don't skip checks for sequence #1

2012-10-16 Thread Imre Deak
So far we skipped some tests for seq#0 and #1, since at that point we
were missing the 'last' state against which we could compare the current
state. Since in the previous patches we fixed the ordering in the test
loop and moved the increment of count to the update state phase, we have
a proper 'last' state for seq#1, so enable the tests already at that
point.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 966089f..f07c0db 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -232,7 +232,7 @@ static void check_state(struct test_output *o, struct 
event_state *es)
}
 
 
-   if (es-count  1  (o-flags  TEST_CHECK_TS)  
(!analog_tv_connector(o))) {
+   if (es-count  0  (o-flags  TEST_CHECK_TS)  
(!analog_tv_connector(o))) {
timersub(es-current_ts, es-last_ts, diff);
usec_interflip = 1.0 / ((double)o-mode.vrefresh) * 1000.0 * 
1000.0;
if (fabsdouble) diff.tv_usec) - usec_interflip) /
@@ -280,7 +280,7 @@ static void run_test_step(struct test_output *o)
o-current_fb_id = !o-current_fb_id;
new_fb_id = o-fb_ids[o-current_fb_id];
 
-   if ((o-flags  TEST_EINVAL)  o-flip_state.count  1)
+   if ((o-flags  TEST_EINVAL)  o-flip_state.count  0)
assert(do_page_flip(o, new_fb_id) == expected_einval);
 
if (o-flags  TEST_MODESET) {
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 17/22] flip_test: unify the name of the current test in status messages

2012-10-16 Thread Imre Deak
Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 85fa0f2..a0c1e5d 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -84,6 +84,7 @@ struct event_state {
 };
 
 struct test_output {
+   const char *test_name;
uint32_t id;
int crtc_idx;
int mode_valid;
@@ -545,8 +546,8 @@ static void flip_mode(struct test_output *o, int duration)
if (!o-mode_valid)
return;
 
-   fprintf(stdout, Beginning page flipping on crtc %d, connector %d\n,
-   crtc, o-id);
+   fprintf(stdout, Beginning %s on crtc %d, connector %d\n,
+   o-test_name, crtc, o-id);
 
o-fb_width = o-mode.hdisplay;
o-fb_height = o-mode.vdisplay;
@@ -594,8 +595,8 @@ static void flip_mode(struct test_output *o, int duration)
 
check_final_state(o, o-flip_state, ellapsed);
 
-   fprintf(stdout, \npage flipping on crtc %d, connector %d: PASSED\n,
-   crtc, o-id);
+   fprintf(stdout, \n%s on crtc %d, connector %d: PASSED\n\n,
+   o-test_name, crtc, o-id);
 
kmstest_remove_fb(drm_fd, o-fb_ids[1]);
kmstest_remove_fb(drm_fd, o-fb_ids[0]);
@@ -604,7 +605,7 @@ static void flip_mode(struct test_output *o, int duration)
drmModeFreeConnector(o-connector);
 }
 
-static int run_test(int duration, int flags)
+static int run_test(int duration, int flags, const char *test_name)
 {
struct test_output o;
int c, i;
@@ -620,6 +621,7 @@ static int run_test(int duration, int flags)
for (c = 0; c  resources-count_connectors; c++) {
for (i = 0; i  resources-count_crtcs; i++) {
memset(o, 0, sizeof(o));
+   o.test_name = test_name;
o.id = resources-connectors[c];
o.flags = flags;
o.flip_state.name = flip;
@@ -658,7 +660,7 @@ int main(int argc, char **argv)
 
for (i = 0; i  sizeof(tests) / sizeof (tests[0]); i++) {
printf(running testcase: %s\n, tests[i].name);
-   run_test(tests[i].duration, tests[i].flags);
+   run_test(tests[i].duration, tests[i].flags, tests[i].name);
}
 
close(drm_fd);
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 18/22] flip_test: make page flip tests conditional

2012-10-16 Thread Imre Deak
Since later we want to add vblank tests where we don't want to flip,
make the flips and corresponding state checks conditional.

No functional change.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index a0c1e5d..45bd9e5 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -48,6 +48,7 @@
 #define TEST_CHECK_TS  (1  4)
 #define TEST_EBUSY (1  5)
 #define TEST_EINVAL(1  6)
+#define TEST_FLIP  (1  7)
 
 drmModeRes *resources;
 int drm_fd;
@@ -251,7 +252,8 @@ static void check_state(struct test_output *o, struct 
event_state *es)
 
 static void check_all_state(struct test_output *o)
 {
-   check_state(o, o-flip_state);
+   if (o-flags  TEST_FLIP)
+   check_state(o, o-flip_state);
 }
 
 static void run_test_step(struct test_output *o)
@@ -259,6 +261,9 @@ static void run_test_step(struct test_output *o)
unsigned int new_fb_id;
/* for funny reasons page_flip returns -EBUSY on disabled crtcs ... */
int expected_einval = o-flags  TEST_MODESET ? -EBUSY : -EINVAL;
+   bool do_flip;
+
+   do_flip = o-flags  TEST_FLIP;
 
/* pan before the flip completes */
if (o-flags  TEST_PAN) {
@@ -282,7 +287,7 @@ static void run_test_step(struct test_output *o)
o-current_fb_id = !o-current_fb_id;
new_fb_id = o-fb_ids[o-current_fb_id];
 
-   if ((o-flags  TEST_EINVAL)  o-flip_state.count  0)
+   if (do_flip  (o-flags  TEST_EINVAL)  o-flip_state.count  0)
assert(do_page_flip(o, new_fb_id) == expected_einval);
 
if (o-flags  TEST_MODESET) {
@@ -301,9 +306,10 @@ static void run_test_step(struct test_output *o)
 
printf(.); fflush(stdout);
 
-   do_or_die(do_page_flip(o, new_fb_id));
+   if (do_flip)
+   do_or_die(do_page_flip(o, new_fb_id));
 
-   if (o-flags  TEST_EBUSY)
+   if (do_flip  (o-flags  TEST_EBUSY))
assert(do_page_flip(o, new_fb_id) == -EBUSY);
 
if (o-flags  TEST_DPMS)
@@ -320,7 +326,7 @@ static void run_test_step(struct test_output *o)
}
}
 
-   if (o-flags  TEST_EINVAL)
+   if (do_flip  (o-flags  TEST_EINVAL))
assert(do_page_flip(o, new_fb_id) == expected_einval);
 }
 
@@ -593,7 +599,8 @@ static void flip_mode(struct test_output *o, int duration)
 
ellapsed = event_loop(o, duration);
 
-   check_final_state(o, o-flip_state, ellapsed);
+   if (o-flags  TEST_FLIP)
+   check_final_state(o, o-flip_state, ellapsed);
 
fprintf(stdout, \n%s on crtc %d, connector %d: PASSED\n\n,
o-test_name, crtc, o-id);
@@ -642,13 +649,13 @@ int main(int argc, char **argv)
int flags;
const char *name;
} tests[] = {
-   { 15, TEST_CHECK_TS | TEST_EBUSY , plain flip },
-   { 30, TEST_DPMS | TEST_EINVAL, flip vs dpms },
-   { 30, TEST_DPMS | TEST_WITH_DUMMY_LOAD, delayed flip vs. dpms 
},
-   { 5, TEST_PAN, flip vs panning },
-   { 30, TEST_PAN | TEST_WITH_DUMMY_LOAD, delayed flip vs 
panning },
-   { 30, TEST_MODESET | TEST_EINVAL, flip vs modeset },
-   { 30, TEST_MODESET | TEST_WITH_DUMMY_LOAD, delayed flip vs 
modeset },
+   { 15, TEST_FLIP | TEST_CHECK_TS | TEST_EBUSY , plain flip },
+   { 30, TEST_FLIP | TEST_DPMS | TEST_EINVAL, flip vs dpms },
+   { 30, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_LOAD, delayed 
flip vs dpms },
+   { 5,  TEST_FLIP | TEST_PAN, flip vs panning },
+   { 30, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_LOAD, delayed 
flip vs panning },
+   { 30, TEST_FLIP | TEST_MODESET | TEST_EINVAL, flip vs modeset 
},
+   { 30, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_LOAD, delayed 
flip vs modeset },
};
int i;
 
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 20/22] flip_test: add event sequence number tracking

2012-10-16 Thread Imre Deak
Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |   29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 9772599..82ab347 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -75,6 +75,7 @@ struct event_state {
 */
struct timeval last_ts; /* kernel reported timestamp */
struct timeval last_received_ts;/* the moment we received it */
+   unsigned int last_seq;  /* kernel reported seq. num */
 
/*
 * Event data for for the current event that we just received and
@@ -82,8 +83,12 @@ struct event_state {
 */
struct timeval current_ts;  /* kernel reported timestamp */
struct timeval current_received_ts; /* the moment we received it */
+   unsigned int current_seq;   /* kernel reported seq. num */
 
int count;  /* # of events of this type */
+
+   /* Step between the current and next 'target' sequence number. */
+   int seq_step;
 };
 
 struct test_output {
@@ -223,6 +228,7 @@ static void event_handler(struct event_state *es, unsigned 
int frame,
gettimeofday(es-current_received_ts, NULL);
es-current_ts.tv_sec = sec;
es-current_ts.tv_usec = usec;
+   es-current_seq = frame;
 }
 
 static void page_flip_handler(int fd, unsigned int frame, unsigned int sec,
@@ -256,10 +262,20 @@ static void check_state(struct test_output *o, struct 
event_state *es)
exit(6);
}
 
+   if (es-count == 0)
+   return;
 
-   if (es-count  0  (o-flags  TEST_CHECK_TS)  
(!analog_tv_connector(o))) {
+   /* This bounding matches the one in DRM_IOCTL_WAIT_VBLANK. */
+   if (es-current_seq - (es-last_seq + es-seq_step)  1UL  23) {
+   fprintf(stderr, unexpected %s seq %u, should be = %u\n,
+   es-name, es-current_seq, es-last_seq + es-seq_step);
+   exit(10);
+   }
+
+   if ((o-flags  TEST_CHECK_TS)  (!analog_tv_connector(o))) {
timersub(es-current_ts, es-last_ts, diff);
-   usec_interflip = 1.0 / ((double)o-mode.vrefresh) * 1000.0 * 
1000.0;
+   usec_interflip = (double)es-seq_step /
+((double)o-mode.vrefresh) * 1000.0 * 1000.0;
if (fabsdouble) diff.tv_usec) - usec_interflip) /
usec_interflip)  0.005) {
fprintf(stderr, inter-%s ts jitter: %is, %ius\n,
@@ -269,6 +285,12 @@ static void check_state(struct test_output *o, struct 
event_state *es)
 * poll helper :( hence make it non-fatal for now */
//exit(9);
}
+
+   if (es-current_seq != es-last_seq + es-seq_step)
+   fprintf(stderr, unexpected %s seq %u, expected %u\n,
+   es-name, es-current_seq,
+   es-last_seq + es-seq_step);
+   /* no exit, due to the same reason as above */
}
 }
 
@@ -361,6 +383,7 @@ static void update_state(struct event_state *es)
 {
es-last_received_ts = es-current_received_ts;
es-last_ts = es-current_ts;
+   es-last_seq = es-current_seq;
es-count++;
 }
 
@@ -499,6 +522,7 @@ static void check_final_state(struct test_output *o, struct 
event_state *es,
int expected;
int count = es-count;
 
+   count *= es-seq_step;
expected = ellapsed * o-mode.vrefresh / (1000 * 1000);
if (count  expected * 99/100) {
fprintf(stderr, dropped frames, expected %d, counted 
%d, encoder type %d\n,
@@ -640,6 +664,7 @@ static void flip_mode(struct test_output *o, int duration)
wait_for_events(o);
 
o-current_fb_id = 1;
+   o-flip_state.seq_step = 1;
 
ellapsed = event_loop(o, duration);
 
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 21/22] flip_test: add check to see if any event has occured

2012-10-16 Thread Imre Deak
At the moment select() would time out in case we don't get any event.
When we add vblank events in a later patch, it's possible that we
receive one type of events but not the other type. In this case select()
doesn't time out and we need another way to detect this.

Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 82ab347..2b70f2a 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -516,6 +516,11 @@ fb_is_bound(struct test_output *o, int fb)
 static void check_final_state(struct test_output *o, struct event_state *es,
  unsigned int ellapsed)
 {
+   if (es-count == 0) {
+   fprintf(stderr, no %s event received\n, es-name);
+   exit(12);
+   }
+
/* Verify we drop no frames, but only if it's not a TV encoder, since
 * those use some funny fake timings behind userspace's back. */
if (o-flags  TEST_CHECK_TS  !analog_tv_connector(o)) {
-- 
1.7.9.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 22/22] flip_test: add wait-for-vblank tests

2012-10-16 Thread Imre Deak
Signed-off-by: Imre Deak imre.d...@intel.com
---
 tests/flip_test.c |  130 +++--
 1 file changed, 126 insertions(+), 4 deletions(-)

diff --git a/tests/flip_test.c b/tests/flip_test.c
index 2b70f2a..7c3d0f2 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -49,8 +49,12 @@
 #define TEST_EBUSY (1  5)
 #define TEST_EINVAL(1  6)
 #define TEST_FLIP  (1  7)
+#define TEST_VBLANK(1  8)
+#define TEST_VBLANK_BLOCK  (1  9)
+#define TEST_VBLANK_ABSOLUTE   (1  10)
 
 #define EVENT_FLIP (1  0)
+#define EVENT_VBLANK   (1  1)
 
 drmModeRes *resources;
 int drm_fd;
@@ -108,6 +112,7 @@ struct test_output {
struct kmstest_fb fb_info[2];
 
struct event_state flip_state;
+   struct event_state vblank_state;
unsigned int pending_events;
 };
 
@@ -211,6 +216,51 @@ static int do_page_flip(struct test_output *o, int fb_id)
return ret;
 }
 
+struct vblank_reply {
+   unsigned int sequence;
+   struct timeval ts;
+};
+
+static int do_wait_for_vblank(struct test_output *o, int crtc_idx,
+ int target_seq, struct vblank_reply *reply)
+{
+   drmVBlank wait_vbl;
+   int ret;
+   unsigned crtc_idx_mask;
+   bool event = !(o-flags  TEST_VBLANK_BLOCK);
+
+   memset(wait_vbl, 0, sizeof(wait_vbl));
+
+   crtc_idx_mask = crtc_idx  DRM_VBLANK_HIGH_CRTC_SHIFT;
+   assert(!(crtc_idx_mask  ~DRM_VBLANK_HIGH_CRTC_MASK));
+
+   wait_vbl.request.type = crtc_idx_mask;
+   if (o-flags  TEST_VBLANK_ABSOLUTE)
+   wait_vbl.request.type |= DRM_VBLANK_ABSOLUTE;
+   else
+   wait_vbl.request.type |= DRM_VBLANK_RELATIVE;
+   if (event) {
+   wait_vbl.request.type |= DRM_VBLANK_EVENT;
+   wait_vbl.request.signal = (unsigned long)o;
+   }
+   wait_vbl.request.sequence = target_seq;
+
+   ret = drmWaitVBlank(drm_fd, wait_vbl);
+
+   if (ret == 0) {
+   reply-ts.tv_sec = wait_vbl.reply.tval_sec;
+   reply-ts.tv_usec = wait_vbl.reply.tval_usec;
+   reply-sequence = wait_vbl.reply.sequence;
+
+   if (event) {
+   assert(!(o-pending_events  EVENT_VBLANK));
+   o-pending_events |= EVENT_VBLANK;
+   }
+   }
+
+   return ret;
+}
+
 static bool
 analog_tv_connector(struct test_output *o)
 {
@@ -240,6 +290,15 @@ static void page_flip_handler(int fd, unsigned int frame, 
unsigned int sec,
event_handler(o-flip_state, frame, sec, usec);
 }
 
+static void vblank_handler(int fd, unsigned int frame, unsigned int sec,
+ unsigned int usec, void *data)
+{
+   struct test_output *o = data;
+
+   clear_flag(o-pending_events, EVENT_VBLANK);
+   event_handler(o-vblank_state, frame, sec, usec);
+}
+
 static void check_state(struct test_output *o, struct event_state *es)
 {
struct timeval diff;
@@ -299,6 +358,8 @@ static void check_all_state(struct test_output *o,
 {
if (completed_events  EVENT_FLIP)
check_state(o, o-flip_state);
+   if (completed_events  EVENT_VBLANK)
+   check_state(o, o-vblank_state);
 }
 
 /* Return mask of completed events. */
@@ -309,12 +370,16 @@ static unsigned int run_test_step(struct test_output *o)
int expected_einval = o-flags  TEST_MODESET ? -EBUSY : -EINVAL;
unsigned int completed_events = 0;
bool do_flip;
+   bool do_vblank;
 
do_flip = (o-flags  TEST_FLIP)  !(o-pending_events  EVENT_FLIP);
+   do_vblank = (o-flags  TEST_VBLANK) 
+   !(o-pending_events  EVENT_VBLANK);
 
/* pan before the flip completes */
if (o-flags  TEST_PAN) {
-   int count = o-flip_state.count;
+   int count = do_flip ?
+   o-flip_state.count : o-vblank_state.count;
int x_ofs = count * 10  o-mode.hdisplay ?
o-mode.hdisplay : count * 10;
 
@@ -356,6 +421,24 @@ static unsigned int run_test_step(struct test_output *o)
if (do_flip)
do_or_die(do_page_flip(o, new_fb_id));
 
+   if (do_vblank) {
+   struct vblank_reply vbl_reply;
+   unsigned int target_seq;
+
+   target_seq = o-vblank_state.seq_step;
+   if (o-flags  TEST_VBLANK_ABSOLUTE)
+   target_seq += o-vblank_state.last_seq;
+
+   do_or_die(do_wait_for_vblank(o, o-crtc_idx, target_seq,
+vbl_reply));
+   if (o-flags  TEST_VBLANK_BLOCK) {
+   event_handler(o-vblank_state, vbl_reply.sequence,
+ vbl_reply.ts.tv_sec,
+ vbl_reply.ts.tv_usec);
+   completed_events = EVENT_VBLANK;
+   }
+   }
+
  

Re: [Intel-gfx] hsw rps values regress RPS on Macbook Air

2012-10-16 Thread Daniel Vetter
On Tue, Oct 16, 2012 at 3:53 PM, Jesse Barnes jbar...@virtuousgeek.org wrote:
 Any thoughts?  Would collecting the above info in Mesa be pretty easy?
 I think we already collect FPS info if certain debug flags are set, and
 frame time seems like a pretty trivial calculation based on some
 timestamping in a couple of places...

How does this work with 2 and more clients rendering to the gpu, each
pretty much oblivious to what the others are doing (i.e. your
composited desktop case)? And if that works, how does it figure out
that the 25 fps video client indeed doesn't want to draw more than
that on a 50 fps screen (which is presumably the frame target)? Note
that the 25 fps case is very tricky, since a lot of workloads with too
little parrallelism between the gpu and cpu and hence lots of idle
time on both run fastest if you lock both gpu and cpu to the max. And
since 2d flips a lot between hw/sw rendering, your mostly idle desktop
is a prime example of this.

Also, I totally don't see how that differs from what the hw does, safe
that we don't know the exact algo the hw implements: Instead of the hw
generating up/down request userspace does the same. And the pin to max
is already implemented in sysfs now. The other issue is that userspace
individually lacks the global overview.

Cheers, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] bad panel power sequencing delays, disabling panel

2012-10-16 Thread Daniel Vetter
On Tue, Oct 16, 2012 at 3:26 PM, Daniel J Blueman dan...@quora.org wrote:
 On my Macbook Retina 2012, after a recent firmware update, i915 fails
 to use the eDP-1 panel [1], which goes blank when switched to. Nouveau
 works correctly though [2]. I see this behaviour on 3.6-rc to 3.7-rc1.

I'm working on this, since when I plug in a 2nd screen in my own edp
machine, the bios doesn't light up the internal panel and our code
can't light it up, too. Unfortunately progress is slow, but you can
try my current wip state at

http://cgit.freedesktop.org/~danvet/drm/log/?h=for-pzanoni

Please attach dmesg with drm.debug=0xe if you try this kernel.
Backlight works now for me, but I still have issues with edp link
training here.

Cheers, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] hsw rps values regress RPS on Macbook Air

2012-10-16 Thread Jesse Barnes
On Tue, 16 Oct 2012 16:38:02 +0200
Daniel Vetter dan...@ffwll.ch wrote:

 On Tue, Oct 16, 2012 at 3:53 PM, Jesse Barnes jbar...@virtuousgeek.org 
 wrote:
  Any thoughts?  Would collecting the above info in Mesa be pretty easy?
  I think we already collect FPS info if certain debug flags are set, and
  frame time seems like a pretty trivial calculation based on some
  timestamping in a couple of places...
 
 How does this work with 2 and more clients rendering to the gpu, each
 pretty much oblivious to what the others are doing (i.e. your
 composited desktop case)? And if that works, how does it figure out
 that the 25 fps video client indeed doesn't want to draw more than
 that on a 50 fps screen (which is presumably the frame target)? Note

How does what figure it out?  A client that wants to draw at 25fps
would use 25fps as its target framerate, not 50.  And it wouldn't
request more GPU frequency unless it wasn't hitting that target.  But
the media stack isn't something I've considered much.  I think we can
use the same approach there in general, but things get a little trickier
with encoding and transcoding, since you don't necessarily want to run
flat out all the time, but you also don't have an FPS target unless
you're doing realtime transcode for camera-display or something.

 that the 25 fps case is very tricky, since a lot of workloads with too
 little parrallelism between the gpu and cpu and hence lots of idle
 time on both run fastest if you lock both gpu and cpu to the max. And
 since 2d flips a lot between hw/sw rendering, your mostly idle desktop
 is a prime example of this.

We need the GPU to go as fast as the most demanding client requires, or
in the case of multiple competing clients, as fast as is needed to
drive them all at their target framerate.  The GL stack should take
care of making requests to make this happen based on what I outlined.

 Also, I totally don't see how that differs from what the hw does, safe
 that we don't know the exact algo the hw implements: Instead of the hw
 generating up/down request userspace does the same. And the pin to max
 is already implemented in sysfs now. The other issue is that userspace
 individually lacks the global overview.

Only the kernel has the global view.  But each client will know if it's
hitting its target or not, and can request more frequency if not (which
could be due to its own demands or that other stuff is taking some GPU
too).

The big difference between this and the hw mechanism is that here we're
basing our frequency requests on what we actually need (the target
framerate).  The hw currently has no idea about this, and can't really,
unless we tell it.  So for example the current stuff will increase the
GPU frequency beyond nominal when an app runs, even if it's hitting its
target framerate, which is less efficient than just leaving the freq at
nominal, which is what this would do.

Jesse
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 08/22] flip_test: move output panning inside the flip_handler

2012-10-16 Thread Daniel Vetter
On Tue, Oct 16, 2012 at 05:34:42PM +0300, Imre Deak wrote:
 Move the panning to a more logical place where the rest of the test
 steps are performed. This won't change things in practice, since the
 first thing drmHandleEvent does is call the flip_handler.
 
 Signed-off-by: Imre Deak imre.d...@intel.com

Looking at this again I think the test is actually broken. It tries to
check whether fb_set_base correclty waits for any outstanding flips (well,
it can't really check that, but it should exercise the code at least). So
the right place to call this is actually right _after_ issueing the flip,
where the TEST_DPMS and TEST_MODESET cases are.
-Daniel

 ---
  tests/flip_test.c |   29 ++---
  1 file changed, 14 insertions(+), 15 deletions(-)
 
 diff --git a/tests/flip_test.c b/tests/flip_test.c
 index 06768a4..0825cda 100644
 --- a/tests/flip_test.c
 +++ b/tests/flip_test.c
 @@ -218,6 +218,20 @@ static void page_flip_handler(int fd, unsigned int 
 frame, unsigned int sec,
   }
   }
  
 + /* pan before the flip completes */
 + if (o-flags  TEST_PAN) {
 + int x_ofs = o-count * 10  o-mode.hdisplay ?
 + o-mode.hdisplay : o-count * 10;
 +
 + if (drmModeSetCrtc(drm_fd, o-crtc, o-fb_ids[o-current_fb_id],
 +x_ofs, 0, o-id, 1, o-mode)) {
 + fprintf(stderr, failed to pan (%dx%d@%dHz): %s\n,
 + o-fb_width, o-fb_height,
 + o-mode.vrefresh, strerror(errno));
 + exit(7);
 + }
 + }
 +
   if (o-flags  TEST_WITH_DUMMY_LOAD)
   emit_dummy_load(o);
  
 @@ -481,21 +495,6 @@ static void flip_mode(struct test_output *o, int crtc, 
 int duration)
   break;
   }
  
 - /* pan before the flip completes */
 - if (o-flags  TEST_PAN) {
 - int x_ofs = o-count * 10  o-mode.hdisplay ? 
 o-mode.hdisplay :
 - o-count * 10;
 -
 - if (drmModeSetCrtc(drm_fd, o-crtc, 
 o-fb_ids[o-current_fb_id],
 -x_ofs, 0,
 -o-id, 1, o-mode)) {
 - fprintf(stderr, failed to pan (%dx%d@%dHz): 
 %s\n,
 - o-fb_width, o-fb_height,
 - o-mode.vrefresh, strerror(errno));
 - exit(7);
 - }
 - }
 -
   ret = drmHandleEvent(drm_fd, evctx);
   assert(ret == 0);
   }
 -- 
 1.7.9.5
 
 ___
 Intel-gfx mailing list
 Intel-gfx@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] bad panel power sequencing delays, disabling panel

2012-10-16 Thread Daniel J Blueman
On my Macbook Retina 2012, after a recent firmware update, i915 fails
to use the eDP-1 panel [1], which goes blank when switched to. Nouveau
works correctly though [2]. I see this behaviour on 3.6-rc to 3.7-rc1.

Full boot and IGD switch (see end) kernel logs at
http://quora.org/2012/mbp-i915-panel.txt with drm.debug=0x6. What
additional information is needed to diagnose this?

Thanks,
  Daniel

--- [1]

nouveau :01:00.0: enabling device (0006 - 0007)
[drm] nouveau :01:00.0: Detected an NVe0 generation card (0x0e7150a2)
[drm] nouveau :01:00.0: acceleration disabled by default, pass
noaccel=0 to force enable
checking generic (9002 1c2) vs hw (9000 1000)
fb: conflicting fb hw usage nouveaufb vs EFI VGA - removing generic driver
ACPI: Invalid Power Resource to register!
Console: switching to colour dummy device 80x25
[drm] nouveau :01:00.0: Checking PRAMIN for VBIOS
[drm] nouveau :01:00.0: ... appears to be valid
[drm] nouveau :01:00.0: Using VBIOS from PRAMIN
[drm] nouveau :01:00.0: BIT BIOS found
[drm] nouveau :01:00.0: Bios version 80.07.26.04
[drm] nouveau :01:00.0: TMDS table version 2.0
[drm] nouveau :01:00.0: MXM: no VBIOS data, nothing to do
[drm] nouveau :01:00.0: DCB version 4.0
[drm] nouveau :01:00.0: DCB outp 00: 048101b6 0f230010
[drm] nouveau :01:00.0: DCB outp 01: 018212d6 0f220020
[drm] nouveau :01:00.0: DCB outp 02: 01021212 00020020
[drm] nouveau :01:00.0: DCB outp 03: 088324c6 0f220010
[drm] nouveau :01:00.0: DCB outp 04: 08032402 00020010
[drm] nouveau :01:00.0: DCB outp 05: 02843862 00020010
[drm] nouveau :01:00.0: DCB conn 00: 00020047
[drm] nouveau :01:00.0: DCB conn 01: 02208146
[drm] nouveau :01:00.0: DCB conn 02: 01104246
[drm] nouveau :01:00.0: DCB conn 03: 00410361
[drm] nouveau :01:00.0: Parsing VBIOS init table 0 at offset 0x86B5
[drm] nouveau :01:00.0: 0x853A: Condition still not met after
20ms, skipping following opcodes
[drm] nouveau :01:00.0: Parsing VBIOS init table 1 at offset 0x8EFC
[drm] nouveau :01:00.0: 0x8F0A: Condition still not met after
20ms, skipping following opcodes
[drm] nouveau :01:00.0: 0x8F9B: Condition still not met after
20ms, skipping following opcodes
[drm] nouveau :01:00.0: Parsing VBIOS init table 2 at offset 0x66E1
[drm] nouveau :01:00.0: Parsing VBIOS init table 3 at offset 0xAAA0
[drm] nouveau :01:00.0: Parsing VBIOS init table 4 at offset 0xAAA1
[drm] nouveau :01:00.0: 0x85E7: Condition still not met after
20ms, skipping following opcodes
[drm] nouveau :01:00.0: Parsing VBIOS init table 5 at offset 0xAB59
[drm] nouveau :01:00.0: Parsing VBIOS init table at offset 0xABBE
[TTM] Zone kernel: Available graphics memory: 4043308 kiB
[TTM] Zone  dma32: Available graphics memory: 2097152 kiB
[TTM] Initializing pool allocator
[TTM] Initializing DMA pool allocator
[drm] nouveau :01:00.0: Detected 1024MiB VRAM (GDDR5)
[drm] nouveau :01:00.0: 512 MiB GART (aperture)
[drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
[drm] No driver support for vblank timestamp query.
[drm] nouveau :01:00.0: ACPI backlight interface available, not
registering our own
[drm] nouveau :01:00.0: voltage table 0x50 unknown
[drm] nouveau :01:00.0: 4 available performance level(s)
[drm] nouveau :01:00.0: 1: core 209MHz shader 419MHz memory 405MHz
voltage 520mV
[drm] nouveau :01:00.0: 2: core 390MHz shader 780MHz memory
1080MHz voltage 610mV
[drm] nouveau :01:00.0: 3: core 1000MHz shader 2000MHz memory
1080MHz voltage 630mV
[drm] nouveau :01:00.0: 4: core 1254MHz shader 2508MHz memory
1080MHz voltage 630mV
[drm] nouveau :01:00.0: c:
[drm] nouveau :01:00.0: allocated 2880x1800 fb: 0xe, bo 88026311b800
fbcon: nouveaufb (fb0) is primary device
Console: switching to colour frame buffer device 240x81
fb0: nouveaufb frame buffer device
drm: registered panic notifier
[drm] Initialized nouveau 1.0.0 20120316 for :01:00.0 on minor 0
pci :00:00.0: Intel Ivybridge Chipset
pci :00:00.0: detected gtt size: 2097152K total, 262144K mappable
pci :00:00.0: detected 65536K stolen memory
i915 :00:02.0: setting latency timer to 64
i915 :00:02.0: irq 53 for MSI/MSI-X
[drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
[drm] Driver supports precise vblank timestamp query.
i915 :00:02.0: Invalid ROM contents
[drm] failed to find VBIOS tables
vgaarb: device changed decodes:
PCI::01:00.0,olddecodes=io+mem,decodes=none:owns=none
vgaarb: device changed decodes:
PCI::00:02.0,olddecodes=io+mem,decodes=none:owns=io+mem
[drm] bad panel power sequencing delays, disabling panel
[drm] Enabling RC6 states: RC6 on, RC6p on, RC6pp off
[drm] GMBUS [i915 gmbus vga] timed out, falling back to bit banging on pin 2
No connectors reported connected with modes
[drm] Cannot find any crtc or sizes - going 1024x768
fb1: inteldrmfb frame buffer device
[Firmware Bug]: ACPI(GFX0) defines 

Re: [Intel-gfx] bad panel power sequencing delays, disabling panel

2012-10-16 Thread Daniel J Blueman
On 16 October 2012 22:43, Daniel Vetter dan...@ffwll.ch wrote:
 On Tue, Oct 16, 2012 at 3:26 PM, Daniel J Blueman dan...@quora.org wrote:
 On my Macbook Retina 2012, after a recent firmware update, i915 fails
 to use the eDP-1 panel [1], which goes blank when switched to. Nouveau
 works correctly though [2]. I see this behaviour on 3.6-rc to 3.7-rc1.

 I'm working on this, since when I plug in a 2nd screen in my own edp
 machine, the bios doesn't light up the internal panel and our code
 can't light it up, too. Unfortunately progress is slow, but you can
 try my current wip state at

 http://cgit.freedesktop.org/~danvet/drm/log/?h=for-pzanoni

 Please attach dmesg with drm.debug=0xe if you try this kernel.
 Backlight works now for me, but I still have issues with edp link
 training here.

Thanks Daniel; I'm happy to collect local information/debug etc, sure.

Alas, it looks like that repo is in an unexpected state:

$ git clone git://people.freedesktop.org/~danvet/drm
Cloning into 'drm'...
remote: Counting objects: 2631581, done.
remote: Compressing objects: 100% (395986/395986), done.
remote: Total 2631581 (delta 2211094), reused 2630318 (delta 2209899)
Receiving objects: 100% (2631581/2631581), 615.36 MiB | 1.77 MiB/s, done.
Resolving deltas: 100% (2211094/2211094), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

$ cd drm  $ git branch
$

When it's in shape, I can try again.

Daniel
-- 
Daniel J Blueman
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] bad panel power sequencing delays, disabling panel

2012-10-16 Thread Daniel Vetter
On Tue, Oct 16, 2012 at 5:15 PM, Daniel J Blueman dan...@quora.org wrote:
 On 16 October 2012 22:43, Daniel Vetter dan...@ffwll.ch wrote:
 On Tue, Oct 16, 2012 at 3:26 PM, Daniel J Blueman dan...@quora.org wrote:
 On my Macbook Retina 2012, after a recent firmware update, i915 fails
 to use the eDP-1 panel [1], which goes blank when switched to. Nouveau
 works correctly though [2]. I see this behaviour on 3.6-rc to 3.7-rc1.

 I'm working on this, since when I plug in a 2nd screen in my own edp
 machine, the bios doesn't light up the internal panel and our code
 can't light it up, too. Unfortunately progress is slow, but you can
 try my current wip state at

 http://cgit.freedesktop.org/~danvet/drm/log/?h=for-pzanoni

 Please attach dmesg with drm.debug=0xe if you try this kernel.
 Backlight works now for me, but I still have issues with edp link
 training here.

 Thanks Daniel; I'm happy to collect local information/debug etc, sure.

 Alas, it looks like that repo is in an unexpected state:

 $ git clone git://people.freedesktop.org/~danvet/drm
 Cloning into 'drm'...
 remote: Counting objects: 2631581, done.
 remote: Compressing objects: 100% (395986/395986), done.
 remote: Total 2631581 (delta 2211094), reused 2630318 (delta 2209899)
 Receiving objects: 100% (2631581/2631581), 615.36 MiB | 1.77 MiB/s, done.
 Resolving deltas: 100% (2211094/2211094), done.
 warning: remote HEAD refers to nonexistent ref, unable to checkout.

That thing is totally in the expected shape, it simply does not have a
HEAD, but only branches

$ git branch -r

will list them all, and

$ git checkout -t remote-branchname

will check out origin/remote-branchname and create a branch
remote-branchname tracking it.

Cheers, Daniel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] hsw rps values regress RPS on Macbook Air

2012-10-16 Thread Chris Wilson
On Tue, 09 Oct 2012 13:05:54 -0700, Eric Anholt e...@anholt.net wrote:
 On my new MBA with danvet's drm-intel-next-queued, I'm not getting
 working RPS.  vblank_mode=0 glxgears never ups the frequency, and
 vblank_mode=0 openarena only makes it up to 500mhz.  Reverting
 1ee9ae3244c4789f3184c5123f3b2d7e405b3f4c gets the machine to responsive
 RPS: fully on while the GPU is busy, fully lowered when it's not.

I can confirm this. The issue is that whilst a GL client is active we
never seen a subsequent RPS interrupt, neither up nor down. In
particular, it is the value of UP_EI that throws us off, even though
we do not use the EI mode for determing RPS interrupts.

diff --git a/drivers/gpu/drm/i915/intel_pm.c
b/drivers/gpu/drm/i915/intel_pm.c
index 6b2ea80..4e5fc33 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -2492,7 +2492,7 @@ static void gen6_enable_rps(struct drm_device *dev)
 
I915_WRITE(GEN6_RP_UP_THRESHOLD, 59400);
I915_WRITE(GEN6_RP_DOWN_THRESHOLD, 245000);
-   I915_WRITE(GEN6_RP_UP_EI, 66000);
+   I915_WRITE(GEN6_RP_UP_EI, 10);
I915_WRITE(GEN6_RP_DOWN_EI, 35);
 
I915_WRITE(GEN6_RP_IDLE_HYSTERSIS, 10);

 Since we're always just looking for all-on or all-off and never see
 workloads that actually want to be somewhere in between, could we please
 just move to race to idle for RPS?

I believe that is more or less the purpose of the AGGRESSIVE_TURBO policy
that is enabled by default, but as with anything to do with RPS the
absence of documentation is remarkable.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] bad panel power sequencing delays, disabling panel

2012-10-16 Thread Daniel J Blueman
On 16 October 2012 23:16, Daniel Vetter dan...@ffwll.ch wrote:
 On Tue, Oct 16, 2012 at 5:15 PM, Daniel J Blueman dan...@quora.org wrote:
 On 16 October 2012 22:43, Daniel Vetter dan...@ffwll.ch wrote:
 On Tue, Oct 16, 2012 at 3:26 PM, Daniel J Blueman dan...@quora.org wrote:
 On my Macbook Retina 2012, after a recent firmware update, i915 fails
 to use the eDP-1 panel [1], which goes blank when switched to. Nouveau
 works correctly though [2]. I see this behaviour on 3.6-rc to 3.7-rc1.

 I'm working on this, since when I plug in a 2nd screen in my own edp
 machine, the bios doesn't light up the internal panel and our code
 can't light it up, too. Unfortunately progress is slow, but you can
 try my current wip state at

 http://cgit.freedesktop.org/~danvet/drm/log/?h=for-pzanoni

 Please attach dmesg with drm.debug=0xe if you try this kernel.
 Backlight works now for me, but I still have issues with edp link
 training here.

 Thanks Daniel; I'm happy to collect local information/debug etc, sure.

 Alas, it looks like that repo is in an unexpected state:
[...]
 That thing is totally in the expected shape, it simply does not have a
 HEAD, but only branches

That worked, thanks. Booting, we see:

[drm:intel_dp_init], cur t1_t3 0 t8 0 t9 0 t10 0 t11_t12 4000
[drm:intel_dp_init], vbt t1_t3 0 t8 0 t9 0 t10 0 t11_t12 0
[drm:intel_dp_init], panel power up delay 21, power down delay 50,
power cycle delay 400
[drm:intel_dp_init], backlight on delay 5, off delay 5
[drm:intel_dp_init], panel power sequencer register settings: PP_ON
0x40d20032, PP_OFF 0x1f40032, PP_DIV 0x186904
[drm:intel_dp_i2c_init], i2c_init DPDDC-A
[drm:ironlake_edp_panel_vdd_on], Turn eDP VDD on
[drm:ironlake_edp_panel_vdd_on], eDP VDD already on
[drm:intel_dp_aux_ch], dp_aux_ch timeout status 0x514500c8
[drm:intel_dp_i2c_aux_ch], aux_ch failed -110

Notable, the nvidia DP init script executed fine; perhaps tracing the
I2C access may be useful?

Full boot log at http://quora.org/2012/mbp-i915-panel-2.txt .

Thanks,
  Daniel
-- 
Daniel J Blueman
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: flush system agent TLBs on SNB so we can WC map the PTEs

2012-10-16 Thread Paulo Zanoni
2012/10/11 Jesse Barnes jbar...@virtuousgeek.org:
 I've only lightly tested this so far, but the corruption seems to be
 gone if I write the GFX_FLSH_CNTL reg after binding an object.  This
 register should control the TLB for the system agent, which is what CPU
 mapped objects will go through.

 Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org

 diff --git a/drivers/char/agp/intel-agp.h b/drivers/char/agp/intel-agp.h
 index 6ec0fff..95f0d4d 100644
 --- a/drivers/char/agp/intel-agp.h
 +++ b/drivers/char/agp/intel-agp.h
 @@ -99,6 +99,9 @@
  #define GFX_FLSH_CNTL  0x2170 /* 915+ */
  #define GFX_FLSH_CNTL_VLV  0x101008

 +#define GFX_FLSH_CNTL  0x101008
 +#define   GFX_FLSH_CNTL_EN (10)

Notice that there's a redefinition of GFX_FLSH_CNTL with a different
value just 3 lines above. We're probably fixing gen6+ and breaking
gen5-

We write 0 to this reg in some places, but I believe that shouldn't matter.


 +
  #define I810_DRAM_CTL  0x3000
  #define I810_DRAM_ROW_00x0001
  #define I810_DRAM_ROW_0_SDRAM  0x0001
 diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
 index e01f5ea..08844d6 100644
 --- a/drivers/char/agp/intel-gtt.c
 +++ b/drivers/char/agp/intel-gtt.c
 @@ -667,12 +667,8 @@ static int intel_gtt_init(void)
 gtt_map_size = intel_private.base.gtt_total_entries * 4;

 intel_private.gtt = NULL;
 -   if (INTEL_GTT_GEN  6)
 -   intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
 -  gtt_map_size);
 -   if (intel_private.gtt == NULL)
 -   intel_private.gtt = ioremap(intel_private.gtt_bus_addr,
 -   gtt_map_size);
 +   intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
 +  gtt_map_size);
 if (intel_private.gtt == NULL) {
 intel_private.driver-cleanup();
 iounmap(intel_private.registers);
 @@ -897,6 +893,7 @@ void intel_gtt_insert_sg_entries(struct sg_table *st,
 }
 }
 readl(intel_private.gtt+j-1);
 +   writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
  }
  EXPORT_SYMBOL(intel_gtt_insert_sg_entries);

 @@ -913,6 +910,7 @@ static void intel_gtt_insert_pages(unsigned int 
 first_entry,
   j, flags);
 }
 readl(intel_private.gtt+j-1);
 +   writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
  }

  static int intel_fake_agp_insert_entries(struct agp_memory *mem,
 @@ -1256,7 +1254,7 @@ static int i9xx_setup(void)

 reg_addr = 0xfff8;

 -   if (INTEL_GTT_GEN = 7)
 +   if (INTEL_GTT_GEN = 6)
 size = MB(2);

 intel_private.registers = ioremap(reg_addr, size);
 ___
 Intel-gfx mailing list
 Intel-gfx@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/intel-gfx



-- 
Paulo Zanoni
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] hsw rps values regress RPS on Macbook Air

2012-10-16 Thread Eric Anholt
Jesse Barnes jbar...@virtuousgeek.org writes:

 On Fri, 12 Oct 2012 11:34:08 -0700
 Eric Anholt e...@anholt.net wrote:

 Jesse Barnes jbar...@virtuousgeek.org writes:
 
  On Tue, 09 Oct 2012 13:05:54 -0700
  Eric Anholt e...@anholt.net wrote:
 
  On my new MBA with danvet's drm-intel-next-queued, I'm not getting
  working RPS.  vblank_mode=0 glxgears never ups the frequency, and
  vblank_mode=0 openarena only makes it up to 500mhz.  Reverting
  1ee9ae3244c4789f3184c5123f3b2d7e405b3f4c gets the machine to responsive
  RPS: fully on while the GPU is busy, fully lowered when it's not.
  
  Since we're always just looking for all-on or all-off and never see
  workloads that actually want to be somewhere in between, could we please
  just move to race to idle for RPS?
 
  Ramping to the max freq is fine for benchmarking.  But for normal
  vblank throttled activity, using the lowest freq (assuming it's
  above our nominal freq) that can hit the refresh is the right answer
  from a power perspective.
 
 Have you seen any workloads where a middle frequency value is actually
 chosen by the current RPS system?

 I can't tell if this is a snarky response or not. :)  But either way it
 misses my point: I think the current RPS system isn't ideal for many of
 our workloads and the way our GL stack runs things.  I've thought we
 could do better for awhile now but couldn't think of a way that would
 let userspace request lower frequencies if it didn't need the extra
 processing power, but if we collect a little data in Mesa maybe we can
 do it.

It's not snarky, I'm really wondering if you've actually seen middle
frequencies like this software is designed to do.  I spend a lot of time
looking at performance, and whenever I look at RPS state, it's either at
highest or lowest, or not working.  I've never seen a functioning
workload that stays at the middle.  Testing with the hsw values
reverted:

openarena vblank-synced at 60fps (can do 240), my clock bounces between
350 and 1150.

nexuiz vblank-synced isn't hitting 60 here, and the clock isn't getting
all the way to 1150 (saw I think 900 and 1100 a bunch), and the CPU
isn't the bottleneck as measured by top.  So this is the only case of
these 3 that's actually choosing a middle frequency, but it shouldn't
be.

I even tried using glxgears vblank-synced, resizing my window.  As I
scale up, it seems to spend more time at 1150 instead of 350, but it's
not choosing something in the middle, even though it seems like the most
obvious workload for this middle frequency support.

I'd like to replace not working with high when busy, low when not,
while you're saying that we have to support a middle frequency like the
complicated software is trying to achieve.

 I propose a new ioctl, I915_FREQ_REQUEST, with 3 different parameters,
 I915_MAX_FREQ, I915_MORE_FREQ, and I915_LESS_FREQ.  The first would
 tell the kernel the app would like to run at the maximum possible
 speed, regardless of power or throttling considerations.  MORE
 would simply tell the kernel the app needs a higher frequency to meet
 its frame rate target, and LESS would tell the kernel it could run
 slower and still hit its target.

 In Mesa, we'd need to track the FPS target for the app, the current FPS
 (e.g. over the last second, or using a decaying average with some
 weight toward recent activity), and the time between swapbuffers calls
 (as an approximation of how long it takes us to draw each frame).

 Periodically (maybe every second when we update our current FPS), Mesa
 would either request more frequency if it wasn't hitting its FPS
 target, or less frequency if its frame draw time was less than 90% of
 the maximum alloted frame time (the period for the frequency we're
 trying to hit).  The FPS target would be based on the swap interval for
 the app.

 In a benchmarking mode (i.e. vblank_mode=0 or swapinterval set to 0),
 we could just make a I915_MAX_FREQ request and be done with it.

 Within the kernel, we'd evaluate every app's requests and choose the
 max frequency requested, re-setting things on every ioctl call and when
 apps close.

 Any thoughts?  Would collecting the above info in Mesa be pretty easy?
 I think we already collect FPS info if certain debug flags are set, and
 frame time seems like a pretty trivial calculation based on some
 timestamping in a couple of places...

Unfortunately, enough apps don't use swap interval, and instead of use
SGI_video_sync or OML_sync_control.  In that case, we don't know the
swap interval outside of a blocking call, unless we look at their
history and try to guess.  It sounds ugly, and I guess we'd basically
end up with I915_MAX_FREQ as our policy.

The design is also predicated on some bad assumptions.  One is that
frame-to-frame workloads stay consistent.  3x difference in work between
high and low-framerate scenes within an app I'd say is normal, and you'd
need to be able to recognize that change and fix the frequency within
half a second in the worst case 

Re: [Intel-gfx] [PATCH] drm/i915: flush system agent TLBs on SNB so we can WC map the PTEs

2012-10-16 Thread Daniel Vetter
On Tue, Oct 16, 2012 at 9:11 PM, Paulo Zanoni przan...@gmail.com wrote:
 2012/10/11 Jesse Barnes jbar...@virtuousgeek.org:
 I've only lightly tested this so far, but the corruption seems to be
 gone if I write the GFX_FLSH_CNTL reg after binding an object.  This
 register should control the TLB for the system agent, which is what CPU
 mapped objects will go through.

 Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org

 diff --git a/drivers/char/agp/intel-agp.h b/drivers/char/agp/intel-agp.h
 index 6ec0fff..95f0d4d 100644
 --- a/drivers/char/agp/intel-agp.h
 +++ b/drivers/char/agp/intel-agp.h
 @@ -99,6 +99,9 @@
  #define GFX_FLSH_CNTL  0x2170 /* 915+ */
  #define GFX_FLSH_CNTL_VLV  0x101008

 +#define GFX_FLSH_CNTL  0x101008
 +#define   GFX_FLSH_CNTL_EN (10)

 Notice that there's a redefinition of GFX_FLSH_CNTL with a different
 value just 3 lines above. We're probably fixing gen6+ and breaking
 gen5-

Yeah, Jesse needs to fix up this patch (or me, since it'll conflict
anyway with -fixes, so I need a backmerge first).

 We write 0 to this reg in some places, but I believe that shouldn't matter.

This is one of the magic registers we have: Read always returns 0, it
doesn't matter what you write into it, but something special happens
as a side-effect of writing to it. In this case we flush the cpu gtt
tlb. We have a few others of this kind.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] hsw rps values regress RPS on Macbook Air

2012-10-16 Thread Jesse Barnes
On Tue, 16 Oct 2012 12:50:22 -0700
Eric Anholt e...@anholt.net wrote:
 I'd like to replace not working with high when busy, low when not,
 while you're saying that we have to support a middle frequency like the
 complicated software is trying to achieve.

Well I think this is pretty simple; much simpler than the underlying hw
system at least, and comparable to our sw support of it.

But for frequencies, you're correct.  We should run at the minimum
frequency we can that will still achieve our target framerate.

 Unfortunately, enough apps don't use swap interval, and instead of use
 SGI_video_sync or OML_sync_control.  In that case, we don't know the
 swap interval outside of a blocking call, unless we look at their
 history and try to guess.  It sounds ugly, and I guess we'd basically
 end up with I915_MAX_FREQ as our policy.

Don't all apps have a default swap interval at least?  If they're doing
additional blocking beyond that we'd lose the target fps information, I
agree.

 The design is also predicated on some bad assumptions.  One is that
 frame-to-frame workloads stay consistent.  3x difference in work between
 high and low-framerate scenes within an app I'd say is normal, and you'd
 need to be able to recognize that change and fix the frequency within
 half a second in the worst case I'd think.  Think about your compositor,
 too: right now it's updating a character at a time as I type, then I go
 hit the expose button and it has to redraw the whole screen and that's a
 waaay different workload.  I want responsiveness.

I don't want to assume constant work at all; I know scenes vary widely
in complexity over time.  If we timestamp the execution of buffers we
send in, we can do very fine grained requests if we notice they're
starting to take longer.

 The other bad assumption I think is that there's a bunch headroom for us
 to reduce the frequency.  Games are tuned to the hardware, to be able to
 barely hit 60fps -- if you're way over 60, then either the app turns on
 more pretty graphics options or you do.  You don't have a bunch of extra
 space to play with turning down the frequency.

Yeah, games are generally demanding.  But we also have desktops and
phone UIs that aren't, and those are pretty common cases too.

Jesse
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] hsw rps values regress RPS on Macbook Air

2012-10-16 Thread Jesse Barnes
On Tue, 16 Oct 2012 12:50:22 -0700
Eric Anholt e...@anholt.net wrote:
 It's not snarky, I'm really wondering if you've actually seen middle
 frequencies like this software is designed to do.  I spend a lot of time
 looking at performance, and whenever I look at RPS state, it's either at
 highest or lowest, or not working.  I've never seen a functioning
 workload that stays at the middle.  Testing with the hsw values
 reverted:

Lemme step back here a minute too, since some people have had strong
reactions to this proposal.

My underlying assumption here is that we're not executing with as much
power efficiency as we could.  This is more the case with apps (desktop
environments, non-gaming apps) that don't stress the GPU much, but may
also be true for some games we can run faster than 60fps.

In an ideal world, we'd run everything at the minimum frequency
required to get it to whatever target framerate it has (60fps for
games, 24fps or whatever for video, or some variable number for a
compositor that has intermittent activity).  We'd do that because even
though we take more time to draw a frame, keeping the frequency low is
more efficient from a power perspective, so over a given time period we
end up consuming fewer joules than if we race to idle at the highest
frequency.

Unfortunately, achieving that ideal is difficult.  Today's
implementation doesn't take into account any fps target, and uses some
sw programmed weight values to figure out when to trigger a frequency
increase or decrease.  The values we have today came from data
collection done with the Windows driver, which uses a different gfx
stack and has very different behavior from ours.  We should probably
tune them based on our own workloads, on a per-platform basis.

But given that we don't give the hw any information about when we need
things done or whether we're doing what we want to do, I thought we
might be able to do better with some additional sw assistance.

It's possible we could combine the proposal I sent out earlier (which
boils down to userspace telling the kernel whether it's getting the
performance it wants or not) with the hw-assisted mechanism, along with
some additional tuning, or we could do something else entirely.

Anyway, that's the background and I probably should have sent it out
first.

Jesse
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] Lockup when switching displays using xrandr since kernel 3.5.x

2012-10-16 Thread Thilo-Alexander Ginkel
Hi there,

since upgrading from kernel 3.4.10 to 3.5.x or 3.6.2 (on Kubuntu
12.04) I am getting sporadic (but frequent) lockups when switching
displays using xrandr:

/usr/bin/xrandr -d :0.0 --output LVDS1 --off --output HDMI3
--mode 1600x1200 --primary --auto
sleep 2
/usr/bin/xrandr -d :0.0 --output HDMI2 --mode 1600x1200
--right-of HDMI3 --auto

$ uname -a
Linux orion 3.6.2 #41 SMP Tue Oct 16 23:45:38 CEST 2012 x86_64 x86_64
x86_64 GNU/Linux

00:02.0 VGA compatible controller: Intel Corporation 2nd Generation
Core Processor Family Integrated Graphics Controller (rev 09) (prog-if
00 [VGA controller])
Subsystem: Lenovo Device 21d2
Flags: bus master, fast devsel, latency 0, IRQ 46
Memory at f000 (64-bit, non-prefetchable) [size=4M]
Memory at e000 (64-bit, prefetchable) [size=256M]
I/O ports at 4000 [size=64]
Expansion ROM at unassigned [disabled]
Capabilities: access denied
Kernel driver in use: i915
Kernel modules: i915

When the lockup happens the local display is completely unresponsive,
but connecting via ssh shows the following stuck tasks:

[  479.796787] INFO: task kworker/2:2:360 blocked for more than 120 seconds.
[  479.796798] echo 0  /proc/sys/kernel/hung_task_timeout_secs
disables this message.
[  479.796803] kworker/2:2 D  0   360  2 0x
[  479.796815]  88020ffb7c30 0046 88020fcfa080
88020ffb7fd8
[  479.796825]  88020ffb7fd8 88020ffb7fd8 8802148c2080
88020fcfa080
[  479.796834]  88020fcfa790 8802024a 88020fcfa740
0002
[  479.796844] Call Trace:
[  479.796862]  [81097e11] ? mark_held_locks+0x61/0x140
[  479.796876]  [815c44a5] ? mutex_lock_nested+0x1e5/0x320
[  479.796890]  [815c5a64] schedule+0x24/0x70
[  479.796902]  [815c5d79] schedule_preempt_disabled+0x9/0x10
[  479.796915]  [815c4411] mutex_lock_nested+0x151/0x320
[  479.796956]  [a00f79b1] ? output_poll_execute+0x51/0x1a0
[drm_kms_helper]
[  479.796973]  [a00f79b1] output_poll_execute+0x51/0x1a0
[drm_kms_helper]
[  479.796984]  [81060bba] process_one_work+0x18a/0x520
[  479.796992]  [81060b5e] ? process_one_work+0x12e/0x520
[  479.797001]  [812d2674] ? do_raw_spin_lock+0x54/0x120
[  479.797016]  [a00f7960] ?
drm_helper_connector_dpms+0x100/0x100 [drm_kms_helper]
[  479.797032]  [810613af] worker_thread+0x18f/0x4f0
[  479.797039]  [815c6cfa] ? _raw_spin_unlock_irqrestore+0x3a/0x70
[  479.797047]  [8109809d] ? trace_hardirqs_on+0xd/0x10
[  479.797055]  [81061220] ? rescuer_thread+0x290/0x290
[  479.797063]  [81066909] kthread+0xa9/0xb0
[  479.797069]  [8109809d] ? trace_hardirqs_on+0xd/0x10
[  479.797078]  [815cec44] kernel_thread_helper+0x4/0x10
[  479.797085]  [815c70b0] ? retint_restore_args+0x13/0x13
[  479.797092]  [81066860] ? __init_kthread_worker+0x70/0x70
[  479.797098]  [815cec40] ? gs_change+0x13/0x13
[  479.797104] 3 locks held by kworker/2:2/360:
[  479.797107]  #0:  (events_nrt){.+.+.+}, at: [81060b5e]
process_one_work+0x12e/0x520
[  479.797125]  #1:
(((dev-mode_config.output_poll_work)-work)){+.+.+.}, at:
[81060b5e] process_one_work+0x12e/0x520
[  479.797140]  #2:  (dev-mode_config.mutex){+.+.+.}, at:
[a00f79b1] output_poll_execute+0x51/0x1a0 [drm_kms_helper]
[  479.797185] INFO: task Xorg:1759 blocked for more than 120 seconds.
[  479.797189] echo 0  /proc/sys/kernel/hung_task_timeout_secs
disables this message.
[  479.797192] XorgD  0  1759   1716 0x0044
[  479.797201]  880211091898 0046 880211999040
880211091fd8
[  479.797211]  880211091fd8 880211091fd8 8801dd9ea080
880211999040
[  479.797219]  880211999708 880211999040 0007
0006
[  479.797228] Call Trace:
[  479.797235]  [81097e11] ? mark_held_locks+0x61/0x140
[  479.797243]  [815c6cfa] ? _raw_spin_unlock_irqrestore+0x3a/0x70
[  479.797249]  [81097ffd] ? trace_hardirqs_on_caller+0x10d/0x1a0
[  479.797256]  [8109809d] ? trace_hardirqs_on+0xd/0x10
[  479.797265]  [815c5a64] schedule+0x24/0x70
[  479.797299]  [a01253ad]
intel_crtc_wait_for_pending_flips+0x6d/0xc0 [i915]
[  479.797307]  [81067190] ? __init_waitqueue_head+0x60/0x60
[  479.797337]  [a0128f5d] ironlake_crtc_disable+0x4d/0x7a0 [i915]
[  479.797363]  [a0129749] ironlake_crtc_prepare+0x9/0x10 [i915]
[  479.797379]  [a00f7ebe]
drm_crtc_helper_set_mode+0x35e/0x520 [drm_kms_helper]
[  479.797403]  [a00f8a1d]
drm_crtc_helper_set_config+0x83d/0xaf0 [drm_kms_helper]
[  479.797440]  [a0071a1d] drm_mode_setcrtc+0x2ed/0x540 [drm]
[  479.797466]  [a00622dc] drm_ioctl+0x47c/0x540 [drm]
[  479.797496]  [a0071730] ? 

Re: [Intel-gfx] [BUG] i915 RC6 lockup

2012-10-16 Thread Ben Widawsky
On Tue, 16 Oct 2012 15:19:26 +0200
Jonas Jelten jel...@in.tum.de wrote:

 Hi list!
 
 I think i've got a problem with the intel driver:
 
 Sometimes, I think especially after running graphics intense
 applications, RC6 is disabled completely and heats up my Thinkpad
 X220t to 90 degree celsius, while idling.
 
 At first I thought that this is a CPU frequency scaling issue, as the
 cpufreq_powersave claims to be running at 800 MHz, but i7z
 (http://code.google.com/p/i7z/) shows all multipliers to be 25 - 2.5
 GHz CPU clock.
 
 Powertop 2.1 reveals that the GPU is 100% active, 0% RC6, 0% RC6p and
 0% RC6pp, and the CPU is 99,9% in C7-deep-sleep, at maximum frequency.
 /sys/kernel/debug/dri/0/i915_ring_freq_table also pointed the issue to
 being caused by the GPU.

Do you mean the GPU is 0% active? If you really mean 100% then the
results are expected, though I'm not sure how powertop attempts to
calculate the GPU activity. I'm guessing it's just 100 - rc6
state percentage, which when rc6 works is probably pretty close to
reasonable.

 
 intel_gpu_top shows a total idle.

This indicates the above assumption is true.

 
 I'm on ArchLinux, Kernel 3.6.2, xf86-video-intel-git
 b42d81b63f5b6a571faffaadd42c74adce40128a, this is 2.20.10.
 Problem first occured with Kernel 3.6.0.
 Core i5-2520M HD 3000

Obviously a bisect of the exact failing commit would be fantastic.

 
 cat /proc/cmdline
 cryptdevice=/dev/sda2:cryptroot root=/dev/mapper/cryptroot ro vga=791
 i915.i915_enable_rc6=7 i915.modeset=1 i915.lvds_downclock=1
 i915.semaphores=1 drm.vblankoffdelay=1 init=/bin/systemd
 initrd=../initramfs-linux.img BOOT_IMAGE=../vmlinuz-linux

First and most obvious, do not set rc6=7. If you do, do not file
bug reports with those results. RC6++ is known to be extremely broken,
and why we let users so easily hurt themselves is probably something we
need to remedy. On HD3000, even rc6+ is highly recommended against.

 
 Sometimes it can be fixed by going to pm-suspend and waking up. A
 reboot always fixes it, until it randomly locks up the GPU again.
 
 Please help me how i can do further investigation to catch the bug.

If you can reproduce it with rc6=1, then it echoes some other bugs
we're trying to track down. Figuring out the most minimal test case to
make it occur would be helpful. Also you can search the mailing list
for RPS related patches which seem to be related. Trying some of those
and reporting your results would be helpful.

Double check your dmesg for any GPU hangs which may have occurred before
the laptop becomes a space heater.


 
 As this makes my Laptop consume ~40W, it would be really nice if this
 gets fixed.
 
 
 Cheers,
 
 Jonas
 
 

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx