Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/i915/dp: missing PCON and sink DSC capability checks in
  compute
--

commit 436e850e3ddf87d0b01bc7a145ea30594fd044f0
Author: Ankit Nautiyal <[email protected]>

drm/i915/dp: Compute the PCON DSC encoder parameters

This commit moves computation of the PCON DSC encoder slice height, slice
width, and compressed bpp from enable time to compute config, storing the
parameters in the crtc state for intel_dp_pcon_dsc_configure() to program.

> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
> b/drivers/gpu/drm/i915/display/intel_dp.c
> index ca218481182fd..272837cc6efa4 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -1232,6 +1232,69 @@ intel_dp_pcon_sink_support_frl(struct intel_dp 
> *intel_dp)
>               intel_dp_hdmi_sink_max_frl(intel_dp);
>  }
>  
> +static bool intel_dp_pcon_can_encode_dsc(struct intel_dp *intel_dp)
> +{
> +     struct intel_connector *connector = intel_dp->attached_connector;
> +
> +     return intel_dp_is_hdmi_2_1_sink(intel_dp) &&
> +             connector->base.display_info.hdmi.dsc_cap.v_1p2 &&
> +             drm_dp_pcon_enc_is_dsc_1_2(intel_dp->pcon_dsc_dpcd);
> +}
> +
> +/*
> + * Compute the PCON DSC encoder parameters for the stream sent to the HDMI
> + * sink, which is in @sink_format. @enc can be NULL to only check 
> feasibility.
> + */
> +static bool
> +intel_dp_pcon_dsc_enc_compute(struct intel_dp *intel_dp,
> +                           const struct drm_display_mode *mode, int 
> pixel_clock,
> +                           int bpc, enum intel_output_format sink_format,
> +                           struct intel_pcon_dsc_enc_config *enc)
> +{
> +     struct intel_connector *connector = intel_dp->attached_connector;
> +     const struct drm_display_info *info = &connector->base.display_info;
> +     int pcon_max_slices = 
> drm_dp_pcon_dsc_max_slices(intel_dp->pcon_dsc_dpcd);
> +     int pcon_max_slice_width = 
> drm_dp_pcon_dsc_max_slice_width(intel_dp->pcon_dsc_dpcd);
> +     int slice_height, num_slices, slice_width, max_link_dsc_bpp, bpp_x16;
> +
> +     if (!intel_dp_pcon_can_encode_dsc(intel_dp))
> +             return false;
> +
> +     slice_height = intel_hdmi_dsc_get_slice_height(mode->vdisplay);
> +     if (!slice_height)
> +             return false;
> +
> +     num_slices = intel_hdmi_dsc_get_num_slices(mode, pixel_clock, 
> sink_format,
> +                                                pcon_max_slices, 
> pcon_max_slice_width,
> +                                                
> info->hdmi.dsc_cap.max_slices,
> +                                                
> info->hdmi.dsc_cap.clk_per_slice);
> +     if (!num_slices)
> +             return false;
> +
> +     slice_width = DIV_ROUND_UP(mode->hdisplay, num_slices);
> +
> +     /* The compressed stream has to fit the FRL link */
> +     max_link_dsc_bpp = intel_dp_hdmi_frl_payload_bw(intel_dp) / pixel_clock;
> +     if (!max_link_dsc_bpp)
> +             return false;
> +
> +     bpp_x16 = 
> intel_hdmi_dsc_get_bpp(drm_dp_pcon_dsc_bpp_incr(intel_dp->pcon_dsc_dpcd),
> +                                      slice_width, num_slices, sink_format, 
> bpc,
> +                                      info->hdmi.dsc_cap.all_bpp,
> +                                      info->hdmi.dsc_cap.total_chunk_kbytes 
> * 1024,
> +                                      max_link_dsc_bpp);
> +     if (!bpp_x16)
> +             return false;
> +
> +     if (enc) {
> +             enc->slice_height = slice_height;
> +             enc->slice_width = slice_width;
> +             enc->bpp_x16 = bpp_x16;
> +     }
> +
> +     return true;
> +}

[Severity: Medium]
Should intel_dp_pcon_can_encode_dsc() and intel_dp_pcon_dsc_enc_compute()
validate the PCON and HDMI sink DSC capabilities before accepting a mode?

intel_dp_pcon_can_encode_dsc() checks only the DSC 1.2 version flags and
skips DP_PCON_DSC_ENCODER_SUPPORTED and DP_PCON_DSC_PPS_ENC_OVERRIDE in
DP_PCON_DSC_ENCODER, even though intel_dp_pcon_dsc_configure()
unconditionally writes PPS override parameters.

intel_dp_pcon_dsc_enc_compute() also skips validating sink_format against
info->hdmi.dsc_cap.native_420 (for INTEL_OUTPUT_FORMAT_YCBCR420) and
DP_PCON_DSC_ENC_COLOR_FMT_CAP.

Similarly, bpc is not checked against info->hdmi.dsc_cap.bpc_supported
(which drm_parse_dsc_info() defaults to 8 bpc independently of
uncompressed deep-color support) or DP_PCON_DSC_ENC_COLOR_DEPTH_CAP.

On a PCON or HDMI 2.1 sink whose DSC capabilities are narrower than its
uncompressed ones (for example, 10 bpc uncompressed but only 8 bpc with
DSC), intel_dp_pcon_compute_config() will accept the mode and program
unsupported parameters, causing blank or corrupted display output.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=10

Reply via email to