1. 05 Nov, 2021 4 commits
    • Maxime Ripard's avatar
      drm/vc4: hdmi: Add a spinlock to protect register access · 81fb55e5
      Maxime Ripard authored
      The vc4 HDMI driver has multiple path shared between the CEC, ALSA and
      KMS frameworks, plus two interrupt handlers (CEC and hotplug) that will
      read and modify a number of registers.
      
      Even though not bug has been reported so far, it's definitely unsafe, so
      let's just add a spinlock to protect the register access of the HDMI
      controller.
      
      Link: https://lore.kernel.org/r/20211025141113.702757-5-maxime@cerno.tech
      Fixes: c8b75bca ("drm/vc4: Add KMS support for Raspberry Pi.")
      Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      81fb55e5
    • Maxime Ripard's avatar
      drm/vc4: crtc: Copy assigned channel to the CRTC · eeb6ab46
      Maxime Ripard authored
      Accessing the crtc->state pointer from outside the modesetting context
      is not allowed. We thus need to copy whatever we need from the KMS state
      to our structure in order to access it.
      
      In VC4, a number of users of that pointers have crept in over the years,
      and the previous commits removed them all but the HVS channel a CRTC has
      been assigned.
      
      Let's move this channel in struct vc4_crtc at atomic_begin() time, drop
      it from our private state structure, and remove our use of crtc->state
      from our vblank handler entirely.
      
      Link: https://lore.kernel.org/all/YWgteNaNeaS9uWDe@phenom.ffwll.local/
      Link: https://lore.kernel.org/r/20211025141113.702757-4-maxime@cerno.tech
      Fixes: 87ebcd42 ("drm/vc4: crtc: Assign output to channel automatically")
      Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      eeb6ab46
    • Maxime Ripard's avatar
      drm/vc4: Fix non-blocking commit getting stuck forever · 0c250c15
      Maxime Ripard authored
      In some situation, we can end up being stuck on a non-blocking that went
      through properly.
      
      The situation that seems to trigger it reliably is to first start a
      non-blocking commit, and then right after, and before we had any vblank
      interrupt), start a blocking commit.
      
      This will lead to the first commit workqueue to be scheduled, setup the
      display, while the second commit is waiting for the first one to be
      completed.
      
      The vblank interrupt will then be raised, vc4_crtc_handle_vblank() will
      run and will compare the active dlist in the HVS channel to the one
      associated with the crtc->state.
      
      However, at that point, the second commit is waiting using
      drm_atomic_helper_wait_for_dependencies that occurs after
      drm_atomic_helper_swap_state has been called, so crtc->state points to
      the second commit state. vc4_crtc_handle_vblank() will compare the two
      dlist addresses and since they don't match will ignore the interrupt.
      
      The vblank event will never be reported, and the first and second commit
      will wait for the first commit completion until they timeout.
      
      The underlying reason is that it was never safe to do so. Indeed,
      accessing the ->state pointer access synchronization is based on
      ownership guarantees that can only occur within the functions and hooks
      defined as part of the KMS framework, and obviously the irq handler
      isn't one of them. The rework to move to generic helpers only uncovered
      the underlying issue.
      
      However, since the code path between
      drm_atomic_helper_wait_for_dependencies() and
      drm_atomic_helper_wait_for_vblanks() is serialised and we can't get two
      commits in that path at the same time, we can work around this issue by
      setting a variable associated to struct drm_crtc to the dlist we expect,
      and then using it from the vc4_crtc_handle_vblank() function.
      
      Since that state is shared with the modesetting path, we also need to
      introduce a spinlock to protect the code shared between the interrupt
      handler and the modesetting path, protecting only our new variable for
      now.
      
      Link: https://lore.kernel.org/all/YWgteNaNeaS9uWDe@phenom.ffwll.local/
      Link: https://lore.kernel.org/r/20211025141113.702757-3-maxime@cerno.tech
      Fixes: 56d1fe09 ("drm/vc4: Make pageflip completion handling more robust.")
      Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      0c250c15
    • Maxime Ripard's avatar
      drm/vc4: crtc: Drop feed_txp from state · a16c6640
      Maxime Ripard authored
      Accessing the crtc->state pointer from outside the modesetting context
      is not allowed. We thus need to copy whatever we need from the KMS state
      to our structure in order to access it.
      
      In VC4, a number of users of that pointers have crept in over the years,
      the first one being whether or not the downstream controller of the
      pixelvalve is our writeback controller.
      
      Fortunately for us, Since commit 39fcb280 ("drm/vc4: txp: Turn the
      TXP into a CRTC of its own") this is no longer something that can change
      from one commit to the other and is hardcoded.
      
      Let's set this flag in struct vc4_crtc if we happen to be the TXP, and
      drop the flag from our private state structure.
      
      Link: https://lore.kernel.org/all/YWgteNaNeaS9uWDe@phenom.ffwll.local/
      Link: https://lore.kernel.org/r/20211025141113.702757-2-maxime@cerno.tech
      Fixes: 008095e0 ("drm/vc4: Add support for the transposer block")
      Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      a16c6640
  2. 04 Nov, 2021 16 commits
  3. 03 Nov, 2021 1 commit
  4. 02 Nov, 2021 6 commits
  5. 01 Nov, 2021 1 commit
    • Andrey Grodzovsky's avatar
      drm/sched: Avoid lockdep spalt on killing a processes · 542cff78
      Andrey Grodzovsky authored
      Probelm:
      Singlaning one sched fence from within another's sched
      fence singal callback generates lockdep splat because
      the both have same lockdep class of their fence->lock
      
      Fix:
      Fix bellow stack by rescheduling to irq work of
      signaling and killing of jobs that left when entity is killed.
      
      [11176.741181]  dump_stack+0x10/0x12
      [11176.741186] __lock_acquire.cold+0x208/0x2df
      [11176.741197]  lock_acquire+0xc6/0x2d0
      [11176.741204]  ? dma_fence_signal+0x28/0x80
      [11176.741212] _raw_spin_lock_irqsave+0x4d/0x70
      [11176.741219]  ? dma_fence_signal+0x28/0x80
      [11176.741225]  dma_fence_signal+0x28/0x80
      [11176.741230] drm_sched_fence_finished+0x12/0x20 [gpu_sched]
      [11176.741240] drm_sched_entity_kill_jobs_cb+0x1c/0x50 [gpu_sched]
      [11176.741248] dma_fence_signal_timestamp_locked+0xac/0x1a0
      [11176.741254]  dma_fence_signal+0x3b/0x80
      [11176.741260] drm_sched_fence_finished+0x12/0x20 [gpu_sched]
      [11176.741268] drm_sched_job_done.isra.0+0x7f/0x1a0 [gpu_sched]
      [11176.741277] drm_sched_job_done_cb+0x12/0x20 [gpu_sched]
      [11176.741284] dma_fence_signal_timestamp_locked+0xac/0x1a0
      [11176.741290]  dma_fence_signal+0x3b/0x80
      [11176.741296] amdgpu_fence_process+0xd1/0x140 [amdgpu]
      [11176.741504] sdma_v4_0_process_trap_irq+0x8c/0xb0 [amdgpu]
      [11176.741731]  amdgpu_irq_dispatch+0xce/0x250 [amdgpu]
      [11176.741954]  amdgpu_ih_process+0x81/0x100 [amdgpu]
      [11176.742174]  amdgpu_irq_handler+0x26/0xa0 [amdgpu]
      [11176.742393] __handle_irq_event_percpu+0x4f/0x2c0
      [11176.742402] handle_irq_event_percpu+0x33/0x80
      [11176.742408]  handle_irq_event+0x39/0x60
      [11176.742414]  handle_edge_irq+0x93/0x1d0
      [11176.742419]  __common_interrupt+0x50/0xe0
      [11176.742426]  common_interrupt+0x80/0x90
      Signed-off-by: default avatarAndrey Grodzovsky <andrey.grodzovsky@amd.com>
      Suggested-by: default avatarDaniel Vetter  <daniel.vetter@ffwll.ch>
      Suggested-by: default avatarChristian König <christian.koenig@amd.com>
      Tested-by: default avatarChristian König <christian.koenig@amd.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Link: https://www.spinics.net/lists/dri-devel/msg321250.html
      542cff78
  6. 30 Oct, 2021 1 commit
  7. 29 Oct, 2021 11 commits