diff mbox series

[v2,3/7] drm/i915/bios: use dp max link rate directly from child data

Message ID 5593ce81f6670dc33cf18fa284f8237c875ef404.1630512523.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/bios: remove vbt ddi_port_info caching | expand

Commit Message

Jani Nikula Sept. 1, 2021, 4:10 p.m. UTC
Avoid extra caching of the data.

Cc: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/display/intel_bios.c | 28 ++++++++++++++---------
 drivers/gpu/drm/i915/i915_drv.h           |  2 --
 2 files changed, 17 insertions(+), 13 deletions(-)

Comments

Nautiyal, Ankit K Sept. 3, 2021, 8:41 a.m. UTC | #1
A small nitpick below:

Otherwise the patch looks good to me.

Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>

On 9/1/2021 9:40 PM, Jani Nikula wrote:
> Avoid extra caching of the data.
>
> Cc: José Roberto de Souza <jose.souza@intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>   drivers/gpu/drm/i915/display/intel_bios.c | 28 ++++++++++++++---------
>   drivers/gpu/drm/i915/i915_drv.h           |  2 --
>   2 files changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
> index 253a528ba61a..10b2beddc121 100644
> --- a/drivers/gpu/drm/i915/display/intel_bios.c
> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
> @@ -1815,6 +1815,17 @@ static int parse_bdb_216_dp_max_link_rate(const int vbt_max_link_rate)
>   	}
>   }
>   
> +static int _intel_bios_dp_max_link_rate(const struct intel_bios_encoder_data *devdata)
> +{
> +	if (!devdata || devdata->i915->vbt.version < 216)
> +		return 0;
> +
> +	if (devdata->i915->vbt.version >= 230)
> +		return parse_bdb_230_dp_max_link_rate(devdata->child.dp_max_link_rate);
> +	else
> +		return parse_bdb_216_dp_max_link_rate(devdata->child.dp_max_link_rate);

Can do away with else.

Regards,

Ankit

> +}
> +
>   static void sanitize_device_type(struct intel_bios_encoder_data *devdata,
>   				 enum port port)
>   {
> @@ -1913,7 +1924,7 @@ static void parse_ddi_port(struct drm_i915_private *i915,
>   	const struct child_device_config *child = &devdata->child;
>   	struct ddi_vbt_port_info *info;
>   	bool is_dvi, is_hdmi, is_dp, is_edp, is_crt, supports_typec_usb, supports_tbt;
> -	int dp_boost_level, hdmi_boost_level, hdmi_level_shift, max_tmds_clock;
> +	int dp_boost_level, dp_max_link_rate, hdmi_boost_level, hdmi_level_shift, max_tmds_clock;
>   	enum port port;
>   
>   	port = dvo_port_to_port(i915, child->dvo_port);
> @@ -2001,17 +2012,11 @@ static void parse_ddi_port(struct drm_i915_private *i915,
>   			    "Port %c VBT HDMI boost level: %d\n",
>   			    port_name(port), hdmi_boost_level);
>   
> -	/* DP max link rate for GLK+ */
> -	if (i915->vbt.version >= 216) {
> -		if (i915->vbt.version >= 230)
> -			info->dp_max_link_rate = parse_bdb_230_dp_max_link_rate(child->dp_max_link_rate);
> -		else
> -			info->dp_max_link_rate = parse_bdb_216_dp_max_link_rate(child->dp_max_link_rate);
> -
> +	dp_max_link_rate = _intel_bios_dp_max_link_rate(devdata);
> +	if (dp_max_link_rate)
>   		drm_dbg_kms(&i915->drm,
>   			    "Port %c VBT DP max link rate: %d\n",
> -			    port_name(port), info->dp_max_link_rate);
> -	}
> +			    port_name(port), dp_max_link_rate);
>   
>   	info->devdata = devdata;
>   }
> @@ -2982,8 +2987,9 @@ int intel_bios_encoder_hdmi_boost_level(const struct intel_bios_encoder_data *de
>   int intel_bios_dp_max_link_rate(struct intel_encoder *encoder)
>   {
>   	struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> +	const struct intel_bios_encoder_data *devdata = i915->vbt.ddi_port_info[encoder->port].devdata;
>   
> -	return i915->vbt.ddi_port_info[encoder->port].dp_max_link_rate;
> +	return _intel_bios_dp_max_link_rate(devdata);
>   }
>   
>   int intel_bios_alternate_ddc_pin(struct intel_encoder *encoder)
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 8b4a31265978..586b5368d4fc 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -641,8 +641,6 @@ struct ddi_vbt_port_info {
>   
>   	u8 alternate_aux_channel;
>   	u8 alternate_ddc_pin;
> -
> -	int dp_max_link_rate;		/* 0 for not limited by VBT */
>   };
>   
>   enum psr_lines_to_wait {
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index 253a528ba61a..10b2beddc121 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -1815,6 +1815,17 @@  static int parse_bdb_216_dp_max_link_rate(const int vbt_max_link_rate)
 	}
 }
 
