1. 19 10月, 2018 1 次提交
    • L
      drm: Get ref on CRTC commit object when waiting for flip_done · 4364bcb2
      Leo Li 提交于
      This fixes a general protection fault, caused by accessing the contents
      of a flip_done completion object that has already been freed. It occurs
      due to the preemption of a non-blocking commit worker thread W by
      another commit thread X. X continues to clear its atomic state at the
      end, destroying the CRTC commit object that W still needs. Switching
      back to W and accessing the commit objects then leads to bad results.
      
      Worker W becomes preemptable when waiting for flip_done to complete. At
      this point, a frequently occurring commit thread X can take over. Here's
      an example where W is a worker thread that flips on both CRTCs, and X
      does a legacy cursor update on both CRTCs:
      
              ...
           1. W does flip work
           2. W runs commit_hw_done()
           3. W waits for flip_done on CRTC 1
           4. > flip_done for CRTC 1 completes
           5. W finishes waiting for CRTC 1
           6. W waits for flip_done on CRTC 2
      
           7. > Preempted by X
           8. > flip_done for CRTC 2 completes
           9. X atomic_check: hw_done and flip_done are complete on all CRTCs
          10. X updates cursor on both CRTCs
          11. X destroys atomic state
          12. X done
      
          13. > Switch back to W
          14. W waits for flip_done on CRTC 2
          15. W raises general protection fault
      
      The error looks like so:
      
          general protection fault: 0000 [#1] PREEMPT SMP PTI
          **snip**
          Call Trace:
           lock_acquire+0xa2/0x1b0
           _raw_spin_lock_irq+0x39/0x70
           wait_for_completion_timeout+0x31/0x130
           drm_atomic_helper_wait_for_flip_done+0x64/0x90 [drm_kms_helper]
           amdgpu_dm_atomic_commit_tail+0xcae/0xdd0 [amdgpu]
           commit_tail+0x3d/0x70 [drm_kms_helper]
           process_one_work+0x212/0x650
           worker_thread+0x49/0x420
           kthread+0xfb/0x130
           ret_from_fork+0x3a/0x50
          Modules linked in: x86_pkg_temp_thermal amdgpu(O) chash(O)
          gpu_sched(O) drm_kms_helper(O) syscopyarea sysfillrect sysimgblt
          fb_sys_fops ttm(O) drm(O)
      
      Note that i915 has this issue masked, since hw_done is signaled after
      waiting for flip_done. Doing so will block the cursor update from
      happening until hw_done is signaled, preventing the cursor commit from
      destroying the state.
      
      v2: The reference on the commit object needs to be obtained before
          hw_done() is signaled, since that's the point where another commit
          is allowed to modify the state. Assuming that the
          new_crtc_state->commit object still exists within flip_done() is
          incorrect.
      
          Fix by getting a reference in setup_commit(), and releasing it
          during default_clear().
      Signed-off-by: NLeo Li <sunpeng.li@amd.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NHarry Wentland <harry.wentland@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/1539611200-6184-1-git-send-email-sunpeng.li@amd.com
      4364bcb2
  2. 26 7月, 2018 2 次提交
  3. 14 7月, 2018 1 次提交
  4. 07 7月, 2018 4 次提交
  5. 06 7月, 2018 1 次提交
  6. 02 7月, 2018 2 次提交
  7. 20 6月, 2018 1 次提交
    • B
      drm: Add writeback connector type · 935774cd
      Brian Starkey 提交于
      Writeback connectors represent writeback engines which can write the
      CRTC output to a memory framebuffer. Add a writeback connector type and
      related support functions.
      
      Drivers should initialize a writeback connector with
      drm_writeback_connector_init() which takes care of setting up all the
      writeback-specific details on top of the normal functionality of
      drm_connector_init().
      
      Writeback connectors have a WRITEBACK_FB_ID property, used to set the
      output framebuffer, and a WRITEBACK_PIXEL_FORMATS blob used to expose the
      supported writeback formats to userspace.
      
      When a framebuffer is attached to a writeback connector with the
      WRITEBACK_FB_ID property, it is used only once (for the commit in which
      it was included), and userspace can never read back the value of
      WRITEBACK_FB_ID. WRITEBACK_FB_ID can only be set if the connector is
      attached to a CRTC.
      
      Changes since v1:
       - Added drm_writeback.c + documentation
       - Added helper to initialize writeback connector in one go
       - Added core checks
       - Squashed into a single commit
       - Dropped the client cap
       - Writeback framebuffers are no longer persistent
      
      Changes since v2:
       Daniel Vetter:
       - Subclass drm_connector to drm_writeback_connector
       - Relax check to allow CRTC to be set without an FB
       - Add some writeback_ prefixes
       - Drop PIXEL_FORMATS_SIZE property, as it was unnecessary
       Gustavo Padovan:
       - Add drm_writeback_job to handle writeback signalling centrally
      
      Changes since v3:
       - Rebased
       - Rename PIXEL_FORMATS -> WRITEBACK_PIXEL_FORMATS
      
      Chances since v4:
       - Embed a drm_encoder inside the drm_writeback_connector to
         reduce the amount of boilerplate code required from the drivers
         that are using it.
      
      Changes since v5:
       - Added Rob Clark's atomic_commit() vfunc to connector helper
         funcs, so that writeback jobs are committed from atomic helpers
       - Updated create_writeback_properties() signature to return an
         error code rather than a boolean false for failure.
       - Free writeback job with the connector state rather than when
         doing the cleanup_work()
      
      Changes since v7:
       - fix extraneous use of out_fence that is only introduced in a
         subsequent patch.
      
      Changes since v8:
       - whitespace changes pull from subsequent patch
      
      Changes since v9:
       - Revert the v6 changes that free the writeback job in the connector
         state cleanup and return to doing it in the cleanup_work() function
      Signed-off-by: NBrian Starkey <brian.starkey@arm.com>
      [rebased and fixed conflicts]
      Signed-off-by: NMihail Atanassov <mihail.atanassov@arm.com>
      [rebased and added atomic_commit() vfunc for writeback jobs]
      Signed-off-by: NRob Clark <robdclark@gmail.com>
      Signed-off-by: NLiviu Dudau <liviu.dudau@arm.com>
      Reviewed-by: NEric Anholt <eric@anholt.net>
      Link: https://patchwork.freedesktop.org/patch/229037/
      935774cd
  8. 12 6月, 2018 1 次提交
  9. 04 5月, 2018 1 次提交
  10. 18 4月, 2018 1 次提交
  11. 17 4月, 2018 1 次提交
  12. 30 3月, 2018 3 次提交
  13. 28 3月, 2018 1 次提交
  14. 16 3月, 2018 1 次提交
  15. 06 3月, 2018 1 次提交
    • V
      drm: Don't pass clip to drm_atomic_helper_check_plane_state() · 81af63a4
      Ville Syrjälä 提交于
      Move the plane clip rectangle handling into
      drm_atomic_helper_check_plane_state(). Drivers no longer
      have to worry about such mundane details.
      
      v2: Convert armada, rcar, and sun4i as well
      v3: Resolve simple_kms_helper conflict
      
      Cc: Liviu Dudau <liviu.dudau@arm.com>
      Cc: Brian Starkey <brian.starkey@arm.com>
      Cc: Mali DP Maintainers <malidp@foss.arm.com>
      Cc: Daniel Vetter <daniel.vetter@intel.com>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Sean Paul <seanpaul@chromium.org>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: CK Hu <ck.hu@mediatek.com>
      Cc: Neil Armstrong <narmstrong@baylibre.com>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Sandy Huang <hjc@rock-chips.com>
      Cc: "Heiko Stübner" <heiko@sntech.de>
      Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: VMware Graphics <linux-graphics-maintainer@vmware.com>
      Cc: Sinclair Yeh <syeh@vmware.com>
      Cc: Thomas Hellstrom <thellstrom@vmware.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Archit Taneja <architt@codeaurora.org>
      Cc: linux-amlogic@lists.infradead.org
      Cc: linux-arm-msm@vger.kernel.org
      Cc: freedreno@lists.freedesktop.org
      Cc: nouveau@lists.freedesktop.org
      Cc: linux-renesas-soc@vger.kernel.org
      Cc: linux-tegra@vger.kernel.org
      Cc: Russell King <rmk+kernel@armlinux.org.uk>
      Suggested-by: NDaniel Vetter <daniel@ffwll.ch>
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: NThierry Reding <treding@nvidia.com>
      Reviewed-by: Archit Taneja <architt@codeaurora.org> #msm
      Link: https://patchwork.freedesktop.org/patch/msgid/20180123170857.13818-5-ville.syrjala@linux.intel.com
      Acked-by: Liviu Dudau <liviu.dudau@arm.com> #hdlcd,malidp
      Acked-by: Philipp Zabel <p.zabel@pengutronix.de> #imx,mtk
      Reviewed-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Reviewed-by: Sinclair Yeh <syeh@vmware.com> #vmwgfx
      Acked-by: Neil Armstrong <narmstrong@baylibre.com> #meson
      Acked-by: Shawn Guo <shawnguo@kernel.org> #zte
      81af63a4
  16. 01 2月, 2018 1 次提交
  17. 30 1月, 2018 1 次提交
  18. 10 1月, 2018 2 次提交
  19. 29 11月, 2017 1 次提交
  20. 21 11月, 2017 1 次提交
  21. 15 11月, 2017 1 次提交
  22. 09 11月, 2017 1 次提交
  23. 18 10月, 2017 1 次提交
  24. 17 10月, 2017 2 次提交
  25. 13 10月, 2017 2 次提交
  26. 12 10月, 2017 1 次提交
  27. 09 10月, 2017 2 次提交
  28. 08 9月, 2017 2 次提交
    • M
      drm/atomic: Make async plane update checks work as intended, v2. · 669c9215
      Maarten Lankhorst 提交于
      By always keeping track of the last commit in plane_state, we know
      whether there is an active update on the plane or not. With that
      information we can reject the fast update, and force the slowpath
      to be used as was originally intended.
      
      We cannot use plane_state->crtc->state here, because this only mentions
      the most recent commit for the crtc, but not the planes that were part
      of it. We specifically care about what the last commit involving this
      plane is, which can only be tracked with a pointer in the plane state.
      
      Changes since v1:
      - Clean up the whole function here, instead of partially earlier.
      - Add mention in the commit message why we need commit in plane_state.
      - Swap plane->state in intel_legacy_cursor_update, instead of
        reassigning all variables. With this commit We know that the cursor
        is not part of any active commits so this hack can be removed.
      
      Cc: Gustavo Padovan <gustavo.padovan@collabora.com>
      Signed-off-by: NMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Reviewed-by: NGustavo Padovan <gustavo.padovan@collabora.com>
      Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> #v1
      Link: https://patchwork.freedesktop.org/patch/msgid/20170904104838.23822-7-maarten.lankhorst@linux.intel.com
      [mlankhorst: Amend commit for merge conflicts with drm-intel]
      669c9215
    • M
      drm/atomic: Fix freeing connector/plane state too early by tracking commits, v3. · 21a01abb
      Maarten Lankhorst 提交于
      Currently we neatly track the crtc state, but forget to look at
      plane/connector state.
      
      When doing a nonblocking modeset, immediately followed by a setprop
      before the modeset completes, the setprop will see the modesets new
      state as the old state and free it.
      
      This has to be solved by waiting for hw_done on the connector, even
      if it's not assigned to a crtc. When a connector is unbound we take
      the last crtc commit, and when it stays unbound we create a new
      fake crtc commit for that gets signaled on hw_done for all the
      planes/connectors.
      
      We wait for it the same way as we do for crtc's, which will make
      sure we never run into a use-after-free situation.
      
      Changes since v1:
      - Only create a single disable commit. (danvet)
      - Fix leak in intel_legacy_cursor_update.
      Changes since v2:
      - Make reference counting in drm_atomic_helper_setup_commit
        more obvious. (pinchartl)
      - Call cleanup_done for fake commit. (danvet)
      - Add comments to drm_atomic_helper_setup_commit. (danvet, pinchartl)
      - Add comment to drm_atomic_helper_swap_state. (pinchartl)
      Signed-off-by: NMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Testcase: kms_atomic_transition.plane-use-after-nonblocking-unbind*
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20170904104838.23822-6-maarten.lankhorst@linux.intel.comReviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      21a01abb