Skip to content

Commit 1b6b032

Browse files
committed
drm/i915: Shrink the size of intel_remapped_plane_info struct
Save some place in the GTT VMAs by using a u16 instead of unsigned int to store the view dimensions. The maximum FB stride is 256kB which is 4096 tiles in the worst case (yf-tiles), the maximum FB height is 16k pixels, which is 16384 tiles in the worst case (linear 4x1 tiled FB). v2: - Fix worst case tile height formula in commit log. (Ville) - Add an assign_chk_ovf helper to simplify the related assignments. v3: - Enclose params of the assign_chk_ovf macro in parentheses. Signed-off-by: Imre Deak <[email protected]> Reviewed-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 23c87dc commit 1b6b032

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,11 @@ plane_view_height_tiles(const struct intel_framebuffer *fb, int color_plane,
613613
return DIV_ROUND_UP(y + dims->height, dims->tile_height);
614614
}
615615

616+
#define assign_chk_ovf(i915, var, val) ({ \
617+
drm_WARN_ON(&(i915)->drm, overflows_type(val, var)); \
618+
(var) = (val); \
619+
})
620+
616621
static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_plane,
617622
const struct fb_plane_view_dims *dims,
618623
u32 obj_offset, u32 gtt_offset, int x, int y,
@@ -627,10 +632,10 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p
627632
unsigned int pitch_tiles;
628633
struct drm_rect r;
629634

630-
remap_info->offset = obj_offset;
631-
remap_info->stride = plane_view_stride_tiles(fb, color_plane, dims);
632-
remap_info->width = plane_view_width_tiles(fb, color_plane, dims, x);
633-
remap_info->height = plane_view_height_tiles(fb, color_plane, dims, y);
635+
assign_chk_ovf(i915, remap_info->offset, obj_offset);
636+
assign_chk_ovf(i915, remap_info->stride, plane_view_stride_tiles(fb, color_plane, dims));
637+
assign_chk_ovf(i915, remap_info->width, plane_view_width_tiles(fb, color_plane, dims, x));
638+
assign_chk_ovf(i915, remap_info->height, plane_view_height_tiles(fb, color_plane, dims, y));
634639

635640
if (view->gtt.type == I915_GGTT_VIEW_ROTATED) {
636641
check_array_bounds(i915, view->gtt.rotated.plane, color_plane);
@@ -676,6 +681,8 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p
676681
return remap_info->width * remap_info->height;
677682
}
678683

684+
#undef assign_chk_ovf
685+
679686
/* Return number of tiles @color_plane needs. */
680687
static unsigned int
681688
calc_plane_normal_size(const struct intel_framebuffer *fb, int color_plane,

drivers/gpu/drm/i915/i915_vma_types.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,16 @@ enum i915_cache_level;
9797

9898
struct intel_remapped_plane_info {
9999
/* in gtt pages */
100-
unsigned int width, height, stride, offset;
100+
u32 offset;
101+
u16 width;
102+
u16 height;
103+
u16 stride;
104+
u16 unused_mbz;
101105
} __packed;
102106

103107
struct intel_remapped_info {
104108
struct intel_remapped_plane_info plane[2];
105-
unsigned int unused_mbz;
109+
u32 unused_mbz;
106110
} __packed;
107111

108112
struct intel_rotation_info {
@@ -123,9 +127,9 @@ enum i915_ggtt_view_type {
123127

124128
static inline void assert_i915_gem_gtt_types(void)
125129
{
126-
BUILD_BUG_ON(sizeof(struct intel_rotation_info) != 8*sizeof(unsigned int));
130+
BUILD_BUG_ON(sizeof(struct intel_rotation_info) != 2 * sizeof(u32) + 8 * sizeof(u16));
127131
BUILD_BUG_ON(sizeof(struct intel_partial_info) != sizeof(u64) + sizeof(unsigned int));
128-
BUILD_BUG_ON(sizeof(struct intel_remapped_info) != 9*sizeof(unsigned int));
132+
BUILD_BUG_ON(sizeof(struct intel_remapped_info) != 3 * sizeof(u32) + 8 * sizeof(u16));
129133

130134
/* Check that rotation/remapped shares offsets for simplicity */
131135
BUILD_BUG_ON(offsetof(struct intel_remapped_info, plane[0]) !=

0 commit comments

Comments
 (0)