1. 11 12月, 2019 1 次提交
  2. 09 12月, 2019 2 次提交
  3. 20 9月, 2019 1 次提交
  4. 19 9月, 2019 2 次提交
    • S
      drm: Measure Self Refresh Entry/Exit times to avoid thrashing · d4da4e33
      Sean Paul 提交于
      Currently the self refresh idle timer is a const set by the crtc. This
      is fine if the self refresh entry/exit times are well-known for all
      panels used on that crtc. However panels and workloads can vary quite a
      bit, and a timeout which works well for one doesn't work well for
      another.
      
      In the extreme, if the timeout is too short we could get in a situation
      where the self refresh exits are taking so long we queue up a self refresh
      entry before the exit commit is even finished.
      
      This patch changes the idle timeout to a moving average of the entry
      times + a moving average of exit times + the crtc constant.
      
      This patch was tested on rockchip, with a kevin CrOS panel the idle
      delay averages out to about ~235ms (35 entry + 100 exit + 100 const). On
      the same board, the bob panel idle delay lands around ~340ms (90 entry
      + 150 exit + 100 const).
      
      WRT the dedicated mutex in self_refresh_data, it would be nice if we
      could rely on drm_crtc.mutex to protect the average times, but there are
      a few reasons why a separate lock is a better choice:
      - We can't rely on drm_crtc.mutex being held if we're doing a nonblocking
        commit
      - We can't grab drm_crtc.mutex since drm_modeset_lock() doesn't tell us
        whether the lock was already held in the acquire context (it eats
        -EALREADY), so we can't tell if we should drop it or not
      - We don't need such a heavy-handed lock for what we're trying to do,
        commit ordering doesn't matter, so a point-of-use lock will be less
        contentious
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NSean Paul <seanpaul@chromium.org>
      Link to v1: https://patchwork.freedesktop.org/patch/msgid/20190917200443.64481-2-sean@poorly.run
      Link: https://patchwork.freedesktop.org/patch/msgid/20190918200734.149876-2-sean@poorly.run
      
      Changes in v2:
      - Migrate locking explanation from comment to commit msg (Daniel)
      - Turf constant entry delay and multiply the avg times by 2 (Daniel)
      d4da4e33
    • D
      drm/atomic: Rename crtc_state->pageflip_flags to async_flip · 4d85f45c
      Daniel Vetter 提交于
      It's the only flag anyone actually cares about. Plus if we're unlucky,
      the atomic ioctl might need a different flag for async flips. So
      better to abstract this away from the uapi a bit.
      Reviewed-by: NMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Reviewed-by: NNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Michel Dänzer <michel@daenzer.net>
      Cc: Alex Deucher <alexdeucher@gmail.com>
      Cc: Adam Jackson <ajax@redhat.com>
      Cc: Sean Paul <sean@poorly.run>
      Cc: David Airlie <airlied@linux.ie>
      Signed-off-by: NDaniel Vetter <daniel.vetter@intel.com>
      Cc: Maxime Ripard <maxime.ripard@bootlin.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
      Cc: Leo Li <sunpeng.li@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: David Francis <David.Francis@amd.com>
      Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
      Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: "Christian König" <christian.koenig@amd.com>
      Cc: Ilia Mirkin <imirkin@alum.mit.edu>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190903190642.32588-3-daniel.vetter@ffwll.ch
      4d85f45c
  5. 17 9月, 2019 1 次提交
  6. 29 8月, 2019 1 次提交
  7. 14 6月, 2019 4 次提交
  8. 08 6月, 2019 1 次提交
  9. 04 6月, 2019 1 次提交
    • H
      drm: don't block fb changes for async plane updates · 89a4aac0
      Helen Koike 提交于
      In the case of a normal sync update, the preparation of framebuffers (be
      it calling drm_atomic_helper_prepare_planes() or doing setups with
      drm_framebuffer_get()) are performed in the new_state and the respective
      cleanups are performed in the old_state.
      
      In the case of async updates, the preparation is also done in the
      new_state but the cleanups are done in the new_state (because updates
      are performed in place, i.e. in the current state).
      
      The current code blocks async udpates when the fb is changed, turning
      async updates into sync updates, slowing down cursor updates and
      introducing regressions in igt tests with errors of type:
      
      "CRITICAL: completed 97 cursor updated in a period of 30 flips, we
      expect to complete approximately 15360 updates, with the threshold set
      at 7680"
      
      Fb changes in async updates were prevented to avoid the following scenario:
      
      - Async update, oldfb = NULL, newfb = fb1, prepare fb1, cleanup fb1
      - Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb2
      - Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2 (wrong)
      Where we have a single call to prepare fb2 but double cleanup call to fb2.
      
      To solve the above problems, instead of blocking async fb changes, we
      place the old framebuffer in the new_state object, so when the code
      performs cleanups in the new_state it will cleanup the old_fb and we
      will have the following scenario instead:
      
      - Async update, oldfb = NULL, newfb = fb1, prepare fb1, no cleanup
      - Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb1
      - Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2
      
      Where calls to prepare/cleanup are balanced.
      
      Cc: <stable@vger.kernel.org> # v4.14+
      Fixes: 25dc194b ("drm: Block fb changes for async plane updates")
      Suggested-by: NBoris Brezillon <boris.brezillon@collabora.com>
      Signed-off-by: NHelen Koike <helen.koike@collabora.com>
      Reviewed-by: NBoris Brezillon <boris.brezillon@collabora.com>
      Reviewed-by: NNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
      Signed-off-by: NBoris Brezillon <boris.brezillon@collabora.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190603165610.24614-6-helen.koike@collabora.com
      89a4aac0
  10. 28 5月, 2019 1 次提交
  11. 01 5月, 2019 1 次提交
  12. 29 3月, 2019 1 次提交
  13. 18 3月, 2019 2 次提交
    • L
      drm: writeback: Add job prepare and cleanup operations · 9d2230dc
      Laurent Pinchart 提交于
      As writeback jobs contain a framebuffer, drivers may need to prepare and
      cleanup them the same way they can prepare and cleanup framebuffers for
      planes. Add two new optional connector helper operations,
      .prepare_writeback_job() and .cleanup_writeback_job() to support this.
      
      The job prepare operation is called from
      drm_atomic_helper_prepare_planes() to avoid a new atomic commit helper
      that would need to be called by all drivers not using
      drm_atomic_helper_commit(). The job cleanup operation is called from the
      existing drm_writeback_cleanup_job() function, invoked both when
      destroying the job as part of a aborted commit, or when the job
      completes.
      
      The drm_writeback_job structure is extended with a priv field to let
      drivers store per-job data, such as mappings related to the writeback
      framebuffer.
      
      For internal plumbing reasons the drm_writeback_job structure needs to
      store a back-pointer to the drm_writeback_connector. To avoid pushing
      too much writeback-specific knowledge to drm_atomic_uapi.c, create a
      drm_writeback_set_fb() function, move the writeback job setup code
      there, and set the connector backpointer. The prepare_signaling()
      function doesn't need to allocate writeback jobs and can ignore
      connectors without a job, as it is called after the writeback jobs are
      allocated to store framebuffers, and a writeback fence with a
      framebuffer is an invalid configuration that gets rejected by the commit
      check.
      Signed-off-by: NLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
      Reviewed-by: NLiviu Dudau <liviu.dudau@arm.com>
      9d2230dc
    • L
      drm/atomic: Constify mode argument to mode_valid_path() · 8518f05a
      Laurent Pinchart 提交于
      The mode_valid_path() function validates the mode it receives without
      ever modifying it. Constify the mode pointer argument to make that
      explicit.
      Signed-off-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NTomi Valkeinen <tomi.valkeinen@ti.com>
      8518f05a
  14. 13 3月, 2019 1 次提交
  15. 28 2月, 2019 1 次提交
    • N
      drm: Block fb changes for async plane updates · 22163229
      Nicholas Kazlauskas 提交于
      The prepare_fb call always happens on new_plane_state.
      
      The drm_atomic_helper_cleanup_planes checks to see if
      plane state pointer has changed when deciding to call cleanup_fb on
      either the new_plane_state or the old_plane_state.
      
      For a non-async atomic commit the state pointer is swapped, so this
      helper calls prepare_fb on the new_plane_state and cleanup_fb on the
      old_plane_state. This makes sense, since we want to prepare the
      framebuffer we are going to use and cleanup the the framebuffer we are
      no longer using.
      
      For the async atomic update helpers this differs. The async atomic
      update helpers perform in-place updates on the existing state. They call
      drm_atomic_helper_cleanup_planes but the state pointer is not swapped.
      This means that prepare_fb is called on the new_plane_state and
      cleanup_fb is called on the new_plane_state (not the old).
      
      In the case where old_plane_state->fb == new_plane_state->fb then
      there should be no behavioral difference between an async update
      and a non-async commit. But there are issues that arise when
      old_plane_state->fb != new_plane_state->fb.
      
      The first is that the new_plane_state->fb is immediately cleaned up
      after it has been prepared, so we're using a fb that we shouldn't
      be.
      
      The second occurs during a sequence of async atomic updates and
      non-async regular atomic commits. Suppose there are two framebuffers
      being interleaved in a double-buffering scenario, fb1 and fb2:
      
      - Async update, oldfb = NULL, newfb = fb1, prepare fb1, cleanup fb1
      - Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb2
      - Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2
      
      We call cleanup_fb on fb2 twice in this example scenario, and any
      further use will result in use-after-free.
      
      The simple fix to this problem is to block framebuffer changes
      in the drm_atomic_helper_async_check function for now.
      
      v2: Move check by itself, add a FIXME (Daniel)
      
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
      Cc: <stable@vger.kernel.org> # v4.14+
      Fixes: fef9df8b ("drm/atomic: initial support for asynchronous plane update")
      Signed-off-by: NNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
      Acked-by: NAndrey Grodzovsky <andrey.grodzovsky@amd.com>
      Acked-by: NHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: NDaniel Vetter <daniel@ffwll.ch>
      Signed-off-by: NHarry Wentland <harry.wentland@amd.com>
      Link: https://patchwork.freedesktop.org/patch/275364/Signed-off-by: NDave Airlie <airlied@redhat.com>
      22163229
  16. 14 2月, 2019 1 次提交
    • N
      drm: Block fb changes for async plane updates · 25dc194b
      Nicholas Kazlauskas 提交于
      The prepare_fb call always happens on new_plane_state.
      
      The drm_atomic_helper_cleanup_planes checks to see if
      plane state pointer has changed when deciding to call cleanup_fb on
      either the new_plane_state or the old_plane_state.
      
      For a non-async atomic commit the state pointer is swapped, so this
      helper calls prepare_fb on the new_plane_state and cleanup_fb on the
      old_plane_state. This makes sense, since we want to prepare the
      framebuffer we are going to use and cleanup the the framebuffer we are
      no longer using.
      
      For the async atomic update helpers this differs. The async atomic
      update helpers perform in-place updates on the existing state. They call
      drm_atomic_helper_cleanup_planes but the state pointer is not swapped.
      This means that prepare_fb is called on the new_plane_state and
      cleanup_fb is called on the new_plane_state (not the old).
      
      In the case where old_plane_state->fb == new_plane_state->fb then
      there should be no behavioral difference between an async update
      and a non-async commit. But there are issues that arise when
      old_plane_state->fb != new_plane_state->fb.
      
      The first is that the new_plane_state->fb is immediately cleaned up
      after it has been prepared, so we're using a fb that we shouldn't
      be.
      
      The second occurs during a sequence of async atomic updates and
      non-async regular atomic commits. Suppose there are two framebuffers
      being interleaved in a double-buffering scenario, fb1 and fb2:
      
      - Async update, oldfb = NULL, newfb = fb1, prepare fb1, cleanup fb1
      - Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb2
      - Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2
      
      We call cleanup_fb on fb2 twice in this example scenario, and any
      further use will result in use-after-free.
      
      The simple fix to this problem is to block framebuffer changes
      in the drm_atomic_helper_async_check function for now.
      
      v2: Move check by itself, add a FIXME (Daniel)
      
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
      Cc: <stable@vger.kernel.org> # v4.14+
      Fixes: fef9df8b ("drm/atomic: initial support for asynchronous plane update")
      Signed-off-by: NNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
      Acked-by: NAndrey Grodzovsky <andrey.grodzovsky@amd.com>
      Acked-by: NHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: NDaniel Vetter <daniel@ffwll.ch>
      Signed-off-by: NHarry Wentland <harry.wentland@amd.com>
      Link: https://patchwork.freedesktop.org/patch/275364/
      25dc194b
  17. 13 2月, 2019 1 次提交
  18. 06 2月, 2019 1 次提交
    • L
      drm/atomic: Add drm_atomic_state->duplicated · 022debad
      Lyude Paul 提交于
      Since
      
      commit 39b50c60 ("drm/atomic_helper: Stop modesets on unregistered
      connectors harder")
      
      We've been failing atomic checks if they try to enable new displays on
      unregistered connectors. This is fine except for the one situation that
      breaks atomic assumptions: suspend/resume. If a connector is
      unregistered before we attempt to restore the atomic state, something we
      end up failing the atomic check that happens when trying to restore the
      state during resume.
      
      Normally this would be OK: we try our best to make sure that the atomic
      state pre-suspend can be restored post-suspend, but failures at that
      point usually don't cause problems. That is of course, until we
      introduced the new atomic MST VCPI helpers:
      
      [drm:drm_atomic_helper_check_modeset [drm_kms_helper]] [CRTC:65:pipe B] active changed
      [drm:drm_atomic_helper_check_modeset [drm_kms_helper]] Updating routing for [CONNECTOR:123:DP-5]
      [drm:drm_atomic_helper_check_modeset [drm_kms_helper]] Disabling [CONNECTOR:123:DP-5]
      [drm:drm_atomic_get_private_obj_state [drm]] Added new private object 0000000025844636 state 000000009fd2899a to 000000003a13d7b8
      WARNING: CPU: 6 PID: 1070 at drivers/gpu/drm/drm_dp_mst_topology.c:3153 drm_dp_atomic_release_vcpi_slots+0xb9/0x200 [drm_kms_helper]
      Modules linked in: fuse vfat fat snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic joydev iTCO_wdt i915(O) wmi_bmof intel_rapl btusb btrtl x86_pkg_temp_thermal btbcm btintel coretemp i2c_algo_bit drm_kms_helper(O) crc32_pclmul snd_hda_intel syscopyarea sysfillrect snd_hda_codec sysimgblt snd_hda_core bluetooth fb_sys_fops snd_pcm pcspkr drm(O) psmouse snd_timer mei_me ecdh_generic i2c_i801 mei i2c_core ucsi_acpi typec_ucsi typec wmi thinkpad_acpi ledtrig_audio snd soundcore tpm_tis rfkill tpm_tis_core video tpm acpi_pad pcc_cpufreq uas usb_storage crc32c_intel nvme serio_raw xhci_pci nvme_core xhci_hcd
      CPU: 6 PID: 1070 Comm: gnome-shell Tainted: G        W  O      5.0.0-rc2Lyude-Test+ #1
      Hardware name: LENOVO 20L8S2N800/20L8S2N800, BIOS N22ET35W (1.12 ) 04/09/2018
      RIP: 0010:drm_dp_atomic_release_vcpi_slots+0xb9/0x200 [drm_kms_helper]
      Code: 00 4c 39 6d f0 74 49 48 8d 7b 10 48 89 f9 48 c1 e9 03 42 80 3c 21 00 0f 85 d2 00 00 00 48 8b 6b 10 48 8d 5d f0 49 39 ee 75 c5 <0f> 0b 48 c7 c7 c0 78 b3 a0 48 89 c2 4c 89 ee e8 03 6c aa ff b8 ea
      RSP: 0018:ffff88841235f268 EFLAGS: 00010246
      RAX: ffff88841bf12ab0 RBX: ffff88841bf12aa8 RCX: 1ffff110837e2557
      RDX: dffffc0000000000 RSI: 0000000000000000 RDI: ffffed108246bde0
      RBP: ffff88841bf12ab8 R08: ffffed1083db3c93 R09: ffffed1083db3c92
      R10: ffffed1083db3c92 R11: ffff88841ed9e497 R12: ffff888419555d80
      R13: ffff8883bc499100 R14: ffff88841bf12ab8 R15: 0000000000000000
      FS:  00007f16fbd4cd00(0000) GS:ffff88841ed80000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f1687c9f000 CR3: 00000003ba3cc003 CR4: 00000000003606e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       drm_atomic_helper_check_modeset+0xf21/0x2f50 [drm_kms_helper]
       ? drm_atomic_helper_commit_modeset_enables+0xa90/0xa90 [drm_kms_helper]
       ? __printk_safe_exit+0x10/0x10
       ? save_stack+0x8c/0xb0
       ? vprintk_func+0x96/0x1bf
       ? __printk_safe_exit+0x10/0x10
       intel_atomic_check+0x234/0x4750 [i915]
       ? printk+0x9f/0xc5
       ? kmsg_dump_rewind_nolock+0xd9/0xd9
       ? _raw_spin_lock_irqsave+0xa4/0x140
       ? drm_atomic_check_only+0xb1/0x28b0 [drm]
       ? drm_dbg+0x186/0x1b0 [drm]
       ? drm_dev_dbg+0x200/0x200 [drm]
       ? intel_link_compute_m_n+0xb0/0xb0 [i915]
       ? drm_mode_put_tile_group+0x20/0x20 [drm]
       ? skl_plane_format_mod_supported+0x17f/0x1b0 [i915]
       ? drm_plane_check_pixel_format+0x14a/0x310 [drm]
       drm_atomic_check_only+0x13c4/0x28b0 [drm]
       ? drm_state_info+0x220/0x220 [drm]
       ? drm_atomic_helper_disable_plane+0x1d0/0x1d0 [drm_kms_helper]
       ? pick_single_encoder_for_connector+0xe0/0xe0 [drm_kms_helper]
       ? kasan_unpoison_shadow+0x35/0x40
       drm_atomic_commit+0x3b/0x100 [drm]
       drm_atomic_helper_set_config+0xd5/0x100 [drm_kms_helper]
       drm_mode_setcrtc+0x636/0x1660 [drm]
       ? vprintk_func+0x96/0x1bf
       ? drm_dev_dbg+0x200/0x200 [drm]
       ? drm_mode_getcrtc+0x790/0x790 [drm]
       ? printk+0x9f/0xc5
       ? mutex_unlock+0x1d/0x40
       ? drm_mode_addfb2+0x2e9/0x3a0 [drm]
       ? rcu_sync_dtor+0x2e0/0x2e0
       ? drm_dbg+0x186/0x1b0 [drm]
       ? set_page_dirty+0x271/0x4d0
       drm_ioctl_kernel+0x203/0x290 [drm]
       ? drm_mode_getcrtc+0x790/0x790 [drm]
       ? drm_setversion+0x7f0/0x7f0 [drm]
       ? __switch_to_asm+0x34/0x70
       ? __switch_to_asm+0x34/0x70
       drm_ioctl+0x445/0x950 [drm]
       ? drm_mode_getcrtc+0x790/0x790 [drm]
       ? drm_getunique+0x220/0x220 [drm]
       ? expand_files.part.10+0x920/0x920
       do_vfs_ioctl+0x1a1/0x13d0
       ? ioctl_preallocate+0x2b0/0x2b0
       ? __fget_light+0x2d6/0x390
       ? schedule+0xd7/0x2e0
       ? fget_raw+0x10/0x10
       ? apic_timer_interrupt+0xa/0x20
       ? apic_timer_interrupt+0xa/0x20
       ? rcu_cleanup_dead_rnp+0x2c0/0x2c0
       ksys_ioctl+0x60/0x90
       __x64_sys_ioctl+0x6f/0xb0
       do_syscall_64+0x136/0x440
       ? syscall_return_slowpath+0x2d0/0x2d0
       ? do_page_fault+0x89/0x330
       ? __do_page_fault+0x9c0/0x9c0
       ? prepare_exit_to_usermode+0x188/0x200
       ? perf_trace_sys_enter+0x1090/0x1090
       ? __x64_sys_sigaltstack+0x280/0x280
       ? __put_user_4+0x1c/0x30
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      RIP: 0033:0x7f16ff89a09b
      Code: 0f 1e fa 48 8b 05 ed bd 0c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d bd bd 0c 00 f7 d8 64 89 01 48
      RSP: 002b:00007fff001232b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 00007fff001232f0 RCX: 00007f16ff89a09b
      RDX: 00007fff001232f0 RSI: 00000000c06864a2 RDI: 000000000000000b
      RBP: 00007fff001232f0 R08: 0000000000000000 R09: 000055a79d484460
      R10: 000055a79d44e770 R11: 0000000000000246 R12: 00000000c06864a2
      R13: 000000000000000b R14: 0000000000000000 R15: 000055a79d44e770
      WARNING: CPU: 6 PID: 1070 at drivers/gpu/drm/drm_dp_mst_topology.c:3153 drm_dp_atomic_release_vcpi_slots+0xb9/0x200 [drm_kms_helper]
      ---[ end trace d536c05c13c83be2 ]---
      [drm:drm_dp_atomic_release_vcpi_slots [drm_kms_helper]] *ERROR* no VCPI for [MST PORT:00000000f9e2b143] found in mst state 000000009fd2899a
      
      This appears to be happening because we destroy the VCPI allocations
      when disabling all connected displays while suspending, and those VCPI
      allocations don't get restored on resume due to failing to restore the
      atomic state.
      
      So, fix this by introducing the suspending option to
      drm_atomic_helper_duplicate_state() and use that to indicate in the
      atomic state that it's being used for suspending or resuming the system,
      and thus needs to be fixed up by the driver. We can then use the new
      state->duplicated hook to tell update_connector_routing() in
      drm_atomic_check_modeset() to allow for modesets on unregistered
      connectors, which allows us to restore atomic states that contain MST
      topologies that were removed after the state was duplicated and thus:
      mostly fixing suspend and resume. This just leaves some issues that were
      introduced with nouveau, that will be addressed next.
      
      Changes since v3:
      * Remove ->duplicated hunks that I left in the VCPI helpers by accident.
        These don't need to be here, that was the supposed to be the purpose
        of the last revision
      Changes since v2:
      * Remove the changes in this patch to the VCPI helpers, they aren't
        needed anymore
      Changes since v1:
      * Rename suspend_or_resume to duplicated
      Signed-off-by: NLyude Paul <lyude@redhat.com>
      Fixes: eceae147 ("drm/dp_mst: Start tracking per-port VCPI allocations")
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190202002023.29665-4-lyude@redhat.com
      022debad
  19. 04 2月, 2019 1 次提交
  20. 24 1月, 2019 1 次提交
  21. 05 12月, 2018 1 次提交
  22. 30 11月, 2018 2 次提交
  23. 29 11月, 2018 3 次提交
  24. 23 11月, 2018 2 次提交
  25. 03 11月, 2018 1 次提交
    • R
      drm: Add connector property to limit max bpc · 47e22ff1
      Radhakrishna Sripada 提交于
      At times 12bpc HDMI cannot be driven due to faulty cables, dongles
      level shifters etc. To workaround them we may need to drive the output
      at a lower bpc. Currently the user space does not have a way to limit
      the bpc. The default bpc to be programmed is decided by the driver and
      is run against connector limitations.
      
      Creating a new connector property "max bpc" in order to limit the bpc.
      xrandr can make use of this connector property to make sure that bpc does
      not exceed the configured value. This property can be used by userspace to
      set the bpc.
      
      V2: Initialize max_bpc to satisfy kms_properties
      V3: Move the property to drm_connector
      V4: Split drm and i915 components(Ville)
      V5: Make the property per connector(Ville)
      V6: Compare the requested bpc to connector bpc(Daniel)
          Move the attach_property function to core(Ville)
      V7: Fix checkpatch warnings
      V8: Simplify the connector check code(Ville)
      V9: Const display_info(Ville)
      V10,V11: Fix CI issues.
      V12: Add the Kernel documentation(Daniel)
      V14: Crossreference the function name in the doc(Daniel)
      
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Kishore Kadiyala <kishore.kadiyala@intel.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Manasi Navare <manasi.d.navare@intel.com>
      Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
      Cc: Sunpeng Li <sunpeng.li@amd.com>
      Acked-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NRadhakrishna Sripada <radhakrishna.sripada@intel.com>
      Reviewed-by: NRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: NRodrigo Vivi <rodrigo.vivi@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20181012184233.29250-1-radhakrishna.sripada@intel.com
      47e22ff1
  26. 19 10月, 2018 4 次提交
    • L
      drm/atomic_helper: Stop modesets on unregistered connectors harder · de9f8eea
      Lyude Paul 提交于
      Unfortunately, it appears our fix in:
      commit b5d29843 ("drm/atomic_helper: Allow DPMS On<->Off changes
      for unregistered connectors")
      
      Which attempted to work around the problems introduced by:
      commit 4d802739 ("drm/atomic_helper: Disallow new modesets on
      unregistered connectors")
      
      Is still not the right solution, as modesets can still be triggered
      outside of drm_atomic_set_crtc_for_connector().
      
      So in order to fix this, while still being careful that we don't break
      modesets that a driver may perform before being registered with
      userspace, we replace connector->registered with a tristate member,
      connector->registration_state. This allows us to keep track of whether
      or not a connector is still initializing and hasn't been exposed to
      userspace, is currently registered and exposed to userspace, or has been
      legitimately removed from the system after having once been present.
      
      Using this info, we can prevent userspace from performing new modesets
      on unregistered connectors while still allowing the driver to perform
      modesets on unregistered connectors before the driver has finished being
      registered.
      
      Changes since v1:
      - Fix WARN_ON() in drm_connector_cleanup() that CI caught with this
        patchset in igt@drv_module_reload@basic-reload-inject and
        igt@drv_module_reload@basic-reload by checking if the connector is
        registered instead of unregistered, as calling drm_connector_cleanup()
        on a connector that hasn't been registered with userspace yet should
        stay valid.
      - Remove unregistered_connector_check(), and just go back to what we
        were doing before in commit 4d802739 ("drm/atomic_helper: Disallow
        new modesets on unregistered connectors") except replacing
        READ_ONCE(connector->registered) with drm_connector_is_unregistered().
        This gets rid of the behavior of allowing DPMS On<->Off, but that should
        be fine as it's more consistent with the UAPI we had before - danvet
      - s/drm_connector_unregistered/drm_connector_is_unregistered/ - danvet
      - Update documentation, fix some typos.
      
      Fixes: b5d29843 ("drm/atomic_helper: Allow DPMS On<->Off changes for unregistered connectors")
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: stable@vger.kernel.org
      Cc: David Airlie <airlied@linux.ie>
      Signed-off-by: NLyude Paul <lyude@redhat.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20181016203946.9601-1-lyude@redhat.com
      (cherry picked from commit 39b50c60)
      Fixes: e9655095 ("drm/atomic_helper: Disallow new modesets on unregistered connectors")
      Fixes: 34ca26a9 ("drm/atomic_helper: Allow DPMS On<->Off changes for unregistered connectors")
      Cc: stable@vger.kernel.org
      Signed-off-by: NJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
      de9f8eea
    • L
      drm/atomic_helper: Allow DPMS On<->Off changes for unregistered connectors · 34ca26a9
      Lyude Paul 提交于
      It appears when testing my previous fix for some of the legacy
      modesetting issues with MST, I misattributed some kernel splats that
      started appearing on my machine after a rebase as being from upstream.
      But it appears they actually came from my patch series:
      
      [    2.980512] [drm:drm_atomic_helper_check_modeset [drm_kms_helper]] Updating routing for [CONNECTOR:65:eDP-1]
      [    2.980516] [drm:drm_atomic_helper_check_modeset [drm_kms_helper]] [CONNECTOR:65:eDP-1] is not registered
      [    2.980516] ------------[ cut here ]------------
      [    2.980519] Could not determine valid watermarks for inherited state
      [    2.980553] WARNING: CPU: 3 PID: 551 at drivers/gpu/drm/i915/intel_display.c:14983 intel_modeset_init+0x14d7/0x19f0 [i915]
      [    2.980556] Modules linked in: i915(O+) i2c_algo_bit drm_kms_helper(O) syscopyarea sysfillrect sysimgblt fb_sys_fops drm(O) intel_rapl x86_pkg_temp_thermal iTCO_wdt wmi_bmof coretemp crc32_pclmul psmouse i2c_i801 mei_me mei i2c_core lpc_ich mfd_core tpm_tis tpm_tis_core wmi tpm thinkpad_acpi pcc_cpufreq video ehci_pci crc32c_intel serio_raw ehci_hcd xhci_pci xhci_hcd
      [    2.980577] CPU: 3 PID: 551 Comm: systemd-udevd Tainted: G           O      4.19.0-rc7Lyude-Test+ #1
      [    2.980579] Hardware name: LENOVO 20BWS1KY00/20BWS1KY00, BIOS JBET63WW (1.27 ) 11/10/2016
      [    2.980605] RIP: 0010:intel_modeset_init+0x14d7/0x19f0 [i915]
      [    2.980607] Code: 89 df e8 ec 27 02 00 e9 24 f2 ff ff be 03 00 00 00 48 89 df e8 da 27 02 00 e9 26 f2 ff ff 48 c7 c7 c8 d1 34 a0 e8 23 cf dc e0 <0f> 0b e9 7c fd ff ff f6 c4 04 0f 85 37 f7 ff ff 48 8b 83 60 08 00
      [    2.980611] RSP: 0018:ffffc90000287988 EFLAGS: 00010282
      [    2.980614] RAX: 0000000000000000 RBX: ffff88031b488000 RCX: 0000000000000006
      [    2.980617] RDX: 0000000000000007 RSI: 0000000000000086 RDI: ffff880321ad54d0
      [    2.980620] RBP: ffffc90000287a10 R08: 000000000000040a R09: 0000000000000065
      [    2.980623] R10: ffff88030ebb8f00 R11: ffffffff81416590 R12: ffff88031b488000
      [    2.980626] R13: ffff88031b4883a0 R14: ffffc900002879a8 R15: ffff880319099800
      [    2.980630] FS:  00007f475620d180(0000) GS:ffff880321ac0000(0000) knlGS:0000000000000000
      [    2.980633] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    2.980636] CR2: 00007f9ef28018a0 CR3: 000000031b72c001 CR4: 00000000003606e0
      [    2.980639] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [    2.980642] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [    2.980645] Call Trace:
      [    2.980675]  i915_driver_load+0xb0e/0xdc0 [i915]
      [    2.980681]  ? kernfs_add_one+0xe7/0x130
      [    2.980709]  i915_pci_probe+0x46/0x60 [i915]
      [    2.980715]  pci_device_probe+0xd4/0x150
      [    2.980719]  really_probe+0x243/0x3b0
      [    2.980722]  driver_probe_device+0xba/0x100
      [    2.980726]  __driver_attach+0xe4/0x110
      [    2.980729]  ? driver_probe_device+0x100/0x100
      [    2.980733]  bus_for_each_dev+0x74/0xb0
      [    2.980736]  driver_attach+0x1e/0x20
      [    2.980739]  bus_add_driver+0x159/0x230
      [    2.980743]  ? 0xffffffffa0393000
      [    2.980746]  driver_register+0x70/0xc0
      [    2.980749]  ? 0xffffffffa0393000
      [    2.980753]  __pci_register_driver+0x57/0x60
      [    2.980780]  i915_init+0x55/0x58 [i915]
      [    2.980785]  do_one_initcall+0x4a/0x1c4
      [    2.980789]  ? do_init_module+0x27/0x210
      [    2.980793]  ? kmem_cache_alloc_trace+0x131/0x190
      [    2.980797]  do_init_module+0x60/0x210
      [    2.980800]  load_module+0x2063/0x22e0
      [    2.980804]  ? vfs_read+0x116/0x140
      [    2.980807]  ? vfs_read+0x116/0x140
      [    2.980811]  __do_sys_finit_module+0xbd/0x120
      [    2.980814]  ? __do_sys_finit_module+0xbd/0x120
      [    2.980818]  __x64_sys_finit_module+0x1a/0x20
      [    2.980821]  do_syscall_64+0x5a/0x110
      [    2.980824]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [    2.980826] RIP: 0033:0x7f4754e32879
      [    2.980828] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d f7 45 2c 00 f7 d8 64 89 01 48
      [    2.980831] RSP: 002b:00007fff43fd97d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
      [    2.980834] RAX: ffffffffffffffda RBX: 0000559a44ca64f0 RCX: 00007f4754e32879
      [    2.980836] RDX: 0000000000000000 RSI: 00007f475599f4cd RDI: 0000000000000018
      [    2.980838] RBP: 00007f475599f4cd R08: 0000000000000000 R09: 0000000000000000
      [    2.980839] R10: 0000000000000018 R11: 0000000000000246 R12: 0000000000000000
      [    2.980841] R13: 0000559a44c92fd0 R14: 0000000000020000 R15: 0000000000000000
      [    2.980881] WARNING: CPU: 3 PID: 551 at drivers/gpu/drm/i915/intel_display.c:14983 intel_modeset_init+0x14d7/0x19f0 [i915]
      [    2.980884] ---[ end trace 5eb47a76277d4731 ]---
      
      The cause of this appears to be due to the fact that if there's
      pre-existing display state that was set by the BIOS when i915 loads, it
      will attempt to perform a modeset before the driver is registered with
      userspace. Since this happens before the driver's registered with
      userspace, it's connectors are also unregistered and thus-states which
      would turn on DPMS on a connector end up getting rejected since the
      connector isn't registered.
      
      These bugs managed to get past Intel's CI partially due to the fact it
      never ran a full test on my patches for some reason, but also because
      all of the tests unload the GPU once before running. Since this bug is
      only really triggered when the drivers tries to perform a modeset before
      it's been fully registered with userspace when coming from whatever
      display configuration the firmware left us with, it likely would never
      have been picked up by CI in the first place.
      
      After some discussion with vsyrjala, we decided the best course of
      action would be to just move the unregistered connector checks out of
      update_connector_routing() and into drm_atomic_set_crtc_for_connector().
      The reason for this being that legacy modesetting isn't going to be
      expecting failures anywhere (at least this is the case with X), so
      ideally we want to ensure that any DPMS changes will still work even on
      unregistered connectors. Instead, we now only reject new modesets which
      would change the current CRTC assigned to an unregistered connector
      unless no new CRTC is being assigned to replace the connector's previous
      one.
      Signed-off-by: NLyude Paul <lyude@redhat.com>
      Reported-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Fixes: 4d802739 ("drm/atomic_helper: Disallow new modesets on unregistered connectors")
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20181009204424.21462-1-lyude@redhat.com
      (cherry picked from commit b5d29843)
      Fixes: e9655095 ("drm/atomic_helper: Disallow new modesets on unregistered connectors")
      Signed-off-by: NJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
      34ca26a9
    • L
      drm/atomic_helper: Disallow new modesets on unregistered connectors · e9655095
      Lyude Paul 提交于
      With the exception of modesets which would switch the DPMS state of a
      connector from on to off, we want to make sure that we disallow all
      modesets which would result in enabling a new monitor or a new mode
      configuration on a monitor if the connector for the display in question
      is no longer registered. This allows us to stop userspace from trying to
      enable new displays on connectors for an MST topology that were just
      removed from the system, without preventing userspace from disabling
      DPMS on those connectors.
      
      Changes since v5:
      - Fix typo in comment, nothing else
      Signed-off-by: NLyude Paul <lyude@redhat.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Cc: stable@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20181008232437.5571-2-lyude@redhat.com
      (cherry picked from commit 4d802739)
      Signed-off-by: NJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
      e9655095
    • 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
  27. 18 10月, 2018 1 次提交
    • L
      drm/atomic_helper: Stop modesets on unregistered connectors harder · 39b50c60
      Lyude Paul 提交于
      Unfortunately, it appears our fix in:
      commit b5d29843 ("drm/atomic_helper: Allow DPMS On<->Off changes
      for unregistered connectors")
      
      Which attempted to work around the problems introduced by:
      commit 4d802739 ("drm/atomic_helper: Disallow new modesets on
      unregistered connectors")
      
      Is still not the right solution, as modesets can still be triggered
      outside of drm_atomic_set_crtc_for_connector().
      
      So in order to fix this, while still being careful that we don't break
      modesets that a driver may perform before being registered with
      userspace, we replace connector->registered with a tristate member,
      connector->registration_state. This allows us to keep track of whether
      or not a connector is still initializing and hasn't been exposed to
      userspace, is currently registered and exposed to userspace, or has been
      legitimately removed from the system after having once been present.
      
      Using this info, we can prevent userspace from performing new modesets
      on unregistered connectors while still allowing the driver to perform
      modesets on unregistered connectors before the driver has finished being
      registered.
      
      Changes since v1:
      - Fix WARN_ON() in drm_connector_cleanup() that CI caught with this
        patchset in igt@drv_module_reload@basic-reload-inject and
        igt@drv_module_reload@basic-reload by checking if the connector is
        registered instead of unregistered, as calling drm_connector_cleanup()
        on a connector that hasn't been registered with userspace yet should
        stay valid.
      - Remove unregistered_connector_check(), and just go back to what we
        were doing before in commit 4d802739 ("drm/atomic_helper: Disallow
        new modesets on unregistered connectors") except replacing
        READ_ONCE(connector->registered) with drm_connector_is_unregistered().
        This gets rid of the behavior of allowing DPMS On<->Off, but that should
        be fine as it's more consistent with the UAPI we had before - danvet
      - s/drm_connector_unregistered/drm_connector_is_unregistered/ - danvet
      - Update documentation, fix some typos.
      
      Fixes: b5d29843 ("drm/atomic_helper: Allow DPMS On<->Off changes for unregistered connectors")
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: stable@vger.kernel.org
      Cc: David Airlie <airlied@linux.ie>
      Signed-off-by: NLyude Paul <lyude@redhat.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20181016203946.9601-1-lyude@redhat.com
      39b50c60