Re: [PATCH 2/3] drm: Pull together probe + setup for drm_fb_helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 23, 2016 at 02:04:16PM +0000, Chris Wilson wrote:
> drm_fb_helper_probe_connector_modes() is always called before
> drm_setup_crtcs(), so just move the call into drm_setup_crtcs for a
> small bit of code compaction.
> 
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>

This drops drm_modeset_lock_all() around one call of drm_setup_crtcs and
just replaces it with dev->mode_config.mutex. But drm_setup_crtcs only
looks at probe state and not at modeset state, so that's all fine.

Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxxx>
> ---
>  drivers/gpu/drm/drm_fb_helper.c | 37 +++++++++++--------------------------
>  1 file changed, 11 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index d13c85682891..a19afc7eccde 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -2098,20 +2098,19 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
>  	return best_score;
>  }
>  
> -static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
> +static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,
> +			    u32 width, u32 height)
>  {
>  	struct drm_device *dev = fb_helper->dev;
>  	struct drm_fb_helper_crtc **crtcs;
>  	struct drm_display_mode **modes;
>  	struct drm_fb_offset *offsets;
>  	bool *enabled;
> -	int width, height;
>  	int i;
>  
>  	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");
>  
>  	/* prevent concurrent modification of connector_count by hotplug */
>  	lockdep_assert_held(&fb_helper->dev->mode_config.mutex);
> @@ -2235,23 +2234,15 @@ int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel)
>  {
>  	struct drm_device *dev = fb_helper->dev;
>  	struct fb_info *info;
> -	int count = 0;
>  	int ret;
>  
>  	if (!drm_fbdev_emulation)
>  		return 0;
>  
>  	mutex_lock(&dev->mode_config.mutex);
> -	count = drm_fb_helper_probe_connector_modes(fb_helper,
> -						    dev->mode_config.max_width,
> -						    dev->mode_config.max_height);
> -	/*
> -	 * we shouldn't end up with no modes here.
> -	 */
> -	if (count == 0)
> -		dev_info(fb_helper->dev->dev, "No connectors reported connected with modes\n");
> -
> -	drm_setup_crtcs(fb_helper);
> +	drm_setup_crtcs(fb_helper,
> +			dev->mode_config.max_width,
> +			dev->mode_config.max_height);
>  	ret = drm_fb_helper_single_fb_probe(fb_helper, bpp_sel);
>  	mutex_unlock(&dev->mode_config.mutex);
>  	if (ret)
> @@ -2299,28 +2290,22 @@ 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;
> -	u32 max_width, max_height;
>  
>  	if (!drm_fbdev_emulation)
>  		return 0;
>  
> -	mutex_lock(&fb_helper->dev->mode_config.mutex);
> +	mutex_lock(&dev->mode_config.mutex);
>  	if (!fb_helper->fb || !drm_fb_helper_is_bound(fb_helper)) {
>  		fb_helper->delayed_hotplug = true;
> -		mutex_unlock(&fb_helper->dev->mode_config.mutex);
> +		mutex_unlock(&dev->mode_config.mutex);
>  		return 0;
>  	}
>  	DRM_DEBUG_KMS("\n");
>  
> -	max_width = fb_helper->fb->width;
> -	max_height = fb_helper->fb->height;
> +	drm_setup_crtcs(fb_helper, fb_helper->fb->width, fb_helper->fb->height);
>  
> -	drm_fb_helper_probe_connector_modes(fb_helper, max_width, max_height);
> -	mutex_unlock(&fb_helper->dev->mode_config.mutex);
> +	mutex_unlock(&dev->mode_config.mutex);
>  
> -	drm_modeset_lock_all(dev);
> -	drm_setup_crtcs(fb_helper);
> -	drm_modeset_unlock_all(dev);
>  	drm_fb_helper_set_par(fb_helper->fbdev);
>  
>  	return 0;
> -- 
> 2.10.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux