[PATCH 5/9] drm/i915: Polish types in fb calculations

Jani Nikula jani.nikula at linux.intel.com
Mon May 6 14:07:55 UTC 2024


On Mon, 06 May 2024, Ville Syrjala <ville.syrjala at linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> Be a bit more consistent in our use of integer types in
> the fb related calculatiosn. u32 we generally only use
> for ggtt offsets and such, and everything else can be regular
> (unsigned) ints.
>
> There's also an overabundance of consts for local variables
> in skl_check_main_surface() which is not something we generally
> do. So get rid of those while at it.

Reviewed-by: Jani Nikula <jani.nikula at intel.com>

>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/i9xx_plane.c     |  2 +-
>  drivers/gpu/drm/i915/display/intel_fb.c       | 27 +++++++++--------
>  drivers/gpu/drm/i915/display/intel_fb_pin.c   |  2 +-
>  .../drm/i915/display/skl_universal_plane.c    | 29 +++++++++----------
>  4 files changed, 29 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/i9xx_plane.c b/drivers/gpu/drm/i915/display/i9xx_plane.c
> index 21303fa4f08f..ea4d8ba55ad8 100644
> --- a/drivers/gpu/drm/i915/display/i9xx_plane.c
> +++ b/drivers/gpu/drm/i915/display/i9xx_plane.c
> @@ -266,7 +266,7 @@ int i9xx_check_plane_surface(struct intel_plane_state *plane_state)
>  	 * despite them not using the linear offset anymore.
>  	 */
>  	if (DISPLAY_VER(dev_priv) >= 4 && fb->modifier == I915_FORMAT_MOD_X_TILED) {
> -		u32 alignment = intel_surf_alignment(fb, 0);
> +		unsigned int alignment = intel_surf_alignment(fb, 0);
>  		int cpp = fb->format->cpp[0];
>  
>  		while ((src_x + src_w) * cpp > plane_state->view.color_plane[0].mapping_stride) {
> diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
> index bf24f48a1e76..b6638726949d 100644
> --- a/drivers/gpu/drm/i915/display/intel_fb.c
> +++ b/drivers/gpu/drm/i915/display/intel_fb.c
> @@ -1045,7 +1045,7 @@ static u32 intel_compute_aligned_offset(struct drm_i915_private *i915,
>  					int color_plane,
>  					unsigned int pitch,
>  					unsigned int rotation,
> -					u32 alignment)
> +					unsigned int alignment)
>  {
>  	unsigned int cpp = fb->format->cpp[color_plane];
>  	u32 offset, offset_aligned;
> @@ -1102,8 +1102,8 @@ u32 intel_plane_compute_aligned_offset(int *x, int *y,
>  	struct drm_i915_private *i915 = to_i915(intel_plane->base.dev);
>  	const struct drm_framebuffer *fb = state->hw.fb;
>  	unsigned int rotation = state->hw.rotation;
> -	int pitch = state->view.color_plane[color_plane].mapping_stride;
> -	u32 alignment;
> +	unsigned int pitch = state->view.color_plane[color_plane].mapping_stride;
> +	unsigned int alignment;
>  
>  	if (intel_plane->id == PLANE_CURSOR)
>  		alignment = intel_cursor_alignment(i915);
> @@ -1120,8 +1120,7 @@ static int intel_fb_offset_to_xy(int *x, int *y,
>  				 int color_plane)
>  {
>  	struct drm_i915_private *i915 = to_i915(fb->dev);
> -	unsigned int height;
> -	u32 alignment, unused;
> +	unsigned int height, alignment, unused;
>  
>  	if (DISPLAY_VER(i915) >= 12 &&
>  	    !intel_fb_needs_pot_stride_remap(to_intel_framebuffer(fb)) &&
> @@ -1508,8 +1507,8 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p
>  		check_array_bounds(i915, view->gtt.remapped.plane, color_plane);
>  
>  		if (view->gtt.remapped.plane_alignment) {
> -			unsigned int aligned_offset = ALIGN(gtt_offset,
> -							    view->gtt.remapped.plane_alignment);
> +			u32 aligned_offset = ALIGN(gtt_offset,
> +						   view->gtt.remapped.plane_alignment);
>  
>  			size += aligned_offset - gtt_offset;
>  			gtt_offset = aligned_offset;
> @@ -1795,16 +1794,16 @@ u32 intel_fb_max_stride(struct drm_i915_private *dev_priv,
>  		return 128 * 1024;
>  }
>  
> -static u32
> +static unsigned int
>  intel_fb_stride_alignment(const struct drm_framebuffer *fb, int color_plane)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(fb->dev);
> -	u32 tile_width;
> +	unsigned int tile_width;
>  
>  	if (is_surface_linear(fb, color_plane)) {
> -		u32 max_stride = intel_plane_fb_max_stride(dev_priv,
> -							   fb->format->format,
> -							   fb->modifier);
> +		unsigned int max_stride = intel_plane_fb_max_stride(dev_priv,
> +								    fb->format->format,
> +								    fb->modifier);
>  
>  		/*
>  		 * To make remapping with linear generally feasible
> @@ -2061,7 +2060,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
>  	drm_helper_mode_fill_fb_struct(&dev_priv->drm, fb, mode_cmd);
>  
>  	for (i = 0; i < fb->format->num_planes; i++) {
> -		u32 stride_alignment;
> +		unsigned int stride_alignment;
>  
>  		if (mode_cmd->handles[i] != mode_cmd->handles[0]) {
>  			drm_dbg_kms(&dev_priv->drm, "bad plane %d handle\n",
> @@ -2078,7 +2077,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
>  		}
>  
>  		if (intel_fb_is_gen12_ccs_aux_plane(fb, i)) {
> -			int ccs_aux_stride = gen12_ccs_aux_stride(intel_fb, i);
> +			unsigned int ccs_aux_stride = gen12_ccs_aux_stride(intel_fb, i);
>  
>  			if (fb->pitches[i] != ccs_aux_stride) {
>  				drm_dbg_kms(&dev_priv->drm,
> diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c b/drivers/gpu/drm/i915/display/intel_fb_pin.c
> index 5b71d9488184..041f09f76628 100644
> --- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
> +++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
> @@ -113,9 +113,9 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
>  	struct drm_i915_gem_object *obj = intel_fb_obj(fb);
>  	intel_wakeref_t wakeref;
>  	struct i915_gem_ww_ctx ww;
> +	unsigned int alignment;
>  	struct i915_vma *vma;
>  	unsigned int pinctl;
> -	u32 alignment;
>  	int ret;
>  
>  	if (drm_WARN_ON(dev, !i915_gem_object_is_framebuffer(obj)))
> diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> index b8103d6ebc1f..24f90368d344 100644
> --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> @@ -1619,7 +1619,7 @@ skl_check_main_ccs_coordinates(struct intel_plane_state *plane_state,
>  	int aux_x = plane_state->view.color_plane[ccs_plane].x;
>  	int aux_y = plane_state->view.color_plane[ccs_plane].y;
>  	u32 aux_offset = plane_state->view.color_plane[ccs_plane].offset;
> -	u32 alignment = intel_surf_alignment(fb, ccs_plane);
> +	unsigned int alignment = intel_surf_alignment(fb, ccs_plane);
>  	int hsub;
>  	int vsub;
>  
> @@ -1639,8 +1639,7 @@ skl_check_main_ccs_coordinates(struct intel_plane_state *plane_state,
>  							       plane_state,
>  							       ccs_plane,
>  							       aux_offset,
> -							       aux_offset -
> -								alignment);
> +							       aux_offset - alignment);
>  		aux_x = x * hsub + aux_x % hsub;
>  		aux_y = y * vsub + aux_y % vsub;
>  	}
> @@ -1662,10 +1661,10 @@ int skl_calc_main_surface_offset(const struct intel_plane_state *plane_state,
>  	struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
>  	struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
>  	const struct drm_framebuffer *fb = plane_state->hw.fb;
> -	const int aux_plane = skl_main_to_aux_plane(fb, 0);
> -	const u32 aux_offset = plane_state->view.color_plane[aux_plane].offset;
> -	const u32 alignment = intel_surf_alignment(fb, 0);
> -	const int w = drm_rect_width(&plane_state->uapi.src) >> 16;
> +	int aux_plane = skl_main_to_aux_plane(fb, 0);
> +	u32 aux_offset = plane_state->view.color_plane[aux_plane].offset;
> +	unsigned int alignment = intel_surf_alignment(fb, 0);
> +	int w = drm_rect_width(&plane_state->uapi.src) >> 16;
>  
>  	intel_add_fb_offsets(x, y, plane_state, 0);
>  	*offset = intel_plane_compute_aligned_offset(x, y, plane_state, 0);
> @@ -1715,13 +1714,13 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state)
>  	const unsigned int rotation = plane_state->hw.rotation;
>  	int x = plane_state->uapi.src.x1 >> 16;
>  	int y = plane_state->uapi.src.y1 >> 16;
> -	const int w = drm_rect_width(&plane_state->uapi.src) >> 16;
> -	const int h = drm_rect_height(&plane_state->uapi.src) >> 16;
> -	const int min_width = intel_plane_min_width(plane, fb, 0, rotation);
> -	const int max_width = intel_plane_max_width(plane, fb, 0, rotation);
> -	const int max_height = intel_plane_max_height(plane, fb, 0, rotation);
> -	const int aux_plane = skl_main_to_aux_plane(fb, 0);
> -	const u32 alignment = intel_surf_alignment(fb, 0);
> +	int w = drm_rect_width(&plane_state->uapi.src) >> 16;
> +	int h = drm_rect_height(&plane_state->uapi.src) >> 16;
> +	int min_width = intel_plane_min_width(plane, fb, 0, rotation);
> +	int max_width = intel_plane_max_width(plane, fb, 0, rotation);
> +	int max_height = intel_plane_max_height(plane, fb, 0, rotation);
> +	unsigned int alignment = intel_surf_alignment(fb, 0);
> +	int aux_plane = skl_main_to_aux_plane(fb, 0);
>  	u32 offset;
>  	int ret;
>  
> @@ -1809,7 +1808,7 @@ static int skl_check_nv12_aux_surface(struct intel_plane_state *plane_state)
>  
>  	if (ccs_plane) {
>  		u32 aux_offset = plane_state->view.color_plane[ccs_plane].offset;
> -		u32 alignment = intel_surf_alignment(fb, uv_plane);
> +		unsigned int alignment = intel_surf_alignment(fb, uv_plane);
>  
>  		if (offset > aux_offset)
>  			offset = intel_plane_adjust_aligned_offset(&x, &y,

-- 
Jani Nikula, Intel


More information about the Intel-gfx mailing list