Fixes for flip_done timeouts
Subsystems (3)
[email protected]
maintainerv2 cover Fixes for flip_done timeouts
From: Leo Li <[email protected]>
This series collects a few fixes targeting the intermittent flip_done timeouts that have been reported on a range of DCN systems (most notably NV3x+ DGPUs and some PSR-capable platforms).
The investigation pointed at two distinct root causes:
1. Cursor vblank events are delivered from the vstartup OTG interrupt, which HW can mask (see [2/3] for details). When that happens, no vblank event reaches userspace and the commit eventually times out.
2. PSR-capable systems can engage dynamic power-gating on HUBP, the HW block responsible for delivering the pflip interrupt. Programming a flip before HUBP fully exits DPG can mask the interrupt.
Patch 1 reverts the 5s vbl offdelay workaround that was added for NV3x+ DGPUs, since the underlying issues are now addressed by patches 2 and 3.
Patch 2 switches DCN vblank delivery from vstartup to the vline2 generic OTG interrupt. Unlike vstartup, vline interrupts cannot be masked while the OTG is active, so they are a reliable signal for delivering vblank events.
Patch 3 adds a backup path for masked pflip interrupts on the newly introduced vline2 handler.
Many thanks to the reporters who collaborated on these issues [1][2][3]; the bug seems to avoid driver devs. Your help with testing patches and collecting debug data was critical to these fixes!
[1] https://gitlab.freedesktop.org/drm/amd/-/work_items/4141
[2] https://gitlab.freedesktop.org/drm/amd/-/work_items/3787
[3] https://lore.kernel.org/amd-gfx/[email protected]/
Changes since v1:
* Include a revert [Patch 1/3] of the change that restored the 5s vbl offdelay
* Fix vline2 irq_source [Patch 2/3] to map from crtc to otg index correctly
* Add a fix [Patch 3/3] to address PSR exit race with flips
Thanks,
Leo
Leo Li (3):
Revert "drm/amd/display: Restore 5s vbl offdelay for NV3x+ DGPUs" drm/amd/display: Use vline2 interrupt on DCN instead of vstartup drm/amd/display: Check for flip completion in OTG interrupt handlers
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 248 ++++++++++++------ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 9 + .../amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 20 +- .../drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c | 103 ++++++-- .../drm/amd/display/amdgpu_dm/amdgpu_dm_irq.h | 7 + .../display/amdgpu_dm/amdgpu_dm_irq_params.h | 8 + .../display/dc/irq/dcn10/irq_service_dcn10.c | 44 +++- .../display/dc/irq/dcn20/irq_service_dcn20.c | 43 ++- .../dc/irq/dcn201/irq_service_dcn201.c | 24 +- .../display/dc/irq/dcn21/irq_service_dcn21.c | 44 +++- .../display/dc/irq/dcn30/irq_service_dcn30.c | 44 +++- .../dc/irq/dcn302/irq_service_dcn302.c | 43 ++- .../dc/irq/dcn303/irq_service_dcn303.c | 24 +- .../display/dc/irq/dcn31/irq_service_dcn31.c | 44 +++- .../dc/irq/dcn314/irq_service_dcn314.c | 44 +++- .../dc/irq/dcn315/irq_service_dcn315.c | 44 +++- .../display/dc/irq/dcn32/irq_service_dcn32.c | 26 +- .../display/dc/irq/dcn35/irq_service_dcn35.c | 41 ++- .../dc/irq/dcn351/irq_service_dcn351.c | 43 ++- .../display/dc/irq/dcn36/irq_service_dcn36.c | 41 ++- .../dc/irq/dcn401/irq_service_dcn401.c | 25 +- .../display/dc/irq/dcn42/irq_service_dcn42.c | 26 +- .../gpu/drm/amd/display/dc/irq/irq_service.h | 18 ++ 24 files changed, 744 insertions(+), 271 deletions(-)
Signature · 1 line
2.53.0
[email protected]
maintainerPATCH v2 1/3 Revert "drm/amd/display: Restore 5s vbl offdelay for NV3x+ DGPUs"
From: Leo Li <[email protected]>
Now that proper fixes have been found, let's revert this workaround.
This reverts commit 751414c12388ff2b475e15c15d3c817dcf563635.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -15
@@ -9518,21 +9518,9 @@ static void manage_dm_interrupts(struct amdgpu_device *adev,if (acrtc_state) { timing = &acrtc_state->stream->timing; -if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) >= -IP_VERSION (3 ,2 ,0 ) && - !(adev->flags &AMD_IS_APU )) { -/* -* DGPUs NV3x and newer that support idle optimizations -* experience intermittent flip-done timeouts on cursor -* updates. Restore 5s offdelay behavior for now. -* -* Discussion on the issue: -* https://lore.kernel.org/amd-gfx/[email protected]/ -*/ - config.offdelay_ms =5000 ; - config.disable_immediate = false; - }else if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) < -IP_VERSION (3 ,5 ,0 )) { +if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) < +IP_VERSION (3 ,5 ,0 ) || + !(adev->flags &AMD_IS_APU )) {/* * Older HW and DGPU have issues with instant off; * use a 2 frame offdelay.
Signature · 1 line
2.53.0
Re: [PATCH v2 1/3] Revert "drm/amd/display: Restore 5s vbl offdelay for NV3x+ DGPUs"
Quoted 7 lines · On 5/19/26 17:04, [email protected] wrote:
From: Leo Li <[email protected]>
Now that proper fixes have been found, let's revert this workaround.
This reverts commit
751414c12388ff2b475e15c15d3c817dcf563635.Signed-off-by Leo Li <[email protected]>
Unless it "actively" makese the problem worse - could this be the last patch in the series instead of the first? This will make things cleaner when it comes to backporting. IE backport the fixes, "then" revert the W/A.
Quoted 33 lines
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3
-15@@ -9518,21 +9518,9 @@ static void manage_dm_interrupts(struct amdgpu_device *adev,if (acrtc_state) { timing = &acrtc_state->stream->timing; -if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) >= -IP_VERSION (3 ,2 ,0 ) && - !(adev->flags &AMD_IS_APU )) { -/* -* DGPUs NV3x and newer that support idle optimizations -* experience intermittent flip-done timeouts on cursor -* updates. Restore 5s offdelay behavior for now. -* -* Discussion on the issue: -* https://lore.kernel.org/amd-gfx/[email protected]/ -*/ - config.offdelay_ms =5000 ; - config.disable_immediate = false; - }else if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) < -IP_VERSION (3 ,5 ,0 )) { +if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) < +IP_VERSION (3 ,5 ,0 ) || + !(adev->flags &AMD_IS_APU )) {/* * Older HW and DGPU have issues with instant off; * use a 2 frame offdelay.
Leo Li
maintainerRe: [PATCH v2 1/3] Revert "drm/amd/display: Restore 5s vbl offdelay for NV3x+ DGPUs"
Quoted 5 lines · Mario Limonciello
Quoted 2 lines · On 5/19/26 17:04, [email protected] wrote:
From: Leo Li <[email protected]>
Quoted 7 lines
Quoted 5 lines
Now that proper fixes have been found, let's revert this workaround.
This reverts commit
751414c12388ff2b475e15c15d3c817dcf563635.Signed-off-by Leo Li <[email protected]>Unless it "actively" makese the problem worse - could this be the last patch in the series instead of the first? This will make things cleaner when it comes to backporting. IE backport the fixes, "then" revert the W/A.
It doesn't make the problem worse, but we do want to revert it since it negatively impacts power. I'll reorder this to be the last patch when merging.
Thanks,
Leo
Quoted 34 lines
Quoted 33 lines
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 18 +++---------------1 file changed, 3 insertions(+), 15 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -9518,21 +9518,9 @@ static void manage_dm_interrupts(struct amdgpu_device *adev, if (acrtc_state) { timing = &acrtc_state->stream->timing;- if (
amdgpu_ip_version(adev, DCE_HWIP, 0)>=
-IP_VERSION(3, 2, 0)&&
- !(adev->flags &AMD_IS_APU)) {
- /*
- * DGPUs NV3x and newer that support idle optimizations
- * experience intermittent flip-done timeouts on cursor
- * updates. Restore 5s offdelay behavior for now.
- *
- * Discussion on the issue:
- * https://lore.kernel.org/amd-gfx/[email protected]/
- */
- config.offdelay_ms = 5000;
- config.disable_immediate = false;
- } else if (amdgpu_ip_version(adev, DCE_HWIP, 0)<
-IP_VERSION(3, 5, 0)) {
+ if (amdgpu_ip_version(adev, DCE_HWIP, 0)<
+IP_VERSION(3, 5, 0)||
+ !(adev->flags &AMD_IS_APU)) {
/*
* Older HW and DGPU have issues with instant off;
* use a 2 frame offdelay.
Re: [PATCH v2 1/3] Revert "drm/amd/display: Restore 5s vbl offdelay for NV3x+ DGPUs"
Quoted 10 lines · Leo Li
Quoted 7 lines · Mario Limonciello
Quoted 4 lines · On 5/19/26 17:04, [email protected] wrote:
From: Leo Li <[email protected]>
Now that proper fixes have been found, let's revert this workaround.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
This reverts commit
751414c12388ff2b475e15c15d3c817dcf563635.Signed-off-by Leo Li <[email protected]>Unless it "actively" makese the problem worse - could this be the last patch in the series instead of the first? This will make things cleaner when it comes to backporting. IE backport the fixes, "then" revert the W/A.
It doesn't make the problem worse, but we do want to revert it since it negatively impacts power. I'll reorder this to be the last patch when merging.
Great, thanks.
Quoted 38 lines
Thanks,
LeoQuoted 34 lines
Quoted 33 lines
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3
-14@@ -9518,21 +9518,9 @@ static void manage_dm_interrupts(struct amdgpu_device *adev, if (acrtc_state) { timing = &acrtc_state->stream->timing; - if (amdgpu_ip_version(adev, DCE_HWIP, 0) >= - IP_VERSION(3, 2, 0) && - !(adev->flags & AMD_IS_APU)) { - /* - * DGPUs NV3x and newer that support idle optimizations - * experience intermittent flip-done timeouts on cursor - * updates. Restore 5s offdelay behavior for now. - * - * Discussion on the issue: - * https://lore.kernel.org/amd-gfx/[email protected]/ - */ - config.offdelay_ms = 5000; - config.disable_immediate = false; - } else if (amdgpu_ip_version(adev, DCE_HWIP, 0) < - IP_VERSION(3, 5, 0)) { + if (amdgpu_ip_version(adev, DCE_HWIP, 0) < + IP_VERSION(3, 5, 0) || + !(adev->flags & AMD_IS_APU)) { /** Older HW and DGPU have issues with instant off; * use a 2 frame offdelay.
[email protected]
maintainerPATCH v2 2/3 drm/amd/display: Use vline2 interrupt on DCN instead of vstartup
In reply to [email protected]From: Leo Li <[email protected]>
[Why]
VStartup is an OTG event that fires when the pixel pipeline prepares for pixel scanout of the next frame. It was previously used to deliver vblank events for commits that do not trigger a fb address update, and hence a pflip interrupt (hw cursor updates, for example).
The issue with vstartup is that HW can mask the interrupt in some cases:
* DPG - DCN can Dynamically Power Gate parts of the display pipe when a self-refresh capable eDP is connected. DPG is engaged when there's enough static frames (detected thru drm_vblank_off) Once gated, even though the OTG (output timing generator) is still enabled, vstartup is masked. vline is unaffected.
* GSL - Driver can use the Global Sync Lock to block HW from latching onto double-buffered registers during programming, to prevent HW from latching onto a partially programmed state. This will mask vstartup, but vline is unaffected. See dcn20_pipe_control_lock()
* MALL - A DCN accessible cache introduced in DCN32+ DGPUs that can store fb data to allow for longer DRAM sleep. When scanning out from MALL, vstartup is masked, vline is unaffected.
This could the explain the range of flip_done timeouts frequently seen in the wild.
DCN hardware provides 3 generic OTG interrupts that can be programmed to fire on a specific line. Vline 0 and 1 are currently reserved, with vline2 available to use for event delivery. These interrupts cannot be masked, as long as the OTG is active.
[How]
Switch to vline2 for vblank handling. Today, DC will program the vline2 position to at vupdate -- the point at which HW latches to double-buffered registers.
Since all the vline interrupt types share the same interrupt src_id, refactor the existing vline0 infrastructure to allow for all the vline0, 1, and 2 types.
Since this is intended to replace vstartup for DCN, use the same handler logic, but be careful to leave DCE on vstartup.
v2:
* Use acrtc->otg_inst when mapping the HW irq_source instead of the SW DRM CRTC id -- they can be different.
* Convert DCN_VINT_TO_DC_IRQSRC to a ternary chain to avoid control flow statements in macro; return at caller.
* Fix other checkpatch.pl issues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 167 ++++++++++++------ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 9 + .../amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 20 ++- .../drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c | 103 +++++++++-- .../drm/amd/display/amdgpu_dm/amdgpu_dm_irq.h | 7 + .../display/dc/irq/dcn10/irq_service_dcn10.c | 44 +++-- .../display/dc/irq/dcn20/irq_service_dcn20.c | 43 +++-- .../dc/irq/dcn201/irq_service_dcn201.c | 24 ++- .../display/dc/irq/dcn21/irq_service_dcn21.c | 44 +++-- .../display/dc/irq/dcn30/irq_service_dcn30.c | 44 +++-- .../dc/irq/dcn302/irq_service_dcn302.c | 43 +++-- .../dc/irq/dcn303/irq_service_dcn303.c | 24 ++- .../display/dc/irq/dcn31/irq_service_dcn31.c | 44 +++-- .../dc/irq/dcn314/irq_service_dcn314.c | 44 +++-- .../dc/irq/dcn315/irq_service_dcn315.c | 44 +++-- .../display/dc/irq/dcn32/irq_service_dcn32.c | 26 +-- .../display/dc/irq/dcn35/irq_service_dcn35.c | 41 +++-- .../dc/irq/dcn351/irq_service_dcn351.c | 43 +++-- .../display/dc/irq/dcn36/irq_service_dcn36.c | 41 +++-- .../dc/irq/dcn401/irq_service_dcn401.c | 25 +-- .../display/dc/irq/dcn42/irq_service_dcn42.c | 26 +-- .../gpu/drm/amd/display/dc/irq/irq_service.h | 18 ++ 23 files changed, 674 insertions(+), 252 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
@@ -909,7 +909,7 @@ struct amdgpu_device {/* For pre-DCE11. DCE11 and later are in "struct amdgpu_device->dm" */ struct delayed_work hotplug_work;struct amdgpu_irq_src crtc_irq; -struct amdgpu_irq_src vline0_irq; +struct amdgpu_irq_src vline_irq;struct amdgpu_irq_src vupdate_irq;struct amdgpu_irq_src pageflip_irq;struct amdgpu_irq_src hpd_irq;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +113 -54
257 lines not on this page · raw message
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +9 -0
@@ -543,6 +543,15 @@ struct amdgpu_display_manager {struct common_irq_params vline0_params[DC_IRQ_SOURCE_DC6_VLINE0 -DC_IRQ_SOURCE_DC1_VLINE0 +1 ]; +/** +* @vline2_params: +* +* OTG vertical interrupt0 IRQ parameters, passed to registered +* handlers when triggered. +*/ +struct common_irq_params + vline2_params[DC_IRQ_SOURCE_DC6_VLINE2 -DC_IRQ_SOURCE_DC1_VLINE2 +1 ]; +/** * @vupdate_params: *
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c +16 -4
@@ -28,6 +28,7 @@#include "dc.h" #include "amdgpu.h" +#include "amdgpu_dm_irq.h" #include "amdgpu_dm_psr.h" #include "amdgpu_dm_replay.h" #include "amdgpu_dm_crtc.h"
@@ -290,10 +291,19 @@ static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc *crtc, bool enable)/* crtc vblank or vstartup interrupt */ if (enable) { - rc =amdgpu_irq_get (adev, &adev->crtc_irq, irq_type); +/* vline only available on DCN+ */ +if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) ==0 ) + rc =amdgpu_irq_get (adev, &adev->crtc_irq, irq_type); +else + rc =amdgpu_irq_get (adev, &adev->vline_irq, +DM_VLINE_IRQ (adev,2 , acrtc->crtc_id));drm_dbg_vbl (crtc->dev,"Get crtc_irq ret=%d\n" , rc); }else { - rc =amdgpu_irq_put (adev, &adev->crtc_irq, irq_type); +if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) ==0 ) + rc =amdgpu_irq_put (adev, &adev->crtc_irq, irq_type); +else + rc =amdgpu_irq_put (adev, &adev->vline_irq, +DM_VLINE_IRQ (adev,2 , acrtc->crtc_id));drm_dbg_vbl (crtc->dev,"Put crtc_irq ret=%d\n" , rc); }
@@ -323,10 +333,12 @@ static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc *crtc, bool enable)/* crtc vline0 interrupt, only available on DCN+ */ if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) !=0 ) {if (enable) { - rc =amdgpu_irq_get (adev, &adev->vline0_irq, irq_type); + rc =amdgpu_irq_get (adev, &adev->vline_irq, +DM_VLINE_IRQ (adev,0 , acrtc->crtc_id));drm_dbg_vbl (crtc->dev,"Get vline0_irq ret=%d\n" , rc); }else { - rc =amdgpu_irq_put (adev, &adev->vline0_irq, irq_type); + rc =amdgpu_irq_put (adev, &adev->vline_irq, +DM_VLINE_IRQ (adev,0 , acrtc->crtc_id));drm_dbg_vbl (crtc->dev,"Put vline0_irq ret=%d\n" , rc); }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c +88 -15
122 lines not on this page · raw message
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.h +7 -0
@@ -27,6 +27,13 @@#include "irq_types.h" /* DAL irq definitions */ +/* +* Get OTG vline irq id from vline num and otg num. See also +* amdgpu_dm_set_vline_irq_state() +*/ +#define DM_VLINE_IRQ (adev, vline_num, otg_num) \ + (adev->mode_info.num_crtc * vline_num + otg_num) +/* * Display Manager IRQ-related interfaces (for use by DAL). */
drivers/gpu/drm/amd/display/dc/irq/dcn10/irq_service_dcn10.c +32 -12
74 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.c +31 -12
73 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn201/irq_service_dcn201.c +20 -4
@@ -47,10 +47,6 @@ static enum dc_irq_source to_dal_irq_source_dcn201(return DC_IRQ_SOURCE_VBLANK1 ;case DCN_1_0__SRCID__DC_D2_OTG_VSTARTUP :return DC_IRQ_SOURCE_VBLANK2 ; -case DCN_1_0__SRCID__OTG1_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC1_VLINE0 ; -case DCN_1_0__SRCID__OTG2_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC2_VLINE0 ;case DCN_1_0__SRCID__HUBP0_FLIP_INTERRUPT :return DC_IRQ_SOURCE_PFLIP1 ;case DCN_1_0__SRCID__HUBP1_FLIP_INTERRUPT :
@@ -59,6 +55,12 @@ static enum dc_irq_source to_dal_irq_source_dcn201(return DC_IRQ_SOURCE_VUPDATE1 ;case DCN_1_0__SRCID__OTG1_IHC_V_UPDATE_NO_LOCK_INTERRUPT :return DC_IRQ_SOURCE_VUPDATE2 ; + +case DCN_VINT_SRCID (1 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (1 , ext_id); +case DCN_VINT_SRCID (2 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (2 , ext_id); +case DCN_1_0__SRCID__DC_HPD1_INT :/* generic src_id for all HPD and HPDRX interrupts */ switch (ext_id) {
@@ -104,6 +106,11 @@ static struct irq_source_info_funcs vline0_irq_info_funcs = { .set = NULL, .ack = NULL }; + +static struct irq_source_info_funcs vline2_irq_info_funcs = { + .set =NULL , + .ack =NULL +};static struct irq_source_info_funcs vupdate_no_lock_irq_info_funcs = { .set =NULL , .ack =NULL
@@ -195,6 +202,13 @@ static struct irq_source_info_funcs vupdate_no_lock_irq_info_funcs = { .funcs = &vline0_irq_info_funcs\ } +#define vline2_int_entry (reg_num)\ + [DC_IRQ_SOURCE_DC1_VLINE2 + reg_num] = {\ + IRQ_REG_ENTRY(OTG, reg_num,\ + OTG_VERTICAL_INTERRUPT2_CONTROL, OTG_VERTICAL_INTERRUPT2_INT_ENABLE,\ + OTG_VERTICAL_INTERRUPT2_CONTROL, OTG_VERTICAL_INTERRUPT2_CLEAR),\ + .funcs = &vline2_irq_info_funcs\ + }#define dummy_irq_entry () \ {\ .funcs = &dummy_irq_info_funcs\
@@ -309,6 +323,8 @@ irq_source_info_dcn201[DAL_IRQ_SOURCES_NUMBER] = {dummy_irq_entry (),dummy_irq_entry (),dummy_irq_entry (), +vline2_int_entry (0 ), + vline2_int_entry(1), }; static const struct irq_service_funcs irq_service_funcs_dcn201 = {
drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c +32 -12
74 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn30/irq_service_dcn30.c +32 -12
74 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn302/irq_service_dcn302.c +31 -12
73 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn303/irq_service_dcn303.c +20 -4
@@ -46,10 +46,6 @@ static enum dc_irq_source to_dal_irq_source_dcn303(struct irq_service *irq_servireturn DC_IRQ_SOURCE_VBLANK1 ;case DCN_1_0__SRCID__DC_D2_OTG_VSTARTUP :return DC_IRQ_SOURCE_VBLANK2 ; -case DCN_1_0__SRCID__OTG1_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC1_VLINE0 ; -case DCN_1_0__SRCID__OTG2_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC2_VLINE0 ;case DCN_1_0__SRCID__HUBP0_FLIP_INTERRUPT :return DC_IRQ_SOURCE_PFLIP1 ;case DCN_1_0__SRCID__HUBP1_FLIP_INTERRUPT :
@@ -59,6 +55,11 @@ static enum dc_irq_source to_dal_irq_source_dcn303(struct irq_service *irq_servicase DCN_1_0__SRCID__OTG1_IHC_V_UPDATE_NO_LOCK_INTERRUPT :return DC_IRQ_SOURCE_VUPDATE2 ; +case DCN_VINT_SRCID (1 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (1 , ext_id); +case DCN_VINT_SRCID (2 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (2 , ext_id); +case DCN_1_0__SRCID__DC_HPD1_INT :/* generic src_id for all HPD and HPDRX interrupts */ switch (ext_id) {
@@ -110,6 +111,11 @@ static struct irq_source_info_funcs vline0_irq_info_funcs = { .ack = NULL }; +static struct irq_source_info_funcs vline2_irq_info_funcs = { + .set =NULL , + .ack =NULL +}; +#undef BASE_INNER#define BASE_INNER (seg) DCN_BASE__INST0_SEG ## seg
@@ -186,6 +192,14 @@ static struct irq_source_info_funcs vline0_irq_info_funcs = { .funcs = &vline0_irq_info_funcs\ } +#define vline2_int_entry (reg_num)\ + [DC_IRQ_SOURCE_DC1_VLINE2 + reg_num] = {\ + IRQ_REG_ENTRY(OTG, reg_num,\ + OTG_VERTICAL_INTERRUPT2_CONTROL, OTG_VERTICAL_INTERRUPT2_INT_ENABLE,\ + OTG_VERTICAL_INTERRUPT2_CONTROL, OTG_VERTICAL_INTERRUPT2_CLEAR),\ + .funcs = &vline2_irq_info_funcs\ + } +#define dummy_irq_entry () { .funcs = &dummy_irq_info_funcs }#define i2c_int_entry (reg_num) \
@@ -260,6 +274,8 @@ static const struct irq_source_info irq_source_info_dcn303[DAL_IRQ_SOURCES_NUMBEvblank_int_entry (1 ),vline0_int_entry (0 ),vline0_int_entry (1 ), +vline2_int_entry (0 ), + vline2_int_entry(1), }; static const struct irq_service_funcs irq_service_funcs_dcn303 = {
drivers/gpu/drm/amd/display/dc/irq/dcn31/irq_service_dcn31.c +32 -12
74 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn314/irq_service_dcn314.c +32 -12
74 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn315/irq_service_dcn315.c +32 -12
74 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn32/irq_service_dcn32.c +14 -12
@@ -57,18 +57,6 @@ static enum dc_irq_source to_dal_irq_source_dcn32(return DC_IRQ_SOURCE_VBLANK5 ;case DCN_1_0__SRCID__DC_D6_OTG_VSTARTUP :return DC_IRQ_SOURCE_VBLANK6 ; -case DCN_1_0__SRCID__OTG1_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC1_VLINE0 ; -case DCN_1_0__SRCID__OTG2_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC2_VLINE0 ; -case DCN_1_0__SRCID__OTG3_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC3_VLINE0 ; -case DCN_1_0__SRCID__OTG4_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC4_VLINE0 ; -case DCN_1_0__SRCID__OTG5_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC5_VLINE0 ; -case DCN_1_0__SRCID__OTG6_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC6_VLINE0 ;case DCN_1_0__SRCID__HUBP0_FLIP_INTERRUPT :return DC_IRQ_SOURCE_PFLIP1 ;case DCN_1_0__SRCID__HUBP1_FLIP_INTERRUPT :
@@ -95,6 +83,20 @@ static enum dc_irq_source to_dal_irq_source_dcn32(return DC_IRQ_SOURCE_VUPDATE6 ;case DCN_1_0__SRCID__DMCUB_OUTBOX_LOW_PRIORITY_READY_INT :return DC_IRQ_SOURCE_DMCUB_OUTBOX ; + +case DCN_VINT_SRCID (1 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (1 , ext_id); +case DCN_VINT_SRCID (2 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (2 , ext_id); +case DCN_VINT_SRCID (3 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (3 , ext_id); +case DCN_VINT_SRCID (4 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (4 , ext_id); +case DCN_VINT_SRCID (5 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (5 , ext_id); +case DCN_VINT_SRCID (6 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (6 , ext_id); +case DCN_1_0__SRCID__DC_HPD1_INT :/* generic src_id for all HPD and HPDRX interrupts */ switch (ext_id) {
drivers/gpu/drm/amd/display/dc/irq/dcn35/irq_service_dcn35.c +29 -12
71 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn351/irq_service_dcn351.c +29 -14
79 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn36/irq_service_dcn36.c +29 -12
71 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/irq/dcn401/irq_service_dcn401.c +13 -12
@@ -36,18 +36,6 @@ static enum dc_irq_source to_dal_irq_source_dcn401(return DC_IRQ_SOURCE_VBLANK5 ;case DCN_1_0__SRCID__DC_D6_OTG_VSTARTUP :return DC_IRQ_SOURCE_VBLANK6 ; -case DCN_1_0__SRCID__OTG1_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC1_VLINE0 ; -case DCN_1_0__SRCID__OTG2_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC2_VLINE0 ; -case DCN_1_0__SRCID__OTG3_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC3_VLINE0 ; -case DCN_1_0__SRCID__OTG4_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC4_VLINE0 ; -case DCN_1_0__SRCID__OTG5_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC5_VLINE0 ; -case DCN_1_0__SRCID__OTG6_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC6_VLINE0 ;case DCN_1_0__SRCID__HUBP0_FLIP_INTERRUPT :return DC_IRQ_SOURCE_PFLIP1 ;case DCN_1_0__SRCID__HUBP1_FLIP_INTERRUPT :
@@ -75,6 +63,19 @@ static enum dc_irq_source to_dal_irq_source_dcn401(case DCN_1_0__SRCID__DMCUB_OUTBOX_LOW_PRIORITY_READY_INT :return DC_IRQ_SOURCE_DMCUB_OUTBOX ; +case DCN_VINT_SRCID (1 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (1 , ext_id); +case DCN_VINT_SRCID (2 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (2 , ext_id); +case DCN_VINT_SRCID (3 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (3 , ext_id); +case DCN_VINT_SRCID (4 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (4 , ext_id); +case DCN_VINT_SRCID (5 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (5 , ext_id); +case DCN_VINT_SRCID (6 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (6 , ext_id); +case DCN_1_0__SRCID__DC_HPD1_INT :/* generic src_id for all HPD and HPDRX interrupts */ switch (ext_id) {
drivers/gpu/drm/amd/display/dc/irq/dcn42/irq_service_dcn42.c +14 -12
@@ -35,18 +35,6 @@ static enum dc_irq_source to_dal_irq_source_dcn42(return DC_IRQ_SOURCE_VBLANK5 ;case DCN_1_0__SRCID__DC_D6_OTG_VSTARTUP :return DC_IRQ_SOURCE_VBLANK6 ; -case DCN_1_0__SRCID__OTG1_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC1_VLINE0 ; -case DCN_1_0__SRCID__OTG2_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC2_VLINE0 ; -case DCN_1_0__SRCID__OTG3_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC3_VLINE0 ; -case DCN_1_0__SRCID__OTG4_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC4_VLINE0 ; -case DCN_1_0__SRCID__OTG5_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC5_VLINE0 ; -case DCN_1_0__SRCID__OTG6_VERTICAL_INTERRUPT0_CONTROL : -return DC_IRQ_SOURCE_DC6_VLINE0 ;case DCN_1_0__SRCID__HUBP0_FLIP_INTERRUPT :return DC_IRQ_SOURCE_PFLIP1 ;case DCN_1_0__SRCID__HUBP1_FLIP_INTERRUPT :
@@ -73,6 +61,20 @@ static enum dc_irq_source to_dal_irq_source_dcn42(return DC_IRQ_SOURCE_VUPDATE6 ;case DCN_1_0__SRCID__DMCUB_OUTBOX_LOW_PRIORITY_READY_INT :return DC_IRQ_SOURCE_DMCUB_OUTBOX ; + +case DCN_VINT_SRCID (1 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (1 , ext_id); +case DCN_VINT_SRCID (2 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (2 , ext_id); +case DCN_VINT_SRCID (3 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (3 , ext_id); +case DCN_VINT_SRCID (4 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (4 , ext_id); +case DCN_VINT_SRCID (5 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (5 , ext_id); +case DCN_VINT_SRCID (6 ,0 ): +return DCN_VINT_TO_DC_IRQSRC (6 , ext_id); +case DCN_1_0__SRCID__DC_HPD1_INT :/* generic src_id for all HPD and HPDRX interrupts */ switch (ext_id) {
drivers/gpu/drm/amd/display/dc/irq/irq_service.h +18 -0
@@ -30,6 +30,24 @@#include "irq_types.h" +/* +* Helper to get vertical interrupt src/ctx id by OTG instance and vint number +*/ +#define DCN_VINT_SRCID (otg_inst, vint_num) \ + DCN_1_0__SRCID__OTG ## otg_inst ## _VERTICAL_INTERRUPT ## vint_num ## _CONTROL +#define DCN_VINT_CTXID (otg_inst, vint_num) \ + DCN_1_0__CTXID__OTG ## otg_inst ## _VERTICAL_INTERRUPT ## vint_num ## _CONTROL +#define DC_VINT_IRQSRC (otg_inst, vint_num) \ + DC_IRQ_SOURCE_DC ## otg_inst ## _VLINE ## vint_num + +/* Helper to map vertical interrupt src/ctx id to DC irq source enum */ +#define DCN_VINT_TO_DC_IRQSRC (otg_inst, ext_id) ( \ + (ext_id) == DCN_VINT_CTXID(otg_inst, 0) ? DC_VINT_IRQSRC(otg_inst, 0) : \ + (ext_id) == DCN_VINT_CTXID(otg_inst, 1) ? DC_VINT_IRQSRC(otg_inst, 1) : \ + (ext_id) == DCN_VINT_CTXID(otg_inst, 2) ? DC_VINT_IRQSRC(otg_inst, 2) : \ + DC_IRQ_SOURCE_INVALID \ +) +struct irq_service ;struct irq_source_info ;
Signature · 1 line
2.53.0
[email protected]
maintainerPATCH v2 3/3 drm/amd/display: Check for flip completion in OTG interrupt handlers
In reply to [email protected]From: Leo Li <[email protected]>
[Why]
HUBP fires the pflip interrupt when it consumes the last programmed flip address. However, when it is in dynamic power gating (DPG), the pflip interrupt can be masked. If the flip addr is programmed prior to HUBP fully exiting DPG, the pflip interrupt may never fire.
This was observed on some PSR systems, where PSR exit in FW did not fully complete before programming the flip address.
[How]
DC has a function for checking the flip status of a plane. DM can consult it in one of the OTG interrupts -- which will fire regardless of HUBP status -- as a backup for delivering events.
First, DM needs to track the dc_plane on which the flip was programmed. Introduce a dc_plane_state flip_target on the acrtc to do so, following the existing acrtc->pflip_status lifecycle.
Then, in the OTG interrupt handlers, check if the flip_target plane has any pending flips. If a flip was armed, and there aren't any pending flips (indicating that HUBP consumed the new flip addr but did not deliver a pflip interrupt), then deliver and clear the armed flip.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 63 +++++++++++++++++-- .../display/amdgpu_dm/amdgpu_dm_irq_params.h | 8 +++ 2 files changed, 67 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +59 -4
@@ -427,6 +427,23 @@ static inline bool update_planes_and_stream_adapter(struct dc *dc, stream_update); } +/** +* clear_flip_isr - clear armed flip after it's been handled +* +* See also prepare_flip_isr. +*/ +static void clear_flip_isr (struct amdgpu_crtc *acrtc) +{ +assert_spin_locked (&acrtc->base.dev->event_lock); + +WARN_ON (acrtc->pflip_status ==AMDGPU_FLIP_NONE ); +WARN_ON (acrtc->dm_irq_params.flip_target ==NULL ); + + acrtc->pflip_status =AMDGPU_FLIP_NONE ; +dc_plane_state_release (acrtc->dm_irq_params.flip_target); + acrtc->dm_irq_params.flip_target =NULL ; +} +/** * dm_pflip_high_irq() - Handle pageflip interrupt * @interrupt_params: ignored
@@ -523,7 +540,8 @@ static void dm_pflip_high_irq(void *interrupt_params) amdgpu_crtc->dm_irq_params.last_flip_vblank =amdgpu_get_vblank_counter_kms (&amdgpu_crtc->base); - amdgpu_crtc->pflip_status =AMDGPU_FLIP_NONE ; +clear_flip_isr (amdgpu_crtc); +spin_unlock_irqrestore (&adev_to_drm (adev)->event_lock, flags); drm_dbg_state(dev,
@@ -750,7 +768,37 @@ static void __dm_crtc_high_irq(void *interrupt_params, acrtc->event =NULL ;drm_crtc_vblank_put (&acrtc->base); } - acrtc->pflip_status =AMDGPU_FLIP_NONE ; +clear_flip_isr (acrtc); + } + +/* +* If pflip irq failed to fire (possible if HW master update lock is +* held, or HUBP was in DPG when flip was programmed), check if HUBP +* consumed the fb addr. If so, send the event here. +* +* Not applicable to DCE HW with no pflip interrupts. +*/ +if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) !=0 && + acrtc->pflip_status ==AMDGPU_FLIP_SUBMITTED ) { +const struct dc_plane_status *status; +union dc_plane_status_update_flags flags = {0 }; + + flags.bits.address =1 ; +/* +* Note that dc_plane_get_status() has a built-in IPS exit from +* non-sleep context. That's ok though, since if interrupts are +* active, then HW is not in IPS. Otherwise, this would have +* been illegal. +*/ + status =dc_plane_get_status (acrtc->dm_irq_params.flip_target, + flags); + +if (!status->is_flip_pending && acrtc->event) { +drm_crtc_send_vblank_event (&acrtc->base, acrtc->event); + acrtc->event =NULL ; +drm_crtc_vblank_put (&acrtc->base); + } +clear_flip_isr (acrtc); }spin_unlock_irqrestore (&adev_to_drm (adev)->event_lock, flags);
@@ -9792,7 +9840,8 @@ static void remove_stream(struct amdgpu_device *adev, acrtc->enabled = false; } -static void prepare_flip_isr (struct amdgpu_crtc *acrtc) +static void prepare_flip_isr (struct amdgpu_crtc *acrtc, +struct dc_plane_state *flip_target) {assert_spin_locked (&acrtc->base.dev->event_lock);
@@ -9806,6 +9855,9 @@ static void prepare_flip_isr(struct amdgpu_crtc *acrtc)/* Mark this event as consumed */ acrtc->base.state->event =NULL ; +dc_plane_state_retain (flip_target); + acrtc->dm_irq_params.flip_target = flip_target; +drm_dbg_state (acrtc->base.dev,"crtc:%d, pflip_stat:AMDGPU_FLIP_SUBMITTED\n" , acrtc->crtc_id);
@@ -10162,6 +10214,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,struct dm_crtc_state *acrtc_state =to_dm_crtc_state (new_pcrtc_state);struct dm_crtc_state *dm_old_crtc_state =to_dm_crtc_state (drm_atomic_get_old_crtc_state (state, pcrtc)); +struct dc_plane_state *flip_target =NULL ;int planes_count =0 , vpos, hpos;unsigned long flags;u32 target_vblank, last_flip_vblank;
@@ -10269,6 +10322,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,continue ; } + flip_target = dc_plane; + fill_dc_plane_info_and_addr( dm->adev, new_plane_state, afb->tiling_flags,
@@ -10414,7 +10469,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,spin_lock_irqsave (&pcrtc->dev->event_lock, flags);WARN_ON (acrtc_attach->pflip_status !=AMDGPU_FLIP_NONE ); -prepare_flip_isr (acrtc_attach); +prepare_flip_isr (acrtc_attach, flip_target);spin_unlock_irqrestore (&pcrtc->dev->event_lock, flags); }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq_params.h +8 -0
@@ -33,6 +33,14 @@ struct dm_irq_params {u32 last_flip_vblank;struct mod_vrr_params vrr_params;struct dc_stream_state *stream; + +/* +* If not NULL, the plane for which a flip interrupt is expected. For +* multi-plane configurations, this should be a plane that had it's fb +* address updated. See also &prepare_flip_isr() and &clear_flip_isr() +*/ +struct dc_plane_state *flip_target; +int active_planes;bool allow_sr_entry;struct mod_freesync_config freesync_config;
Signature · 1 line
2.53.0