drm/fb-helper: Deferred setup support
Subsystems (11)
v3 cover drm/fb-helper: Deferred setup support
From: Thierry Reding <[email protected]>
This set of patches adds support for deferring FB helper setup, which is useful to obtain a sane configuration even when no outputs are available during probe.
One example is HDMI, where fbdev will currently fallback to a 1024x786 resolution if no monitor is connected, and will then forever stay that way. With these patches, the FB helpers will take note that it doesn't make sense to setup fbdev yet and will defer until a monitor is connected, at which point the preferred mode will be selected.
Thierry
Changes in v3:
- fix kerneldoc for top-level FB helper lock
- drop some patches that no longer apply
- add Tested-by from John Stultz
- add cleanup patches
Changes in v2:
- now with locking
Thierry Reding (10):
drm/fb-helper: Cleanup checkpatch warnings drm/fb-helper: Reshuffle code for subsequent patches drm/fb-helper: Improve code readability drm/fb-helper: Push down modeset lock into FB helpers drm/fb-helper: Add top-level lock drm/fb-helper: Support deferred setup drm/exynos: Remove custom FB helper deferred setup drm/hisilicon: Remove custom FB helper deferred setup drm/atmel-hlcdc: Remove unnecessary NULL check drm/rockchip: Remove unnecessary NULL check
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 3 +- drivers/gpu/drm/drm_fb_helper.c | 242 ++++++++++++++++++------ drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 +- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 - drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 21 +- drivers/gpu/drm/i915/intel_dp_mst.c | 3 - drivers/gpu/drm/radeon/radeon_dp_mst.c | 7 - drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 4 +- include/drm/drm_fb_helper.h | 28 +++ 9 files changed, 225 insertions(+), 91 deletions(-)
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 1/10 drm/fb-helper: Cleanup checkpatch warnings
From: Thierry Reding <[email protected]>
Fix up a couple of checkpatch warnings, such as whitespace or coding style issues.
--- drivers/gpu/drm/drm_fb_helper.c | 54 ++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 22 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +32 -22
@@ -213,9 +213,9 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, fb_helper_connector = fb_helper->connector_info[i];drm_connector_put (fb_helper_connector->connector); -for (j = i +1 ; j < fb_helper->connector_count; j++) { +for (j = i +1 ; j < fb_helper->connector_count; j++) fb_helper->connector_info[j -1 ] = fb_helper->connector_info[j]; - } + fb_helper->connector_count--;kfree (fb_helper_connector);
@@ -316,6 +316,7 @@ int drm_fb_helper_debug_leave(struct fb_info *info)for (i =0 ; i < helper->crtc_count; i++) {struct drm_mode_set *mode_set = &helper->crtc_info[i].mode_set; + crtc = mode_set->crtc; funcs = crtc->helper_private; fb =drm_mode_config_fb (crtc);
@@ -346,7 +347,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper)struct drm_plane *plane;struct drm_atomic_state *state;int i, ret; -unsigned plane_mask; +unsigned int plane_mask; state =drm_atomic_state_alloc (dev);if (!state)
@@ -378,7 +379,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper) goto fail; } -for (i =0 ; i < fb_helper->crtc_count; i++) { +for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_mode_set *mode_set = &fb_helper->crtc_info[i].mode_set; ret =__drm_atomic_helper_set_config (mode_set, state);
@@ -488,8 +489,10 @@ static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper)struct drm_crtc *crtc;int bound =0 , crtcs_bound =0 ; -/* Sometimes user space wants everything disabled, so don't steal the -* display if there's a master. */ +/* +* Sometimes user space wants everything disabled, so don't steal the +* display if there's a master. +*/ if (READ_ONCE (dev->master))return false;
@@ -537,6 +540,7 @@ static bool drm_fb_helper_force_kernel_mode(void)static void drm_fb_helper_restore_work_fn (struct work_struct *ignored) {bool ret; + ret =drm_fb_helper_force_kernel_mode ();if (ret == true)DRM_ERROR ("Failed to restore crtc configuration\n" );
@@ -870,9 +874,8 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)mutex_lock (&kernel_fb_helper_lock);if (!list_empty (&fb_helper->kernel_fb_list)) {list_del (&fb_helper->kernel_fb_list); -if (list_empty (&kernel_fb_helper_list)) { +if (list_empty (&kernel_fb_helper_list))unregister_sysrq_key ('v' , &sysrq_drm_fb_helper_restore_op); - } }mutex_unlock (&kernel_fb_helper_lock);
@@ -1165,6 +1168,7 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, (blue << info->var.blue.offset);if (info->var.transp.length >0 ) {u32 mask = (1 << info->var.transp.length) -1 ; + mask <<= info->var.transp.offset; value |= mask; }
@@ -1447,7 +1451,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var,struct drm_atomic_state *state;struct drm_plane *plane;int i, ret; -unsigned plane_mask; +unsigned int plane_mask; state =drm_atomic_state_alloc (dev);if (!state)
@@ -1456,7 +1460,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var, state->acquire_ctx = dev->mode_config.acquire_ctx; retry: plane_mask =0 ; -for (i =0 ; i < fb_helper->crtc_count; i++) { +for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_mode_set *mode_set; mode_set = &fb_helper->crtc_info[i].mode_set;
@@ -1561,11 +1565,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,memset (&sizes,0 ,sizeof (struct drm_fb_helper_surface_size )); sizes.surface_depth =24 ; sizes.surface_bpp =32 ; - sizes.fb_width = (unsigned )-1 ; - sizes.fb_height = (unsigned )-1 ; + sizes.fb_width = (u32)-1 ; + sizes.fb_height = (u32)-1 ; -/* if driver picks 8 or 16 by default use that -for both depth/bpp */ +/* if driver picks 8 or 16 by default use that for both depth/bpp */ if (preferred_bpp != sizes.surface_bpp) sizes.surface_depth = sizes.surface_bpp = preferred_bpp;
@@ -1630,6 +1633,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,for (j =0 ; j < mode_set->num_connectors; j++) {struct drm_connector *connector = mode_set->connectors[j]; +if (connector->has_tile) { lasth = (connector->tile_h_loc == (connector->num_h_tile -1 )); lastv = (connector->tile_v_loc == (connector->num_v_tile -1 ));
@@ -1645,8 +1649,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, }if (crtc_count ==0 || sizes.fb_width ==-1 || sizes.fb_height ==-1 ) { -/* hmm everyone went away - assume VGA cable just fell out -and will come back later. */ +/* +* hmm everyone went away - assume VGA cable just fell out +* and will come back later. +*/ DRM_INFO ("Cannot find any crtc or sizes - going 1024x768\n" ); sizes.fb_width = sizes.surface_width =1024 ; sizes.fb_height = sizes.surface_height =768 ;
@@ -1703,7 +1709,6 @@ void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, info->fix.accel =FB_ACCEL_NONE ; info->fix.line_length = pitch; -return ; }EXPORT_SYMBOL (drm_fb_helper_fill_fix);
@@ -1725,6 +1730,7 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helpe uint32_t fb_width, uint32_t fb_height) {struct drm_framebuffer *fb = fb_helper->fb; + info->pseudo_palette = fb_helper->pseudo_palette; info->var.xres_virtual = fb->width; info->var.yres_virtual = fb->height;
@@ -2057,13 +2063,15 @@ static bool drm_target_preferred(struct drm_fb_helper *fb_helper,continue ; }else { -if (fb_helper_conn->connector->tile_h_loc != tile_pass -1 && +if (fb_helper_conn->connector->tile_h_loc != tile_pass -1 && fb_helper_conn->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 */ +/* +* find the tile offsets for this pass - need to find +* all tiles left and above +*/ drm_get_tile_offsets (fb_helper, modes, offsets, i, fb_helper_conn->connector->tile_h_loc, fb_helper_conn->connector->tile_v_loc); }
@@ -2147,8 +2155,10 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,if (!encoder) goto out; -/* select a crtc for this connector and then attempt to configure -remaining connectors */ +/* +* select a crtc for this connector and then attempt to configure +* remaining connectors +*/ for (c =0 ; c < fb_helper->crtc_count; c++) { crtc = &fb_helper->crtc_info[c];
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 2/10 drm/fb-helper: Reshuffle code for subsequent patches
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
An unlocked version of the drm_fb_helper_add_one_connector() function will be added in a subsequent patch. Reshuffle the code separately to make the diff more readable later on.
--- drivers/gpu/drm/drm_fb_helper.c | 59 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 30 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +29 -30
@@ -109,6 +109,35 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);for (({lockdep_assert_held (&(fbh)->dev->mode_config.mutex); }), \ i__ =0 ; i__ < (fbh)->connector_count; i__++) +int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector) +{ + struct drm_fb_helper_connector **temp; +struct drm_fb_helper_connector *fb_helper_connector; + +if (!drm_fbdev_emulation) +return 0 ; + +WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex)); +if (fb_helper->connector_count +1 > fb_helper->connector_info_alloc_count) { + temp =krealloc (fb_helper->connector_info,sizeof (struct drm_fb_helper_connector *) * (fb_helper->connector_count +1 ),GFP_KERNEL ); +if (!temp) +return -ENOMEM ; + + fb_helper->connector_info_alloc_count = fb_helper->connector_count +1 ; + fb_helper->connector_info = temp; + } + + fb_helper_connector =kzalloc (sizeof (struct drm_fb_helper_connector ),GFP_KERNEL ); +if (!fb_helper_connector) +return -ENOMEM ; + +drm_connector_get (connector); + fb_helper_connector->connector = connector; + fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; +return 0 ; +} +EXPORT_SYMBOL (drm_fb_helper_add_one_connector); +/** * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev * emulation helper
@@ -162,36 +191,6 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) }EXPORT_SYMBOL (drm_fb_helper_single_add_all_connectors); -int drm_fb_helper_add_one_connector (struct drm_fb_helper *fb_helper,struct drm_connector *connector) -{ -struct drm_fb_helper_connector **temp; -struct drm_fb_helper_connector *fb_helper_connector; - -if (!drm_fbdev_emulation) -return 0 ; - -WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex)); -if (fb_helper->connector_count +1 > fb_helper->connector_info_alloc_count) { - temp =krealloc (fb_helper->connector_info,sizeof (struct drm_fb_helper_connector *) * (fb_helper->connector_count +1 ),GFP_KERNEL ); -if (!temp) -return -ENOMEM ; - - fb_helper->connector_info_alloc_count = fb_helper->connector_count +1 ; - fb_helper->connector_info = temp; - } - - - fb_helper_connector =kzalloc (sizeof (struct drm_fb_helper_connector ),GFP_KERNEL ); -if (!fb_helper_connector) -return -ENOMEM ; - -drm_connector_get (connector); - fb_helper_connector->connector = connector; - fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; -return 0 ; -} -EXPORT_SYMBOL (drm_fb_helper_add_one_connector); -int drm_fb_helper_remove_one_connector (struct drm_fb_helper *fb_helper,struct drm_connector *connector) {
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 3/10 drm/fb-helper: Improve code readability
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Add a couple of temporary variables and use shorter names for existing variables in drm_fb_helper_add_one_connector() for better readability.
--- drivers/gpu/drm/drm_fb_helper.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +16 -9
@@ -109,31 +109,38 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);for (({lockdep_assert_held (&(fbh)->dev->mode_config.mutex); }), \ i__ =0 ; i__ < (fbh)->connector_count; i__++) -int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector) +int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, + struct drm_connector *connector) { struct drm_fb_helper_connector **temp; -struct drm_fb_helper_connector *fb_helper_connector; +struct drm_fb_helper_connector *conn; +unsigned int count;if (!drm_fbdev_emulation)return 0 ;WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex)); -if (fb_helper->connector_count +1 > fb_helper->connector_info_alloc_count) { - temp =krealloc (fb_helper->connector_info,sizeof (struct drm_fb_helper_connector *) * (fb_helper->connector_count +1 ),GFP_KERNEL ); + + count = fb_helper->connector_count +1 ; + +if (count > fb_helper->connector_info_alloc_count) { +size_t size = count *sizeof (conn); + + temp =krealloc (fb_helper->connector_info, size,GFP_KERNEL );if (!temp)return -ENOMEM ; - fb_helper->connector_info_alloc_count = fb_helper->connector_count +1 ; + fb_helper->connector_info_alloc_count = count; fb_helper->connector_info = temp; } - fb_helper_connector =kzalloc (sizeof (struct drm_fb_helper_connector ),GFP_KERNEL ); -if (!fb_helper_connector) + conn =kzalloc (sizeof (*conn),GFP_KERNEL ); +if (!conn)return -ENOMEM ;drm_connector_get (connector); - fb_helper_connector->connector = connector; - fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; + conn->connector = connector; + fb_helper->connector_info[fb_helper->connector_count++] = conn;return 0 ; }EXPORT_SYMBOL (drm_fb_helper_add_one_connector);
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 4/10 drm/fb-helper: Push down modeset lock into FB helpers
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Move the modeset locking from drivers into FB helpers.
--- drivers/gpu/drm/drm_fb_helper.c | 39 ++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_dp_mst.c | 3 --- drivers/gpu/drm/radeon/radeon_dp_mst.c | 7 ------ 3 files changed, 33 insertions(+), 16 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +33 -6
@@ -109,8 +109,8 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);for (({lockdep_assert_held (&(fbh)->dev->mode_config.mutex); }), \ i__ =0 ; i__ < (fbh)->connector_count; i__++) -int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, - struct drm_connector *connector) +static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, +struct drm_connector *connector) {struct drm_fb_helper_connector **temp;struct drm_fb_helper_connector *conn;
@@ -143,6 +143,20 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, fb_helper->connector_info[fb_helper->connector_count++] = conn;return 0 ; } + +int drm_fb_helper_add_one_connector (struct drm_fb_helper *fb_helper, +struct drm_connector *connector) +{ +int err; + +mutex_lock (&fb_helper->dev->mode_config.mutex); + + err =__drm_fb_helper_add_one_connector (fb_helper, connector); + +mutex_unlock (&fb_helper->dev->mode_config.mutex); + +return err; +}EXPORT_SYMBOL (drm_fb_helper_add_one_connector);/**
@@ -172,8 +186,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)mutex_lock (&dev->mode_config.mutex);drm_connector_list_iter_begin (dev, &conn_iter);drm_for_each_connector_iter (connector, &conn_iter) { - ret =drm_fb_helper_add_one_connector (fb_helper, connector); - + ret =__drm_fb_helper_add_one_connector (fb_helper, connector);if (ret) goto fail; }
@@ -198,8 +211,8 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) }EXPORT_SYMBOL (drm_fb_helper_single_add_all_connectors); -int drm_fb_helper_remove_one_connector (struct drm_fb_helper *fb_helper, -struct drm_connector *connector) +static int __drm_fb_helper_remove_one_connector (struct drm_fb_helper *fb_helper, +struct drm_connector *connector) {struct drm_fb_helper_connector *fb_helper_connector;int i, j;
@@ -227,6 +240,20 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,return 0 ; } + +int drm_fb_helper_remove_one_connector (struct drm_fb_helper *fb_helper, +struct drm_connector *connector) +{ +int err; + +mutex_lock (&fb_helper->dev->mode_config.mutex); + + err =__drm_fb_helper_remove_one_connector (fb_helper, connector); + +mutex_unlock (&fb_helper->dev->mode_config.mutex); + +return err; +}EXPORT_SYMBOL (drm_fb_helper_remove_one_connector);static void drm_fb_helper_save_lut_atomic (struct drm_crtc *crtc,struct drm_fb_helper *helper)
drivers/gpu/drm/i915/intel_dp_mst.c +0 -3
@@ -484,15 +484,12 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, struct drm_connector *connector) {struct intel_connector *intel_connector =to_intel_connector (connector); -struct drm_device *dev = connector->dev;drm_connector_unregister (connector);/* need to nuke the connector */ -drm_modeset_lock_all (dev);intel_connector_remove_from_fbdev (intel_connector); intel_connector->mst_port =NULL ; -drm_modeset_unlock_all (dev);drm_connector_unreference (&intel_connector->base);DRM_DEBUG_KMS ("\n" );
drivers/gpu/drm/radeon/radeon_dp_mst.c +0 -7
@@ -300,9 +300,7 @@ static void radeon_dp_register_mst_connector(struct drm_connector *connector)struct drm_device *dev = connector->dev;struct radeon_device *rdev = dev->dev_private; -drm_modeset_lock_all (dev);radeon_fb_add_connector (rdev, connector); -drm_modeset_unlock_all (dev);drm_connector_register (connector); }
@@ -315,13 +313,8 @@ static void radeon_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,struct radeon_device *rdev = dev->dev_private;drm_connector_unregister (connector); -/* need to nuke the connector */ -drm_modeset_lock_all (dev); -/* dpms off */ radeon_fb_remove_connector (rdev, connector); -drm_connector_cleanup (connector); -drm_modeset_unlock_all (dev);kfree (connector);DRM_DEBUG_KMS ("\n" );
Signature · 6 lines
2.12.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 5/10 drm/fb-helper: Add top-level lock
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Introduce a new top-level lock for the FB helper code. This will allow better locking granularity and avoid the need to abuse modeset locking for this purpose instead.
--- drivers/gpu/drm/drm_fb_helper.c | 27 ++++++++++++++++++++++++++- include/drm/drm_fb_helper.h | 7 +++++++ 2 files changed, 33 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +26 -1
@@ -119,6 +119,7 @@ static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,if (!drm_fbdev_emulation)return 0 ; +WARN_ON (!mutex_is_locked (&fb_helper->lock));WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex)); count = fb_helper->connector_count +1 ;
@@ -141,6 +142,7 @@ static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,drm_connector_get (connector); conn->connector = connector; fb_helper->connector_info[fb_helper->connector_count++] = conn; +return 0 ; }
@@ -149,11 +151,13 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, {int err; +mutex_lock (&fb_helper->lock);mutex_lock (&fb_helper->dev->mode_config.mutex); err =__drm_fb_helper_add_one_connector (fb_helper, connector);mutex_unlock (&fb_helper->dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);return err; }
@@ -183,6 +187,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)if (!drm_fbdev_emulation)return 0 ; +mutex_lock (&fb_helper->lock);mutex_lock (&dev->mode_config.mutex);drm_connector_list_iter_begin (dev, &conn_iter);drm_for_each_connector_iter (connector, &conn_iter) {
@@ -206,6 +211,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) out:drm_connector_list_iter_end (&conn_iter);mutex_unlock (&dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);return ret; }
@@ -220,6 +226,7 @@ static int __drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,if (!drm_fbdev_emulation)return 0 ; +WARN_ON (!mutex_is_locked (&fb_helper->lock));WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex));for (i =0 ; i < fb_helper->connector_count; i++) {
@@ -246,11 +253,13 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, {int err; +mutex_lock (&fb_helper->lock);mutex_lock (&fb_helper->dev->mode_config.mutex); err =__drm_fb_helper_remove_one_connector (fb_helper, connector);mutex_unlock (&fb_helper->dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);return err; }
@@ -502,16 +511,21 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)if (!drm_fbdev_emulation)return -ENODEV ; +mutex_lock (&fb_helper->lock);drm_modeset_lock_all (dev); + ret =restore_fbdev_mode (fb_helper); do_delayed = fb_helper->delayed_hotplug;if (do_delayed) fb_helper->delayed_hotplug = false; +drm_modeset_unlock_all (dev); +mutex_unlock (&fb_helper->lock);if (do_delayed)drm_fb_helper_hotplug_event (fb_helper); +return ret; }EXPORT_SYMBOL (drm_fb_helper_restore_fbdev_mode_unlocked);
@@ -747,6 +761,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper,INIT_WORK (&helper->resume_work, drm_fb_helper_resume_worker);INIT_WORK (&helper->dirty_work, drm_fb_helper_dirty_work); helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0 ; +mutex_init (&helper->lock); helper->funcs = funcs; helper->dev = dev; }
@@ -912,6 +927,7 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) }mutex_unlock (&kernel_fb_helper_lock); +mutex_destroy (&fb_helper->lock);drm_fb_helper_crtc_free (fb_helper); }
@@ -2421,25 +2437,34 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);int drm_fb_helper_hotplug_event (struct drm_fb_helper *fb_helper) {struct drm_device *dev = fb_helper->dev; +int err =0 ;if (!drm_fbdev_emulation)return 0 ; +mutex_lock (&fb_helper->lock);mutex_lock (&dev->mode_config.mutex); +if (!fb_helper->fb || !drm_fb_helper_is_bound (fb_helper)) { fb_helper->delayed_hotplug = true;mutex_unlock (&dev->mode_config.mutex); -return 0 ; + goto unlock; } +DRM_DEBUG_KMS ("\n" );drm_setup_crtcs (fb_helper, fb_helper->fb->width, fb_helper->fb->height);mutex_unlock (&dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);drm_fb_helper_set_par (fb_helper->fbdev);return 0 ; + +unlock: +mutex_unlock (&fb_helper->lock); +return err; }EXPORT_SYMBOL (drm_fb_helper_hotplug_event);
include/drm/drm_fb_helper.h +7 -0
@@ -201,6 +201,13 @@ struct drm_fb_helper {struct work_struct resume_work;/** +* @lock: +* +* Top-level FB helper lock. +*/ +struct mutex lock; + +/** * @kernel_fb_list: * * Entry on the global kernel_fb_helper_list, used for kgdb entry/exit.
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 6/10 drm/fb-helper: Support deferred setup
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
FB helper code falls back to a 1024x768 mode if no outputs are connected or don't report back any modes upon initialization. This can be annoying because outputs that are added to FB helper later on can't be used with FB helper if they don't support a matching mode.
The fallback is in place because VGA connectors can happen to report an unknown connection status even when they are in fact connected.
Some drivers have custom solutions in place to defer FB helper setup until at least one output is connected. But the logic behind these solutions is always the same and there is nothing driver-specific about it, so a better alterative is to fix the FB helper core and add support for all drivers automatically.
This patch adds support for deferred FB helper setup. It checks all the connectors for their connection status, and if all of them report to be disconnected marks the FB helper as needing deferred setup. Whet setup is deferred, the FB helper core will automatically retry setup after a hotplug event, and it will keep trying until it succeeds.
--- drivers/gpu/drm/drm_fb_helper.c | 60 +++++++++++++++++++++++++++++++++++++---- include/drm/drm_fb_helper.h | 21 +++++++++++++++ 2 files changed, 76 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +55 -5
@@ -511,6 +511,9 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)if (!drm_fbdev_emulation)return -ENODEV ; +if (fb_helper->deferred_setup) +return 0 ; +mutex_lock (&fb_helper->lock);drm_modeset_lock_all (dev);
@@ -1597,6 +1600,23 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, }EXPORT_SYMBOL (drm_fb_helper_pan_display); +static bool drm_fb_helper_maybe_connected (struct drm_fb_helper *helper) +{ +bool connected = false; +unsigned int i; + +for (i =0 ; i < helper->connector_count; i++) { +struct drm_fb_helper_connector *fb = helper->connector_info[i]; + +if (fb->connector->status != connector_status_disconnected) { + connected = true; +break ; + } + } + +return connected; +} +/* * Allocates the backing storage and sets up the fbdev info structure through * the ->fb_probe callback and then registers the fbdev and sets up the panic
@@ -2254,8 +2274,6 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,int i;DRM_DEBUG_KMS ("\n" ); -if (drm_fb_helper_probe_connector_modes (fb_helper, width, height) ==0 ) -DRM_DEBUG_KMS ("No connectors reported connected with modes\n" );/* prevent concurrent modification of connector_count by hotplug */ lockdep_assert_held (&fb_helper->dev->mode_config.mutex);
@@ -2378,6 +2396,7 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,int drm_fb_helper_initial_config (struct drm_fb_helper *fb_helper,int bpp_sel) {struct drm_device *dev = fb_helper->dev; +unsigned int width, height;struct fb_info *info;int ret;
@@ -2385,14 +2404,34 @@ int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel)return 0 ;mutex_lock (&dev->mode_config.mutex); -drm_setup_crtcs (fb_helper, - dev->mode_config.max_width, - dev->mode_config.max_height); + + width = dev->mode_config.max_width; + height = dev->mode_config.max_height; + +if (drm_fb_helper_probe_connector_modes (fb_helper, width, height) ==0 ) +DRM_DEBUG_KMS ("No connectors reported connected with modes\n" ); + +/* +* If everything's disconnected, there's no use in attempting to set +* up fbdev. +*/ +if (!drm_fb_helper_maybe_connected (fb_helper)) { +DRM_INFO ("No outputs connected, deferring setup\n" ); + fb_helper->preferred_bpp = bpp_sel; + fb_helper->deferred_setup = true; +mutex_unlock (&dev->mode_config.mutex); +return 0 ; + } + +drm_setup_crtcs (fb_helper, width, height); + ret =drm_fb_helper_single_fb_probe (fb_helper, bpp_sel);mutex_unlock (&dev->mode_config.mutex);if (ret)return ret; + fb_helper->deferred_setup = false; + info = fb_helper->fbdev; info->var.pixclock =0 ; ret =register_framebuffer (info);
@@ -2437,11 +2476,16 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);int drm_fb_helper_hotplug_event (struct drm_fb_helper *fb_helper) {struct drm_device *dev = fb_helper->dev; +unsigned int width, height;int err =0 ;if (!drm_fbdev_emulation)return 0 ; +if (fb_helper->deferred_setup) +return drm_fb_helper_initial_config (fb_helper, + fb_helper->preferred_bpp); +mutex_lock (&fb_helper->lock);mutex_lock (&dev->mode_config.mutex);
@@ -2453,6 +2497,12 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)DRM_DEBUG_KMS ("\n" ); + width = dev->mode_config.max_width; + height = dev->mode_config.max_height; + +if (drm_fb_helper_probe_connector_modes (fb_helper, width, height) ==0 ) +DRM_DEBUG_KMS ("No connectors reported connected with modes\n" ); +drm_setup_crtcs (fb_helper, fb_helper->fb->width, fb_helper->fb->height);mutex_unlock (&dev->mode_config.mutex);
include/drm/drm_fb_helper.h +21 -0
@@ -222,6 +222,27 @@ struct drm_fb_helper {* needs to be reprobe when fbdev is in control again. */ bool delayed_hotplug; + +/** +* @deferred_setup: +* +* If no outputs are connected (disconnected or unknown) the FB helper +* code will defer setup until at least one of the outputs shows up. +* This field keeps track of the status so that setup can be retried +* at every hotplug event until it succeeds eventually. +*/ +bool deferred_setup; + +/** +* @preferred_bpp: +* +* Temporary storage for the driver's preferred BPP setting passed to +* FB helper initialization. This needs to be tracked so that deferred +* FB helper setup can pass this on. +* +* See also: @deferred_setup +*/ +int preferred_bpp; };/**
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 7/10 drm/exynos: Remove custom FB helper deferred setup
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The FB helper core now supports deferred setup, so the driver's custom implementation can be removed.
--- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++++-- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_drv.c +4 -2
@@ -399,8 +399,9 @@ static int exynos_drm_bind(struct device *dev)/* init kms poll for handling hpd */ drm_kms_helper_poll_init (drm); -/* force connectors detection */ -drm_helper_hpd_irq_event (drm); + ret =exynos_drm_fbdev_init (dev); +if (ret) + goto err_cleanup_poll;/* register the DRM device */ ret =drm_dev_register (drm,0 );
@@ -411,6 +412,7 @@ static int exynos_drm_bind(struct device *dev) err_cleanup_fbdev:exynos_drm_fbdev_fini (drm); +err_cleanup_poll:drm_kms_helper_poll_fini (drm);exynos_drm_device_subdrv_remove (drm); err_cleanup_vblank:
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0 -2
@@ -306,6 +306,4 @@ void exynos_drm_output_poll_changed(struct drm_device *dev)if (fb_helper)drm_fb_helper_hotplug_event (fb_helper); -else -exynos_drm_fbdev_init (dev); }
Signature · 6 lines
2.12.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 8/10 drm/hisilicon: Remove custom FB helper deferred setup
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The FB helper core now supports deferred setup, so the driver's custom implementation can be removed.
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +11 -10
@@ -55,14 +55,7 @@ static void kirin_fbdev_output_poll_changed(struct drm_device *dev) {struct kirin_drm_private *priv = dev->dev_private; -if (priv->fbdev) { -drm_fbdev_cma_hotplug_event (priv->fbdev); - }else { - priv->fbdev =drm_fbdev_cma_init (dev,32 , - dev->mode_config.num_connector); -if (IS_ERR (priv->fbdev)) - priv->fbdev =NULL ; - } +drm_fbdev_cma_hotplug_event (priv->fbdev); }#endif
@@ -129,11 +122,19 @@ static int kirin_drm_kms_init(struct drm_device *dev)/* init kms poll for handling hpd */ drm_kms_helper_poll_init (dev); -/* force detection after connectors init */ - (void )drm_helper_hpd_irq_event (dev); + priv->fbdev =drm_fbdev_cma_init (dev,32 , + dev->mode_config.num_connector); +if (IS_ERR (priv->fbdev)) { +DRM_ERROR ("failed to initialize fbdev.\n" ); + ret =PTR_ERR (priv->fbdev); + goto err_cleanup_poll; + }return 0 ; +err_cleanup_poll: +drm_kms_helper_poll_fini (dev); +drm_vblank_cleanup (dev); err_unbind_all:component_unbind_all (dev->dev, dev); err_dc_cleanup:
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 9/10 drm/atmel-hlcdc: Remove unnecessary NULL check
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
drm_fbdev_cma_hotplug_event() already checks for NULL pointers before dereferencing, so callers don't need to do that.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +1 -2
@@ -450,8 +450,7 @@ static void atmel_hlcdc_fb_output_poll_changed(struct drm_device *dev) {struct atmel_hlcdc_dc *dc = dev->dev_private; -if (dc->fbdev) -drm_fbdev_cma_hotplug_event (dc->fbdev); +drm_fbdev_cma_hotplug_event (dc->fbdev); }struct atmel_hlcdc_dc_commit {
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 10/10 drm/rockchip: Remove unnecessary NULL check
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The expression &private->fbdev_helper can never be NULL, so the check is completely unnecessary.
--- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +1 -3
@@ -168,10 +168,8 @@ rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,static void rockchip_drm_output_poll_changed (struct drm_device *dev) {struct rockchip_drm_private *private = dev->dev_private; -struct drm_fb_helper *fb_helper = &private->fbdev_helper; -if (fb_helper) -drm_fb_helper_hotplug_event (fb_helper); +drm_fb_helper_hotplug_event (&private->fbdev_helper); } static void
Signature · 6 lines
2.12.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 01/10] drm/fb-helper: Cleanup checkpatch warnings
In reply to Thierry RedingQuoted 7 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Fix up a couple of checkpatch warnings, such as whitespace or coding style issues.
Tested-by John Stultz <[email protected]>Signed-off-by Thierry Reding <[email protected]>
Quoted 195 lines
--- drivers/gpu/drm/drm_fb_helper.c | 54 ++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 22 deletions(-)drivers/gpu/drm/drm_fb_helper.c +32
-22@@ -213,9 +213,9 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, fb_helper_connector = fb_helper->connector_info[i];drm_connector_put (fb_helper_connector->connector); -for (j = i +1 ; j < fb_helper->connector_count; j++) { +for (j = i +1 ; j < fb_helper->connector_count; j++) fb_helper->connector_info[j -1 ] = fb_helper->connector_info[j]; - } + fb_helper->connector_count--;kfree (fb_helper_connector);@@ -316,6 +316,7 @@ int drm_fb_helper_debug_leave(struct fb_info *info)for (i =0 ; i < helper->crtc_count; i++) {struct drm_mode_set *mode_set = &helper->crtc_info[i].mode_set; + crtc = mode_set->crtc; funcs = crtc->helper_private; fb =drm_mode_config_fb (crtc);@@ -346,7 +347,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper)struct drm_plane *plane;struct drm_atomic_state *state;int i, ret; -unsigned plane_mask; +unsigned int plane_mask; state =drm_atomic_state_alloc (dev);if (!state)@@ -378,7 +379,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper) goto fail; } -for (i =0 ; i < fb_helper->crtc_count; i++) { +for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_mode_set *mode_set = &fb_helper->crtc_info[i].mode_set; ret =__drm_atomic_helper_set_config (mode_set, state);@@ -488,8 +489,10 @@ static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper)struct drm_crtc *crtc;int bound =0 , crtcs_bound =0 ; -/* Sometimes user space wants everything disabled, so don't steal the -* display if there's a master. */ +/* +* Sometimes user space wants everything disabled, so don't steal the +* display if there's a master. +*/ if (READ_ONCE (dev->master))return false;@@ -537,6 +540,7 @@ static bool drm_fb_helper_force_kernel_mode(void)static void drm_fb_helper_restore_work_fn (struct work_struct *ignored) {bool ret; + ret =drm_fb_helper_force_kernel_mode ();if (ret == true)DRM_ERROR ("Failed to restore crtc configuration\n" );@@ -870,9 +874,8 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)mutex_lock (&kernel_fb_helper_lock);if (!list_empty (&fb_helper->kernel_fb_list)) {list_del (&fb_helper->kernel_fb_list); -if (list_empty (&kernel_fb_helper_list)) { +if (list_empty (&kernel_fb_helper_list))unregister_sysrq_key ('v' , &sysrq_drm_fb_helper_restore_op); - } }mutex_unlock (&kernel_fb_helper_lock);@@ -1165,6 +1168,7 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, (blue << info->var.blue.offset);if (info->var.transp.length >0 ) {u32 mask = (1 << info->var.transp.length) -1 ; + mask <<= info->var.transp.offset; value |= mask; }@@ -1447,7 +1451,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var,struct drm_atomic_state *state;struct drm_plane *plane;int i, ret; -unsigned plane_mask; +unsigned int plane_mask; state =drm_atomic_state_alloc (dev);if (!state)@@ -1456,7 +1460,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var, state->acquire_ctx = dev->mode_config.acquire_ctx; retry: plane_mask =0 ; -for (i =0 ; i < fb_helper->crtc_count; i++) { +for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_mode_set *mode_set; mode_set = &fb_helper->crtc_info[i].mode_set;@@ -1561,11 +1565,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,memset (&sizes,0 ,sizeof (struct drm_fb_helper_surface_size )); sizes.surface_depth =24 ; sizes.surface_bpp =32 ; - sizes.fb_width = (unsigned )-1 ; - sizes.fb_height = (unsigned )-1 ; + sizes.fb_width = (u32)-1 ; + sizes.fb_height = (u32)-1 ; -/* if driver picks 8 or 16 by default use that -for both depth/bpp */ +/* if driver picks 8 or 16 by default use that for both depth/bpp */ if (preferred_bpp != sizes.surface_bpp) sizes.surface_depth = sizes.surface_bpp = preferred_bpp;@@ -1630,6 +1633,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,for (j =0 ; j < mode_set->num_connectors; j++) {struct drm_connector *connector = mode_set->connectors[j]; +if (connector->has_tile) { lasth = (connector->tile_h_loc == (connector->num_h_tile -1 )); lastv = (connector->tile_v_loc == (connector->num_v_tile -1 ));@@ -1645,8 +1649,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, }if (crtc_count ==0 || sizes.fb_width ==-1 || sizes.fb_height ==-1 ) { -/* hmm everyone went away - assume VGA cable just fell out -and will come back later. */ +/* +* hmm everyone went away - assume VGA cable just fell out +* and will come back later. +*/ DRM_INFO ("Cannot find any crtc or sizes - going 1024x768\n" ); sizes.fb_width = sizes.surface_width =1024 ; sizes.fb_height = sizes.surface_height =768 ;@@ -1703,7 +1709,6 @@ void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, info->fix.accel =FB_ACCEL_NONE ; info->fix.line_length = pitch; -return ; }EXPORT_SYMBOL (drm_fb_helper_fill_fix);@@ -1725,6 +1730,7 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helpe uint32_t fb_width, uint32_t fb_height) {struct drm_framebuffer *fb = fb_helper->fb; + info->pseudo_palette = fb_helper->pseudo_palette; info->var.xres_virtual = fb->width; info->var.yres_virtual = fb->height;@@ -2057,13 +2063,15 @@ static bool drm_target_preferred(struct drm_fb_helper *fb_helper,continue ; }else { -if (fb_helper_conn->connector->tile_h_loc != tile_pass -1 && +if (fb_helper_conn->connector->tile_h_loc != tile_pass -1 && fb_helper_conn->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 */ +/* +* find the tile offsets for this pass - need to find +* all tiles left and above +*/ drm_get_tile_offsets (fb_helper, modes, offsets, i, fb_helper_conn->connector->tile_h_loc, fb_helper_conn->connector->tile_v_loc); }@@ -2147,8 +2155,10 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,if (!encoder) goto out; -/* select a crtc for this connector and then attempt to configure -remaining connectors */ +/* +* select a crtc for this connector and then attempt to configure +* remaining connectors +*/ for (c =0 ; c < fb_helper->crtc_count; c++) { crtc = &fb_helper->crtc_info[c];Signature · 6 lines
2.12.0 _______________________________________________ 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 v3 02/10] drm/fb-helper: Reshuffle code for subsequent patches
In reply to Thierry RedingQuoted 8 lines · Thierry Reding
From: Thierry Reding <[email protected]>
An unlocked version of the
drm_fb_helper_add_one_connector()function will be added in a subsequent patch. Reshuffle the code separately to make the diff more readable later on.Tested-by John Stultz <[email protected]>Signed-off-by Thierry Reding <[email protected]>
Quoted 88 lines
--- drivers/gpu/drm/drm_fb_helper.c | 59 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 30 deletions(-)drivers/gpu/drm/drm_fb_helper.c +29
-30@@ -109,6 +109,35 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);for (({lockdep_assert_held (&(fbh)->dev->mode_config.mutex); }), \ i__ =0 ; i__ < (fbh)->connector_count; i__++) +int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector) +{ + struct drm_fb_helper_connector **temp; +struct drm_fb_helper_connector *fb_helper_connector; + +if (!drm_fbdev_emulation) +return 0 ; + +WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex)); +if (fb_helper->connector_count +1 > fb_helper->connector_info_alloc_count) { + temp =krealloc (fb_helper->connector_info,sizeof (struct drm_fb_helper_connector *) * (fb_helper->connector_count +1 ),GFP_KERNEL ); +if (!temp) +return -ENOMEM ; + + fb_helper->connector_info_alloc_count = fb_helper->connector_count +1 ; + fb_helper->connector_info = temp; + } + + fb_helper_connector =kzalloc (sizeof (struct drm_fb_helper_connector ),GFP_KERNEL ); +if (!fb_helper_connector) +return -ENOMEM ; + +drm_connector_get (connector); + fb_helper_connector->connector = connector; + fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; +return 0 ; +} +EXPORT_SYMBOL (drm_fb_helper_add_one_connector); +/** * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev * emulation helper @@ -162,36 +191,6 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) }EXPORT_SYMBOL (drm_fb_helper_single_add_all_connectors); -int drm_fb_helper_add_one_connector (struct drm_fb_helper *fb_helper,struct drm_connector *connector) -{ -struct drm_fb_helper_connector **temp; -struct drm_fb_helper_connector *fb_helper_connector; - -if (!drm_fbdev_emulation) -return 0 ; - -WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex)); -if (fb_helper->connector_count +1 > fb_helper->connector_info_alloc_count) { - temp =krealloc (fb_helper->connector_info,sizeof (struct drm_fb_helper_connector *) * (fb_helper->connector_count +1 ),GFP_KERNEL ); -if (!temp) -return -ENOMEM ; - - fb_helper->connector_info_alloc_count = fb_helper->connector_count +1 ; - fb_helper->connector_info = temp; - } - - - fb_helper_connector =kzalloc (sizeof (struct drm_fb_helper_connector ),GFP_KERNEL ); -if (!fb_helper_connector) -return -ENOMEM ; - -drm_connector_get (connector); - fb_helper_connector->connector = connector; - fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; -return 0 ; -} -EXPORT_SYMBOL (drm_fb_helper_add_one_connector); -int drm_fb_helper_remove_one_connector (struct drm_fb_helper *fb_helper,struct drm_connector *connector) {Signature · 6 lines
2.12.0 _______________________________________________ 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 v3 03/10] drm/fb-helper: Improve code readability
In reply to Thierry RedingQuoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Add a couple of temporary variables and use shorter names for existing variables in
drm_fb_helper_add_one_connector()for better readability.Tested-by John Stultz <[email protected]>Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/drm_fb_helper.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)drivers/gpu/drm/drm_fb_helper.c +0
-0
drivers/gpu/drm/drm_fb_helper.c static DEFINE_MUTEX(kernel_fb_helper_lock); · line 116
Quoted 10 lines
drivers/gpu/drm/drm_fb_helper.c +3
-2@@ -109,31 +109,38 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);for (({lockdep_assert_held (&(fbh)->dev->mode_config.mutex); }), \ i__ =0 ; i__ < (fbh)->connector_count; i__++) -int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector) +int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, + struct drm_connector *connector) { struct drm_fb_helper_connector **temp; -struct drm_fb_helper_connector *fb_helper_connector; +struct drm_fb_helper_connector *conn;
I'd go with fb_conn here. Still short, but avoids confusion with drm_connector, which is what we usually call conn. Either way:
Quoted 44 lines
drivers/gpu/drm/drm_fb_helper.c +13
-7+unsigned int count;if (!drm_fbdev_emulation)return 0 ;WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex)); -if (fb_helper->connector_count +1 > fb_helper->connector_info_alloc_count) { - temp =krealloc (fb_helper->connector_info,sizeof (struct drm_fb_helper_connector *) * (fb_helper->connector_count +1 ),GFP_KERNEL ); + + count = fb_helper->connector_count +1 ; + +if (count > fb_helper->connector_info_alloc_count) { +size_t size = count *sizeof (conn); + + temp =krealloc (fb_helper->connector_info, size,GFP_KERNEL );if (!temp)return -ENOMEM ; - fb_helper->connector_info_alloc_count = fb_helper->connector_count +1 ; + fb_helper->connector_info_alloc_count = count; fb_helper->connector_info = temp; } - fb_helper_connector =kzalloc (sizeof (struct drm_fb_helper_connector ),GFP_KERNEL ); -if (!fb_helper_connector) + conn =kzalloc (sizeof (*conn),GFP_KERNEL ); +if (!conn)return -ENOMEM ;drm_connector_get (connector); - fb_helper_connector->connector = connector; - fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; + conn->connector = connector; + fb_helper->connector_info[fb_helper->connector_count++] = conn;return 0 ; }EXPORT_SYMBOL (drm_fb_helper_add_one_connector);Signature · 6 lines
2.12.0 _______________________________________________ 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
Re: [PATCH v3 04/10] drm/fb-helper: Push down modeset lock into FB helpers
In reply to Thierry RedingQuoted 6 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Move the modeset locking from drivers into FB helpers.
Tested-by John Stultz <[email protected]>Signed-off-by Thierry Reding <[email protected]>
Quoted 139 lines
--- drivers/gpu/drm/drm_fb_helper.c | 39 ++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_dp_mst.c | 3 --- drivers/gpu/drm/radeon/radeon_dp_mst.c | 7 ------ 3 files changed, 33 insertions(+), 16 deletions(-)drivers/gpu/drm/drm_fb_helper.c +33
-6@@ -109,8 +109,8 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);for (({lockdep_assert_held (&(fbh)->dev->mode_config.mutex); }), \ i__ =0 ; i__ < (fbh)->connector_count; i__++) -int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, - struct drm_connector *connector) +static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, +struct drm_connector *connector) {struct drm_fb_helper_connector **temp;struct drm_fb_helper_connector *conn;@@ -143,6 +143,20 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, fb_helper->connector_info[fb_helper->connector_count++] = conn;return 0 ; } + +int drm_fb_helper_add_one_connector (struct drm_fb_helper *fb_helper, +struct drm_connector *connector) +{ +int err; + +mutex_lock (&fb_helper->dev->mode_config.mutex); + + err =__drm_fb_helper_add_one_connector (fb_helper, connector); + +mutex_unlock (&fb_helper->dev->mode_config.mutex); + +return err; +}EXPORT_SYMBOL (drm_fb_helper_add_one_connector);/** @@ -172,8 +186,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)mutex_lock (&dev->mode_config.mutex);drm_connector_list_iter_begin (dev, &conn_iter);drm_for_each_connector_iter (connector, &conn_iter) { - ret =drm_fb_helper_add_one_connector (fb_helper, connector); - + ret =__drm_fb_helper_add_one_connector (fb_helper, connector);if (ret) goto fail; }@@ -198,8 +211,8 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) }EXPORT_SYMBOL (drm_fb_helper_single_add_all_connectors); -int drm_fb_helper_remove_one_connector (struct drm_fb_helper *fb_helper, -struct drm_connector *connector) +static int __drm_fb_helper_remove_one_connector (struct drm_fb_helper *fb_helper, +struct drm_connector *connector) {struct drm_fb_helper_connector *fb_helper_connector;int i, j;@@ -227,6 +240,20 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,return 0 ; } + +int drm_fb_helper_remove_one_connector (struct drm_fb_helper *fb_helper, +struct drm_connector *connector) +{ +int err; + +mutex_lock (&fb_helper->dev->mode_config.mutex); + + err =__drm_fb_helper_remove_one_connector (fb_helper, connector); + +mutex_unlock (&fb_helper->dev->mode_config.mutex); + +return err; +}EXPORT_SYMBOL (drm_fb_helper_remove_one_connector);static void drm_fb_helper_save_lut_atomic (struct drm_crtc *crtc,struct drm_fb_helper *helper)drivers/gpu/drm/i915/intel_dp_mst.c +0
-3@@ -484,15 +484,12 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, struct drm_connector *connector) {struct intel_connector *intel_connector =to_intel_connector (connector); -struct drm_device *dev = connector->dev;drm_connector_unregister (connector);/* need to nuke the connector */ -drm_modeset_lock_all (dev);intel_connector_remove_from_fbdev (intel_connector); intel_connector->mst_port =NULL ; -drm_modeset_unlock_all (dev);drm_connector_unreference (&intel_connector->base);DRM_DEBUG_KMS ("\n" );drivers/gpu/drm/radeon/radeon_dp_mst.c +0
-7@@ -300,9 +300,7 @@ static void radeon_dp_register_mst_connector(struct drm_connector *connector)struct drm_device *dev = connector->dev;struct radeon_device *rdev = dev->dev_private; -drm_modeset_lock_all (dev);radeon_fb_add_connector (rdev, connector); -drm_modeset_unlock_all (dev);drm_connector_register (connector); }@@ -315,13 +313,8 @@ static void radeon_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,struct radeon_device *rdev = dev->dev_private;drm_connector_unregister (connector); -/* need to nuke the connector */ -drm_modeset_lock_all (dev); -/* dpms off */ radeon_fb_remove_connector (rdev, connector); -drm_connector_cleanup (connector); -drm_modeset_unlock_all (dev);kfree (connector);DRM_DEBUG_KMS ("\n" );Signature · 6 lines
2.12.0 _______________________________________________ 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
Patchwork
CI✓ Fi.CI.BAT: success for drm/fb-helper: Deferred setup support (rev2)
In reply to Thierry Reding== Series Details ==
== Series Details ==
Series: drm/fb-helper: Deferred setup support (rev2)
URL : https://patchwork.freedesktop.org/series/8410/
State : success
== Summary ==
Series 8410v2 drm/fb-helper: Deferred setup support
https://patchwork.freedesktop.org/api/1.0/series/8410/revisions/2/mbox/
fi-bdw-5557u total:278 pass:267 dwarn:0 dfail:0 fail:0 skip:11 time: 458s fi-bsw-n3050 total:278 pass:239 dwarn:0 dfail:0 fail:0 skip:39 time: 601s fi-bxt-j4205 total:278 pass:259 dwarn:0 dfail:0 fail:0 skip:19 time: 535s fi-bxt-t5700 total:278 pass:258 dwarn:0 dfail:0 fail:0 skip:20 time: 581s fi-byt-j1900 total:278 pass:251 dwarn:0 dfail:0 fail:0 skip:27 time: 511s fi-byt-n2820 total:278 pass:247 dwarn:0 dfail:0 fail:0 skip:31 time: 503s fi-hsw-4770 total:278 pass:262 dwarn:0 dfail:0 fail:0 skip:16 time: 435s fi-hsw-4770r total:278 pass:262 dwarn:0 dfail:0 fail:0 skip:16 time: 441s fi-ilk-650 total:278 pass:228 dwarn:0 dfail:0 fail:0 skip:50 time: 439s fi-ivb-3520m total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time: 510s fi-ivb-3770 total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time: 499s fi-kbl-7500u total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time: 489s fi-skl-6260u total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time: 484s fi-skl-6700hq total:278 pass:261 dwarn:0 dfail:0 fail:0 skip:17 time: 602s fi-skl-6700k total:278 pass:256 dwarn:4 dfail:0 fail:0 skip:18 time: 486s fi-skl-6770hq total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time: 516s fi-snb-2520m total:278 pass:250 dwarn:0 dfail:0 fail:0 skip:28 time: 554s fi-snb-2600 total:278 pass:249 dwarn:0 dfail:0 fail:0 skip:29 time: 413s
5b6f03e54c55e73e102b34138242d646c7afd829 drm-tip: 2017y-03m-21d-08h-31m-10s UTC integration manifest 6b2f5da drm/rockchip: Remove unnecessary NULL check
fbd6b26 drm/atmel-hlcdc: Remove unnecessary NULL check
965e81a drm/hisilicon: Remove custom FB helper deferred setup
04d935a drm/exynos: Remove custom FB helper deferred setup
c94913a drm/fb-helper: Support deferred setup
be4ed65 drm/fb-helper: Add top-level lock
cf6ec86 drm/fb-helper: Push down modeset lock into FB helpers
c310d30 drm/fb-helper: Improve code readability
cf64817 drm/fb-helper: Reshuffle code for subsequent patches
0fd2dd3 drm/fb-helper: Cleanup checkpatch warnings
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4238/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 07/10] drm/exynos: Remove custom FB helper deferred setup
In reply to Thierry RedingQuoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The FB helper core now supports deferred setup, so the driver's custom implementation can be removed.
Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++++-- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/exynos/exynos_drm_drv.c +0
-0
drivers/gpu/drm/exynos/exynos_drm_drv.c static int exynos_drm_bind(struct device *dev) · line 404
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +3
-2@@ -399,8 +399,9 @@ static int exynos_drm_bind(struct device *dev)/* init kms poll for handling hpd */ drm_kms_helper_poll_init (drm); -/* force connectors detection */ -drm_helper_hpd_irq_event (drm); + ret =exynos_drm_fbdev_init (dev); +if (ret) + goto err_cleanup_poll;
It should be rather:
ret = exynos_drm_fbdev_init(drm);
Even with this change it does not work, I will try to track down the problem.
Regards
Andrzej
Quoted 16 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +1
-0/* register the DRM device */ ret =drm_dev_register (drm,0 );@@ -411,6 +412,7 @@ static int exynos_drm_bind(struct device *dev) err_cleanup_fbdev:exynos_drm_fbdev_fini (drm); +err_cleanup_poll:drm_kms_helper_poll_fini (drm);exynos_drm_device_subdrv_remove (drm); err_cleanup_vblank:drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0
-0
drivers/gpu/drm/exynos/exynos_drm_fbdev.c void exynos_drm_output_poll_changed(struct drm_device *dev) · line 309
Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0
-2@@ -306,6 +306,4 @@ void exynos_drm_output_poll_changed(struct drm_device *dev)if (fb_helper)drm_fb_helper_hotplug_event (fb_helper); -else -exynos_drm_fbdev_init (dev); }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 05/10] drm/fb-helper: Add top-level lock
In reply to Thierry RedingQuoted 8 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Introduce a new top-level lock for the FB helper code. This will allow better locking granularity and avoid the need to abuse modeset locking for this purpose instead.
Tested-by John Stultz <[email protected]>Signed-off-by Thierry Reding <[email protected]>
Some suggestions below, since I think this state of locking implemented here is a bit a too awkwared intermediate thing.
Quoted 10 lines
--- drivers/gpu/drm/drm_fb_helper.c | 27 ++++++++++++++++++++++++++- include/drm/drm_fb_helper.h | 7 +++++++ 2 files changed, 33 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_fb_helper.c +0
-0
drivers/gpu/drm/drm_fb_helper.c static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, · line 123
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -119,6 +119,7 @@ static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,if (!drm_fbdev_emulation)return 0 ; +WARN_ON (!mutex_is_locked (&fb_helper->lock));WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex));
mode_config.mutex isn't needed anymore here (with the recommendations at the bottom), please remove.
Quoted 11 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0count = fb_helper->connector_count +1 ;@@ -141,6 +142,7 @@ static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,drm_connector_get (connector); conn->connector = connector; fb_helper->connector_info[fb_helper->connector_count++] = conn; +return 0 ; }
drivers/gpu/drm/drm_fb_helper.c int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, · line 155
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -149,11 +151,13 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, {int err; +mutex_lock (&fb_helper->lock);mutex_lock (&fb_helper->dev->mode_config.mutex);
Same.
Quoted 9 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0err =__drm_fb_helper_add_one_connector (fb_helper, connector);mutex_unlock (&fb_helper->dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);return err; }
drivers/gpu/drm/drm_fb_helper.c int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) · line 191
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -183,6 +187,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)if (!drm_fbdev_emulation)return 0 ; +mutex_lock (&fb_helper->lock);mutex_lock (&dev->mode_config.mutex);
Same.
Quoted 11 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0drm_connector_list_iter_begin (dev, &conn_iter);drm_for_each_connector_iter (connector, &conn_iter) {@@ -206,6 +211,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) out:drm_connector_list_iter_end (&conn_iter);mutex_unlock (&dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);return ret; }
drivers/gpu/drm/drm_fb_helper.c static int __drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, · line 230
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -220,6 +226,7 @@ static int __drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,if (!drm_fbdev_emulation)return 0 ; +WARN_ON (!mutex_is_locked (&fb_helper->lock));WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex));
Same.
Quoted 95 lines
drivers/gpu/drm/drm_fb_helper.c +19
-1for (i =0 ; i < fb_helper->connector_count; i++) {@@ -246,11 +253,13 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, {int err; +mutex_lock (&fb_helper->lock);mutex_lock (&fb_helper->dev->mode_config.mutex); err =__drm_fb_helper_remove_one_connector (fb_helper, connector);mutex_unlock (&fb_helper->dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);return err; }@@ -502,16 +511,21 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)if (!drm_fbdev_emulation)return -ENODEV ; +mutex_lock (&fb_helper->lock);drm_modeset_lock_all (dev); + ret =restore_fbdev_mode (fb_helper); do_delayed = fb_helper->delayed_hotplug;if (do_delayed) fb_helper->delayed_hotplug = false; +drm_modeset_unlock_all (dev); +mutex_unlock (&fb_helper->lock);if (do_delayed)drm_fb_helper_hotplug_event (fb_helper); +return ret; }EXPORT_SYMBOL (drm_fb_helper_restore_fbdev_mode_unlocked);@@ -747,6 +761,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper,INIT_WORK (&helper->resume_work, drm_fb_helper_resume_worker);INIT_WORK (&helper->dirty_work, drm_fb_helper_dirty_work); helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0 ; +mutex_init (&helper->lock); helper->funcs = funcs; helper->dev = dev; }@@ -912,6 +927,7 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) }mutex_unlock (&kernel_fb_helper_lock); +mutex_destroy (&fb_helper->lock);drm_fb_helper_crtc_free (fb_helper); }@@ -2421,25 +2437,34 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);int drm_fb_helper_hotplug_event (struct drm_fb_helper *fb_helper) {struct drm_device *dev = fb_helper->dev; +int err =0 ;if (!drm_fbdev_emulation)return 0 ; +mutex_lock (&fb_helper->lock);mutex_lock (&dev->mode_config.mutex); +if (!fb_helper->fb || !drm_fb_helper_is_bound (fb_helper)) { fb_helper->delayed_hotplug = true;mutex_unlock (&dev->mode_config.mutex); -return 0 ; + goto unlock; } +DRM_DEBUG_KMS ("\n" );drm_setup_crtcs (fb_helper, fb_helper->fb->width, fb_helper->fb->height);mutex_unlock (&dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);drm_fb_helper_set_par (fb_helper->fbdev);return 0 ; + +unlock: +mutex_unlock (&fb_helper->lock); +return err; }EXPORT_SYMBOL (drm_fb_helper_hotplug_event);include/drm/drm_fb_helper.h +0
-0
include/drm/drm_fb_helper.h struct drm_fb_helper { · line 206
Quoted 6 lines
include/drm/drm_fb_helper.h +3
-0@@ -201,6 +201,13 @@ struct drm_fb_helper {struct work_struct resume_work;/** +* @lock: +* +* Top-level FB helper lock.
Bit more detail would be good here.
"This protects all the internal data structures and lists, like @connector_info or @crtc_info."
include/drm/drm_fb_helper.h struct drm_fb_helper { · line 213
Quoted 7 lines
include/drm/drm_fb_helper.h +4
-0+*/ +struct mutex lock; + +/** * @kernel_fb_list: * * Entry on the global kernel_fb_helper_list, used for kgdb entry/exit.
So I think you're missing to protect almost all the fbdev paths. Essentially anything looking at crtc_info or connector_info must hold the new lock, which means all the places that currently call drm_modeset_lock_all() need to grab this new lock too.
Best way to make sure you catch them all is to also update the lockdep assert in drm_fb_helper_for_each_connector().
There's still a massive mess going with locking here, especially around the probe code and drm_fb_helper_is_bound, but that's a different thing and better left for cleanup later on.
-Daniel
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 v3 06/10] drm/fb-helper: Support deferred setup
In reply to Thierry RedingQuoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
FB helper code falls back to a 1024x768 mode if no outputs are connected or don't report back any modes upon initialization. This can be annoying because outputs that are added to FB helper later on can't be used with FB helper if they don't support a matching mode.
The fallback is in place because VGA connectors can happen to report an unknown connection status even when they are in fact connected.
Some drivers have custom solutions in place to defer FB helper setup until at least one output is connected. But the logic behind these solutions is always the same and there is nothing driver-specific about it, so a better alterative is to fix the FB helper core and add support for all drivers automatically.
Quoted 8 lines
This patch adds support for deferred FB helper setup. It checks all the connectors for their connection status, and if all of them report to be disconnected marks the FB helper as needing deferred setup. Whet setup is deferred, the FB helper core will automatically retry setup after a hotplug event, and it will keep trying until it succeeds.
Tested-by John Stultz <[email protected]>Signed-off-by Thierry Reding <[email protected]>
Tiny nitpicks below, with those addressed:
Quoted 10 lines
--- drivers/gpu/drm/drm_fb_helper.c | 60 +++++++++++++++++++++++++++++++++++++---- include/drm/drm_fb_helper.h | 21 +++++++++++++++ 2 files changed, 76 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_fb_helper.c +0
-0
drivers/gpu/drm/drm_fb_helper.c int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper) · line 515
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +2
-0@@ -511,6 +511,9 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)if (!drm_fbdev_emulation)return -ENODEV ; +if (fb_helper->deferred_setup) +return 0 ;
READ_ONCE or put it under the ->lock protection. Just for clarity.
Quoted 86 lines
drivers/gpu/drm/drm_fb_helper.c +42
-5+mutex_lock (&fb_helper->lock);drm_modeset_lock_all (dev);@@ -1597,6 +1600,23 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, }EXPORT_SYMBOL (drm_fb_helper_pan_display); +static bool drm_fb_helper_maybe_connected (struct drm_fb_helper *helper) +{ +bool connected = false; +unsigned int i; + +for (i =0 ; i < helper->connector_count; i++) { +struct drm_fb_helper_connector *fb = helper->connector_info[i]; + +if (fb->connector->status != connector_status_disconnected) { + connected = true; +break ; + } + } + +return connected; +} +/* * Allocates the backing storage and sets up the fbdev info structure through * the ->fb_probe callback and then registers the fbdev and sets up the panic @@ -2254,8 +2274,6 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,int i;DRM_DEBUG_KMS ("\n" ); -if (drm_fb_helper_probe_connector_modes (fb_helper, width, height) ==0 ) -DRM_DEBUG_KMS ("No connectors reported connected with modes\n" );/* prevent concurrent modification of connector_count by hotplug */ lockdep_assert_held (&fb_helper->dev->mode_config.mutex);@@ -2378,6 +2396,7 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,int drm_fb_helper_initial_config (struct drm_fb_helper *fb_helper,int bpp_sel) {struct drm_device *dev = fb_helper->dev; +unsigned int width, height;struct fb_info *info;int ret;@@ -2385,14 +2404,34 @@ int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel)return 0 ;mutex_lock (&dev->mode_config.mutex); -drm_setup_crtcs (fb_helper, - dev->mode_config.max_width, - dev->mode_config.max_height); + + width = dev->mode_config.max_width; + height = dev->mode_config.max_height; + +if (drm_fb_helper_probe_connector_modes (fb_helper, width, height) ==0 ) +DRM_DEBUG_KMS ("No connectors reported connected with modes\n" ); + +/* +* If everything's disconnected, there's no use in attempting to set +* up fbdev. +*/ +if (!drm_fb_helper_maybe_connected (fb_helper)) { +DRM_INFO ("No outputs connected, deferring setup\n" ); + fb_helper->preferred_bpp = bpp_sel; + fb_helper->deferred_setup = true; +mutex_unlock (&dev->mode_config.mutex); +return 0 ; + } + +drm_setup_crtcs (fb_helper, width, height); + ret =drm_fb_helper_single_fb_probe (fb_helper, bpp_sel);mutex_unlock (&dev->mode_config.mutex);if (ret)return ret; + fb_helper->deferred_setup = false; + info = fb_helper->fbdev; info->var.pixclock =0 ; ret =register_framebuffer (info);@@ -2437,11 +2476,16 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);int drm_fb_helper_hotplug_event (struct drm_fb_helper *fb_helper) {
drivers/gpu/drm/drm_fb_helper.c EXPORT_SYMBOL(drm_fb_helper_initial_config); · line 2487
Quoted 10 lines
drivers/gpu/drm/drm_fb_helper.c +4
-0struct drm_device *dev = fb_helper->dev; +unsigned int width, height;int err =0 ;if (!drm_fbdev_emulation)return 0 ; +if (fb_helper->deferred_setup) +return drm_fb_helper_initial_config (fb_helper, + fb_helper->preferred_bpp);
I think this must be moved under the protection of ->lock, you might race otherwise (e.g. hpd vs. userspace forcing a re-probe, both noticing the change).
Quoted 23 lines
drivers/gpu/drm/drm_fb_helper.c +7
-0+mutex_lock (&fb_helper->lock);mutex_lock (&dev->mode_config.mutex);@@ -2453,6 +2497,12 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)DRM_DEBUG_KMS ("\n" ); + width = dev->mode_config.max_width; + height = dev->mode_config.max_height; + +if (drm_fb_helper_probe_connector_modes (fb_helper, width, height) ==0 ) +DRM_DEBUG_KMS ("No connectors reported connected with modes\n" ); +drm_setup_crtcs (fb_helper, fb_helper->fb->width, fb_helper->fb->height);mutex_unlock (&dev->mode_config.mutex);include/drm/drm_fb_helper.h +0
-0@@ -222,6 +222,27 @@ struct drm_fb_helper {* needs to be reprobe when fbdev is in control again.
include/drm/drm_fb_helper.h struct drm_fb_helper { · line 232
Quoted 10 lines
include/drm/drm_fb_helper.h +8
-0*/ bool delayed_hotplug; + +/** +* @deferred_setup: +* +* If no outputs are connected (disconnected or unknown) the FB helper +* code will defer setup until at least one of the outputs shows up. +* This field keeps track of the status so that setup can be retried +* at every hotplug event until it succeeds eventually.
Please add:
"Protected by @lock."
Quoted 23 lines
include/drm/drm_fb_helper.h +13
-0+*/ +bool deferred_setup; + +/** +* @preferred_bpp: +* +* Temporary storage for the driver's preferred BPP setting passed to +* FB helper initialization. This needs to be tracked so that deferred +* FB helper setup can pass this on. +* +* See also: @deferred_setup +*/ +int preferred_bpp; };/** Signature · 6 lines
2.12.0 _______________________________________________ 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
Re: [PATCH v3 05/10] drm/fb-helper: Add top-level lock
In reply to Daniel VetterQuoted 7 lines · Daniel Vetter
Quoted 6 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Introduce a new top-level lock for the FB helper code. This will allow better locking granularity and avoid the need to abuse modeset locking for this purpose instead.
Quoted 5 lines
Quoted 2 lines
Tested-by John Stultz <[email protected]>Signed-off-by Thierry Reding <[email protected]>Some suggestions below, since I think this state of locking implemented here is a bit a too awkwared intermediate thing.
To clarify: After having reviewed the next patch I think this here is fine. So gets an Reviewed-by: Daniel Vetter <[email protected]> as-is. I just think we want a notch more here.
But if you're burried too much we can do that as a follow-up too, but in that case please add a FIXME to e.g. the @lock kernel-doc:
"FIXME: fbdev emulation locking is a mess, long term we want to protect all helper internal state with this lock, and reduce core KMS locking as much as possible."
Your choice :-)
Cheers, Daniel
Quoted 205 lines
Quoted 11 lines
--- drivers/gpu/drm/drm_fb_helper.c | 27 ++++++++++++++++++++++++++- include/drm/drm_fb_helper.h | 7 +++++++ 2 files changed, 33 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_fb_helper.c +0
-0drivers/gpu/drm/drm_fb_helper.c static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, · line 123
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -119,6 +119,7 @@ static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,if (!drm_fbdev_emulation)return 0 ; +WARN_ON (!mutex_is_locked (&fb_helper->lock));WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex));mode_config.mutex isn't needed anymore here (with the recommendations at the bottom), please remove.
Quoted 11 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0count = fb_helper->connector_count +1 ;@@ -141,6 +142,7 @@ static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,drm_connector_get (connector); conn->connector = connector; fb_helper->connector_info[fb_helper->connector_count++] = conn; +return 0 ; }drivers/gpu/drm/drm_fb_helper.c int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, · line 155
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -149,11 +151,13 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, {int err; +mutex_lock (&fb_helper->lock);mutex_lock (&fb_helper->dev->mode_config.mutex);Same.
Quoted 9 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0err =__drm_fb_helper_add_one_connector (fb_helper, connector);mutex_unlock (&fb_helper->dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);return err; }drivers/gpu/drm/drm_fb_helper.c int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) · line 191
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -183,6 +187,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)if (!drm_fbdev_emulation)return 0 ; +mutex_lock (&fb_helper->lock);mutex_lock (&dev->mode_config.mutex);Same.
Quoted 11 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0drm_connector_list_iter_begin (dev, &conn_iter);drm_for_each_connector_iter (connector, &conn_iter) {@@ -206,6 +211,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) out:drm_connector_list_iter_end (&conn_iter);mutex_unlock (&dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);return ret; }drivers/gpu/drm/drm_fb_helper.c static int __drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, · line 230
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -220,6 +226,7 @@ static int __drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,if (!drm_fbdev_emulation)return 0 ; +WARN_ON (!mutex_is_locked (&fb_helper->lock));WARN_ON (!mutex_is_locked (&fb_helper->dev->mode_config.mutex));Same.
Quoted 95 lines
drivers/gpu/drm/drm_fb_helper.c +19
-1for (i =0 ; i < fb_helper->connector_count; i++) {@@ -246,11 +253,13 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, {int err; +mutex_lock (&fb_helper->lock);mutex_lock (&fb_helper->dev->mode_config.mutex); err =__drm_fb_helper_remove_one_connector (fb_helper, connector);mutex_unlock (&fb_helper->dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);return err; }@@ -502,16 +511,21 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)if (!drm_fbdev_emulation)return -ENODEV ; +mutex_lock (&fb_helper->lock);drm_modeset_lock_all (dev); + ret =restore_fbdev_mode (fb_helper); do_delayed = fb_helper->delayed_hotplug;if (do_delayed) fb_helper->delayed_hotplug = false; +drm_modeset_unlock_all (dev); +mutex_unlock (&fb_helper->lock);if (do_delayed)drm_fb_helper_hotplug_event (fb_helper); +return ret; }EXPORT_SYMBOL (drm_fb_helper_restore_fbdev_mode_unlocked);@@ -747,6 +761,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper,INIT_WORK (&helper->resume_work, drm_fb_helper_resume_worker);INIT_WORK (&helper->dirty_work, drm_fb_helper_dirty_work); helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0 ; +mutex_init (&helper->lock); helper->funcs = funcs; helper->dev = dev; }@@ -912,6 +927,7 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) }mutex_unlock (&kernel_fb_helper_lock); +mutex_destroy (&fb_helper->lock);drm_fb_helper_crtc_free (fb_helper); }@@ -2421,25 +2437,34 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);int drm_fb_helper_hotplug_event (struct drm_fb_helper *fb_helper) {struct drm_device *dev = fb_helper->dev; +int err =0 ;if (!drm_fbdev_emulation)return 0 ; +mutex_lock (&fb_helper->lock);mutex_lock (&dev->mode_config.mutex); +if (!fb_helper->fb || !drm_fb_helper_is_bound (fb_helper)) { fb_helper->delayed_hotplug = true;mutex_unlock (&dev->mode_config.mutex); -return 0 ; + goto unlock; } +DRM_DEBUG_KMS ("\n" );drm_setup_crtcs (fb_helper, fb_helper->fb->width, fb_helper->fb->height);mutex_unlock (&dev->mode_config.mutex); +mutex_unlock (&fb_helper->lock);drm_fb_helper_set_par (fb_helper->fbdev);return 0 ; + +unlock: +mutex_unlock (&fb_helper->lock); +return err; }EXPORT_SYMBOL (drm_fb_helper_hotplug_event);include/drm/drm_fb_helper.h +0
-0include/drm/drm_fb_helper.h struct drm_fb_helper { · line 206
Quoted 6 lines
include/drm/drm_fb_helper.h +3
-0@@ -201,6 +201,13 @@ struct drm_fb_helper {struct work_struct resume_work;/** +* @lock: +* +* Top-level FB helper lock. Bit more detail would be good here.
"This protects all the internal data structures and lists, like @connector_info or @crtc_info."
include/drm/drm_fb_helper.h struct drm_fb_helper { · line 213
Quoted 7 lines
include/drm/drm_fb_helper.h +4
-0+*/ +struct mutex lock; + +/** * @kernel_fb_list: * * Entry on the global kernel_fb_helper_list, used for kgdb entry/exit. So I think you're missing to protect almost all the fbdev paths. Essentially anything looking at
crtc_infoorconnector_infomust hold the new lock, which means all the places that currently calldrm_modeset_lock_all()need to grab this new lock too.Best way to make sure you catch them all is to also update the lockdep assert in
drm_fb_helper_for_each_connector().There's still a massive mess going with locking here, especially around the probe code and
drm_fb_helper_is_bound, but that's a different thing and better left for cleanup later on.
-DanielSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
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 v3 07/10] drm/exynos: Remove custom FB helper deferred setup
In reply to Andrzej HajdaQuoted 27 lines · Andrzej Hajda
Quoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The FB helper core now supports deferred setup, so the driver's custom implementation can be removed.
Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++++-- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/exynos/exynos_drm_drv.c +0
-0drivers/gpu/drm/exynos/exynos_drm_drv.c static int exynos_drm_bind(struct device *dev) · line 404
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +3
-2@@ -399,8 +399,9 @@ static int exynos_drm_bind(struct device *dev)/* init kms poll for handling hpd */ drm_kms_helper_poll_init (drm); -/* force connectors detection */ -drm_helper_hpd_irq_event (drm); + ret =exynos_drm_fbdev_init (dev); +if (ret) + goto err_cleanup_poll;It should be rather:
Quoted 4 lines
ret = exynos_drm_fbdev_init(drm);Even with this change it does not work, I will try to track down the problem.
We might need the multi-stage fbdev setup here, i.e. init fbdev, run hpd_irq_event() (I suspect that kicks all the connectors to start probing), then initial_config for fbdev.
Probably simplest way to achieve this is to keep the hpd_irq_event call, but place it _after_ the fbdev_init.
-Daniel
Quoted 33 lines
Regards
AndrzejQuoted 16 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +1
-0/* register the DRM device */ ret =drm_dev_register (drm,0 );@@ -411,6 +412,7 @@ static int exynos_drm_bind(struct device *dev) err_cleanup_fbdev:exynos_drm_fbdev_fini (drm); +err_cleanup_poll:drm_kms_helper_poll_fini (drm);exynos_drm_device_subdrv_remove (drm); err_cleanup_vblank:drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0
-0drivers/gpu/drm/exynos/exynos_drm_fbdev.c void exynos_drm_output_poll_changed(struct drm_device *dev) · line 309
Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0
-2@@ -306,6 +306,4 @@ void exynos_drm_output_poll_changed(struct drm_device *dev)if (fb_helper)drm_fb_helper_hotplug_event (fb_helper); -else -exynos_drm_fbdev_init (dev); }_______________________________________________
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 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 10/10] drm/rockchip: Remove unnecessary NULL check
In reply to Thierry RedingQuoted 6 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The expression
&private->fbdev_helpercan never be NULL, so the check is completely unnecessary.Signed-off-by Thierry Reding <[email protected]>
On the 3 drivers patches (all except exynos):
For merging, do you want to push it all through drm-misc? Or planning on sending a pull request to Dave?
-Daniel
Quoted 27 lines
--- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/rockchip/rockchip_drm_fb.c +1
-3@@ -168,10 +168,8 @@ rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,static void rockchip_drm_output_poll_changed (struct drm_device *dev) {struct rockchip_drm_private *private = dev->dev_private; -struct drm_fb_helper *fb_helper = &private->fbdev_helper; -if (fb_helper) -drm_fb_helper_hotplug_event (fb_helper); +drm_fb_helper_hotplug_event (&private->fbdev_helper); } static voidSignature · 6 lines
2.12.0 _______________________________________________ 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
Re: [PATCH v3 07/10] drm/exynos: Remove custom FB helper deferred setup
In reply to Daniel VetterQuoted 29 lines · Daniel Vetter
Quoted 28 lines · Andrzej Hajda
Quoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The FB helper core now supports deferred setup, so the driver's custom implementation can be removed.
Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++++-- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/exynos/exynos_drm_drv.c +0
-0drivers/gpu/drm/exynos/exynos_drm_drv.c static int exynos_drm_bind(struct device *dev) · line 404
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +3
-2@@ -399,8 +399,9 @@ static int exynos_drm_bind(struct device *dev)/* init kms poll for handling hpd */ drm_kms_helper_poll_init (drm); -/* force connectors detection */ -drm_helper_hpd_irq_event (drm); + ret =exynos_drm_fbdev_init (dev); +if (ret) + goto err_cleanup_poll;It should be rather:
ret = exynos_drm_fbdev_init(drm);
Quoted 2 lines
Quoted 2 lines
Even with this change it does not work, I will try to track down the problem.
The solution was to remove custom equivalent of drm_fb_helper_maybe_connected - exynos_drm_fbdev_is_anything_connected, it is called earlier and it was a part of custom deferred fbdev.
Quoted 7 lines
We might need the multi-stage fbdev setup here, i.e. init fbdev, run
hpd_irq_event()(I suspect that kicks all the connectors to start probing), theninitial_configfor fbdev.Probably simplest way to achieve this is to keep the
hpd_irq_eventcall, but place it _after_ thefbdev_init.
-Daniel
I wonder if it wouldn't be sufficient to check if there is anything connected, instead of checking if there is anything not-disconnected, in drm_fb_helper_maybe_connected.
Regards
Andrzej
Quoted 22 lines
Quoted 22 lines
Regards
AndrzejQuoted 17 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +1
-0/* register the DRM device */ ret =drm_dev_register (drm,0 );@@ -411,6 +412,7 @@ static int exynos_drm_bind(struct device *dev) err_cleanup_fbdev:exynos_drm_fbdev_fini (drm); +err_cleanup_poll:drm_kms_helper_poll_fini (drm);exynos_drm_device_subdrv_remove (drm); err_cleanup_vblank:drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0
-0@@ -306,6 +306,4 @@ void exynos_drm_output_poll_changed(struct drm_device *dev)
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c void exynos_drm_output_poll_changed(struct drm_device *dev) · line 309
Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0
-2if (fb_helper)drm_fb_helper_hotplug_event (fb_helper); -else -exynos_drm_fbdev_init (dev); }_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 07/10] drm/exynos: Remove custom FB helper deferred setup
Quoted 30 lines · Andrzej Hajda
Quoted 29 lines · Daniel Vetter
Quoted 28 lines · Andrzej Hajda
Quoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The FB helper core now supports deferred setup, so the driver's custom implementation can be removed.
Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++++-- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/exynos/exynos_drm_drv.c +0
-0drivers/gpu/drm/exynos/exynos_drm_drv.c static int exynos_drm_bind(struct device *dev) · line 404
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +3
-2@@ -399,8 +399,9 @@ static int exynos_drm_bind(struct device *dev)/* init kms poll for handling hpd */ drm_kms_helper_poll_init (drm); -/* force connectors detection */ -drm_helper_hpd_irq_event (drm); + ret =exynos_drm_fbdev_init (dev); +if (ret) + goto err_cleanup_poll;It should be rather:
ret = exynos_drm_fbdev_init(drm);
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Even with this change it does not work, I will try to track down the problem.
The solution was to remove custom equivalent of
drm_fb_helper_maybe_connected-exynos_drm_fbdev_is_anything_connected, it is called earlier and it was a part of custom deferred fbdev.
Cool, thanks for figuring that out. I can add that to this patch for v4.
Quoted 11 lines
Quoted 7 lines
We might need the multi-stage fbdev setup here, i.e. init fbdev, run
hpd_irq_event()(I suspect that kicks all the connectors to start probing), theninitial_configfor fbdev.Probably simplest way to achieve this is to keep the
hpd_irq_eventcall, but place it _after_ thefbdev_init.
-DanielI wonder if it wouldn't be sufficient to check if there is anything connected, instead of checking if there is anything not-disconnected, in
drm_fb_helper_maybe_connected.
My recollection is that this had been discussed when I first sent this out. VGA outputs are somewhat of a special case in that you can't always properly detect that it's connected or not. So effectively we need to take into account the connector_status_unknown. There's also some more information about this in the kerneldoc for enum drm_connector_status.
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 10/10] drm/rockchip: Remove unnecessary NULL check
In reply to Daniel VetterQuoted 6 lines · Daniel Vetter
Quoted 5 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The expression
&private->fbdev_helpercan never be NULL, so the check is completely unnecessary.
Quoted 8 lines
Quoted 1 line
Signed-off-by Thierry Reding <[email protected]>On the 3 drivers patches (all except exynos):
Reviewed-by Daniel Vetter <[email protected]>For merging, do you want to push it all through drm-misc? Or planning on sending a pull request to Dave?
I think this is perfect material for drm-misc. I'll resend v4 shortly with a build fix and the fix Andrzej pointed out folded into the Exynos driver.
Thierry
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 07/10] drm/exynos: Remove custom FB helper deferred setup
In reply to Thierry RedingQuoted 45 lines · Thierry Reding
Quoted 30 lines · Andrzej Hajda
Quoted 29 lines · Daniel Vetter
Quoted 28 lines · Andrzej Hajda
Quoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The FB helper core now supports deferred setup, so the driver's custom implementation can be removed.
Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++++-- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/exynos/exynos_drm_drv.c +0
-0drivers/gpu/drm/exynos/exynos_drm_drv.c static int exynos_drm_bind(struct device *dev) · line 404
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +3
-2@@ -399,8 +399,9 @@ static int exynos_drm_bind(struct device *dev)/* init kms poll for handling hpd */ drm_kms_helper_poll_init (drm); -/* force connectors detection */ -drm_helper_hpd_irq_event (drm); + ret =exynos_drm_fbdev_init (dev); +if (ret) + goto err_cleanup_poll;It should be rather:
ret = exynos_drm_fbdev_init(drm);Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Even with this change it does not work, I will try to track down the problem.
The solution was to remove custom equivalent of
drm_fb_helper_maybe_connected-exynos_drm_fbdev_is_anything_connected, it is called earlier and it was a part of custom deferred fbdev.Cool, thanks for figuring that out. I can add that to this patch for v4.
Quoted 7 lines
Quoted 7 lines
We might need the multi-stage fbdev setup here, i.e. init fbdev, run
hpd_irq_event()(I suspect that kicks all the connectors to start probing), theninitial_configfor fbdev.Probably simplest way to achieve this is to keep the
hpd_irq_eventcall, but place it _after_ thefbdev_init.
-Daniel
Quoted 8 lines
Quoted 3 lines
I wonder if it wouldn't be sufficient to check if there is anything connected, instead of checking if there is anything not-disconnected, in
drm_fb_helper_maybe_connected.My recollection is that this had been discussed when I first sent this out. VGA outputs are somewhat of a special case in that you can't always properly detect that it's connected or not. So effectively we need to take into account the
connector_status_unknown. There's also some more information about this in the kerneldoc for enumdrm_connector_status.
OK, I forgot about it and assumed that it is only used for initial state of connector.
Returning to Daniel's proposition about hpd_irq_event(), it seems unnecessary then: before calling drm_fb_helper_maybe_connected drm_fb_helper_probe_connector_modes is called, which calls fill_modes callback which should perform connector probing anyway, am I right?
Regards
Andrzej
Quoted 2 lines
Thierry
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 07/10] drm/exynos: Remove custom FB helper deferred setup
Quoted 55 lines · Andrzej Hajda
Quoted 45 lines · Thierry Reding
Quoted 30 lines · Andrzej Hajda
Quoted 29 lines · Daniel Vetter
Quoted 28 lines · Andrzej Hajda
Quoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The FB helper core now supports deferred setup, so the driver's custom implementation can be removed.
Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++++-- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/exynos/exynos_drm_drv.c +0
-0drivers/gpu/drm/exynos/exynos_drm_drv.c static int exynos_drm_bind(struct device *dev) · line 404
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +3
-2@@ -399,8 +399,9 @@ static int exynos_drm_bind(struct device *dev)/* init kms poll for handling hpd */ drm_kms_helper_poll_init (drm); -/* force connectors detection */ -drm_helper_hpd_irq_event (drm); + ret =exynos_drm_fbdev_init (dev); +if (ret) + goto err_cleanup_poll;It should be rather:
ret = exynos_drm_fbdev_init(drm);Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Even with this change it does not work, I will try to track down the problem.
The solution was to remove custom equivalent of
drm_fb_helper_maybe_connected-exynos_drm_fbdev_is_anything_connected, it is called earlier and it was a part of custom deferred fbdev.Cool, thanks for figuring that out. I can add that to this patch for v4.
Quoted 7 lines
Quoted 7 lines
We might need the multi-stage fbdev setup here, i.e. init fbdev, run
hpd_irq_event()(I suspect that kicks all the connectors to start probing), theninitial_configfor fbdev.Probably simplest way to achieve this is to keep the
hpd_irq_eventcall, but place it _after_ thefbdev_init.
-DanielQuoted 8 lines
Quoted 3 lines
I wonder if it wouldn't be sufficient to check if there is anything connected, instead of checking if there is anything not-disconnected, in
drm_fb_helper_maybe_connected.My recollection is that this had been discussed when I first sent this out. VGA outputs are somewhat of a special case in that you can't always properly detect that it's connected or not. So effectively we need to take into account the
connector_status_unknown. There's also some more information about this in the kerneldoc for enumdrm_connector_status.
Quoted 6 lines
OK, I forgot about it and assumed that it is only used for initial state of connector.
Returning to Daniel's proposition abouthpd_irq_event(), it seems unnecessary then: before callingdrm_fb_helper_maybe_connecteddrm_fb_helper_probe_connector_modesis called, which callsfill_modescallback which should perform connector probing anyway, am I right?
Yes, that matches my understanding of the call sequence.
Thierry
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 07/10] drm/exynos: Remove custom FB helper deferred setup
In reply to Andrzej HajdaQuoted 49 lines · Andrzej Hajda
Quoted 48 lines · Thierry Reding
Quoted 30 lines · Andrzej Hajda
Quoted 29 lines · Daniel Vetter
Quoted 28 lines · Andrzej Hajda
Quoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The FB helper core now supports deferred setup, so the driver's custom implementation can be removed.
Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++++-- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/exynos/exynos_drm_drv.c +0
-0drivers/gpu/drm/exynos/exynos_drm_drv.c static int exynos_drm_bind(struct device *dev) · line 404
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +3
-2@@ -399,8 +399,9 @@ static int exynos_drm_bind(struct device *dev)/* init kms poll for handling hpd */ drm_kms_helper_poll_init (drm); -/* force connectors detection */ -drm_helper_hpd_irq_event (drm); + ret =exynos_drm_fbdev_init (dev); +if (ret) + goto err_cleanup_poll;It should be rather:
ret = exynos_drm_fbdev_init(drm);Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Even with this change it does not work, I will try to track down the problem.
The solution was to remove custom equivalent of
drm_fb_helper_maybe_connected-exynos_drm_fbdev_is_anything_connected, it is called earlier and it was a part of custom deferred fbdev.Cool, thanks for figuring that out. I can add that to this patch for v4.
Quoted 10 lines
Quoted 7 lines
We might need the multi-stage fbdev setup here, i.e. init fbdev, run
hpd_irq_event()(I suspect that kicks all the connectors to start probing), theninitial_configfor fbdev.Probably simplest way to achieve this is to keep the
hpd_irq_eventcall, but place it _after_ thefbdev_init.
-DanielI wonder if it wouldn't be sufficient to check if there is anything connected, instead of checking if there is anything not-disconnected, in
drm_fb_helper_maybe_connected.
Quoted 8 lines
Quoted 5 lines
My recollection is that this had been discussed when I first sent this out. VGA outputs are somewhat of a special case in that you can't always properly detect that it's connected or not. So effectively we need to take into account the
connector_status_unknown. There's also some more information about this in the kerneldoc for enumdrm_connector_status.OK, I forgot about it and assumed that it is only used for initial state of connector.
unknown does indeed mean "I couldn't figure this out", which kinda only happesn for VGA on platforms where load detect doesn't exist (or doesn't reliably exist). We should probably document this somewhere ... hint :-)
Quoted 4 lines
Returning to Daniel's proposition about
hpd_irq_event(), it seems unnecessary then: before callingdrm_fb_helper_maybe_connecteddrm_fb_helper_probe_connector_modesis called, which callsfill_modescallback which should perform connector probing anyway, am I right?
Yeah if you can fix this by removing the exynos copy of maybe_connected, then we indeed don't need the hpd_irq. Needing it would indicate a bug in exynos anyway.
-Daniel
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 v3 06/10] drm/fb-helper: Support deferred setup
In reply to Daniel VetterQuoted 1 line · Daniel Vetter
On Tue, Mar 21, 2017 at 09:13:54AM +0100, Thierry Reding wrote:
[...]
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/drm_fb_helper.c +0
-0
[...]
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -2437,11 +2476,16 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);int drm_fb_helper_hotplug_event (struct drm_fb_helper *fb_helper) {struct drm_device *dev = fb_helper->dev; +unsigned int width, height;int err =0 ;if (!drm_fbdev_emulation)return 0 ;
Quoted 7 lines
drivers/gpu/drm/drm_fb_helper.c EXPORT_SYMBOL(drm_fb_helper_initial_config); · line 2487
Quoted 3 lines
drivers/gpu/drm/drm_fb_helper.c +3
-0+if (fb_helper->deferred_setup) +return drm_fb_helper_initial_config (fb_helper, + fb_helper->preferred_bpp);I think this must be moved under the protection of ->lock, you might race otherwise (e.g. hpd vs. userspace forcing a re-probe, both noticing the change).
I think I had originally put this under the lock only to see that result in a deadlock. I can't quite remember why that was, but testing shows that this still happens. It's getting rather late, so I'll have to defer tracking this down to tomorrow.
Thierry
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 06/10] drm/fb-helper: Support deferred setup
Quoted 23 lines · Thierry Reding
Quoted 1 line · Daniel Vetter
On Tue, Mar 21, 2017 at 09:13:54AM +0100, Thierry Reding wrote:
[...]
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/drm_fb_helper.c +0
-0[...]
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0@@ -2437,11 +2476,16 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);int drm_fb_helper_hotplug_event (struct drm_fb_helper *fb_helper) {struct drm_device *dev = fb_helper->dev; +unsigned int width, height;int err =0 ;if (!drm_fbdev_emulation)return 0 ;Quoted 7 lines
drivers/gpu/drm/drm_fb_helper.c EXPORT_SYMBOL(drm_fb_helper_initial_config); · line 2487
Quoted 3 lines
drivers/gpu/drm/drm_fb_helper.c +3
-0+if (fb_helper->deferred_setup) +return drm_fb_helper_initial_config (fb_helper, + fb_helper->preferred_bpp);I think this must be moved under the protection of ->lock, you might race otherwise (e.g. hpd vs. userspace forcing a re-probe, both noticing the change).
Quoted 4 lines
I think I had originally put this under the lock only to see that result in a deadlock. I can't quite remember why that was, but testing shows that this still happens. It's getting rather late, so I'll have to defer tracking this down to tomorrow.
initial_config also grabs your new lock, which means you'd need more static _unlocked variants to make it work. I didn't see any other obvious problem this would cause.
-Daniel
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: [PATCH v3 06/10] drm/fb-helper: Support deferred setup
In reply to Thierry RedingQuoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
FB helper code falls back to a 1024x768 mode if no outputs are connected or don't report back any modes upon initialization. This can be annoying because outputs that are added to FB helper later on can't be used with FB helper if they don't support a matching mode.
The fallback is in place because VGA connectors can happen to report an unknown connection status even when they are in fact connected.
Some drivers have custom solutions in place to defer FB helper setup until at least one output is connected. But the logic behind these solutions is always the same and there is nothing driver-specific about it, so a better alterative is to fix the FB helper core and add support for all drivers automatically.
Quoted 8 lines
This patch adds support for deferred FB helper setup. It checks all the connectors for their connection status, and if all of them report to be disconnected marks the FB helper as needing deferred setup. Whet setup is deferred, the FB helper core will automatically retry setup after a hotplug event, and it will keep trying until it succeeds.
Tested-by John Stultz <[email protected]>Signed-off-by Thierry Reding <[email protected]>
Ok 2nd attempt at making this work, probably easier to go back to v2.
Quoted 10 lines
--- drivers/gpu/drm/drm_fb_helper.c | 60 +++++++++++++++++++++++++++++++++++++---- include/drm/drm_fb_helper.h | 21 +++++++++++++++ 2 files changed, 76 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_fb_helper.c +0
-0
drivers/gpu/drm/drm_fb_helper.c int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper) · line 515
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +2
-0@@ -511,6 +511,9 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)if (!drm_fbdev_emulation)return -ENODEV ; +if (fb_helper->deferred_setup) +return 0 ;
Please wrap in READ_ONCE to make it clear we're doing lockless checking here.
Quoted 46 lines
drivers/gpu/drm/drm_fb_helper.c +19
-2+mutex_lock (&fb_helper->lock);drm_modeset_lock_all (dev);@@ -1597,6 +1600,23 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, }EXPORT_SYMBOL (drm_fb_helper_pan_display); +static bool drm_fb_helper_maybe_connected (struct drm_fb_helper *helper) +{ +bool connected = false; +unsigned int i; + +for (i =0 ; i < helper->connector_count; i++) { +struct drm_fb_helper_connector *fb = helper->connector_info[i]; + +if (fb->connector->status != connector_status_disconnected) { + connected = true; +break ; + } + } + +return connected; +} +/* * Allocates the backing storage and sets up the fbdev info structure through * the ->fb_probe callback and then registers the fbdev and sets up the panic @@ -2254,8 +2274,6 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,int i;DRM_DEBUG_KMS ("\n" ); -if (drm_fb_helper_probe_connector_modes (fb_helper, width, height) ==0 ) -DRM_DEBUG_KMS ("No connectors reported connected with modes\n" );/* prevent concurrent modification of connector_count by hotplug */ lockdep_assert_held (&fb_helper->dev->mode_config.mutex);@@ -2378,6 +2396,7 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,int drm_fb_helper_initial_config (struct drm_fb_helper *fb_helper,int bpp_sel) {struct drm_device *dev = fb_helper->dev; +unsigned int width, height;struct fb_info *info;int ret;
drivers/gpu/drm/drm_fb_helper.c int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel) · line 2405
Quoted 2 lines
drivers/gpu/drm/drm_fb_helper.c +0
-0@@ -2385,14 +2404,34 @@ int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel)return 0 ;
From here ...
Quoted 21 lines
drivers/gpu/drm/drm_fb_helper.c +17
-3mutex_lock (&dev->mode_config.mutex); -drm_setup_crtcs (fb_helper, - dev->mode_config.max_width, - dev->mode_config.max_height); + + width = dev->mode_config.max_width; + height = dev->mode_config.max_height; + +if (drm_fb_helper_probe_connector_modes (fb_helper, width, height) ==0 ) +DRM_DEBUG_KMS ("No connectors reported connected with modes\n" ); + +/* +* If everything's disconnected, there's no use in attempting to set +* up fbdev. +*/ +if (!drm_fb_helper_maybe_connected (fb_helper)) { +DRM_INFO ("No outputs connected, deferring setup\n" ); + fb_helper->preferred_bpp = bpp_sel; + fb_helper->deferred_setup = true; +mutex_unlock (&dev->mode_config.mutex); +return 0 ;
drivers/gpu/drm/drm_fb_helper.c int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel) · line 2433
Quoted 10 lines
drivers/gpu/drm/drm_fb_helper.c +5
-0+ } + +drm_setup_crtcs (fb_helper, width, height); + ret =drm_fb_helper_single_fb_probe (fb_helper, bpp_sel);mutex_unlock (&dev->mode_config.mutex);if (ret)return ret; + fb_helper->deferred_setup = false;
To here you need to hold the new fb_helper->mutex. Plus at the top, after you've grabbed the lock, you need to re-check ->deferred_setup. This way we guaranteed that only 1 thread can ever do the deferred setup, while not holding the lock while we call register_framebuffer. If you hold any fbdev or kms lock while calling register_framebuffer you will deadlock.
Quoted 5 lines
drivers/gpu/drm/drm_fb_helper.c +1
-0+ info = fb_helper->fbdev; info->var.pixclock =0 ; ret =register_framebuffer (info);
drivers/gpu/drm/drm_fb_helper.c EXPORT_SYMBOL(drm_fb_helper_initial_config); · line 2485
Quoted 10 lines
drivers/gpu/drm/drm_fb_helper.c +2
-0@@ -2437,11 +2476,16 @@ EXPORT_SYMBOL(drm_fb_helper_initial_config);int drm_fb_helper_hotplug_event (struct drm_fb_helper *fb_helper) {struct drm_device *dev = fb_helper->dev; +unsigned int width, height;int err =0 ;if (!drm_fbdev_emulation)return 0 ; +if (fb_helper->deferred_setup)
Same here, please wrap in READ_ONCE, this is just a fastpath check.
With those changes your prep patch to roll out fb_helper->mutex more shouldn't be needed at all.
Cheers, Daniel
Quoted 58 lines
drivers/gpu/drm/drm_fb_helper.c +9
-0+return drm_fb_helper_initial_config (fb_helper, + fb_helper->preferred_bpp); +mutex_lock (&fb_helper->lock);mutex_lock (&dev->mode_config.mutex);@@ -2453,6 +2497,12 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)DRM_DEBUG_KMS ("\n" ); + width = dev->mode_config.max_width; + height = dev->mode_config.max_height; + +if (drm_fb_helper_probe_connector_modes (fb_helper, width, height) ==0 ) +DRM_DEBUG_KMS ("No connectors reported connected with modes\n" ); +drm_setup_crtcs (fb_helper, fb_helper->fb->width, fb_helper->fb->height);mutex_unlock (&dev->mode_config.mutex);include/drm/drm_fb_helper.h +21
-0@@ -222,6 +222,27 @@ struct drm_fb_helper {* needs to be reprobe when fbdev is in control again. */ bool delayed_hotplug; + +/** +* @deferred_setup: +* +* If no outputs are connected (disconnected or unknown) the FB helper +* code will defer setup until at least one of the outputs shows up. +* This field keeps track of the status so that setup can be retried +* at every hotplug event until it succeeds eventually. +*/ +bool deferred_setup; + +/** +* @preferred_bpp: +* +* Temporary storage for the driver's preferred BPP setting passed to +* FB helper initialization. This needs to be tracked so that deferred +* FB helper setup can pass this on. +* +* See also: @deferred_setup +*/ +int preferred_bpp; };/** Signature · 6 lines
2.12.0 _______________________________________________ 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