1. 19 6月, 2014 3 次提交
    • D
      drm/i915: Introduce accurate frontbuffer tracking · a071fa00
      Daniel Vetter 提交于
      So from just a quick look we seem to have enough information to
      accurately figure out whether a given gem bo is used as a frontbuffer
      and where exactly: We have obj->pin_count as a first check with no
      false negatives and only negligible false positives. And then we can
      just walk the modeset objects and figure out where exactly a buffer is
      used as scanout.
      
      Except that we can't due to locking order: If we already hold
      dev->struct_mutex we can't acquire any modeset locks, so could
      potential chase freed pointers and other evil stuff.
      
      So we need something else. For that introduce a new set of bits
      obj->frontbuffer_bits to track where a buffer object is used. That we
      can then chase without grabbing any modeset locks.
      
      Of course the consumers of this (DRRS, PSR, FBC, ...) still need to be
      able to do their magic both when called from modeset and from gem
      code. But that can be easily achieved by adding locks for these
      specific subsystems which always nest within either kms or gem
      locking.
      
      This patch just adds the relevant update code to all places.
      
      Note that if we ever support multi-planar scanout targets then we need
      one frontbuffer tracking bit per attachment point that we expose to
      userspace.
      
      v2:
      - Fix more oopsen. Oops.
      - WARN if we leak obj->frontbuffer_bits when freeing a gem buffer. Fix
        the bugs this brought to light.
      - s/update_frontbuffer_bits/update_fb_bits/. More consistent with the
        fb tracking functions (fb for gem object, frontbuffer for raw bits).
        And the function name was way too long.
      
      v3: Size obj->frontbuffer_bits correctly so that all pipes fit in.
      
      v4: Don't update fb bits in set_base on failure. Noticed by Chris.
      
      v5: s/i915_gem_update_fb_bits/i915_gem_track_fb/ Also remove a few
      local enum pipe variables which are now no longer needed to make the
      function arguments no drop over the 80 char limit.
      
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      a071fa00
    • D
      drm/i915: Drop schedule_back from psr_exit · 3108e99e
      Daniel Vetter 提交于
      It doesn't make sense to never again schedule the work, since by the
      time we might want to re-enable psr the world might have changed and
      we can do it again.
      
      The only exception is when we shut down the pipe, but that's an
      entirely different thing and needs to be handled in psr_disable.
      
      Note that later patch will again split psr_exit into psr_invalidate
      and psr_flush. But the split is different and this simplification
      helps with the transition.
      
      v2: Improve the commit message a bit.
      
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Reviewed-by: NRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      3108e99e
    • D
      drm/i915: Ditch intel_edp_psr_update · e6e559d4
      Daniel Vetter 提交于
      We have _enable/_disable interfaces now for the modeset sequence and
      intel_edp_psr_exit for workarounds.
      
      The callsites in intel_display.c are all redundant with the modeset
      sequence enable/disable calls in intel_ddi.c. The one in
      intel_sprite.c is real and needs to be switched to psr_exit.
      
      If this breaks anything then we need to augment the enable/disable
      functions accordingly.
      
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Reviewed-by: NRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      e6e559d4
  2. 17 6月, 2014 2 次提交
    • 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
    • D
      drm/i915: Fix comment about our plane remapping on gen2/3 · 8c0f92e1
      Daniel Vetter 提交于
      Spotted while crawling around in the area.
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      8c0f92e1
  3. 14 6月, 2014 1 次提交
    • R
      drm/i915: Force PSR exit by inactivating it. · 7c8f8a70
      Rodrigo Vivi 提交于
      The perfect solution for psr_exit is the hardware tracking the changes and
      doing the psr exit by itself. This scenario works for HSW and BDW with some
      environments like Gnome and Wayland.
      
      However there are many other scenarios that this isn't true. Mainly one right
      now is KDE users on HSW and BDW with PSR on. User would miss many screen
      updates. For instances any key typed could be seen only when mouse cursor is
      moved. So this patch introduces the ability of trigger PSR exit on kernel side
      on some common cases that.
      
      Most of the cases are coverred by psr_exit at set_domain. The remaining cases
      are coverred by triggering it at set_domain, busy_ioctl, sw_finish and
      mark_busy.
      
      The downside here might be reducing the residency time on the cases this
      already work very wall like Gnome environment. But so far let's get focused
      on fixinge issues sio PSR couild be used for everybody and we could even
      get it enabled by default. Later we can add some alternatives to choose the
      level of PSR efficiency over boot flag of even over crtc property.
      
      v2: remove exit from connector_dpms. Daniel pointed this is the wrong way and
      also this isn't needed for BDW and HSW anyway.
      
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: NVijay Purushothaman <vijay.a.purushothaman@intel.com>
      Signed-off-by: NRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      7c8f8a70
  4. 13 6月, 2014 3 次提交
    • V
      drm/i915: Add locking around framebuffer_references-- · 60a5ca01
      Ville Syrjälä 提交于
      obj->framebuffer_references isn't an atomic_t so the decrement needs to
      be protected by some lock. struct_mutex seems like the appropriate lock
      here, and we may already take it for the obj unref anyway.
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      60a5ca01
    • M
      drm/i915: Switch to unified plane cursor handling (v4) · 3d7d6510
      Matt Roper 提交于
      The DRM core will translate calls to legacy cursor ioctls into universal
      cursor calls automatically, so there's no need to maintain the legacy
      cursor support.  This greatly simplifies the transition since we don't
      have to handle reference counting differently depending on which cursor
      interface was called.
      
      The aim here is to transition to the universal plane interface with
      minimal code change.  There's a lot of cleanup that can be done (e.g.,
      using state stored in crtc->cursor->fb rather than intel_crtc) that is
      left to future patches.
      
      v4:
       - Drop drm_gem_object_unreference() that is no longer needed now that
         we receive the GEM obj directly rather than looking up the ID.
      v3:
       - Pass cursor obj to intel_crtc_cursor_set_obj() if cursor fb changes,
         even if 'visible' is false.  intel_crtc_cursor_set_obj() will notice
         that the cursor isn't visible and disable it properly, but we still
         need to get intel_crtc->cursor_addr set properly so that we behave
         properly if the cursor becomes visible again in the future without
         changing the cursor buffer (noted by Chris Wilson and verified
         via i-g-t kms_cursor_crc).
       - s/drm_plane_init/drm_universal_plane_init/.  Due to type
         compatibility between enum and bool, everything actually works
         correctly with the wrong init call, except for the type of plane that
         gets exposed to userspace (it shows up as type 'primary' rather than
         type 'cursor').
      v2:
       - Remove duplicate dimension checks on cursor
       - Drop explicit cursor disable from crtc destroy (fb & plane
         destruction will take care of that now)
       - Use DRM plane helper to check update parameters
      
      Cc: intel-gfx@lists.freedesktop.org
      Signed-off-by: NMatt Roper <matthew.d.roper@intel.com>
      Reviewed-by: Pallavi G<pallavi.g@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      3d7d6510
    • M
      drm/i915: Add intel_crtc_cursor_set_obj() to set cursor buffer (v2) · e3287951
      Matt Roper 提交于
      Refactor cursor buffer setting such that the code to actually update the
      cursor lives in a new function, intel_crtc_cursor_set_obj(), and takes
      a GEM object as a parameter.  The existing legacy cursor ioctl handler,
      intel_crtc_cursor_set() will now perform the userspace handle lookup and
      then call this new function.
      
      This refactoring is in preparation for the universal plane cursor
      support where we'll want to update the cursor with an actual GEM buffer
      object (obtained via drm_framebuffer) rather than a userspace handle.
      
      v2:  Drop obvious kerneldoc and replace with note about function's
           reference consumption
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NMatt Roper <matthew.d.roper@intel.com>
      Reviewed-by: Pallavi G<pallavi.g@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      e3287951
  5. 11 6月, 2014 6 次提交
    • D
      drm/i915: runtime PM support for DPMS · 0e572fe7
      Daniel Vetter 提交于
      Keeping track of the power domains is a bit messy since crtc->active
      is currently updated by the platform hooks, but we need to be aware of
      which state transition exactly is going on. Maybe we simply need to
      shovel all the power domain handling down into platform code to
      simplify this. But doing that requires some more auditing since
      currently the ->mode_set callbacks still read some random registers
      (to e.g. figure out the reference clocks).
      
      Also note that intel_crtc_update_dpms is always call first/last even
      for encoders which have their own dpms functions. Hence we really only
      need to update this place here.
      
      Being a quick "does it blow up?" run not really tested yet.
      
      v2: Don't do runtime PM in the DPMS hooks for HAS_DDI platforms since
      that is stalled. Also add a comment to explain what's going on.
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      0e572fe7
    • M
      drm/i915: Intel-specific primary plane handling (v8) · 465c120c
      Matt Roper 提交于
      Intel hardware allows the primary plane to be disabled independently of
      the CRTC.  Provide custom primary plane handling to allow this.
      
      v8:
       - Pin/unpin properly when clipping causes the primary plane to be
         disabled when it has previously been enabled.
       - s/drm_primary_helper_check_update/drm_plane_helper_check_update/
      v7:
       - Clip primary plane to invisible when crtc is disabled since
         intel_crtc->config.pipe_src_{w,h} may be garbage otherwise.
       - Unpin old fb before pinning new one in the "just pin and
         return" case that is used when the crtc is disabled.
       - Don't treat implicit disabling of the primary plane (caused by
         clipping) the same way as explicit disabling (caused by fb=0).
         For implicit disables, we should leave the fb set and pinned,
         whereas for explicit disables we need to unpin the fb before
         primary->fb is cleared.
      v6:
       - Pass rectangles to primary helper check function and get plane
         visibility back.
       - Wait for pending pageflips on primary plane update/disable.
       - Allow primary plane to be updated while the crtc is disabled (changes
         will take effect when the crtc is re-enabled if modeset passes -1
         for the fb id).
       - Drop WARN() if we try to disable the primary plane when it's
         already been disabled.  This will happen if the crtc gets disabled
         after the primary plane has already been disabled independently.
      v5:
       - Use new drm_primary_helper_check_update() helper function to check
         setplane parameter validity.
       - Swap primary plane's pipe for pre-gen4 FBC (caught by Ville Syrjälä)
       - Cleanup primary plane properly on crtc init failure
      v4:
       - Don't add a primary_plane field to intel_crtc; that was left over
         from a much earlier iteration of this patch series, but is no longer
         needed/used now that the DRM core primary plane support has been
         merged.
      v3:
       - Provide gen-specific primary plane format lists (suggested by Daniel
         Vetter).
       - If the primary plane is already enabled, go ahead and just call the
         primary plane helper to do the update (suggested by Daniel Vetter).
       - Don't try to disable the primary plane on destruction; the DRM layer
         should have already taken care of this for us.
      v2:
       - Unpin fb properly on primary plane disable
       - Provide an Intel-specific set of primary plane formats
       - Additional sanity checks on setplane (in line with the checks
         currently being done by the DRM core primary plane helper)
      Reviewed-by: NChon Ming Lee <chon.ming.lee@intel.com>
      Signed-off-by: NMatt Roper <matthew.d.roper@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      465c120c
    • M
      drm/i915: don't force full modeset if primary plane is disabled (v2) · 3b150f08
      Matt Roper 提交于
      In a future patch, we'll allow the primary plane to be disabled by
      userspace via the universal plane API.  If a modeset is requested while
      the primary plane is disabled, crtc->primary->fb will be NULL which
      generally triggers a full modeset (except in fastboot situations).  If
      we detect that the crtc is active, but there's no primary plane fb,
      we should still allow a simple plane update rather than a full modeset
      if the mode isn't actually changing (after re-enabling the primary plane
      of course).
      
      v2:
       - Enable plane after set_base to avoid enabling the plane if set_base
         fails, and to make flip+enable atomic (suggested by Ville)
       - Drop BUG to WARN if we somehow enter the 'fb_changed' modeset case
         with the crtc disabled (suggested by Ville)
      Reviewed-by: NChon Ming Lee <chon.ming.lee@intel.com>
      Signed-off-by: NMatt Roper <matthew.d.roper@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      3b150f08
    • C
      drm/i915: Check for a NULL shared dpll before dereferencing · be19f0ff
      Chris Wilson 提交于
      This doesn't look possible but a little extra defense against the
      improbable is worth it - an oops here could lockup the machine.
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      be19f0ff
    • V
      drm/i915/chv: Force PHY clock buffers off after PLL disable · 61407f6d
      Ville Syrjälä 提交于
      Now that we forced the clock buffers on in .pre_pll_enable() we
      should probably undo the damage after we've turned the PLL off.
      
      We do the clock buffer force enable in the .pre_pll_enable() hook
      as we need to know which port is going to be used, but in the disable
      case we don't need the port since we just disable the clock buffers
      to both channels. So we can do this in chv_disable_pll() instead
      of having to add any kind of .post_pll_disable() hook.
      
      v2: Improve the commit message
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: NMika Kuoppala <mika.kuoppala@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      61407f6d
    • V
      drm/i915: Keep vblank interrupts enabled while enabling/disabling planes · f98551ae
      Ville Syrjälä 提交于
      Because of the upcoming vblank interrupt driven watermark update
      mechanism we will have use for vblank interrupts during plane
      enabling/disabling. So don't call drm_vblank_off() until planes
      are off, and call drm_vblank_on() just before we start to enable
      the planes.
      
      v2: Pimp commit message (Paulo)
      Reviewed-by: NPaulo Zanoni <paulo.r.zanoni@intel.com>
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      f98551ae
  6. 05 6月, 2014 7 次提交
  7. 04 6月, 2014 3 次提交
    • D
      drm: Split connection_mutex out of mode_config.mutex (v3) · 6e9f798d
      Daniel Vetter 提交于
      After the split-out of crtc locks from the big mode_config.mutex
      there's still two major areas it protects:
      - Various connector probe states, like connector->status, EDID
        properties, probed mode lists and similar information.
      - The links from connector->encoder and encoder->crtc and other
        modeset-relevant connector state (e.g. properties which control the
        panel fitter).
      
      The later is used by modeset operations. But they don't really care
      about the former since it's allowed to e.g. enable a disconnected VGA
      output or with a mode not in the probed list.
      
      Thus far this hasn't been a problem, but for the atomic modeset
      conversion Rob Clark needs to convert all modeset relevant locks into
      w/w locks. This is required because the order of acquisition is
      determined by how userspace supplies the atomic modeset data. This has
      run into troubles in the detect path since the i915 load detect code
      needs _both_ protections offered by the mode_config.mutex: It updates
      probe state and it needs to change the modeset configuration to enable
      the temporary load detect pipe.
      
      The big deal here is that for the probe/detect users of this lock a
      plain mutex fits best, but for atomic modesets we really want a w/w
      mutex. To fix this lets split out a new connection_mutex lock for the
      modeset relevant parts.
      
      For simplicity I've decided to only add one additional lock for all
      connector/encoder links and modeset configuration states. We have
      piles of different modeset objects in addition to those (like bridges
      or panels), so adding per-object locks would be much more effort.
      
      Also, we're guaranteed (at least for now) to do a full modeset if we
      need to acquire this lock. Which means that fine-grained locking is
      fairly irrelevant compared to the amount of time the full modeset will
      take.
      
      I've done a full audit, and there's just a few things that justify
      special focus:
      - Locking in drm_sysfs.c is almost completely absent. We should
        sprinkle mode_config.connection_mutex over this file a bit, but
        since it already lacks mode_config.mutex this patch wont make the
        situation any worse. This is material for a follow-up patch.
      
      - omap has a omap_framebuffer_flush function which walks the
        connector->encoder->crtc links and is called from many contexts.
        Some look like they don't acquire mode_config.mutex, so this is
        already racy. Again fixing this is material for a separate patch.
      
      - The radeon hot_plug function to retrain DP links looks at
        connector->dpms. Currently this happens without any locking, so is
        already racy. I think radeon_hotplug_work_func should gain
        mutex_lock/unlock calls for the mode_config.connection_mutex.
      
      - Same applies to i915's intel_dp_hot_plug. But again, this is already
        racy.
      
      - i915 load_detect code needs to acquire this lock. Which means the
        w/w dance due to Rob's work will be nicely contained to _just_ this
        function.
      
      I've added fixme comments everywhere where it looks suspicious but in
      the sysfs code. After a quick irc discussion with Dave Airlie it
      sounds like the lack of locking in there is due to sysfs cleanup fun
      at module unload.
      
      v1: original (only compile tested)
      
      v2: missing mutex_init(), etc (from Rob Clark)
      
      v3: i915 needs more care in the conversion:
      - Protect the edp pp logic with the connection_mutex.
      - Use connection_mutex in the backlight code due to
        get_pipe_from_connector.
      - Use drm_modeset_lock_all in suspend/resume paths.
      - Update lock checks in the overlay code.
      
      Cc: Alex Deucher <alexdeucher@gmail.com>
      Cc: Rob Clark <robdclark@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: NRob Clark <robdclark@gmail.com>
      6e9f798d
    • J
      drm/i915: replace drm_get_encoder_name() with direct name field use · 8e329a03
      Jani Nikula 提交于
      Generated using semantic patches:
      
      @@
      expression E;
      @@
      
      - drm_get_encoder_name(&E)
      + E.name
      
      @@
      expression E;
      @@
      
      - drm_get_encoder_name(E)
      + E->name
      
      v2: Turn drm_get_encoder_name(&E) into E.name instead of &(E)->name.
      Acked-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJani Nikula <jani.nikula@intel.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      8e329a03
    • J
      drm/i915: replace drm_get_connector_name() with direct name field use · c23cc417
      Jani Nikula 提交于
      Generated using semantic patches:
      
      @@
      expression E;
      @@
      
      - drm_get_connector_name(&E)
      + E.name
      
      @@
      expression E;
      @@
      
      - drm_get_connector_name(E)
      + E->name
      
      v2: Turn drm_get_connector_name(&E) into E.name instead of &(E)->name.
      Acked-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJani Nikula <jani.nikula@intel.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      c23cc417
  8. 27 5月, 2014 1 次提交
  9. 23 5月, 2014 1 次提交
  10. 22 5月, 2014 4 次提交
  11. 21 5月, 2014 9 次提交
    • V
      drm/i915: Re-enable vblank irqs for already active pipes · d3eaf884
      Ville Syrjälä 提交于
      If a pipe is already active when we init/resume there might not be a
      full modeset afterwards so drm_vblank_on() may not get called. In such
      a case if someone is holding a vblank reference across a suspend/resume
      cycle drm_vblank_get() called after resuming won't re-enable the vblank
      interrupts.
      
      So in order to make sure vblank interrupts get re-enabled post-resume,
      call drm_vblank_on() in intel_sanitize_crtc() if the crtc is already
      active.
      
      v2: Also drm_vblank_off() if the pipe got disabled magically
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Testecase: igt/kms_flip/vblank-vs-suspend
      Tested-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      d3eaf884
    • 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
    • D
      drm/i915: Use new kms-native vblank functions · 87b6b101
      Daniel Vetter 提交于
      Only the low-level irq handling functions still use integer crtc
      indices with this. But fixing that will require a lot more sugery
      and some good ideas for backwards compat with old ums userspace.
      Both in drivers and in the drm core.
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      87b6b101
    • D
      drm/i915: Remove drm_vblank_pre/post_modeset calls · add1d008
      Daniel Vetter 提交于
      Originally these functions have been for user modesetting drivers to
      ensure vblank processing doesn't fall over completely around modeset
      changes. This has been carried over ever since then.
      
      Now that Ville cleaned our vblank handling with an explicit
      drm_vblank_off/on braket when disabling/enabling crtcs. So this seems
      to be unnecessary now. The most important side effect was that due to
      the delayed vblank disabling we have been pretty much guaranteed to
      receive a vblank interrupt soonish after a crtc was enabled.
      
      Note that our vblank handling across modeset is still fairly decent
      fubar - we don't actually handle vblank counter all to well.
      drm_update_vblank_count will make sure that the frame counter always
      rolls forward, but userspace isn't really all to ready to cope with
      the big jumps this causes.
      
      This isn't a big mostly because the hardware retains the frame
      counter. But with runtime pm and also across suspend/resume we fall
      over.
      
      Fixing this is a lot more involved and also needs som i-g-ts. So
      material for another patch series.
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      add1d008
    • V
      drm/i915: Move buffer pinning and ring selection to intel_crtc_page_flip() · 4fa62c89
      Ville Syrjälä 提交于
      All of the .queue_flip() callbacks duplicate the same code to pin the
      buffers and calculate the gtt_offset. Move that code to
      intel_crtc_page_flip(). In order to do that we must also move the ring
      selection logic there.
      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>
      4fa62c89
    • V
      drm/i915: Drop the excessive vblank waits from modeset codepaths · 6304cd91
      Ville Syrjälä 提交于
      Now that we've plugged the mmio vs. ring flip race, we shouldn't need
      these vblank waits in the modeset codepaths anymore. So get rid of
      them.
      
      v2: gen2 needs to wait for planes to turn off before disabling pipe
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: NRodrigo Vivi <rodrigo.vivi@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      6304cd91
    • V
      drm/i915: Wait for vblank in hsw_enable_ips() · cea165c3
      Ville Syrjälä 提交于
      Now that the vblank wait is gone from intel_enable_primary_plane(),
      hsw_enable_ips() needs to do the vblank wait itself.
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: NRodrigo Vivi <rodrigo.vivi@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      cea165c3
    • V
      drm/i915: Fix mmio vs. CS flip race on ILK+ · 75f7f3ec
      Ville Syrjälä 提交于
      Starting from ILK, mmio flips also cause a flip done interrupt to be
      signalled. This means if we first do a set_base and follow it
      immediately with the CS flip, we might mistake the flip done interrupt
      caused by the set_base as the flip done interrupt caused by the CS
      flip.
      
      The hardware has a flip counter which increments every time a mmio or
      CS flip is issued. It basically counts the number of DSPSURF register
      writes. This means we can sample the counter before we put the CS
      flip into the ring, and then when we get a flip done interrupt we can
      check whether the CS flip has actually performed the surface address
      update, or if the interrupt was caused by a previous but yet
      unfinished mmio flip.
      
      Even with the flip counter we still have a race condition of the CS flip
      base address update happens after the mmio flip done interrupt was
      raised but not yet processed by the driver. When the interrupt is
      eventually processed, the flip counter will already indicate that the
      CS flip has been executed, but it would not actually complete until the
      next start of vblank. We can use the DSPSURFLIVE register to check
      whether the hardware is actually scanning out of the buffer we expect,
      or if we managed hit this race window.
      
      This covers all the cases where the CS flip actually changes the base
      address. If the base address remains unchanged, we might still complete
      the CS flip before it has actually completed. But since the address
      didn't change anyway, the premature flip completion can't result in
      userspace overwriting data that's still being scanned out.
      
      CTG already has the flip counter and DSPSURFLIVE registers, and
      although the flip done interrupt is still limited to CS flips alone,
      the code now also checks the flip counter on CTG as well.
      
      v2: s/dspsurf/gtt_offset/ (Chris)
      
      Testcase: igt/kms_mmio_vs_cs_flip/setcrtc_vs_cs_flip
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73027Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: NRodrigo Vivi <rodrigo.vivi@gmail.com>
      [danvet: Add g4x_ prefix to flip_count_after_eq.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      75f7f3ec
    • V
      drm: Add drm_vblank_on() · f2752282
      Ville Syrjälä 提交于
      drm_vblank_off() will turn off vblank interrupts, but as long as the
      refcount is elevated drm_vblank_get() will not re-enable them. This
      is a problem is someone is holding a vblank reference while a modeset is
      happening, and the driver requires vblank interrupt to work during that
      time.
      
      Add drm_vblank_on() as a counterpart to drm_vblank_off() which will
      re-enabled vblank interrupts if the refcount is already elevated. This
      will allow drivers to choose the specific places in the modeset sequence
      at which vblank interrupts get disabled and enabled.
      
      Testcase: igt/kms_flip/*-vs-suspend
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      [danvet: Add Testcase tag for the igt I've written.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      f2752282