DC Patches August 13, 2021
Subsystems (3)
cover DC Patches August 13, 2021
This DC patchset brings improvements in multiple areas. In summary, we highlight:
* Ensure DCN save init registers after VM setup
* Fix multi-display support for idle opt workqueue
* Use vblank control events for PSR enable/disable
* Create default dc_sink when fail reading EDID under MST
---
Anthony Koo (1):
drm/amd/display: [FW Promotion] Release 0.0.79
Aric Cyr (1):
drm/amd/display: 3.2.149
Jake Wang (1):
drm/amd/display: Ensure DCN save after VM setup
Nicholas Kazlauskas (3):
drm/amd/display: Fix multi-display support for idle opt workqueue drm/amd/display: Use vblank control events for PSR enable/disable drm/amd/display: Guard vblank wq flush with DCN guards
Wayne Lin (1):
drm/amd/display: Create dc_sink when EDID fail
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 112 +++++++++++------- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 23 ++-- .../display/amdgpu_dm/amdgpu_dm_irq_params.h | 1 + .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 23 ++++ drivers/gpu/drm/amd/display/dc/core/dc.c | 6 + .../drm/amd/display/dc/core/dc_vm_helper.c | 3 + drivers/gpu/drm/amd/display/dc/dc.h | 3 +- .../drm/amd/display/dc/dcn31/dcn31_hwseq.c | 12 ++ .../drm/amd/display/dc/dcn31/dcn31_hwseq.h | 1 + .../gpu/drm/amd/display/dc/dcn31/dcn31_init.c | 1 + .../gpu/drm/amd/display/dc/inc/hw_sequencer.h | 1 + .../gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 19 ++- 12 files changed, 148 insertions(+), 57 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/7 drm/amd/display: Create dc_sink when EDID fail
[Why]
While reading remote EDID via Startech 1-to-4 hub, occasionally we won't get response in time and won't light up corresponding monitor.
Ideally, we can still add generic modes for userspace to choose to try to light up the monitor and which is done in drm_helper_probe_single_connector_modes(). So the main problem here is that we fail .mode_valid since we don't create remote dc_sink for this case.
[How]
Also add default dc_sink if we can't get the EDID.
--- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +23 -0
@@ -213,6 +213,29 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)drm_connector_update_edid_property ( &aconnector->base,NULL ); + +DRM_DEBUG_KMS ("Can't get EDID of %s. Add default remote sink." , connector->name); +if (!aconnector->dc_sink) { +struct dc_sink *dc_sink; +struct dc_sink_init_data init_params = { + .link = aconnector->dc_link, + .sink_signal =SIGNAL_TYPE_DISPLAY_PORT_MST }; + + dc_sink =dc_link_add_remote_sink ( + aconnector->dc_link, +NULL , +0 , + &init_params); + +if (!dc_sink) { +DRM_ERROR ("Unable to add a remote sink\n" ); +return 0 ; + } + + dc_sink->priv = aconnector; + aconnector->dc_sink = dc_sink; + } +return ret; }
Signature · 1 line
2.25.1
PATCH 2/7 drm/amd/display: Fix multi-display support for idle opt workqueue
In reply to Wayne LinFrom: Nicholas Kazlauskas <[email protected]>
[Why]
The current implementation for idle optimization support only has a single work item that gets reshuffled into the system workqueue whenever we receive an enable or disable event.
We can have mismatched events if the work hasn't been processed or if we're getting control events from multiple displays at once.
This fixes this issue and also makes the implementation usable for PSR control - which will be addressed in another patch.
[How]
We need to be able to flush remaining work out on demand for driver stop and psr disable so create a driver specific workqueue instead of using the system one. The workqueue will be single threaded to guarantee the ordering of enable/disable events.
Refactor the queue to allocate the control work and deallocate it after processing it.
Pass the acrtc directly to make it easier to handle psr enable/disable in a later patch.
Rename things to indicate that it's not just MALL specific.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 62 ++++++++----------- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 21 ++++--- 2 files changed, 36 insertions(+), 47 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +25 -37
@@ -1044,10 +1044,10 @@ static void mmhub_read_system_context(struct amdgpu_device *adev, struct dc_phy_ }#endif #if defined(CONFIG_DRM_AMD_DC_DCN ) -static void event_mall_stutter (struct work_struct *work) +static void vblank_control_worker (struct work_struct *work) { - - struct vblank_workqueue *vblank_work = container_of(work, struct vblank_workqueue, mall_work); +struct vblank_control_work *vblank_work = + container_of(work, struct vblank_control_work, work);struct amdgpu_display_manager *dm = vblank_work->dm;mutex_lock (&dm->dc_lock);
@@ -1062,22 +1062,9 @@ static void event_mall_stutter(struct work_struct *work)DRM_DEBUG_KMS ("Allow idle optimizations (MALL): %d\n" , dm->active_vblank_irq_count ==0 );mutex_unlock (&dm->dc_lock); + kfree(vblank_work); } -static struct vblank_workqueue *vblank_create_workqueue (struct amdgpu_device *adev,struct dc *dc) -{ -struct vblank_workqueue *vblank_work; - - vblank_work =kzalloc (sizeof (*vblank_work),GFP_KERNEL ); -if (ZERO_OR_NULL_PTR (vblank_work)) { -kfree (vblank_work); -return NULL ; - } - -INIT_WORK (&vblank_work->mall_work, event_mall_stutter); - -return vblank_work; -}#endif static int amdgpu_dm_init (struct amdgpu_device *adev) {
@@ -1220,12 +1207,10 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)#if defined(CONFIG_DRM_AMD_DC_DCN )if (adev->dm.dc->caps.max_links >0 ) { - adev->dm.vblank_workqueue =vblank_create_workqueue (adev, adev->dm.dc); - -if (!adev->dm.vblank_workqueue) + adev->dm.vblank_control_workqueue = +create_singlethread_workqueue ("dm_vblank_control_workqueue" ); +if (!adev->dm.vblank_control_workqueue)DRM_ERROR ("amdgpu: failed to initialize vblank_workqueue.\n" ); -else -DRM_DEBUG_DRIVER ("amdgpu: vblank_workqueue init done %p.\n" , adev->dm.vblank_workqueue); }#endif
@@ -1298,6 +1283,13 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev) {int i; +#if defined(CONFIG_DRM_AMD_DC_DCN ) +if (adev->dm.vblank_control_workqueue) { +destroy_workqueue (adev->dm.vblank_control_workqueue); + adev->dm.vblank_control_workqueue =NULL ; + } +#endif +for (i =0 ; i < adev->dm.display_indexes_num; i++) {drm_encoder_cleanup (&adev->dm.mst_encoders[i].base); }
@@ -1321,14 +1313,6 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev)dc_deinit_callbacks (adev->dm.dc);#endif -#if defined(CONFIG_DRM_AMD_DC_DCN ) -if (adev->dm.vblank_workqueue) { - adev->dm.vblank_workqueue->dm =NULL ; -kfree (adev->dm.vblank_workqueue); - adev->dm.vblank_workqueue =NULL ; - } -#endif -dc_dmub_srv_destroy (&adev->dm.dc->ctx->dmub_srv);if (dc_enable_dmub_notifications (adev->dm.dc)) {
@@ -6000,7 +5984,7 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)struct dm_crtc_state *acrtc_state =to_dm_crtc_state (crtc->state);#if defined(CONFIG_DRM_AMD_DC_DCN )struct amdgpu_display_manager *dm = &adev->dm; -unsigned long flags; +struct vblank_control_work *work;#endif int rc =0 ;
@@ -6025,12 +6009,16 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)return 0 ;#if defined(CONFIG_DRM_AMD_DC_DCN ) -spin_lock_irqsave (&dm->vblank_lock, flags); - dm->vblank_workqueue->dm = dm; - dm->vblank_workqueue->otg_inst = acrtc->otg_inst; - dm->vblank_workqueue->enable = enable; -spin_unlock_irqrestore (&dm->vblank_lock, flags); -schedule_work (&dm->vblank_workqueue->mall_work); + work =kzalloc (sizeof (*work),GFP_ATOMIC ); +if (!work) +return -ENOMEM ; + +INIT_WORK (&work->work, vblank_control_worker); + work->dm = dm; + work->acrtc = acrtc; + work->enable = enable; + +queue_work (dm->vblank_control_workqueue, &work->work);#endif return 0 ;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +11 -10
@@ -60,6 +60,7 @@ enum aux_return_code_type;/* Forward declarations */ struct amdgpu_device ; +struct amdgpu_crtc ;struct drm_device ;struct dc ;struct amdgpu_bo ;
@@ -86,16 +87,16 @@ struct dm_compressor_info { };/** -* struct vblank_workqueue - Works to be executed in a separate thread during vblank -* @mall_work: work for mall stutter +* struct vblank_control_work - Work data for vblank control +* @work: Kernel work data for the work event * @dm: amdgpu display manager device -* @otg_inst: otg instance of which vblank is being set -* @enable: true if enable vblank +* @acrtc: amdgpu CRTC instance for which the event has occurred +* @enable: true if enabling vblank */ -struct vblank_workqueue { -struct work_struct mall_work; +struct vblank_control_work { +struct work_struct work;struct amdgpu_display_manager *dm; -int otg_inst; +struct amdgpu_crtc *acrtc;bool enable; };
@@ -380,11 +381,11 @@ struct amdgpu_display_manager {#if defined(CONFIG_DRM_AMD_DC_DCN )/** -* @vblank_workqueue: +* @vblank_control_workqueue: * -* amdgpu workqueue during vblank +* Deferred work for vblank control events. */ -struct vblank_workqueue *vblank_workqueue; +struct workqueue_struct *vblank_control_workqueue;#endif struct drm_atomic_state *cached_state;
Signature · 1 line
2.25.1
PATCH 3/7 drm/amd/display: Use vblank control events for PSR enable/disable
In reply to Wayne LinFrom: Nicholas Kazlauskas <[email protected]>
[Why]
PSR can disable the HUBP along with the OTG when PSR is active.
We'll hit a pageflip timeout when the OTG is disable because we're no longer updating the CRTC vblank counter and the pflip high IRQ will not fire on the flip.
In order to flip the page flip timeout occur we should modify the enter/exit conditions to match DRM requirements.
[How]
Use our deferred handlers for DRM vblank control to notify DMCU(B) when it can enable or disable PSR based on whether vblank is disabled or enabled respectively.
We'll need to pass along the stream with the notification now because we want to access the CRTC state while the CRTC is locked to get the stream state prior to the commit.
Retain a reference to the stream so it remains safe to continue to access and release that reference once we're done with it.
Enable/disable logic follows what we were previously doing in update_planes.
The workqueue has to be flushed before programming streams or planes to ensure that we exit out of idle optimizations and PSR before these events occur if necessary.
To keep the skip count logic the same to avoid FBCON PSR enablement requires copying the allow condition onto the DM IRQ parameters - a field that we can actually access from the worker.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 48 +++++++++++++++---- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 2 + .../display/amdgpu_dm/amdgpu_dm_irq_params.h | 1 + 3 files changed, 43 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +40 -8
@@ -1061,7 +1061,22 @@ static void vblank_control_worker(struct work_struct *work)DRM_DEBUG_KMS ("Allow idle optimizations (MALL): %d\n" , dm->active_vblank_irq_count ==0 ); +/* Control PSR based on vblank requirements from OS */ +if (vblank_work->stream && vblank_work->stream->link) { +if (vblank_work->enable) { +if (vblank_work->stream->link->psr_settings.psr_allow_active) +amdgpu_dm_psr_disable (vblank_work->stream); + }else if (vblank_work->stream->link->psr_settings.psr_feature_enabled && + !vblank_work->stream->link->psr_settings.psr_allow_active && + vblank_work->acrtc->dm_irq_params.allow_psr_entry) { +amdgpu_dm_psr_enable (vblank_work->stream); + } + } +mutex_unlock (&dm->dc_lock); + +dc_stream_release (vblank_work->stream); +kfree (vblank_work); }
@@ -6018,6 +6033,11 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable) work->acrtc = acrtc; work->enable = enable; +if (acrtc_state->stream) { +dc_stream_retain (acrtc_state->stream); + work->stream = acrtc_state->stream; + } +queue_work (dm->vblank_control_workqueue, &work->work);#endif
@@ -8623,6 +8643,12 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,/* Update the planes if changed or disable if we don't have any. */ if ((planes_count || acrtc_state->active_planes ==0 ) && acrtc_state->stream) { +/* +* If PSR or idle optimizations are enabled then flush out +* any pending work before hardware programming. +*/ +flush_workqueue (dm->vblank_control_workqueue); + bundle->stream_update.stream = acrtc_state->stream;if (new_pcrtc_state->mode_changed) { bundle->stream_update.src = acrtc_state->stream->src;
@@ -8691,16 +8717,20 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, acrtc_state->stream->link->psr_settings.psr_version != DC_PSR_VERSION_UNSUPPORTED && !acrtc_state->stream->link->psr_settings.psr_feature_enabled)amdgpu_dm_link_setup_psr (acrtc_state->stream); - else if ((acrtc_state->update_type == UPDATE_TYPE_FAST) && - acrtc_state->stream->link->psr_settings.psr_feature_enabled && - !acrtc_state->stream->link->psr_settings.psr_allow_active) { -struct amdgpu_dm_connector *aconn = (struct amdgpu_dm_connector *) - acrtc_state->stream->dm_stream_context; + +/* Decrement skip count when PSR is enabled and we're doing fast updates. */ +if (acrtc_state->update_type ==UPDATE_TYPE_FAST && + acrtc_state->stream->link->psr_settings.psr_feature_enabled) { +struct amdgpu_dm_connector *aconn = + (struct amdgpu_dm_connector *)acrtc_state->stream->dm_stream_context;if (aconn->psr_skip_count >0 ) aconn->psr_skip_count--; -else -amdgpu_dm_psr_enable (acrtc_state->stream); + +/* Allow PSR when skip count is 0. */ + acrtc_attach->dm_irq_params.allow_psr_entry = !aconn->psr_skip_count; + }else { + acrtc_attach->dm_irq_params.allow_psr_entry = false; }mutex_unlock (&dm->dc_lock);
@@ -8949,8 +8979,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)if (dc_state) {/* if there mode set or reset, disable eDP PSR */ -if (mode_set_reset_required) +if (mode_set_reset_required) { +flush_workqueue (dm->vblank_control_workqueue);amdgpu_dm_psr_disable_all (dm); + }dm_enable_per_frame_crtc_master_sync (dc_state);mutex_lock (&dm->dc_lock);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2 -0
@@ -91,12 +91,14 @@ struct dm_compressor_info {* @work: Kernel work data for the work event * @dm: amdgpu display manager device * @acrtc: amdgpu CRTC instance for which the event has occurred +* @stream: DC stream for which the event has occurred * @enable: true if enabling vblank */ struct vblank_control_work {struct work_struct work;struct amdgpu_display_manager *dm;struct amdgpu_crtc *acrtc; +struct dc_stream_state *stream;bool enable; };
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq_params.h +1 -0
@@ -33,6 +33,7 @@ struct dm_irq_params {struct mod_vrr_params vrr_params;struct dc_stream_state *stream;int active_planes; +bool allow_psr_entry;struct mod_freesync_config freesync_config;#ifdef CONFIG_DEBUG_FS
Signature · 1 line
2.25.1
Re: [PATCH 3/7] drm/amd/display: Use vblank control events for PSR enable/disable
Hi
This patch is causing issues on my PRIME system
I've opened https://gitlab.freedesktop.org/drm/amd/-/issues/1700 to track
Cheers
Mike
Quoted 171 lines · Wayne Lin
From: Nicholas Kazlauskas <[email protected]>
[Why]
PSR can disable the HUBP along with the OTG when PSR is active.We'll hit a pageflip timeout when the OTG is disable because we're no longer updating the CRTC vblank counter and the pflip high IRQ will not fire on the flip.
In order to flip the page flip timeout occur we should modify the enter/exit conditions to match DRM requirements.
[How]
Use our deferred handlers for DRM vblank control to notify DMCU(B) when it can enable or disable PSR based on whether vblank is disabled or enabled respectively.We'll need to pass along the stream with the notification now because we want to access the CRTC state while the CRTC is locked to get the stream state prior to the commit.
Retain a reference to the stream so it remains safe to continue to access and release that reference once we're done with it.
Enable/disable logic follows what we were previously doing in
update_planes.The workqueue has to be flushed before programming streams or planes to ensure that we exit out of idle optimizations and PSR before these events occur if necessary.
To keep the skip count logic the same to avoid FBCON PSR enablement requires copying the allow condition onto the DM IRQ parameters - a field that we can actually access from the worker.
Reviewed-by Roman Li <[email protected]>Acked-by Wayne Lin <[email protected]>Signed-off-by Nicholas Kazlauskas <[email protected]>--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 48 +++++++++++++++---- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 2 + .../display/amdgpu_dm/amdgpu_dm_irq_params.h | 1 + 3 files changed, 43 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +40
-8@@ -1061,7 +1061,22 @@ static void vblank_control_worker(struct work_struct *work)DRM_DEBUG_KMS ("Allow idle optimizations (MALL): %d\n" , dm->active_vblank_irq_count ==0 ); +/* Control PSR based on vblank requirements from OS */ +if (vblank_work->stream && vblank_work->stream->link) { +if (vblank_work->enable) { +if (vblank_work->stream->link->psr_settings.psr_allow_active) +amdgpu_dm_psr_disable (vblank_work->stream); + }else if (vblank_work->stream->link->psr_settings.psr_feature_enabled && + !vblank_work->stream->link->psr_settings.psr_allow_active && + vblank_work->acrtc->dm_irq_params.allow_psr_entry) { +amdgpu_dm_psr_enable (vblank_work->stream); + } + } +mutex_unlock (&dm->dc_lock); + +dc_stream_release (vblank_work->stream); +kfree (vblank_work); }@@ -6018,6 +6033,11 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable) work->acrtc = acrtc; work->enable = enable; +if (acrtc_state->stream) { +dc_stream_retain (acrtc_state->stream); + work->stream = acrtc_state->stream; + } +queue_work (dm->vblank_control_workqueue, &work->work);#endif @@ -8623,6 +8643,12 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,/* Update the planes if changed or disable if we don't have any. */ if ((planes_count || acrtc_state->active_planes ==0 ) && acrtc_state->stream) { +/* +* If PSR or idle optimizations are enabled then flush out +* any pending work before hardware programming. +*/ +flush_workqueue (dm->vblank_control_workqueue); + bundle->stream_update.stream = acrtc_state->stream;if (new_pcrtc_state->mode_changed) { bundle->stream_update.src = acrtc_state->stream->src;@@ -8691,16 +8717,20 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, acrtc_state->stream->link->psr_settings.psr_version != DC_PSR_VERSION_UNSUPPORTED && !acrtc_state->stream->link->psr_settings.psr_feature_enabled)amdgpu_dm_link_setup_psr (acrtc_state->stream); - else if ((acrtc_state->update_type == UPDATE_TYPE_FAST) && - acrtc_state->stream->link->psr_settings.psr_feature_enabled && - !acrtc_state->stream->link->psr_settings.psr_allow_active) { -struct amdgpu_dm_connector *aconn = (struct amdgpu_dm_connector *) - acrtc_state->stream->dm_stream_context; + +/* Decrement skip count when PSR is enabled and we're doing fast updates. */ +if (acrtc_state->update_type ==UPDATE_TYPE_FAST && + acrtc_state->stream->link->psr_settings.psr_feature_enabled) { +struct amdgpu_dm_connector *aconn = + (struct amdgpu_dm_connector *)acrtc_state->stream->dm_stream_context;if (aconn->psr_skip_count >0 ) aconn->psr_skip_count--; -else -amdgpu_dm_psr_enable (acrtc_state->stream); + +/* Allow PSR when skip count is 0. */ + acrtc_attach->dm_irq_params.allow_psr_entry = !aconn->psr_skip_count; + }else { + acrtc_attach->dm_irq_params.allow_psr_entry = false; }mutex_unlock (&dm->dc_lock);@@ -8949,8 +8979,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)if (dc_state) {/* if there mode set or reset, disable eDP PSR */ -if (mode_set_reset_required) +if (mode_set_reset_required) { +flush_workqueue (dm->vblank_control_workqueue);amdgpu_dm_psr_disable_all (dm); + }dm_enable_per_frame_crtc_master_sync (dc_state);mutex_lock (&dm->dc_lock);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2
-0@@ -91,12 +91,14 @@ struct dm_compressor_info {* @work: Kernel work data for the work event * @dm: amdgpu display manager device * @acrtc: amdgpu CRTC instance for which the event has occurred +* @stream: DC stream for which the event has occurred * @enable: true if enabling vblank */ struct vblank_control_work {struct work_struct work;struct amdgpu_display_manager *dm;struct amdgpu_crtc *acrtc; +struct dc_stream_state *stream;bool enable; };drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq_params.h +1
-1@@ -33,6 +33,7 @@ struct dm_irq_params {struct mod_vrr_params vrr_params;struct dc_stream_state *stream;int active_planes; +bool allow_psr_entry;struct mod_freesync_config freesync_config;#ifdef CONFIG_DEBUG_FS --2.25.1
Re: [PATCH 3/7] drm/amd/display: Use vblank control events for PSR enable/disable
Quoted 9 lines · Mike Lothian
Hi
This patch is causing issues on my PRIME system
Cheers
Mike
We don't create the workqueue on headless configs so I guess all the instances of flush need to be guarded with NULL checks first.
Thanks for reporting this!
Regards,
Nicholas Kazlauskas
Quoted 174 lines · Wayne Lin
Quoted 171 lines
From: Nicholas Kazlauskas <[email protected]>
[Why]
PSR can disable the HUBP along with the OTG when PSR is active.We'll hit a pageflip timeout when the OTG is disable because we're no longer updating the CRTC vblank counter and the pflip high IRQ will not fire on the flip.
In order to flip the page flip timeout occur we should modify the enter/exit conditions to match DRM requirements.
[How]
Use our deferred handlers for DRM vblank control to notify DMCU(B) when it can enable or disable PSR based on whether vblank is disabled or enabled respectively.We'll need to pass along the stream with the notification now because we want to access the CRTC state while the CRTC is locked to get the stream state prior to the commit.
Retain a reference to the stream so it remains safe to continue to access and release that reference once we're done with it.
Enable/disable logic follows what we were previously doing in
update_planes.The workqueue has to be flushed before programming streams or planes to ensure that we exit out of idle optimizations and PSR before these events occur if necessary.
To keep the skip count logic the same to avoid FBCON PSR enablement requires copying the allow condition onto the DM IRQ parameters - a field that we can actually access from the worker.
Reviewed-by Roman Li <[email protected]>Acked-by Wayne Lin <[email protected]>Signed-off-by Nicholas Kazlauskas <[email protected]>--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 48 +++++++++++++++---- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 2 + .../display/amdgpu_dm/amdgpu_dm_irq_params.h | 1 + 3 files changed, 43 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +40
-8@@ -1061,7 +1061,22 @@ static void vblank_control_worker(struct work_struct *work)DRM_DEBUG_KMS ("Allow idle optimizations (MALL): %d\n" , dm->active_vblank_irq_count ==0 ); +/* Control PSR based on vblank requirements from OS */ +if (vblank_work->stream && vblank_work->stream->link) { +if (vblank_work->enable) { +if (vblank_work->stream->link->psr_settings.psr_allow_active) +amdgpu_dm_psr_disable (vblank_work->stream); + }else if (vblank_work->stream->link->psr_settings.psr_feature_enabled && + !vblank_work->stream->link->psr_settings.psr_allow_active && + vblank_work->acrtc->dm_irq_params.allow_psr_entry) { +amdgpu_dm_psr_enable (vblank_work->stream); + } + } +mutex_unlock (&dm->dc_lock); + +dc_stream_release (vblank_work->stream); +kfree (vblank_work); }@@ -6018,6 +6033,11 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable) work->acrtc = acrtc; work->enable = enable; +if (acrtc_state->stream) { +dc_stream_retain (acrtc_state->stream); + work->stream = acrtc_state->stream; + } +queue_work (dm->vblank_control_workqueue, &work->work);#endif @@ -8623,6 +8643,12 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,/* Update the planes if changed or disable if we don't have any. */ if ((planes_count || acrtc_state->active_planes ==0 ) && acrtc_state->stream) { +/* +* If PSR or idle optimizations are enabled then flush out +* any pending work before hardware programming. +*/ +flush_workqueue (dm->vblank_control_workqueue); + bundle->stream_update.stream = acrtc_state->stream;if (new_pcrtc_state->mode_changed) { bundle->stream_update.src = acrtc_state->stream->src;@@ -8691,16 +8717,20 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, acrtc_state->stream->link->psr_settings.psr_version != DC_PSR_VERSION_UNSUPPORTED && !acrtc_state->stream->link->psr_settings.psr_feature_enabled)amdgpu_dm_link_setup_psr (acrtc_state->stream); - else if ((acrtc_state->update_type == UPDATE_TYPE_FAST) && - acrtc_state->stream->link->psr_settings.psr_feature_enabled && - !acrtc_state->stream->link->psr_settings.psr_allow_active) { -struct amdgpu_dm_connector *aconn = (struct amdgpu_dm_connector *) - acrtc_state->stream->dm_stream_context; + +/* Decrement skip count when PSR is enabled and we're doing fast updates. */ +if (acrtc_state->update_type ==UPDATE_TYPE_FAST && + acrtc_state->stream->link->psr_settings.psr_feature_enabled) { +struct amdgpu_dm_connector *aconn = + (struct amdgpu_dm_connector *)acrtc_state->stream->dm_stream_context;if (aconn->psr_skip_count >0 ) aconn->psr_skip_count--; -else -amdgpu_dm_psr_enable (acrtc_state->stream); + +/* Allow PSR when skip count is 0. */ + acrtc_attach->dm_irq_params.allow_psr_entry = !aconn->psr_skip_count; + }else { + acrtc_attach->dm_irq_params.allow_psr_entry = false; }mutex_unlock (&dm->dc_lock);@@ -8949,8 +8979,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)if (dc_state) {/* if there mode set or reset, disable eDP PSR */ -if (mode_set_reset_required) +if (mode_set_reset_required) { +flush_workqueue (dm->vblank_control_workqueue);amdgpu_dm_psr_disable_all (dm); + }dm_enable_per_frame_crtc_master_sync (dc_state);mutex_lock (&dm->dc_lock);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2
-0@@ -91,12 +91,14 @@ struct dm_compressor_info {* @work: Kernel work data for the work event * @dm: amdgpu display manager device * @acrtc: amdgpu CRTC instance for which the event has occurred +* @stream: DC stream for which the event has occurred * @enable: true if enabling vblank */ struct vblank_control_work {struct work_struct work;struct amdgpu_display_manager *dm;struct amdgpu_crtc *acrtc; +struct dc_stream_state *stream;bool enable; };drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq_params.h +1
-1@@ -33,6 +33,7 @@ struct dm_irq_params {struct mod_vrr_params vrr_params;struct dc_stream_state *stream;int active_planes; +bool allow_psr_entry;struct mod_freesync_config freesync_config;#ifdef CONFIG_DEBUG_FS --2.25.1
PATCH 4/7 drm/amd/display: Ensure DCN save after VM setup
In reply to Wayne LinFrom: Jake Wang <[email protected]>
[Why]
DM initializes VM context after DMCUB initialization. This results in loss of DCN_VM_CONTEXT registers after z10.
[How]
Notify DMCUB when VM setup is complete, and have DMCUB save init registers.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ++++++ drivers/gpu/drm/amd/display/dc/core/dc_vm_helper.c | 3 +++ drivers/gpu/drm/amd/display/dc/dc.h | 1 + drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c | 12 ++++++++++++ drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.h | 1 + drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c | 1 + drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h | 1 + drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 5 +++++ 8 files changed, 30 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +6 -0
@@ -1549,6 +1549,12 @@ void dc_z10_restore(struct dc *dc)if (dc->hwss.z10_restore) dc->hwss.z10_restore(dc); } + +void dc_z10_save_init (struct dc *dc) +{ +if (dc->hwss.z10_save_init) + dc->hwss.z10_save_init (dc); +}#endif /* * Applies given context to HW and copy it into current context.
drivers/gpu/drm/amd/display/dc/core/dc_vm_helper.c +3 -0
@@ -47,6 +47,9 @@ int dc_setup_system_context(struct dc *dc, struct dc_phy_addr_space_config *pa_c*/ memcpy (&dc->vm_pa_config, pa_config,sizeof (struct dc_phy_addr_space_config )); dc->vm_pa_config.valid = true; +#if defined(CONFIG_DRM_AMD_DC_DCN3_1 ) +dc_z10_save_init (dc); +#endif }return num_vmids;
drivers/gpu/drm/amd/display/dc/dc.h +1 -0
@@ -1338,6 +1338,7 @@ void dc_hardware_release(struct dc *dc);bool dc_set_psr_allow_active (struct dc *dc,bool enable);#if defined(CONFIG_DRM_AMD_DC_DCN )void dc_z10_restore (struct dc *dc); +void dc_z10_save_init (struct dc *dc);#endif bool dc_enable_dmub_notifications (struct dc *dc);
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c +12 -0
@@ -407,6 +407,18 @@ void dcn31_update_info_frame(struct pipe_ctx *pipe_ctx) &pipe_ctx->stream_res.encoder_info_frame); } } +void dcn31_z10_save_init (struct dc *dc) +{ +union dmub_rb_cmd cmd; + +memset (&cmd,0 ,sizeof (cmd)); + cmd.dcn_restore.header.type =DMUB_CMD__IDLE_OPT ; + cmd.dcn_restore.header.sub_type =DMUB_CMD__IDLE_OPT_DCN_SAVE_INIT ; + +dc_dmub_srv_cmd_queue (dc->ctx->dmub_srv, &cmd); +dc_dmub_srv_cmd_execute (dc->ctx->dmub_srv); +dc_dmub_srv_wait_idle (dc->ctx->dmub_srv); +}void dcn31_z10_restore (struct dc *dc) {
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.h +1 -0
@@ -44,6 +44,7 @@ void dcn31_enable_power_gating_plane(void dcn31_update_info_frame (struct pipe_ctx *pipe_ctx);void dcn31_z10_restore (struct dc *dc); +void dcn31_z10_save_init (struct dc *dc);void dcn31_hubp_pg_control (struct dce_hwseq *hws,unsigned int hubp_inst,bool power_on);int dcn31_init_sys_ctx (struct dce_hwseq *hws,struct dc *dc,struct dc_phy_addr_space_config *pa_config);
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c +1 -0
@@ -97,6 +97,7 @@ static const struct hw_sequencer_funcs dcn31_funcs = { .set_abm_immediate_disable = dcn21_set_abm_immediate_disable, .set_pipe = dcn21_set_pipe, .z10_restore = dcn31_z10_restore, + .z10_save_init = dcn31_z10_save_init, .is_abm_supported = dcn31_is_abm_supported, .set_disp_pattern_generator = dcn30_set_disp_pattern_generator, .update_visual_confirm_color = dcn20_update_visual_confirm_color,
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h +1 -0
@@ -237,6 +237,7 @@ struct hw_sequencer_funcs { int width, int height, int offset);void (*z10_restore)(struct dc *dc); +void (*z10_save_init)(struct dc *dc); void (*update_visual_confirm_color)(struct dc *dc, struct pipe_ctx *pipe_ctx,
drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h +5 -0
@@ -860,6 +860,11 @@ enum dmub_cmd_idle_opt_type {* DCN hardware restore. */ DMUB_CMD__IDLE_OPT_DCN_RESTORE =0 , + +/** +* DCN hardware save. +*/ + DMUB_CMD__IDLE_OPT_DCN_SAVE_INIT = 1 };/**
Signature · 1 line
2.25.1
PATCH 5/7 drm/amd/display: Guard vblank wq flush with DCN guards
In reply to Wayne LinFrom: Nicholas Kazlauskas <[email protected]>
[Why]
Compilation of the workqueue fails if not building with the DCN config option set.
[How]
Guard calls to the flush with the DCN config option to fix the build.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
@@ -8643,11 +8643,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,/* Update the planes if changed or disable if we don't have any. */ if ((planes_count || acrtc_state->active_planes ==0 ) && acrtc_state->stream) { +#if defined(CONFIG_DRM_AMD_DC_DCN )/* * If PSR or idle optimizations are enabled then flush out * any pending work before hardware programming. */ flush_workqueue (dm->vblank_control_workqueue); +#endif bundle->stream_update.stream = acrtc_state->stream;if (new_pcrtc_state->mode_changed) {
@@ -8980,7 +8982,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)if (dc_state) {/* if there mode set or reset, disable eDP PSR */ if (mode_set_reset_required) { +#if defined(CONFIG_DRM_AMD_DC_DCN )flush_workqueue (dm->vblank_control_workqueue); +#endif amdgpu_dm_psr_disable_all (dm); }
Signature · 1 line
2.25.1
PATCH 6/7 drm/amd/display: [FW Promotion] Release 0.0.79
In reply to Wayne LinFrom: Anthony Koo <[email protected]>
--- drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h +12 -2
@@ -47,10 +47,10 @@/* Firmware versioning. */ #ifdef DMUB_EXPOSE_VERSION -#define DMUB_FW_VERSION_GIT_HASH 0x9b7fa7783 +#define DMUB_FW_VERSION_GIT_HASH 0x7383caadc#define DMUB_FW_VERSION_MAJOR 0#define DMUB_FW_VERSION_MINOR 0 -#define DMUB_FW_VERSION_REVISION 78 +#define DMUB_FW_VERSION_REVISION 79#define DMUB_FW_VERSION_TEST 0#define DMUB_FW_VERSION_VBIOS 0#define DMUB_FW_VERSION_HOTFIX 0
@@ -322,6 +322,10 @@ union dmub_fw_boot_status { uint32_t mailbox_rdy : 1; /**< 1 if mailbox ready */ uint32_t optimized_init_done : 1; /**< 1 if optimized init done */ uint32_t restore_required : 1; /**< 1 if driver should call restore */ + uint32_t defer_load : 1; /**< 1 if VBIOS data is deferred programmed */ + uint32_t reserved : 1; + uint32_t detection_required: 1; /**< if detection need to be triggered by driver */ + } bits;/**< status bits */ uint32_t all;/**< 32-bit access to status bits */ };
@@ -335,6 +339,7 @@ enum dmub_fw_boot_status_bit {DMUB_FW_BOOT_STATUS_BIT_OPTIMIZED_INIT_DONE = (1 <<2 ),/**< 1 if init done */ DMUB_FW_BOOT_STATUS_BIT_RESTORE_REQUIRED = (1 <<3 ),/**< 1 if driver should call restore */ DMUB_FW_BOOT_STATUS_BIT_DEFERRED_LOADED = (1 <<4 ),/**< 1 if VBIOS data is deferred programmed */ + DMUB_FW_BOOT_STATUS_BIT_DETECTION_REQUIRED = (1 << 6), /**< 1 if detection need to be triggered by driver*/ };/* Register bit definition for SCRATCH5 */
@@ -489,6 +494,11 @@ enum dmub_gpint_command {* RETURN: PSR residency in milli-percent. */ DMUB_GPINT__PSR_RESIDENCY =9 , + +/** +* DESC: Notifies DMCUB detection is done so detection required can be cleared. +*/ + DMUB_GPINT__NOTIFY_DETECTION_DONE = 12, };/**
Signature · 1 line
2.25.1
PATCH 7/7 drm/amd/display: 3.2.149
In reply to Wayne LinFrom: Aric Cyr <[email protected]>
This version brings along following fixes:
* Ensure DCN save init registers after VM setup
* Fix multi-display support for idle opt workqueue
* Use vblank control events for PSR enable/disable
* Create default dc_sink when fail reading EDID under MST
--- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dc.h +1 -1
@@ -45,7 +45,7 @@/* forward declaration */ struct aux_payload ; -#define DC_VER "3.2.148" +#define DC_VER "3.2.149"#define MAX_SURFACES 3#define MAX_PLANES 6
Signature · 1 line
2.25.1