Re: [PATCH 05/15] drm/i915: Extract skl_allocate_plane_ddb()

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

 



On Tue, Jan 18, 2022 at 11:23:44AM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> 
> Replace some copy-pasta with a function.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@xxxxxxxxx>

> ---
>  drivers/gpu/drm/i915/intel_pm.c | 41 +++++++++++++++++++--------------
>  1 file changed, 24 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index cd1b5f09f241..93ff07f6ef26 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -5073,9 +5073,24 @@ struct skl_plane_ddb_iter {
>  	u16 start, size;
>  };
>  
> +static u16
> +skl_allocate_plane_ddb(struct skl_plane_ddb_iter *iter,
> +		       const struct skl_wm_level *wm,
> +		       u64 data_rate)
> +{
> +	u16 extra;
> +
> +	extra = min_t(u16, iter->size,
> +		      DIV64_U64_ROUND_UP(iter->size * data_rate, iter->data_rate));
> +	iter->size -= extra;
> +	iter->data_rate -= data_rate;
> +
> +	return wm->min_ddb_alloc + extra;
> +}
> +
>  static int
> -skl_allocate_plane_ddb(struct intel_atomic_state *state,
> -		       struct intel_crtc *crtc)
> +skl_crtc_allocate_plane_ddb(struct intel_atomic_state *state,
> +			    struct intel_crtc *crtc)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>  	struct intel_crtc_state *crtc_state =
> @@ -5160,8 +5175,6 @@ skl_allocate_plane_ddb(struct intel_atomic_state *state,
>  	for_each_plane_id_on_crtc(crtc, plane_id) {
>  		const struct skl_plane_wm *wm =
>  			&crtc_state->wm.skl.optimal.planes[plane_id];
> -		u64 data_rate;
> -		u16 extra;
>  
>  		if (plane_id == PLANE_CURSOR)
>  			continue;
> @@ -5173,22 +5186,16 @@ skl_allocate_plane_ddb(struct intel_atomic_state *state,
>  		if (iter.data_rate == 0)
>  			break;
>  
> -		data_rate = crtc_state->plane_data_rate[plane_id];
> -		extra = min_t(u16, iter.size,
> -			      DIV64_U64_ROUND_UP(iter.size * data_rate, iter.data_rate));
> -		iter.total[plane_id] = wm->wm[level].min_ddb_alloc + extra;
> -		iter.size -= extra;
> -		iter.data_rate -= data_rate;
> +		iter.total[plane_id] =
> +			skl_allocate_plane_ddb(&iter, &wm->wm[level],
> +					       crtc_state->plane_data_rate[plane_id]);
>  
>  		if (iter.data_rate == 0)
>  			break;
>  
> -		data_rate = crtc_state->uv_plane_data_rate[plane_id];
> -		extra = min_t(u16, iter.size,
> -			      DIV64_U64_ROUND_UP(iter.size * data_rate, iter.data_rate));
> -		iter.uv_total[plane_id] = wm->uv_wm[level].min_ddb_alloc + extra;
> -		iter.size -= extra;
> -		iter.data_rate -= data_rate;
> +		iter.uv_total[plane_id] =
> +			skl_allocate_plane_ddb(&iter, &wm->uv_wm[level],
> +					       crtc_state->uv_plane_data_rate[plane_id]);
>  	}
>  	drm_WARN_ON(&dev_priv->drm, iter.size != 0 || iter.data_rate != 0);
>  
> @@ -6136,7 +6143,7 @@ skl_compute_ddb(struct intel_atomic_state *state)
>  
>  	for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
>  					    new_crtc_state, i) {
> -		ret = skl_allocate_plane_ddb(state, crtc);
> +		ret = skl_crtc_allocate_plane_ddb(state, crtc);
>  		if (ret)
>  			return ret;
>  
> -- 
> 2.32.0
> 



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux