[PATCH i-g-t] lib/igt_fb: Fix intel_buf surface init

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Fri Oct 4 11:00:43 UTC 2024


For flat ccs case I don't think buf->ccs[] would become filled because 
it should later cause gpu fault if aux stuff is present in render batch 
w/ flat ccs.

Anyway the change look good
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>

On 24.9.2024 0.36, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> The current coed is populating buf->ccs[] and buf->surface[]
> in a rather inconsistent way.
> 
> It looks like for flat CCS platforms:
> - we populate buf->ccs[] with some nonsense even though
>    we shouldn't since the AUX stuff is completely hidden by
>    the hardware
> - we seem to stick data about the clear color into both
>    both buf->ccs[] and buf->surfaces[] when it should be in neither
> 
> For non-flat CCS platforms the code seems more reasonable,
> except it only manages to skip the clear color fumble by
> the fact that num_planes is always odd with clear color
> and thus the /2 will truncate it away.
> 
> Anyways, let's make the code make actual sense for all platforms
> by properly calculating how many main surfaces and ccs surfaces
> there should be.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>   lib/igt_fb.c | 42 +++++++++++++++++++++++++++++++++++-------
>   1 file changed, 35 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index b8ffd7cfb261..6deb2a221df6 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -2636,6 +2636,35 @@ static int yuv_semiplanar_bpp(uint32_t drm_format)
>   	}
>   }
>   
> +static int intel_num_surfaces(const struct igt_fb *fb)
> +{
> +	int num_surfaces;
> +
> +	if (!igt_fb_is_ccs_modifier(fb->modifier))
> +		return fb->num_planes;
> +
> +	num_surfaces = fb->num_planes;
> +
> +	if (igt_fb_is_gen12_rc_ccs_cc_modifier(fb->modifier))
> +		num_surfaces--;
> +
> +	if (!HAS_FLATCCS(intel_get_drm_devid(fb->fd)))
> +		num_surfaces /= 2;
> +
> +	return num_surfaces;
> +}
> +
> +static int intel_num_ccs_surfaces(const struct igt_fb *fb)
> +{
> +	if (!igt_fb_is_ccs_modifier(fb->modifier))
> +		return 0;
> +
> +	if (HAS_FLATCCS(intel_get_drm_devid(fb->fd)))
> +		return 0;
> +
> +	return intel_num_surfaces(fb);
> +}
> +
>   struct intel_buf *
>   igt_fb_create_intel_buf(int fd, struct buf_ops *bops,
>                           const struct igt_fb *fb,
> @@ -2705,13 +2734,12 @@ igt_fb_create_intel_buf(int fd, struct buf_ops *bops,
>   	if (buf->format_is_yuv_semiplanar)
>   		buf->yuv_semiplanar_bpp = yuv_semiplanar_bpp(fb->drm_format);
>   
> -	if (igt_fb_is_ccs_modifier(fb->modifier)) {
> -		num_surfaces = fb->num_planes / (HAS_FLATCCS(intel_get_drm_devid(fb->fd)) ? 1 : 2);
> -		for (i = 0; i < num_surfaces; i++)
> -			init_buf_ccs(buf, i,
> -				     fb->offsets[num_surfaces + i],
> -				     fb->strides[num_surfaces + i]);
> -	}
> +	num_surfaces = intel_num_surfaces(fb);
> +
> +	for (i = 0; i < intel_num_ccs_surfaces(fb); i++)
> +		init_buf_ccs(buf, i,
> +			     fb->offsets[num_surfaces + i],
> +			     fb->strides[num_surfaces + i]);
>   
>   	igt_assert(fb->offsets[0] == 0);
>   	for (i = 0; i < num_surfaces; i++) {



More information about the igt-dev mailing list