Refactor DC atomic commit and gamma
Subsystems (3)
cover Refactor DC atomic commit and gamma
These patches are first steps of addressing some of the problems in DC's atomic implementation. Please take a look and provide feedback if possible. Our hope is that we can start setting a direction on fixing up DC to do atomic correctly and lay the groundwork for moving past the midlayer.
THe biggest patch here is Andrey's work to bring atomic_commit in line with the atomic helpers instead of rolling our own. We got atomic_commmit_tail now and things appear to work correctly with this change. It allowed us to clean up some of the commit code, but there's still a lot left.
The second important patch is fixing up our gamma implementation and correct the use of crtc_set_property and atomic_set_properties.
Beyond that there's some minor cleanup and support patches for the above change.
The whole DC tree with these patches and rebased on drm-next a couple days ago can be found at
https://cgit.freedesktop.org/~hwentland/linux/log/?h=dc-drm-next-atomic
Known issue:
- corruption on one display in two-display setup
Cheers,
Harry
Andrey Grodzovsky (3):
drm/amdgpu: Add a few members to support DAL atomic refactor. drm/amd/display: Refactor atomic commit implementation. drm/amd/display: Refactor headless to use atomic commit.
Harry Wentland (5):
drm/amdgpu: Expose mode_config functions for DM drm/amd/display: Use amdgpu mode funcs statically drm/amd/display: Use atomic helpers for gamma drm/amd/display: Remove unused define from amdgpu_dm_types Revert "drm/amdgpu: Refactor flip into prepare submit and submit.
(v3)"
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 140 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_display.h | 33 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 19 +- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 70 ++- .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 548 +++++++++------------ .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.h | 12 +- 6 files changed, 341 insertions(+), 481 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170209214116.11687-1-harry.wentland-5C7GfCeVMHo@public.gmane.org
PATCH 1/8 drm/amdgpu: Expose mode_config functions for DM
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_display.h | 33 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -2
@@ -596,7 +596,7 @@ amdgpu_framebuffer_init(struct drm_device *dev,return 0 ; } -static struct drm_framebuffer * +struct drm_framebuffer *amdgpu_user_framebuffer_create (struct drm_device *dev,struct drm_file *file_priv,const struct drm_mode_fb_cmd2 *mode_cmd)
@@ -628,7 +628,7 @@ amdgpu_user_framebuffer_create(struct drm_device *dev,return &amdgpu_fb->base; } -static void amdgpu_output_poll_changed (struct drm_device *dev) +void amdgpu_output_poll_changed (struct drm_device *dev) {struct amdgpu_device *adev = dev->dev_private;amdgpu_fb_output_poll_changed (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright 2017 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef __AMDGPU_DISPLAY_H__ +#define __AMDGPU_DISPLAY_H__ + +struct drm_framebuffer * +amdgpu_user_framebuffer_create (struct drm_device *dev, +struct drm_file *file_priv, +const struct drm_mode_fb_cmd2 *mode_cmd); + +void amdgpu_output_poll_changed (struct drm_device *dev); + +#endif
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/8 drm/amd/display: Use amdgpu mode funcs statically
In reply to a message not in the archiveNo need to assign them dynamically. This is much more readable.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -5
@@ -28,6 +28,7 @@#include "vid.h" #include "amdgpu.h" +#include "amdgpu_display.h" #include "atom.h" #include "amdgpu_dm.h" #include "amdgpu_dm_types.h"
@@ -727,6 +728,8 @@ const struct amdgpu_ip_block_version dm_ip_block =/* TODO: it is temporary non-const, should fixed later */ static struct drm_mode_config_funcs amdgpu_dm_mode_funcs = { + .fb_create = amdgpu_user_framebuffer_create, + .output_poll_changed = amdgpu_output_poll_changed, .atomic_check = amdgpu_dm_atomic_check, .atomic_commit = amdgpu_dm_atomic_commit };
@@ -1102,11 +1105,6 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev) adev->mode_info.mode_config_initialized = true; - amdgpu_dm_mode_funcs.fb_create = - amdgpu_mode_funcs.fb_create; - amdgpu_dm_mode_funcs.output_poll_changed = - amdgpu_mode_funcs.output_poll_changed; - adev->ddev->mode_config.funcs = (void *)&amdgpu_dm_mode_funcs; adev->ddev->mode_config.max_width =16384 ;
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/8 drm/amd/display: Use atomic helpers for gamma
In reply to a message not in the archiveWe were using set_properties and gamma in a weird way. This change aligns the properties with other drivers and allows us to remove a private gamma flag and reuse atomic helpers for most of this.
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 89 +++++----------------- 1 file changed, 21 insertions(+), 68 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c +21 -68
@@ -61,7 +61,6 @@ struct dm_connector_state {#define to_dm_connector_state (x)\ container_of((x), struct dm_connector_state, base) -#define AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET 1void amdgpu_dm_encoder_destroy (struct drm_encoder *encoder) {
@@ -551,23 +550,18 @@ static void fill_gamma_from_crtc( {int i;struct dc_gamma *gamma; -uint16_t *red, *green, *blue; -int end = (crtc->gamma_size >NUM_OF_RAW_GAMMA_RAMP_RGB_256 ) ? -NUM_OF_RAW_GAMMA_RAMP_RGB_256 : crtc->gamma_size; - - red = crtc->gamma_store; - green = red + crtc->gamma_size; - blue = green + crtc->gamma_size; +struct drm_crtc_state *state = crtc->state; +struct drm_color_lut *lut = (struct drm_color_lut *) state->gamma_lut->data; gamma =dc_create_gamma ();if (gamma ==NULL )return ; -for (i =0 ; i < end; i++) { - gamma->red[i] = (unsigned short ) red[i]; - gamma->green[i] = (unsigned short ) green[i]; - gamma->blue[i] = (unsigned short ) blue[i]; +for (i =0 ; i <NUM_OF_RAW_GAMMA_RAMP_RGB_256 ; i++) { + gamma->red[i] = lut[i].red; + gamma->green[i] = lut[i].green; + gamma->blue[i] = lut[i].blue; } dc_surface->gamma_correction = gamma;
@@ -601,8 +595,7 @@ static void fill_plane_attributes( surface->in_transfer_func = input_tf;/* In case of gamma set, update gamma value */ -if (crtc->mode.private_flags & -AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET ) { +if (state->crtc->state->gamma_lut) {fill_gamma_from_crtc (crtc, surface); } }
@@ -719,12 +712,6 @@ static void dm_dc_surface_commit( dc_surface, crtc->primary->state, true); -if (crtc->mode.private_flags & -AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET ) { -/* reset trigger of gamma */ - crtc->mode.private_flags &= - ~AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET ; - } dc_surfaces[0 ] = dc_surface;
@@ -1049,50 +1036,6 @@ void amdgpu_dm_crtc_destroy(struct drm_crtc *crtc)kfree (crtc); } -static int amdgpu_dm_atomic_crtc_gamma_set ( -struct drm_crtc *crtc, -u16 *red, -u16 *green, -u16 *blue, -uint32_t size) -{ -struct drm_device *dev = crtc->dev; -struct drm_property *prop = dev->mode_config.prop_crtc_id; - - crtc->state->mode.private_flags |=AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET ; - -return drm_atomic_helper_crtc_set_property (crtc, prop,0 ); -} - -static int dm_crtc_funcs_atomic_set_property ( -struct drm_crtc *crtc, -struct drm_crtc_state *crtc_state, -struct drm_property *property, -uint64_t val) -{ -struct drm_plane_state *plane_state; - - crtc_state->planes_changed = true; - -/* -* Bit of magic done here. We need to ensure -* that planes get update after mode is set. -* So, we need to add primary plane to state, -* and this way atomic_update would be called -* for it -*/ - plane_state = -drm_atomic_get_plane_state ( - crtc_state->state, - crtc->primary); - -if (!plane_state) -return -EINVAL ; - -return 0 ; -} - - static int amdgpu_atomic_helper_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, struct drm_pending_vblank_event *event,
@@ -1174,12 +1117,12 @@ static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = { .cursor_set = dm_crtc_cursor_set, .cursor_move = dm_crtc_cursor_move, .destroy = amdgpu_dm_crtc_destroy, - .gamma_set = amdgpu_dm_atomic_crtc_gamma_set, + .gamma_set = drm_atomic_helper_legacy_gamma_set, .set_config = drm_atomic_helper_set_config, + .set_property = drm_atomic_helper_crtc_set_property, .page_flip = amdgpu_atomic_helper_page_flip, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, - .atomic_set_property = dm_crtc_funcs_atomic_set_property }; static enum drm_connector_status
@@ -2790,8 +2733,7 @@ int amdgpu_dm_atomic_commit(struct dm_connector_state *dm_state =NULL ;enum dm_commit_action action; -if (!fb || !crtc || !crtc->state->planes_changed || - !crtc->state->active) +if (!fb || !crtc || !crtc->state->active)continue ; action =get_dm_commit_action (crtc->state);
@@ -3223,6 +3165,17 @@ int amdgpu_dm_atomic_check(struct drm_device *dev, }break ; } + +/* +* TODO revisit when removing commit action +* and looking at atomic flags directly +*/ + +/* commit needs planes right now (for gamma, eg.) */ +/* TODO rework commit to chack crtc for gamma change */ + ret =drm_atomic_add_affected_planes (state, crtc); +if (ret) +return ret; }for (i =0 ; i < set_count; i++) {
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/8 drm/amd/display: Remove unused define from amdgpu_dm_types
In reply to a message not in the archive--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h | 5 ----- 1 file changed, 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h +0 -5
@@ -59,11 +59,6 @@ int amdgpu_dm_atomic_commit(int amdgpu_dm_atomic_check (struct drm_device *dev,struct drm_atomic_state *state); -int dm_create_validation_set_for_stream ( -struct drm_connector *connector, -struct drm_display_mode *mode, -struct dc_validation_set *val_set); -void amdgpu_dm_connector_funcs_reset (struct drm_connector *connector);struct drm_connector_state *amdgpu_dm_connector_atomic_duplicate_state (struct drm_connector *connector);
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/8 drm/amdgpu: Add a few members to support DAL atomic refactor.
In reply to a message not in the archiveFrom: Andrey Grodzovsky <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +4 -0
@@ -322,6 +322,9 @@ struct amdgpu_display_funcs {struct amdgpu_framebuffer {struct drm_framebuffer base;struct drm_gem_object *obj; + +/* caching for later use */ +uint64_t address; };struct amdgpu_fbdev {
@@ -447,6 +450,7 @@ struct amdgpu_crtc {uint32_t flip_flags;/* After Set Mode stream will be non-NULL */ const struct dc_stream *stream; +struct drm_pending_vblank_event *event; };struct amdgpu_encoder_atom_dig {
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/8 drm/amd/display: Refactor atomic commit implementation.
In reply to a message not in the archiveFrom: Andrey Grodzovsky <[email protected]>
Modify amdgpu_dm_atomic_comit to implement atomic_comit_tail hook.
Unify Buffer objects allocation and dealocation for surface updates and page flips.
Simplify wait for fences and target_vbank logic for non blockiing commit.
Remove hacky update surface to page flip synchronization we had and rely on atomic framework synchronization logic.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 62 ++-- .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 321 +++++++++------------ .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.h | 7 +- 3 files changed, 190 insertions(+), 200 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +44 -18
@@ -155,7 +155,6 @@ static struct amdgpu_crtc *get_crtc_by_otg_inst(static void dm_pflip_high_irq (void *interrupt_params) { -struct amdgpu_flip_work *works;struct amdgpu_crtc *amdgpu_crtc;struct common_irq_params *irq_params = interrupt_params;struct amdgpu_device *adev = irq_params->adev;
@@ -171,7 +170,6 @@ static void dm_pflip_high_irq(void *interrupt_params) }spin_lock_irqsave (&adev->ddev->event_lock, flags); - works = amdgpu_crtc->pflip_works;if (amdgpu_crtc->pflip_status !=AMDGPU_FLIP_SUBMITTED ){ DRM_DEBUG_DRIVER("amdgpu_crtc->pflip_status = %d !=AMDGPU_FLIP_SUBMITTED(%d) on crtc:%d[%p] \n",
@@ -183,23 +181,25 @@ static void dm_pflip_high_irq(void *interrupt_params)return ; } -/* page flip completed. clean up */ - amdgpu_crtc->pflip_status =AMDGPU_FLIP_NONE ; - amdgpu_crtc->pflip_works =NULL ;/* wakeup usersapce */ -if (works->event) -drm_crtc_send_vblank_event (&amdgpu_crtc->base, - works->event); +if (amdgpu_crtc->event && + amdgpu_crtc->event->event.base.type + ==DRM_EVENT_FLIP_COMPLETE ) { +drm_crtc_send_vblank_event (&amdgpu_crtc->base, amdgpu_crtc->event); +/* page flip completed. clean up */ + amdgpu_crtc->event =NULL ; + }else { +WARN_ON (1 ); + } + amdgpu_crtc->pflip_status =AMDGPU_FLIP_NONE ;spin_unlock_irqrestore (&adev->ddev->event_lock, flags); -DRM_DEBUG_DRIVER ("%s - crtc :%d[%p], pflip_stat:AMDGPU_FLIP_NONE, work: %p,\n" , - __func__, amdgpu_crtc->crtc_id, amdgpu_crtc, works); +DRM_DEBUG_DRIVER ("%s - crtc :%d[%p], pflip_stat:AMDGPU_FLIP_NONE \n" , + __func__, amdgpu_crtc->crtc_id, amdgpu_crtc); -if (amdgpu_crtc->base.funcs->page_flip_target) -drm_crtc_vblank_put (&amdgpu_crtc->base); -schedule_work (&works->unpin_work); +drm_crtc_vblank_put (&amdgpu_crtc->base); }static void dm_crtc_high_irq (void *interrupt_params)
@@ -731,7 +731,11 @@ static struct drm_mode_config_funcs amdgpu_dm_mode_funcs = { .fb_create = amdgpu_user_framebuffer_create, .output_poll_changed = amdgpu_output_poll_changed, .atomic_check = amdgpu_dm_atomic_check, - .atomic_commit = amdgpu_dm_atomic_commit + .atomic_commit = drm_atomic_helper_commit +}; + +static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = { + .atomic_commit_tail = amdgpu_dm_atomic_commit_tail }; void amdgpu_dm_update_connector_after_detect(
@@ -1106,6 +1110,7 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev) adev->mode_info.mode_config_initialized = true; adev->ddev->mode_config.funcs = (void *)&amdgpu_dm_mode_funcs; + adev->ddev->mode_config.helper_private = &amdgpu_dm_mode_config_helperfuncs; adev->ddev->mode_config.max_width =16384 ; adev->ddev->mode_config.max_height =16384 ;
@@ -1359,6 +1364,14 @@ static void dm_page_flip(struct amdgpu_device *adev, acrtc = adev->mode_info.crtcs[crtc_id]; stream = acrtc->stream; + +if (acrtc->pflip_status !=AMDGPU_FLIP_NONE ) { +DRM_ERROR ("flip queue: acrtc %d, already busy\n" , acrtc->crtc_id); +/* In commit tail framework this cannot happen */ +BUG_ON (0 ); + } + +/* * Received a page flip call after the display has been reset. * Just return in this case. Everything should be clean-up on reset.
@@ -1373,15 +1386,28 @@ static void dm_page_flip(struct amdgpu_device *adev, addr.address.grph.addr.high_part =upper_32_bits (crtc_base); addr.flip_immediate = async; + +if (acrtc->base.state->event && + acrtc->base.state->event->event.base.type == +DRM_EVENT_FLIP_COMPLETE ) { + acrtc->event = acrtc->base.state->event; + +/* Set the flip status */ + acrtc->pflip_status =AMDGPU_FLIP_SUBMITTED ; + +/* Mark this event as consumed */ + acrtc->base.state->event =NULL ; + } + +dc_flip_surface_addrs (adev->dm.dc, +dc_stream_get_status (stream)->surfaces, + &addr,1 ); +DRM_DEBUG_DRIVER ("%s Flipping to hi: 0x%x, low: 0x%x \n" , __func__, addr.address.grph.addr.high_part, addr.address.grph.addr.low_part); -dc_flip_surface_addrs ( - adev->dm.dc, -dc_stream_get_status (stream)->surfaces, - &addr,1 ); } static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c +143 -178
444 lines not on this page · raw message
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h +3 -4
@@ -52,10 +52,9 @@ void amdgpu_dm_encoder_destroy(struct drm_encoder *encoder);int amdgpu_dm_connector_get_modes (struct drm_connector *connector); -int amdgpu_dm_atomic_commit ( -struct drm_device *dev, -struct drm_atomic_state *state, -bool async); +void amdgpu_dm_atomic_commit_tail ( +struct drm_atomic_state *state); +int amdgpu_dm_atomic_check (struct drm_device *dev,struct drm_atomic_state *state);
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/8 drm/amd/display: Refactor headless to use atomic commit.
In reply to a message not in the archiveFrom: Andrey Grodzovsky <[email protected]>
Headless mode set needs to be synchronized against outstanding nonblocking commits. This achieved by building atomic state and commiting it.
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 140 +++++++++------------ 1 file changed, 61 insertions(+), 79 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c +61 -79
@@ -2802,6 +2802,65 @@ void amdgpu_dm_atomic_commit_tail(/* Release old FB */ drm_atomic_helper_cleanup_planes (dev, state); } + + +static int dm_force_atomic_commit (struct drm_connector *connector) +{ +int ret =0 ; +struct drm_device *ddev = connector->dev; +struct drm_atomic_state *state =drm_atomic_state_alloc (ddev); +struct amdgpu_crtc *disconnected_acrtc =to_amdgpu_crtc (connector->encoder->crtc); +struct drm_plane *plane = disconnected_acrtc->base.primary; +struct drm_connector_state *conn_state; +struct drm_crtc_state *crtc_state; +struct drm_plane_state *plane_state; + +if (!state) +return ENOMEM ; + + state->acquire_ctx = ddev->mode_config.acquire_ctx; + +/* Construct an atomic state to restore previous display setting */ + +/* +* Attach connectors to drm_atomic_state +*/ + conn_state =drm_atomic_get_connector_state (state, connector); + + ret =PTR_ERR_OR_ZERO (conn_state); +if (ret) + goto err; + +/* Attach crtc to drm_atomic_state*/ + crtc_state =drm_atomic_get_crtc_state (state, &disconnected_acrtc->base); + + ret =PTR_ERR_OR_ZERO (crtc_state); +if (ret) + goto err; + +/* force a restore */ + crtc_state->mode_changed = true; + +/* Attach plane to drm_atomic_state */ + plane_state =drm_atomic_get_plane_state (state, plane); + + ret =PTR_ERR_OR_ZERO (plane_state); +if (ret) + goto err; + + +/* Call commit internally with the state we just constructed */ + ret =drm_atomic_commit (state); +if (!ret) +return 0 ; + +err: +DRM_ERROR ("Restoring old state failed with %i\n" , ret); +drm_atomic_state_put (state); + +return ret; +} +/* * This functions handle all cases when set mode does not come upon hotplug. * This include when the same display is unplugged then plugged back into the
@@ -2809,15 +2868,8 @@ void amdgpu_dm_atomic_commit_tail(*/ void dm_restore_drm_connector_state (struct drm_device *dev,struct drm_connector *connector) { -struct drm_crtc *crtc; -struct amdgpu_device *adev = dev->dev_private; -struct dc *dc = adev->dm.dc;struct amdgpu_connector *aconnector =to_amdgpu_connector (connector);struct amdgpu_crtc *disconnected_acrtc; -const struct dc_sink *sink; -const struct dc_stream *commit_streams[MAX_STREAMS ]; -const struct dc_stream *current_stream; -uint32_t commit_streams_count =0 ;if (!aconnector->dc_sink || !connector->state || !connector->encoder)return ;
@@ -2827,83 +2879,13 @@ void dm_restore_drm_connector_state(struct drm_device *dev, struct drm_connectorif (!disconnected_acrtc || !disconnected_acrtc->stream)return ; - sink = disconnected_acrtc->stream->sink; -/* * If the previous sink is not released and different from the current, * we deduce we are in a state where we can not rely on usermode call * to turn on the display, so we do it here */ -if (sink != aconnector->dc_sink) { -struct dm_connector_state *dm_state = -to_dm_connector_state (aconnector->base.state); - -struct dc_stream *new_stream = -create_stream_for_sink ( - aconnector, - &disconnected_acrtc->base.state->mode, - dm_state); - -DRM_INFO ("Headless hotplug, restoring connector state\n" ); -/* -* we evade vblanks and pflips on crtc that -* should be changed -*/ -manage_dm_interrupts (adev, disconnected_acrtc, false); -/* this is the update mode case */ - - current_stream = disconnected_acrtc->stream; - - disconnected_acrtc->stream = new_stream; - disconnected_acrtc->enabled = true; - disconnected_acrtc->hw_mode = disconnected_acrtc->base.state->mode; - - commit_streams_count =0 ; - -list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { -struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc); - -if (acrtc->stream) { - commit_streams[commit_streams_count] = acrtc->stream; - ++commit_streams_count; - } - } - -/* DC is optimized not to do anything if 'streams' didn't change. */ -if (!dc_commit_streams (dc, commit_streams, - commit_streams_count)) { -DRM_INFO ("Failed to restore connector state!\n" ); -dc_stream_release (disconnected_acrtc->stream); - disconnected_acrtc->stream = current_stream; -manage_dm_interrupts (adev, disconnected_acrtc, true); -return ; - } - -if (adev->dm.freesync_module) { -mod_freesync_remove_stream (adev->dm.freesync_module, - current_stream); - -mod_freesync_add_stream (adev->dm.freesync_module, - new_stream, &aconnector->caps); - } - -list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { -struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc); - -if (acrtc->stream !=NULL ) { - acrtc->otg_inst = -dc_stream_get_status (acrtc->stream)->primary_otg_inst; - } - } - -dc_stream_release (current_stream); - -dm_dc_surface_commit (dc, &disconnected_acrtc->base); - -manage_dm_interrupts (adev, disconnected_acrtc, true); -dm_crtc_cursor_reset (&disconnected_acrtc->base); - - } +if (disconnected_acrtc->stream->sink != aconnector->dc_sink) +dm_force_atomic_commit (&aconnector->base); } static uint32_t add_val_sets_surface(
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/8 Revert "drm/amdgpu: Refactor flip into prepare submit and submit. (v3)"
In reply to a message not in the archiveThis reverts commit cb341a319f7e66f879d69af929c3dadfc1a8f31e.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 136 ++++++---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 15 --- 2 files changed, 28 insertions(+), 123 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +28 -108
@@ -138,52 +138,10 @@ static void amdgpu_unpin_work_func(struct work_struct *__work)kfree (work); } - -static void amdgpu_flip_work_cleanup (struct amdgpu_flip_work *work) -{ -int i; - -amdgpu_bo_unref (&work->old_abo); -dma_fence_put (work->excl); -for (i =0 ; i < work->shared_count; ++i) -dma_fence_put (work->shared[i]); -kfree (work->shared); -kfree (work); -} - -static void amdgpu_flip_cleanup_unreserve (struct amdgpu_flip_work *work, -struct amdgpu_bo *new_abo) -{ -amdgpu_bo_unreserve (new_abo); -amdgpu_flip_work_cleanup (work); -} - -static void amdgpu_flip_cleanup_unpin (struct amdgpu_flip_work *work, -struct amdgpu_bo *new_abo) -{ -if (unlikely (amdgpu_bo_unpin (new_abo) !=0 )) -DRM_ERROR ("failed to unpin new abo in error path\n" ); -amdgpu_flip_cleanup_unreserve (work, new_abo); -} - -void amdgpu_crtc_cleanup_flip_ctx (struct amdgpu_flip_work *work, -struct amdgpu_bo *new_abo) -{ -if (unlikely (amdgpu_bo_reserve (new_abo, false) !=0 )) { -DRM_ERROR ("failed to reserve new abo in error path\n" ); -amdgpu_flip_work_cleanup (work); -return ; - } -amdgpu_flip_cleanup_unpin (work, new_abo); -} - -int amdgpu_crtc_prepare_flip (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_pending_vblank_event *event, -uint32_t page_flip_flags, -uint32_t target, -struct amdgpu_flip_work **work_p, -struct amdgpu_bo **new_abo_p) +int amdgpu_crtc_page_flip_target (struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_pending_vblank_event *event, +uint32_t page_flip_flags,uint32_t target) {struct drm_device *dev = crtc->dev;struct amdgpu_device *adev = dev->dev_private;
@@ -196,7 +154,7 @@ int amdgpu_crtc_prepare_flip(struct drm_crtc *crtc,unsigned long flags;u64 tiling_flags;u64 base; -int r; +int i, r; work =kzalloc (sizeof *work,GFP_KERNEL );if (work ==NULL )
@@ -257,79 +215,41 @@ int amdgpu_crtc_prepare_flip(struct drm_crtc *crtc,spin_unlock_irqrestore (&crtc->dev->event_lock, flags); r = -EBUSY ; goto pflip_cleanup; - } -spin_unlock_irqrestore (&crtc->dev->event_lock, flags); - - *work_p = work; - *new_abo_p = new_abo; - -return 0 ; - -pflip_cleanup: -amdgpu_crtc_cleanup_flip_ctx (work, new_abo); -return r; - -unpin: -amdgpu_flip_cleanup_unpin (work, new_abo); -return r; - -unreserve: -amdgpu_flip_cleanup_unreserve (work, new_abo); -return r; -cleanup: -amdgpu_flip_work_cleanup (work); -return r; - -} - -void amdgpu_crtc_submit_flip (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct amdgpu_flip_work *work, -struct amdgpu_bo *new_abo) -{ -unsigned long flags; -struct amdgpu_crtc *amdgpu_crtc =to_amdgpu_crtc (crtc); - -spin_lock_irqsave (&crtc->dev->event_lock, flags); amdgpu_crtc->pflip_status =AMDGPU_FLIP_PENDING ; amdgpu_crtc->pflip_works = work; + +DRM_DEBUG_DRIVER ("crtc:%d[%p], pflip_stat:AMDGPU_FLIP_PENDING, work: %p,\n" , + amdgpu_crtc->crtc_id, amdgpu_crtc, work);/* update crtc fb */ crtc->primary->fb = fb;spin_unlock_irqrestore (&crtc->dev->event_lock, flags); - -DRM_DEBUG_DRIVER ( -"crtc:%d[%p], pflip_stat:AMDGPU_FLIP_PENDING, work: %p,\n" , - amdgpu_crtc->crtc_id, amdgpu_crtc, work); -amdgpu_flip_work_func (&work->flip_work.work); -} - -int amdgpu_crtc_page_flip_target (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_pending_vblank_event *event, -uint32_t page_flip_flags, -uint32_t target) -{ -struct amdgpu_bo *new_abo; -struct amdgpu_flip_work *work; -int r; +return 0 ; - r =amdgpu_crtc_prepare_flip (crtc, - fb, - event, - page_flip_flags, - target, - &work, - &new_abo); -if (r) -return r; +pflip_cleanup: +if (unlikely (amdgpu_bo_reserve (new_abo, false) !=0 )) { +DRM_ERROR ("failed to reserve new abo in error path\n" ); + goto cleanup; + } +unpin: +if (unlikely (amdgpu_bo_unpin (new_abo) !=0 )) { +DRM_ERROR ("failed to unpin new abo in error path\n" ); + } +unreserve: +amdgpu_bo_unreserve (new_abo); -amdgpu_crtc_submit_flip (crtc, fb, work, new_abo); +cleanup: +amdgpu_bo_unref (&work->old_abo); +dma_fence_put (work->excl); +for (i =0 ; i < work->shared_count; ++i) +dma_fence_put (work->shared[i]); +kfree (work->shared); +kfree (work); -return 0 ; +return r; }int amdgpu_crtc_set_config (struct drm_mode_set *set)
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +0 -15
@@ -682,21 +682,6 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,struct drm_framebuffer *fb, struct drm_pending_vblank_event *event, uint32_t page_flip_flags, uint32_t target); -void amdgpu_crtc_cleanup_flip_ctx (struct amdgpu_flip_work *work, -struct amdgpu_bo *new_abo); -int amdgpu_crtc_prepare_flip (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_pending_vblank_event *event, -uint32_t page_flip_flags, -uint32_t target, -struct amdgpu_flip_work **work, -struct amdgpu_bo **new_abo); - -void amdgpu_crtc_submit_flip (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct amdgpu_flip_work *work, -struct amdgpu_bo *new_abo); -extern const struct drm_mode_config_funcs amdgpu_mode_funcs;#endif
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 21 lines · Harry Wentland
These patches are first steps of addressing some of the problems in DC's atomic implementation. Please take a look and provide feedback if possible. Our hope is that we can start setting a direction on fixing up DC to do atomic correctly and lay the groundwork for moving past the midlayer.
THe biggest patch here is Andrey's work to bring
atomic_commitin line with the atomic helpers instead of rolling our own. We gotatomic_commmit_tailnow and things appear to work correctly with this change. It allowed us to clean up some of the commit code, but there's still a lot left.The second important patch is fixing up our gamma implementation and correct the use of
crtc_set_propertyandatomic_set_properties.Beyond that there's some minor cleanup and support patches for the above change.
The whole DC tree with these patches and rebased on drm-next a couple days ago can be found at
Quoted 7 lines
https://cgit.freedesktop.org/~hwentland/linux/log/?h=dc-drm-next-atomic
Known issue:
- corruption on one display in two-display setupCheers,
Harry
Harry, can you please resend this series and add dri-devel as well so the discussion happens in a larger forum in case others working on atomic have similar questions?
Thanks,
Alex
Quoted 23 lines
Andrey Grodzovsky (3):
drm/amdgpu: Add a few members to support DAL atomic refactor. drm/amd/display: Refactor atomic commit implementation. drm/amd/display: Refactor headless to use atomic commit.Harry Wentland (5):
drm/amdgpu: Exposemode_configfunctions for DM drm/amd/display: Use amdgpu mode funcs statically drm/amd/display: Use atomic helpers for gamma drm/amd/display: Remove unused define fromamdgpu_dm_typesRevert "drm/amdgpu: Refactor flip into prepare submit and submit.(v3)"drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 140 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_display.h | 33 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 19 +- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 70 ++- .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 548 +++++++++------------ .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.h | 12 +- 6 files changed, 341 insertions(+), 481 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h
Quoted 7 lines
--
2.9.3_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel