[Intel-gfx] [PATCH 42/58] drm/i915: don't save all the encoder/crtc state in set_config

Jesse Barnes jbarnes at virtuousgeek.org
Wed Sep 5 18:52:44 CEST 2012


On Sun, 19 Aug 2012 21:12:59 +0200
Daniel Vetter <daniel.vetter at ffwll.ch> wrote:

> We actually only touch the connector -> encoder and encoder -> crtc
> linking. So it's enough to just save/restore that.
> 
> Signed-Off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 28 +++++++++++++++-------------
>  drivers/gpu/drm/i915/intel_drv.h     |  4 ++--
>  2 files changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 56827d6..24706ca 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -6724,8 +6724,8 @@ done:
>  static void intel_set_config_free(struct intel_set_config *config)
>  {
>  	if (config) {
> -		kfree(config->save_connectors);
> -		kfree(config->save_encoders);
> +		kfree(config->save_connector_encoders);
> +		kfree(config->save_encoder_crtcs);
>  		kfree(config->save_crtcs);
>  	}
>  	kfree(config);
> @@ -6741,19 +6741,21 @@ static int intel_set_config_save_state(struct drm_device *dev,
>  
>  	/* Allocate space for the backup of all (non-pointer) crtc, encoder and
>  	 * connector data. */
> -	config->save_crtcs = kzalloc(dev->mode_config.num_crtc *
> +	config->save_crtcs = kcalloc(dev->mode_config.num_crtc,
>  				     sizeof(struct drm_crtc), GFP_KERNEL);
>  	if (!config->save_crtcs)
>  		return -ENOMEM;
>  
> -	config->save_encoders = kzalloc(dev->mode_config.num_encoder *
> -					sizeof(struct drm_encoder), GFP_KERNEL);
> -	if (!config->save_encoders)
> +	config->save_encoder_crtcs =
> +		kcalloc(dev->mode_config.num_encoder,
> +			sizeof(struct drm_crtc *), GFP_KERNEL);
> +	if (!config->save_encoder_crtcs)
>  		return -ENOMEM;
>  
> -	config->save_connectors = kzalloc(dev->mode_config.num_connector *
> -					  sizeof(struct drm_connector), GFP_KERNEL);
> -	if (!config->save_connectors)
> +	config->save_connector_encoders =
> +		kcalloc(dev->mode_config.num_connector,
> +			sizeof(struct drm_encoder *), GFP_KERNEL);
> +	if (!config->save_connector_encoders)
>  		return -ENOMEM;
>  
>  	/* Copy data. Note that driver private data is not affected.
> @@ -6767,12 +6769,12 @@ static int intel_set_config_save_state(struct drm_device *dev,
>  
>  	count = 0;
>  	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
> -		config->save_encoders[count++] = *encoder;
> +		config->save_encoder_crtcs[count++] = encoder->crtc;
>  	}
>  
>  	count = 0;
>  	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
> -		config->save_connectors[count++] = *connector;
> +		config->save_connector_encoders[count++] = connector->encoder;
>  	}
>  
>  	return 0;
> @@ -6793,12 +6795,12 @@ static void intel_set_config_restore_state(struct drm_device *dev,
>  
>  	count = 0;
>  	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
> -		*encoder = config->save_encoders[count++];
> +		encoder->crtc = config->save_encoder_crtcs[count++];
>  	}
>  
>  	count = 0;
>  	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
> -		*connector = config->save_connectors[count++];
> +		connector->encoder = config->save_connector_encoders[count++];
>  	}
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index fad11c8..4946282 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -424,8 +424,8 @@ extern void intel_panel_destroy_backlight(struct drm_device *dev);
>  extern enum drm_connector_status intel_panel_detect(struct drm_device *dev);
>  
>  struct intel_set_config {
> -	struct drm_connector *save_connectors;
> -	struct drm_encoder *save_encoders;
> +	struct drm_encoder **save_connector_encoders;
> +	struct drm_crtc **save_encoder_crtcs;
>  	struct drm_crtc *save_crtcs;
>  
>  	bool fb_changed;

Sneaky that you moved to kcalloc too :)

Reviewed-by: Jesse Barnes <jbarnes at virtuousgeek.org>

-- 
Jesse Barnes, Intel Open Source Technology Center



More information about the Intel-gfx mailing list