diff mbox series

[01/19] drm/i915/dp: Sanitize DPCD revision check in intel_dp_get_dsc_sink_cap()

Message ID 20231006133727.1822579-2-imre.deak@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Store DSC DPCD capabilities in the connector | expand

Commit Message

Imre Deak Oct. 6, 2023, 1:37 p.m. UTC
Check only the eDP or the DP specific DPCD revision depending on the
sink type. Pass the corresponding revision to the function, which allows
getting the DSC caps of a branch device (in an MST topology, which has
its own DPCD and so DPCD revision).

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dp.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Stanislav Lisovskiy Oct. 6, 2023, 2:59 p.m. UTC | #1
On Fri, Oct 06, 2023 at 04:37:09PM +0300, Imre Deak wrote:
> Check only the eDP or the DP specific DPCD revision depending on the
> sink type. Pass the corresponding revision to the function, which allows
> getting the DSC caps of a branch device (in an MST topology, which has
> its own DPCD and so DPCD revision).
> 
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dp.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 0ef7cb8134b66..1bd11f9e308c1 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -3467,7 +3467,7 @@ bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp)
>  	return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED;
>  }
>  
> -static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
> +static void intel_dp_get_dsc_sink_cap(u8 dpcd_rev, struct intel_dp *intel_dp)
>  {
>  	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
>  
> @@ -3481,8 +3481,8 @@ static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
>  	intel_dp->fec_capable = 0;
>  
>  	/* Cache the DSC DPCD if eDP or DP rev >= 1.4 */
> -	if (intel_dp->dpcd[DP_DPCD_REV] >= 0x14 ||
> -	    intel_dp->edp_dpcd[0] >= DP_EDP_14) {
> +	if ((intel_dp_is_edp(intel_dp) && dpcd_rev >= DP_EDP_14) ||
> +	    (!intel_dp_is_edp(intel_dp) && dpcd_rev >= 0x14)) {

A bit curious whether could we use some macro for 0x14, just as for DP_EDP_14?
Because otherwise we are combining some values with macros, which seems like a bit
non-uniform approach.

However that is a minor thing anyway..

Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>


>  		if (drm_dp_dpcd_read(&intel_dp->aux, DP_DSC_SUPPORT,
>  				     intel_dp->dsc_dpcd,
>  				     sizeof(intel_dp->dsc_dpcd)) < 0)
> @@ -3674,7 +3674,8 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp)
>  
>  	/* Read the eDP DSC DPCD registers */
>  	if (HAS_DSC(dev_priv))
> -		intel_dp_get_dsc_sink_cap(intel_dp);
> +		intel_dp_get_dsc_sink_cap(intel_dp->edp_dpcd[0],
> +					  intel_dp);
>  
>  	/*
>  	 * If needed, program our source OUI so we can make various Intel-specific AUX services
> @@ -5384,7 +5385,8 @@ intel_dp_detect(struct drm_connector *connector,
>  
>  	/* Read DP Sink DSC Cap DPCD regs for DP v1.4 */
>  	if (HAS_DSC(dev_priv))
> -		intel_dp_get_dsc_sink_cap(intel_dp);
> +		intel_dp_get_dsc_sink_cap(intel_dp->dpcd[DP_DPCD_REV],
> +					  intel_dp);
>  
>  	intel_dp_configure_mst(intel_dp);
>  
> -- 
> 2.39.2
>
Ville Syrjälä Oct. 9, 2023, 2:48 p.m. UTC | #2
On Fri, Oct 06, 2023 at 04:37:09PM +0300, Imre Deak wrote:
> Check only the eDP or the DP specific DPCD revision depending on the
> sink type. Pass the corresponding revision to the function, which allows
> getting the DSC caps of a branch device (in an MST topology, which has
> its own DPCD and so DPCD revision).
> 
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dp.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 0ef7cb8134b66..1bd11f9e308c1 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -3467,7 +3467,7 @@ bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp)
>  	return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED;
>  }
>  
> -static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
> +static void intel_dp_get_dsc_sink_cap(u8 dpcd_rev, struct intel_dp *intel_dp)
>  {
>  	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
>  
> @@ -3481,8 +3481,8 @@ static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
>  	intel_dp->fec_capable = 0;
>  
>  	/* Cache the DSC DPCD if eDP or DP rev >= 1.4 */
> -	if (intel_dp->dpcd[DP_DPCD_REV] >= 0x14 ||
> -	    intel_dp->edp_dpcd[0] >= DP_EDP_14) {
> +	if ((intel_dp_is_edp(intel_dp) && dpcd_rev >= DP_EDP_14) ||
> +	    (!intel_dp_is_edp(intel_dp) && dpcd_rev >= 0x14)) {

This is horribly confusing. DPCD_REV and EDP_DPCD_REV are not the same
thing.

>  		if (drm_dp_dpcd_read(&intel_dp->aux, DP_DSC_SUPPORT,
>  				     intel_dp->dsc_dpcd,
>  				     sizeof(intel_dp->dsc_dpcd)) < 0)
> @@ -3674,7 +3674,8 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp)
>  
>  	/* Read the eDP DSC DPCD registers */
>  	if (HAS_DSC(dev_priv))
> -		intel_dp_get_dsc_sink_cap(intel_dp);
> +		intel_dp_get_dsc_sink_cap(intel_dp->edp_dpcd[0],
> +					  intel_dp);
>  
>  	/*
>  	 * If needed, program our source OUI so we can make various Intel-specific AUX services
> @@ -5384,7 +5385,8 @@ intel_dp_detect(struct drm_connector *connector,
>  
>  	/* Read DP Sink DSC Cap DPCD regs for DP v1.4 */
>  	if (HAS_DSC(dev_priv))
> -		intel_dp_get_dsc_sink_cap(intel_dp);
> +		intel_dp_get_dsc_sink_cap(intel_dp->dpcd[DP_DPCD_REV],
> +					  intel_dp);
>  
>  	intel_dp_configure_mst(intel_dp);
>  
> -- 
> 2.39.2
Imre Deak Oct. 10, 2023, 9:20 a.m. UTC | #3
On Mon, Oct 09, 2023 at 05:48:04PM +0300, Ville Syrjälä wrote:
> On Fri, Oct 06, 2023 at 04:37:09PM +0300, Imre Deak wrote:
> > Check only the eDP or the DP specific DPCD revision depending on the
> > sink type. Pass the corresponding revision to the function, which allows
> > getting the DSC caps of a branch device (in an MST topology, which has
> > its own DPCD and so DPCD revision).
> > 
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_dp.c | 12 +++++++-----
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> > index 0ef7cb8134b66..1bd11f9e308c1 100644
> > --- a/drivers/gpu/drm/i915/display/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> > @@ -3467,7 +3467,7 @@ bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp)
> >  	return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED;
> >  }
> >  
> > -static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
> > +static void intel_dp_get_dsc_sink_cap(u8 dpcd_rev, struct intel_dp *intel_dp)
> >  {
> >  	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> >  
> > @@ -3481,8 +3481,8 @@ static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
> >  	intel_dp->fec_capable = 0;
> >  
> >  	/* Cache the DSC DPCD if eDP or DP rev >= 1.4 */
> > -	if (intel_dp->dpcd[DP_DPCD_REV] >= 0x14 ||
> > -	    intel_dp->edp_dpcd[0] >= DP_EDP_14) {
> > +	if ((intel_dp_is_edp(intel_dp) && dpcd_rev >= DP_EDP_14) ||
> > +	    (!intel_dp_is_edp(intel_dp) && dpcd_rev >= 0x14)) {
> 
> This is horribly confusing. DPCD_REV and EDP_DPCD_REV are not the same
> thing.

Ok, I can add separate functions for DP and eDP each checking its
relevant DPCD revision.

> >  		if (drm_dp_dpcd_read(&intel_dp->aux, DP_DSC_SUPPORT,
> >  				     intel_dp->dsc_dpcd,
> >  				     sizeof(intel_dp->dsc_dpcd)) < 0)
> > @@ -3674,7 +3674,8 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp)
> >  
> >  	/* Read the eDP DSC DPCD registers */
> >  	if (HAS_DSC(dev_priv))
> > -		intel_dp_get_dsc_sink_cap(intel_dp);
> > +		intel_dp_get_dsc_sink_cap(intel_dp->edp_dpcd[0],
> > +					  intel_dp);
> >  
> >  	/*
> >  	 * If needed, program our source OUI so we can make various Intel-specific AUX services
> > @@ -5384,7 +5385,8 @@ intel_dp_detect(struct drm_connector *connector,
> >  
> >  	/* Read DP Sink DSC Cap DPCD regs for DP v1.4 */
> >  	if (HAS_DSC(dev_priv))
> > -		intel_dp_get_dsc_sink_cap(intel_dp);
> > +		intel_dp_get_dsc_sink_cap(intel_dp->dpcd[DP_DPCD_REV],
> > +					  intel_dp);
> >  
> >  	intel_dp_configure_mst(intel_dp);
> >  
> > -- 
> > 2.39.2
> 
> -- 
> Ville Syrjälä
> Intel
Imre Deak Oct. 10, 2023, 10:14 a.m. UTC | #4
On Fri, Oct 06, 2023 at 05:59:06PM +0300, Lisovskiy, Stanislav wrote:
> On Fri, Oct 06, 2023 at 04:37:09PM +0300, Imre Deak wrote:
> > Check only the eDP or the DP specific DPCD revision depending on the
> > sink type. Pass the corresponding revision to the function, which allows
> > getting the DSC caps of a branch device (in an MST topology, which has
> > its own DPCD and so DPCD revision).
> > 
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_dp.c | 12 +++++++-----
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> > index 0ef7cb8134b66..1bd11f9e308c1 100644
> > --- a/drivers/gpu/drm/i915/display/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> > @@ -3467,7 +3467,7 @@ bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp)
> >  	return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED;
> >  }
> >  
> > -static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
> > +static void intel_dp_get_dsc_sink_cap(u8 dpcd_rev, struct intel_dp *intel_dp)
> >  {
> >  	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> >  
> > @@ -3481,8 +3481,8 @@ static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
> >  	intel_dp->fec_capable = 0;
> >  
> >  	/* Cache the DSC DPCD if eDP or DP rev >= 1.4 */
> > -	if (intel_dp->dpcd[DP_DPCD_REV] >= 0x14 ||
> > -	    intel_dp->edp_dpcd[0] >= DP_EDP_14) {
> > +	if ((intel_dp_is_edp(intel_dp) && dpcd_rev >= DP_EDP_14) ||
> > +	    (!intel_dp_is_edp(intel_dp) && dpcd_rev >= 0x14)) {
> 
> A bit curious whether could we use some macro for 0x14, just as for DP_EDP_14?

Yes, make sense to make it more uniform, will use DP_DPCD_REV_14. The
driver uses the open-coded DPCD revisions elsewhere as well, those
could be also changed in a follow-up.

> Because otherwise we are combining some values with macros, which seems like a bit
> non-uniform approach.
> 
> However that is a minor thing anyway..
> 
> Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> 
> 
> >  		if (drm_dp_dpcd_read(&intel_dp->aux, DP_DSC_SUPPORT,
> >  				     intel_dp->dsc_dpcd,
> >  				     sizeof(intel_dp->dsc_dpcd)) < 0)
> > @@ -3674,7 +3674,8 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp)
> >  
> >  	/* Read the eDP DSC DPCD registers */
> >  	if (HAS_DSC(dev_priv))
> > -		intel_dp_get_dsc_sink_cap(intel_dp);
> > +		intel_dp_get_dsc_sink_cap(intel_dp->edp_dpcd[0],
> > +					  intel_dp);
> >  
> >  	/*
> >  	 * If needed, program our source OUI so we can make various Intel-specific AUX services
> > @@ -5384,7 +5385,8 @@ intel_dp_detect(struct drm_connector *connector,
> >  
> >  	/* Read DP Sink DSC Cap DPCD regs for DP v1.4 */
> >  	if (HAS_DSC(dev_priv))
> > -		intel_dp_get_dsc_sink_cap(intel_dp);
> > +		intel_dp_get_dsc_sink_cap(intel_dp->dpcd[DP_DPCD_REV],
> > +					  intel_dp);
> >  
> >  	intel_dp_configure_mst(intel_dp);
> >  
> > -- 
> > 2.39.2
> >
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 0ef7cb8134b66..1bd11f9e308c1 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -3467,7 +3467,7 @@  bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp)
 	return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED;
 }
 