+static int _intel_bios_dp_max_link_rate(const struct intel_bios_encoder_data *devdata)
+{
+	if (!devdata || devdata->i915->vbt.version < 216)
+		return 0;
+
+	if (devdata->i915->vbt.version >= 230)
+		return parse_bdb_230_dp_max_link_rate(devdata->child.dp_max_link_rate);
+	else
+		return parse_bdb_216_dp_max_link_rate(devdata->child.dp_max_link_rate);
+}
+
 static void sanitize_device_type(struct intel_bios_encoder_data *devdata,
 				 enum port port)
 {
@@ -1913,7 +1924,7 @@  static void parse_ddi_port(struct drm_i915_private *i915,
 	const struct child_device_config *child = &devdata->child;
 	struct ddi_vbt_port_info *info;
 	bool is_dvi, is_hdmi, is_dp, is_edp, is_crt, supports_typec_usb, supports_tbt;
-	int dp_boost_level, hdmi_boost_level, hdmi_level_shift, max_tmds_clock;
+	int dp_boost_level, dp_max_link_rate, hdmi_boost_level, hdmi_level_shift, max_tmds_clock;
 	enum port port;
 
 	port = dvo_port_to_port(i915, child->dvo_port);
@@ -2001,17 +2012,11 @@  static void parse_ddi_port(struct drm_i915_private *i915,
 			    "Port %c VBT HDMI boost level: %d\n",
 			    port_name(port), hdmi_boost_level);
 
-	/* DP max link rate for GLK+ */
-	if (i915->vbt.version >= 216) {
-		if (i915->vbt.version >= 230)
-			info->dp_max_link_rate = parse_bdb_230_dp_max_link_rate(child->dp_max_link_rate);
-		else
-			info->dp_max_link_rate = parse_bdb_216_dp_max_link_rate(child->dp_max_link_rate);
-
+	dp_max_link_rate = _intel_bios_dp_max_link_rate(devdata);
+	if (dp_max_link_rate)
 		drm_dbg_kms(&i915->drm,
 			    "Port %c VBT DP max link rate: %d\n",
-			    port_name(port), info->dp_max_link_rate);
-	}
+			    port_name(port), dp_max_link_rate);
 
 	info->devdata = devdata;
 }
@@ -2982,8 +2987,9 @@  int intel_bios_encoder_hdmi_boost_level(const struct intel_bios_encoder_data *de
 int intel_bios_dp_max_link_rate(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+	const struct intel_bios_encoder_data *devdata = i915->vbt.ddi_port_info[encoder->port].devdata;
 
-	return i915->vbt.ddi_port_info[encoder->port].dp_max_link_rate;
+	return _intel_bios_dp_max_link_rate(devdata);
 }
 
 int intel_bios_alternate_ddc_pin(struct intel_encoder *encoder)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 8b4a31265978..586b5368d4fc 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -641,8 +641,6 @@  struct ddi_vbt_port_info {
 
 	u8 alternate_aux_channel;
 	u8 alternate_ddc_pin;
-
-	int dp_max_link_rate;		/* 0 for not limited by VBT */
 };
 
 enum psr_lines_to_wait {