Skip to content

Commit f61289a

Browse files
vsrini4rodrigovivi
authored andcommitted
drm/i915/display: Fix NV12 ceiling division for bigjoiner case
Commit 16df4cc ("drm/i915/display: Use ceiling division for NV12 UV surface offset calculation") computes the UV (chroma) surface start/size as ceiling(half of Y plane start/size) directly from the U16.16 fixed-point source rectangle: x = fp_16_16_to_int_ceil(fp_16_16_div2(src.x1)); For a single pipe the source coordinates are integers, so this is correct. (UV start = ceiling(half of Y plane start)). With bigjoiner + a plane scaler the picture changes. The pipe boundary is a fixed integer destination pixel, but the plane's position and the scaler ratio are arbitrary, so drm_rect_clip_scaled() maps the seam back to a *fractional* per-pipe source. For a 1280->2407 upscaled NV12 plane crossing the seam: master src: width = 1204 * 1280/2407 = 640.265899, x1 = 0 joiner src: width = 1203 * 1280/2407 = 639.734115, x1 = 640.265884 The luma path floors this to an integer (src.x1 >> 16 = 640), but the UV path takes ceiling(640.265884 / 2) = ceil(320.13) = 321. The Y plane then starts at column 640 while the UV plane starts at 321*2 = 642, pushing the chroma read one column past the 640-wide chroma surface on the joiner secondary: [CRTC:382:pipe C] PLANE ATS fault [CRTC:382:pipe C][PLANE:267:plane 1C] fault (CTL=0x81009400, ...) The spec "Y plane start" is the integer pixel the luma surface actually programs (640), not the pre-floor fixed-point value (640.27). Convert the Y plane start/size to integer first - matching skl_check_main_surface() - and then apply the ceiling. This is a no-op for the integer (non-joiner) case and yields the correct, in-bounds chroma offset for the fractional joiner seam: before fix after fix master 1B: x=0 w=321 x=0 w=320 -> [0, 320) slave 1C: x=321 w=320 x=320 w=320 -> [320, 640) The two halves now tile the 640-wide chroma plane exactly and the ATS fault is gone. Assisted-by: GitHub-Copilot:Claude-Opus-4.8 Fixes: 16df4cc ("drm/i915/display: Use ceiling division for NV12 UV surface offset calculation") Signed-off-by: Vidya Srinivas <vidya.srinivas@intel.com> Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Signed-off-by: Uma Shankar <uma.shankar@intel.com> Link: https://patch.msgid.link/20260618181837.687302-1-vidya.srinivas@intel.com (cherry picked from commit 0c59cc7) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent a82f1bb commit f61289a

1 file changed

Lines changed: 13 additions & 20 deletions

File tree

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

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,19 +2126,6 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state)
21262126
return 0;
21272127
}
21282128

2129-
2130-
/* Divide a U16.16 fixed-point value by 2, staying in fixed-point domain */
2131-
static inline u32 fp_16_16_div2(u32 fp)
2132-
{
2133-
return fp >> 1;
2134-
}
2135-
2136-
/* Convert a U16.16 fixed-point value to integer, rounding up */
2137-
static inline int fp_16_16_to_int_ceil(u32 fp)
2138-
{
2139-
return DIV_ROUND_UP(fp, 1 << 16);
2140-
}
2141-
21422129
static int skl_check_nv12_aux_surface(struct intel_plane_state *plane_state)
21432130
{
21442131
struct intel_display *display = to_intel_display(plane_state);
@@ -2154,14 +2141,20 @@ static int skl_check_nv12_aux_surface(struct intel_plane_state *plane_state)
21542141
int max_height = intel_plane_max_height(plane, fb, uv_plane, rotation);
21552142

21562143
/*
2157-
* LNL+ UV surface start/size =
2158-
* ceiling(half of Y plane start/size). Use ceiling division
2159-
* unconditionally; it is a no-op for even values.
2144+
* UV (chroma) start/size = ceiling(half of the *integer* Y plane
2145+
* start/size), i.e. the value the luma surface programs (src >> 16),
2146+
* not the raw U16.16. A bigjoiner seam mapped through the scaler can
2147+
* give a fractional luma src; ceiling that directly would round the
2148+
* chroma one column too far and read past the chroma surface.
21602149
*/
2161-
int x = fp_16_16_to_int_ceil(fp_16_16_div2(plane_state->uapi.src.x1));
2162-
int y = fp_16_16_to_int_ceil(fp_16_16_div2(plane_state->uapi.src.y1));
2163-
int w = fp_16_16_to_int_ceil(fp_16_16_div2(drm_rect_width(&plane_state->uapi.src)));
2164-
int h = fp_16_16_to_int_ceil(fp_16_16_div2(drm_rect_height(&plane_state->uapi.src)));
2150+
int luma_x = plane_state->uapi.src.x1 >> 16;
2151+
int luma_y = plane_state->uapi.src.y1 >> 16;
2152+
int luma_w = drm_rect_width(&plane_state->uapi.src) >> 16;
2153+
int luma_h = drm_rect_height(&plane_state->uapi.src) >> 16;
2154+
int x = DIV_ROUND_UP(luma_x, 2);
2155+
int y = DIV_ROUND_UP(luma_y, 2);
2156+
int w = DIV_ROUND_UP(luma_x + luma_w, 2) - x;
2157+
int h = DIV_ROUND_UP(luma_y + luma_h, 2) - y;
21652158
u32 offset;
21662159

21672160
/* FIXME not quite sure how/if these apply to the chroma plane */

0 commit comments

Comments
 (0)