1. 23 7月, 2014 1 次提交
  2. 12 7月, 2014 1 次提交
  3. 11 7月, 2014 1 次提交
  4. 09 7月, 2014 1 次提交
  5. 08 7月, 2014 1 次提交
  6. 07 7月, 2014 1 次提交
    • D
      drm/i915: rework digital port IRQ handling (v2) · 13cf5504
      Dave Airlie 提交于
      The digital ports from Ironlake and up have the ability to distinguish
      between long and short HPD pulses. Displayport 1.1 only uses the short
      form to request link retraining usually, so we haven't really needed
      support for it until now.
      
      However with DP 1.2 MST we need to handle the short irqs on their
      own outside the modesetting locking the long hpd's involve. This
      patch adds the framework to distinguish between short/long to the
      current code base, to lay the basis for future DP 1.2 MST work.
      
      This should mean we get better bisectability in case of regression
      due to the new irq handling.
      
      v2: add GM45 support (untested, due to lack of hw)
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      Reviewed-by: NTodd Previte <tprevite@gmail.com>
      [danvet: Fix conflicts in i915_irq.c with Oscar Mateo's irq handling
      race fixes and a trivial one in intel_drv.h with the psr code.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      13cf5504
  7. 18 6月, 2014 4 次提交
    • O
      drm/i915/chv: Ack interrupts before handling them (CHV) · 27b6c122
      Oscar Mateo 提交于
      Otherwise, we might receive a new interrupt before we have time to
      ack the first one, eventually missing it.
      
      Without an atomic XCHG operation with mmio space, this patch merely
      reduces the window in which we can miss an interrupt (especially when
      you consider how heavyweight the I915_READ/I915_WRITE operations are).
      
      Notice that, before clearing a port-sourced interrupt in the IIR, the
      corresponding interrupt source status in the PORT_HOTPLUG_STAT must be
      cleared.
      
      Spotted by Bob Beckett <robert.beckett@intel.com>.
      
      v2:
      - Add warning to commit message and comments to the code as per Chris
        Wilson's request.
      - Imre Deak pointed out that the pipe underrun flag might not be signaled
        in IIR, so do not make valleyview_pipestat_irq_handler depend on it.
      
      v3: Improve the source code comment.
      Signed-off-by: NOscar Mateo <oscar.mateo@intel.com>
      Reviewed-by: NImre Deak <imre.deak@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      27b6c122
    • O
      drm/i915/bdw: Ack interrupts before handling them (GEN8) · 38cc46d7
      Oscar Mateo 提交于
      Otherwise, we might receive a new interrupt before we have time to
      ack the first one, eventually missing it.
      
      The right order should be:
      
      1 - Disable Master Interrupt Control.
      2 - Find the category of interrupt that is pending.
      3 - Find the source(s) of the interrupt and clear the Interrupt Identity bits (IIR)
      4 - Process the interrupt(s) that had bits set in the IIRs.
      5 - Re-enable Master Interrupt Control.
      
      Without an atomic XCHG operation with mmio space, the above merely reduces the window
      in which we can miss an interrupt (especially when you consider how heavyweight the
      I915_READ/I915_WRITE operations are).
      
      Spotted by Bob Beckett <robert.beckett@intel.com>.
      
      v2: Add warning to commit message and comments to the code as per Chris Wilson's request.
      
      v3: Improve the source code comment.
      Signed-off-by: NOscar Mateo <oscar.mateo@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      38cc46d7
    • O
      drm/i915/vlv: Ack interrupts before handling them (VLV) · 3ff60f89
      Oscar Mateo 提交于
      Otherwise, we might receive a new interrupt before we have time to
      ack the first one, eventually missing it.
      
      Without an atomic XCHG operation with mmio space, this patch merely
      reduces the window in which we can miss an interrupt (especially when
      you consider how heavyweight the I915_READ/I915_WRITE operations are).
      
      Notice that, before clearing a port-sourced interrupt in the IIR, the
      corresponding interrupt source status in the PORT_HOTPLUG_STAT must be
      cleared.
      
      Spotted by Bob Beckett <robert.beckett@intel.com>.
      
      v2:
      - Reorder the IIR clearing to reduce the window even further.
      - Add warning to commit message and comments to the code as per Chris
        Wilson's request.
      - Imre Deak pointed out that the pipe underrun flag might not be signaled
        in IIR, so do not make valleyview_pipestat_irq_handler depend on it.
      
      v3: Improve the source code comment.
      Signed-off-by: NOscar Mateo <oscar.mateo@intel.com>
      Reviewed-by: NImre Deak <imre.deak@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      3ff60f89
    • O
      drm/i915: Ack interrupts before handling them (GEN5 - GEN7) · 72c90f62
      Oscar Mateo 提交于
      Otherwise, we might receive a new interrupt before we have time to ack the first
      one, eventually missing it.
      
      According to BSPec, the right order should be:
      
      1 - Disable Master Interrupt Control.
      2 - Find the source(s) of the interrupt.
      3 - Clear the Interrupt Identity bits (IIR).
      4 - Process the interrupt(s) that had bits set in the IIRs.
      5 - Re-enable Master Interrupt Control.
      
      Without an atomic XCHG operation with mmio space, the above merely reduces the window
      in which we can miss an interrupt (especially when you consider how heavyweight the
      I915_READ/I915_WRITE operations are).
      
      We maintain the "disable SDE interrupts when handling" hack since apparently it works.
      
      Spotted by Bob Beckett <robert.beckett@intel.com>.
      
      v2: Add warning to commit message and comments to the code as per Chris Wilson's request.
      v3: Improve the source comments.
      Signed-off-by: NOscar Mateo <oscar.mateo@intel.com>
      Reviewed-by: NImre Deak <imre.deak@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      72c90f62
  8. 17 6月, 2014 1 次提交
    • S
      drm/i915: Replaced Blitter ring based flips with MMIO flips · 84c33a64
      Sourab Gupta 提交于
      This patch enables the framework for using MMIO based flip calls,
      in contrast with the CS based flip calls which are being used currently.
      
      MMIO based flip calls can be enabled on architectures where
      Render and Blitter engines reside in different power wells. The
      decision to use MMIO flips can be made based on workloads to give
      100% residency for Media power well.
      
      v2: The MMIO flips now use the interrupt driven mechanism for issuing the
      flips when target seqno is reached. (Incorporating Ville's idea)
      
      v3: Rebasing on latest code. Code restructuring after incorporating
      Damien's comments
      
      v4: Addressing Ville's review comments
          -general cleanup
          -updating only base addr instead of calling update_primary_plane
          -extending patch for gen5+ platforms
      
      v5: Addressed Ville's review comments
          -Making mmio flip vs cs flip selection based on module parameter
          -Adding check for DRIVER_MODESET feature in notify_ring before calling
           notify mmio flip.
          -Other changes mostly in function arguments
      
      v6: -Having a seperate function to check condition for using mmio flips (Ville)
          -propogating error code from i915_gem_check_olr (Ville)
      
      v7: -Adding __must_check with i915_gem_check_olr (Chris)
          -Renaming mmio_flip_data to mmio_flip (Chris)
          -Rebasing on latest nightly
      
      v8: -Rebasing on latest code
          -squash 3rd patch in series(mmio setbase vs page flip race) with this patch
          -Added new tiling mode update in intel_do_mmio_flip (Chris)
      
      v9: -check for obj->last_write_seqno being 0 instead of obj->ring being NULL in
      intel_postpone_flip, as this is a more restrictive condition (Chris)
      
      v10: -Applied Chris's suggestions for squashing patches 2,3 into this patch.
      These patches make the selection of CS vs MMIO flip at the page flip time, and
      make the module parameter for using mmio flips as tristate, the states being
      'force CS flips', 'force mmio flips', 'driver discretion'.
      Changed the logic for driver discretion (Chris)
      
      v11: Minor code cleanup(better readability, fixing whitespace errors, using
      lockdep to check mutex locked status in postpone_flip, removal of __must_check
      in function definition) (Chris)
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NSourab Gupta <sourab.gupta@intel.com>
      Signed-off-by: NAkash Goel <akash.goel@intel.com>
      Tested-by: Chris Wilson <chris@chris-wilson.co.uk> # snb, ivb
      [danvet: Fix up parameter alignement checkpatch spotted.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      84c33a64
  9. 11 6月, 2014 2 次提交
  10. 05 6月, 2014 4 次提交
    • V
      drm/i915: Set AGPBUSY# bit in init_clock_gating · 12fabbcb
      Ville Syrjälä 提交于
      I don't see why we wouldn't want interrupts to wake up the CPU from C3
      always, so just set the AGPBUSY# bit in gen3_init_clock_gating().
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      12fabbcb
    • D
      drm/i915: Extract gen8_gt_irq_reset · d6e3cca3
      Daniel Vetter 提交于
      Fallout from an intermediate patch revision that I deemed worth saving.
      
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      d6e3cca3
    • D
      drm/i915: Inline ilk/gen8_irq_reset · 723761b8
      Daniel Vetter 提交于
      No point in having this indirection.
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      723761b8
    • D
      drm/i915: Fix up fifo underrun tracking, take N · 2ae2a50c
      Daniel Vetter 提交于
      So apparently this is tricky.
      
      We need to consider:
      - We start out with all the hw enabling bits disabled, both the
        individual fifo underrun interrupts and the shared display error
        interrupts masked. Otherwise if the bios config is broken we'll blow
        up with a NULL deref in our interrupt handler since the crtc
        structures aren't set up yet at driver load time.
      - On gmch we need to mask fifo underruns on the sw side, so always
        need to set that in sanitize_crtc for those platforms.
      - On other platforms we try to set the sw tracking so that it reflects
        the real state. But since a few platforms have shared bits we must
        _not_ disable fifo underrun reporting. Otherwise we'll never enable
        the shared error interrupt.
      
      This is the state before out patch, but unfortunately this is not good
      enough. But after a suspend resume operation this is broken:
      1. We don't enable the hw interrupts since the same code runs on
      resume as on driver load.
      2. The fifo underrun state adjustments we do in sanitize_crtc doesn't
      fire on resume since (except for hilarious firmware) all pipes are off
      at that point. But they also don't hurt since the subsequent crtc
      enabling due to force_restore will enable fifo underruns.
      
      Which means when we enable fifo underrun reporting we notice that the
      per-crtc state is already correct and short-circuit everthing out. And
      the interrupt doesn't get enabled.
      
      A similar problem would happen if the bios doesn't light up anything
      when the driver loads. Which is exactly what happens when we reload
      the driver since our unload functions disables all outputs.
      
      Now we can't just rip out the short-circuit logic and unconditionally
      update the fifo underrun reporting interrupt masking: We have some
      checks for shared error interrupts to catch issues that happened when
      the shared error interrupt was disabled.
      
      The right fix is to push down this logic so that we can always update
      the hardware state, but only check for missed fifo underruns on a real
      enabled->disabled transition and ignore them when we're already
      disabled.
      
      On platforms with shared error interrupt the pipe CRC interrupts are
      grouped together with the fifo underrun reporting this fixes pipe CRC
      support after suspend and driver reloads.
      
      Testcase: igt/kms_pipe_crc_basic/suspend-*
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      2ae2a50c
  11. 04 6月, 2014 1 次提交
  12. 23 5月, 2014 3 次提交
    • O
      drm/i915: Split the ringbuffers from the rings (3/3) · 93b0a4e0
      Oscar Mateo 提交于
      Manual cleanup after the previous Coccinelle script.
      
      Yes, I could write another Coccinelle script to do this but I
      don't want labor-replacing robots making an honest programmer's
      work obsolete (also, I'm lazy).
      Signed-off-by: NOscar Mateo <oscar.mateo@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      93b0a4e0
    • O
      drm/i915: Split the ringbuffers from the rings (2/3) · ee1b1e5e
      Oscar Mateo 提交于
      This refactoring has been performed using the following Coccinelle
      semantic script:
      
          @@
          struct intel_engine_cs r;
          @@
          (
          - (r).obj
          + r.buffer->obj
          |
          - (r).virtual_start
          + r.buffer->virtual_start
          |
          - (r).head
          + r.buffer->head
          |
          - (r).tail
          + r.buffer->tail
          |
          - (r).space
          + r.buffer->space
          |
          - (r).size
          + r.buffer->size
          |
          - (r).effective_size
          + r.buffer->effective_size
          |
          - (r).last_retired_head
          + r.buffer->last_retired_head
          )
      
          @@
          struct intel_engine_cs *r;
          @@
          (
          - (r)->obj
          + r->buffer->obj
          |
          - (r)->virtual_start
          + r->buffer->virtual_start
          |
          - (r)->head
          + r->buffer->head
          |
          - (r)->tail
          + r->buffer->tail
          |
          - (r)->space
          + r->buffer->space
          |
          - (r)->size
          + r->buffer->size
          |
          - (r)->effective_size
          + r->buffer->effective_size
          |
          - (r)->last_retired_head
          + r->buffer->last_retired_head
          )
      
          @@
          expression E;
          @@
          (
          - LP_RING(E)->obj
          + LP_RING(E)->buffer->obj
          |
          - LP_RING(E)->virtual_start
          + LP_RING(E)->buffer->virtual_start
          |
          - LP_RING(E)->head
          + LP_RING(E)->buffer->head
          |
          - LP_RING(E)->tail
          + LP_RING(E)->buffer->tail
          |
          - LP_RING(E)->space
          + LP_RING(E)->buffer->space
          |
          - LP_RING(E)->size
          + LP_RING(E)->buffer->size
          |
          - LP_RING(E)->effective_size
          + LP_RING(E)->buffer->effective_size
          |
          - LP_RING(E)->last_retired_head
          + LP_RING(E)->buffer->last_retired_head
          )
      
      Note: On top of this this patch also removes the now unused ringbuffer
      fields in intel_engine_cs.
      Signed-off-by: NOscar Mateo <oscar.mateo@intel.com>
      [danvet: Add note about fixup patch included here.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      ee1b1e5e
    • O
      drm/i915: s/intel_ring_buffer/intel_engine_cs · a4872ba6
      Oscar Mateo 提交于
      In the upcoming patches we plan to break the correlation between
      engine command streamers (a.k.a. rings) and ringbuffers, so it
      makes sense to refactor the code and make the change obvious.
      
      No functional changes.
      Signed-off-by: NOscar Mateo <oscar.mateo@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      a4872ba6
  13. 22 5月, 2014 7 次提交
  14. 21 5月, 2014 1 次提交
    • D
      drm/i915: Accurately initialize fifo underrun state on gmch platforms · c5ab3bc0
      Daniel Vetter 提交于
      We don't have hardware based disable bits on gmch platforms, so need
      to block spurious underrun reports in software. Which means that we
      _must_ start out with fifo underrun reporting disabled everywhere.
      
      This is in big contrast to ilk/hsw/cpt where there's only _one_
      disable bit for all platforms and hence we must allow underrun
      reporting on disabled pipes. Otherwise nothing really works,
      especially the CRC support since that's key'ed off the same irq
      disable bit.
      
      This allows us to ditch the fifo underrun reporting hack from the vlv
      runtime pm code and unexport the internal function from i915_irq.c
      again. Yay!
      
      v2: Keep the display irq disabling, spotted by Imre.
      
      Cc: Imre Deak <imre.deak@intel.com>
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      c5ab3bc0
  15. 20 5月, 2014 3 次提交
  16. 17 5月, 2014 1 次提交
  17. 16 5月, 2014 1 次提交
    • B
      drm/i915/bdw: Implement a basic PM interrupt handler · 0961021a
      Ben Widawsky 提交于
      Almost all of it is reusable from the existing code. The primary
      difference is we need to do even less in the interrupt handler, since
      interrupts are not shared in the same way.
      
      The patch is mostly a copy-paste of the existing snb+ code, with updates
      to the relevant parts requiring changes to the interrupt handling. As
      such it /should/ be relatively trivial. It's highly likely that I missed
      some places where I need a gen8 version of the PM interrupts, but it has
      become invisible to me by now.
      
      This patch could probably be split into adding the new functions,
      followed by actually handling the interrupts. Since the code is
      currently disabled (and broken) I think the patch stands better by
      itself.
      
      v2: Move the commit about not touching the ringbuffer interrupt to the
      snb_* function where it belongs (Rodrigo)
      
      v3: Rebased on Paulo's runtime PM changes
      
      v4: Not well validated, but rebase on
      commit 730488b2
      Author: Paulo Zanoni <paulo.r.zanoni@intel.com>
      Date:   Fri Mar 7 20:12:32 2014 -0300
      
          drm/i915: kill dev_priv->pm.regsave
      
      v5: Rebased on latest code base. (Deepak)
      
      v6: Remove conflict markers, Unnecessary empty line and use right
      IIR interrupt (Ville)
      
      v7: mask modified without rmw (Ville Syrjälä)
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDeepak S <deepak.s@linux.intel.com>
      Signed-off-by: NMika Kuoppala <mika.kuoppala@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      0961021a
  18. 13 5月, 2014 2 次提交
    • D
      drm/i915: Drop unecessary casts in i915_irq.c · 45a83f84
      Daniel Vetter 提交于
      Inspired by a review bikeshed from Jani.
      
      Cc: Jani Nikula <jani.nikula@intel.com>
      Reviewed-by: NJani Nikula <jani.nikula@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      45a83f84
    • V
      drm/i915/chv: Preliminary interrupt support for Cherryview · 43f328d7
      Ville Syrjälä 提交于
      CHV has the Gen8 master interrupt register, as well as Gen8
      GT/PCU interrupt registers.
      
      The display block is based on VLV, with the main difference
      of adding pipe C.
      
      v2: Rewrite the order of operations to make more sense
          Don't bail out if MASTER_CTL register doesn't show an interrupt,
          as display interrupts aren't reported there.
      
      v3: Rebase on top of Egbert Eich's hpd irq handling rework by using
      the relevant port hotplug logic like for vlv.
      
      v4: Rebase on top of Ben's gt irq #define refactoring.
      
      v5: Squash in gen8_gt_irq_handler refactoring from Zhao Yakui
      <yakui.zhao@intel.com>
      
      v6: Adapt to upstream changes, dev_priv->irq_received is gone.
      
      v7: Enable 3 the commented-out 3 pipe support.
      
      v8: Rebase on top of Paulo's irq setup rework, use the renamed macros from
      upstream.
      
      v9: Grab irq_lock around i915_enable_pipestat()
      
      FIXME: There's probably some potential for more shared code between bdw and chv.
      
      Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> (v2)
      Reviewed-by: NJani Nikula <jani.nikula@intel.com>
      [danvet: Drop the unnecessary cast Jani spotted.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      43f328d7
  19. 06 5月, 2014 1 次提交
    • V
      drm/i915: Make sprite updates atomic · 8d7849db
      Ville Syrjälä 提交于
      Add a mechanism by which we can evade the leading edge of vblank. This
      guarantees that no two sprite register writes will straddle on either
      side of the vblank start, and that means all the writes will be latched
      together in one atomic operation.
      
      We do the vblank evade by checking the scanline counter, and if it's too
      close to the start of vblank (too close has been hardcoded to 100usec
      for now), we will wait for the vblank start to pass. In order to
      eliminate random delayes from the rest of the system, we operate with
      interrupts disabled, except when waiting for the vblank obviously.
      
      Note that we now go digging through pipe_to_crtc_mapping[] in the
      vblank interrupt handler, which is a bit dangerous since we set up
      interrupts before the crtcs. However in this case since it's the vblank
      interrupt, we don't actually unmask it until some piece of code
      requests it.
      
      v2: preempt_check_resched() calls after local_irq_enable() (Jesse)
          Hook up the vblank irq stuff on BDW as well
      v3: Pass intel_crtc instead of drm_crtc (Daniel)
          Warn if crtc.mutex isn't locked (Daniel)
          Add an explicit compiler barrier and document the barriers (Daniel)
          Note the irq vs. modeset setup madness in the commit message (Daniel)
      v4: Use prepare_to_wait() & co. directly and eliminate vbl_received
      v5: Refactor intel_pipe_handle_vblank() vs. drm_handle_vblank() (Chris)
          Check for min/max scanline <= 0 (Chris)
          Don't call intel_pipe_update_end() if start failed totally (Chris)
          Check that the vblank counters match on both sides of the critical
          section (Chris)
      v6: Fix atomic update for interlaced modes
      v7: Reorder code for better readability (Chris)
      v8: Drop preempt_check_resched(). It's not available to modules
          anymore and isn't even needed unless we ourselves cause
          a wakeup needing reschedule while interrupts are off
      Reviewed-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      Reviewed-by: NSourab Gupta <sourabgupta@gmail.com>
      Reviewed-by: NAkash Goel <akash.goels@gmail.com>
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      8d7849db
  20. 05 5月, 2014 3 次提交
    • B
      drm/i915: Move semaphore specific ring members to struct · ebc348b2
      Ben Widawsky 提交于
      This will be helpful in abstracting some of the code in preparation for
      gen8 semaphores.
      
      v2: Move mbox stuff to a separate struct
      
      v3: Rebased over VCS2 work
      
      Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> (v1)
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      ebc348b2
    • V
      drm/i915: Add intel_get_crtc_scanline() · a225f079
      Ville Syrjälä 提交于
      Add a new function intel_get_crtc_scanline() that returns the current
      scanline counter for the crtc.
      
      v2: Rebase after vblank timestamp changes.
          Use intel_ prefix instead of i915_ as is more customary for
          display related functions.
          Include DRM_SCANOUTPOS_INVBL in the return value even w/o
          adjustments, for a bit of extra consistency.
      v3: Change the implementation to be based on DSL on all gens,
          since that's enough for the needs of atomic updates, and
          it will avoid complicating the scanout position calculations
          for the vblank timestamps
      v4: Don't break scanline wraparound for interlaced modes
      Reviewed-by: NSourab Gupta <sourabgupta@gmail.com>
      Reviewed-by: NAkash Goel <akash.goels@gmail.com>
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      a225f079
    • V
      drm/i915: Fix scanout position for real · 78e8fc6b
      Ville Syrjälä 提交于
      Seems I've been a bit dense with regards to the start of vblank
      vs. the scanline counter / pixel counter.
      
      After staring at the pixel counter on gen4 I came to the conclusion
      that the start of vblank interrupt and scanline counter increment
      happen at the same time. The scanline counter increment is documented
      to occur at start of hsync, which means that the start of vblank
      interrupt must also trigger there. Looking at the pixel counter value
      when the scanline wraps from vtotal-1 to 0 confirms that, as the pixel
      counter at that point reads hsync_start. This also clarifies why we see
      need the +1 adjustment to the scaline counter. The counter actually
      starts counting from vtotal-1 on the first active line.
      
      I also confirmed that the frame start interrupt happens ~1 line after
      the start of vblank, but the frame start occurs at hblank_start instead.
      We only use the frame start interrupt on gen2 where the start of vblank
      interrupt isn't available. The only important thing to note here is that
      frame start occurs after vblank start, so we don't have to play any
      additional tricks to fix up the scanline counter.
      
      The other thing to note is the fact that the pixel counter on gen3-4
      starts counting from the start of horizontal active on the first active
      line. That means that when we get the start of vblank interrupt, the
      pixel counter reads (htotal*(vblank_start-1)+hsync_start). Since we
      consider vblank to start at (htotal*vblank_start) we need to add a
      constant (htotal-hsync_start) offset to the pixel counter, or else we
      risk misdetecting whether we're in vblank or not.
      
      I talked a bit with Art Runyan about these topics, and he confirmed my
      findings. And that the same rules should hold for platforms which don't
      have the pixel counter. That's good since without the pixel counter it's
      rather difficult to verify the timings to this accuracy.
      
      So the conclusion is that we can throw away all the ISR tricks I added,
      and just increment the scanline counter by one always.
      Reviewed-by: NSourab Gupta <sourabgupta@gmail.com>
      Reviewed-by: NAkash Goel <akash.goels@gmail.com>
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      78e8fc6b