Skip to content

Commit 95357b6

Browse files
committed
drm/i915: Pass drm_format_info into plane->max_stride()
Pass the format info into plane->max_stride() from the caller instead of doing yet another drm_format_info() lookup on the spot. drm_format_info() is both rather expensive, and technically incorrect since it doesn't return the correct format info for compressed formats (though that doesn't actually matter for the current .max_stride() implementations since they are just interested in the cpp value). Most callers already have the format info available. The only exception is intel_dumb_fb_max_stride() where we shall use the actually correct drm_get_format_info() variant. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patch.msgid.link/20251107181126.5743-3-ville.syrjala@linux.intel.com Reviewed-by: Jani Nikula <jani.nikula@intel.com>
1 parent 854efdc commit 95357b6

9 files changed

Lines changed: 47 additions & 47 deletions

File tree

drivers/gpu/drm/i915/display/i9xx_plane.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,9 @@ static bool i9xx_plane_get_hw_state(struct intel_plane *plane,
754754

755755
static unsigned int
756756
hsw_primary_max_stride(struct intel_plane *plane,
757-
u32 pixel_format, u64 modifier,
758-
unsigned int rotation)
757+
const struct drm_format_info *info,
758+
u64 modifier, unsigned int rotation)
759759
{
760-
const struct drm_format_info *info = drm_format_info(pixel_format);
761760
int cpp = info->cpp[0];
762761

763762
/* Limit to 8k pixels to guarantee OFFSET.x doesn't get too big. */
@@ -766,10 +765,9 @@ hsw_primary_max_stride(struct intel_plane *plane,
766765

767766
static unsigned int
768767
ilk_primary_max_stride(struct intel_plane *plane,
769-
u32 pixel_format, u64 modifier,
770-
unsigned int rotation)
768+
const struct drm_format_info *info,
769+
u64 modifier, unsigned int rotation)
771770
{
772-
const struct drm_format_info *info = drm_format_info(pixel_format);
773771
int cpp = info->cpp[0];
774772

775773
/* Limit to 4k pixels to guarantee TILEOFF.x doesn't get too big. */
@@ -781,10 +779,9 @@ ilk_primary_max_stride(struct intel_plane *plane,
781779

782780
unsigned int
783781
i965_plane_max_stride(struct intel_plane *plane,
784-
u32 pixel_format, u64 modifier,
785-
unsigned int rotation)
782+
const struct drm_format_info *info,
783+
u64 modifier, unsigned int rotation)
786784
{
787-
const struct drm_format_info *info = drm_format_info(pixel_format);
788785
int cpp = info->cpp[0];
789786

790787
/* Limit to 4k pixels to guarantee TILEOFF.x doesn't get too big. */
@@ -796,8 +793,8 @@ i965_plane_max_stride(struct intel_plane *plane,
796793

797794
static unsigned int
798795
i915_plane_max_stride(struct intel_plane *plane,
799-
u32 pixel_format, u64 modifier,
800-
unsigned int rotation)
796+
const struct drm_format_info *info,
797+
u64 modifier, unsigned int rotation)
801798
{
802799
if (modifier == I915_FORMAT_MOD_X_TILED)
803800
return 8 * 1024;
@@ -807,8 +804,8 @@ i915_plane_max_stride(struct intel_plane *plane,
807804

808805
static unsigned int
809806
i8xx_plane_max_stride(struct intel_plane *plane,
810-
u32 pixel_format, u64 modifier,
811-
unsigned int rotation)
807+
const struct drm_format_info *info,
808+
u64 modifier, unsigned int rotation)
812809
{
813810
if (plane->i9xx_plane == PLANE_C)
814811
return 4 * 1024;

drivers/gpu/drm/i915/display/i9xx_plane.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/types.h>
1010

1111
enum pipe;
12+
struct drm_format_info;
1213
struct drm_framebuffer;
1314
struct intel_crtc;
1415
struct intel_display;
@@ -18,8 +19,8 @@ struct intel_plane_state;
1819

1920
#ifdef I915
2021
unsigned int i965_plane_max_stride(struct intel_plane *plane,
21-
u32 pixel_format, u64 modifier,
22-
unsigned int rotation);
22+
const struct drm_format_info *info,
23+
u64 modifier, unsigned int rotation);
2324
unsigned int vlv_plane_min_alignment(struct intel_plane *plane,
2425
const struct drm_framebuffer *fb,
2526
int colot_plane);

drivers/gpu/drm/i915/display/intel_cursor.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ static int intel_check_cursor(struct intel_crtc_state *crtc_state,
182182

183183
static unsigned int
184184
i845_cursor_max_stride(struct intel_plane *plane,
185-
u32 pixel_format, u64 modifier,
186-
unsigned int rotation)
185+
const struct drm_format_info *info,
186+
u64 modifier, unsigned int rotation)
187187
{
188188
return 2048;
189189
}
@@ -343,8 +343,8 @@ static bool i845_cursor_get_hw_state(struct intel_plane *plane,
343343

344344
static unsigned int
345345
i9xx_cursor_max_stride(struct intel_plane *plane,
346-
u32 pixel_format, u64 modifier,
347-
unsigned int rotation)
346+
const struct drm_format_info *info,
347+
u64 modifier, unsigned int rotation)
348348
{
349349
return plane->base.dev->mode_config.cursor_width * 4;
350350
}

drivers/gpu/drm/i915/display/intel_display.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ void intel_disable_transcoder(const struct intel_crtc_state *old_crtc_state)
548548
}
549549

550550
u32 intel_plane_fb_max_stride(struct intel_display *display,
551-
u32 pixel_format, u64 modifier)
551+
const struct drm_format_info *info,
552+
u64 modifier)
552553
{
553554
struct intel_crtc *crtc;
554555
struct intel_plane *plane;
@@ -564,7 +565,7 @@ u32 intel_plane_fb_max_stride(struct intel_display *display,
564565

565566
plane = to_intel_plane(crtc->base.primary);
566567

567-
return plane->max_stride(plane, pixel_format, modifier,
568+
return plane->max_stride(plane, info, modifier,
568569
DRM_MODE_ROTATE_0);
569570
}
570571

@@ -576,7 +577,9 @@ u32 intel_dumb_fb_max_stride(struct drm_device *drm,
576577
if (!HAS_DISPLAY(display))
577578
return 0;
578579

579-
return intel_plane_fb_max_stride(display, pixel_format, modifier);
580+
return intel_plane_fb_max_stride(display,
581+
drm_get_format_info(drm, pixel_format, modifier),
582+
modifier);
580583
}
581584

582585
void intel_set_plane_visible(struct intel_crtc_state *crtc_state,

drivers/gpu/drm/i915/display/intel_display.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct drm_atomic_state;
3434
struct drm_device;
3535
struct drm_display_mode;
3636
struct drm_encoder;
37+
struct drm_format_info;
3738
struct drm_modeset_acquire_ctx;
3839
struct intel_atomic_state;
3940
struct intel_crtc;
@@ -403,7 +404,8 @@ void intel_link_compute_m_n(u16 bpp, int nlanes,
403404
int bw_overhead,
404405
struct intel_link_m_n *m_n);
405406
u32 intel_plane_fb_max_stride(struct intel_display *display,
406-
u32 pixel_format, u64 modifier);
407+
const struct drm_format_info *info,
408+
u64 modifier);
407409
u32 intel_dumb_fb_max_stride(struct drm_device *drm,
408410
u32 pixel_format, u64 modifier);
409411
enum drm_mode_status

drivers/gpu/drm/i915/display/intel_display_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,8 @@ struct intel_plane {
15641564
const struct drm_framebuffer *fb,
15651565
int color_plane);
15661566
unsigned int (*max_stride)(struct intel_plane *plane,
1567-
u32 pixel_format, u64 modifier,
1568-
unsigned int rotation);
1567+
const struct drm_format_info *info,
1568+
u64 modifier, unsigned int rotation);
15691569
bool (*can_async_flip)(u64 modifier);
15701570
/* Write all non-self arming plane registers */
15711571
void (*update_noarm)(struct intel_dsb *dsb,

drivers/gpu/drm/i915/display/intel_fb.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ static bool intel_plane_needs_remap(const struct intel_plane_state *plane_state)
13261326
* unclear in Bspec, for now no checking.
13271327
*/
13281328
stride = intel_fb_pitch(fb, 0, rotation);
1329-
max_stride = plane->max_stride(plane, fb->base.format->format,
1329+
max_stride = plane->max_stride(plane, fb->base.format,
13301330
fb->base.modifier, rotation);
13311331

13321332
return stride > max_stride;
@@ -1972,7 +1972,8 @@ void intel_add_fb_offsets(int *x, int *y,
19721972

19731973
static
19741974
u32 intel_fb_max_stride(struct intel_display *display,
1975-
u32 pixel_format, u64 modifier)
1975+
const struct drm_format_info *info,
1976+
u64 modifier)
19761977
{
19771978
/*
19781979
* Arbitrary limit for gen4+ chosen to match the
@@ -1982,7 +1983,7 @@ u32 intel_fb_max_stride(struct intel_display *display,
19821983
*/
19831984
if (DISPLAY_VER(display) < 4 || intel_fb_is_ccs_modifier(modifier) ||
19841985
intel_fb_modifier_uses_dpt(display, modifier))
1985-
return intel_plane_fb_max_stride(display, pixel_format, modifier);
1986+
return intel_plane_fb_max_stride(display, info, modifier);
19861987
else if (DISPLAY_VER(display) >= 7)
19871988
return 256 * 1024;
19881989
else
@@ -1997,7 +1998,7 @@ intel_fb_stride_alignment(const struct drm_framebuffer *fb, int color_plane)
19971998

19981999
if (is_surface_linear(fb, color_plane)) {
19992000
unsigned int max_stride = intel_plane_fb_max_stride(display,
2000-
fb->format->format,
2001+
fb->format,
20012002
fb->modifier);
20022003

20032004
/*
@@ -2055,7 +2056,7 @@ static int intel_plane_check_stride(const struct intel_plane_state *plane_state)
20552056

20562057
/* FIXME other color planes? */
20572058
stride = plane_state->view.color_plane[0].mapping_stride;
2058-
max_stride = plane->max_stride(plane, fb->format->format,
2059+
max_stride = plane->max_stride(plane, fb->format,
20592060
fb->modifier, rotation);
20602061

20612062
if (stride > max_stride) {
@@ -2243,8 +2244,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
22432244
goto err_bo_framebuffer_fini;
22442245
}
22452246

2246-
max_stride = intel_fb_max_stride(display, mode_cmd->pixel_format,
2247-
mode_cmd->modifier[0]);
2247+
max_stride = intel_fb_max_stride(display, info, mode_cmd->modifier[0]);
22482248
if (mode_cmd->pitches[0] > max_stride) {
22492249
drm_dbg_kms(display->drm,
22502250
"%s pitch (%u) must be at most %d\n",

drivers/gpu/drm/i915/display/intel_sprite.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,9 @@ static int g4x_sprite_min_cdclk(const struct intel_crtc_state *crtc_state,
958958

959959
static unsigned int
960960
g4x_sprite_max_stride(struct intel_plane *plane,
961-
u32 pixel_format, u64 modifier,
962-
unsigned int rotation)
961+
const struct drm_format_info *info,
962+
u64 modifier, unsigned int rotation)
963963
{
964-
const struct drm_format_info *info = drm_format_info(pixel_format);
965964
int cpp = info->cpp[0];
966965

967966
/* Limit to 4k pixels to guarantee TILEOFF.x doesn't get too big. */
@@ -973,10 +972,9 @@ g4x_sprite_max_stride(struct intel_plane *plane,
973972

974973
static unsigned int
975974
hsw_sprite_max_stride(struct intel_plane *plane,
976-
u32 pixel_format, u64 modifier,
977-
unsigned int rotation)
975+
const struct drm_format_info *info,
976+
u64 modifier, unsigned int rotation)
978977
{
979-
const struct drm_format_info *info = drm_format_info(pixel_format);
980978
int cpp = info->cpp[0];
981979

982980
/* Limit to 8k pixels to guarantee OFFSET.x doesn't get too big. */

drivers/gpu/drm/i915/display/skl_universal_plane.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,11 @@ static int icl_plane_max_height(const struct drm_framebuffer *fb,
465465

466466
static unsigned int
467467
plane_max_stride(struct intel_plane *plane,
468-
u32 pixel_format, u64 modifier,
469-
unsigned int rotation,
468+
const struct drm_format_info *info,
469+
u64 modifier, unsigned int rotation,
470470
unsigned int max_pixels,
471471
unsigned int max_bytes)
472472
{
473-
const struct drm_format_info *info = drm_format_info(pixel_format);
474473
int cpp = info->cpp[0];
475474

476475
if (drm_rotation_90_or_270(rotation))
@@ -481,26 +480,26 @@ plane_max_stride(struct intel_plane *plane,
481480

482481
static unsigned int
483482
adl_plane_max_stride(struct intel_plane *plane,
484-
u32 pixel_format, u64 modifier,
485-
unsigned int rotation)
483+
const struct drm_format_info *info,
484+
u64 modifier, unsigned int rotation)
486485
{
487486
unsigned int max_pixels = 65536; /* PLANE_OFFSET limit */
488487
unsigned int max_bytes = 128 * 1024;
489488

490-
return plane_max_stride(plane, pixel_format,
489+
return plane_max_stride(plane, info,
491490
modifier, rotation,
492491
max_pixels, max_bytes);
493492
}
494493

495494
static unsigned int
496495
skl_plane_max_stride(struct intel_plane *plane,
497-
u32 pixel_format, u64 modifier,
498-
unsigned int rotation)
496+
const struct drm_format_info *info,
497+
u64 modifier, unsigned int rotation)
499498
{
500499
unsigned int max_pixels = 8192; /* PLANE_OFFSET limit */
501500
unsigned int max_bytes = 32 * 1024;
502501

503-
return plane_max_stride(plane, pixel_format,
502+
return plane_max_stride(plane, info,
504503
modifier, rotation,
505504
max_pixels, max_bytes);
506505
}

0 commit comments

Comments
 (0)