-static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
+static void intel_dp_get_dsc_sink_cap(u8 dpcd_rev, struct intel_dp *intel_dp)
 {
 	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
 
@@ -3481,8 +3481,8 @@  static void intel_dp_get_dsc_sink_cap(struct intel_dp *intel_dp)
 	intel_dp->fec_capable = 0;
 
 	/* Cache the DSC DPCD if eDP or DP rev >= 1.4 */
-	if (intel_dp->dpcd[DP_DPCD_REV] >= 0x14 ||
-	    intel_dp->edp_dpcd[0] >= DP_EDP_14) {
+	if ((intel_dp_is_edp(intel_dp) && dpcd_rev >= DP_EDP_14) ||
+	    (!intel_dp_is_edp(intel_dp) && dpcd_rev >= 0x14)) {
 		if (drm_dp_dpcd_read(&intel_dp->aux, DP_DSC_SUPPORT,
 				     intel_dp->dsc_dpcd,
 				     sizeof(intel_dp->dsc_dpcd)) < 0)
@@ -3674,7 +3674,8 @@  intel_edp_init_dpcd(struct intel_dp *intel_dp)
 
 	/* Read the eDP DSC DPCD registers */
 	if (HAS_DSC(dev_priv))
-		intel_dp_get_dsc_sink_cap(intel_dp);
+		intel_dp_get_dsc_sink_cap(intel_dp->edp_dpcd[0],
+					  intel_dp);
 
 	/*
 	 * If needed, program our source OUI so we can make various Intel-specific AUX services
@@ -5384,7 +5385,8 @@  intel_dp_detect(struct drm_connector *connector,
 
 	/* Read DP Sink DSC Cap DPCD regs for DP v1.4 */
 	if (HAS_DSC(dev_priv))
-		intel_dp_get_dsc_sink_cap(intel_dp);
+		intel_dp_get_dsc_sink_cap(intel_dp->dpcd[DP_DPCD_REV],
+					  intel_dp);
 
 	intel_dp_configure_mst(intel_dp);