Skip to content

Commit 16f17ed

Browse files
leo-sunli1alexdeucher
authored andcommitted
drm/amd/display: Send vblank and user events at vsartup for DCN
[Why] For DCN hardware, the crtc_high_irq handler is assigned to the vstartup interrupt. This is different from DCE, which has it assigned to vblank start. We'd like to send vblank and user events at vstartup because: * It happens close enough to vupdate - the point of no return for HW. * It is programmed as lines relative to vblank end - i.e. it is not in the variable portion when VRR is enabled. We should signal user events here. * The pflip interrupt responsible for sending user events today only fires if the DCH HUBP component is not clock gated. In situations where planes are disabled - but the CRTC is enabled - user events won't be sent out, leading to flip done timeouts. Consequently, this makes vupdate on DCN hardware redundant. It will be removed in the next change. [How] Add a DCN-specific crtc_high_irq handler, and hook it to the VStartup signal. Inside the DCN handler, we send off user events if the pflip handler hasn't already done so. Reviewed-by: Nicholas Kazlauskas <[email protected]> Signed-off-by: Leo Li <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 61aa7a6 commit 16f17ed

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,69 @@ static void dm_crtc_high_irq(void *interrupt_params)
485485
}
486486
}
487487

488+
489+
/**
490+
* dm_dcn_crtc_high_irq() - Handles VStartup interrupt for DCN generation ASICs
491+
* @interrupt params - interrupt parameters
492+
*
493+
* Notify DRM's vblank event handler at VSTARTUP
494+
*
495+
* Unlike DCE hardware, we trigger the handler at VSTARTUP. at which:
496+
* * We are close enough to VUPDATE - the point of no return for hw
497+
* * We are in the fixed portion of variable front porch when vrr is enabled
498+
* * We are before VUPDATE, where double-buffered vrr registers are swapped
499+
*
500+
* It is therefore the correct place to signal vblank, send user flip events,
501+
* and update VRR.
502+
*/
503+
static void dm_dcn_crtc_high_irq(void *interrupt_params)
504+
{
505+
struct common_irq_params *irq_params = interrupt_params;
506+
struct amdgpu_device *adev = irq_params->adev;
507+
struct amdgpu_crtc *acrtc;
508+
struct dm_crtc_state *acrtc_state;
509+
unsigned long flags;
510+
511+
acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - IRQ_TYPE_VBLANK);
512+
513+
if (!acrtc)
514+
return;
515+
516+
acrtc_state = to_dm_crtc_state(acrtc->base.state);
517+
518+
DRM_DEBUG_DRIVER("crtc:%d, vupdate-vrr:%d\n", acrtc->crtc_id,
519+
amdgpu_dm_vrr_active(acrtc_state));
520+
521+
amdgpu_dm_crtc_handle_crc_irq(&acrtc->base);
522+
drm_crtc_handle_vblank(&acrtc->base);
523+
524+
spin_lock_irqsave(&adev->ddev->event_lock, flags);
525+
526+
if (acrtc_state->vrr_params.supported &&
527+
acrtc_state->freesync_config.state == VRR_STATE_ACTIVE_VARIABLE) {
528+
mod_freesync_handle_v_update(
529+
adev->dm.freesync_module,
530+
acrtc_state->stream,
531+
&acrtc_state->vrr_params);
532+
533+
dc_stream_adjust_vmin_vmax(
534+
adev->dm.dc,
535+
acrtc_state->stream,
536+
&acrtc_state->vrr_params.adjust);
537+
}
538+
539+
if (acrtc->pflip_status == AMDGPU_FLIP_SUBMITTED) {
540+
if (acrtc->event) {
541+
drm_crtc_send_vblank_event(&acrtc->base, acrtc->event);
542+
acrtc->event = NULL;
543+
drm_crtc_vblank_put(&acrtc->base);
544+
}
545+
acrtc->pflip_status = AMDGPU_FLIP_NONE;
546+
}
547+
548+
spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
549+
}
550+
488551
static int dm_set_clockgating_state(void *handle,
489552
enum amd_clockgating_state state)
490553
{
@@ -2175,7 +2238,7 @@ static int dcn10_register_irq_handlers(struct amdgpu_device *adev)
21752238
c_irq_params->irq_src = int_params.irq_source;
21762239

21772240
amdgpu_dm_irq_register_interrupt(adev, &int_params,
2178-
dm_crtc_high_irq, c_irq_params);
2241+
dm_dcn_crtc_high_irq, c_irq_params);
21792242
}
21802243

21812244
/* Use VUPDATE_NO_LOCK interrupt on DCN, which seems to correspond to

0 commit comments

Comments
 (0)