drm/fb-helper: Move modesetting code to drm_client
Subsystems (5)
cover drm/fb-helper: Move modesetting code to drm_client
This moves the modesetting code from drm_fb_helper to drm_client so it can be shared by all internal clients.
I have also added a client display abstraction and a bootsplash example client to show where this might be heading. Hopefully Max Staudt will be able to pick up his bootsplash work now.
Noralf.
Noralf Trønnes (16):
drm/fb-helper: Remove unused gamma_size variable drm/fb-helper: dpms_legacy(): Only set on connectors in use drm/atomic: Move __drm_atomic_helper_disable_plane/set_config() drm/fb-helper: No need to cache rotation and sw_rotations drm/fb-helper: Remove drm_fb_helper_crtc->{x,y,desired_mode} drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper drm/fb-helper: Remove drm_fb_helper_crtc drm/fb-helper: Prepare to move out commit code drm/fb-helper: Move out commit code
drm/fb-helper: Remove drm_fb_helper_connector drm/fb-helper: Prepare to move out modeset config code drm/fb-helper: Move out modeset config code drm/fb-helper: Avoid race with DRM userspace drm/client: Add display abstraction
drm/client: Hack: Add bootsplash example
drm/vc4: Call drm_dev_register() after all setup is done
Documentation/gpu/todo.rst | 10 + drivers/gpu/drm/Kconfig | 5 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_atomic.c | 168 ++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --- drivers/gpu/drm/drm_auth.c | 20 + drivers/gpu/drm/drm_bootsplash.c | 216 ++++ drivers/gpu/drm/drm_client.c | 1449 +++++++++++++++++++++++++++ drivers/gpu/drm/drm_crtc_internal.h | 5 + drivers/gpu/drm/drm_drv.c | 4 + drivers/gpu/drm/drm_fb_helper.c | 1151 ++------------------- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/i915/intel_fbdev.c | 218 ---- drivers/gpu/drm/vc4/vc4_drv.c | 6 +- include/drm/drm_atomic_helper.h | 4 - include/drm/drm_client.h | 117 +++ include/drm/drm_fb_helper.h | 127 +-- 17 files changed, 2128 insertions(+), 1539 deletions(-) create mode 100644 drivers/gpu/drm/drm_bootsplash.c
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/16 drm/fb-helper: Remove unused gamma_size variable
The gamma_size variable has not been used since
commit 4abe35204af8 ("drm/kms/fb: use slow work mechanism for normal hotplug also.")
While in the area move a comment back to its code block.
They got separated by
commit d50ba256b5f1 ("drm/kms: start adding command line interface using fb.").
--- drivers/gpu/drm/drm_fb_helper.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +1 -5
@@ -1873,7 +1873,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,int crtc_count =0 ;int i;struct drm_fb_helper_surface_size sizes; -int gamma_size =0 ;int best_depth =0 ;memset (&sizes,0 ,sizeof (struct drm_fb_helper_surface_size ));
@@ -1889,7 +1888,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,if (preferred_bpp != sizes.surface_bpp) sizes.surface_depth = sizes.surface_bpp = preferred_bpp; -/* first up get a count of crtcs now in use and new min/maxes width/heights */ drm_fb_helper_for_each_connector (fb_helper, i) {struct drm_fb_helper_connector *fb_helper_conn = fb_helper->connector_info[i];struct drm_cmdline_mode *cmdline_mode;
@@ -1969,6 +1967,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, sizes.surface_depth = best_depth; } +/* first up get a count of crtcs now in use and new min/maxes width/heights */ crtc_count =0 ;for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_display_mode *desired_mode;
@@ -1991,9 +1990,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, x = fb_helper->crtc_info[i].x; y = fb_helper->crtc_info[i].y; -if (gamma_size ==0 ) - gamma_size = fb_helper->crtc_info[i].mode_set.crtc->gamma_size; - sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 01/16] drm/fb-helper: Remove unused gamma_size variable
Quoted 8 lines · Noralf Trønnes
The
gamma_sizevariable has not been used since
commit4abe35204af8("drm/kms/fb: use slow work mechanism for normal hotplug also.")While in the area move a comment back to its code block.
They got separated by
commitd50ba256b5f1("drm/kms: start adding command line interface using fb.").Signed-off-by Noralf Trønnes <[email protected]>
Quoted 49 lines
--- drivers/gpu/drm/drm_fb_helper.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpu/drm/drm_fb_helper.c +1
-5@@ -1873,7 +1873,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,int crtc_count =0 ;int i;struct drm_fb_helper_surface_size sizes; -int gamma_size =0 ;int best_depth =0 ;memset (&sizes,0 ,sizeof (struct drm_fb_helper_surface_size ));@@ -1889,7 +1888,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,if (preferred_bpp != sizes.surface_bpp) sizes.surface_depth = sizes.surface_bpp = preferred_bpp; -/* first up get a count of crtcs now in use and new min/maxes width/heights */ drm_fb_helper_for_each_connector (fb_helper, i) {struct drm_fb_helper_connector *fb_helper_conn = fb_helper->connector_info[i];struct drm_cmdline_mode *cmdline_mode;@@ -1969,6 +1967,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, sizes.surface_depth = best_depth; } +/* first up get a count of crtcs now in use and new min/maxes width/heights */ crtc_count =0 ;for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_display_mode *desired_mode;@@ -1991,9 +1990,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, x = fb_helper->crtc_info[i].x; y = fb_helper->crtc_info[i].y; -if (gamma_size ==0 ) - gamma_size = fb_helper->crtc_info[i].mode_set.crtc->gamma_size; - sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height);Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 01/16] drm/fb-helper: Remove unused gamma_size variable
Den 26.03.2019 19.23, skrev Daniel Vetter:
Quoted 11 lines · Noralf Trønnes
Quoted 8 lines
The
gamma_sizevariable has not been used since
commit4abe35204af8("drm/kms/fb: use slow work mechanism for normal hotplug also.")While in the area move a comment back to its code block.
They got separated by
commitd50ba256b5f1("drm/kms: start adding command line interface using fb.").Signed-off-by Noralf Trønnes <[email protected]>Reviewed-by Daniel Vetter <[email protected]>
Thanks, patches 1 & 2 applied to drm-misc-next.
Noralf.
Quoted 43 lines
Quoted 43 lines
--- drivers/gpu/drm/drm_fb_helper.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpu/drm/drm_fb_helper.c +1
-5@@ -1873,7 +1873,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,int crtc_count =0 ;int i;struct drm_fb_helper_surface_size sizes; -int gamma_size =0 ;int best_depth =0 ;memset (&sizes,0 ,sizeof (struct drm_fb_helper_surface_size ));@@ -1889,7 +1888,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,if (preferred_bpp != sizes.surface_bpp) sizes.surface_depth = sizes.surface_bpp = preferred_bpp; -/* first up get a count of crtcs now in use and new min/maxes width/heights */ drm_fb_helper_for_each_connector (fb_helper, i) {struct drm_fb_helper_connector *fb_helper_conn = fb_helper->connector_info[i];struct drm_cmdline_mode *cmdline_mode;@@ -1969,6 +1967,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, sizes.surface_depth = best_depth; } +/* first up get a count of crtcs now in use and new min/maxes width/heights */ crtc_count =0 ;for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_display_mode *desired_mode;@@ -1991,9 +1990,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, x = fb_helper->crtc_info[i].x; y = fb_helper->crtc_info[i].y; -if (gamma_size ==0 ) - gamma_size = fb_helper->crtc_info[i].mode_set.crtc->gamma_size; - sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height);
Quoted 8 lines
Quoted 7 lines
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/16 drm/fb-helper: dpms_legacy(): Only set on connectors in use
In reply to Noralf TrønnesFor each enabled crtc the functions sets dpms on all registered connectors. Limit this to only doing it once and on the connectors actually in use.
--- drivers/gpu/drm/drm_fb_helper.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +5 -6
@@ -639,20 +639,19 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };static void dpms_legacy (struct drm_fb_helper *fb_helper,int dpms_mode) {struct drm_device *dev = fb_helper->dev; -struct drm_crtc *crtc;struct drm_connector *connector; +struct drm_mode_set *modeset;int i, j;drm_modeset_lock_all (dev);for (i =0 ; i < fb_helper->crtc_count; i++) { - crtc = fb_helper->crtc_info[i].mode_set.crtc; + modeset = &fb_helper->crtc_info[i].mode_set; -if (!crtc->enabled) +if (!modeset->crtc->enabled)continue ; -/* Walk the connectors & encoders on this fb turning them on/off */ -drm_fb_helper_for_each_connector (fb_helper, j) { - connector = fb_helper->connector_info[j]->connector; +for (j =0 ; j < modeset->num_connectors; j++) { + connector = modeset->connectors[j]; connector->funcs->dpms (connector, dpms_mode);drm_object_property_set_value (&connector->base, dev->mode_config.dpms_property, dpms_mode);
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 02/16] drm/fb-helper: dpms_legacy(): Only set on connectors in use
Quoted 4 lines · Noralf Trønnes
For each enabled crtc the functions sets dpms on all registered connectors. Limit this to only doing it once and on the connectors actually in use.
Signed-off-by Noralf Trønnes <[email protected]>
Just want to trick the AUTOSEL bot into cherrypicking a silly patch onto -stable :-)
-Daniel
Quoted 41 lines
--- drivers/gpu/drm/drm_fb_helper.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_fb_helper.c +5
-6@@ -639,20 +639,19 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };static void dpms_legacy (struct drm_fb_helper *fb_helper,int dpms_mode) {struct drm_device *dev = fb_helper->dev; -struct drm_crtc *crtc;struct drm_connector *connector; +struct drm_mode_set *modeset;int i, j;drm_modeset_lock_all (dev);for (i =0 ; i < fb_helper->crtc_count; i++) { - crtc = fb_helper->crtc_info[i].mode_set.crtc; + modeset = &fb_helper->crtc_info[i].mode_set; -if (!crtc->enabled) +if (!modeset->crtc->enabled)continue ; -/* Walk the connectors & encoders on this fb turning them on/off */ -drm_fb_helper_for_each_connector (fb_helper, j) { - connector = fb_helper->connector_info[j]->connector; +for (j =0 ; j < modeset->num_connectors; j++) { + connector = modeset->connectors[j]; connector->funcs->dpms (connector, dpms_mode);drm_object_property_set_value (&connector->base, dev->mode_config.dpms_property, dpms_mode);Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/16 drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
In reply to Noralf TrønnesPrepare for moving drm_fb_helper modesetting code to drm_client. drm_client will be linked to drm.ko, so move __drm_atomic_helper_disable_plane() and __drm_atomic_helper_set_config() out of drm_kms_helper.ko.
While at it, fix two checkpatch complaints:
- WARNING: Block comments use a trailing */ on a separate line
- CHECK: Alignment should match open parenthesis
--- drivers/gpu/drm/drm_atomic.c | 168 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --------------------------- drivers/gpu/drm/drm_crtc_internal.h | 5 + include/drm/drm_atomic_helper.h | 4 - 4 files changed, 173 insertions(+), 168 deletions(-)
drivers/gpu/drm/drm_atomic.c +168 -0
@@ -1130,6 +1130,174 @@ int drm_atomic_nonblocking_commit(struct drm_atomic_state *state) }EXPORT_SYMBOL (drm_atomic_nonblocking_commit); +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state) +{ +int ret; + + ret =drm_atomic_set_crtc_for_plane (plane_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (plane_state,NULL ); + plane_state->crtc_x =0 ; + plane_state->crtc_y =0 ; + plane_state->crtc_w =0 ; + plane_state->crtc_h =0 ; + plane_state->src_x =0 ; + plane_state->src_y =0 ; + plane_state->src_w =0 ; + plane_state->src_h =0 ; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_disable_plane); + +static int update_output_state (struct drm_atomic_state *state, +struct drm_mode_set *set) +{ +struct drm_device *dev = set->crtc->dev; +struct drm_crtc *crtc; +struct drm_crtc_state *new_crtc_state; +struct drm_connector *connector; +struct drm_connector_state *new_conn_state; +int ret, i; + + ret =drm_modeset_lock (&dev->mode_config.connection_mutex, + state->acquire_ctx); +if (ret) +return ret; + +/* First disable all connectors on the target crtc. */ + ret =drm_atomic_add_affected_connectors (state, set->crtc); +if (ret) +return ret; + +for_each_new_connector_in_state (state, connector, new_conn_state, i) { +if (new_conn_state->crtc == set->crtc) { + ret =drm_atomic_set_crtc_for_connector (new_conn_state, +NULL ); +if (ret) +return ret; + +/* Make sure legacy setCrtc always re-trains */ + new_conn_state->link_status =DRM_LINK_STATUS_GOOD ; + } + } + +/* Then set all connectors from set->connectors on the target crtc */ +for (i =0 ; i < set->num_connectors; i++) { + new_conn_state =drm_atomic_get_connector_state (state, + set->connectors[i]); +if (IS_ERR (new_conn_state)) +return PTR_ERR (new_conn_state); + + ret =drm_atomic_set_crtc_for_connector (new_conn_state, + set->crtc); +if (ret) +return ret; + } + +for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { +/* +* Don't update ->enable for the CRTC in the set_config request, +* since a mismatch would indicate a bug in the upper layers. +* The actual modeset code later on will catch any +* inconsistencies here. +*/ +if (crtc == set->crtc) +continue ; + +if (!new_crtc_state->connector_mask) { + ret =drm_atomic_set_mode_prop_for_crtc (new_crtc_state, +NULL ); +if (ret <0 ) +return ret; + + new_crtc_state->active = false; + } + } + +return 0 ; +} + +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state) +{ +struct drm_crtc_state *crtc_state; +struct drm_plane_state *primary_state; +struct drm_crtc *crtc = set->crtc; +int hdisplay, vdisplay; +int ret; + + crtc_state =drm_atomic_get_crtc_state (state, crtc); +if (IS_ERR (crtc_state)) +return PTR_ERR (crtc_state); + + primary_state =drm_atomic_get_plane_state (state, crtc->primary); +if (IS_ERR (primary_state)) +return PTR_ERR (primary_state); + +if (!set->mode) { +WARN_ON (set->fb); +WARN_ON (set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state,NULL ); +if (ret !=0 ) +return ret; + + crtc_state->active = false; + + ret =drm_atomic_set_crtc_for_plane (primary_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (primary_state,NULL ); + + goto commit; + } + +WARN_ON (!set->fb); +WARN_ON (!set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state, set->mode); +if (ret !=0 ) +return ret; + + crtc_state->active = true; + + ret =drm_atomic_set_crtc_for_plane (primary_state, crtc); +if (ret !=0 ) +return ret; + +drm_mode_get_hv_timing (set->mode, &hdisplay, &vdisplay); + +drm_atomic_set_fb_for_plane (primary_state, set->fb); + primary_state->crtc_x =0 ; + primary_state->crtc_y =0 ; + primary_state->crtc_w = hdisplay; + primary_state->crtc_h = vdisplay; + primary_state->src_x = set->x <<16 ; + primary_state->src_y = set->y <<16 ; +if (drm_rotation_90_or_270 (primary_state->rotation)) { + primary_state->src_w = vdisplay <<16 ; + primary_state->src_h = hdisplay <<16 ; + }else { + primary_state->src_w = hdisplay <<16 ; + primary_state->src_h = vdisplay <<16 ; + } + +commit: + ret =update_output_state (state, set); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_set_config); +void drm_atomic_print_state (const struct drm_atomic_state *state) {struct drm_printer p =drm_info_printer (state->dev->dev);
drivers/gpu/drm/drm_atomic_helper.c +0 -164
176 lines not on this page · raw message
drivers/gpu/drm/drm_crtc_internal.h +5 -0
@@ -207,6 +207,11 @@ struct drm_minor;int drm_atomic_debugfs_init (struct drm_minor *minor);#endif +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state); +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state); +void drm_atomic_print_state (const struct drm_atomic_state *state);/* drm_atomic_uapi.c */
include/drm/drm_atomic_helper.h +0 -4
@@ -117,12 +117,8 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane, struct drm_modeset_acquire_ctx *ctx);int drm_atomic_helper_disable_plane (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_disable_plane (struct drm_plane *plane, -struct drm_plane_state *plane_state);int drm_atomic_helper_set_config (struct drm_mode_set *set,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_set_config (struct drm_mode_set *set, -struct drm_atomic_state *state);int drm_atomic_helper_disable_all (struct drm_device *dev,struct drm_modeset_acquire_ctx *ctx);
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 03/16] drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
Quoted 10 lines · Noralf Trønnes
Prepare for moving
drm_fb_helpermodesetting code todrm_client.drm_clientwill be linked to drm.ko, so move__drm_atomic_helper_disable_plane()and__drm_atomic_helper_set_config()out of drm_kms_helper.ko.While at it, fix two checkpatch complaints:
- WARNING: Block comments use a trailing */ on a separate line
- CHECK: Alignment should match open parenthesisSigned-off-by Noralf Trønnes <[email protected]>
Triggers a bit my midlayer ocd, but I can't come up with a better idea either.
Quoted 408 lines
--- drivers/gpu/drm/drm_atomic.c | 168 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --------------------------- drivers/gpu/drm/drm_crtc_internal.h | 5 + include/drm/drm_atomic_helper.h | 4 - 4 files changed, 173 insertions(+), 168 deletions(-)drivers/gpu/drm/drm_atomic.c +168
-0@@ -1130,6 +1130,174 @@ int drm_atomic_nonblocking_commit(struct drm_atomic_state *state) }EXPORT_SYMBOL (drm_atomic_nonblocking_commit); +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state) +{ +int ret; + + ret =drm_atomic_set_crtc_for_plane (plane_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (plane_state,NULL ); + plane_state->crtc_x =0 ; + plane_state->crtc_y =0 ; + plane_state->crtc_w =0 ; + plane_state->crtc_h =0 ; + plane_state->src_x =0 ; + plane_state->src_y =0 ; + plane_state->src_w =0 ; + plane_state->src_h =0 ; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_disable_plane); + +static int update_output_state (struct drm_atomic_state *state, +struct drm_mode_set *set) +{ +struct drm_device *dev = set->crtc->dev; +struct drm_crtc *crtc; +struct drm_crtc_state *new_crtc_state; +struct drm_connector *connector; +struct drm_connector_state *new_conn_state; +int ret, i; + + ret =drm_modeset_lock (&dev->mode_config.connection_mutex, + state->acquire_ctx); +if (ret) +return ret; + +/* First disable all connectors on the target crtc. */ + ret =drm_atomic_add_affected_connectors (state, set->crtc); +if (ret) +return ret; + +for_each_new_connector_in_state (state, connector, new_conn_state, i) { +if (new_conn_state->crtc == set->crtc) { + ret =drm_atomic_set_crtc_for_connector (new_conn_state, +NULL ); +if (ret) +return ret; + +/* Make sure legacy setCrtc always re-trains */ + new_conn_state->link_status =DRM_LINK_STATUS_GOOD ; + } + } + +/* Then set all connectors from set->connectors on the target crtc */ +for (i =0 ; i < set->num_connectors; i++) { + new_conn_state =drm_atomic_get_connector_state (state, + set->connectors[i]); +if (IS_ERR (new_conn_state)) +return PTR_ERR (new_conn_state); + + ret =drm_atomic_set_crtc_for_connector (new_conn_state, + set->crtc); +if (ret) +return ret; + } + +for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { +/* +* Don't update ->enable for the CRTC in the set_config request, +* since a mismatch would indicate a bug in the upper layers. +* The actual modeset code later on will catch any +* inconsistencies here. +*/ +if (crtc == set->crtc) +continue ; + +if (!new_crtc_state->connector_mask) { + ret =drm_atomic_set_mode_prop_for_crtc (new_crtc_state, +NULL ); +if (ret <0 ) +return ret; + + new_crtc_state->active = false; + } + } + +return 0 ; +} + +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state) +{ +struct drm_crtc_state *crtc_state; +struct drm_plane_state *primary_state; +struct drm_crtc *crtc = set->crtc; +int hdisplay, vdisplay; +int ret; + + crtc_state =drm_atomic_get_crtc_state (state, crtc); +if (IS_ERR (crtc_state)) +return PTR_ERR (crtc_state); + + primary_state =drm_atomic_get_plane_state (state, crtc->primary); +if (IS_ERR (primary_state)) +return PTR_ERR (primary_state); + +if (!set->mode) { +WARN_ON (set->fb); +WARN_ON (set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state,NULL ); +if (ret !=0 ) +return ret; + + crtc_state->active = false; + + ret =drm_atomic_set_crtc_for_plane (primary_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (primary_state,NULL ); + + goto commit; + } + +WARN_ON (!set->fb); +WARN_ON (!set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state, set->mode); +if (ret !=0 ) +return ret; + + crtc_state->active = true; + + ret =drm_atomic_set_crtc_for_plane (primary_state, crtc); +if (ret !=0 ) +return ret; + +drm_mode_get_hv_timing (set->mode, &hdisplay, &vdisplay); + +drm_atomic_set_fb_for_plane (primary_state, set->fb); + primary_state->crtc_x =0 ; + primary_state->crtc_y =0 ; + primary_state->crtc_w = hdisplay; + primary_state->crtc_h = vdisplay; + primary_state->src_x = set->x <<16 ; + primary_state->src_y = set->y <<16 ; +if (drm_rotation_90_or_270 (primary_state->rotation)) { + primary_state->src_w = vdisplay <<16 ; + primary_state->src_h = hdisplay <<16 ; + }else { + primary_state->src_w = hdisplay <<16 ; + primary_state->src_h = vdisplay <<16 ; + } + +commit: + ret =update_output_state (state, set); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_set_config); +void drm_atomic_print_state (const struct drm_atomic_state *state) {struct drm_printer p =drm_info_printer (state->dev->dev);drivers/gpu/drm/drm_atomic_helper.c +0
-164@@ -2831,95 +2831,6 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane, }EXPORT_SYMBOL (drm_atomic_helper_disable_plane); -/* just used from fb-helper and atomic-helper: */ -int __drm_atomic_helper_disable_plane (struct drm_plane *plane, -struct drm_plane_state *plane_state) -{ -int ret; - - ret =drm_atomic_set_crtc_for_plane (plane_state,NULL ); -if (ret !=0 ) -return ret; - -drm_atomic_set_fb_for_plane (plane_state,NULL ); - plane_state->crtc_x =0 ; - plane_state->crtc_y =0 ; - plane_state->crtc_w =0 ; - plane_state->crtc_h =0 ; - plane_state->src_x =0 ; - plane_state->src_y =0 ; - plane_state->src_w =0 ; - plane_state->src_h =0 ; - -return 0 ; -} - -static int update_output_state (struct drm_atomic_state *state, -struct drm_mode_set *set) -{ -struct drm_device *dev = set->crtc->dev; -struct drm_crtc *crtc; -struct drm_crtc_state *new_crtc_state; -struct drm_connector *connector; -struct drm_connector_state *new_conn_state; -int ret, i; - - ret =drm_modeset_lock (&dev->mode_config.connection_mutex, - state->acquire_ctx); -if (ret) -return ret; - -/* First disable all connectors on the target crtc. */ - ret =drm_atomic_add_affected_connectors (state, set->crtc); -if (ret) -return ret; - -for_each_new_connector_in_state (state, connector, new_conn_state, i) { -if (new_conn_state->crtc == set->crtc) { - ret =drm_atomic_set_crtc_for_connector (new_conn_state, -NULL ); -if (ret) -return ret; - -/* Make sure legacy setCrtc always re-trains */ - new_conn_state->link_status =DRM_LINK_STATUS_GOOD ; - } - } - -/* Then set all connectors from set->connectors on the target crtc */ -for (i =0 ; i < set->num_connectors; i++) { - new_conn_state =drm_atomic_get_connector_state (state, - set->connectors[i]); -if (IS_ERR (new_conn_state)) -return PTR_ERR (new_conn_state); - - ret =drm_atomic_set_crtc_for_connector (new_conn_state, - set->crtc); -if (ret) -return ret; - } - -for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { -/* Don't update ->enable for the CRTC in the set_config request, -* since a mismatch would indicate a bug in the upper layers. -* The actual modeset code later on will catch any -* inconsistencies here. */ -if (crtc == set->crtc) -continue ; - -if (!new_crtc_state->connector_mask) { - ret =drm_atomic_set_mode_prop_for_crtc (new_crtc_state, -NULL ); -if (ret <0 ) -return ret; - - new_crtc_state->active = false; - } - } - -return 0 ; -} -/** * drm_atomic_helper_set_config - set a new config from userspace * @set: mode set configuration @@ -2964,81 +2875,6 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set, }EXPORT_SYMBOL (drm_atomic_helper_set_config); -/* just used from fb-helper and atomic-helper: */ -int __drm_atomic_helper_set_config (struct drm_mode_set *set, -struct drm_atomic_state *state) -{ -struct drm_crtc_state *crtc_state; -struct drm_plane_state *primary_state; -struct drm_crtc *crtc = set->crtc; -int hdisplay, vdisplay; -int ret; - - crtc_state =drm_atomic_get_crtc_state (state, crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); - - primary_state =drm_atomic_get_plane_state (state, crtc->primary); -if (IS_ERR (primary_state)) -return PTR_ERR (primary_state); - -if (!set->mode) { -WARN_ON (set->fb); -WARN_ON (set->num_connectors); - - ret =drm_atomic_set_mode_for_crtc (crtc_state,NULL ); -if (ret !=0 ) -return ret; - - crtc_state->active = false; - - ret =drm_atomic_set_crtc_for_plane (primary_state,NULL ); -if (ret !=0 ) -return ret; - -drm_atomic_set_fb_for_plane (primary_state,NULL ); - - goto commit; - } - -WARN_ON (!set->fb); -WARN_ON (!set->num_connectors); - - ret =drm_atomic_set_mode_for_crtc (crtc_state, set->mode); -if (ret !=0 ) -return ret; - - crtc_state->active = true; - - ret =drm_atomic_set_crtc_for_plane (primary_state, crtc); -if (ret !=0 ) -return ret; - -drm_mode_get_hv_timing (set->mode, &hdisplay, &vdisplay); - -drm_atomic_set_fb_for_plane (primary_state, set->fb); - primary_state->crtc_x =0 ; - primary_state->crtc_y =0 ; - primary_state->crtc_w = hdisplay; - primary_state->crtc_h = vdisplay; - primary_state->src_x = set->x <<16 ; - primary_state->src_y = set->y <<16 ; -if (drm_rotation_90_or_270 (primary_state->rotation)) { - primary_state->src_w = vdisplay <<16 ; - primary_state->src_h = hdisplay <<16 ; - }else { - primary_state->src_w = hdisplay <<16 ; - primary_state->src_h = vdisplay <<16 ; - } - -commit: - ret =update_output_state (state, set); -if (ret) -return ret; - -return 0 ; -} -static int __drm_atomic_helper_disable_all (struct drm_device *dev,struct drm_modeset_acquire_ctx *ctx,bool clean_old_fbs)drivers/gpu/drm/drm_crtc_internal.h +5
-0@@ -207,6 +207,11 @@ struct drm_minor;int drm_atomic_debugfs_init (struct drm_minor *minor);#endif +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state); +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state); +void drm_atomic_print_state (const struct drm_atomic_state *state);/* drm_atomic_uapi.c */ include/drm/drm_atomic_helper.h +0
-4@@ -117,12 +117,8 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane, struct drm_modeset_acquire_ctx *ctx);int drm_atomic_helper_disable_plane (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_disable_plane (struct drm_plane *plane, -struct drm_plane_state *plane_state);int drm_atomic_helper_set_config (struct drm_mode_set *set,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_set_config (struct drm_mode_set *set, -struct drm_atomic_state *state);int drm_atomic_helper_disable_all (struct drm_device *dev,struct drm_modeset_acquire_ctx *ctx);Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 03/16] drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
Den 26.03.2019 21.48, skrev Daniel Vetter:
Quoted 10 lines · Noralf Trønnes
Quoted 9 lines
Prepare for moving
drm_fb_helpermodesetting code todrm_client.drm_clientwill be linked to drm.ko, so move__drm_atomic_helper_disable_plane()and__drm_atomic_helper_set_config()out of drm_kms_helper.ko.While at it, fix two checkpatch complaints:
- WARNING: Block comments use a trailing */ on a separate line
- CHECK: Alignment should match open parenthesis
Quoted 7 lines
Quoted 1 line
Signed-off-by Noralf Trønnes <[email protected]>Triggers a bit my midlayer ocd, but I can't come up with a better idea either.
Reviewed-by Daniel Vetter <[email protected]>
The Intel CI informed me that this patch didn't apply.
Turns out there's a patch in drm-next by Sean:
drm: Merge __drm_atomic_helper_disable_all() intodrm_atomic_helper_disable_all()
https://cgit.freedesktop.org/drm/drm/commit?id=37406a60fac7de336dec331a8707a94462ac5a5e
Should I move the whole function with the kerneldoc to drm_atomic.c, or should I keep the doc and function in drm_atomic_helper.c and just recreate __drm_atomic_helper_disable_all() and call that ?
Noralf.
Quoted 404 lines
Quoted 404 lines
--- drivers/gpu/drm/drm_atomic.c | 168 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --------------------------- drivers/gpu/drm/drm_crtc_internal.h | 5 + include/drm/drm_atomic_helper.h | 4 - 4 files changed, 173 insertions(+), 168 deletions(-)drivers/gpu/drm/drm_atomic.c +168
-0@@ -1130,6 +1130,174 @@ int drm_atomic_nonblocking_commit(struct drm_atomic_state *state) }EXPORT_SYMBOL (drm_atomic_nonblocking_commit); +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state) +{ +int ret; + + ret =drm_atomic_set_crtc_for_plane (plane_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (plane_state,NULL ); + plane_state->crtc_x =0 ; + plane_state->crtc_y =0 ; + plane_state->crtc_w =0 ; + plane_state->crtc_h =0 ; + plane_state->src_x =0 ; + plane_state->src_y =0 ; + plane_state->src_w =0 ; + plane_state->src_h =0 ; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_disable_plane); + +static int update_output_state (struct drm_atomic_state *state, +struct drm_mode_set *set) +{ +struct drm_device *dev = set->crtc->dev; +struct drm_crtc *crtc; +struct drm_crtc_state *new_crtc_state; +struct drm_connector *connector; +struct drm_connector_state *new_conn_state; +int ret, i; + + ret =drm_modeset_lock (&dev->mode_config.connection_mutex, + state->acquire_ctx); +if (ret) +return ret; + +/* First disable all connectors on the target crtc. */ + ret =drm_atomic_add_affected_connectors (state, set->crtc); +if (ret) +return ret; + +for_each_new_connector_in_state (state, connector, new_conn_state, i) { +if (new_conn_state->crtc == set->crtc) { + ret =drm_atomic_set_crtc_for_connector (new_conn_state, +NULL ); +if (ret) +return ret; + +/* Make sure legacy setCrtc always re-trains */ + new_conn_state->link_status =DRM_LINK_STATUS_GOOD ; + } + } + +/* Then set all connectors from set->connectors on the target crtc */ +for (i =0 ; i < set->num_connectors; i++) { + new_conn_state =drm_atomic_get_connector_state (state, + set->connectors[i]); +if (IS_ERR (new_conn_state)) +return PTR_ERR (new_conn_state); + + ret =drm_atomic_set_crtc_for_connector (new_conn_state, + set->crtc); +if (ret) +return ret; + } + +for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { +/* +* Don't update ->enable for the CRTC in the set_config request, +* since a mismatch would indicate a bug in the upper layers. +* The actual modeset code later on will catch any +* inconsistencies here. +*/ +if (crtc == set->crtc) +continue ; + +if (!new_crtc_state->connector_mask) { + ret =drm_atomic_set_mode_prop_for_crtc (new_crtc_state, +NULL ); +if (ret <0 ) +return ret; + + new_crtc_state->active = false; + } + } + +return 0 ; +} + +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state) +{ +struct drm_crtc_state *crtc_state; +struct drm_plane_state *primary_state; +struct drm_crtc *crtc = set->crtc; +int hdisplay, vdisplay; +int ret; + + crtc_state =drm_atomic_get_crtc_state (state, crtc); +if (IS_ERR (crtc_state)) +return PTR_ERR (crtc_state); + + primary_state =drm_atomic_get_plane_state (state, crtc->primary); +if (IS_ERR (primary_state)) +return PTR_ERR (primary_state); + +if (!set->mode) { +WARN_ON (set->fb); +WARN_ON (set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state,NULL ); +if (ret !=0 ) +return ret; + + crtc_state->active = false; + + ret =drm_atomic_set_crtc_for_plane (primary_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (primary_state,NULL ); + + goto commit; + } + +WARN_ON (!set->fb); +WARN_ON (!set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state, set->mode); +if (ret !=0 ) +return ret; + + crtc_state->active = true; + + ret =drm_atomic_set_crtc_for_plane (primary_state, crtc); +if (ret !=0 ) +return ret; + +drm_mode_get_hv_timing (set->mode, &hdisplay, &vdisplay); + +drm_atomic_set_fb_for_plane (primary_state, set->fb); + primary_state->crtc_x =0 ; + primary_state->crtc_y =0 ; + primary_state->crtc_w = hdisplay; + primary_state->crtc_h = vdisplay; + primary_state->src_x = set->x <<16 ; + primary_state->src_y = set->y <<16 ; +if (drm_rotation_90_or_270 (primary_state->rotation)) { + primary_state->src_w = vdisplay <<16 ; + primary_state->src_h = hdisplay <<16 ; + }else { + primary_state->src_w = hdisplay <<16 ; + primary_state->src_h = vdisplay <<16 ; + } + +commit: + ret =update_output_state (state, set); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_set_config); +void drm_atomic_print_state (const struct drm_atomic_state *state) {struct drm_printer p =drm_info_printer (state->dev->dev);drivers/gpu/drm/drm_atomic_helper.c +0
-164@@ -2831,95 +2831,6 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane, }EXPORT_SYMBOL (drm_atomic_helper_disable_plane); -/* just used from fb-helper and atomic-helper: */ -int __drm_atomic_helper_disable_plane (struct drm_plane *plane, -struct drm_plane_state *plane_state) -{ -int ret; - - ret =drm_atomic_set_crtc_for_plane (plane_state,NULL ); -if (ret !=0 ) -return ret; - -drm_atomic_set_fb_for_plane (plane_state,NULL ); - plane_state->crtc_x =0 ; - plane_state->crtc_y =0 ; - plane_state->crtc_w =0 ; - plane_state->crtc_h =0 ; - plane_state->src_x =0 ; - plane_state->src_y =0 ; - plane_state->src_w =0 ; - plane_state->src_h =0 ; - -return 0 ; -} - -static int update_output_state (struct drm_atomic_state *state, -struct drm_mode_set *set) -{ -struct drm_device *dev = set->crtc->dev; -struct drm_crtc *crtc; -struct drm_crtc_state *new_crtc_state; -struct drm_connector *connector; -struct drm_connector_state *new_conn_state; -int ret, i; - - ret =drm_modeset_lock (&dev->mode_config.connection_mutex, - state->acquire_ctx); -if (ret) -return ret; - -/* First disable all connectors on the target crtc. */ - ret =drm_atomic_add_affected_connectors (state, set->crtc); -if (ret) -return ret; - -for_each_new_connector_in_state (state, connector, new_conn_state, i) { -if (new_conn_state->crtc == set->crtc) { - ret =drm_atomic_set_crtc_for_connector (new_conn_state, -NULL ); -if (ret) -return ret; - -/* Make sure legacy setCrtc always re-trains */ - new_conn_state->link_status =DRM_LINK_STATUS_GOOD ; - } - } - -/* Then set all connectors from set->connectors on the target crtc */ -for (i =0 ; i < set->num_connectors; i++) { - new_conn_state =drm_atomic_get_connector_state (state, - set->connectors[i]); -if (IS_ERR (new_conn_state)) -return PTR_ERR (new_conn_state); - - ret =drm_atomic_set_crtc_for_connector (new_conn_state, - set->crtc); -if (ret) -return ret; - } - -for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { -/* Don't update ->enable for the CRTC in the set_config request, -* since a mismatch would indicate a bug in the upper layers. -* The actual modeset code later on will catch any -* inconsistencies here. */ -if (crtc == set->crtc) -continue ; - -if (!new_crtc_state->connector_mask) { - ret =drm_atomic_set_mode_prop_for_crtc (new_crtc_state, -NULL ); -if (ret <0 ) -return ret; - - new_crtc_state->active = false; - } - } - -return 0 ; -} -/** * drm_atomic_helper_set_config - set a new config from userspace * @set: mode set configuration @@ -2964,81 +2875,6 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set, }EXPORT_SYMBOL (drm_atomic_helper_set_config); -/* just used from fb-helper and atomic-helper: */ -int __drm_atomic_helper_set_config (struct drm_mode_set *set, -struct drm_atomic_state *state) -{ -struct drm_crtc_state *crtc_state; -struct drm_plane_state *primary_state; -struct drm_crtc *crtc = set->crtc; -int hdisplay, vdisplay; -int ret; - - crtc_state =drm_atomic_get_crtc_state (state, crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); - - primary_state =drm_atomic_get_plane_state (state, crtc->primary); -if (IS_ERR (primary_state)) -return PTR_ERR (primary_state); - -if (!set->mode) { -WARN_ON (set->fb); -WARN_ON (set->num_connectors); - - ret =drm_atomic_set_mode_for_crtc (crtc_state,NULL ); -if (ret !=0 ) -return ret; - - crtc_state->active = false; - - ret =drm_atomic_set_crtc_for_plane (primary_state,NULL ); -if (ret !=0 ) -return ret; - -drm_atomic_set_fb_for_plane (primary_state,NULL ); - - goto commit; - } - -WARN_ON (!set->fb); -WARN_ON (!set->num_connectors); - - ret =drm_atomic_set_mode_for_crtc (crtc_state, set->mode); -if (ret !=0 ) -return ret; - - crtc_state->active = true; - - ret =drm_atomic_set_crtc_for_plane (primary_state, crtc); -if (ret !=0 ) -return ret; - -drm_mode_get_hv_timing (set->mode, &hdisplay, &vdisplay); - -drm_atomic_set_fb_for_plane (primary_state, set->fb); - primary_state->crtc_x =0 ; - primary_state->crtc_y =0 ; - primary_state->crtc_w = hdisplay; - primary_state->crtc_h = vdisplay; - primary_state->src_x = set->x <<16 ; - primary_state->src_y = set->y <<16 ; -if (drm_rotation_90_or_270 (primary_state->rotation)) { - primary_state->src_w = vdisplay <<16 ; - primary_state->src_h = hdisplay <<16 ; - }else { - primary_state->src_w = hdisplay <<16 ; - primary_state->src_h = vdisplay <<16 ; - } - -commit: - ret =update_output_state (state, set); -if (ret) -return ret; - -return 0 ; -} -static int __drm_atomic_helper_disable_all (struct drm_device *dev,struct drm_modeset_acquire_ctx *ctx,bool clean_old_fbs)drivers/gpu/drm/drm_crtc_internal.h +5
-0@@ -207,6 +207,11 @@ struct drm_minor;int drm_atomic_debugfs_init (struct drm_minor *minor);#endif +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state); +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state); +void drm_atomic_print_state (const struct drm_atomic_state *state);/* drm_atomic_uapi.c */ include/drm/drm_atomic_helper.h +0
-4@@ -117,12 +117,8 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane, struct drm_modeset_acquire_ctx *ctx);int drm_atomic_helper_disable_plane (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_disable_plane (struct drm_plane *plane, -struct drm_plane_state *plane_state);int drm_atomic_helper_set_config (struct drm_mode_set *set,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_set_config (struct drm_mode_set *set, -struct drm_atomic_state *state);int drm_atomic_helper_disable_all (struct drm_device *dev,struct drm_modeset_acquire_ctx *ctx);Signature · 1 line
2.20.1
Quoted 5 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 03/16] drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
Quoted 26 lines · Noralf Trønnes
Den 26.03.2019 21.48, skrev Daniel Vetter:
Quoted 10 lines · Noralf Trønnes
Quoted 9 lines
Prepare for moving
drm_fb_helpermodesetting code todrm_client.drm_clientwill be linked to drm.ko, so move__drm_atomic_helper_disable_plane()and__drm_atomic_helper_set_config()out of drm_kms_helper.ko.While at it, fix two checkpatch complaints:
- WARNING: Block comments use a trailing */ on a separate line
- CHECK: Alignment should match open parenthesisQuoted 7 lines
Quoted 1 line
Signed-off-by Noralf Trønnes <[email protected]>Triggers a bit my midlayer ocd, but I can't come up with a better idea either.
Reviewed-by Daniel Vetter <[email protected]>The Intel CI informed me that this patch didn't apply..
Turns out there's a patch in drm-next by Sean:
Quoted 8 lines
drm: Merge
__drm_atomic_helper_disable_all()intodrm_atomic_helper_disable_all()https://cgit.freedesktop.org/drm/drm/commit?id=37406a60fac7de336dec331a8707a94462ac5a5e
Should I move the whole function with the kerneldoc to
drm_atomic.c, or should I keep the doc and function indrm_atomic_helper.cand just recreate__drm_atomic_helper_disable_all()and call that ?
So my longterm goal with all these compat helpers is to move them into the core anyway, and make them at least the default, if not only the only accepted choice for atomic drivers. We've already done that for the dpms hook. We can't make it the enforced default yet for planes because of cursors, but I think we could just move both of these into the core (disable_plane and update_plane), make it the default option, and remove all driver users that just set it as the default hook.
Would need to be renamed to something like drm_atomic_default_* ofc.
Not sure why you're talking about disable_all here though, since that doesn't seem to be touched in this patch at all?
-Daniel
Quoted 412 lines
Noralf.
Quoted 409 lines
Quoted 408 lines
--- drivers/gpu/drm/drm_atomic.c | 168 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --------------------------- drivers/gpu/drm/drm_crtc_internal.h | 5 + include/drm/drm_atomic_helper.h | 4 - 4 files changed, 173 insertions(+), 168 deletions(-)drivers/gpu/drm/drm_atomic.c +168
-0@@ -1130,6 +1130,174 @@ int drm_atomic_nonblocking_commit(struct drm_atomic_state *state) }EXPORT_SYMBOL (drm_atomic_nonblocking_commit); +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state) +{ +int ret; + + ret =drm_atomic_set_crtc_for_plane (plane_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (plane_state,NULL ); + plane_state->crtc_x =0 ; + plane_state->crtc_y =0 ; + plane_state->crtc_w =0 ; + plane_state->crtc_h =0 ; + plane_state->src_x =0 ; + plane_state->src_y =0 ; + plane_state->src_w =0 ; + plane_state->src_h =0 ; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_disable_plane); + +static int update_output_state (struct drm_atomic_state *state, +struct drm_mode_set *set) +{ +struct drm_device *dev = set->crtc->dev; +struct drm_crtc *crtc; +struct drm_crtc_state *new_crtc_state; +struct drm_connector *connector; +struct drm_connector_state *new_conn_state; +int ret, i; + + ret =drm_modeset_lock (&dev->mode_config.connection_mutex, + state->acquire_ctx); +if (ret) +return ret; + +/* First disable all connectors on the target crtc. */ + ret =drm_atomic_add_affected_connectors (state, set->crtc); +if (ret) +return ret; + +for_each_new_connector_in_state (state, connector, new_conn_state, i) { +if (new_conn_state->crtc == set->crtc) { + ret =drm_atomic_set_crtc_for_connector (new_conn_state, +NULL ); +if (ret) +return ret; + +/* Make sure legacy setCrtc always re-trains */ + new_conn_state->link_status =DRM_LINK_STATUS_GOOD ; + } + } + +/* Then set all connectors from set->connectors on the target crtc */ +for (i =0 ; i < set->num_connectors; i++) { + new_conn_state =drm_atomic_get_connector_state (state, + set->connectors[i]); +if (IS_ERR (new_conn_state)) +return PTR_ERR (new_conn_state); + + ret =drm_atomic_set_crtc_for_connector (new_conn_state, + set->crtc); +if (ret) +return ret; + } + +for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { +/* +* Don't update ->enable for the CRTC in the set_config request, +* since a mismatch would indicate a bug in the upper layers. +* The actual modeset code later on will catch any +* inconsistencies here. +*/ +if (crtc == set->crtc) +continue ; + +if (!new_crtc_state->connector_mask) { + ret =drm_atomic_set_mode_prop_for_crtc (new_crtc_state, +NULL ); +if (ret <0 ) +return ret; + + new_crtc_state->active = false; + } + } + +return 0 ; +} + +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state) +{ +struct drm_crtc_state *crtc_state; +struct drm_plane_state *primary_state; +struct drm_crtc *crtc = set->crtc; +int hdisplay, vdisplay; +int ret; + + crtc_state =drm_atomic_get_crtc_state (state, crtc); +if (IS_ERR (crtc_state)) +return PTR_ERR (crtc_state); + + primary_state =drm_atomic_get_plane_state (state, crtc->primary); +if (IS_ERR (primary_state)) +return PTR_ERR (primary_state); + +if (!set->mode) { +WARN_ON (set->fb); +WARN_ON (set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state,NULL ); +if (ret !=0 ) +return ret; + + crtc_state->active = false; + + ret =drm_atomic_set_crtc_for_plane (primary_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (primary_state,NULL ); + + goto commit; + } + +WARN_ON (!set->fb); +WARN_ON (!set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state, set->mode); +if (ret !=0 ) +return ret; + + crtc_state->active = true; + + ret =drm_atomic_set_crtc_for_plane (primary_state, crtc); +if (ret !=0 ) +return ret; + +drm_mode_get_hv_timing (set->mode, &hdisplay, &vdisplay); + +drm_atomic_set_fb_for_plane (primary_state, set->fb); + primary_state->crtc_x =0 ; + primary_state->crtc_y =0 ; + primary_state->crtc_w = hdisplay; + primary_state->crtc_h = vdisplay; + primary_state->src_x = set->x <<16 ; + primary_state->src_y = set->y <<16 ; +if (drm_rotation_90_or_270 (primary_state->rotation)) { + primary_state->src_w = vdisplay <<16 ; + primary_state->src_h = hdisplay <<16 ; + }else { + primary_state->src_w = hdisplay <<16 ; + primary_state->src_h = vdisplay <<16 ; + } + +commit: + ret =update_output_state (state, set); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_set_config); +void drm_atomic_print_state (const struct drm_atomic_state *state) {struct drm_printer p =drm_info_printer (state->dev->dev);drivers/gpu/drm/drm_atomic_helper.c +0
-164@@ -2831,95 +2831,6 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane, }EXPORT_SYMBOL (drm_atomic_helper_disable_plane); -/* just used from fb-helper and atomic-helper: */ -int __drm_atomic_helper_disable_plane (struct drm_plane *plane, -struct drm_plane_state *plane_state) -{ -int ret; - - ret =drm_atomic_set_crtc_for_plane (plane_state,NULL ); -if (ret !=0 ) -return ret; - -drm_atomic_set_fb_for_plane (plane_state,NULL ); - plane_state->crtc_x =0 ; - plane_state->crtc_y =0 ; - plane_state->crtc_w =0 ; - plane_state->crtc_h =0 ; - plane_state->src_x =0 ; - plane_state->src_y =0 ; - plane_state->src_w =0 ; - plane_state->src_h =0 ; - -return 0 ; -} - -static int update_output_state (struct drm_atomic_state *state, -struct drm_mode_set *set) -{ -struct drm_device *dev = set->crtc->dev; -struct drm_crtc *crtc; -struct drm_crtc_state *new_crtc_state; -struct drm_connector *connector; -struct drm_connector_state *new_conn_state; -int ret, i; - - ret =drm_modeset_lock (&dev->mode_config.connection_mutex, - state->acquire_ctx); -if (ret) -return ret; - -/* First disable all connectors on the target crtc. */ - ret =drm_atomic_add_affected_connectors (state, set->crtc); -if (ret) -return ret; - -for_each_new_connector_in_state (state, connector, new_conn_state, i) { -if (new_conn_state->crtc == set->crtc) { - ret =drm_atomic_set_crtc_for_connector (new_conn_state, -NULL ); -if (ret) -return ret; - -/* Make sure legacy setCrtc always re-trains */ - new_conn_state->link_status =DRM_LINK_STATUS_GOOD ; - } - } - -/* Then set all connectors from set->connectors on the target crtc */ -for (i =0 ; i < set->num_connectors; i++) { - new_conn_state =drm_atomic_get_connector_state (state, - set->connectors[i]); -if (IS_ERR (new_conn_state)) -return PTR_ERR (new_conn_state); - - ret =drm_atomic_set_crtc_for_connector (new_conn_state, - set->crtc); -if (ret) -return ret; - } - -for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { -/* Don't update ->enable for the CRTC in the set_config request, -* since a mismatch would indicate a bug in the upper layers. -* The actual modeset code later on will catch any -* inconsistencies here. */ -if (crtc == set->crtc) -continue ; - -if (!new_crtc_state->connector_mask) { - ret =drm_atomic_set_mode_prop_for_crtc (new_crtc_state, -NULL ); -if (ret <0 ) -return ret; - - new_crtc_state->active = false; - } - } - -return 0 ; -} -/** * drm_atomic_helper_set_config - set a new config from userspace * @set: mode set configuration @@ -2964,81 +2875,6 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set, }EXPORT_SYMBOL (drm_atomic_helper_set_config); -/* just used from fb-helper and atomic-helper: */ -int __drm_atomic_helper_set_config (struct drm_mode_set *set, -struct drm_atomic_state *state) -{ -struct drm_crtc_state *crtc_state; -struct drm_plane_state *primary_state; -struct drm_crtc *crtc = set->crtc; -int hdisplay, vdisplay; -int ret; - - crtc_state =drm_atomic_get_crtc_state (state, crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); - - primary_state =drm_atomic_get_plane_state (state, crtc->primary); -if (IS_ERR (primary_state)) -return PTR_ERR (primary_state); - -if (!set->mode) { -WARN_ON (set->fb); -WARN_ON (set->num_connectors); - - ret =drm_atomic_set_mode_for_crtc (crtc_state,NULL ); -if (ret !=0 ) -return ret; - - crtc_state->active = false; - - ret =drm_atomic_set_crtc_for_plane (primary_state,NULL ); -if (ret !=0 ) -return ret; - -drm_atomic_set_fb_for_plane (primary_state,NULL ); - - goto commit; - } - -WARN_ON (!set->fb); -WARN_ON (!set->num_connectors); - - ret =drm_atomic_set_mode_for_crtc (crtc_state, set->mode); -if (ret !=0 ) -return ret; - - crtc_state->active = true; - - ret =drm_atomic_set_crtc_for_plane (primary_state, crtc); -if (ret !=0 ) -return ret; - -drm_mode_get_hv_timing (set->mode, &hdisplay, &vdisplay); - -drm_atomic_set_fb_for_plane (primary_state, set->fb); - primary_state->crtc_x =0 ; - primary_state->crtc_y =0 ; - primary_state->crtc_w = hdisplay; - primary_state->crtc_h = vdisplay; - primary_state->src_x = set->x <<16 ; - primary_state->src_y = set->y <<16 ; -if (drm_rotation_90_or_270 (primary_state->rotation)) { - primary_state->src_w = vdisplay <<16 ; - primary_state->src_h = hdisplay <<16 ; - }else { - primary_state->src_w = hdisplay <<16 ; - primary_state->src_h = vdisplay <<16 ; - } - -commit: - ret =update_output_state (state, set); -if (ret) -return ret; - -return 0 ; -} -static int __drm_atomic_helper_disable_all (struct drm_device *dev,struct drm_modeset_acquire_ctx *ctx,bool clean_old_fbs)drivers/gpu/drm/drm_crtc_internal.h +5
-0@@ -207,6 +207,11 @@ struct drm_minor;int drm_atomic_debugfs_init (struct drm_minor *minor);#endif +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state); +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state); +void drm_atomic_print_state (const struct drm_atomic_state *state);/* drm_atomic_uapi.c */ include/drm/drm_atomic_helper.h +0
-5@@ -117,12 +117,8 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane, struct drm_modeset_acquire_ctx *ctx);int drm_atomic_helper_disable_plane (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_disable_plane (struct drm_plane *plane, -struct drm_plane_state *plane_state);int drm_atomic_helper_set_config (struct drm_mode_set *set,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_set_config (struct drm_mode_set *set, -struct drm_atomic_state *state);int drm_atomic_helper_disable_all (struct drm_device *dev,struct drm_modeset_acquire_ctx *ctx); --2.20.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 03/16] drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
Den 27.03.2019 14.55, skrev Daniel Vetter:
Quoted 44 lines · Noralf Trønnes
Quoted 26 lines
Den 26.03.2019 21.48, skrev Daniel Vetter:
Quoted 10 lines · Noralf Trønnes
Quoted 9 lines
Prepare for moving
drm_fb_helpermodesetting code todrm_client.drm_clientwill be linked to drm.ko, so move__drm_atomic_helper_disable_plane()and__drm_atomic_helper_set_config()out of drm_kms_helper.ko.While at it, fix two checkpatch complaints:
- WARNING: Block comments use a trailing */ on a separate line
- CHECK: Alignment should match open parenthesisQuoted 7 lines
Quoted 1 line
Signed-off-by Noralf Trønnes <[email protected]>Triggers a bit my midlayer ocd, but I can't come up with a better idea either.
Reviewed-by Daniel Vetter <[email protected]>The Intel CI informed me that this patch didn't apply..
Turns out there's a patch in drm-next by Sean:
Quoted 8 lines
drm: Merge
__drm_atomic_helper_disable_all()intodrm_atomic_helper_disable_all()https://cgit.freedesktop.org/drm/drm/commit?id=37406a60fac7de336dec331a8707a94462ac5a5e
Should I move the whole function with the kerneldoc to
drm_atomic.c, or should I keep the doc and function indrm_atomic_helper.cand just recreate__drm_atomic_helper_disable_all()and call that ?So my longterm goal with all these compat helpers is to move them into the core anyway, and make them at least the default, if not only the only accepted choice for atomic drivers. We've already done that for the dpms hook. We can't make it the enforced default yet for planes because of cursors, but I think we could just move both of these into the core (
disable_planeandupdate_plane), make it the default option, and remove all driver users that just set it as the default hook.
Quoted 4 lines
Would need to be renamed to something like drm_atomic_default_* ofc.
Not sure why you're talking about
disable_allhere though, since that doesn't seem to be touched in this patch at all?
Sorry my bad, I was just confused. Looking at it again, I see that I can just rebase on top of that patch.
Noralf.
Quoted 417 lines
-Daniel
Quoted 412 lines
Noralf.
Quoted 409 lines
Quoted 408 lines
--- drivers/gpu/drm/drm_atomic.c | 168 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --------------------------- drivers/gpu/drm/drm_crtc_internal.h | 5 + include/drm/drm_atomic_helper.h | 4 - 4 files changed, 173 insertions(+), 168 deletions(-)drivers/gpu/drm/drm_atomic.c +168
-0@@ -1130,6 +1130,174 @@ int drm_atomic_nonblocking_commit(struct drm_atomic_state *state) }EXPORT_SYMBOL (drm_atomic_nonblocking_commit); +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state) +{ +int ret; + + ret =drm_atomic_set_crtc_for_plane (plane_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (plane_state,NULL ); + plane_state->crtc_x =0 ; + plane_state->crtc_y =0 ; + plane_state->crtc_w =0 ; + plane_state->crtc_h =0 ; + plane_state->src_x =0 ; + plane_state->src_y =0 ; + plane_state->src_w =0 ; + plane_state->src_h =0 ; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_disable_plane); + +static int update_output_state (struct drm_atomic_state *state, +struct drm_mode_set *set) +{ +struct drm_device *dev = set->crtc->dev; +struct drm_crtc *crtc; +struct drm_crtc_state *new_crtc_state; +struct drm_connector *connector; +struct drm_connector_state *new_conn_state; +int ret, i; + + ret =drm_modeset_lock (&dev->mode_config.connection_mutex, + state->acquire_ctx); +if (ret) +return ret; + +/* First disable all connectors on the target crtc. */ + ret =drm_atomic_add_affected_connectors (state, set->crtc); +if (ret) +return ret; + +for_each_new_connector_in_state (state, connector, new_conn_state, i) { +if (new_conn_state->crtc == set->crtc) { + ret =drm_atomic_set_crtc_for_connector (new_conn_state, +NULL ); +if (ret) +return ret; + +/* Make sure legacy setCrtc always re-trains */ + new_conn_state->link_status =DRM_LINK_STATUS_GOOD ; + } + } + +/* Then set all connectors from set->connectors on the target crtc */ +for (i =0 ; i < set->num_connectors; i++) { + new_conn_state =drm_atomic_get_connector_state (state, + set->connectors[i]); +if (IS_ERR (new_conn_state)) +return PTR_ERR (new_conn_state); + + ret =drm_atomic_set_crtc_for_connector (new_conn_state, + set->crtc); +if (ret) +return ret; + } + +for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { +/* +* Don't update ->enable for the CRTC in the set_config request, +* since a mismatch would indicate a bug in the upper layers. +* The actual modeset code later on will catch any +* inconsistencies here. +*/ +if (crtc == set->crtc) +continue ; + +if (!new_crtc_state->connector_mask) { + ret =drm_atomic_set_mode_prop_for_crtc (new_crtc_state, +NULL ); +if (ret <0 ) +return ret; + + new_crtc_state->active = false; + } + } + +return 0 ; +} + +/* just used from drm-client and atomic-helper: */ +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state) +{ +struct drm_crtc_state *crtc_state; +struct drm_plane_state *primary_state; +struct drm_crtc *crtc = set->crtc; +int hdisplay, vdisplay; +int ret; + + crtc_state =drm_atomic_get_crtc_state (state, crtc); +if (IS_ERR (crtc_state)) +return PTR_ERR (crtc_state); + + primary_state =drm_atomic_get_plane_state (state, crtc->primary); +if (IS_ERR (primary_state)) +return PTR_ERR (primary_state); + +if (!set->mode) { +WARN_ON (set->fb); +WARN_ON (set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state,NULL ); +if (ret !=0 ) +return ret; + + crtc_state->active = false; + + ret =drm_atomic_set_crtc_for_plane (primary_state,NULL ); +if (ret !=0 ) +return ret; + +drm_atomic_set_fb_for_plane (primary_state,NULL ); + + goto commit; + } + +WARN_ON (!set->fb); +WARN_ON (!set->num_connectors); + + ret =drm_atomic_set_mode_for_crtc (crtc_state, set->mode); +if (ret !=0 ) +return ret; + + crtc_state->active = true; + + ret =drm_atomic_set_crtc_for_plane (primary_state, crtc); +if (ret !=0 ) +return ret; + +drm_mode_get_hv_timing (set->mode, &hdisplay, &vdisplay); + +drm_atomic_set_fb_for_plane (primary_state, set->fb); + primary_state->crtc_x =0 ; + primary_state->crtc_y =0 ; + primary_state->crtc_w = hdisplay; + primary_state->crtc_h = vdisplay; + primary_state->src_x = set->x <<16 ; + primary_state->src_y = set->y <<16 ; +if (drm_rotation_90_or_270 (primary_state->rotation)) { + primary_state->src_w = vdisplay <<16 ; + primary_state->src_h = hdisplay <<16 ; + }else { + primary_state->src_w = hdisplay <<16 ; + primary_state->src_h = vdisplay <<16 ; + } + +commit: + ret =update_output_state (state, set); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL (__drm_atomic_helper_set_config); +void drm_atomic_print_state (const struct drm_atomic_state *state) {struct drm_printer p =drm_info_printer (state->dev->dev);drivers/gpu/drm/drm_atomic_helper.c +0
-164@@ -2831,95 +2831,6 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane, }EXPORT_SYMBOL (drm_atomic_helper_disable_plane); -/* just used from fb-helper and atomic-helper: */ -int __drm_atomic_helper_disable_plane (struct drm_plane *plane, -struct drm_plane_state *plane_state) -{ -int ret; - - ret =drm_atomic_set_crtc_for_plane (plane_state,NULL ); -if (ret !=0 ) -return ret; - -drm_atomic_set_fb_for_plane (plane_state,NULL ); - plane_state->crtc_x =0 ; - plane_state->crtc_y =0 ; - plane_state->crtc_w =0 ; - plane_state->crtc_h =0 ; - plane_state->src_x =0 ; - plane_state->src_y =0 ; - plane_state->src_w =0 ; - plane_state->src_h =0 ; - -return 0 ; -} - -static int update_output_state (struct drm_atomic_state *state, -struct drm_mode_set *set) -{ -struct drm_device *dev = set->crtc->dev; -struct drm_crtc *crtc; -struct drm_crtc_state *new_crtc_state; -struct drm_connector *connector; -struct drm_connector_state *new_conn_state; -int ret, i; - - ret =drm_modeset_lock (&dev->mode_config.connection_mutex, - state->acquire_ctx); -if (ret) -return ret; - -/* First disable all connectors on the target crtc. */ - ret =drm_atomic_add_affected_connectors (state, set->crtc); -if (ret) -return ret; - -for_each_new_connector_in_state (state, connector, new_conn_state, i) { -if (new_conn_state->crtc == set->crtc) { - ret =drm_atomic_set_crtc_for_connector (new_conn_state, -NULL ); -if (ret) -return ret; - -/* Make sure legacy setCrtc always re-trains */ - new_conn_state->link_status =DRM_LINK_STATUS_GOOD ; - } - } - -/* Then set all connectors from set->connectors on the target crtc */ -for (i =0 ; i < set->num_connectors; i++) { - new_conn_state =drm_atomic_get_connector_state (state, - set->connectors[i]); -if (IS_ERR (new_conn_state)) -return PTR_ERR (new_conn_state); - - ret =drm_atomic_set_crtc_for_connector (new_conn_state, - set->crtc); -if (ret) -return ret; - } - -for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { -/* Don't update ->enable for the CRTC in the set_config request, -* since a mismatch would indicate a bug in the upper layers. -* The actual modeset code later on will catch any -* inconsistencies here. */ -if (crtc == set->crtc) -continue ; - -if (!new_crtc_state->connector_mask) { - ret =drm_atomic_set_mode_prop_for_crtc (new_crtc_state, -NULL ); -if (ret <0 ) -return ret; - - new_crtc_state->active = false; - } - } - -return 0 ; -} -/** * drm_atomic_helper_set_config - set a new config from userspace * @set: mode set configuration @@ -2964,81 +2875,6 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set, }EXPORT_SYMBOL (drm_atomic_helper_set_config); -/* just used from fb-helper and atomic-helper: */ -int __drm_atomic_helper_set_config (struct drm_mode_set *set, -struct drm_atomic_state *state) -{ -struct drm_crtc_state *crtc_state; -struct drm_plane_state *primary_state; -struct drm_crtc *crtc = set->crtc; -int hdisplay, vdisplay; -int ret; - - crtc_state =drm_atomic_get_crtc_state (state, crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); - - primary_state =drm_atomic_get_plane_state (state, crtc->primary); -if (IS_ERR (primary_state)) -return PTR_ERR (primary_state); - -if (!set->mode) { -WARN_ON (set->fb); -WARN_ON (set->num_connectors); - - ret =drm_atomic_set_mode_for_crtc (crtc_state,NULL ); -if (ret !=0 ) -return ret; - - crtc_state->active = false; - - ret =drm_atomic_set_crtc_for_plane (primary_state,NULL ); -if (ret !=0 ) -return ret; - -drm_atomic_set_fb_for_plane (primary_state,NULL ); - - goto commit; - } - -WARN_ON (!set->fb); -WARN_ON (!set->num_connectors); - - ret =drm_atomic_set_mode_for_crtc (crtc_state, set->mode); -if (ret !=0 ) -return ret; - - crtc_state->active = true; - - ret =drm_atomic_set_crtc_for_plane (primary_state, crtc); -if (ret !=0 ) -return ret; - -drm_mode_get_hv_timing (set->mode, &hdisplay, &vdisplay); - -drm_atomic_set_fb_for_plane (primary_state, set->fb); - primary_state->crtc_x =0 ; - primary_state->crtc_y =0 ; - primary_state->crtc_w = hdisplay; - primary_state->crtc_h = vdisplay; - primary_state->src_x = set->x <<16 ; - primary_state->src_y = set->y <<16 ; -if (drm_rotation_90_or_270 (primary_state->rotation)) { - primary_state->src_w = vdisplay <<16 ; - primary_state->src_h = hdisplay <<16 ; - }else { - primary_state->src_w = hdisplay <<16 ; - primary_state->src_h = vdisplay <<16 ; - } - -commit: - ret =update_output_state (state, set); -if (ret) -return ret; - -return 0 ; -} -static int __drm_atomic_helper_disable_all (struct drm_device *dev,struct drm_modeset_acquire_ctx *ctx,bool clean_old_fbs)drivers/gpu/drm/drm_crtc_internal.h +5
-0@@ -207,6 +207,11 @@ struct drm_minor;int drm_atomic_debugfs_init (struct drm_minor *minor);#endif +int __drm_atomic_helper_disable_plane (struct drm_plane *plane, +struct drm_plane_state *plane_state); +int __drm_atomic_helper_set_config (struct drm_mode_set *set, +struct drm_atomic_state *state); +void drm_atomic_print_state (const struct drm_atomic_state *state);/* drm_atomic_uapi.c */ include/drm/drm_atomic_helper.h +0
-5@@ -117,12 +117,8 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane, struct drm_modeset_acquire_ctx *ctx);int drm_atomic_helper_disable_plane (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_disable_plane (struct drm_plane *plane, -struct drm_plane_state *plane_state);int drm_atomic_helper_set_config (struct drm_mode_set *set,struct drm_modeset_acquire_ctx *ctx); -int __drm_atomic_helper_set_config (struct drm_mode_set *set, -struct drm_atomic_state *state);int drm_atomic_helper_disable_all (struct drm_device *dev,struct drm_modeset_acquire_ctx *ctx); --2.20.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/16 drm/fb-helper: No need to cache rotation and sw_rotations
In reply to Noralf TrønnesGetting rotation info is cheap so we can do it on demand.
This is done in preparation for the removal of struct drm_fb_helper_crtc.
---
Hans,
You had this comment inline in restore_fbdev_mode_atomic() the last time I sent this out:
We want plane_state->rotation to be set to DRM_MODE_ROTATE_0 in the else case, AFAIK new_plane_state starts with the current state and rotation may have a different value there.
Otherwise this looks good to me.
Rotation is reset for each plane in the code section above the one I'm changing.
Noralf.
drivers/gpu/drm/drm_fb_helper.c | 131 ++++++++++++++++---------------- include/drm/drm_fb_helper.h | 8 -- 2 files changed, 65 insertions(+), 74 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +65 -66
@@ -387,6 +387,49 @@ int drm_fb_helper_debug_leave(struct fb_info *info) }EXPORT_SYMBOL (drm_fb_helper_debug_leave); +/* Check if the plane can hw rotate to match panel orientation */ +static bool drm_fb_helper_panel_rotation (struct drm_mode_set *modeset, +unsigned int *rotation) +{ +struct drm_connector *connector = modeset->connectors[0 ]; +struct drm_plane *plane = modeset->crtc->primary; +u64 valid_mask =0 ; +unsigned int i; + +if (!modeset->num_connectors) +return false; + +switch (connector->display_info.panel_orientation) { +case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP : + *rotation =DRM_MODE_ROTATE_180 ; +break ; +case DRM_MODE_PANEL_ORIENTATION_LEFT_UP : + *rotation =DRM_MODE_ROTATE_90 ; +break ; +case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP : + *rotation =DRM_MODE_ROTATE_270 ; +break ; +default : + *rotation =DRM_MODE_ROTATE_0 ; + } + +/* +* TODO: support 90 / 270 degree hardware rotation, +* depending on the hardware this may require the framebuffer +* to be in a specific tiling format. +*/ +if (*rotation !=DRM_MODE_ROTATE_180 || !plane->rotation_property) +return false; + +for (i =0 ; i < plane->rotation_property->num_values; i++) + valid_mask |= (1ULL << plane->rotation_property->values[i]); + +if (!(*rotation & valid_mask)) +return false; + +return true; +} +static int restore_fbdev_mode_atomic (struct drm_fb_helper *fb_helper,bool active) {struct drm_device *dev = fb_helper->dev;
@@ -427,10 +470,13 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activfor (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_mode_set *mode_set = &fb_helper->crtc_info[i].mode_set;struct drm_plane *primary = mode_set->crtc->primary; +unsigned int rotation; -/* Cannot fail as we've already gotten the plane state above */ - plane_state =drm_atomic_get_new_plane_state (state, primary); - plane_state->rotation = fb_helper->crtc_info[i].rotation; +if (drm_fb_helper_panel_rotation (mode_set, &rotation)) { +/* Cannot fail as we've already gotten the plane state above */ + plane_state =drm_atomic_get_new_plane_state (state, primary); + plane_state->rotation = rotation; + } ret =__drm_atomic_helper_set_config (mode_set, state);if (ret !=0 )
@@ -881,7 +927,6 @@ int drm_fb_helper_init(struct drm_device *dev,if (!fb_helper->crtc_info[i].mode_set.connectors) goto out_free; fb_helper->crtc_info[i].mode_set.num_connectors =0 ; - fb_helper->crtc_info[i].rotation =DRM_MODE_ROTATE_0 ; } i =0 ;
@@ -2500,62 +2545,6 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,return best_score; } -/* -* This function checks if rotation is necessary because of panel orientation -* and if it is, if it is supported. -* If rotation is necessary and supported, it gets set in fb_crtc.rotation. -* If rotation is necessary but not supported, a DRM_MODE_ROTATE_* flag gets -* or-ed into fb_helper->sw_rotations. In drm_setup_crtcs_fb() we check if only -* one bit is set and then we set fb_info.fbcon_rotate_hint to make fbcon do -* the unsupported rotation. -*/ -static void drm_setup_crtc_rotation (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_crtc *fb_crtc, -struct drm_connector *connector) -{ -struct drm_plane *plane = fb_crtc->mode_set.crtc->primary; -uint64_t valid_mask =0 ; -int i, rotation; - - fb_crtc->rotation =DRM_MODE_ROTATE_0 ; - -switch (connector->display_info.panel_orientation) { -case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP : - rotation =DRM_MODE_ROTATE_180 ; -break ; -case DRM_MODE_PANEL_ORIENTATION_LEFT_UP : - rotation =DRM_MODE_ROTATE_90 ; -break ; -case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP : - rotation =DRM_MODE_ROTATE_270 ; -break ; -default : - rotation =DRM_MODE_ROTATE_0 ; - } - -/* -* TODO: support 90 / 270 degree hardware rotation, -* depending on the hardware this may require the framebuffer -* to be in a specific tiling format. -*/ -if (rotation !=DRM_MODE_ROTATE_180 || !plane->rotation_property) { - fb_helper->sw_rotations |= rotation; -return ; - } - -for (i =0 ; i < plane->rotation_property->num_values; i++) - valid_mask |= (1ULL << plane->rotation_property->values[i]); - -if (!(rotation & valid_mask)) { - fb_helper->sw_rotations |= rotation; -return ; - } - - fb_crtc->rotation = rotation; -/* Rotating in hardware, fbcon should not rotate */ - fb_helper->sw_rotations |=DRM_MODE_ROTATE_0 ; -} -static void drm_setup_crtcs (struct drm_fb_helper *fb_helper,u32 width,u32 height) {
@@ -2615,7 +2604,6 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,drm_fb_helper_modeset_release (fb_helper, &fb_helper->crtc_info[i].mode_set); - fb_helper->sw_rotations =0 ;drm_fb_helper_for_each_connector (fb_helper, i) {struct drm_display_mode *mode = modes[i];struct drm_fb_helper_crtc *fb_crtc = crtcs[i];
@@ -2635,7 +2623,6 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper, modeset->mode =drm_mode_duplicate (dev, fb_crtc->desired_mode);drm_connector_get (connector); -drm_setup_crtc_rotation (fb_helper, fb_crtc, connector); modeset->connectors[modeset->num_connectors++] = connector; modeset->x = offset->x; modeset->y = offset->y;
@@ -2658,11 +2645,23 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,static void drm_setup_crtcs_fb (struct drm_fb_helper *fb_helper) {struct fb_info *info = fb_helper->fbdev; +unsigned int rotation, sw_rotations =0 ;int i; -for (i =0 ; i < fb_helper->crtc_count; i++) -if (fb_helper->crtc_info[i].mode_set.num_connectors) - fb_helper->crtc_info[i].mode_set.fb = fb_helper->fb; +for (i =0 ; i < fb_helper->crtc_count; i++) { +struct drm_mode_set *modeset = &fb_helper->crtc_info[i].mode_set; + +if (!modeset->num_connectors) +continue ; + + modeset->fb = fb_helper->fb; + +if (drm_fb_helper_panel_rotation (modeset, &rotation)) +/* Rotating in hardware, fbcon should not rotate */ + sw_rotations |=DRM_MODE_ROTATE_0 ; +else + sw_rotations |= rotation; + }mutex_lock (&fb_helper->dev->mode_config.mutex);drm_fb_helper_for_each_connector (fb_helper, i) {
@@ -2678,7 +2677,7 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper) }mutex_unlock (&fb_helper->dev->mode_config.mutex); -switch (fb_helper->sw_rotations) { +switch (sw_rotations) {case DRM_MODE_ROTATE_0 : info->fbcon_rotate_hint =FB_ROTATE_UR ;break ;
include/drm/drm_fb_helper.h +0 -8
@@ -50,7 +50,6 @@ struct drm_fb_helper_crtc {struct drm_mode_set mode_set;struct drm_display_mode *desired_mode;int x, y; -int rotation; };/**
@@ -175,13 +174,6 @@ struct drm_fb_helper {struct drm_fb_helper_crtc *crtc_info;int connector_count;int connector_info_alloc_count; -/** -* @sw_rotations: -* Bitmask of all rotations requested for panel-orientation which -* could not be handled in hardware. If only one bit is set -* fbdev->fbcon_rotate_hint gets set to the requested rotation. -*/ -int sw_rotations;/** * @connector_info: *
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/16] drm/fb-helper: No need to cache rotation and sw_rotations
Quoted 13 lines · Noralf Trønnes
Getting rotation info is cheap so we can do it on demand.
This is done in preparation for the removal of struct
drm_fb_helper_crtc.Cc Hans de Goede <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>---
Hans,
You had this comment inline in
restore_fbdev_mode_atomic()the last time I sent this out:
Quoted 8 lines
We want
plane_state->rotationto be set toDRM_MODE_ROTATE_0in the else case, AFAIKnew_plane_statestarts with the current state and rotation may have a different value there.Otherwise this looks good to me.
Rotation is reset for each plane in the code section above the one I'm changing.
I think best to let Hans review/test this in detail. lgtm at a glance.
Quoted 234 lines
Noralf.
drivers/gpu/drm/drm_fb_helper.c | 131 ++++++++++++++++---------------- include/drm/drm_fb_helper.h | 8 -- 2 files changed, 65 insertions(+), 74 deletions(-)drivers/gpu/drm/drm_fb_helper.c +65
-66@@ -387,6 +387,49 @@ int drm_fb_helper_debug_leave(struct fb_info *info) }EXPORT_SYMBOL (drm_fb_helper_debug_leave); +/* Check if the plane can hw rotate to match panel orientation */ +static bool drm_fb_helper_panel_rotation (struct drm_mode_set *modeset, +unsigned int *rotation) +{ +struct drm_connector *connector = modeset->connectors[0 ]; +struct drm_plane *plane = modeset->crtc->primary; +u64 valid_mask =0 ; +unsigned int i; + +if (!modeset->num_connectors) +return false; + +switch (connector->display_info.panel_orientation) { +case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP : + *rotation =DRM_MODE_ROTATE_180 ; +break ; +case DRM_MODE_PANEL_ORIENTATION_LEFT_UP : + *rotation =DRM_MODE_ROTATE_90 ; +break ; +case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP : + *rotation =DRM_MODE_ROTATE_270 ; +break ; +default : + *rotation =DRM_MODE_ROTATE_0 ; + } + +/* +* TODO: support 90 / 270 degree hardware rotation, +* depending on the hardware this may require the framebuffer +* to be in a specific tiling format. +*/ +if (*rotation !=DRM_MODE_ROTATE_180 || !plane->rotation_property) +return false; + +for (i =0 ; i < plane->rotation_property->num_values; i++) + valid_mask |= (1ULL << plane->rotation_property->values[i]); + +if (!(*rotation & valid_mask)) +return false; + +return true; +} +static int restore_fbdev_mode_atomic (struct drm_fb_helper *fb_helper,bool active) {struct drm_device *dev = fb_helper->dev;@@ -427,10 +470,13 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activfor (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_mode_set *mode_set = &fb_helper->crtc_info[i].mode_set;struct drm_plane *primary = mode_set->crtc->primary; +unsigned int rotation; -/* Cannot fail as we've already gotten the plane state above */ - plane_state =drm_atomic_get_new_plane_state (state, primary); - plane_state->rotation = fb_helper->crtc_info[i].rotation; +if (drm_fb_helper_panel_rotation (mode_set, &rotation)) { +/* Cannot fail as we've already gotten the plane state above */ + plane_state =drm_atomic_get_new_plane_state (state, primary); + plane_state->rotation = rotation; + } ret =__drm_atomic_helper_set_config (mode_set, state);if (ret !=0 )@@ -881,7 +927,6 @@ int drm_fb_helper_init(struct drm_device *dev,if (!fb_helper->crtc_info[i].mode_set.connectors) goto out_free; fb_helper->crtc_info[i].mode_set.num_connectors =0 ; - fb_helper->crtc_info[i].rotation =DRM_MODE_ROTATE_0 ; } i =0 ;@@ -2500,62 +2545,6 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,return best_score; } -/* -* This function checks if rotation is necessary because of panel orientation -* and if it is, if it is supported. -* If rotation is necessary and supported, it gets set in fb_crtc.rotation. -* If rotation is necessary but not supported, a DRM_MODE_ROTATE_* flag gets -* or-ed into fb_helper->sw_rotations. In drm_setup_crtcs_fb() we check if only -* one bit is set and then we set fb_info.fbcon_rotate_hint to make fbcon do -* the unsupported rotation. -*/ -static void drm_setup_crtc_rotation (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_crtc *fb_crtc, -struct drm_connector *connector) -{ -struct drm_plane *plane = fb_crtc->mode_set.crtc->primary; -uint64_t valid_mask =0 ; -int i, rotation; - - fb_crtc->rotation =DRM_MODE_ROTATE_0 ; - -switch (connector->display_info.panel_orientation) { -case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP : - rotation =DRM_MODE_ROTATE_180 ; -break ; -case DRM_MODE_PANEL_ORIENTATION_LEFT_UP : - rotation =DRM_MODE_ROTATE_90 ; -break ; -case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP : - rotation =DRM_MODE_ROTATE_270 ; -break ; -default : - rotation =DRM_MODE_ROTATE_0 ; - } - -/* -* TODO: support 90 / 270 degree hardware rotation, -* depending on the hardware this may require the framebuffer -* to be in a specific tiling format. -*/ -if (rotation !=DRM_MODE_ROTATE_180 || !plane->rotation_property) { - fb_helper->sw_rotations |= rotation; -return ; - } - -for (i =0 ; i < plane->rotation_property->num_values; i++) - valid_mask |= (1ULL << plane->rotation_property->values[i]); - -if (!(rotation & valid_mask)) { - fb_helper->sw_rotations |= rotation; -return ; - } - - fb_crtc->rotation = rotation; -/* Rotating in hardware, fbcon should not rotate */ - fb_helper->sw_rotations |=DRM_MODE_ROTATE_0 ; -} -static void drm_setup_crtcs (struct drm_fb_helper *fb_helper,u32 width,u32 height) {@@ -2615,7 +2604,6 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,drm_fb_helper_modeset_release (fb_helper, &fb_helper->crtc_info[i].mode_set); - fb_helper->sw_rotations =0 ;drm_fb_helper_for_each_connector (fb_helper, i) {struct drm_display_mode *mode = modes[i];struct drm_fb_helper_crtc *fb_crtc = crtcs[i];@@ -2635,7 +2623,6 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper, modeset->mode =drm_mode_duplicate (dev, fb_crtc->desired_mode);drm_connector_get (connector); -drm_setup_crtc_rotation (fb_helper, fb_crtc, connector); modeset->connectors[modeset->num_connectors++] = connector; modeset->x = offset->x; modeset->y = offset->y;@@ -2658,11 +2645,23 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,static void drm_setup_crtcs_fb (struct drm_fb_helper *fb_helper) {struct fb_info *info = fb_helper->fbdev; +unsigned int rotation, sw_rotations =0 ;int i; -for (i =0 ; i < fb_helper->crtc_count; i++) -if (fb_helper->crtc_info[i].mode_set.num_connectors) - fb_helper->crtc_info[i].mode_set.fb = fb_helper->fb; +for (i =0 ; i < fb_helper->crtc_count; i++) { +struct drm_mode_set *modeset = &fb_helper->crtc_info[i].mode_set; + +if (!modeset->num_connectors) +continue ; + + modeset->fb = fb_helper->fb; + +if (drm_fb_helper_panel_rotation (modeset, &rotation)) +/* Rotating in hardware, fbcon should not rotate */ + sw_rotations |=DRM_MODE_ROTATE_0 ; +else + sw_rotations |= rotation; + }mutex_lock (&fb_helper->dev->mode_config.mutex);drm_fb_helper_for_each_connector (fb_helper, i) {@@ -2678,7 +2677,7 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper) }mutex_unlock (&fb_helper->dev->mode_config.mutex); -switch (fb_helper->sw_rotations) { +switch (sw_rotations) {case DRM_MODE_ROTATE_0 : info->fbcon_rotate_hint =FB_ROTATE_UR ;break ;include/drm/drm_fb_helper.h +0
-8@@ -50,7 +50,6 @@ struct drm_fb_helper_crtc {struct drm_mode_set mode_set;struct drm_display_mode *desired_mode;int x, y; -int rotation; };/** @@ -175,13 +174,6 @@ struct drm_fb_helper {struct drm_fb_helper_crtc *crtc_info;int connector_count;int connector_info_alloc_count; -/** -* @sw_rotations: -* Bitmask of all rotations requested for panel-orientation which -* could not be handled in hardware. If only one bit is set -* fbdev->fbcon_rotate_hint gets set to the requested rotation. -*/ -int sw_rotations;/** * @connector_info: * Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/16 drm/fb-helper: Remove drm_fb_helper_crtc->{x, y, desired_mode}
In reply to Noralf TrønnesThe values are already present in the modeset.
This is done in preparation for the removal of struct drm_fb_helper_crtc.
--- drivers/gpu/drm/drm_fb_helper.c | 12 ++++-------- include/drm/drm_fb_helper.h | 2 -- 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +4 -8
@@ -2023,16 +2023,16 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,*/ bool lastv = true, lasth = true; - desired_mode = fb_helper->crtc_info[i].desired_mode; mode_set = &fb_helper->crtc_info[i].mode_set; + desired_mode = mode_set->mode;if (!desired_mode)continue ; crtc_count++; - x = fb_helper->crtc_info[i].x; - y = fb_helper->crtc_info[i].y; + x = mode_set->x; + y = mode_set->y; sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height);
@@ -2617,11 +2617,7 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,DRM_DEBUG_KMS ("desired mode %s set on crtc %d (%d,%d)\n" , mode->name, fb_crtc->mode_set.crtc->base.id, offset->x, offset->y); - fb_crtc->desired_mode = mode; - fb_crtc->x = offset->x; - fb_crtc->y = offset->y; - modeset->mode =drm_mode_duplicate (dev, - fb_crtc->desired_mode); + modeset->mode =drm_mode_duplicate (dev, mode);drm_connector_get (connector); modeset->connectors[modeset->num_connectors++] = connector; modeset->x = offset->x;
include/drm/drm_fb_helper.h +0 -2
@@ -48,8 +48,6 @@ struct drm_fb_offset {struct drm_fb_helper_crtc {struct drm_mode_set mode_set; -struct drm_display_mode *desired_mode; -int x, y; };/**
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/16] drm/fb-helper: Remove drm_fb_helper_crtc->{x, y, desired_mode}
Quoted 5 lines · Noralf Trønnes
The values are already present in the modeset.
This is done in preparation for the removal of struct
drm_fb_helper_crtc.Signed-off-by Noralf Trønnes <[email protected]>
Quoted 62 lines
--- drivers/gpu/drm/drm_fb_helper.c | 12 ++++-------- include/drm/drm_fb_helper.h | 2 -- 2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/drm_fb_helper.c +4
-8@@ -2023,16 +2023,16 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,*/ bool lastv = true, lasth = true; - desired_mode = fb_helper->crtc_info[i].desired_mode; mode_set = &fb_helper->crtc_info[i].mode_set; + desired_mode = mode_set->mode;if (!desired_mode)continue ; crtc_count++; - x = fb_helper->crtc_info[i].x; - y = fb_helper->crtc_info[i].y; + x = mode_set->x; + y = mode_set->y; sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height);@@ -2617,11 +2617,7 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,DRM_DEBUG_KMS ("desired mode %s set on crtc %d (%d,%d)\n" , mode->name, fb_crtc->mode_set.crtc->base.id, offset->x, offset->y); - fb_crtc->desired_mode = mode; - fb_crtc->x = offset->x; - fb_crtc->y = offset->y; - modeset->mode =drm_mode_duplicate (dev, - fb_crtc->desired_mode); + modeset->mode =drm_mode_duplicate (dev, mode);drm_connector_get (connector); modeset->connectors[modeset->num_connectors++] = connector; modeset->x = offset->x;include/drm/drm_fb_helper.h +0
-2@@ -48,8 +48,6 @@ struct drm_fb_offset {struct drm_fb_helper_crtc {struct drm_mode_set mode_set; -struct drm_display_mode *desired_mode; -int x, y; };/** Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/16 drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper
In reply to Noralf TrønnesIt is generic code and having it in the helper will let other drivers benefit from it.
One change was necessary assuming this to be true:
INTEL_INFO(dev_priv)->num_pipes == dev->mode_config.num_crtc
--- drivers/gpu/drm/drm_fb_helper.c | 194 ++++++++++++++++++++++++- drivers/gpu/drm/i915/intel_fbdev.c | 218 ----------------------------- include/drm/drm_fb_helper.h | 23 --- 3 files changed, 190 insertions(+), 245 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +190 -4
@@ -2545,6 +2545,194 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,return best_score; } +static struct drm_fb_helper_crtc * +drm_fb_helper_crtc (struct drm_fb_helper *fb_helper,struct drm_crtc *crtc) +{ +int i; + +for (i =0 ; i < fb_helper->crtc_count; i++) +if (fb_helper->crtc_info[i].mode_set.crtc == crtc) +return &fb_helper->crtc_info[i]; + +return NULL ; +} + +/* Try to read the BIOS display configuration and use it for the initial config */ +static bool drm_fb_helper_firmware_config (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_crtc **crtcs, +struct drm_display_mode **modes, +struct drm_fb_offset *offsets, +bool *enabled,int width,int height) +{ +struct drm_device *dev = fb_helper->dev; +unsigned int count =min (fb_helper->connector_count,BITS_PER_LONG ); +unsigned long conn_configured, conn_seq; +int i, j; +bool *save_enabled; +bool fallback = true, ret = true; +int num_connectors_enabled =0 ; +int num_connectors_detected =0 ; +struct drm_modeset_acquire_ctx ctx; + + save_enabled =kcalloc (count,sizeof (bool ),GFP_KERNEL ); +if (!save_enabled) +return false; + +drm_modeset_acquire_init (&ctx,0 ); + +while (drm_modeset_lock_all_ctx (dev, &ctx) !=0 ) +drm_modeset_backoff (&ctx); + +memcpy (save_enabled, enabled, count); + conn_seq =GENMASK (count -1 ,0 ); + conn_configured =0 ; +retry: +for (i =0 ; i < count; i++) { +struct drm_fb_helper_connector *fb_conn; +struct drm_connector *connector; +struct drm_encoder *encoder; +struct drm_fb_helper_crtc *new_crtc; + + fb_conn = fb_helper->connector_info[i]; + connector = fb_conn->connector; + +if (conn_configured &BIT (i)) +continue ; + +/* First pass, only consider tiled connectors */ +if (conn_seq ==GENMASK (count -1 ,0 ) && !connector->has_tile) +continue ; + +if (connector->status == connector_status_connected) + num_connectors_detected++; + +if (!enabled[i]) { +DRM_DEBUG_KMS ("connector %s not enabled, skipping\n" , + connector->name); + conn_configured |=BIT (i); +continue ; + } + +if (connector->force ==DRM_FORCE_OFF ) { +DRM_DEBUG_KMS ("connector %s is disabled by user, skipping\n" , + connector->name); + enabled[i] = false; +continue ; + } + + encoder = connector->state->best_encoder; +if (!encoder ||WARN_ON (!connector->state->crtc)) { +if (connector->force >DRM_FORCE_OFF ) + goto bail; + +DRM_DEBUG_KMS ("connector %s has no encoder or crtc, skipping\n" , + connector->name); + enabled[i] = false; + conn_configured |=BIT (i); +continue ; + } + + num_connectors_enabled++; + + new_crtc =drm_fb_helper_crtc (fb_helper, connector->state->crtc); + +/* +* Make sure we're not trying to drive multiple connectors +* with a single CRTC, since our cloning support may not +* match the BIOS. +*/ +for (j =0 ; j < count; j++) { +if (crtcs[j] == new_crtc) { +DRM_DEBUG_KMS ("fallback: cloned configuration\n" ); + goto bail; + } + } + +DRM_DEBUG_KMS ("looking for cmdline mode on connector %s\n" , + connector->name); + +/* go for command line mode first */ + modes[i] =drm_pick_cmdline_mode (fb_conn); + +/* try for preferred next */ +if (!modes[i]) { +DRM_DEBUG_KMS ("looking for preferred mode on connector %s %d\n" , + connector->name, connector->has_tile); + modes[i] =drm_has_preferred_mode (fb_conn, width, + height); + } + +/* No preferred mode marked by the EDID? Are there any modes? */ +if (!modes[i] && !list_empty (&connector->modes)) { +DRM_DEBUG_KMS ("using first mode listed on connector %s\n" , + connector->name); + modes[i] =list_first_entry (&connector->modes, + struct drm_display_mode, + head); + } + +/* last resort: use current mode */ +if (!modes[i]) { +/* +* IMPORTANT: We want to use the adjusted mode (i.e. +* after the panel fitter upscaling) as the initial +* config, not the input mode, which is what crtc->mode +* usually contains. But since our current +* code puts a mode derived from the post-pfit timings +* into crtc->mode this works out correctly. +* +* This is crtc->mode and not crtc->state->mode for the +* fastboot check to work correctly. +*/ +DRM_DEBUG_KMS ("looking for current mode on connector %s\n" , + connector->name); + modes[i] = &connector->state->crtc->mode; + } + crtcs[i] = new_crtc; + +DRM_DEBUG_KMS ("connector %s on [CRTC:%d:%s]: %dx%d%s\n" , + connector->name, + connector->state->crtc->base.id, + connector->state->crtc->name, + modes[i]->hdisplay, modes[i]->vdisplay, + modes[i]->flags &DRM_MODE_FLAG_INTERLACE ?"i" :"" ); + + fallback = false; + conn_configured |=BIT (i); + } + +if (conn_configured != conn_seq) {/* repeat until no more are found */ + conn_seq = conn_configured; + goto retry; + } + +/* +* If the BIOS didn't enable everything it could, fall back to have the +* same user experiencing of lighting up as much as possible like the +* fbdev helper library. +*/ +if (num_connectors_enabled != num_connectors_detected && + num_connectors_enabled < dev->mode_config.num_crtc) { +DRM_DEBUG_KMS ("fallback: Not all outputs enabled\n" ); +DRM_DEBUG_KMS ("Enabled: %i, detected: %i\n" , num_connectors_enabled, + num_connectors_detected); + fallback = true; + } + +if (fallback) { +bail: +DRM_DEBUG_KMS ("Not using firmware configuration\n" ); +memcpy (enabled, save_enabled, count); + ret = false; + } + +drm_modeset_drop_locks (&ctx); +drm_modeset_acquire_fini (&ctx); + +kfree (save_enabled); +return ret; +} +static void drm_setup_crtcs (struct drm_fb_helper *fb_helper,u32 width,u32 height) {
@@ -2577,10 +2765,8 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,DRM_DEBUG_KMS ("No connectors reported connected with modes\n" );drm_enable_connectors (fb_helper, enabled); -if (!(fb_helper->funcs->initial_config && - fb_helper->funcs->initial_config (fb_helper, crtcs, modes, - offsets, - enabled, width, height))) { +if (!drm_fb_helper_firmware_config (fb_helper, crtcs, modes, offsets, + enabled, width, height)) {memset (modes,0 , fb_helper->connector_count*sizeof (modes[0 ]));memset (crtcs,0 , fb_helper->connector_count*sizeof (crtcs[0 ]));memset (offsets,0 , fb_helper->connector_count*sizeof (offsets[0 ]));
drivers/gpu/drm/i915/intel_fbdev.c +0 -218
225 lines not on this page · raw message
include/drm/drm_fb_helper.h +0 -23
@@ -100,29 +100,6 @@ struct drm_fb_helper_funcs {*/ int (*fb_probe)(struct drm_fb_helper *helper,struct drm_fb_helper_surface_size *sizes); - -/** -* @initial_config: -* -* Driver callback to setup an initial fbdev display configuration. -* Drivers can use this callback to tell the fbdev emulation what the -* preferred initial configuration is. This is useful to implement -* smooth booting where the fbdev (and subsequently all userspace) never -* changes the mode, but always inherits the existing configuration. -* -* This callback is optional. -* -* RETURNS: -* -* The driver should return true if a suitable initial configuration has -* been filled out and false when the fbdev helper should fall back to -* the default probing logic. -*/ -bool (*initial_config)(struct drm_fb_helper *fb_helper, -struct drm_fb_helper_crtc **crtcs, -struct drm_display_mode **modes, -struct drm_fb_offset *offsets, -bool *enabled,int width,int height); };struct drm_fb_helper_connector {
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 06/16] drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper
Quoted 5 lines · Noralf Trønnes
It is generic code and having it in the helper will let other drivers benefit from it.
One change was necessary assuming this to be true:
INTEL_INFO(dev_priv)->num_pipes ==dev->mode_config.num_crtc
This holds after intel_modeset_init(), in time for the use here.
Quoted 6 lines
Suggested-by Daniel Vetter <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>
and
for merging via drm-misc or whichever tree makes most sense.
Quoted 482 lines
--- drivers/gpu/drm/drm_fb_helper.c | 194 ++++++++++++++++++++++++- drivers/gpu/drm/i915/intel_fbdev.c | 218 ----------------------------- include/drm/drm_fb_helper.h | 23 --- 3 files changed, 190 insertions(+), 245 deletions(-)drivers/gpu/drm/drm_fb_helper.c +190
-4@@ -2545,6 +2545,194 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,return best_score; } +static struct drm_fb_helper_crtc * +drm_fb_helper_crtc (struct drm_fb_helper *fb_helper,struct drm_crtc *crtc) +{ +int i; + +for (i =0 ; i < fb_helper->crtc_count; i++) +if (fb_helper->crtc_info[i].mode_set.crtc == crtc) +return &fb_helper->crtc_info[i]; + +return NULL ; +} + +/* Try to read the BIOS display configuration and use it for the initial config */ +static bool drm_fb_helper_firmware_config (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_crtc **crtcs, +struct drm_display_mode **modes, +struct drm_fb_offset *offsets, +bool *enabled,int width,int height) +{ +struct drm_device *dev = fb_helper->dev; +unsigned int count =min (fb_helper->connector_count,BITS_PER_LONG ); +unsigned long conn_configured, conn_seq; +int i, j; +bool *save_enabled; +bool fallback = true, ret = true; +int num_connectors_enabled =0 ; +int num_connectors_detected =0 ; +struct drm_modeset_acquire_ctx ctx; + + save_enabled =kcalloc (count,sizeof (bool ),GFP_KERNEL ); +if (!save_enabled) +return false; + +drm_modeset_acquire_init (&ctx,0 ); + +while (drm_modeset_lock_all_ctx (dev, &ctx) !=0 ) +drm_modeset_backoff (&ctx); + +memcpy (save_enabled, enabled, count); + conn_seq =GENMASK (count -1 ,0 ); + conn_configured =0 ; +retry: +for (i =0 ; i < count; i++) { +struct drm_fb_helper_connector *fb_conn; +struct drm_connector *connector; +struct drm_encoder *encoder; +struct drm_fb_helper_crtc *new_crtc; + + fb_conn = fb_helper->connector_info[i]; + connector = fb_conn->connector; + +if (conn_configured &BIT (i)) +continue ; + +/* First pass, only consider tiled connectors */ +if (conn_seq ==GENMASK (count -1 ,0 ) && !connector->has_tile) +continue ; + +if (connector->status == connector_status_connected) + num_connectors_detected++; + +if (!enabled[i]) { +DRM_DEBUG_KMS ("connector %s not enabled, skipping\n" , + connector->name); + conn_configured |=BIT (i); +continue ; + } + +if (connector->force ==DRM_FORCE_OFF ) { +DRM_DEBUG_KMS ("connector %s is disabled by user, skipping\n" , + connector->name); + enabled[i] = false; +continue ; + } + + encoder = connector->state->best_encoder; +if (!encoder ||WARN_ON (!connector->state->crtc)) { +if (connector->force >DRM_FORCE_OFF ) + goto bail; + +DRM_DEBUG_KMS ("connector %s has no encoder or crtc, skipping\n" , + connector->name); + enabled[i] = false; + conn_configured |=BIT (i); +continue ; + } + + num_connectors_enabled++; + + new_crtc =drm_fb_helper_crtc (fb_helper, connector->state->crtc); + +/* +* Make sure we're not trying to drive multiple connectors +* with a single CRTC, since our cloning support may not +* match the BIOS. +*/ +for (j =0 ; j < count; j++) { +if (crtcs[j] == new_crtc) { +DRM_DEBUG_KMS ("fallback: cloned configuration\n" ); + goto bail; + } + } + +DRM_DEBUG_KMS ("looking for cmdline mode on connector %s\n" , + connector->name); + +/* go for command line mode first */ + modes[i] =drm_pick_cmdline_mode (fb_conn); + +/* try for preferred next */ +if (!modes[i]) { +DRM_DEBUG_KMS ("looking for preferred mode on connector %s %d\n" , + connector->name, connector->has_tile); + modes[i] =drm_has_preferred_mode (fb_conn, width, + height); + } + +/* No preferred mode marked by the EDID? Are there any modes? */ +if (!modes[i] && !list_empty (&connector->modes)) { +DRM_DEBUG_KMS ("using first mode listed on connector %s\n" , + connector->name); + modes[i] =list_first_entry (&connector->modes, + struct drm_display_mode, + head); + } + +/* last resort: use current mode */ +if (!modes[i]) { +/* +* IMPORTANT: We want to use the adjusted mode (i.e. +* after the panel fitter upscaling) as the initial +* config, not the input mode, which is what crtc->mode +* usually contains. But since our current +* code puts a mode derived from the post-pfit timings +* into crtc->mode this works out correctly. +* +* This is crtc->mode and not crtc->state->mode for the +* fastboot check to work correctly. +*/ +DRM_DEBUG_KMS ("looking for current mode on connector %s\n" , + connector->name); + modes[i] = &connector->state->crtc->mode; + } + crtcs[i] = new_crtc; + +DRM_DEBUG_KMS ("connector %s on [CRTC:%d:%s]: %dx%d%s\n" , + connector->name, + connector->state->crtc->base.id, + connector->state->crtc->name, + modes[i]->hdisplay, modes[i]->vdisplay, + modes[i]->flags &DRM_MODE_FLAG_INTERLACE ?"i" :"" ); + + fallback = false; + conn_configured |=BIT (i); + } + +if (conn_configured != conn_seq) {/* repeat until no more are found */ + conn_seq = conn_configured; + goto retry; + } + +/* +* If the BIOS didn't enable everything it could, fall back to have the +* same user experiencing of lighting up as much as possible like the +* fbdev helper library. +*/ +if (num_connectors_enabled != num_connectors_detected && + num_connectors_enabled < dev->mode_config.num_crtc) { +DRM_DEBUG_KMS ("fallback: Not all outputs enabled\n" ); +DRM_DEBUG_KMS ("Enabled: %i, detected: %i\n" , num_connectors_enabled, + num_connectors_detected); + fallback = true; + } + +if (fallback) { +bail: +DRM_DEBUG_KMS ("Not using firmware configuration\n" ); +memcpy (enabled, save_enabled, count); + ret = false; + } + +drm_modeset_drop_locks (&ctx); +drm_modeset_acquire_fini (&ctx); + +kfree (save_enabled); +return ret; +} +static void drm_setup_crtcs (struct drm_fb_helper *fb_helper,u32 width,u32 height) {@@ -2577,10 +2765,8 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,DRM_DEBUG_KMS ("No connectors reported connected with modes\n" );drm_enable_connectors (fb_helper, enabled); -if (!(fb_helper->funcs->initial_config && - fb_helper->funcs->initial_config (fb_helper, crtcs, modes, - offsets, - enabled, width, height))) { +if (!drm_fb_helper_firmware_config (fb_helper, crtcs, modes, offsets, + enabled, width, height)) {memset (modes,0 , fb_helper->connector_count*sizeof (modes[0 ]));memset (crtcs,0 , fb_helper->connector_count*sizeof (crtcs[0 ]));memset (offsets,0 , fb_helper->connector_count*sizeof (offsets[0 ]));drivers/gpu/drm/i915/intel_fbdev.c +0
-218@@ -292,225 +292,7 @@ static int intelfb_create(struct drm_fb_helper *helper,return ret; } -static struct drm_fb_helper_crtc * -intel_fb_helper_crtc (struct drm_fb_helper *fb_helper,struct drm_crtc *crtc) -{ -int i; - -for (i =0 ; i < fb_helper->crtc_count; i++) -if (fb_helper->crtc_info[i].mode_set.crtc == crtc) -return &fb_helper->crtc_info[i]; - -return NULL ; -} - -/* -* Try to read the BIOS display configuration and use it for the initial -* fb configuration. -* -* The BIOS or boot loader will generally create an initial display -* configuration for us that includes some set of active pipes and displays. -* This routine tries to figure out which pipes and connectors are active -* and stuffs them into the crtcs and modes array given to us by the -* drm_fb_helper code. -* -* The overall sequence is: -* intel_fbdev_init - from driver load -* intel_fbdev_init_bios - initialize the intel_fbdev using BIOS data -* drm_fb_helper_init - build fb helper structs -* drm_fb_helper_single_add_all_connectors - more fb helper structs -* intel_fbdev_initial_config - apply the config -* drm_fb_helper_initial_config - call ->probe then register_framebuffer() -* drm_setup_crtcs - build crtc config for fbdev -* intel_fb_initial_config - find active connectors etc -* drm_fb_helper_single_fb_probe - set up fbdev -* intelfb_create - re-use or alloc fb, build out fbdev structs -* -* Note that we don't make special consideration whether we could actually -* switch to the selected modes without a full modeset. E.g. when the display -* is in VGA mode we need to recalculate watermarks and set a new high-res -* framebuffer anyway. -*/ -static bool intel_fb_initial_config (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_crtc **crtcs, -struct drm_display_mode **modes, -struct drm_fb_offset *offsets, -bool *enabled,int width,int height) -{ -struct drm_i915_private *dev_priv =to_i915 (fb_helper->dev); -unsigned int count =min (fb_helper->connector_count,BITS_PER_LONG ); -unsigned long conn_configured, conn_seq; -int i, j; -bool *save_enabled; -bool fallback = true, ret = true; -int num_connectors_enabled =0 ; -int num_connectors_detected =0 ; -struct drm_modeset_acquire_ctx ctx; - - save_enabled =kcalloc (count,sizeof (bool ),GFP_KERNEL ); -if (!save_enabled) -return false; - -drm_modeset_acquire_init (&ctx,0 ); - -while (drm_modeset_lock_all_ctx (fb_helper->dev, &ctx) !=0 ) -drm_modeset_backoff (&ctx); - -memcpy (save_enabled, enabled, count); - conn_seq =GENMASK (count -1 ,0 ); - conn_configured =0 ; -retry: -for (i =0 ; i < count; i++) { -struct drm_fb_helper_connector *fb_conn; -struct drm_connector *connector; -struct drm_encoder *encoder; -struct drm_fb_helper_crtc *new_crtc; - - fb_conn = fb_helper->connector_info[i]; - connector = fb_conn->connector; - -if (conn_configured &BIT (i)) -continue ; - -/* First pass, only consider tiled connectors */ -if (conn_seq ==GENMASK (count -1 ,0 ) && !connector->has_tile) -continue ; - -if (connector->status == connector_status_connected) - num_connectors_detected++; - -if (!enabled[i]) { -DRM_DEBUG_KMS ("connector %s not enabled, skipping\n" , - connector->name); - conn_configured |=BIT (i); -continue ; - } - -if (connector->force ==DRM_FORCE_OFF ) { -DRM_DEBUG_KMS ("connector %s is disabled by user, skipping\n" , - connector->name); - enabled[i] = false; -continue ; - } - - encoder = connector->state->best_encoder; -if (!encoder ||WARN_ON (!connector->state->crtc)) { -if (connector->force >DRM_FORCE_OFF ) - goto bail; - -DRM_DEBUG_KMS ("connector %s has no encoder or crtc, skipping\n" , - connector->name); - enabled[i] = false; - conn_configured |=BIT (i); -continue ; - } - - num_connectors_enabled++; - - new_crtc =intel_fb_helper_crtc (fb_helper, - connector->state->crtc); - -/* -* Make sure we're not trying to drive multiple connectors -* with a single CRTC, since our cloning support may not -* match the BIOS. -*/ -for (j =0 ; j < count; j++) { -if (crtcs[j] == new_crtc) { -DRM_DEBUG_KMS ("fallback: cloned configuration\n" ); - goto bail; - } - } - -DRM_DEBUG_KMS ("looking for cmdline mode on connector %s\n" , - connector->name); - -/* go for command line mode first */ - modes[i] =drm_pick_cmdline_mode (fb_conn); - -/* try for preferred next */ -if (!modes[i]) { -DRM_DEBUG_KMS ("looking for preferred mode on connector %s %d\n" , - connector->name, connector->has_tile); - modes[i] =drm_has_preferred_mode (fb_conn, width, - height); - } - -/* No preferred mode marked by the EDID? Are there any modes? */ -if (!modes[i] && !list_empty (&connector->modes)) { -DRM_DEBUG_KMS ("using first mode listed on connector %s\n" , - connector->name); - modes[i] =list_first_entry (&connector->modes, - struct drm_display_mode, - head); - } - -/* last resort: use current mode */ -if (!modes[i]) { -/* -* IMPORTANT: We want to use the adjusted mode (i.e. -* after the panel fitter upscaling) as the initial -* config, not the input mode, which is what crtc->mode -* usually contains. But since our current -* code puts a mode derived from the post-pfit timings -* into crtc->mode this works out correctly. -* -* This is crtc->mode and not crtc->state->mode for the -* fastboot check to work correctly. crtc_state->mode has -* I915_MODE_FLAG_INHERITED, which we clear to force check -* state. -*/ -DRM_DEBUG_KMS ("looking for current mode on connector %s\n" , - connector->name); - modes[i] = &connector->state->crtc->mode; - } - crtcs[i] = new_crtc; - -DRM_DEBUG_KMS ("connector %s on [CRTC:%d:%s]: %dx%d%s\n" , - connector->name, - connector->state->crtc->base.id, - connector->state->crtc->name, - modes[i]->hdisplay, modes[i]->vdisplay, - modes[i]->flags &DRM_MODE_FLAG_INTERLACE ?"i" :"" ); - - fallback = false; - conn_configured |=BIT (i); - } - -if (conn_configured != conn_seq) {/* repeat until no more are found */ - conn_seq = conn_configured; - goto retry; - } - -/* -* If the BIOS didn't enable everything it could, fall back to have the -* same user experiencing of lighting up as much as possible like the -* fbdev helper library. -*/ -if (num_connectors_enabled != num_connectors_detected && - num_connectors_enabled <INTEL_INFO (dev_priv)->num_pipes) { -DRM_DEBUG_KMS ("fallback: Not all outputs enabled\n" ); -DRM_DEBUG_KMS ("Enabled: %i, detected: %i\n" , num_connectors_enabled, - num_connectors_detected); - fallback = true; - } - -if (fallback) { -bail: -DRM_DEBUG_KMS ("Not using firmware configuration\n" ); -memcpy (enabled, save_enabled, count); - ret = false; - } - -drm_modeset_drop_locks (&ctx); -drm_modeset_acquire_fini (&ctx); - -kfree (save_enabled); -return ret; -} -static const struct drm_fb_helper_funcs intel_fb_helper_funcs = { - .initial_config = intel_fb_initial_config, .fb_probe = intelfb_create, };include/drm/drm_fb_helper.h +0
-23@@ -100,29 +100,6 @@ struct drm_fb_helper_funcs {*/ int (*fb_probe)(struct drm_fb_helper *helper,struct drm_fb_helper_surface_size *sizes); - -/** -* @initial_config: -* -* Driver callback to setup an initial fbdev display configuration. -* Drivers can use this callback to tell the fbdev emulation what the -* preferred initial configuration is. This is useful to implement -* smooth booting where the fbdev (and subsequently all userspace) never -* changes the mode, but always inherits the existing configuration. -* -* This callback is optional. -* -* RETURNS: -* -* The driver should return true if a suitable initial configuration has -* been filled out and false when the fbdev helper should fall back to -* the default probing logic. -*/ -bool (*initial_config)(struct drm_fb_helper *fb_helper, -struct drm_fb_helper_crtc **crtcs, -struct drm_display_mode **modes, -struct drm_fb_offset *offsets, -bool *enabled,int width,int height); };struct drm_fb_helper_connector {
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 06/16] drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper
Den 27.03.2019 14.33, skrev Jani Nikula:
Quoted 16 lines · Noralf Trønnes
Quoted 5 lines
It is generic code and having it in the helper will let other drivers benefit from it.
One change was necessary assuming this to be true:
INTEL_INFO(dev_priv)->num_pipes ==dev->mode_config.num_crtcThis holds after
intel_modeset_init(), in time for the use here.Quoted 6 lines
Suggested-by Daniel Vetter <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>
Quoted 8 lines
Reviewed-by Jani Nikula <[email protected]>and
Acked-by Jani Nikula <[email protected]>for merging via drm-misc or whichever tree makes most sense.
Thanks, I'll take it through drm-misc.
One of the patches had a conflict with drm-tip, so I didn't get a CI run. I'll apply this if CI agrees when I submit the next version.
Noralf.
Quoted 482 lines
Quoted 482 lines
--- drivers/gpu/drm/drm_fb_helper.c | 194 ++++++++++++++++++++++++- drivers/gpu/drm/i915/intel_fbdev.c | 218 ----------------------------- include/drm/drm_fb_helper.h | 23 --- 3 files changed, 190 insertions(+), 245 deletions(-)drivers/gpu/drm/drm_fb_helper.c +190
-4@@ -2545,6 +2545,194 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,return best_score; } +static struct drm_fb_helper_crtc * +drm_fb_helper_crtc (struct drm_fb_helper *fb_helper,struct drm_crtc *crtc) +{ +int i; + +for (i =0 ; i < fb_helper->crtc_count; i++) +if (fb_helper->crtc_info[i].mode_set.crtc == crtc) +return &fb_helper->crtc_info[i]; + +return NULL ; +} + +/* Try to read the BIOS display configuration and use it for the initial config */ +static bool drm_fb_helper_firmware_config (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_crtc **crtcs, +struct drm_display_mode **modes, +struct drm_fb_offset *offsets, +bool *enabled,int width,int height) +{ +struct drm_device *dev = fb_helper->dev; +unsigned int count =min (fb_helper->connector_count,BITS_PER_LONG ); +unsigned long conn_configured, conn_seq; +int i, j; +bool *save_enabled; +bool fallback = true, ret = true; +int num_connectors_enabled =0 ; +int num_connectors_detected =0 ; +struct drm_modeset_acquire_ctx ctx; + + save_enabled =kcalloc (count,sizeof (bool ),GFP_KERNEL ); +if (!save_enabled) +return false; + +drm_modeset_acquire_init (&ctx,0 ); + +while (drm_modeset_lock_all_ctx (dev, &ctx) !=0 ) +drm_modeset_backoff (&ctx); + +memcpy (save_enabled, enabled, count); + conn_seq =GENMASK (count -1 ,0 ); + conn_configured =0 ; +retry: +for (i =0 ; i < count; i++) { +struct drm_fb_helper_connector *fb_conn; +struct drm_connector *connector; +struct drm_encoder *encoder; +struct drm_fb_helper_crtc *new_crtc; + + fb_conn = fb_helper->connector_info[i]; + connector = fb_conn->connector; + +if (conn_configured &BIT (i)) +continue ; + +/* First pass, only consider tiled connectors */ +if (conn_seq ==GENMASK (count -1 ,0 ) && !connector->has_tile) +continue ; + +if (connector->status == connector_status_connected) + num_connectors_detected++; + +if (!enabled[i]) { +DRM_DEBUG_KMS ("connector %s not enabled, skipping\n" , + connector->name); + conn_configured |=BIT (i); +continue ; + } + +if (connector->force ==DRM_FORCE_OFF ) { +DRM_DEBUG_KMS ("connector %s is disabled by user, skipping\n" , + connector->name); + enabled[i] = false; +continue ; + } + + encoder = connector->state->best_encoder; +if (!encoder ||WARN_ON (!connector->state->crtc)) { +if (connector->force >DRM_FORCE_OFF ) + goto bail; + +DRM_DEBUG_KMS ("connector %s has no encoder or crtc, skipping\n" , + connector->name); + enabled[i] = false; + conn_configured |=BIT (i); +continue ; + } + + num_connectors_enabled++; + + new_crtc =drm_fb_helper_crtc (fb_helper, connector->state->crtc); + +/* +* Make sure we're not trying to drive multiple connectors +* with a single CRTC, since our cloning support may not +* match the BIOS. +*/ +for (j =0 ; j < count; j++) { +if (crtcs[j] == new_crtc) { +DRM_DEBUG_KMS ("fallback: cloned configuration\n" ); + goto bail; + } + } + +DRM_DEBUG_KMS ("looking for cmdline mode on connector %s\n" , + connector->name); + +/* go for command line mode first */ + modes[i] =drm_pick_cmdline_mode (fb_conn); + +/* try for preferred next */ +if (!modes[i]) { +DRM_DEBUG_KMS ("looking for preferred mode on connector %s %d\n" , + connector->name, connector->has_tile); + modes[i] =drm_has_preferred_mode (fb_conn, width, + height); + } + +/* No preferred mode marked by the EDID? Are there any modes? */ +if (!modes[i] && !list_empty (&connector->modes)) { +DRM_DEBUG_KMS ("using first mode listed on connector %s\n" , + connector->name); + modes[i] =list_first_entry (&connector->modes, + struct drm_display_mode, + head); + } + +/* last resort: use current mode */ +if (!modes[i]) { +/* +* IMPORTANT: We want to use the adjusted mode (i.e. +* after the panel fitter upscaling) as the initial +* config, not the input mode, which is what crtc->mode +* usually contains. But since our current +* code puts a mode derived from the post-pfit timings +* into crtc->mode this works out correctly. +* +* This is crtc->mode and not crtc->state->mode for the +* fastboot check to work correctly. +*/ +DRM_DEBUG_KMS ("looking for current mode on connector %s\n" , + connector->name); + modes[i] = &connector->state->crtc->mode; + } + crtcs[i] = new_crtc; + +DRM_DEBUG_KMS ("connector %s on [CRTC:%d:%s]: %dx%d%s\n" , + connector->name, + connector->state->crtc->base.id, + connector->state->crtc->name, + modes[i]->hdisplay, modes[i]->vdisplay, + modes[i]->flags &DRM_MODE_FLAG_INTERLACE ?"i" :"" ); + + fallback = false; + conn_configured |=BIT (i); + } + +if (conn_configured != conn_seq) {/* repeat until no more are found */ + conn_seq = conn_configured; + goto retry; + } + +/* +* If the BIOS didn't enable everything it could, fall back to have the +* same user experiencing of lighting up as much as possible like the +* fbdev helper library. +*/ +if (num_connectors_enabled != num_connectors_detected && + num_connectors_enabled < dev->mode_config.num_crtc) { +DRM_DEBUG_KMS ("fallback: Not all outputs enabled\n" ); +DRM_DEBUG_KMS ("Enabled: %i, detected: %i\n" , num_connectors_enabled, + num_connectors_detected); + fallback = true; + } + +if (fallback) { +bail: +DRM_DEBUG_KMS ("Not using firmware configuration\n" ); +memcpy (enabled, save_enabled, count); + ret = false; + } + +drm_modeset_drop_locks (&ctx); +drm_modeset_acquire_fini (&ctx); + +kfree (save_enabled); +return ret; +} +static void drm_setup_crtcs (struct drm_fb_helper *fb_helper,u32 width,u32 height) {@@ -2577,10 +2765,8 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,DRM_DEBUG_KMS ("No connectors reported connected with modes\n" );drm_enable_connectors (fb_helper, enabled); -if (!(fb_helper->funcs->initial_config && - fb_helper->funcs->initial_config (fb_helper, crtcs, modes, - offsets, - enabled, width, height))) { +if (!drm_fb_helper_firmware_config (fb_helper, crtcs, modes, offsets, + enabled, width, height)) {memset (modes,0 , fb_helper->connector_count*sizeof (modes[0 ]));memset (crtcs,0 , fb_helper->connector_count*sizeof (crtcs[0 ]));memset (offsets,0 , fb_helper->connector_count*sizeof (offsets[0 ]));drivers/gpu/drm/i915/intel_fbdev.c +0
-218@@ -292,225 +292,7 @@ static int intelfb_create(struct drm_fb_helper *helper,return ret; } -static struct drm_fb_helper_crtc * -intel_fb_helper_crtc (struct drm_fb_helper *fb_helper,struct drm_crtc *crtc) -{ -int i; - -for (i =0 ; i < fb_helper->crtc_count; i++) -if (fb_helper->crtc_info[i].mode_set.crtc == crtc) -return &fb_helper->crtc_info[i]; - -return NULL ; -} - -/* -* Try to read the BIOS display configuration and use it for the initial -* fb configuration. -* -* The BIOS or boot loader will generally create an initial display -* configuration for us that includes some set of active pipes and displays. -* This routine tries to figure out which pipes and connectors are active -* and stuffs them into the crtcs and modes array given to us by the -* drm_fb_helper code. -* -* The overall sequence is: -* intel_fbdev_init - from driver load -* intel_fbdev_init_bios - initialize the intel_fbdev using BIOS data -* drm_fb_helper_init - build fb helper structs -* drm_fb_helper_single_add_all_connectors - more fb helper structs -* intel_fbdev_initial_config - apply the config -* drm_fb_helper_initial_config - call ->probe then register_framebuffer() -* drm_setup_crtcs - build crtc config for fbdev -* intel_fb_initial_config - find active connectors etc -* drm_fb_helper_single_fb_probe - set up fbdev -* intelfb_create - re-use or alloc fb, build out fbdev structs -* -* Note that we don't make special consideration whether we could actually -* switch to the selected modes without a full modeset. E.g. when the display -* is in VGA mode we need to recalculate watermarks and set a new high-res -* framebuffer anyway. -*/ -static bool intel_fb_initial_config (struct drm_fb_helper *fb_helper, -struct drm_fb_helper_crtc **crtcs, -struct drm_display_mode **modes, -struct drm_fb_offset *offsets, -bool *enabled,int width,int height) -{ -struct drm_i915_private *dev_priv =to_i915 (fb_helper->dev); -unsigned int count =min (fb_helper->connector_count,BITS_PER_LONG ); -unsigned long conn_configured, conn_seq; -int i, j; -bool *save_enabled; -bool fallback = true, ret = true; -int num_connectors_enabled =0 ; -int num_connectors_detected =0 ; -struct drm_modeset_acquire_ctx ctx; - - save_enabled =kcalloc (count,sizeof (bool ),GFP_KERNEL ); -if (!save_enabled) -return false; - -drm_modeset_acquire_init (&ctx,0 ); - -while (drm_modeset_lock_all_ctx (fb_helper->dev, &ctx) !=0 ) -drm_modeset_backoff (&ctx); - -memcpy (save_enabled, enabled, count); - conn_seq =GENMASK (count -1 ,0 ); - conn_configured =0 ; -retry: -for (i =0 ; i < count; i++) { -struct drm_fb_helper_connector *fb_conn; -struct drm_connector *connector; -struct drm_encoder *encoder; -struct drm_fb_helper_crtc *new_crtc; - - fb_conn = fb_helper->connector_info[i]; - connector = fb_conn->connector; - -if (conn_configured &BIT (i)) -continue ; - -/* First pass, only consider tiled connectors */ -if (conn_seq ==GENMASK (count -1 ,0 ) && !connector->has_tile) -continue ; - -if (connector->status == connector_status_connected) - num_connectors_detected++; - -if (!enabled[i]) { -DRM_DEBUG_KMS ("connector %s not enabled, skipping\n" , - connector->name); - conn_configured |=BIT (i); -continue ; - } - -if (connector->force ==DRM_FORCE_OFF ) { -DRM_DEBUG_KMS ("connector %s is disabled by user, skipping\n" , - connector->name); - enabled[i] = false; -continue ; - } - - encoder = connector->state->best_encoder; -if (!encoder ||WARN_ON (!connector->state->crtc)) { -if (connector->force >DRM_FORCE_OFF ) - goto bail; - -DRM_DEBUG_KMS ("connector %s has no encoder or crtc, skipping\n" , - connector->name); - enabled[i] = false; - conn_configured |=BIT (i); -continue ; - } - - num_connectors_enabled++; - - new_crtc =intel_fb_helper_crtc (fb_helper, - connector->state->crtc); - -/* -* Make sure we're not trying to drive multiple connectors -* with a single CRTC, since our cloning support may not -* match the BIOS. -*/ -for (j =0 ; j < count; j++) { -if (crtcs[j] == new_crtc) { -DRM_DEBUG_KMS ("fallback: cloned configuration\n" ); - goto bail; - } - } - -DRM_DEBUG_KMS ("looking for cmdline mode on connector %s\n" , - connector->name); - -/* go for command line mode first */ - modes[i] =drm_pick_cmdline_mode (fb_conn); - -/* try for preferred next */ -if (!modes[i]) { -DRM_DEBUG_KMS ("looking for preferred mode on connector %s %d\n" , - connector->name, connector->has_tile); - modes[i] =drm_has_preferred_mode (fb_conn, width, - height); - } - -/* No preferred mode marked by the EDID? Are there any modes? */ -if (!modes[i] && !list_empty (&connector->modes)) { -DRM_DEBUG_KMS ("using first mode listed on connector %s\n" , - connector->name); - modes[i] =list_first_entry (&connector->modes, - struct drm_display_mode, - head); - } - -/* last resort: use current mode */ -if (!modes[i]) { -/* -* IMPORTANT: We want to use the adjusted mode (i.e. -* after the panel fitter upscaling) as the initial -* config, not the input mode, which is what crtc->mode -* usually contains. But since our current -* code puts a mode derived from the post-pfit timings -* into crtc->mode this works out correctly. -* -* This is crtc->mode and not crtc->state->mode for the -* fastboot check to work correctly. crtc_state->mode has -* I915_MODE_FLAG_INHERITED, which we clear to force check -* state. -*/ -DRM_DEBUG_KMS ("looking for current mode on connector %s\n" , - connector->name); - modes[i] = &connector->state->crtc->mode; - } - crtcs[i] = new_crtc; - -DRM_DEBUG_KMS ("connector %s on [CRTC:%d:%s]: %dx%d%s\n" , - connector->name, - connector->state->crtc->base.id, - connector->state->crtc->name, - modes[i]->hdisplay, modes[i]->vdisplay, - modes[i]->flags &DRM_MODE_FLAG_INTERLACE ?"i" :"" ); - - fallback = false; - conn_configured |=BIT (i); - } - -if (conn_configured != conn_seq) {/* repeat until no more are found */ - conn_seq = conn_configured; - goto retry; - } - -/* -* If the BIOS didn't enable everything it could, fall back to have the -* same user experiencing of lighting up as much as possible like the -* fbdev helper library. -*/ -if (num_connectors_enabled != num_connectors_detected && - num_connectors_enabled <INTEL_INFO (dev_priv)->num_pipes) { -DRM_DEBUG_KMS ("fallback: Not all outputs enabled\n" ); -DRM_DEBUG_KMS ("Enabled: %i, detected: %i\n" , num_connectors_enabled, - num_connectors_detected); - fallback = true; - } - -if (fallback) { -bail: -DRM_DEBUG_KMS ("Not using firmware configuration\n" ); -memcpy (enabled, save_enabled, count); - ret = false; - } - -drm_modeset_drop_locks (&ctx); -drm_modeset_acquire_fini (&ctx); - -kfree (save_enabled); -return ret; -} -static const struct drm_fb_helper_funcs intel_fb_helper_funcs = { - .initial_config = intel_fb_initial_config, .fb_probe = intelfb_create, };include/drm/drm_fb_helper.h +0
-23@@ -100,29 +100,6 @@ struct drm_fb_helper_funcs {*/ int (*fb_probe)(struct drm_fb_helper *helper,struct drm_fb_helper_surface_size *sizes); - -/** -* @initial_config: -* -* Driver callback to setup an initial fbdev display configuration. -* Drivers can use this callback to tell the fbdev emulation what the -* preferred initial configuration is. This is useful to implement -* smooth booting where the fbdev (and subsequently all userspace) never -* changes the mode, but always inherits the existing configuration. -* -* This callback is optional. -* -* RETURNS: -* -* The driver should return true if a suitable initial configuration has -* been filled out and false when the fbdev helper should fall back to -* the default probing logic. -*/ -bool (*initial_config)(struct drm_fb_helper *fb_helper, -struct drm_fb_helper_crtc **crtcs, -struct drm_display_mode **modes, -struct drm_fb_offset *offsets, -bool *enabled,int width,int height); };
Quoted 2 lines
include/drm/drm_fb_helper.h struct drm_fb_helper_funcs { · line 105
Quoted 1 line
include/drm/drm_fb_helper.h +0
-0struct drm_fb_helper_connector {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/16 drm/fb-helper: Remove drm_fb_helper_crtc
In reply to Noralf TrønnesIt now only contains the modeset so use that directly instead. The modeset code will be moved to drm_client, so add code there.
The modeset connector array size is hardcoded for the cloned case to avoid having to pass in a value from the driver. A value of 8 is chosen to err on the safe side. This means that the max connector argument for drm_fb_helper_init() and drm_fb_helper_fbdev_setup() isn't used anymore, a todo entry for this is added.
--- Documentation/gpu/todo.rst | 7 + drivers/gpu/drm/drm_client.c | 93 ++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 262 +++++++++++--------------------- include/drm/drm_client.h | 16 ++ include/drm/drm_fb_helper.h | 14 +- 5 files changed, 207 insertions(+), 185 deletions(-)
Documentation/gpu/todo.rst +7 -0
@@ -300,6 +300,13 @@ it to use drm_mode_hsync() instead. Contact: Sean Paul +drm_fb_helper cleanup tasks +--------------------------- + +- The max connector argument for drm_fb_helper_init() and + drm_fb_helper_fbdev_setup() isn't used anymore and can be removed. + + Core refactorings =================
drivers/gpu/drm/drm_client.c +93 -0
99 lines not on this page · raw message
drivers/gpu/drm/drm_fb_helper.c +85 -177
591 lines not on this page · raw message
include/drm/drm_client.h +16 -0
@@ -5,6 +5,8 @@#include <linux/types.h> +#include <drm/drm_crtc.h> +struct drm_client_dev ;struct drm_device ;struct drm_file ;
@@ -13,6 +15,8 @@ struct drm_gem_object;struct drm_minor ;struct module ; +#define DRM_CLIENT_MAX_CLONED_CONNECTORS 8 +/** * struct drm_client_funcs - DRM client callbacks */
@@ -135,6 +139,18 @@ struct drm_client_buffer * drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format);void drm_client_framebuffer_delete (struct drm_client_buffer *buffer); +struct drm_mode_set *drm_client_modesets_create (struct drm_device *dev); +void drm_client_modesets_release (struct drm_mode_set *modesets); +struct drm_mode_set *drm_client_find_modeset (struct drm_mode_set *modesets,struct drm_crtc *crtc); + +/** +* drm_client_for_each_modeset() - Iterate over modesets +* @modeset: &drm_mode_set loop cursor +* @modesets: Modeset array to iterate over +*/ +#define drm_client_for_each_modeset (modeset, modesets) \ + for (modeset = modesets; modeset->crtc; modeset++) +int drm_client_debugfs_init (struct drm_minor *minor);#endif
include/drm/drm_fb_helper.h +6 -8
@@ -46,10 +46,6 @@ struct drm_fb_offset {int x, y; }; -struct drm_fb_helper_crtc { -struct drm_mode_set mode_set; -}; -/** * struct drm_fb_helper_surface_size - describes fbdev size and scanout surface size * @fb_width: fbdev width
@@ -110,8 +106,6 @@ struct drm_fb_helper_connector {* struct drm_fb_helper - main structure to emulate fbdev on top of KMS * @fb: Scanout framebuffer object * @dev: DRM device -* @crtc_count: number of possible CRTCs -* @crtc_info: per-CRTC helper state (mode, x/y offset, etc) * @connector_count: number of connected connectors * @connector_info_alloc_count: size of connector_info * @funcs: driver callbacks for fb helper
@@ -145,8 +139,12 @@ struct drm_fb_helper {struct drm_framebuffer *fb;struct drm_device *dev; -int crtc_count; -struct drm_fb_helper_crtc *crtc_info; + +/** +* @modesets: CRTC configurations +*/ +struct drm_mode_set *modesets; +int connector_count;int connector_info_alloc_count;/**
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/16 drm/fb-helper: Prepare to move out commit code
In reply to Noralf TrønnesThis makes the necessary changes so the commit code can be moved out to drm_client as-is in the next patch. It's split up to ease review.
--- drivers/gpu/drm/drm_fb_helper.c | 93 +++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 34 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +59 -34
@@ -382,9 +382,20 @@ int drm_fb_helper_debug_leave(struct fb_info *info) }EXPORT_SYMBOL (drm_fb_helper_debug_leave); -/* Check if the plane can hw rotate to match panel orientation */ -static bool drm_fb_helper_panel_rotation (struct drm_mode_set *modeset, -unsigned int *rotation) +/** +* drm_client_panel_rotation() - Check panel orientation +* @modeset: DRM modeset +* @rotation: Returned rotation value +* +* This function checks if the primary plane in @modeset can hw rotate to match +* the panel orientation on its connector. +* +* Note: Currently only 0 and 180 degrees are supported. +* +* Return: +* True if the plane can do the rotation, false otherwise. +*/ +bool drm_client_panel_rotation (struct drm_mode_set *modeset,unsigned int *rotation) {struct drm_connector *connector = modeset->connectors[0 ];struct drm_plane *plane = modeset->crtc->primary;
@@ -425,9 +436,9 @@ static bool drm_fb_helper_panel_rotation(struct drm_mode_set *modeset,return true; } -static int restore_fbdev_mode_atomic (struct drm_fb_helper *fb_helper,bool active) +static int drm_client_modesets_commit_atomic (struct drm_device *dev,struct drm_mode_set *modesets, +bool active) { -struct drm_device *dev = fb_helper->dev;struct drm_plane_state *plane_state;struct drm_plane *plane;struct drm_atomic_state *state;
@@ -463,11 +474,11 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ goto out_state; } -drm_client_for_each_modeset (mode_set, fb_helper->modesets) { +drm_client_for_each_modeset (mode_set, modesets) {struct drm_plane *primary = mode_set->crtc->primary;unsigned int rotation; -if (drm_fb_helper_panel_rotation (mode_set, &rotation)) { +if (drm_client_panel_rotation (mode_set, &rotation)) {/* Cannot fail as we've already gotten the plane state above */ plane_state =drm_atomic_get_new_plane_state (state, primary); plane_state->rotation = rotation;
@@ -509,14 +520,13 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ goto retry; } -static int restore_fbdev_mode_legacy (struct drm_fb_helper *fb_helper) +static int drm_client_modesets_commit_legacy (struct drm_device *dev,struct drm_mode_set *modesets) { -struct drm_device *dev = fb_helper->dev;struct drm_mode_set *mode_set;struct drm_plane *plane;int ret =0 ; -drm_modeset_lock_all (fb_helper->dev); +drm_modeset_lock_all (dev);drm_for_each_plane (plane, dev) {if (plane->type !=DRM_PLANE_TYPE_PRIMARY )drm_plane_force_disable (plane);
@@ -527,7 +537,7 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper *fb_helper) DRM_MODE_ROTATE_0); } -drm_client_for_each_modeset (mode_set, fb_helper->modesets) { +drm_client_for_each_modeset (mode_set, modesets) {struct drm_crtc *crtc = mode_set->crtc;if (crtc->funcs->cursor_set2) {
@@ -545,19 +555,25 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper *fb_helper) goto out; } out: -drm_modeset_unlock_all (fb_helper->dev); +drm_modeset_unlock_all (dev);return ret; } -static int restore_fbdev_mode (struct drm_fb_helper *fb_helper) +/** +* drm_client_modesets_commit() - Commit CRTC configuration +* @dev: DRM device +* @modesets: Modeset array +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_client_modesets_commit (struct drm_device *dev,struct drm_mode_set *modesets) { -struct drm_device *dev = fb_helper->dev; -if (drm_drv_uses_atomic_modeset (dev)) -return restore_fbdev_mode_atomic (fb_helper, true); +return drm_client_modesets_commit_atomic (dev, modesets, true);else -return restore_fbdev_mode_legacy (fb_helper); +return drm_client_modesets_commit_legacy (dev, modesets); }/**
@@ -583,7 +599,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)return 0 ;mutex_lock (&fb_helper->lock); - ret =restore_fbdev_mode (fb_helper); + ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); do_delayed = fb_helper->delayed_hotplug;if (do_delayed)
@@ -645,7 +661,7 @@ static bool drm_fb_helper_force_kernel_mode(void)continue ;mutex_lock (&helper->lock); - ret =restore_fbdev_mode (helper); + ret =drm_client_modesets_commit (dev, helper->modesets);if (ret) error = true;mutex_unlock (&helper->lock);
@@ -677,15 +693,15 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = {static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };#endif -static void dpms_legacy (struct drm_fb_helper *fb_helper,int dpms_mode) +static void drm_client_modesets_dpms_legacy (struct drm_device *dev,struct drm_mode_set *modesets, +int dpms_mode) { -struct drm_device *dev = fb_helper->dev;struct drm_connector *connector;struct drm_mode_set *modeset;int j;drm_modeset_lock_all (dev); -drm_client_for_each_modeset (modeset, fb_helper->modesets) { +drm_client_for_each_modeset (modeset, modesets) {if (!modeset->crtc->enabled)continue ;
@@ -699,6 +715,22 @@ static void dpms_legacy(struct drm_fb_helper *fb_helper, int dpms_mode)drm_modeset_unlock_all (dev); } +/** +* drm_client_modesets_dpms() - Set DPMS mode +* @dev: DRM device +* @modesets: Modeset array +* @mode: DPMS mode +* +* Note: For atomic drivers @mode is reduced to on/off. +*/ +void drm_client_modesets_dpms (struct drm_device *dev,struct drm_mode_set *modesets,int mode) +{ +if (drm_drv_uses_atomic_modeset (dev)) +drm_client_modesets_commit_atomic (dev, modesets, mode ==DRM_MODE_DPMS_ON ); +else +drm_client_modesets_dpms_legacy (dev, modesets, mode); +} +static void drm_fb_helper_dpms (struct fb_info *info,int dpms_mode) {struct drm_fb_helper *fb_helper = info->par;
@@ -707,15 +739,8 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)* For each CRTC in this fb, turn the connectors on/off. */ mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { -mutex_unlock (&fb_helper->lock); -return ; - } - -if (drm_drv_uses_atomic_modeset (fb_helper->dev)) -restore_fbdev_mode_atomic (fb_helper, dpms_mode ==DRM_MODE_DPMS_ON ); -else -dpms_legacy (fb_helper, dpms_mode); +if (drm_fb_helper_is_bound (fb_helper)) +drm_client_modesets_dpms (fb_helper->dev, fb_helper->modesets, dpms_mode);mutex_unlock (&fb_helper->lock); }
@@ -1770,7 +1795,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var,pan_set (fb_helper, var->xoffset, var->yoffset); - ret =restore_fbdev_mode_atomic (fb_helper, true); + ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets);if (!ret) { info->var.xoffset = var->xoffset; info->var.yoffset = var->yoffset;
@@ -1987,7 +2012,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,/* First time: disable all crtc's.. */ if (!fb_helper->deferred_setup && !READ_ONCE (fb_helper->dev->master)) -restore_fbdev_mode (fb_helper); +drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets);return -EAGAIN ; }
@@ -2754,7 +2779,7 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper) modeset->fb = fb_helper->fb; -if (drm_fb_helper_panel_rotation (modeset, &rotation)) +if (drm_client_panel_rotation (modeset, &rotation))/* Rotating in hardware, fbcon should not rotate */ sw_rotations |=DRM_MODE_ROTATE_0 ;else
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 9/16 drm/fb-helper: Move out commit code
In reply to Noralf TrønnesMove the modeset commit code to drm_client.
No changes except exporting API.
--- drivers/gpu/drm/drm_client.c | 236 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 232 ------------------------------- include/drm/drm_client.h | 3 + 3 files changed, 239 insertions(+), 232 deletions(-)
drivers/gpu/drm/drm_client.c +236 -0
@@ -9,6 +9,7 @@#include <linux/seq_file.h> #include <linux/slab.h> +#include <drm/drm_atomic.h> #include <drm/drm_client.h> #include <drm/drm_debugfs.h> #include <drm/drm_device.h>
@@ -485,6 +486,241 @@ struct drm_mode_set *drm_client_find_modeset(struct drm_mode_set *modesets, stru }EXPORT_SYMBOL (drm_client_find_modeset); +/** +* drm_client_panel_rotation() - Check panel orientation +* @modeset: DRM modeset +* @rotation: Returned rotation value +* +* This function checks if the primary plane in @modeset can hw rotate to match +* the panel orientation on its connector. +* +* Note: Currently only 0 and 180 degrees are supported. +* +* Return: +* True if the plane can do the rotation, false otherwise. +*/ +bool drm_client_panel_rotation (struct drm_mode_set *modeset,unsigned int *rotation) +{ +struct drm_connector *connector = modeset->connectors[0 ]; +struct drm_plane *plane = modeset->crtc->primary; +u64 valid_mask =0 ; +unsigned int i; + +if (!modeset->num_connectors) +return false; + +switch (connector->display_info.panel_orientation) { +case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP : + *rotation =DRM_MODE_ROTATE_180 ; +break ; +case DRM_MODE_PANEL_ORIENTATION_LEFT_UP : + *rotation =DRM_MODE_ROTATE_90 ; +break ; +case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP : + *rotation =DRM_MODE_ROTATE_270 ; +break ; +default : + *rotation =DRM_MODE_ROTATE_0 ; + } + +/* +* TODO: support 90 / 270 degree hardware rotation, +* depending on the hardware this may require the framebuffer +* to be in a specific tiling format. +*/ +if (*rotation !=DRM_MODE_ROTATE_180 || !plane->rotation_property) +return false; + +for (i =0 ; i < plane->rotation_property->num_values; i++) + valid_mask |= (1ULL << plane->rotation_property->values[i]); + +if (!(*rotation & valid_mask)) +return false; + +return true; +} +EXPORT_SYMBOL (drm_client_panel_rotation); + +static int drm_client_modesets_commit_atomic (struct drm_device *dev,struct drm_mode_set *modesets, +bool active) +{ +struct drm_plane_state *plane_state; +struct drm_plane *plane; +struct drm_atomic_state *state; +struct drm_modeset_acquire_ctx ctx; +struct drm_mode_set *mode_set; +int ret; + +drm_modeset_acquire_init (&ctx,0 ); + + state =drm_atomic_state_alloc (dev); +if (!state) { + ret = -ENOMEM ; + goto out_ctx; + } + + state->acquire_ctx = &ctx; +retry: +drm_for_each_plane (plane, dev) { + plane_state =drm_atomic_get_plane_state (state, plane); +if (IS_ERR (plane_state)) { + ret =PTR_ERR (plane_state); + goto out_state; + } + + plane_state->rotation =DRM_MODE_ROTATE_0 ; + +/* disable non-primary: */ +if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) +continue ; + + ret =__drm_atomic_helper_disable_plane (plane, plane_state); +if (ret !=0 ) + goto out_state; + } + +drm_client_for_each_modeset (mode_set, modesets) { +struct drm_plane *primary = mode_set->crtc->primary; +unsigned int rotation; + +if (drm_client_panel_rotation (mode_set, &rotation)) { +/* Cannot fail as we've already gotten the plane state above */ + plane_state =drm_atomic_get_new_plane_state (state, primary); + plane_state->rotation = rotation; + } + + ret =__drm_atomic_helper_set_config (mode_set, state); +if (ret !=0 ) + goto out_state; + +/* +* __drm_atomic_helper_set_config() sets active when a +* mode is set, unconditionally clear it if we force DPMS off +*/ +if (!active) { +struct drm_crtc *crtc = mode_set->crtc; +struct drm_crtc_state *crtc_state =drm_atomic_get_new_crtc_state (state, crtc); + + crtc_state->active = false; + } + } + + ret =drm_atomic_commit (state); + +out_state: +if (ret == -EDEADLK ) + goto backoff; + +drm_atomic_state_put (state); +out_ctx: +drm_modeset_drop_locks (&ctx); +drm_modeset_acquire_fini (&ctx); + +return ret; + +backoff: +drm_atomic_state_clear (state); +drm_modeset_backoff (&ctx); + + goto retry; +} + +static int drm_client_modesets_commit_legacy (struct drm_device *dev,struct drm_mode_set *modesets) +{ +struct drm_mode_set *mode_set; +struct drm_plane *plane; +int ret =0 ; + +drm_modeset_lock_all (dev); +drm_for_each_plane (plane, dev) { +if (plane->type !=DRM_PLANE_TYPE_PRIMARY ) +drm_plane_force_disable (plane); + +if (plane->rotation_property) +drm_mode_plane_set_obj_prop (plane, + plane->rotation_property, +DRM_MODE_ROTATE_0 ); + } + +drm_client_for_each_modeset (mode_set, modesets) { +struct drm_crtc *crtc = mode_set->crtc; + +if (crtc->funcs->cursor_set2) { + ret = crtc->funcs->cursor_set2 (crtc,NULL ,0 ,0 ,0 ,0 ,0 ); +if (ret) + goto out; + }else if (crtc->funcs->cursor_set) { + ret = crtc->funcs->cursor_set (crtc,NULL ,0 ,0 ,0 ); +if (ret) + goto out; + } + + ret =drm_mode_set_config_internal (mode_set); +if (ret) + goto out; + } +out: +drm_modeset_unlock_all (dev); + +return ret; +} + +/** +* drm_client_modesets_commit() - Commit CRTC configuration +* @dev: DRM device +* @modesets: Modeset array +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_client_modesets_commit (struct drm_device *dev,struct drm_mode_set *modesets) +{ +if (drm_drv_uses_atomic_modeset (dev)) +return drm_client_modesets_commit_atomic (dev, modesets, true); +else +return drm_client_modesets_commit_legacy (dev, modesets); +} +EXPORT_SYMBOL (drm_client_modesets_commit); + +static void drm_client_modesets_dpms_legacy (struct drm_device *dev,struct drm_mode_set *modesets, +int dpms_mode) +{ +struct drm_connector *connector; +struct drm_mode_set *modeset; +int j; + +drm_modeset_lock_all (dev); +drm_client_for_each_modeset (modeset, modesets) { +if (!modeset->crtc->enabled) +continue ; + +for (j =0 ; j < modeset->num_connectors; j++) { + connector = modeset->connectors[j]; + connector->funcs->dpms (connector, dpms_mode); +drm_object_property_set_value (&connector->base, + dev->mode_config.dpms_property, dpms_mode); + } + } +drm_modeset_unlock_all (dev); +} + +/** +* drm_client_modesets_dpms() - Set DPMS mode +* @dev: DRM device +* @modesets: Modeset array +* @mode: DPMS mode +* +* Note: For atomic drivers @mode is reduced to on/off. +*/ +void drm_client_modesets_dpms (struct drm_device *dev,struct drm_mode_set *modesets,int mode) +{ +if (drm_drv_uses_atomic_modeset (dev)) +drm_client_modesets_commit_atomic (dev, modesets, mode ==DRM_MODE_DPMS_ON ); +else +drm_client_modesets_dpms_legacy (dev, modesets, mode); +} +EXPORT_SYMBOL (drm_client_modesets_dpms); +#ifdef CONFIG_DEBUG_FS static int drm_client_debugfs_internal_clients (struct seq_file *m,void *data) {
drivers/gpu/drm/drm_fb_helper.c +0 -232
244 lines not on this page · raw message
include/drm/drm_client.h +3 -0
@@ -142,6 +142,9 @@ void drm_client_framebuffer_delete(struct drm_client_buffer *buffer);struct drm_mode_set *drm_client_modesets_create (struct drm_device *dev);void drm_client_modesets_release (struct drm_mode_set *modesets);struct drm_mode_set *drm_client_find_modeset (struct drm_mode_set *modesets,struct drm_crtc *crtc); +bool drm_client_panel_rotation (struct drm_mode_set *modeset,unsigned int *rotation); +int drm_client_modesets_commit (struct drm_device *dev,struct drm_mode_set *modesets); +void drm_client_modesets_dpms (struct drm_device *dev,struct drm_mode_set *modesets,int mode);/** * drm_client_for_each_modeset() - Iterate over modesets
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 09/16] drm/fb-helper: Move out commit code
Hi Noralf,
Quoted 10 lines · On Tue, 26 Mar 2019 18:55:39 +0100 Noralf Trønnes <[email protected]> wrote:
Move the modeset commit code to
drm_client.
No changes except exporting API.Signed-off-by Noralf Trønnes <[email protected]>--- drivers/gpu/drm/drm_client.c | 236 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 232 ------------------------------- include/drm/drm_client.h | 3 + 3 files changed, 239 insertions(+), 232 deletions(-)
It looks like you are moving MIT licenced code to a GPL-only
licenced file.
Cheers,
Signature · 5 lines
Emmanuel Vadot <[email protected]> <[email protected]> _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 09/16] drm/fb-helper: Move out commit code
Den 27.03.2019 15.13, skrev Emmanuel Vadot:
Quoted 17 lines
Hi Noralf,
Quoted 10 lines · On Tue, 26 Mar 2019 18:55:39 +0100 Noralf Trønnes <[email protected]> wrote:
Move the modeset commit code to
drm_client.
No changes except exporting API.Signed-off-by Noralf Trønnes <[email protected]>--- drivers/gpu/drm/drm_client.c | 236 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 232 ------------------------------- include/drm/drm_client.h | 3 + 3 files changed, 239 insertions(+), 232 deletions(-)
Quoted 3 lines
It looks like you are moving MIT licenced code to a GPL-only
licenced file.
I had planned to copy over the copyrights, but forgot. Didn't know it was MIT though. I think I'll just copy over the whole copyrights section from drm_fb_helper to drm_client and drop GPL. I wrote the whole of drm_client so that should be fine.
Thanks,
Noralf
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 09/16] drm/fb-helper: Move out commit code
Quoted 20 lines · On Wed, 27 Mar 2019 16:01:01 +0100 Noralf Trønnes <[email protected]> wrote:
Den 27.03.2019 15.13, skrev Emmanuel Vadot:
Quoted 17 lines
Hi Noralf,
Quoted 10 lines · On Tue, 26 Mar 2019 18:55:39 +0100 Noralf Trønnes <[email protected]> wrote:
Move the modeset commit code to
drm_client.
No changes except exporting API.Signed-off-by Noralf Trønnes <[email protected]>--- drivers/gpu/drm/drm_client.c | 236 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 232 ------------------------------- include/drm/drm_client.h | 3 + 3 files changed, 239 insertions(+), 232 deletions(-)
Quoted 8 lines
Quoted 3 lines
It looks like you are moving MIT licenced code to a GPL-only
licenced file.I had planned to copy over the copyrights, but forgot. Didn't know it was MIT though. I think I'll just copy over the whole copyrights section from
drm_fb_helpertodrm_clientand drop GPL. I wrote the whole ofdrm_clientso that should be fine.
That would be awesome if you relicence drm_client.
Thanks,
Quoted 7 lines
Thanks,
Noralf_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 5 lines
Emmanuel Vadot <[email protected]> <[email protected]> _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 10/16 drm/fb-helper: Remove drm_fb_helper_connector
In reply to Noralf TrønnesAll drivers add all their connectors so there's no need to keep around an array of available connectors.
Rename functions which signature is changed since they will be moved to drm_client in a later patch.
---
checkpatch complains, but I'm unable to satisfy it:
ERROR: Macros with complex values should be enclosed in parentheses #939: FILE: include/drm/drm_client.h:160:
+#define drm_client_for_each_connector_iter(connector, iter) \
+ drm_for_each_connector_iter(connector, iter) \
+ if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
Documentation/gpu/todo.rst | 3 + drivers/gpu/drm/drm_fb_helper.c | 499 ++++++++++---------------------- include/drm/drm_client.h | 15 + include/drm/drm_fb_helper.h | 80 ++--- 4 files changed, 194 insertions(+), 403 deletions(-)
Documentation/gpu/todo.rst +3 -0
@@ -306,6 +306,9 @@ drm_fb_helper cleanup tasks - The max connector argument for drm_fb_helper_init() and drm_fb_helper_fbdev_setup() isn't used anymore and can be removed. +- The helper doesn't keep an array of connectors anymore so these can be + removed: drm_fb_helper_single_add_all_connectors(), + drm_fb_helper_add_one_connector() and drm_fb_helper_remove_one_connector(). Core refactorings =================
drivers/gpu/drm/drm_fb_helper.c +155 -344
843 lines not on this page · raw message
include/drm/drm_client.h +15 -0
@@ -5,6 +5,7 @@#include <linux/types.h> +#include <drm/drm_connector.h> #include <drm/drm_crtc.h> struct drm_client_dev ;
@@ -146,6 +147,20 @@ bool drm_client_panel_rotation(struct drm_mode_set *modeset, unsigned int *rotatint drm_client_modesets_commit (struct drm_device *dev,struct drm_mode_set *modesets);void drm_client_modesets_dpms (struct drm_device *dev,struct drm_mode_set *modesets,int mode); +/** +* drm_client_for_each_connector_iter - connector_list iterator macro +* @connector: &struct drm_connector pointer used as cursor +* @iter: &struct drm_connector_list_iter +* +* This iterates the connectors that are useable for internal clients (excludes +* writeback connectors). +* +* For more info see drm_for_each_connector_iter(). +*/ +#define drm_client_for_each_connector_iter (connector, iter) \ + drm_for_each_connector_iter(connector, iter) \ + if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) +/** * drm_client_for_each_modeset() - Iterate over modesets * @modeset: &drm_mode_set loop cursor
include/drm/drm_fb_helper.h +21 -59
122 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 11/16 drm/fb-helper: Prepare to move out modeset config code
In reply to Noralf TrønnesThis prepares the modeset code so it can be moved out as-is in the next patch.
--- drivers/gpu/drm/drm_fb_helper.c | 75 +++++++++++++++++++++++++-------- include/drm/drm_fb_helper.h | 4 -- 2 files changed, 57 insertions(+), 22 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +57 -18
@@ -45,6 +45,10 @@#include "drm_crtc_internal.h" #include "drm_crtc_helper_internal.h" +struct drm_client_offset { +int x, y; +}; +static bool drm_fbdev_emulation = true;module_param_named (fbdev_emulation, drm_fbdev_emulation, bool,0600 ); MODULE_PARM_DESC(fbdev_emulation,
@@ -1792,7 +1796,7 @@ static bool drm_client_target_cloned(struct drm_device *dev,struct drm_connector **connectors, unsigned int connector_count, struct drm_display_mode **modes, - struct drm_fb_offset *offsets, + struct drm_client_offset *offsets, bool *enabled, int width, int height) { int count, i, j;
@@ -1871,7 +1875,7 @@ static bool drm_client_target_cloned(struct drm_device *dev,static int drm_client_get_tile_offsets (struct drm_connector **connectors,unsigned int connector_count,struct drm_display_mode **modes, -struct drm_fb_offset *offsets, +struct drm_client_offset *offsets,int idx,int h_idx,int v_idx) {
@@ -1904,7 +1908,7 @@ static int drm_client_get_tile_offsets(struct drm_connector **connectors,static bool drm_client_target_preferred (struct drm_connector **connectors,unsigned int connector_count,struct drm_display_mode **modes, -struct drm_fb_offset *offsets, +struct drm_client_offset *offsets,bool *enabled,int width,int height) {const u64 mask =BIT_ULL (connector_count) -1 ;
@@ -2068,7 +2072,7 @@ static bool drm_client_firmware_config(struct drm_device *dev,unsigned int connector_count, struct drm_crtc **crtcs, struct drm_display_mode **modes, - struct drm_fb_offset *offsets, + struct drm_client_offset *offsets, bool *enabled, int width, int height) { unsigned int count = min_t(unsigned int, connector_count, BITS_PER_LONG);
@@ -2236,32 +2240,51 @@ static bool drm_client_firmware_config(struct drm_device *dev,return ret; } -static void drm_setup_crtcs (struct drm_fb_helper *fb_helper, -u32 width,u32 height) +/** +* drm_client_modesets_probe() - Probe for displays +* @dev: DRM device +* @width: Maximum display mode width (optional) +* @height: Maximum display mode height (optional) +* +* This function tries to set up pipelines for enabled connectors and returns +* the CRTC config as a &drm_mode_set array. +* +* Use drm_client_modesets_release() to free the array and its resources. +* +* Returns: +* A &drm_mode_set array on success, NULL if no connectors are found +* or error pointer on failure. +*/ +struct drm_mode_set * +drm_client_modesets_probe (struct drm_device *dev,unsigned int width,unsigned int height) {struct drm_connector *connector, **connectors =NULL ;struct drm_connector_list_iter conn_iter; -struct drm_device *dev = fb_helper->dev;struct drm_mode_set *modesets =NULL ;unsigned int total_modes_count =0 ; +struct drm_client_offset *offsets;unsigned int connector_count =0 ;struct drm_display_mode **modes; -struct drm_fb_offset *offsets;struct drm_crtc **crtcs; +int i, ret =0 ;bool *enabled; -int i;DRM_DEBUG_KMS ("\n" ); -/* prevent concurrent modification of connector_count by hotplug */ -lockdep_assert_held (&fb_helper->lock); + +if (!width) + width = dev->mode_config.max_width; +if (!height) + height = dev->mode_config.max_height;drm_connector_list_iter_begin (dev, &conn_iter);drm_client_for_each_connector_iter (connector, &conn_iter) {struct drm_connector **tmp; tmp =krealloc (connectors, (connector_count +1 ) *sizeof (*connectors),GFP_KERNEL ); -if (!tmp) +if (!tmp) { + ret = -ENOMEM ; goto free_connectors; + } connectors = tmp;drm_connector_get (connector);
@@ -2270,7 +2293,7 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,drm_connector_list_iter_end (&conn_iter);if (!connector_count) -return ; +return NULL ; modesets =drm_client_modesets_create (dev); crtcs =kcalloc (connector_count,sizeof (*crtcs),GFP_KERNEL );
@@ -2279,10 +2302,11 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper, enabled =kcalloc (connector_count,sizeof (bool ),GFP_KERNEL );if (IS_ERR (modesets) || !crtcs || !modes || !enabled || !offsets) {DRM_ERROR ("Memory allocation failed\n" ); + ret = -ENOMEM ; goto out; } -mutex_lock (&fb_helper->dev->mode_config.mutex); +mutex_lock (&dev->mode_config.mutex);for (i =0 ; i < connector_count; i++) total_modes_count += connectors[i]->funcs->fill_modes (connectors[i], width, height);if (!total_modes_count)
@@ -2307,12 +2331,12 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,drm_client_pick_crtcs (dev, modesets, connectors, connector_count, crtcs, modes,0 , width, height); } -mutex_unlock (&fb_helper->dev->mode_config.mutex); +mutex_unlock (&dev->mode_config.mutex);for (i =0 ; i < connector_count; i++) {struct drm_display_mode *mode = modes[i];struct drm_crtc *crtc = crtcs[i]; -struct drm_fb_offset *offset = &offsets[i]; +struct drm_client_offset *offset = &offsets[i];if (mode && crtc) {struct drm_mode_set *modeset =drm_client_find_modeset (modesets, crtc);
@@ -2332,8 +2356,6 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper, modeset->y = offset->y; } } - -swap (fb_helper->modesets, modesets); out:kfree (crtcs);kfree (modes);
@@ -2346,6 +2368,23 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,kfree (connectors); } +if (ret) { +drm_client_modesets_release (modesets); +return ERR_PTR (ret); + } + +return modesets; +} + +static void drm_setup_crtcs (struct drm_fb_helper *fb_helper,u32 width,u32 height) +{ +struct drm_mode_set *modesets; + + modesets =drm_client_modesets_probe (fb_helper->dev, width, height); +if (IS_ERR_OR_NULL (modesets)) +return ; + +swap (fb_helper->modesets, modesets);drm_client_modesets_release (modesets); }
include/drm/drm_fb_helper.h +0 -4
@@ -42,10 +42,6 @@ enum mode_set_atomic { ENTER_ATOMIC_MODE_SET, }; -struct drm_fb_offset { -int x, y; -}; -/** * struct drm_fb_helper_surface_size - describes fbdev size and scanout surface size * @fb_width: fbdev width
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 12/16 drm/fb-helper: Move out modeset config code
In reply to Noralf TrønnesNo functional changes, just moving code as-is and fixing includes. There is one addition and that is exporting drm_client_modesets_probe().
--- drivers/gpu/drm/drm_client.c | 698 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 697 ------------------------------- include/drm/drm_client.h | 4 +- 3 files changed, 700 insertions(+), 699 deletions(-)
drivers/gpu/drm/drm_client.c +698 -0
@@ -11,9 +11,11 @@#include <drm/drm_atomic.h> #include <drm/drm_client.h> +#include <drm/drm_connector.h> #include <drm/drm_debugfs.h> #include <drm/drm_device.h> #include <drm/drm_drv.h> +#include <drm/drm_encoder.h> #include <drm/drm_file.h> #include <drm/drm_fourcc.h> #include <drm/drm_gem.h>
@@ -24,6 +26,12 @@#include "drm_crtc_internal.h" #include "drm_internal.h" +#define DRM_CLIENT_MAX_CLONED_CONNECTORS 8 + +struct drm_client_offset { +int x, y; +}; +/** * DOC: overview *
@@ -486,6 +494,696 @@ struct drm_mode_set *drm_client_find_modeset(struct drm_mode_set *modesets, stru }EXPORT_SYMBOL (drm_client_find_modeset); +static struct drm_display_mode * +drm_connector_has_preferred_mode (struct drm_connector *connector,int width,int height) +{ +struct drm_display_mode *mode; + +list_for_each_entry (mode, &connector->modes, head) { +if (mode->hdisplay > width || + mode->vdisplay > height) +continue ; +if (mode->type &DRM_MODE_TYPE_PREFERRED ) +return mode; + } +return NULL ; +} + +static struct drm_display_mode * +drm_connector_pick_cmdline_mode (struct drm_connector *connector) +{ +struct drm_cmdline_mode *cmdline_mode; +struct drm_display_mode *mode; +bool prefer_non_interlace; + + cmdline_mode = &connector->cmdline_mode; +if (cmdline_mode->specified == false) +return NULL ; + +/* attempt to find a matching mode in the list of modes +* we have gotten so far, if not add a CVT mode that conforms +*/ +if (cmdline_mode->rb || cmdline_mode->margins) + goto create_mode; + + prefer_non_interlace = !cmdline_mode->interlace; +again: +list_for_each_entry (mode, &connector->modes, head) { +/* check width/height */ +if (mode->hdisplay != cmdline_mode->xres || + mode->vdisplay != cmdline_mode->yres) +continue ; + +if (cmdline_mode->refresh_specified) { +if (mode->vrefresh != cmdline_mode->refresh) +continue ; + } + +if (cmdline_mode->interlace) { +if (!(mode->flags &DRM_MODE_FLAG_INTERLACE )) +continue ; + }else if (prefer_non_interlace) { +if (mode->flags &DRM_MODE_FLAG_INTERLACE ) +continue ; + } +return mode; + } + +if (prefer_non_interlace) { + prefer_non_interlace = false; + goto again; + } + +create_mode: + mode =drm_mode_create_from_cmdline_mode (connector->dev, cmdline_mode); +list_add (&mode->head, &connector->modes); +return mode; +} + +static bool drm_connector_enabled (struct drm_connector *connector,bool strict) +{ +bool enable; + +if (connector->display_info.non_desktop) +return false; + +if (strict) + enable = connector->status == connector_status_connected; +else + enable = connector->status != connector_status_disconnected; + +return enable; +} + +static void drm_client_connectors_enabled (struct drm_connector **connectors, +unsigned int connector_count, +bool *enabled) +{ +bool any_enabled = false; +struct drm_connector *connector; +int i =0 ; + +for (i =0 ; i < connector_count; i++) { + connector = connectors[i]; + enabled[i] =drm_connector_enabled (connector, true); +DRM_DEBUG_KMS ("connector %d enabled? %s\n" , connector->base.id, + connector->display_info.non_desktop ?"non desktop" : enabled[i] ?"yes" :"no" ); + + any_enabled |= enabled[i]; + } + +if (any_enabled) +return ; + +for (i =0 ; i < connector_count; i++) + enabled[i] =drm_connector_enabled (connectors[i], false); +} + +static bool drm_client_target_cloned (struct drm_device *dev, +struct drm_connector **connectors, +unsigned int connector_count, +struct drm_display_mode **modes, +struct drm_client_offset *offsets, +bool *enabled,int width,int height) +{ +int count, i, j; +bool can_clone = false; +struct drm_display_mode *dmt_mode, *mode; + +/* only contemplate cloning in the single crtc case */ +if (dev->mode_config.num_crtc >1 ) +return false; + + count =0 ; +for (i =0 ; i < connector_count; i++) { +if (enabled[i]) + count++; + } + +/* only contemplate cloning if more than one connector is enabled */ +if (count <=1 ) +return false; + +/* check the command line or if nothing common pick 1024x768 */ + can_clone = true; +for (i =0 ; i < connector_count; i++) { +if (!enabled[i]) +continue ; + modes[i] =drm_connector_pick_cmdline_mode (connectors[i]); +if (!modes[i]) { + can_clone = false; +break ; + } +for (j =0 ; j < i; j++) { +if (!enabled[j]) +continue ; +if (!drm_mode_match (modes[j], modes[i], +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_CLOCK | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS )) + can_clone = false; + } + } + +if (can_clone) { +DRM_DEBUG_KMS ("can clone using command line\n" ); +return true; + } + +/* try and find a 1024x768 mode on each connector */ + can_clone = true; + dmt_mode =drm_mode_find_dmt (dev,1024 ,768 ,60 , false); + +for (i =0 ; i < connector_count; i++) { +if (!enabled[i]) +continue ; + +list_for_each_entry (mode, &connectors[i]->modes, head) { +if (drm_mode_match (mode, dmt_mode, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_CLOCK | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS )) + modes[i] = mode; + } +if (!modes[i]) + can_clone = false; + } + +if (can_clone) { +DRM_DEBUG_KMS ("can clone using 1024x768\n" ); +return true; + } +DRM_INFO ("kms: can't enable cloning when we probably wanted to.\n" ); +return false; +} + +static int drm_client_get_tile_offsets (struct drm_connector **connectors, +unsigned int connector_count, +struct drm_display_mode **modes, +struct drm_client_offset *offsets, +int idx, +int h_idx,int v_idx) +{ +struct drm_connector *connector; +int i; +int hoffset =0 , voffset =0 ; + +for (i =0 ; i < connector_count; i++) { + connector = connectors[i]; +if (!connector->has_tile) +continue ; + +if (!modes[i] && (h_idx || v_idx)) { +DRM_DEBUG_KMS ("no modes for connector tiled %d %d\n" , i, + connector->base.id); +continue ; + } +if (connector->tile_h_loc < h_idx) + hoffset += modes[i]->hdisplay; + +if (connector->tile_v_loc < v_idx) + voffset += modes[i]->vdisplay; + } + offsets[idx].x = hoffset; + offsets[idx].y = voffset; +DRM_DEBUG_KMS ("returned %d %d for %d %d\n" , hoffset, voffset, h_idx, v_idx); +return 0 ; +} + +static bool drm_client_target_preferred (struct drm_connector **connectors, +unsigned int connector_count, +struct drm_display_mode **modes, +struct drm_client_offset *offsets, +bool *enabled,int width,int height) +{ +const u64 mask =BIT_ULL (connector_count) -1 ; +struct drm_connector *connector; +u64 conn_configured =0 ; +int tile_pass =0 ; +int i; + +retry: +for (i =0 ; i < connector_count; i++) { + connector = connectors[i]; + +if (conn_configured &BIT_ULL (i)) +continue ; + +if (enabled[i] == false) { + conn_configured |=BIT_ULL (i); +continue ; + } + +/* first pass over all the untiled connectors */ +if (tile_pass ==0 && connector->has_tile) +continue ; + +if (tile_pass ==1 ) { +if (connector->tile_h_loc !=0 || + connector->tile_v_loc !=0 ) +continue ; + + }else { +if (connector->tile_h_loc != tile_pass -1 && + connector->tile_v_loc != tile_pass -1 ) +/* if this tile_pass doesn't cover any of the tiles - keep going */ +continue ; + +/* +* find the tile offsets for this pass - need to find +* all tiles left and above +*/ +drm_client_get_tile_offsets (connectors, connector_count, modes, offsets, i, + connector->tile_h_loc, connector->tile_v_loc); + } +DRM_DEBUG_KMS ("looking for cmdline mode on connector %d\n" , + connector->base.id); + +/* got for command line mode first */ + modes[i] =drm_connector_pick_cmdline_mode (connector); +if (!modes[i]) { +DRM_DEBUG_KMS ("looking for preferred mode on connector %d %d\n" , + connector->base.id, connector->tile_group ? connector->tile_group->id :0 ); + modes[i] =drm_connector_has_preferred_mode (connector, width, height); + } +/* No preferred modes, pick one off the list */ +if (!modes[i] && !list_empty (&connector->modes)) { +list_for_each_entry (modes[i], &connector->modes, head) +break ; + } +DRM_DEBUG_KMS ("found mode %s\n" , modes[i] ? modes[i]->name : +"none" ); + conn_configured |=BIT_ULL (i); + } + +if ((conn_configured & mask) != mask) { + tile_pass++; + goto retry; + } +return true; +} + +static bool connector_has_possible_crtc (struct drm_connector *connector, +struct drm_crtc *crtc) +{ +struct drm_encoder *encoder; +int i; + +drm_connector_for_each_possible_encoder (connector, encoder, i) { +if (encoder->possible_crtcs &drm_crtc_mask (crtc)) +return true; + } + +return false; +} + +static int drm_client_pick_crtcs (struct drm_device *dev, +struct drm_mode_set *modesets, +struct drm_connector **connectors, +unsigned int connector_count, +struct drm_crtc **best_crtcs, +struct drm_display_mode **modes, +int n,int width,int height) +{ +struct drm_connector *connector; +int my_score, best_score, score; +struct drm_crtc **crtcs, *crtc; +struct drm_mode_set *modeset; +int o; + +if (n == connector_count) +return 0 ; + + connector = connectors[n]; + + best_crtcs[n] =NULL ; + best_score =drm_client_pick_crtcs (dev, modesets, connectors, connector_count, + best_crtcs, modes, n +1 , width, height); +if (modes[n] ==NULL ) +return best_score; + + crtcs =kcalloc (connector_count,sizeof (*crtcs),GFP_KERNEL ); +if (!crtcs) +return best_score; + + my_score =1 ; +if (connector->status == connector_status_connected) + my_score++; +if (connector->cmdline_mode.specified) + my_score++; +if (drm_connector_has_preferred_mode (connector, width, height)) + my_score++; + +/* +* select a crtc for this connector and then attempt to configure +* remaining connectors +*/ +drm_client_for_each_modeset (modeset, modesets) { + crtc = modeset->crtc; + +if (!connector_has_possible_crtc (connector, crtc)) +continue ; + +for (o =0 ; o < n; o++) +if (best_crtcs[o] == crtc) +break ; + +if (o < n) { +/* ignore cloning unless only a single crtc */ +if (dev->mode_config.num_crtc >1 ) +continue ; + +if (!drm_mode_equal (modes[o], modes[n])) +continue ; + } + + crtcs[n] = crtc; +memcpy (crtcs, best_crtcs, n *sizeof (*crtcs)); + score = my_score +drm_client_pick_crtcs (dev, modesets, connectors, connector_count, + crtcs, modes, n +1 , width, height); +if (score > best_score) { + best_score = score; +memcpy (best_crtcs, crtcs, connector_count *sizeof (*crtcs)); + } + } + +kfree (crtcs); +return best_score; +} + +/* Try to read the BIOS display configuration and use it for the initial config */ +static bool drm_client_firmware_config (struct drm_device *dev, +struct drm_connector **connectors, +unsigned int connector_count, +struct drm_crtc **crtcs, +struct drm_display_mode **modes, +struct drm_client_offset *offsets, +bool *enabled,int width,int height) +{ + unsigned int count = min_t(unsigned int, connector_count, BITS_PER_LONG); +unsigned long conn_configured, conn_seq; +int i, j; +bool *save_enabled; +bool fallback = true, ret = true; +int num_connectors_enabled =0 ; +int num_connectors_detected =0 ; +struct drm_modeset_acquire_ctx ctx; + + save_enabled =kcalloc (count,sizeof (bool ),GFP_KERNEL ); +if (!save_enabled) +return false; + +drm_modeset_acquire_init (&ctx,0 ); + +while (drm_modeset_lock_all_ctx (dev, &ctx) !=0 ) +drm_modeset_backoff (&ctx); + +memcpy (save_enabled, enabled, count); + conn_seq =GENMASK (count -1 ,0 ); + conn_configured =0 ; +retry: +for (i =0 ; i < count; i++) { +struct drm_connector *connector; +struct drm_encoder *encoder; +struct drm_crtc *new_crtc; + + connector = connectors[i]; + +if (conn_configured &BIT (i)) +continue ; + +/* First pass, only consider tiled connectors */ +if (conn_seq ==GENMASK (count -1 ,0 ) && !connector->has_tile) +continue ; + +if (connector->status == connector_status_connected) + num_connectors_detected++; + +if (!enabled[i]) { +DRM_DEBUG_KMS ("connector %s not enabled, skipping\n" , + connector->name); + conn_configured |=BIT (i); +continue ; + } + +if (connector->force ==DRM_FORCE_OFF ) { +DRM_DEBUG_KMS ("connector %s is disabled by user, skipping\n" , + connector->name); + enabled[i] = false; +continue ; + } + + encoder = connector->state->best_encoder; +if (!encoder ||WARN_ON (!connector->state->crtc)) { +if (connector->force >DRM_FORCE_OFF ) + goto bail; + +DRM_DEBUG_KMS ("connector %s has no encoder or crtc, skipping\n" , + connector->name); + enabled[i] = false; + conn_configured |=BIT (i); +continue ; + } + + num_connectors_enabled++; + + new_crtc = connector->state->crtc; + +/* +* Make sure we're not trying to drive multiple connectors +* with a single CRTC, since our cloning support may not +* match the BIOS. +*/ +for (j =0 ; j < count; j++) { +if (crtcs[j] == new_crtc) { +DRM_DEBUG_KMS ("fallback: cloned configuration\n" ); + goto bail; + } + } + +DRM_DEBUG_KMS ("looking for cmdline mode on connector %s\n" , + connector->name); + +/* go for command line mode first */ + modes[i] =drm_connector_pick_cmdline_mode (connector); + +/* try for preferred next */ +if (!modes[i]) { +DRM_DEBUG_KMS ("looking for preferred mode on connector %s %d\n" , + connector->name, connector->has_tile); + modes[i] =drm_connector_has_preferred_mode (connector, width, height); + } + +/* No preferred mode marked by the EDID? Are there any modes? */ +if (!modes[i] && !list_empty (&connector->modes)) { +DRM_DEBUG_KMS ("using first mode listed on connector %s\n" , + connector->name); + modes[i] =list_first_entry (&connector->modes, + struct drm_display_mode, + head); + } + +/* last resort: use current mode */ +if (!modes[i]) { +/* +* IMPORTANT: We want to use the adjusted mode (i.e. +* after the panel fitter upscaling) as the initial +* config, not the input mode, which is what crtc->mode +* usually contains. But since our current +* code puts a mode derived from the post-pfit timings +* into crtc->mode this works out correctly. +* +* This is crtc->mode and not crtc->state->mode for the +* fastboot check to work correctly. +*/ +DRM_DEBUG_KMS ("looking for current mode on connector %s\n" , + connector->name); + modes[i] = &connector->state->crtc->mode; + } + crtcs[i] = new_crtc; + +DRM_DEBUG_KMS ("connector %s on [CRTC:%d:%s]: %dx%d%s\n" , + connector->name, + connector->state->crtc->base.id, + connector->state->crtc->name, + modes[i]->hdisplay, modes[i]->vdisplay, + modes[i]->flags &DRM_MODE_FLAG_INTERLACE ?"i" :"" ); + + fallback = false; + conn_configured |=BIT (i); + } + +if (conn_configured != conn_seq) {/* repeat until no more are found */ + conn_seq = conn_configured; + goto retry; + } + +/* +* If the BIOS didn't enable everything it could, fall back to have the +* same user experiencing of lighting up as much as possible like the +* fbdev helper library. +*/ +if (num_connectors_enabled != num_connectors_detected && + num_connectors_enabled < dev->mode_config.num_crtc) { +DRM_DEBUG_KMS ("fallback: Not all outputs enabled\n" ); +DRM_DEBUG_KMS ("Enabled: %i, detected: %i\n" , num_connectors_enabled, + num_connectors_detected); + fallback = true; + } + +if (fallback) { +bail: +DRM_DEBUG_KMS ("Not using firmware configuration\n" ); +memcpy (enabled, save_enabled, count); + ret = false; + } + +drm_modeset_drop_locks (&ctx); +drm_modeset_acquire_fini (&ctx); + +kfree (save_enabled); +return ret; +} + +/** +* drm_client_modesets_probe() - Probe for displays +* @dev: DRM device +* @width: Maximum display mode width (optional) +* @height: Maximum display mode height (optional) +* +* This function tries to set up pipelines for enabled connectors and returns +* the CRTC config as a &drm_mode_set array. +* +* Use drm_client_modesets_release() to free the array and its resources. +* +* Returns: +* A &drm_mode_set array on success, NULL if no connectors are found +* or error pointer on failure. +*/ +struct drm_mode_set * +drm_client_modesets_probe (struct drm_device *dev,unsigned int width,unsigned int height) +{ +struct drm_connector *connector, **connectors =NULL ; +struct drm_connector_list_iter conn_iter; +struct drm_mode_set *modesets =NULL ; +unsigned int total_modes_count =0 ; +struct drm_client_offset *offsets; +unsigned int connector_count =0 ; +struct drm_display_mode **modes; +struct drm_crtc **crtcs; +int i, ret =0 ; +bool *enabled; + +DRM_DEBUG_KMS ("\n" ); + +if (!width) + width = dev->mode_config.max_width; +if (!height) + height = dev->mode_config.max_height; + +drm_connector_list_iter_begin (dev, &conn_iter); +drm_client_for_each_connector_iter (connector, &conn_iter) { +struct drm_connector **tmp; + + tmp =krealloc (connectors, (connector_count +1 ) *sizeof (*connectors),GFP_KERNEL ); +if (!tmp) { + ret = -ENOMEM ; + goto free_connectors; + } + + connectors = tmp; +drm_connector_get (connector); + connectors[connector_count++] = connector; + } +drm_connector_list_iter_end (&conn_iter); + +if (!connector_count) +return NULL ; + + modesets =drm_client_modesets_create (dev); + crtcs =kcalloc (connector_count,sizeof (*crtcs),GFP_KERNEL ); + modes =kcalloc (connector_count,sizeof (*modes),GFP_KERNEL ); + offsets =kcalloc (connector_count,sizeof (*offsets),GFP_KERNEL ); + enabled =kcalloc (connector_count,sizeof (bool ),GFP_KERNEL ); +if (IS_ERR (modesets) || !crtcs || !modes || !enabled || !offsets) { +DRM_ERROR ("Memory allocation failed\n" ); + ret = -ENOMEM ; + goto out; + } + +mutex_lock (&dev->mode_config.mutex); +for (i =0 ; i < connector_count; i++) + total_modes_count += connectors[i]->funcs->fill_modes (connectors[i], width, height); +if (!total_modes_count) +DRM_DEBUG_KMS ("No connectors reported connected with modes\n" ); +drm_client_connectors_enabled (connectors, connector_count, enabled); + +if (!drm_client_firmware_config (dev, connectors, connector_count, crtcs, + modes, offsets, enabled, width, height)) { +memset (modes,0 , connector_count *sizeof (*modes)); +memset (crtcs,0 , connector_count *sizeof (*crtcs)); +memset (offsets,0 , connector_count *sizeof (*offsets)); + +if (!drm_client_target_cloned (dev, connectors, connector_count, modes, + offsets, enabled, width, height) && + !drm_client_target_preferred (connectors, connector_count, modes, + offsets, enabled, width, height)) +DRM_ERROR ("Unable to find initial modes\n" ); + +DRM_DEBUG_KMS ("picking CRTCs for %dx%d config\n" , + width, height); + +drm_client_pick_crtcs (dev, modesets, connectors, connector_count, + crtcs, modes,0 , width, height); + } +mutex_unlock (&dev->mode_config.mutex); + +for (i =0 ; i < connector_count; i++) { +struct drm_display_mode *mode = modes[i]; +struct drm_crtc *crtc = crtcs[i]; +struct drm_client_offset *offset = &offsets[i]; + +if (mode && crtc) { +struct drm_mode_set *modeset =drm_client_find_modeset (modesets, crtc); +struct drm_connector *connector = connectors[i]; + +DRM_DEBUG_KMS ("desired mode %s set on crtc %d (%d,%d)\n" , + mode->name, crtc->base.id, offset->x, offset->y); + +if (WARN_ON_ONCE (modeset->num_connectors ==DRM_CLIENT_MAX_CLONED_CONNECTORS || + (dev->mode_config.num_crtc >1 && modeset->num_connectors ==1 ))) +break ; + + modeset->mode =drm_mode_duplicate (dev, mode); +drm_connector_get (connector); + modeset->connectors[modeset->num_connectors++] = connector; + modeset->x = offset->x; + modeset->y = offset->y; + } + } +out: +kfree (crtcs); +kfree (modes); +kfree (offsets); +kfree (enabled); +free_connectors: +if (connectors) { +for (i =0 ; i < connector_count; i++) +drm_connector_put (connectors[i]); +kfree (connectors); + } + +if (ret) { +drm_client_modesets_release (modesets); +return ERR_PTR (ret); + } + +return modesets; +} +EXPORT_SYMBOL (drm_client_modesets_probe); +/** * drm_client_panel_rotation() - Check panel orientation * @modeset: DRM modeset
drivers/gpu/drm/drm_fb_helper.c +0 -697
709 lines not on this page · raw message
include/drm/drm_client.h +2 -2
@@ -16,8 +16,6 @@ struct drm_gem_object;struct drm_minor ;struct module ; -#define DRM_CLIENT_MAX_CLONED_CONNECTORS 8 -/** * struct drm_client_funcs - DRM client callbacks */
@@ -143,6 +141,8 @@ void drm_client_framebuffer_delete(struct drm_client_buffer *buffer);struct drm_mode_set *drm_client_modesets_create (struct drm_device *dev);void drm_client_modesets_release (struct drm_mode_set *modesets);struct drm_mode_set *drm_client_find_modeset (struct drm_mode_set *modesets,struct drm_crtc *crtc); +struct drm_mode_set * +drm_client_modesets_probe (struct drm_device *dev,unsigned int width,unsigned int height);bool drm_client_panel_rotation (struct drm_mode_set *modeset,unsigned int *rotation);int drm_client_modesets_commit (struct drm_device *dev,struct drm_mode_set *modesets);void drm_client_modesets_dpms (struct drm_device *dev,struct drm_mode_set *modesets,int mode);
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 13/16 drm/fb-helper: Avoid race with DRM userspace
In reply to Noralf Trønnesdrm_fb_helper_is_bound() is used to check if DRM userspace is in control. This is done by looking at the fb on the primary plane. By the time fb-helper gets around to committing, it's possible that the facts have changed.
Avoid this race by holding the drm_device->master_mutex lock while committing. When DRM userspace does its first open, it will now wait until fb-helper is done. The helper will stay away if there's a master.
Locking rule: Always take the fb-helper lock first.
--- drivers/gpu/drm/drm_auth.c | 20 ++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 49 ++++++++++++++++++++++++--------- drivers/gpu/drm/drm_internal.h | 2 ++ 3 files changed, 58 insertions(+), 13 deletions(-)
drivers/gpu/drm/drm_auth.c +20 -0
@@ -368,3 +368,23 @@ void drm_master_put(struct drm_master **master) *master =NULL ; }EXPORT_SYMBOL (drm_master_put); + +/* Used by drm_client and drm_fb_helper */ +bool drm_master_internal_acquire (struct drm_device *dev) +{ +mutex_lock (&dev->master_mutex); +if (dev->master) { +mutex_unlock (&dev->master_mutex); +return false; + } + +return true; +} +EXPORT_SYMBOL (drm_master_internal_acquire); + +/* Used by drm_client and drm_fb_helper */ +void drm_master_internal_release (struct drm_device *dev) +{ +mutex_unlock (&dev->master_mutex); +} +EXPORT_SYMBOL (drm_master_internal_release);
drivers/gpu/drm/drm_fb_helper.c +36 -13
137 lines not on this page · raw message
drivers/gpu/drm/drm_internal.h +2 -0
@@ -91,6 +91,8 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int drm_master_open (struct drm_file *file_priv);void drm_master_release (struct drm_file *file_priv); +bool drm_master_internal_acquire (struct drm_device *dev); +void drm_master_internal_release (struct drm_device *dev);/* drm_sysfs.c */ extern struct class *drm_class;
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 13/16] drm/fb-helper: Avoid race with DRM userspace
Quoted 5 lines · Noralf Trønnes
drm_fb_helper_is_bound()is used to check if DRM userspace is in control. This is done by looking at the fb on the primary plane. By the time fb-helper gets around to committing, it's possible that the facts have changed.
Quoted 8 lines
Avoid this race by holding the
drm_device->master_mutexlock while committing. When DRM userspace does its first open, it will now wait until fb-helper is done. The helper will stay away if there's a master.Locking rule: Always take the fb-helper lock first.
Suggested-by Daniel Vetter <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>
I think it'd be good to reorder this earlier in the series. And I'm wondering why you didn't replace all occurences of the _is_bound() function. With the consistent master state check we're doing with this I don't think any of the fbdev checking is still needed. Plus looking at crtc->primary->fb without any locks is racy, so would be good to ditch that hack.
-Daniel
Quoted 202 lines
--- drivers/gpu/drm/drm_auth.c | 20 ++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 49 ++++++++++++++++++++++++--------- drivers/gpu/drm/drm_internal.h | 2 ++ 3 files changed, 58 insertions(+), 13 deletions(-)drivers/gpu/drm/drm_auth.c +20
-0@@ -368,3 +368,23 @@ void drm_master_put(struct drm_master **master) *master =NULL ; }EXPORT_SYMBOL (drm_master_put); + +/* Used by drm_client and drm_fb_helper */ +bool drm_master_internal_acquire (struct drm_device *dev) +{ +mutex_lock (&dev->master_mutex); +if (dev->master) { +mutex_unlock (&dev->master_mutex); +return false; + } + +return true; +} +EXPORT_SYMBOL (drm_master_internal_acquire); + +/* Used by drm_client and drm_fb_helper */ +void drm_master_internal_release (struct drm_device *dev) +{ +mutex_unlock (&dev->master_mutex); +} +EXPORT_SYMBOL (drm_master_internal_release);drivers/gpu/drm/drm_fb_helper.c +36
-13@@ -41,6 +41,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_atomic.h> +#include "drm_internal.h" +static bool drm_fbdev_emulation = true;module_param_named (fbdev_emulation, drm_fbdev_emulation, bool,0600 ); MODULE_PARM_DESC(fbdev_emulation,@@ -235,7 +237,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)return 0 ;mutex_lock (&fb_helper->lock); - ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +if (drm_master_internal_acquire (fb_helper->dev)) { + ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +drm_master_internal_release (fb_helper->dev); + }else { + ret = -EBUSY ; + } do_delayed = fb_helper->delayed_hotplug;if (do_delayed)@@ -332,13 +339,16 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };static void drm_fb_helper_dpms (struct fb_info *info,int dpms_mode) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;/* * For each CRTC in this fb, turn the connectors on/off. */ mutex_lock (&fb_helper->lock); -if (drm_fb_helper_is_bound (fb_helper)) -drm_client_modesets_dpms (fb_helper->dev, fb_helper->modesets, dpms_mode); +if (drm_master_internal_acquire (dev)) { +drm_client_modesets_dpms (dev, fb_helper->modesets, dpms_mode); +drm_master_internal_release (dev); + }mutex_unlock (&fb_helper->lock); }@@ -1097,6 +1107,7 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)int drm_fb_helper_setcmap (struct fb_cmap *cmap,struct fb_info *info) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;int ret;if (oops_in_progress)@@ -1104,9 +1115,9 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { +if (!drm_master_internal_acquire (dev)) { ret = -EBUSY ; - goto out; + goto unlock; }if (info->fix.visual ==FB_VISUAL_TRUECOLOR )@@ -1116,7 +1127,8 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)else ret =setcmap_legacy (cmap, info); -out: +drm_master_internal_release (dev); +unlock:mutex_unlock (&fb_helper->lock);return ret;@@ -1136,11 +1148,13 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;struct drm_crtc *crtc;int ret =0 ;mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { + +if (!drm_master_internal_acquire (dev)) { ret = -EBUSY ; goto unlock; }@@ -1177,13 +1191,15 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, } ret =0 ; - goto unlock; +break ;default : ret = -ENOTTY ; } +drm_master_internal_release (dev); unlock:mutex_unlock (&fb_helper->lock); +return ret; }EXPORT_SYMBOL (drm_fb_helper_ioctl);@@ -1426,15 +1442,19 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,return -EBUSY ;mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { -mutex_unlock (&fb_helper->lock); -return -EBUSY ; + +if (!drm_master_internal_acquire (dev)) { + ret = -EBUSY ; + goto unlock; }if (drm_drv_uses_atomic_modeset (dev)) ret =pan_display_atomic (var, info);else ret =pan_display_legacy (var, info); + +drm_master_internal_release (dev); +unlock:mutex_unlock (&fb_helper->lock);return ret;@@ -1451,6 +1471,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,int ret =0 ;int crtc_count =0 ;struct drm_connector_list_iter conn_iter; +struct drm_device *dev = fb_helper->dev;struct drm_fb_helper_surface_size sizes;struct drm_connector *connector;struct drm_mode_set *mode_set;@@ -1593,8 +1614,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,DRM_INFO ("Cannot find any crtc or sizes\n" );/* First time: disable all crtc's.. */ -if (!fb_helper->deferred_setup && !READ_ONCE (fb_helper->dev->master)) -drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +if (!fb_helper->deferred_setup &&drm_master_internal_acquire (dev)) { +drm_client_modesets_commit (dev, fb_helper->modesets); +drm_master_internal_release (dev); + }return -EAGAIN ; }drivers/gpu/drm/drm_internal.h +2
-0@@ -91,6 +91,8 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int drm_master_open (struct drm_file *file_priv);void drm_master_release (struct drm_file *file_priv); +bool drm_master_internal_acquire (struct drm_device *dev); +void drm_master_internal_release (struct drm_device *dev);/* drm_sysfs.c */ extern struct class *drm_class;Signature · 1 line
2.20.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 13/16] drm/fb-helper: Avoid race with DRM userspace
Den 28.03.2019 09.17, skrev Daniel Vetter:
Quoted 15 lines · Noralf Trønnes
Quoted 5 lines
drm_fb_helper_is_bound()is used to check if DRM userspace is in control. This is done by looking at the fb on the primary plane. By the time fb-helper gets around to committing, it's possible that the facts have changed.Quoted 8 lines
Avoid this race by holding the
drm_device->master_mutexlock while committing. When DRM userspace does its first open, it will now wait until fb-helper is done. The helper will stay away if there's a master.Locking rule: Always take the fb-helper lock first.
Suggested-by Daniel Vetter <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>
Quoted 6 lines
I think it'd be good to reorder this earlier in the series. And I'm wondering why you didn't replace all occurences of the
_is_bound()function. With the consistent master state check we're doing with this I don't think any of the fbdev checking is still needed. Plus looking atcrtc->primary->fbwithout any locks is racy, so would be good to ditch that hack.
_is_bound() is used in drm_fb_helper_hotplug_event() to decide on delayed hotplug. The master lock won't help here. I have studied drm_fb_helper for 2 years now, and I still think it is convoluted and difficult to grasp in places. So I kept this one call site. I'm vary of making unrelated changes in this series.
The reason I included this patch is because it's used with the bootsplash example support code. I can move the patch earlier in the series.
Noralf.
Quoted 199 lines
-Daniel
Quoted 197 lines
--- drivers/gpu/drm/drm_auth.c | 20 ++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 49 ++++++++++++++++++++++++--------- drivers/gpu/drm/drm_internal.h | 2 ++ 3 files changed, 58 insertions(+), 13 deletions(-)drivers/gpu/drm/drm_auth.c +20
-0@@ -368,3 +368,23 @@ void drm_master_put(struct drm_master **master) *master =NULL ; }EXPORT_SYMBOL (drm_master_put); + +/* Used by drm_client and drm_fb_helper */ +bool drm_master_internal_acquire (struct drm_device *dev) +{ +mutex_lock (&dev->master_mutex); +if (dev->master) { +mutex_unlock (&dev->master_mutex); +return false; + } + +return true; +} +EXPORT_SYMBOL (drm_master_internal_acquire); + +/* Used by drm_client and drm_fb_helper */ +void drm_master_internal_release (struct drm_device *dev) +{ +mutex_unlock (&dev->master_mutex); +} +EXPORT_SYMBOL (drm_master_internal_release);drivers/gpu/drm/drm_fb_helper.c +36
-13@@ -41,6 +41,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_atomic.h> +#include "drm_internal.h" +static bool drm_fbdev_emulation = true;module_param_named (fbdev_emulation, drm_fbdev_emulation, bool,0600 ); MODULE_PARM_DESC(fbdev_emulation,@@ -235,7 +237,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)return 0 ;mutex_lock (&fb_helper->lock); - ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +if (drm_master_internal_acquire (fb_helper->dev)) { + ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +drm_master_internal_release (fb_helper->dev); + }else { + ret = -EBUSY ; + } do_delayed = fb_helper->delayed_hotplug;if (do_delayed)@@ -332,13 +339,16 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };static void drm_fb_helper_dpms (struct fb_info *info,int dpms_mode) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;/* * For each CRTC in this fb, turn the connectors on/off. */ mutex_lock (&fb_helper->lock); -if (drm_fb_helper_is_bound (fb_helper)) -drm_client_modesets_dpms (fb_helper->dev, fb_helper->modesets, dpms_mode); +if (drm_master_internal_acquire (dev)) { +drm_client_modesets_dpms (dev, fb_helper->modesets, dpms_mode); +drm_master_internal_release (dev); + }mutex_unlock (&fb_helper->lock); }@@ -1097,6 +1107,7 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)int drm_fb_helper_setcmap (struct fb_cmap *cmap,struct fb_info *info) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;int ret;if (oops_in_progress)@@ -1104,9 +1115,9 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { +if (!drm_master_internal_acquire (dev)) { ret = -EBUSY ; - goto out; + goto unlock; }if (info->fix.visual ==FB_VISUAL_TRUECOLOR )@@ -1116,7 +1127,8 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)else ret =setcmap_legacy (cmap, info); -out: +drm_master_internal_release (dev); +unlock:mutex_unlock (&fb_helper->lock);return ret;@@ -1136,11 +1148,13 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;struct drm_crtc *crtc;int ret =0 ;mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { + +if (!drm_master_internal_acquire (dev)) { ret = -EBUSY ; goto unlock; }@@ -1177,13 +1191,15 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, } ret =0 ; - goto unlock; +break ;default : ret = -ENOTTY ; } +drm_master_internal_release (dev); unlock:mutex_unlock (&fb_helper->lock); +return ret; }EXPORT_SYMBOL (drm_fb_helper_ioctl);@@ -1426,15 +1442,19 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,return -EBUSY ;mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { -mutex_unlock (&fb_helper->lock); -return -EBUSY ; + +if (!drm_master_internal_acquire (dev)) { + ret = -EBUSY ; + goto unlock; }if (drm_drv_uses_atomic_modeset (dev)) ret =pan_display_atomic (var, info);else ret =pan_display_legacy (var, info); + +drm_master_internal_release (dev); +unlock:mutex_unlock (&fb_helper->lock);return ret;@@ -1451,6 +1471,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,int ret =0 ;int crtc_count =0 ;struct drm_connector_list_iter conn_iter; +struct drm_device *dev = fb_helper->dev;struct drm_fb_helper_surface_size sizes;struct drm_connector *connector;struct drm_mode_set *mode_set;@@ -1593,8 +1614,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,DRM_INFO ("Cannot find any crtc or sizes\n" );/* First time: disable all crtc's.. */ -if (!fb_helper->deferred_setup && !READ_ONCE (fb_helper->dev->master)) -drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +if (!fb_helper->deferred_setup &&drm_master_internal_acquire (dev)) { +drm_client_modesets_commit (dev, fb_helper->modesets); +drm_master_internal_release (dev); + }return -EAGAIN ; }drivers/gpu/drm/drm_internal.h +2
-0@@ -91,6 +91,8 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int drm_master_open (struct drm_file *file_priv);void drm_master_release (struct drm_file *file_priv); +bool drm_master_internal_acquire (struct drm_device *dev); +void drm_master_internal_release (struct drm_device *dev);
Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/drm_internal.h +0
-0/* drm_sysfs.c */ extern struct class *drm_class;Signature · 1 line
2.20.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 13/16] drm/fb-helper: Avoid race with DRM userspace
Quoted 25 lines · Noralf Trønnes
Den 28.03.2019 09.17, skrev Daniel Vetter:
Quoted 15 lines · Noralf Trønnes
Quoted 5 lines
drm_fb_helper_is_bound()is used to check if DRM userspace is in control. This is done by looking at the fb on the primary plane. By the time fb-helper gets around to committing, it's possible that the facts have changed.Quoted 8 lines
Avoid this race by holding the
drm_device->master_mutexlock while committing. When DRM userspace does its first open, it will now wait until fb-helper is done. The helper will stay away if there's a master.Locking rule: Always take the fb-helper lock first.
Suggested-by Daniel Vetter <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>Quoted 6 lines
I think it'd be good to reorder this earlier in the series. And I'm wondering why you didn't replace all occurences of the
_is_bound()function. With the consistent master state check we're doing with this I don't think any of the fbdev checking is still needed. Plus looking atcrtc->primary->fbwithout any locks is racy, so would be good to ditch that hack.
Quoted 5 lines
_is_bound()is used indrm_fb_helper_hotplug_event()to decide on delayed hotplug. The master lock won't help here. I have studieddrm_fb_helperfor 2 years now, and I still think it is convoluted and difficult to grasp in places. So I kept this one call site. I'm vary of making unrelated changes in this series.
Hm, why would it not work for the hotplug case? _is_bound already checks dev->master (but with races, unlike this here). And the other checks are various levels of cargo-culting. dev->master is (well, has become through retrofitting) the "who owns the display" tracking, I think fully standardizing on that makes sense. The only case where there's a difference is if:
- some compositor dropped master
- but didn't disable it's framebuffers
We actually want that for smooth vt switching, so that the new compositor could take over in a transition. Having a special case with fbdev where the compositor has to disable all its fb or fbcon won't take over feels a bit irky.
-Daniel
Quoted 210 lines
The reason I included this patch is because it's used with the bootsplash example support code. I can move the patch earlier in the series.
Noralf.
Quoted 205 lines
-Daniel
Quoted 202 lines
--- drivers/gpu/drm/drm_auth.c | 20 ++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 49 ++++++++++++++++++++++++--------- drivers/gpu/drm/drm_internal.h | 2 ++ 3 files changed, 58 insertions(+), 13 deletions(-)drivers/gpu/drm/drm_auth.c +20
-0@@ -368,3 +368,23 @@ void drm_master_put(struct drm_master **master) *master =NULL ; }EXPORT_SYMBOL (drm_master_put); + +/* Used by drm_client and drm_fb_helper */ +bool drm_master_internal_acquire (struct drm_device *dev) +{ +mutex_lock (&dev->master_mutex); +if (dev->master) { +mutex_unlock (&dev->master_mutex); +return false; + } + +return true; +} +EXPORT_SYMBOL (drm_master_internal_acquire); + +/* Used by drm_client and drm_fb_helper */ +void drm_master_internal_release (struct drm_device *dev) +{ +mutex_unlock (&dev->master_mutex); +} +EXPORT_SYMBOL (drm_master_internal_release);drivers/gpu/drm/drm_fb_helper.c +36
-13@@ -41,6 +41,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_atomic.h> +#include "drm_internal.h" +static bool drm_fbdev_emulation = true;module_param_named (fbdev_emulation, drm_fbdev_emulation, bool,0600 ); MODULE_PARM_DESC(fbdev_emulation,@@ -235,7 +237,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)return 0 ;mutex_lock (&fb_helper->lock); - ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +if (drm_master_internal_acquire (fb_helper->dev)) { + ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +drm_master_internal_release (fb_helper->dev); + }else { + ret = -EBUSY ; + } do_delayed = fb_helper->delayed_hotplug;if (do_delayed)@@ -332,13 +339,16 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };static void drm_fb_helper_dpms (struct fb_info *info,int dpms_mode) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;/* * For each CRTC in this fb, turn the connectors on/off. */ mutex_lock (&fb_helper->lock); -if (drm_fb_helper_is_bound (fb_helper)) -drm_client_modesets_dpms (fb_helper->dev, fb_helper->modesets, dpms_mode); +if (drm_master_internal_acquire (dev)) { +drm_client_modesets_dpms (dev, fb_helper->modesets, dpms_mode); +drm_master_internal_release (dev); + }mutex_unlock (&fb_helper->lock); }@@ -1097,6 +1107,7 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)int drm_fb_helper_setcmap (struct fb_cmap *cmap,struct fb_info *info) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;int ret;if (oops_in_progress)@@ -1104,9 +1115,9 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { +if (!drm_master_internal_acquire (dev)) { ret = -EBUSY ; - goto out; + goto unlock; }if (info->fix.visual ==FB_VISUAL_TRUECOLOR )@@ -1116,7 +1127,8 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)else ret =setcmap_legacy (cmap, info); -out: +drm_master_internal_release (dev); +unlock:mutex_unlock (&fb_helper->lock);return ret;@@ -1136,11 +1148,13 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;struct drm_crtc *crtc;int ret =0 ;mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { + +if (!drm_master_internal_acquire (dev)) { ret = -EBUSY ; goto unlock; }@@ -1177,13 +1191,15 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, } ret =0 ; - goto unlock; +break ;default : ret = -ENOTTY ; } +drm_master_internal_release (dev); unlock:mutex_unlock (&fb_helper->lock); +return ret; }EXPORT_SYMBOL (drm_fb_helper_ioctl);@@ -1426,15 +1442,19 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,return -EBUSY ;mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { -mutex_unlock (&fb_helper->lock); -return -EBUSY ; + +if (!drm_master_internal_acquire (dev)) { + ret = -EBUSY ; + goto unlock; }if (drm_drv_uses_atomic_modeset (dev)) ret =pan_display_atomic (var, info);else ret =pan_display_legacy (var, info); + +drm_master_internal_release (dev); +unlock:mutex_unlock (&fb_helper->lock);return ret;@@ -1451,6 +1471,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,int ret =0 ;int crtc_count =0 ;struct drm_connector_list_iter conn_iter; +struct drm_device *dev = fb_helper->dev;struct drm_fb_helper_surface_size sizes;struct drm_connector *connector;struct drm_mode_set *mode_set;@@ -1593,8 +1614,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,DRM_INFO ("Cannot find any crtc or sizes\n" );/* First time: disable all crtc's.. */ -if (!fb_helper->deferred_setup && !READ_ONCE (fb_helper->dev->master)) -drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +if (!fb_helper->deferred_setup &&drm_master_internal_acquire (dev)) { +drm_client_modesets_commit (dev, fb_helper->modesets); +drm_master_internal_release (dev); + }return -EAGAIN ; }drivers/gpu/drm/drm_internal.h +2
-0@@ -91,6 +91,8 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int drm_master_open (struct drm_file *file_priv);void drm_master_release (struct drm_file *file_priv); +bool drm_master_internal_acquire (struct drm_device *dev); +void drm_master_internal_release (struct drm_device *dev);/* drm_sysfs.c */ extern struct class *drm_class;Signature · 1 line
2.20.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 13/16] drm/fb-helper: Avoid race with DRM userspace
Den 01.04.2019 09.12, skrev Daniel Vetter:
Quoted 32 lines · Noralf Trønnes
Quoted 25 lines
Den 28.03.2019 09.17, skrev Daniel Vetter:
Quoted 15 lines · Noralf Trønnes
Quoted 5 lines
drm_fb_helper_is_bound()is used to check if DRM userspace is in control. This is done by looking at the fb on the primary plane. By the time fb-helper gets around to committing, it's possible that the facts have changed.Quoted 8 lines
Avoid this race by holding the
drm_device->master_mutexlock while committing. When DRM userspace does its first open, it will now wait until fb-helper is done. The helper will stay away if there's a master.Locking rule: Always take the fb-helper lock first.
Suggested-by Daniel Vetter <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>Quoted 6 lines
I think it'd be good to reorder this earlier in the series. And I'm wondering why you didn't replace all occurences of the
_is_bound()function. With the consistent master state check we're doing with this I don't think any of the fbdev checking is still needed. Plus looking atcrtc->primary->fbwithout any locks is racy, so would be good to ditch that hack.Quoted 5 lines
_is_bound()is used indrm_fb_helper_hotplug_event()to decide on delayed hotplug. The master lock won't help here. I have studieddrm_fb_helperfor 2 years now, and I still think it is convoluted and difficult to grasp in places. So I kept this one call site. I'm vary of making unrelated changes in this series.
Quoted 12 lines
Hm, why would it not work for the hotplug case?
_is_boundalready checksdev->master(but with races, unlike this here). And the other checks are various levels of cargo-culting.dev->masteris (well, has become through retrofitting) the "who owns the display" tracking, I think fully standardizing on that makes sense. The only case where there's a difference is if:
- some compositor dropped master
- but didn't disable it's framebuffers
We actually want that for smooth vt switching, so that the new compositor could take over in a transition. Having a special case with fbdev where the compositor has to disable all its fb or fbcon won't take over feels a bit irky.
You're right ofc.
I read '->deferred_setup = true' when in fact it is '->delayed_hotplug = true', so I assumed there was something that _is_bound() was protecting wrt. to setup state.
I'll fix it in the next version.
Noralf.
Quoted 213 lines
-Daniel
Quoted 210 lines
The reason I included this patch is because it's used with the bootsplash example support code. I can move the patch earlier in the series.
Noralf.
Quoted 205 lines
-Daniel
Quoted 202 lines
--- drivers/gpu/drm/drm_auth.c | 20 ++++++++++++++ drivers/gpu/drm/drm_fb_helper.c | 49 ++++++++++++++++++++++++--------- drivers/gpu/drm/drm_internal.h | 2 ++ 3 files changed, 58 insertions(+), 13 deletions(-)drivers/gpu/drm/drm_auth.c +20
-0@@ -368,3 +368,23 @@ void drm_master_put(struct drm_master **master) *master =NULL ; }EXPORT_SYMBOL (drm_master_put); + +/* Used by drm_client and drm_fb_helper */ +bool drm_master_internal_acquire (struct drm_device *dev) +{ +mutex_lock (&dev->master_mutex); +if (dev->master) { +mutex_unlock (&dev->master_mutex); +return false; + } + +return true; +} +EXPORT_SYMBOL (drm_master_internal_acquire); + +/* Used by drm_client and drm_fb_helper */ +void drm_master_internal_release (struct drm_device *dev) +{ +mutex_unlock (&dev->master_mutex); +} +EXPORT_SYMBOL (drm_master_internal_release);drivers/gpu/drm/drm_fb_helper.c +36
-13@@ -41,6 +41,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_atomic.h> +#include "drm_internal.h" +static bool drm_fbdev_emulation = true;module_param_named (fbdev_emulation, drm_fbdev_emulation, bool,0600 ); MODULE_PARM_DESC(fbdev_emulation,@@ -235,7 +237,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)return 0 ;mutex_lock (&fb_helper->lock); - ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +if (drm_master_internal_acquire (fb_helper->dev)) { + ret =drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +drm_master_internal_release (fb_helper->dev); + }else { + ret = -EBUSY ; + } do_delayed = fb_helper->delayed_hotplug;if (do_delayed)@@ -332,13 +339,16 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };static void drm_fb_helper_dpms (struct fb_info *info,int dpms_mode) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;/* * For each CRTC in this fb, turn the connectors on/off. */ mutex_lock (&fb_helper->lock); -if (drm_fb_helper_is_bound (fb_helper)) -drm_client_modesets_dpms (fb_helper->dev, fb_helper->modesets, dpms_mode); +if (drm_master_internal_acquire (dev)) { +drm_client_modesets_dpms (dev, fb_helper->modesets, dpms_mode); +drm_master_internal_release (dev); + }mutex_unlock (&fb_helper->lock); }@@ -1097,6 +1107,7 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)int drm_fb_helper_setcmap (struct fb_cmap *cmap,struct fb_info *info) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;int ret;if (oops_in_progress)@@ -1104,9 +1115,9 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { +if (!drm_master_internal_acquire (dev)) { ret = -EBUSY ; - goto out; + goto unlock; }if (info->fix.visual ==FB_VISUAL_TRUECOLOR )@@ -1116,7 +1127,8 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)else ret =setcmap_legacy (cmap, info); -out: +drm_master_internal_release (dev); +unlock:mutex_unlock (&fb_helper->lock);return ret;@@ -1136,11 +1148,13 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) {struct drm_fb_helper *fb_helper = info->par; +struct drm_device *dev = fb_helper->dev;struct drm_crtc *crtc;int ret =0 ;mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { + +if (!drm_master_internal_acquire (dev)) { ret = -EBUSY ; goto unlock; }@@ -1177,13 +1191,15 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, } ret =0 ; - goto unlock; +break ;default : ret = -ENOTTY ; } +drm_master_internal_release (dev); unlock:mutex_unlock (&fb_helper->lock); +return ret; }EXPORT_SYMBOL (drm_fb_helper_ioctl);@@ -1426,15 +1442,19 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,return -EBUSY ;mutex_lock (&fb_helper->lock); -if (!drm_fb_helper_is_bound (fb_helper)) { -mutex_unlock (&fb_helper->lock); -return -EBUSY ; + +if (!drm_master_internal_acquire (dev)) { + ret = -EBUSY ; + goto unlock; }if (drm_drv_uses_atomic_modeset (dev)) ret =pan_display_atomic (var, info);else ret =pan_display_legacy (var, info); + +drm_master_internal_release (dev); +unlock:mutex_unlock (&fb_helper->lock);return ret;@@ -1451,6 +1471,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,int ret =0 ;int crtc_count =0 ;struct drm_connector_list_iter conn_iter; +struct drm_device *dev = fb_helper->dev;struct drm_fb_helper_surface_size sizes;struct drm_connector *connector;struct drm_mode_set *mode_set;@@ -1593,8 +1614,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,DRM_INFO ("Cannot find any crtc or sizes\n" );/* First time: disable all crtc's.. */ -if (!fb_helper->deferred_setup && !READ_ONCE (fb_helper->dev->master)) -drm_client_modesets_commit (fb_helper->dev, fb_helper->modesets); +if (!fb_helper->deferred_setup &&drm_master_internal_acquire (dev)) { +drm_client_modesets_commit (dev, fb_helper->modesets); +drm_master_internal_release (dev); + }return -EAGAIN ; }drivers/gpu/drm/drm_internal.h +2
-0@@ -91,6 +91,8 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int drm_master_open (struct drm_file *file_priv);void drm_master_release (struct drm_file *file_priv); +bool drm_master_internal_acquire (struct drm_device *dev); +void drm_master_internal_release (struct drm_device *dev);/* drm_sysfs.c */ extern struct class *drm_class;Signature · 1 line
2.20.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 14/16 drm/client: Add display abstraction
In reply to Noralf TrønnesAdd display abstraction and helpers to probe for displays and commit modesets.
TODO:
If the bootsplash client doesn't need to subclass drm_client_display, the callbacks can be removed.
--- drivers/gpu/drm/drm_client.c | 415 +++++++++++++++++++++++++++++++++++ include/drm/drm_client.h | 80 +++++++ 2 files changed, 495 insertions(+)
drivers/gpu/drm/drm_client.c +415 -0
@@ -4,6 +4,7 @@*/ #include <linux/list.h> +#include <linux/list_sort.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/seq_file.h>
@@ -106,6 +107,9 @@ int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,drm_dev_get (dev); +mutex_init (&client->displaylist_mutex); +INIT_LIST_HEAD (&client->displaylist); +return 0 ; err_put_module:
@@ -156,6 +160,9 @@ void drm_client_release(struct drm_client_dev *client)DRM_DEV_DEBUG_KMS (dev->dev,"%s\n" , client->name); +drm_client_release_displays (client); +mutex_destroy (&client->displaylist_mutex); +drm_client_close (client);drm_dev_put (dev);if (client->funcs)
@@ -1419,6 +1426,414 @@ void drm_client_modesets_dpms(struct drm_device *dev, struct drm_mode_set *modes }EXPORT_SYMBOL (drm_client_modesets_dpms); +static struct drm_client_display * +drm_client_display_alloc (struct drm_client_dev *client,unsigned int num_modesets) +{ +struct drm_client_display *display; +struct drm_mode_set *modesets; + + modesets =kcalloc (num_modesets +1 ,sizeof (*modesets),GFP_KERNEL ); +if (!modesets) +return ERR_PTR (-ENOMEM ); + +if (client->funcs && client->funcs->display_alloc) + display = client->funcs->display_alloc (client); +else + display =kzalloc (sizeof (*display),GFP_KERNEL ); +if (!display) + display =ERR_PTR (-ENOMEM ); + +if (IS_ERR (display)) { +kfree (modesets); +return display; + } + + display->client = client; + display->modesets = modesets; + +return display; +} + +static void drm_client_display_release (struct drm_client_display *display) +{ +unsigned int i; + +if (!display) +return ; + +for (i =0 ; i < display->num_buffers; i++) +drm_client_framebuffer_delete (display->buffers[i]); +kfree (display->buffers); + +drm_mode_destroy (display->client->dev, display->mode); + +drm_client_modesets_release (display->modesets); + +if (display->client->funcs && display->client->funcs->display_free) + display->client->funcs->display_free (display); +else +kfree (display); +} + +static void drm_client_display_debugprint (struct drm_client_display *display) +{ +struct drm_display_mode *mode = display->mode; +struct drm_mode_set *modeset; +unsigned int i; + +DRM_DEBUG_KMS (" %dx%d %dHz\n" , mode->hdisplay, mode->vdisplay, mode->vrefresh); + +drm_client_for_each_modeset (modeset, display->modesets) { +DRM_DEBUG_KMS (" crtc=%d, connectors:" , modeset->crtc->base.id); +for (i =0 ; i < modeset->num_connectors; i++) +DRM_DEBUG_KMS (" %s\n" , modeset->connectors[i]->name); + } +} + +static bool drm_client_modeset_equal (struct drm_mode_set *modeset1,struct drm_mode_set *modeset2) +{ +unsigned int i; + +if (modeset1->crtc != modeset2->crtc || + !drm_mode_equal (modeset1->mode, modeset2->mode) || + modeset1->x != modeset2->x || modeset1->y != modeset2->y || + modeset1->num_connectors != modeset2->num_connectors) +return false; + +for (i =0 ; i < modeset1->num_connectors; i++) { +if (modeset1->connectors[i] != modeset2->connectors[i]) +return false; + } + +return true; +} + +static bool drm_client_display_equal (struct drm_client_display *display1, +struct drm_client_display *display2) +{ +struct drm_mode_set *modeset1, *modeset2; + +if (!display1 || !display2) +return false; + +if (display1 == display2) +return true; + +if (!drm_mode_equal (display1->mode, display2->mode)) +return false; + +for (modeset1 = display1->modesets, modeset2 = display2->modesets; + modeset1->crtc && modeset2->crtc; modeset1++, modeset2++) +if (!drm_client_modeset_equal (modeset1, modeset2)) +return false; + +return !modeset1->crtc && !modeset2->crtc; +} + +static int drm_client_display_framebuffer_create (struct drm_client_display *display, +unsigned int num_buffers,u32 format) +{ +struct drm_client_buffer **buffers; +struct drm_mode_set *modeset; +unsigned int i; +int ret; + +if (!display || !display->mode) +return -EINVAL ; + +if (display->num_buffers && display->num_buffers != num_buffers) +return -EINVAL ; + +if (display->num_buffers == num_buffers) +return 0 ; + + buffers =kcalloc (num_buffers,sizeof (*buffers),GFP_KERNEL ); +if (!buffers) +return -ENOMEM ; + +for (i =0 ; i < num_buffers; i++) { + buffers[i] =drm_client_framebuffer_create (display->client, display->mode->hdisplay, + display->mode->vdisplay, format); +if (IS_ERR (buffers[i])) { + ret =PTR_ERR (buffers[i]); + goto err_free; + } + } + + display->buffers = buffers; + display->num_buffers = num_buffers; + +drm_client_for_each_modeset (modeset, display->modesets) + modeset->fb = display->buffers[0 ]->fb; + +return 0 ; + +err_free: +for (i =0 ; i < num_buffers; i++) { +if (!IS_ERR_OR_NULL (buffers[i])) +drm_client_framebuffer_delete (buffers[i]); + } +kfree (buffers); + +return ret; +} + +static int drm_client_find_displays (struct drm_client_dev *client,struct list_head *displaylist) +{ +struct drm_mode_set *modeset, *modesets; +struct drm_device *dev = client->dev; +struct drm_client_display *display; +unsigned int num_modesets =0 ; +int ret =0 ; + + modesets =drm_client_modesets_probe (dev,0 ,0 ); +if (IS_ERR_OR_NULL (modesets)) +return PTR_ERR_OR_ZERO (modesets); + +/* TODO: Support more than one tiled monitor? */ + display =NULL ; +drm_client_for_each_modeset (modeset, modesets) { +if (!modeset->mode || !modeset->connectors[0 ]->has_tile) +continue ; + +if (!display) { + display =drm_client_display_alloc (client, dev->mode_config.num_crtc); +if (IS_ERR (display)) { + ret =PTR_ERR (display); + goto err_free; + } + +list_add (&display->list, displaylist); + } + + display->modesets[num_modesets++] = *modeset; + modeset->num_connectors =0 ; + modeset->connectors =NULL ; + modeset->mode =NULL ; + } + +/* Contruct a mode for the tiled monitor */ +if (display) { +int hdisplay =0 , vdisplay =0 , vrefresh =0 ; + +drm_client_for_each_modeset (modeset, display->modesets) { +if (!modeset->y) + hdisplay += modeset->mode->hdisplay; +if (!modeset->x) + vdisplay += modeset->mode->vdisplay; + vrefresh = modeset->mode->vrefresh; + } + + display->mode =drm_cvt_mode (dev, hdisplay, vdisplay, vrefresh, false, false, false); +if (!display->mode) { + ret = -ENOMEM ; + goto err_free; + } + } + +/* The rest have one display per modeset */ +drm_client_for_each_modeset (modeset, modesets) { +if (!modeset->mode || modeset->connectors[0 ]->has_tile) +continue ; + + display =drm_client_display_alloc (client,1 ); +if (IS_ERR (display)) { + ret =PTR_ERR (display); + goto err_free; + } + +list_add (&display->list, displaylist); + display->modesets[0 ] = *modeset; + modeset->num_connectors =0 ; + modeset->connectors =NULL ; + modeset->mode =NULL ; + + display->mode =drm_mode_duplicate (dev, display->modesets[0 ].mode); +if (!display->mode) { + ret = -ENOMEM ; + goto err_free; + } + } + + goto out; + +err_free: +list_for_each_entry (display, displaylist, list) +drm_client_display_release (display); +out: +drm_client_modesets_release (modesets); + +return ret; +} + +static int drm_client_displays_compare (void *priv,struct list_head *lh_a,struct list_head *lh_b) +{ + struct drm_client_display *a = list_entry(lh_a, struct drm_client_display, list); + struct drm_client_display *b = list_entry(lh_b, struct drm_client_display, list); + +return b->mode->hdisplay * b->mode->vdisplay - a->mode->hdisplay * a->mode->vdisplay; +} + +static void drm_client_displays_sort (struct list_head *displaylist) +{ +list_sort (NULL , displaylist, drm_client_displays_compare); +} + +/** +* drm_client_probe_displays() - Probe for displays +* @client: DRM client +* @num_buffers: Number of buffers to attach (optional) +* @format: Buffer format +* +* This function probes for connected displays and updates the clients list of displays. +* The list is sorted from largest to smallest. +* +* Returns: +* Number of displays or negative error code on failure. +*/ +int drm_client_probe_displays (struct drm_client_dev *client,unsigned int num_buffers,u32 format) +{ +struct drm_client_display *display, *tmp; +LIST_HEAD (displaylist); +bool changed = false; +int ret; + + ret =drm_client_find_displays (client, &displaylist); +if (ret <0 ) +return ret; + +if (list_empty (&displaylist)) { +drm_client_release_displays (client); +return 0 ; + } + +mutex_lock (&client->displaylist_mutex); + +/* If a display hasn't changed, keep it to avoid reallocating buffers */ +list_for_each_entry_safe (display, tmp, &client->displaylist, list) { +struct drm_client_display *display2, *tmp2; +bool found = false; + +list_for_each_entry_safe (display2, tmp2, &displaylist, list) { +if (drm_client_display_equal (display, display2)) { +list_del (&display2->list); +drm_client_display_release (display2); + found = true; +break ; + } + } + +if (!found) { +list_del (&display->list); +drm_client_display_release (display); + changed = true; + } + } + +if (!list_empty (&displaylist)) + changed = true; + +list_splice (&displaylist, &client->displaylist); + +/* Sort from largest to smallest */ +drm_client_displays_sort (&client->displaylist); + +if (changed) { +DRM_DEBUG_KMS ("Displays:\n" ); +drm_client_for_each_display (display, client) +drm_client_display_debugprint (display); + } + +if (num_buffers) { +drm_client_for_each_display (display, client) { + ret =drm_client_display_framebuffer_create (display, num_buffers, format); +if (ret) + goto out_unlock; + } + } + + ret =0 ; +drm_client_for_each_display (display, client) + ret++; + +out_unlock: +mutex_unlock (&client->displaylist_mutex); + +return ret; +} +EXPORT_SYMBOL (drm_client_probe_displays); + +/** +* drm_client_release_displays() - Release displays +* @client: DRM client +* +* This function releases all the clients displays. +*/ +void drm_client_release_displays (struct drm_client_dev *client) +{ +struct drm_client_display *display, *tmp; + +mutex_lock (&client->displaylist_mutex); +list_for_each_entry_safe (display, tmp, &client->displaylist, list) { +list_del (&display->list); +drm_client_display_release (display); + } +mutex_unlock (&client->displaylist_mutex); +} +EXPORT_SYMBOL (drm_client_release_displays); + +static int drm_client_display_set_buffer (struct drm_client_display *display,unsigned int buffer) +{ +struct drm_mode_set *modeset; + +if (!display || buffer >= display->num_buffers) +return -EINVAL ; + +drm_client_for_each_modeset (modeset, display->modesets) + modeset->fb = display->buffers[buffer]->fb; + +return 0 ; +} + +static int drm_client_display_commit (struct drm_client_display *display) +{ +int ret; + +if (!display) +return -EINVAL ; + +if (!drm_master_internal_acquire (display->client->dev)) +return -EBUSY ; + + ret =drm_client_modesets_commit (display->client->dev, display->modesets); + +drm_master_internal_release (display->client->dev); + +return ret; +} + +/** +* drm_client_display_commit_buffer() - Commit display modeset(s) with buffer +* @display: Client display +* @buffer: Buffer index +* +* This function sets the framebuffer to @buffer and commits the modeset(s). +* +* Returns: +* Zero on success or negative error code on failure. +*/ +int drm_client_display_commit_buffer (struct drm_client_display *display,unsigned int buffer) +{ +int ret; + + ret =drm_client_display_set_buffer (display, buffer); +if (ret) +return ret; + +return drm_client_display_commit (display); +} +EXPORT_SYMBOL (drm_client_display_commit_buffer); +#ifdef CONFIG_DEBUG_FS static int drm_client_debugfs_internal_clients (struct seq_file *m,void *data) {
include/drm/drm_client.h +80 -0
110 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 15/16 drm/client: Hack: Add bootsplash example
In reply to Noralf TrønnesAn example to showcase the client API.
TODO:
A bootsplash client needs a way to tell drm_fb_helper to stay away, otherwise it will chime in on setup and hotplug.
Most DRM drivers register fbdev before calling drm_dev_register() (the generic emulation is an exception). This have to be reversed for bootsplash to fend off fbdev.
--- drivers/gpu/drm/Kconfig | 5 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_bootsplash.c | 216 +++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_client.c | 7 + drivers/gpu/drm/drm_drv.c | 4 + include/drm/drm_client.h | 3 + 6 files changed, 236 insertions(+) create mode 100644 drivers/gpu/drm/drm_bootsplash.c
drivers/gpu/drm/Kconfig +5 -0
@@ -65,6 +65,11 @@ config DRM_DEBUG_SELFTEST If in doubt, say "N". +config DRM_CLIENT_BOOTSPLASH + bool "DRM Bootsplash" + help + DRM Bootsplash + config DRM_KMS_HELPER tristate depends on DRM
drivers/gpu/drm/Makefile +1 -0
@@ -32,6 +32,7 @@ drm-$(CONFIG_OF) += drm_of.o drm-$(CONFIG_AGP) += drm_agpsupport.o drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o +drm-$(CONFIG_DRM_CLIENT_BOOTSPLASH) += drm_bootsplash.o drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_dsc.o drm_probe_helper.o \ drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
drivers/gpu/drm/drm_bootsplash.c new file +216 -0
216 lines not on this page · raw message
drivers/gpu/drm/drm_client.c +7 -0
@@ -170,6 +170,13 @@ void drm_client_release(struct drm_client_dev *client) }EXPORT_SYMBOL (drm_client_release); +void drm_client_dev_register (struct drm_device *dev) +{ +#if CONFIG_DRM_CLIENT_BOOTSPLASH +drm_bootsplash_client_register (dev); +#endif +} +void drm_client_dev_unregister (struct drm_device *dev) {struct drm_client_dev *client, *tmp;
drivers/gpu/drm/drm_drv.c +4 -0
@@ -1018,6 +1018,10 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)drm_minor_unregister (dev,DRM_MINOR_RENDER ); out_unlock:mutex_unlock (&drm_global_mutex); + +if (!ret) +drm_client_dev_register (dev); +return ret; }EXPORT_SYMBOL (drm_dev_register);
include/drm/drm_client.h +3 -0
@@ -130,6 +130,7 @@ int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,void drm_client_release (struct drm_client_dev *client);void drm_client_add (struct drm_client_dev *client); +void drm_client_dev_register (struct drm_device *dev);void drm_client_dev_unregister (struct drm_device *dev);void drm_client_dev_hotplug (struct drm_device *dev);void drm_client_dev_restore (struct drm_device *dev);
@@ -251,4 +252,6 @@ int drm_client_display_commit_buffer(struct drm_client_display *display, unsigneint drm_client_debugfs_init (struct drm_minor *minor); +void drm_bootsplash_client_register (struct drm_device *dev); +#endif
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 16/16 drm/vc4: Call drm_dev_register() after all setup is done
In reply to Noralf Trønnesdrm_dev_register() initializes internal clients like bootsplash as the last thing it does, so all setup needs to be done at this point.
Fix by calling vc4_kms_load() before registering. Also check the error code returned from that function.
--- drivers/gpu/drm/vc4/vc4_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.c +4 -2
@@ -280,11 +280,13 @@ static int vc4_drm_bind(struct device *dev)drm_fb_helper_remove_conflicting_framebuffers (NULL ,"vc4drmfb" , false); - ret =drm_dev_register (drm,0 ); + ret =vc4_kms_load (drm);if (ret <0 ) goto unbind_all; -vc4_kms_load (drm); + ret =drm_dev_register (drm,0 ); +if (ret <0 ) + goto unbind_all;drm_fbdev_generic_setup (drm,16 );
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 16/16] drm/vc4: Call drm_dev_register() after all setup is done
Quoted 8 lines · Noralf Trønnes
drm_dev_register()initializes internal clients like bootsplash as the last thing it does, so all setup needs to be done at this point.Fix by calling
vc4_kms_load()before registering. Also check the error code returned from that function.Cc Eric Anholt <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>
Looks like this has been slightly backwards ever since vc4 landed. I guess would have needed the split between kms setup and fbdev setup (which is now done with the generic fbdev).
Quoted 31 lines
--- drivers/gpu/drm/vc4/vc4_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/vc4/vc4_drv.c +4
-2@@ -280,11 +280,13 @@ static int vc4_drm_bind(struct device *dev)drm_fb_helper_remove_conflicting_framebuffers (NULL ,"vc4drmfb" , false); - ret =drm_dev_register (drm,0 ); + ret =vc4_kms_load (drm);if (ret <0 ) goto unbind_all; -vc4_kms_load (drm); + ret =drm_dev_register (drm,0 ); +if (ret <0 ) + goto unbind_all;drm_fbdev_generic_setup (drm,16 );Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 16/16] drm/vc4: Call drm_dev_register() after all setup is done
In reply to Noralf TrønnesQuoted 8 lines · Noralf Trønnes
drm_dev_register()initializes internal clients like bootsplash as the last thing it does, so all setup needs to be done at this point.Fix by calling
vc4_kms_load()before registering. Also check the error code returned from that function.Cc Eric Anholt <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Noralf Trønnes
AppliedRe: [PATCH 16/16] drm/vc4: Call drm_dev_register() after all setup is done
Den 27.03.2019 17.36, skrev Eric Anholt:
Quoted 5 lines
Quoted 3 lines · Noralf Trønnes
drm_dev_register()initializes internal clients like bootsplash as the last thing it does, so all setup needs to be done at this point.
Quoted 8 lines
Quoted 5 lines
Fix by calling
vc4_kms_load()before registering. Also check the error code returned from that function.Cc Eric Anholt <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>Reviewed-by Eric Anholt <[email protected]>
Applied to drm-misc-next.
Noralf.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for drm/fb-helper: Move modesetting code to drm_client
In reply to Noralf Trønnes== Series Details ==
== Series Details ==
Series: drm/fb-helper: Move modesetting code to drm_client
URL : https://patchwork.freedesktop.org/series/58597/
State : failure
== Summary ==
Applying: drm/fb-helper: Remove unused gamma_size variable
Applying: drm/fb-helper: dpms_legacy(): Only set on connectors in use
Applying: drm/atomic: Move __drm_atomic_helper_disable_plane/set_config() Using index info to reconstruct a base tree...
M drivers/gpu/drm/drm_atomic_helper.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/drm_atomic_helper.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/drm_atomic_helper.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch' to see the failed patch
Patch failed at 0003 drm/atomic: Move __drm_atomic_helper_disable_plane/set_config() When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Den 26.03.2019 18.55, skrev Noralf Trønnes:
Quoted 6 lines
This moves the modesetting code from
drm_fb_helpertodrm_clientso it can be shared by all internal clients.I have also added a client display abstraction and a bootsplash example client to show where this might be heading. Hopefully Max Staudt will be able to pick up his bootsplash work now.
I get 'User has moved to <unknown>' failure on Max's email address. If someone knows his new address, please cc him this cover letter.
Noralf.
Quoted 32 lines
Noralf.
Noralf Trønnes (16):
drm/fb-helper: Remove unusedgamma_sizevariable drm/fb-helper:dpms_legacy(): Only set on connectors in use drm/atomic: Move __drm_atomic_helper_disable_plane/set_config() drm/fb-helper: No need to cache rotation andsw_rotationsdrm/fb-helper: Remove drm_fb_helper_crtc->{x,y,desired_mode} drm/i915/fbdev: Moveintel_fb_initial_config()to fbdev helper drm/fb-helper: Removedrm_fb_helper_crtcdrm/fb-helper: Prepare to move out commit code drm/fb-helper: Move out commit code
drm/fb-helper: Removedrm_fb_helper_connectordrm/fb-helper: Prepare to move out modeset config code drm/fb-helper: Move out modeset config code drm/fb-helper: Avoid race with DRM userspace drm/client: Add display abstraction
drm/client: Hack: Add bootsplash example
drm/vc4: Calldrm_dev_register()after all setup is doneDocumentation/gpu/todo.rst | 10 + drivers/gpu/drm/Kconfig | 5 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_atomic.c | 168 ++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --- drivers/gpu/drm/drm_auth.c | 20 + drivers/gpu/drm/drm_bootsplash.c | 216 ++++ drivers/gpu/drm/drm_client.c | 1449 +++++++++++++++++++++++++++ drivers/gpu/drm/drm_crtc_internal.h | 5 + drivers/gpu/drm/drm_drv.c | 4 + drivers/gpu/drm/drm_fb_helper.c | 1151 ++-------------------
Quoted 9 lines
drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/i915/intel_fbdev.c | 218 ---- drivers/gpu/drm/vc4/vc4_drv.c | 6 +- include/drm/drm_atomic_helper.h | 4 - include/drm/drm_client.h | 117 +++ include/drm/drm_fb_helper.h | 127 +-- 17 files changed, 2128 insertions(+), 1539 deletions(-) create mode 100644 drivers/gpu/drm/drm_bootsplash.c
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerHi
Am 27.03.19 um 14:45 schrieb Noralf Trønnes:
Quoted 6 lines
Den 26.03.2019 18.55, skrev Noralf Trønnes:
Quoted 3 lines
This moves the modesetting code from
drm_fb_helpertodrm_clientso it can be shared by all internal clients.
Quoted 6 lines
Quoted 3 lines
I have also added a client display abstraction and a bootsplash example client to show where this might be heading. Hopefully Max Staudt will be able to pick up his bootsplash work now.
I get 'User has moved to <unknown>' failure on Max's email address. If someone knows his new address, please cc him this cover letter.
He left SUSE quiet a while ago.
Best regards
Thomas
Quoted 49 lines
Noralf.
Quoted 32 lines
Noralf.
Noralf Trønnes (16):
drm/fb-helper: Remove unusedgamma_sizevariable drm/fb-helper:dpms_legacy(): Only set on connectors in use drm/atomic: Move __drm_atomic_helper_disable_plane/set_config() drm/fb-helper: No need to cache rotation andsw_rotationsdrm/fb-helper: Remove drm_fb_helper_crtc->{x,y,desired_mode} drm/i915/fbdev: Moveintel_fb_initial_config()to fbdev helper drm/fb-helper: Removedrm_fb_helper_crtcdrm/fb-helper: Prepare to move out commit code drm/fb-helper: Move out commit code
drm/fb-helper: Removedrm_fb_helper_connectordrm/fb-helper: Prepare to move out modeset config code drm/fb-helper: Move out modeset config code drm/fb-helper: Avoid race with DRM userspace drm/client: Add display abstraction
drm/client: Hack: Add bootsplash example
drm/vc4: Calldrm_dev_register()after all setup is doneDocumentation/gpu/todo.rst | 10 + drivers/gpu/drm/Kconfig | 5 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_atomic.c | 168 ++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --- drivers/gpu/drm/drm_auth.c | 20 + drivers/gpu/drm/drm_bootsplash.c | 216 ++++ drivers/gpu/drm/drm_client.c | 1449 +++++++++++++++++++++++++++ drivers/gpu/drm/drm_crtc_internal.h | 5 + drivers/gpu/drm/drm_drv.c | 4 + drivers/gpu/drm/drm_fb_helper.c | 1151 ++-------------------Quoted 9 lines
drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/i915/intel_fbdev.c | 218 ---- drivers/gpu/drm/vc4/vc4_drv.c | 6 +- include/drm/drm_atomic_helper.h | 4 - include/drm/drm_client.h | 117 +++ include/drm/drm_fb_helper.h | 127 +-- 17 files changed, 2128 insertions(+), 1539 deletions(-) create mode 100644 drivers/gpu/drm/drm_bootsplash.c_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 5 lines
Thomas Zimmermann Graphics Driver Developer SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 6 lines · Noralf Trønnes
This moves the modesetting code from
drm_fb_helpertodrm_clientso it can be shared by all internal clients.I have also added a client display abstraction and a bootsplash example client to show where this might be heading. Hopefully Max Staudt will be able to pick up his bootsplash work now.
First a fairly unrelated thing that I noticed while reading stuff:
In drm_fbdev_generic_setup() we register the drm_client to the world (with drm_client_add) before it's fully set up. And the checks in the setup code aren't safe against a concurrent hotplug call from another thread. Which can happen, because usually by that point, and definitely by the time the driver called drm_dev_register() the hotplug handler is running.
Maybe good idea to rename drm_client_add to drm_client_register (to stay consistent with our naming scheme of _register() = others can start calling us from any thread).
We need to do the basic setup code _before_ we call drm_client_register. The kerneldoc for the various fbdev setup functions have explanations for when exactly it's ok to handle hotplug events.
The other bit is kinda the high-level review on the drm_client modeset api:
- Allowing multiple different modeset clients per drm_client feels like overkill. I think we can just require a 1:1 mapping between drm_client and modeset config. If a client wants to have multiple different modeset configs per drm_device they can create more drm_clients.
- That also fixes your "do we need embedding" question, since drm_client supports that already.
- That means we could clean up the api considerably by embedding all the modeset stuff into drm_client, and e.g. allocating the modeset arrays at drm_client_init() time.
- Except that wouldn't work with the current fbdev emulation code, because that one isn't always using drm_client.
Hence my question/suggestion: Could we rework the fbdev emulation to always allocate a drm_client, but only use drm_client for buffer allocation for generic_setup(). That could also provide us with a smoother upgrade path for other drivers to generic_setup, e.g. we could ditch all the hotplug handling already.
I'm thinking of embedding a drm_client into drm_fb_helper, and calling drm_client_init() on it at the right time. But only call drm_client_add() for generic_setup(). At least as a first step.
Related question: What's the plan for drivers which don't support generic_setup()? If we eventually have stuff like kmscon running on top of drm_client, we'd have to somehow port them all ...
And finally the bikeshed: I thik drm_client_modeset would be a good prefix for all this (maybe even in a separate file):
- we have a pretty clear split between basic drm stuff and kms
- modeset means kms, display usually only means the actual physical display. drm_simple_display_pipe always gets me with using display instead of modeset, but a bit too late to rename that one :-)
Thoughts on this?
Cheers, Daniel
Quoted 48 lines
Noralf.
Noralf Trønnes (16):
drm/fb-helper: Remove unusedgamma_sizevariable drm/fb-helper:dpms_legacy(): Only set on connectors in use drm/atomic: Move __drm_atomic_helper_disable_plane/set_config() drm/fb-helper: No need to cache rotation andsw_rotationsdrm/fb-helper: Remove drm_fb_helper_crtc->{x,y,desired_mode} drm/i915/fbdev: Moveintel_fb_initial_config()to fbdev helper drm/fb-helper: Removedrm_fb_helper_crtcdrm/fb-helper: Prepare to move out commit code drm/fb-helper: Move out commit code
drm/fb-helper: Removedrm_fb_helper_connectordrm/fb-helper: Prepare to move out modeset config code drm/fb-helper: Move out modeset config code drm/fb-helper: Avoid race with DRM userspace drm/client: Add display abstraction
drm/client: Hack: Add bootsplash example
drm/vc4: Calldrm_dev_register()after all setup is doneDocumentation/gpu/todo.rst | 10 + drivers/gpu/drm/Kconfig | 5 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_atomic.c | 168 ++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --- drivers/gpu/drm/drm_auth.c | 20 + drivers/gpu/drm/drm_bootsplash.c | 216 ++++ drivers/gpu/drm/drm_client.c | 1449 +++++++++++++++++++++++++++ drivers/gpu/drm/drm_crtc_internal.h | 5 + drivers/gpu/drm/drm_drv.c | 4 + drivers/gpu/drm/drm_fb_helper.c | 1151 ++------------------- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/i915/intel_fbdev.c | 218 ---- drivers/gpu/drm/vc4/vc4_drv.c | 6 +- include/drm/drm_atomic_helper.h | 4 - include/drm/drm_client.h | 117 +++ include/drm/drm_fb_helper.h | 127 +-- 17 files changed, 2128 insertions(+), 1539 deletions(-) create mode 100644 drivers/gpu/drm/drm_bootsplash.cSignature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Den 28.03.2019 10.31, skrev Daniel Vetter:
Quoted 8 lines · Noralf Trønnes
Quoted 6 lines
This moves the modesetting code from
drm_fb_helpertodrm_clientso it can be shared by all internal clients.I have also added a client display abstraction and a bootsplash example client to show where this might be heading. Hopefully Max Staudt will be able to pick up his bootsplash work now.
Quoted 8 lines
First a fairly unrelated thing that I noticed while reading stuff:
In
drm_fbdev_generic_setup()we register thedrm_clientto the world (withdrm_client_add) before it's fully set up. And the checks in the setup code aren't safe against a concurrent hotplug call from another thread. Which can happen, because usually by that point, and definitely by the time the driver calleddrm_dev_register()the hotplug handler is running.
Ah, this hasn't crossed my mind. I'll move drm_client_add() after setup.
Quoted 4 lines
Maybe good idea to rename
drm_client_addtodrm_client_register(to stay consistent with our naming scheme of_register()= others can start calling us from any thread).
Makes sense, I'll change the name.
Quoted 11 lines
We need to do the basic setup code _before_ we call
drm_client_register. The kerneldoc for the various fbdev setup functions have explanations for when exactly it's ok to handle hotplug events.The other bit is kinda the high-level review on the
drm_clientmodeset api:
- Allowing multiple different modeset clients perdrm_clientfeels like overkill. I think we can just require a 1:1 mapping betweendrm_clientand modeset config. If a client wants to have multiple different modeset configs perdrm_devicethey can create moredrm_clients.
The reason I ended up doing this is that there can be more than one display connected. So for me the natural choice was to have each display represented individually with its own modeset(s).
I did consider having the modeset array attached to drm_client and use a modesets mask to tell the displays apart. It would have been easier if we didn't have those tiled monitors driven by multiple outputs, because that would have given us one modeset per display.
drm_fb_helper uses the same framebuffer for all displays, sizing it to match the smallest.
Ofc the easy way out is to only support one display per drm_device. I don't see how multiple drm_clients per drm_device should work. Should the client keep an array of drm_client for as many displays as it supports?
The bootsplash client example I made, puts a splash on all displays it can find. But maybe it should do it on only one display? If so we need some heuristics to determine which is the primary display.
Not sure how kmscon is supposed to work, but I believe it is meant to be a developer console. So I guess it will also just use the primary display.
Quoted 16 lines
- That also fixes your "do we need embedding" question, since
drm_clientsupports that already.- That means we could clean up the api considerably by embedding all the modeset stuff into
drm_client, and e.g. allocating the modeset arrays atdrm_client_init()time.- Except that wouldn't work with the current fbdev emulation code, because that one isn't always using
drm_client.Hence my question/suggestion: Could we rework the fbdev emulation to always allocate a
drm_client, but only usedrm_clientfor buffer allocation forgeneric_setup(). That could also provide us with a smoother upgrade path for other drivers togeneric_setup, e.g. we could ditch all the hotplug handling already.
Quoted 4 lines
I'm thinking of embedding a
drm_clientintodrm_fb_helper, and callingdrm_client_init()on it at the right time. But only calldrm_client_add()forgeneric_setup(). At least as a first step.
Yeah, this certainly makes sense if we have the modesets attached to drm_client_dev.
Quoted 4 lines
Related question: What's the plan for drivers which don't support
generic_setup()? If we eventually have stuff like kmscon running on top ofdrm_client, we'd have to somehow port them all ...
It should just work as long the driver supports ->dumb_create and ->gem_prime_vmap.
rockchip and mediatek (I think) don't provide a virtual address on its buffers because of limited virtual address space.
We could add a ->dumb_create_internal hook so these drivers could provide an address to internal clients. This way they could use the generic fbdev emualtion as well. Unless Rob finds a way to vmap a dma buffer after allocation. He has looked at converting rockchip to generic fbdev.
Quoted 2 lines
And finally the bikeshed: I thik
drm_client_modesetwould be a good prefix for all this (maybe even in a separate file):
I have used prefix drm_client_modesets_ for all functions that operates on the modeset array.
Emmanuel Vadot alerted me to the fact that dm_fb_helper is MIT licensed. I was now planning to change drm_client to MIT as well, so I can legally move over code. If we add drm_client_modeset.c with a MIT license, then I wouldn't have to change the license of drm_client.c.
I think I would prefer to have it all in one file. drm_client.c is now 421 lines including everything, when I add the modeset code it becomes 1871. But it's not very important to me either way.
Noralf.
Quoted 5 lines
- we have a pretty clear split between basic drm stuff and kms
- modeset means kms, display usually only means the actual physical display.drm_simple_display_pipealways gets me with using display instead of modeset, but a bit too late to rename that one :-)
Quoted 54 lines
Thoughts on this?
Cheers, Daniel
Quoted 48 lines
Noralf.
Noralf Trønnes (16):
drm/fb-helper: Remove unusedgamma_sizevariable drm/fb-helper:dpms_legacy(): Only set on connectors in use drm/atomic: Move __drm_atomic_helper_disable_plane/set_config() drm/fb-helper: No need to cache rotation andsw_rotationsdrm/fb-helper: Remove drm_fb_helper_crtc->{x,y,desired_mode} drm/i915/fbdev: Moveintel_fb_initial_config()to fbdev helper drm/fb-helper: Removedrm_fb_helper_crtcdrm/fb-helper: Prepare to move out commit code drm/fb-helper: Move out commit code
drm/fb-helper: Removedrm_fb_helper_connectordrm/fb-helper: Prepare to move out modeset config code drm/fb-helper: Move out modeset config code drm/fb-helper: Avoid race with DRM userspace drm/client: Add display abstraction
drm/client: Hack: Add bootsplash example
drm/vc4: Calldrm_dev_register()after all setup is doneDocumentation/gpu/todo.rst | 10 + drivers/gpu/drm/Kconfig | 5 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_atomic.c | 168 ++++ drivers/gpu/drm/drm_atomic_helper.c | 164 --- drivers/gpu/drm/drm_auth.c | 20 + drivers/gpu/drm/drm_bootsplash.c | 216 ++++ drivers/gpu/drm/drm_client.c | 1449 +++++++++++++++++++++++++++ drivers/gpu/drm/drm_crtc_internal.h | 5 + drivers/gpu/drm/drm_drv.c | 4 + drivers/gpu/drm/drm_fb_helper.c | 1151 ++------------------- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/i915/intel_fbdev.c | 218 ---- drivers/gpu/drm/vc4/vc4_drv.c | 6 +- include/drm/drm_atomic_helper.h | 4 - include/drm/drm_client.h | 117 +++ include/drm/drm_fb_helper.h | 127 +-- 17 files changed, 2128 insertions(+), 1539 deletions(-) create mode 100644 drivers/gpu/drm/drm_bootsplash.cSignature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx