From: Jani Nikula <jani.nikula@linux.intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 5/9] drm/i915: Polish types in fb calculations
Date: Mon, 06 May 2024 17:07:55 +0300 [thread overview]
Message-ID: <87v83rkp8k.fsf@intel.com> (raw)
In-Reply-To: <20240506125718.26001-6-ville.syrjala@linux.intel.com>
On Mon, 06 May 2024, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@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@intel.com>
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@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
next prev parent reply other threads:[~2024-05-06 14:08 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 12:57 [PATCH 0/9] drm/i915: Plane fb refactoring Ville Syrjala
2024-05-06 12:57 ` [PATCH 1/9] drm/i915: Split gen2 vs. gen3 .max_stride() Ville Syrjala
2024-05-06 13:57 ` Jani Nikula
2024-05-06 12:57 ` [PATCH 2/9] drm/i915: Clean up skl+ plane stride limits Ville Syrjala
2024-05-06 14:03 ` Jani Nikula
2024-05-06 16:38 ` Ville Syrjälä
2024-05-07 9:02 ` Jani Nikula
2024-05-06 12:57 ` [PATCH 3/9] drm/i915: Drop 'uses_fence' parameter from intel_pin_fb_obj_dpt() Ville Syrjala
2024-05-06 14:04 ` Jani Nikula
2024-05-06 12:57 ` [PATCH 4/9] drm/i915: Extract intel_plane_needs_physical() Ville Syrjala
2024-05-06 14:05 ` Jani Nikula
2024-05-06 12:57 ` [PATCH 5/9] drm/i915: Polish types in fb calculations Ville Syrjala
2024-05-06 14:07 ` Jani Nikula [this message]
2024-05-06 12:57 ` [PATCH 6/9] drm/i915: Constify 'fb' in during pinning Ville Syrjala
2024-05-06 14:11 ` Jani Nikula
2024-05-06 12:57 ` [PATCH 7/9] drm/i915: Change intel_fbdev_fb_alloc() reuturn type Ville Syrjala
2024-05-06 14:16 ` Jani Nikula
2024-05-06 16:51 ` Ville Syrjälä
2024-05-06 18:19 ` Ville Syrjälä
2024-05-10 10:22 ` [PATCH v2 7/9] drm/i915: Change intel_fbdev_fb_alloc() return type Ville Syrjala
2024-05-10 11:30 ` Jani Nikula
2024-05-06 12:57 ` [PATCH 8/9] drm/i915: Cleanup fbdev fb setup Ville Syrjala
2024-05-10 10:22 ` [PATCH v2 " Ville Syrjala
2024-05-10 11:32 ` Jani Nikula
2024-05-06 12:57 ` [PATCH 9/9] drm/i915: Rename the fb pinning functions to indicate the address space Ville Syrjala
2024-05-10 11:35 ` Jani Nikula
2024-05-06 13:34 ` ✗ Fi.CI.SPARSE: warning for drm/i915: Plane fb refactoring Patchwork
2024-05-06 13:42 ` ✓ Fi.CI.BAT: success " Patchwork
2024-05-06 18:13 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-05-10 12:37 ` ✓ Fi.CI.BAT: success for drm/i915: Plane fb refactoring (rev3) Patchwork
2024-05-10 16:55 ` [PATCH 0/9] drm/i915: Plane fb refactoring Ville Syrjälä
2024-05-11 19:00 ` Lucas De Marchi
2024-05-11 4:12 ` ✗ Fi.CI.IGT: failure for drm/i915: Plane fb refactoring (rev3) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v83rkp8k.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).