1. 28 Jan, 2015 3 commits
  2. 27 Jan, 2015 37 commits
    • Dave Airlie's avatar
      Merge tag 'topic/atomic-core-2015-01-27' of git://anongit.freedesktop.org/drm-intel into drm-next · 21773f16
      Dave Airlie authored
      * tag 'topic/atomic-core-2015-01-27' of git://anongit.freedesktop.org/drm-intel:
        drm/atomic: Fix potential use of state after free
        drm/atomic-helper: debug output for modesets
        drm/atomic-helpers: Saner encoder/crtc callbacks
        drm/atomic-helpers: Recover full cursor plane behaviour
        drm/atomic-helper: add connector->dpms() implementation
        drm/atomic: Add drm_crtc_state->active
        drm: Add standardized boolean props
        drm/plane-helper: Fix transitional helper kerneldocs
        drm/plane-helper: Skip prepare_fb/cleanup_fb when newfb==oldfb
      
      Conflicts:
      	include/drm/drm_crtc_helper.h
      21773f16
    • Dave Airlie's avatar
      Merge tag 'drm/tegra/for-3.20-rc1' of git://anongit.freedesktop.org/tegra/linux into drm-next · 2f5b4ef1
      Dave Airlie authored
      drm/tegra: Changes for v3.20-rc1
      
      The biggest part of these changes is the conversion to atomic mode-
      setting. A lot of cleanup and demidlayering was required before the
      conversion, with the result being a whole lot of changes.
      
      Besides the atomic mode-setting support, the host1x bus now has the
      proper infrastructure to support suspend/resume for child devices.
      
      Finally, a couple of smaller cleanup patches round things off.
      
      * tag 'drm/tegra/for-3.20-rc1' of git://anongit.freedesktop.org/tegra/linux: (54 commits)
        drm/tegra: Use correct relocation target offsets
        drm/tegra: Add minimal power management
        drm/tegra: dc: Unify enabling the display controller
        drm/tegra: Track tiling and format in plane state
        drm/tegra: Track active planes in CRTC state
        drm/tegra: Remove unused ->mode_fixup() callbacks
        drm/tegra: Atomic conversion, phase 3, step 3
        drm/tegra: Atomic conversion, phase 3, step 2
        drm/tegra: dc: Use atomic clock state in modeset
        drm/tegra: sor: Implement ->atomic_check()
        drm/tegra: hdmi: Implement ->atomic_check()
        drm/tegra: dsi: Implement ->atomic_check()
        drm/tegra: rgb: Implement ->atomic_check()
        drm/tegra: dc: Store clock setup in atomic state
        drm/tegra: Atomic conversion, phase 3, step 1
        drm/tegra: Atomic conversion, phase 2
        drm/tegra: Atomic conversion, phase 1
        drm/tegra: dc: Do not needlessly deassert reset
        drm/tegra: Output cleanup functions cannot fail
        drm/tegra: Remove remnants of the output midlayer
        ...
      2f5b4ef1
    • David Ung's avatar
      drm/tegra: Use correct relocation target offsets · 31f40f86
      David Ung authored
      When copying a relocation from userspace, copy the correct target
      offset.
      Signed-off-by: default avatarDavid Ung <davidu@nvidia.com>
      Fixes: 961e3bea ("drm/tegra: Make job submission 64-bit safe")
      Cc: stable@vger.kernel.org
      [treding@nvidia.com: provide a better commit message]
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      31f40f86
    • Thierry Reding's avatar
      drm/tegra: Add minimal power management · 359ae687
      Thierry Reding authored
      For now only disable the KMS hotplug polling helper logic upon suspend
      and re-enable it on resume.
      Reviewed-by: default avatarSean Paul <seanpaul@chromium.org>
      Reviewed-by: default avatarMark Zhang <markz@nvidia.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      359ae687
    • Thierry Reding's avatar
      drm/tegra: dc: Unify enabling the display controller · 666cb873
      Thierry Reding authored
      Previously output drivers would enable continuous display mode and power
      up the display controller at various points during the initialization.
      This is suboptimal because it accesses display controller registers in
      output drivers and duplicates a bit of code.
      
      Move this code into the display controller driver and enable the display
      controller as the final step of the ->mode_set_nofb() implementation.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      666cb873
    • Thierry Reding's avatar
      drm/tegra: Track tiling and format in plane state · 8f604f8c
      Thierry Reding authored
      Tracking these in the plane state allows them to be computed in the
      ->atomic_check() callback and reused when applying the configuration in
      ->atomic_update().
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      8f604f8c
    • Thierry Reding's avatar
      drm/tegra: Track active planes in CRTC state · 47802b09
      Thierry Reding authored
      Wrap struct drm_crtc_state in a driver-specific structure and add the
      planes field which keeps track of which planes are updated or disabled
      during a modeset. This allows atomic updates of the the display engine
      at ->atomic_flush() time.
      
      v2: open-code getting the state of the CRTC that the plane is being
          attached to (Daniel Vetter)
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      47802b09
    • Thierry Reding's avatar
      drm/tegra: Remove unused ->mode_fixup() callbacks · 3f0fb52e
      Thierry Reding authored
      All output drivers have now been converted to use the ->atomic_check()
      callback, so the ->mode_fixup() callbacks are no longer used.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      3f0fb52e
    • Thierry Reding's avatar
      drm/tegra: Atomic conversion, phase 3, step 3 · 1503ca47
      Thierry Reding authored
      Provide a custom ->atomic_commit() implementation which supports async
      commits. The generic atomic page-flip helper can use this to implement
      page-flipping.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      1503ca47
    • Thierry Reding's avatar
      drm/tegra: Atomic conversion, phase 3, step 2 · 74f48791
      Thierry Reding authored
      Replace drm_crtc_helper_set_config() by drm_atomic_helper_set_config().
      All drivers have now been converted to use ->atomic_check() to set the
      atomic state, therefore the atomic mode setting helpers can be used.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      74f48791
    • Thierry Reding's avatar
      drm/tegra: dc: Use atomic clock state in modeset · 76d59ed0
      Thierry Reding authored
      All clock state is now stored in the display controller's atomic state,
      so the output drivers no longer need to call back into the display
      controller driver to set up the clock. This is also required to make
      sure no hardware changes are made before validating a configuration.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      76d59ed0
    • Thierry Reding's avatar
      drm/tegra: sor: Implement ->atomic_check() · 82f1511c
      Thierry Reding authored
      The implementation of the ->atomic_check() callback precomputes all
      parameters to check if the given configuration can be applied. If so the
      precomputed values are stored in the atomic state object for the encoder
      and applied during modeset. In that way the modeset no longer needs to
      perform any checking but simply program values into registers.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      82f1511c
    • Thierry Reding's avatar
      drm/tegra: hdmi: Implement ->atomic_check() · a9825a6e
      Thierry Reding authored
      The implementation of the ->atomic_check() callback precomputes all
      parameters to check if the given configuration can be applied. If so the
      precomputed values are stored in the atomic state object for the encoder
      and applied during modeset. In that way the modeset no longer needs to
      perform any checking but simply program values into registers.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      a9825a6e
    • Thierry Reding's avatar
      drm/tegra: dsi: Implement ->atomic_check() · ebd14afe
      Thierry Reding authored
      The implementation of the ->atomic_check() callback precomputes all
      parameters to check if the given configuration can be applied. If so the
      precomputed values are stored in the atomic state object for the encoder
      and applied during modeset. In that way the modeset no longer needs to
      perform any checking but simply program values into registers.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      ebd14afe
    • Thierry Reding's avatar
      drm/tegra: rgb: Implement ->atomic_check() · 3cebae67
      Thierry Reding authored
      The implementation of the ->atomic_check() callback precomputes all
      parameters to check if the given configuration can be applied. If so the
      precomputed values are stored in the atomic state object for the encoder
      and applied during modeset. In that way the modeset no longer needs to
      perform any checking but simply program values into registers.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      3cebae67
    • Thierry Reding's avatar
      drm/tegra: dc: Store clock setup in atomic state · ca915b10
      Thierry Reding authored
      This allows the clock setup to be separated from the clock programming
      and better matches the expectations of the atomic modesetting where no
      code paths must fail during modeset.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      ca915b10
    • Thierry Reding's avatar
      drm/tegra: Atomic conversion, phase 3, step 1 · 07866963
      Thierry Reding authored
      Switch out the regular plane helpers for the atomic plane helpers. Also
      use the default atomic helpers to implement the ->atomic_check() and
      ->atomic_commit() callbacks. The driver now exclusively uses the atomic
      interfaces.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      07866963
    • Thierry Reding's avatar
      drm/tegra: Atomic conversion, phase 2 · 9d44189f
      Thierry Reding authored
      Hook up the default ->reset() and ->atomic_duplicate_state() helpers.
      This ensures that state objects are properly created and framebuffer
      reference counts correctly maintained.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      9d44189f
    • Thierry Reding's avatar
      drm/tegra: Atomic conversion, phase 1 · 4aa3df71
      Thierry Reding authored
      Implement initial atomic state handling. Hook up the CRTCs, planes' and
      connectors' ->atomic_destroy_state() callback to ensure that the atomic
      state objects don't leak.
      
      Furthermore the CRTC now implements the ->mode_set_nofb() callback that
      is used by new helpers to implement ->mode_set() and ->mode_set_base().
      These new helpers also make use of the new plane helper functions which
      the driver now provides.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      4aa3df71
    • Thierry Reding's avatar
      drm/tegra: dc: Do not needlessly deassert reset · 05f175f4
      Thierry Reding authored
      Commit 9c012700 ("drm/tegra: dc: Add powergate support") changed the
      driver's ->probe() implementation to deassert the module reset, and with
      there being nobody else to assert it until ->remove() there is no need
      to deassert again later on.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      05f175f4
    • Thierry Reding's avatar
      drm/tegra: Output cleanup functions cannot fail · 328ec69e
      Thierry Reding authored
      The tegra_output_exit() and tegra_output_remove() functions cannot fail,
      so make them return void.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      328ec69e
    • Thierry Reding's avatar
      drm/tegra: Remove remnants of the output midlayer · ea130b24
      Thierry Reding authored
      The tegra_output midlayer is now completely gone and output drivers use
      it purely as a helper library.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      ea130b24
    • Thierry Reding's avatar
      drm/tegra: debugfs cleanup cannot fail · 4009c224
      Thierry Reding authored
      The debugfs cleanup code never fails, so no error is returned. Therefore
      the functions can all return void instead.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      4009c224
    • Thierry Reding's avatar
      drm/tegra: sor: Demidlayer · 6fad8f66
      Thierry Reding authored
      Implement encoder and connector within the eDP driver itself using the
      Tegra output helpers rather than using the Tegra output as midlayer. By
      doing so one level of indirection is removed and output drivers become
      more flexible while keeping the majority of the advantages provided by
      the common output helpers.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      6fad8f66
    • Thierry Reding's avatar
      drm/tegra: dsi: Demidlayer · 5b901e78
      Thierry Reding authored
      Implement encoder and connector within the DSI driver itself using the
      Tegra output helpers rather than using the Tegra output as midlayer. By
      doing so one level of indirection is removed and output drivers become
      more flexible while keeping the majority of the advantages provided by
      the common output helpers.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      5b901e78
    • Thierry Reding's avatar
      drm/tegra: hdmi: Demidlayer · 59682719
      Thierry Reding authored
      Implement encoder and connector within the HDMI driver itself using the
      Tegra output helpers rather than using the Tegra output as midlayer. By
      doing so one level of indirection is removed and output drivers become
      more flexible while keeping the majority of the advantages provided by
      the common output helpers.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      59682719
    • Thierry Reding's avatar
      drm/tegra: rgb: Demidlayer · 3b0e5855
      Thierry Reding authored
      Implement encoder and connector within the RGB driver itself using the
      Tegra output helpers rather than using the Tegra output as midlayer. By
      doing so one level of indirection is removed and output drivers become
      more flexible while keeping the majority of the advantages provided by
      the common output helpers.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      3b0e5855
    • Thierry Reding's avatar
      drm/tegra: Add tegra_dc_setup_clock() helper · c5a107d3
      Thierry Reding authored
      This is a small helper that performs the basic steps required by all
      output drivers to prepare the display controller for use with a given
      encoder.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      c5a107d3
    • Thierry Reding's avatar
      drm/tegra: output: Make ->setup_clock() optional · d5bae6f3
      Thierry Reding authored
      In order to transition output drivers to using the struct tegra_output
      as a helper rather than midlayer, make this callback optional. Instead
      drivers should implement the equivalent as part of ->mode_fixup(). For
      the conversion to atomic modesetting a new callback ->atomic_check()
      should be implemented that updates the display controller's state with
      the corresponding parent clock, rate and shift clock divider.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      d5bae6f3
    • Thierry Reding's avatar
      drm/tegra: Convert output midlayer to helpers · 132085d8
      Thierry Reding authored
      The output layer was initially designed to help reduce the amount of
      code duplicated in output drivers. An unfortunate side-effect of that
      was that it turned into a midlayer and it became difficult to make the
      output drivers work without bending over backwards to fit into the
      midlayer.
      
      This commit starts to convert the midlayer into a helper library by
      exporting most of the common functions so that they can be used by the
      output drivers directly. Doing so will allow output drivers to reuse
      common code paths but more easily override them where necessary.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      132085d8
    • Thierry Reding's avatar
      drm/tegra: dc: No longer disable planes at CRTC disable · 50a246aa
      Thierry Reding authored
      The DRM core should take care of disabling all unneeded planes, so there
      is no need to do this explicitly.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      50a246aa
    • Thierry Reding's avatar
      drm/tegra: Move tegra_drm_mode_funcs to the core · f9914214
      Thierry Reding authored
      This structure will be extended using non-framebuffer related callbacks
      in subsequent patches, so it should move to a more central location.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      f9914214
    • Thierry Reding's avatar
      drm/tegra: dc: Wait for idle when disabled · 86df256f
      Thierry Reding authored
      When disabling the display controller, stop it and wait for it to become
      idle. Doing so ensures that no further accesses to the framebuffer occur
      and the buffers can be safely unmapped or freed.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      86df256f
    • Thierry Reding's avatar
      drm/tegra: Stop CRTC at CRTC disable time · 36904adf
      Thierry Reding authored
      Previously output drivers would all stop the display controller in their
      disable path. However with the transition to atomic modesetting the
      display controller needs to be kept running until all planes have been
      disabled so that software can properly determine (using VBLANK counts)
      when it is safe to remove the framebuffers associated with the planes.
      
      Moving this code into the display controller's disable path also gets
      rid of the duplication of this into all output drivers.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      36904adf
    • Thierry Reding's avatar
      drm/tegra: Use tegra_commit_dc() in output drivers · 62b9e063
      Thierry Reding authored
      All output drivers have open-coded variants of this function, so export
      it to remove some code duplication.
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      62b9e063
    • Thierry Reding's avatar
      drm/atomic: Add ->atomic_check() to encoder helpers · 4cd4df80
      Thierry Reding authored
      This callback can be used instead of the legacy ->mode_fixup() and is
      passed the CRTC and connector states. It can thus use these states to
      validate the modeset and cache values in the state to be used during
      the actual modeset.
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      4cd4df80
    • Thierry Reding's avatar
      drm/plane: Add optional ->atomic_disable() callback · 407b8bd9
      Thierry Reding authored
      In order to prevent drivers from having to perform the same checks over
      and over again, add an optional ->atomic_disable callback which the core
      calls under the right circumstances.
      
      v2: pass old state and detect edges to avoid calling ->atomic_disable on
      already disabled planes, remove redundant comment (Daniel Vetter)
      
      v3: rename helper to drm_atomic_plane_disabling() to clarify that it is
      checking for transitions, move helper to drm_atomic_helper.h, clarify
      check for !old_state and its relation to transitional helpers
      
      Here's an extract from some discussion rationalizing the behaviour (for
      a full version, see the reference below):
      
          > > Hm, thinking about this some more this will result in a slight difference
          > > in behaviour, at least when drivers just use the helper ->reset functions
          > > but don't disable everything:
          > > - With transitional helpers we assume we know nothing and call
          > >   ->atomic_disable.
          > > - With atomic old_state->crtc == NULL in the same situation right after
          > >   boot-up, but we asssume the plane is really off and _dont_ call
          > >   ->atomic_disable.
          > >
          > > Should we instead check for (old_state && old_state->crtc) and state that
          > > drivers need to make sure they don't have stuff hanging around?
          >
          > I don't think we can check for old_state because otherwise this will
          > always return false, whereas we really want it to force-disable planes
          > that could be on (lacking any more accurate information). For
          > transitional helpers anyway.
          >
          > For the atomic helpers, old_state will never be NULL, but I'd assume
          > that the driver would reconstruct the current state in ->reset().
      
          By the way, the reason for why old_state can be NULL with transitional
          helpers is the ordering of the steps in the atomic transition. Currently
          the Tegra patches do this (based on your blog post and the Exynos proto-
          type):
      
              1) atomic conversion, phase 1:
                 - implement ->atomic_{check,update,disable}()
                 - use drm_plane_helper_{update,disable}()
      
              2) atomic conversion, phase 2:
                 - call drm_mode_config_reset() from ->load()
                 - implement ->reset()
      
          That's only a partial list of what's done in these steps, but that's the
          only relevant pieces for why old_state is NULL.
      
          What happens is that without ->reset() implemented there won't be any
          initial state, hence plane->state (the old_state here) will be NULL the
          first time atomic state is applied.
      
          We could of course reorder the sequence such that drivers are required
          to hook up ->reset() before they can (or at the same as they) hook up
          the transitional helpers. We could add an appropriate WARN_ON to this
          helper to make that more obvious.
      
          However, that will not solve the problem because it only gets rid of the
          special case. We still don't know whether old_state->crtc == NULL is the
          current state or just the initial default.
      
          So no matter which way we do this, I don't see a way to get away without
          requiring specific semantics from drivers. They would be that:
      
              - drivers recreate the correct state in ->reset() so that
                old_state->crtc != NULL if the plane is really enabled
      
          or
      
              - drivers have to ensure that the real state in fact mirrors the
                initial default as encoded in the state (plane disabled)
      
      References: http://lists.freedesktop.org/archives/dri-devel/2015-January/075578.htmlReviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      407b8bd9