TC phy check cleanup
Subsystems (3)
v2 cover TC phy check cleanup
We are relying on end-less if-else ladders for a type-c phy capabilities check. Though it made sense when platforms supported legacy type-c support, modern platforms rely on the information passed by vbt. This cleanup restricts the if-else ladder to the platforms supporting legacy type-c phys and relies on vbt info for modern client and discrete platforms.
v2: Move cleanup vbt later to handle safe encoder removal
Radhakrishna Sripada (4):
drm/i915: Move intel_bios_driver_remove later drm/i915: Rename intel_bios_encoder_data_lookup as a port variant drm/i915: Introduce intel_encoder_phy_data_lookup drm/i915: Separate tc check for legacy and non legacy tc phys
drivers/gpu/drm/i915/display/g4x_dp.c | 2 +- drivers/gpu/drm/i915/display/g4x_hdmi.c | 2 +- drivers/gpu/drm/i915/display/intel_bios.c | 15 +++++++++- drivers/gpu/drm/i915/display/intel_bios.h | 5 +++- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + .../drm/i915/display/intel_display_driver.c | 4 +-- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 9 files changed, 44 insertions(+), 18 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/4 drm/i915: Move intel_bios_driver_remove later
Vbt structures will be used during mode config cleanup. Move the vbt structures cleanup to later time to accommodate cleaner mode config removal.
--- drivers/gpu/drm/i915/display/intel_display_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_display_driver.c +2 -2
@@ -466,6 +466,8 @@ void intel_display_driver_remove_noirq(struct drm_i915_private *i915)destroy_workqueue (i915->display.wq.modeset);intel_fbc_cleanup (i915); + +intel_bios_driver_remove (i915); }/* part #3: call after gem init */
@@ -476,8 +478,6 @@ void intel_display_driver_remove_nogem(struct drm_i915_private *i915)intel_power_domains_driver_remove (i915);intel_vga_unregister (i915); - -intel_bios_driver_remove (i915); }void intel_display_driver_unregister (struct drm_i915_private *i915)
Signature · 1 line
2.34.1
PATCH v2 2/4 drm/i915: Rename intel_bios_encoder_data_lookup as a port variant
In reply to Radhakrishna Sripadaintel_bios_encoder_data_lookup takes enum port as an argument. A variant based out of phy based lookup is required to be used out of vbt code which will be introduced in a later patch. Hence indicate the current variant as intel_bios_encoder_port_data_lookup.
--- drivers/gpu/drm/i915/display/g4x_dp.c | 2 +- drivers/gpu/drm/i915/display/g4x_hdmi.c | 2 +- drivers/gpu/drm/i915/display/intel_bios.c | 2 +- drivers/gpu/drm/i915/display/intel_bios.h | 2 +- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/display/g4x_dp.c +1 -1
@@ -1298,7 +1298,7 @@ bool g4x_dp_init(struct drm_i915_private *dev_priv,if (!assert_port_valid (dev_priv, port))return false; - devdata =intel_bios_encoder_data_lookup (dev_priv, port); + devdata =intel_bios_encoder_port_data_lookup (dev_priv, port);/* FIXME bail? */ if (!devdata)
drivers/gpu/drm/i915/display/g4x_hdmi.c +1 -1
@@ -697,7 +697,7 @@ void g4x_hdmi_init(struct drm_i915_private *dev_priv,if (!assert_hdmi_port_valid (dev_priv, port))return ; - devdata =intel_bios_encoder_data_lookup (dev_priv, port); + devdata =intel_bios_encoder_port_data_lookup (dev_priv, port);/* FIXME bail? */ if (!devdata)
drivers/gpu/drm/i915/display/intel_bios.c +1 -1
@@ -3636,7 +3636,7 @@ bool intel_bios_encoder_hpd_invert(const struct intel_bios_encoder_data *devdata }const struct intel_bios_encoder_data * -intel_bios_encoder_data_lookup (struct drm_i915_private *i915,enum port port) +intel_bios_encoder_port_data_lookup (struct drm_i915_private *i915,enum port port) {struct intel_bios_encoder_data *devdata;
drivers/gpu/drm/i915/display/intel_bios.h +1 -1
@@ -255,7 +255,7 @@ bool intel_bios_port_supports_typec_usb(struct drm_i915_private *i915, enum portbool intel_bios_port_supports_tbt (struct drm_i915_private *i915,enum port port);const struct intel_bios_encoder_data * -intel_bios_encoder_data_lookup (struct drm_i915_private *i915,enum port port); +intel_bios_encoder_port_data_lookup (struct drm_i915_private *i915,enum port port);bool intel_bios_encoder_supports_dvi (const struct intel_bios_encoder_data *devdata);bool intel_bios_encoder_supports_hdmi (const struct intel_bios_encoder_data *devdata);
drivers/gpu/drm/i915/display/intel_dp.c +1 -1
@@ -6155,7 +6155,7 @@ static bool _intel_dp_is_port_edp(struct drm_i915_private *dev_priv,bool intel_dp_is_port_edp (struct drm_i915_private *i915,enum port port) {const struct intel_bios_encoder_data *devdata = -intel_bios_encoder_data_lookup (i915, port); +intel_bios_encoder_port_data_lookup (i915, port);return _intel_dp_is_port_edp (i915, devdata, port); }
Signature · 1 line
2.34.1
PATCH v2 3/4 drm/i915: Introduce intel_encoder_phy_data_lookup
In reply to Radhakrishna SripadaThis patch introduces phy version of intel_encoder_port_data_lookup. Port based variant is dependent on vbt child data extraction and conversion to port data to be used further. Port data is not immediately available and is difficult to be determined from phy info.
--- drivers/gpu/drm/i915/display/intel_bios.c | 13 +++++++++++++ drivers/gpu/drm/i915/display/intel_bios.h | 3 +++ 2 files changed, 16 insertions(+)
drivers/gpu/drm/i915/display/intel_bios.c +13 -0
@@ -3648,6 +3648,19 @@ intel_bios_encoder_port_data_lookup(struct drm_i915_private *i915, enum port porreturn NULL ; } +const struct intel_bios_encoder_data * +intel_bios_encoder_phy_data_lookup (struct drm_i915_private *i915,enum phy phy) +{ +struct intel_bios_encoder_data *devdata; + +list_for_each_entry (devdata, &i915->display.vbt.display_devices, node) { +if (intel_port_to_phy (i915,intel_bios_encoder_port (devdata)) == phy) +return devdata; + } + +return NULL ; +} +void intel_bios_for_each_encoder (struct drm_i915_private *i915,void (*func)(struct drm_i915_private *i915,const struct intel_bios_encoder_data *devdata))
drivers/gpu/drm/i915/display/intel_bios.h +3 -0
@@ -39,6 +39,7 @@ struct intel_crtc_state;struct intel_encoder ;struct intel_panel ;enum aux_ch ; +enum phy ;enum port ;enum intel_backlight_type {
@@ -254,6 +255,8 @@ bool intel_bios_get_dsc_params(struct intel_encoder *encoder,bool intel_bios_port_supports_typec_usb (struct drm_i915_private *i915,enum port port);bool intel_bios_port_supports_tbt (struct drm_i915_private *i915,enum port port); +const struct intel_bios_encoder_data * +intel_bios_encoder_phy_data_lookup (struct drm_i915_private *i915,enum phy phy);const struct intel_bios_encoder_data *intel_bios_encoder_port_data_lookup (struct drm_i915_private *i915,enum port port);
Signature · 1 line
2.34.1
PATCH v2 4/4 drm/i915: Separate tc check for legacy and non legacy tc phys
In reply to Radhakrishna SripadaStarting MTL and DG2 if a phy is not marked as USB-typeC or TBT capable by vbt we should not consider it as a Legacy type-c phy.
The concept of Legacy-tc existed in platforms from Icelake to Alder lake where an external FIA can be routed to one of the phy's thus making the phy tc capable without being marked in the vbt.
Discrete cards have native ports and client products post MTL have a 1:1 mapping with type-C subsystem which is advertised by the bios. So rely on the vbt info regarding type-c capability.
--- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + 3 files changed, 21 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/display/intel_ddi.c +1 -1
@@ -5100,7 +5100,7 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, }if (intel_phy_is_tc (dev_priv, phy)) { -bool is_legacy = +bool is_legacy =HAS_LEGACY_TC (dev_priv) && !intel_bios_encoder_supports_typec_usb (devdata) && !intel_bios_encoder_supports_tbt (devdata);
drivers/gpu/drm/i915/display/intel_display.c +19 -10
@@ -1854,17 +1854,9 @@ bool intel_phy_is_combo(struct drm_i915_private *dev_priv, enum phy phy)return false; } -bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +static bool intel_phy_is_legacy_tc (struct drm_i915_private *dev_priv,enum phy phy) { -/* -* DG2's "TC1", although TC-capable output, doesn't share the same flow -* as other platforms on the display engine side and rather rely on the -* SNPS PHY, that is programmed separately -*/ -if (IS_DG2 (dev_priv)) -return false; - -if (DISPLAY_VER (dev_priv) >=13 ) +if (DISPLAY_VER (dev_priv) ==13 )return phy >=PHY_F && phy <=PHY_I ;else if (IS_TIGERLAKE (dev_priv))return phy >=PHY_D && phy <=PHY_I ;
@@ -1874,6 +1866,23 @@ bool intel_phy_is_tc(struct drm_i915_private *dev_priv, enum phy phy)return false; } +static bool intel_phy_is_vbt_tc (struct drm_i915_private *dev_priv,enum phy phy) +{ +const struct intel_bios_encoder_data *data = +intel_bios_encoder_phy_data_lookup (dev_priv, phy); + +return intel_bios_encoder_supports_typec_usb (data) && +intel_bios_encoder_supports_tbt (data); +} + +bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +{ +if (!HAS_LEGACY_TC (dev_priv)) +return intel_phy_is_vbt_tc (dev_priv, phy); +else +return intel_phy_is_legacy_tc (dev_priv, phy); +} +bool intel_phy_is_snps (struct drm_i915_private *dev_priv,enum phy phy) {/*
drivers/gpu/drm/i915/display/intel_display_device.h +1 -0
@@ -58,6 +58,7 @@ struct drm_printer;#define HAS_IPS (i915) (IS_HASWELL_ULT(i915) || IS_BROADWELL(i915))#define HAS_LRR (i915) (DISPLAY_VER(i915) >= 12)#define HAS_LSPCON (i915) (IS_DISPLAY_VER(i915, 9, 10)) +#define HAS_LEGACY_TC (i915) (IS_DISPLAY_VER(i915, 11, 13) && !IS_DGFX(i915))#define HAS_MBUS_JOINING (i915) (IS_ALDERLAKE_P(i915) || DISPLAY_VER(i915) >= 14)#define HAS_MSO (i915) (DISPLAY_VER(i915) >= 12)#define HAS_OVERLAY (i915) (DISPLAY_INFO(i915)->has_overlay)
Signature · 1 line
2.34.1
Re: [PATCH v2 4/4] drm/i915: Separate tc check for legacy and non legacy tc phys
Quoted 23 lines · Radhakrishna Sripada
Starting MTL and DG2 if a phy is not marked as USB-typeC or TBT capable by vbt we should not consider it as a Legacy type-c phy.
The concept of Legacy-tc existed in platforms from Icelake to Alder lake where an external FIA can be routed to one of the phy's thus making the phy tc capable without being marked in the vbt.
Discrete cards have native ports and client products post MTL have a 1:1 mapping with type-C subsystem which is advertised by the bios. So rely on the vbt info regarding type-c capability.
Signed-off-by Radhakrishna Sripada <[email protected]>--- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + 3 files changed, 21 insertions(+), 11 deletions(-)drivers/gpu/drm/i915/display/intel_ddi.c +0
-0
drivers/gpu/drm/i915/display/intel_ddi.c void intel_ddi_init(struct drm_i915_private *dev_priv, · line 5103
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_ddi.c +1
-1@@ -5100,7 +5100,7 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, }if (intel_phy_is_tc (dev_priv, phy)) { - bool is_legacy = + bool is_legacy = HAS_LEGACY_TC(dev_priv) &&
This doesn't make sense to me. PHYs are either TC or non-TC (aka combo PHY) and TC PHYs can be configured to work either in legacy (a TC PHY wired to a native DP connector) or non-legacy mode (a TC PHY wired to a TC connector). So this would break the functionality on MTL native DP connectors and all future platforms I looked at which also support this.
Quoted 28 lines
drivers/gpu/drm/i915/display/intel_ddi.c +0
-0!intel_bios_encoder_supports_typec_usb (devdata) && !intel_bios_encoder_supports_tbt (devdata);drivers/gpu/drm/i915/display/intel_display.c +2
-10@@ -1854,17 +1854,9 @@ bool intel_phy_is_combo(struct drm_i915_private *dev_priv, enum phy phy)return false; } -bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +static bool intel_phy_is_legacy_tc (struct drm_i915_private *dev_priv,enum phy phy) { -/* -* DG2's "TC1", although TC-capable output, doesn't share the same flow -* as other platforms on the display engine side and rather rely on the -* SNPS PHY, that is programmed separately -*/ -if (IS_DG2 (dev_priv)) -return false; - -if (DISPLAY_VER (dev_priv) >=13 ) +if (DISPLAY_VER (dev_priv) ==13 )return phy >=PHY_F && phy <=PHY_I ;else if (IS_TIGERLAKE (dev_priv))return phy >=PHY_D && phy <=PHY_I ;
drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_tc(struct drm_i915_private *dev_priv, enum phy phy) · line 1875
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_display.c +7
-0@@ -1874,6 +1866,23 @@ bool intel_phy_is_tc(struct drm_i915_private *dev_priv, enum phy phy)return false; } +static bool intel_phy_is_vbt_tc (struct drm_i915_private *dev_priv,enum phy phy) +{ +const struct intel_bios_encoder_data *data = +intel_bios_encoder_phy_data_lookup (dev_priv, phy); + +return intel_bios_encoder_supports_typec_usb (data) && +intel_bios_encoder_supports_tbt (data);
Based on the above, this doesn't look correct: a TC PHY can be configured by the vendor (reflected by the above typec_usb and tbt flags in VBT) in any of the following ways:
- legacy mode (wired to a native DP connector): typec_usb:false, tbt:false - tbt-alt + dp-alt support (wired to a TC connector): typec_usb:true, tbt:true - tbt-alt only support (wired to a TC connector): typec_usb:false, tbt:true - dp-alt only support (wired to a TC connector): typec_usb:true, tbt:false
For all the above cases intel_phy_is_tc() should return true. So I don't think this (is a PHY TC or non-TC) can be determined based on the above VBT flags.
Quoted 28 lines
drivers/gpu/drm/i915/display/intel_display.c +10
-0+} + +bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +{ +if (!HAS_LEGACY_TC (dev_priv)) +return intel_phy_is_vbt_tc (dev_priv, phy); +else +return intel_phy_is_legacy_tc (dev_priv, phy); +} +bool intel_phy_is_snps (struct drm_i915_private *dev_priv,enum phy phy) {/* drivers/gpu/drm/i915/display/intel_display_device.h +1
-0@@ -58,6 +58,7 @@ struct drm_printer;#define HAS_IPS (i915) (IS_HASWELL_ULT(i915) || IS_BROADWELL(i915))#define HAS_LRR (i915) (DISPLAY_VER(i915) >= 12)#define HAS_LSPCON (i915) (IS_DISPLAY_VER(i915, 9, 10)) +#define HAS_LEGACY_TC (i915) (IS_DISPLAY_VER(i915, 11, 13) && !IS_DGFX(i915))#define HAS_MBUS_JOINING (i915) (IS_ALDERLAKE_P(i915) || DISPLAY_VER(i915) >= 14)#define HAS_MSO (i915) (DISPLAY_VER(i915) >= 12)#define HAS_OVERLAY (i915) (DISPLAY_INFO(i915)->has_overlay)Signature · 1 line
2.34.1
RE: [PATCH v2 4/4] drm/i915: Separate tc check for legacy and non legacy tc phys
Hi Imre,
I have question related to tc legacy handling. I am looking in the context of discrete cards.
Quoted 36 lines
-----Original Message-----
From: Deak, Imre <[email protected]>
Sent: Friday, December 22, 2023 3:44 AM
To: Sripada, Radhakrishna <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v2 4/4] drm/i915: Separate tc check for legacy and non legacy tc physQuoted 11 lines · Radhakrishna Sripada
Starting MTL and DG2 if a phy is not marked as USB-typeC or TBT capable by vbt we should not consider it as a Legacy type-c phy.
The concept of Legacy-tc existed in platforms from Icelake to Alder lake where an external FIA can be routed to one of the phy's thus making the phy tc capable without being marked in the vbt.
Discrete cards have native ports and client products post MTL have a 1:1 mapping with type-C subsystem which is advertised by the bios. So rely on the vbt info regarding type-c capability.
Review
Quoted 8 lines
Signed-off-by Radhakrishna Sripada <[email protected]>--- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + 3 files changed, 21 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/display/intel_ddi.cdrivers/gpu/drm/i915/display/intel_ddi.c void intel_ddi_init(struct drm_i915_private
Quoted 4 lines
index
12a29363e5df..7d5b95f97d5f100644drivers/gpu/drm/i915/display/intel_ddi.c +0
-0@@ -5100,7 +5100,7 @@ void intel_ddi_init(struct drm_i915_private
*dev_priv,Quoted 2 lines
drivers/gpu/drm/i915/display/intel_ddi.c +0
-0}
Quoted 9 lines
drivers/gpu/drm/i915/display/intel_ddi.c void intel_ddi_init(struct drm_i915_private *dev_priv, · line 5103
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_ddi.c +1
-1if (intel_phy_is_tc (dev_priv, phy)) { - bool is_legacy = + bool is_legacy = HAS_LEGACY_TC(dev_priv) &&This doesn't make sense to me. PHYs are either TC or non-TC (aka combo PHY) and TC PHYs can be configured to work either in legacy (a TC PHY wired to a native DP connector) or non-legacy mode (a TC PHY wired to a TC connector). So this would break the functionality on MTL native DP connectors and all future platforms I looked at which also support this.
I understand. I want to figure out a way to determine if a phy is connected to FIA. Like in DG2, the phy's are not connected to FIA. I am assuming that will be the case for all future discrete cards as well. So instead of looking/building an if-else ladder for the phy check, is there something that we can rely on viz. vbt, register etc. to determine if FIA is connected to a phy?
Quoted 49 lines
Review
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_ddi.c +0
-0!intel_bios_encoder_supports_typec_usb (devdata) && !intel_bios_encoder_supports_tbt (devdata);(quoted diff) +0
-0
b/drivers/gpu/drm/i915/display/intel_display.cdrivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_combo(struct drm_i915_private
Quoted 4 lines
index
b10aad15a63d..03006c9af824100644drivers/gpu/drm/i915/display/intel_display.c +0
-0@@ -1854,17 +1854,9 @@ bool intel_phy_is_combo(struct drm_i915_private
*dev_priv, enum phy phy)drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_combo(struct drm_i915_private *dev_priv, enum phy phy)
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-1return false; } -bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +static bool intel_phy_is_legacy_tc(struct drm_i915_private *dev_priv, enumphy phy)
drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_tc(struct drm_i915_private
Quoted 15 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-9{ -/* -* DG2's "TC1", although TC-capable output, doesn't share the same flow -* as other platforms on the display engine side and rather rely on the -* SNPS PHY, that is programmed separately -*/ -if (IS_DG2 (dev_priv)) -return false; - -if (DISPLAY_VER (dev_priv) >=13 ) +if (DISPLAY_VER (dev_priv) ==13 )return phy >=PHY_F && phy <=PHY_I ;else if (IS_TIGERLAKE (dev_priv))return phy >=PHY_D && phy <=PHY_I ;@@ -1874,6 +1866,23 @@ bool intel_phy_is_tc(struct drm_i915_private
*dev_priv, enum phy phy)drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_combo(struct drm_i915_private *dev_priv, enum phy phy)
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-0return false; } +static bool intel_phy_is_vbt_tc(struct drm_i915_private *dev_priv, enum phyphy)
drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_tc(struct drm_i915_private *dev_priv, enum phy phy) · line 1875
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_display.c +6
-0+{ +const struct intel_bios_encoder_data *data = +intel_bios_encoder_phy_data_lookup (dev_priv, phy); + +return intel_bios_encoder_supports_typec_usb (data) && +intel_bios_encoder_supports_tbt (data);Based on the above, this doesn't look correct: a TC PHY can be configured by the vendor (reflected by the above
typec_usband tbt flags in VBT) in any of the following ways:
Quoted 8 lines
- legacy mode (wired to a native DP connector): typec_usb:false, tbt:false - tbt-alt + dp-alt support (wired to a TC connector): typec_usb:true, tbt:true - tbt-alt only support (wired to a TC connector): typec_usb:false, tbt:true - dp-alt only support (wired to a TC connector): typec_usb:true, tbt:falseFor all the above cases
intel_phy_is_tc()should return true. So I don't think this (is a PHY TC or non-TC) can be determined based on the above VBT flags.
Thanks for this clarification Imre. I am looking to see from the driver if we can make a determination if a phy is connected to a FIA to make this decision. Is there a way that you could suggest?
Thanks,
Radhakrishna Sripada
Quoted 33 lines
Review
Quoted 15 lines
drivers/gpu/drm/i915/display/intel_display.c +10
-0+} + +bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +{ +if (!HAS_LEGACY_TC (dev_priv)) +return intel_phy_is_vbt_tc (dev_priv, phy); +else +return intel_phy_is_legacy_tc (dev_priv, phy); +} +bool intel_phy_is_snps (struct drm_i915_private *dev_priv,enum phy phy) {/* (quoted diff) +0
-0
b/drivers/gpu/drm/i915/display/intel_display_device.hdrivers/gpu/drm/i915/display/intel_display_device.h struct drm_printer; · line 58
Quoted 5 lines
index
fe4268813786..9450e263c873100644drivers/gpu/drm/i915/display/intel_display_device.h +0
-0@@ -58,6 +58,7 @@ struct drm_printer;#define HAS_IPS (i915) (IS_HASWELL_ULT(i915) ||
IS_BROADWELL(i915))drivers/gpu/drm/i915/display/intel_display_device.h struct drm_printer;
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_display_device.h +1
-0#define HAS_LRR (i915) (DISPLAY_VER(i915) >= 12)#define HAS_LSPCON (i915) (IS_DISPLAY_VER(i915, 9, 10)) +#define HAS_LEGACY_TC (i915) (IS_DISPLAY_VER(i915, 11, 13)&& !IS_DGFX(i915))
drivers/gpu/drm/i915/display/intel_display_device.h struct drm_printer; · line 62
Quoted 1 line
drivers/gpu/drm/i915/display/intel_display_device.h +0
-0#define HAS_MBUS_JOINING (i915) (IS_ALDERLAKE_P(i915) ||
DISPLAY_VER(i915)>= 14)Quoted 5 lines
drivers/gpu/drm/i915/display/intel_display_device.h +0
-1#define HAS_MSO (i915) (DISPLAY_VER(i915) >= 12)#define HAS_OVERLAY (i915) (DISPLAY_INFO(i915)->has_overlay) --2.34.1
Re: [PATCH v2 4/4] drm/i915: Separate tc check for legacy and non legacy tc phys
Quoted 51 lines · Radhakrishna
Hi Imre,
I have question related to tc legacy handling. I am looking in the context of discrete cards.
Quoted 40 lines
-----Original Message-----
From: Deak, Imre <[email protected]>
Sent: Friday, December 22, 2023 3:44 AM
To: Sripada, Radhakrishna <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v2 4/4] drm/i915: Separate tc check for legacy and non legacy tc physQuoted 11 lines · Radhakrishna Sripada
Starting MTL and DG2 if a phy is not marked as USB-typeC or TBT capable by vbt we should not consider it as a Legacy type-c phy.
The concept of Legacy-tc existed in platforms from Icelake to Alder lake where an external FIA can be routed to one of the phy's thus making the phy tc capable without being marked in the vbt.
Discrete cards have native ports and client products post MTL have a 1:1 mapping with type-C subsystem which is advertised by the bios. So rely on the vbt info regarding type-c capability.
Review
Quoted 8 lines
Signed-off-by Radhakrishna Sripada <[email protected]>--- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + 3 files changed, 21 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/display/intel_ddi.cdrivers/gpu/drm/i915/display/intel_ddi.c void intel_ddi_init(struct drm_i915_private
Quoted 4 lines
index
12a29363e5df..7d5b95f97d5f100644drivers/gpu/drm/i915/display/intel_ddi.c +0
-0@@ -5100,7 +5100,7 @@ void intel_ddi_init(struct drm_i915_private
*dev_priv,drivers/gpu/drm/i915/display/intel_ddi.c void intel_ddi_init(struct drm_i915_private *dev_priv, · line 5103
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_ddi.c +1
-1}if (intel_phy_is_tc (dev_priv, phy)) { - bool is_legacy = + bool is_legacy = HAS_LEGACY_TC(dev_priv) &&Quoted 5 lines
This doesn't make sense to me. PHYs are either TC or non-TC (aka combo PHY) and TC PHYs can be configured to work either in legacy (a TC PHY wired to a native DP connector) or non-legacy mode (a TC PHY wired to a TC connector). So this would break the functionality on MTL native DP connectors and all future platforms I looked at which also support this.
Quoted 6 lines
I understand. I want to figure out a way to determine if a phy is connected to FIA. Like in DG2, the phy's are not connected to FIA. I am assuming that will be the case for all future discrete cards as well. So instead of looking/building an if-else ladder for the phy check, is there something that we can rely on viz. vbt, register etc. to determine if FIA is connected to a phy?
I suppose this question is if a PHY is TypeC or not, TypeC requiring some kind of mux (which can be FIA or something else). One other way instead of the if-ladder in intel_phy_is_tc() would be adding a tc_phy_mask to intel_display_runtime_info, similarly to the port_mask there. Not sure how much that would improve things over the current way.
Quoted 95 lines
Quoted 48 lines
Review
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_ddi.c +0
-0!intel_bios_encoder_supports_typec_usb (devdata) && !intel_bios_encoder_supports_tbt (devdata);(quoted diff) +0
-0
b/drivers/gpu/drm/i915/display/intel_display.cdrivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_combo(struct drm_i915_private
Quoted 4 lines
index
b10aad15a63d..03006c9af824100644drivers/gpu/drm/i915/display/intel_display.c +0
-0@@ -1854,17 +1854,9 @@ bool intel_phy_is_combo(struct drm_i915_private
*dev_priv, enum phy phy)drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_combo(struct drm_i915_private *dev_priv, enum phy phy)
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-1return false; } -bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +static bool intel_phy_is_legacy_tc(struct drm_i915_private *dev_priv, enumphy phy)
drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_tc(struct drm_i915_private
Quoted 15 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-9{ -/* -* DG2's "TC1", although TC-capable output, doesn't share the same flow -* as other platforms on the display engine side and rather rely on the -* SNPS PHY, that is programmed separately -*/ -if (IS_DG2 (dev_priv)) -return false; - -if (DISPLAY_VER (dev_priv) >=13 ) +if (DISPLAY_VER (dev_priv) ==13 )return phy >=PHY_F && phy <=PHY_I ;else if (IS_TIGERLAKE (dev_priv))return phy >=PHY_D && phy <=PHY_I ;@@ -1874,6 +1866,23 @@ bool intel_phy_is_tc(struct drm_i915_private
*dev_priv, enum phy phy)drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_combo(struct drm_i915_private *dev_priv, enum phy phy)
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-0return false; } +static bool intel_phy_is_vbt_tc(struct drm_i915_private *dev_priv, enum phyphy)
drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_tc(struct drm_i915_private *dev_priv, enum phy phy) · line 1875
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_display.c +6
-0+{ +const struct intel_bios_encoder_data *data = +intel_bios_encoder_phy_data_lookup (dev_priv, phy); + +return intel_bios_encoder_supports_typec_usb (data) && +intel_bios_encoder_supports_tbt (data);Based on the above, this doesn't look correct: a TC PHY can be configured by the vendor (reflected by the above
typec_usband tbt flags in VBT) in any of the following ways:Quoted 8 lines
- legacy mode (wired to a native DP connector): typec_usb:false, tbt:false - tbt-alt + dp-alt support (wired to a TC connector): typec_usb:true, tbt:true - tbt-alt only support (wired to a TC connector): typec_usb:false, tbt:true - dp-alt only support (wired to a TC connector): typec_usb:true, tbt:falseFor all the above cases
intel_phy_is_tc()should return true. So I don't think this (is a PHY TC or non-TC) can be determined based on the above VBT flags.Thanks for this clarification Imre. I am looking to see from the driver if we can make a determination if a phy is connected to a FIA to make this decision. Is there a way that you could suggest?
Thanks,
Radhakrishna SripadaQuoted 33 lines
Review
Quoted 15 lines
drivers/gpu/drm/i915/display/intel_display.c +10
-0+} + +bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +{ +if (!HAS_LEGACY_TC (dev_priv)) +return intel_phy_is_vbt_tc (dev_priv, phy); +else +return intel_phy_is_legacy_tc (dev_priv, phy); +} +bool intel_phy_is_snps (struct drm_i915_private *dev_priv,enum phy phy) {/* (quoted diff) +0
-0
b/drivers/gpu/drm/i915/display/intel_display_device.hdrivers/gpu/drm/i915/display/intel_display_device.h struct drm_printer; · line 58
Quoted 5 lines
index
fe4268813786..9450e263c873100644drivers/gpu/drm/i915/display/intel_display_device.h +0
-0@@ -58,6 +58,7 @@ struct drm_printer;#define HAS_IPS (i915) (IS_HASWELL_ULT(i915) ||
IS_BROADWELL(i915))drivers/gpu/drm/i915/display/intel_display_device.h struct drm_printer;
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_display_device.h +1
-0#define HAS_LRR (i915) (DISPLAY_VER(i915) >= 12)#define HAS_LSPCON (i915) (IS_DISPLAY_VER(i915, 9, 10)) +#define HAS_LEGACY_TC (i915) (IS_DISPLAY_VER(i915, 11, 13)&& !IS_DGFX(i915))
drivers/gpu/drm/i915/display/intel_display_device.h struct drm_printer; · line 62
Quoted 1 line
drivers/gpu/drm/i915/display/intel_display_device.h +0
-0#define HAS_MBUS_JOINING (i915) (IS_ALDERLAKE_P(i915) ||
DISPLAY_VER(i915)>= 14)Quoted 5 lines
drivers/gpu/drm/i915/display/intel_display_device.h +0
-1#define HAS_MSO (i915) (DISPLAY_VER(i915) >= 12)#define HAS_OVERLAY (i915) (DISPLAY_INFO(i915)->has_overlay) --2.34.1
RE: [PATCH v2 4/4] drm/i915: Separate tc check for legacy and non legacy tc phys
Hi Imre,
Thank you for the pointer. Let me evaluate and see if it is worth taking that trouble.
Thanks,
Radhakrishna(RK) Sripada
Quoted 174 lines
-----Original Message-----
From: Deak, Imre <[email protected]>
Sent: Wednesday, January 3, 2024 8:51 AM
To: Sripada, Radhakrishna <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v2 4/4] drm/i915: Separate tc check for legacy and non legacy tc physQuoted 3 lines · Radhakrishna
Hi Imre,
I have question related to tc legacy handling. I am looking in the context of
discrete cards.
Quoted 48 lines
Quoted 41 lines
-----Original Message-----
From: Deak, Imre <[email protected]>
Sent: Friday, December 22, 2023 3:44 AM
To: Sripada, Radhakrishna <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v2 4/4] drm/i915: Separate tc check for legacy and non legacy tc physQuoted 11 lines · Radhakrishna Sripada
Starting MTL and DG2 if a phy is not marked as USB-typeC or TBT capable by vbt we should not consider it as a Legacy type-c phy.
The concept of Legacy-tc existed in platforms from Icelake to Alder lake where an external FIA can be routed to one of the phy's thus making the phy tc capable without being marked in the vbt.
Discrete cards have native ports and client products post MTL have a 1:1 mapping with type-C subsystem which is advertised by the bios. So rely on the vbt info regarding type-c capability.
Review
Quoted 8 lines
Signed-off-by Radhakrishna Sripada <[email protected]>--- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + 3 files changed, 21 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/display/intel_ddi.cdrivers/gpu/drm/i915/display/intel_ddi.c void intel_ddi_init(struct drm_i915_private
Quoted 4 lines
index
12a29363e5df..7d5b95f97d5f100644drivers/gpu/drm/i915/display/intel_ddi.c +0
-0@@ -5100,7 +5100,7 @@ void intel_ddi_init(struct drm_i915_private
*dev_priv,drivers/gpu/drm/i915/display/intel_ddi.c void intel_ddi_init(struct drm_i915_private *dev_priv, · line 5103
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_ddi.c +1
-1}if (intel_phy_is_tc (dev_priv, phy)) { - bool is_legacy = + bool is_legacy = HAS_LEGACY_TC(dev_priv) &&Quoted 5 lines
This doesn't make sense to me. PHYs are either TC or non-TC (aka combo PHY) and TC PHYs can be configured to work either in legacy (a TC PHY wired to a native DP connector) or non-legacy mode (a TC PHY wired to a TC connector). So this would break the functionality on MTL native DP connectors and all future platforms I looked at which also support this.
Quoted 6 lines
I understand. I want to figure out a way to determine if a phy is connected to FIA. Like in DG2, the phy's are not connected to FIA. I am assuming that will be the case for all future discrete cards as well. So instead of looking/building an if-else ladder for the phy check, is there something that we can rely on viz. vbt, register etc. to determine if FIA is connected to a phy?
I suppose this question is if a PHY is TypeC or not, TypeC requiring some kind of mux (which can be FIA or something else). One other way instead of the if-ladder in
intel_phy_is_tc()would be adding atc_phy_masktointel_display_runtime_info, similarly to theport_maskthere. Not sure how much that would improve things over the current way.Quoted 9 lines
Quoted 9 lines
Review
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_ddi.c +0
-0!intel_bios_encoder_supports_typec_usb (devdata) && !intel_bios_encoder_supports_tbt (devdata);(quoted diff) +0
-0
b/drivers/gpu/drm/i915/display/intel_display.cdrivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_combo(struct
Quoted 4 lines
index
b10aad15a63d..03006c9af824100644drivers/gpu/drm/i915/display/intel_display.c +0
-0@@ -1854,17 +1854,9 @@ bool intel_phy_is_combo(struct
drm_i915_privateQuoted 6 lines
Quoted 6 lines
*dev_priv, enum phy phy)drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_combo(struct drm_i915_private *dev_priv, enum phy phy)
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-1return false; } -bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +static bool intel_phy_is_legacy_tc(struct drm_i915_private *dev_priv,enum
Quoted 17 lines
Quoted 17 lines
phy phy)
drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_tc(struct drm_i915_private
Quoted 15 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-9{ -/* -* DG2's "TC1", although TC-capable output, doesn't share the same flow -* as other platforms on the display engine side and rather rely on the -* SNPS PHY, that is programmed separately -*/ -if (IS_DG2 (dev_priv)) -return false; - -if (DISPLAY_VER (dev_priv) >=13 ) +if (DISPLAY_VER (dev_priv) ==13 )return phy >=PHY_F && phy <=PHY_I ;else if (IS_TIGERLAKE (dev_priv))return phy >=PHY_D && phy <=PHY_I ;@@ -1874,6 +1866,23 @@ bool intel_phy_is_tc(struct drm_i915_private
*dev_priv, enum phy phy)Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_combo(struct drm_i915_private *dev_priv, enum phy phy)
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-0return false; } +static bool intel_phy_is_vbt_tc(struct drm_i915_private *dev_priv, enumphy
Quoted 17 lines
Quoted 17 lines
phy)
drivers/gpu/drm/i915/display/intel_display.c bool intel_phy_is_tc(struct drm_i915_private *dev_priv, enum phy phy) · line 1875
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_display.c +6
-0+{ +const struct intel_bios_encoder_data *data = +intel_bios_encoder_phy_data_lookup (dev_priv, phy); + +return intel_bios_encoder_supports_typec_usb (data) && +intel_bios_encoder_supports_tbt (data);Based on the above, this doesn't look correct: a TC PHY can be configured by the vendor (reflected by the above
typec_usband tbt flags in VBT) in any of the following ways:- legacy mode (wired to a native DP connector): typec_usb:false, tbt:false - tbt-alt + dp-alt support (wired to a TC connector): typec_usb:true, tbt:true - tbt-alt only support (wired to a TC connector): typec_usb:false, tbt:true - dp-alt only support (wired to a TC connector): typec_usb:true, tbt:falseQuoted 5 lines
Quoted 3 lines
For all the above cases
intel_phy_is_tc()should return true. So I don't think this (is a PHY TC or non-TC) can be determined based on the above VBT flags.Thanks for this clarification Imre. I am looking to see from the driver if we can
make a determination if
Quoted 1 line
a phy is connected to a FIA to make this decision. Is there a way that you could
suggest?
Quoted 36 lines
Thanks,
Radhakrishna SripadaQuoted 33 lines
Review
Quoted 15 lines
drivers/gpu/drm/i915/display/intel_display.c +10
-0+} + +bool intel_phy_is_tc (struct drm_i915_private *dev_priv,enum phy phy) +{ +if (!HAS_LEGACY_TC (dev_priv)) +return intel_phy_is_vbt_tc (dev_priv, phy); +else +return intel_phy_is_legacy_tc (dev_priv, phy); +} +bool intel_phy_is_snps (struct drm_i915_private *dev_priv,enum phy phy) {/* (quoted diff) +0
-0
b/drivers/gpu/drm/i915/display/intel_display_device.hdrivers/gpu/drm/i915/display/intel_display_device.h struct drm_printer; · line 58
Quoted 5 lines
index
fe4268813786..9450e263c873100644drivers/gpu/drm/i915/display/intel_display_device.h +0
-0@@ -58,6 +58,7 @@ struct drm_printer;#define HAS_IPS (i915) (IS_HASWELL_ULT(i915) ||
IS_BROADWELL(i915))drivers/gpu/drm/i915/display/intel_display_device.h struct drm_printer;
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_display_device.h +1
-0#define HAS_LRR (i915) (DISPLAY_VER(i915) >= 12)#define HAS_LSPCON (i915) (IS_DISPLAY_VER(i915, 9, 10)) +#define HAS_LEGACY_TC (i915) (IS_DISPLAY_VER(i915, 11, 13)&& !IS_DGFX(i915))
drivers/gpu/drm/i915/display/intel_display_device.h struct drm_printer; · line 62
Quoted 1 line
drivers/gpu/drm/i915/display/intel_display_device.h +0
-0#define HAS_MBUS_JOINING (i915) (IS_ALDERLAKE_P(i915) ||
DISPLAY_VER(i915)>= 14)Quoted 5 lines
drivers/gpu/drm/i915/display/intel_display_device.h +0
-1#define HAS_MSO (i915) (DISPLAY_VER(i915) >= 12)#define HAS_OVERLAY (i915) (DISPLAY_INFO(i915)->has_overlay) --2.34.1
Jani Nikula
maintainerQuoted 6 lines · Radhakrishna Sripada
We are relying on end-less if-else ladders for a type-c phy capabilities check. Though it made sense when platforms supported legacy type-c support, modern platforms rely on the information passed by vbt. This cleanup restricts the if-else ladder to the platforms supporting legacy type-c phys and relies on vbt info for modern client and discrete platforms.
This series is moving the vbt handling in the wrong direction.
We want to *avoid* new lookups. The idea is that you do the lookup *once* when initializing the encoder, and after that you use encoder->devdata.
If you look at the intel_phy_is_tc() call sites, you'll observe that almost all of the places have the encoder (or devdata) already available. They get the port from encoder->port, and the phy from intel_port_to_phy().
So this throws away the information that's already available, and then goes to look it up again in the worst possible way.
You should convert intel_phy_is_tc() to something like intel_encoder_is_tc(), and pass encoder to it instead of phy. Similarly, intel_port_to_tc() should be converted to intel_encoder_to_tc().
There are a couple of special cases that only have devdata or phy. But we can handle the special cases after making the common case straightforward.
BR,
Jani.
Quoted 19 lines
v2: Move cleanup vbt later to handle safe encoder removal
Radhakrishna Sripada (4):
drm/i915: Moveintel_bios_driver_removelater drm/i915: Renameintel_bios_encoder_data_lookupas a port variant drm/i915: Introduceintel_encoder_phy_data_lookupdrm/i915: Separate tc check for legacy and non legacy tc physdrivers/gpu/drm/i915/display/g4x_dp.c | 2 +- drivers/gpu/drm/i915/display/g4x_hdmi.c | 2 +- drivers/gpu/drm/i915/display/intel_bios.c | 15 +++++++++- drivers/gpu/drm/i915/display/intel_bios.h | 5 +++- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + .../drm/i915/display/intel_display_driver.c | 4 +-- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 9 files changed, 44 insertions(+), 18 deletions(-)
Signature · 1 line
Jani Nikula, Intel
Hi Jani,
Quoted 30 lines
-----Original Message-----
From: Jani Nikula <[email protected]>
Sent: Thursday, December 21, 2023 2:04 AM
To: Sripada, Radhakrishna <[email protected]>; intel- [email protected]
Subject: Re: [PATCH v2 0/4] TC phy check cleanupQuoted 6 lines · Radhakrishna Sripada
We are relying on end-less if-else ladders for a type-c phy capabilities check. Though it made sense when platforms supported legacy type-c support, modern platforms rely on the information passed by vbt. This cleanup restricts the if-else ladder to the platforms supporting legacy type-c phys and relies on vbt info for modern client and discrete platforms.
This series is moving the vbt handling in the wrong direction.
We want to *avoid* new lookups. The idea is that you do the lookup *once* when initializing the encoder, and after that you use
encoder->devdata.If you look at the
intel_phy_is_tc()call sites, you'll observe that almost all of the places have the encoder (or devdata) already available. They get the port fromencoder->port, and the phy fromintel_port_to_phy().So this throws away the information that's already available, and then goes to look it up again in the worst possible way.
Quoted 7 lines
You should convert
intel_phy_is_tc()to something likeintel_encoder_is_tc(), and pass encoder to it instead of phy. Similarly,intel_port_to_tc()should be converted tointel_encoder_to_tc().There are a couple of special cases that only have devdata or phy. But we can handle the special cases after making the common case straightforward.
Common case making a tc check out of encoder sure makes lot of sense
And agreed to you point. The question that arises in the special cases. For ex. during vbt_defaults init in intel_bios.c, I can only handle for legacy tc ports.
In other cases where only phy info is available, I may have to iterate over all the drm_encoders to obtain port info and compare it with phy info adding lot of lookup overhead. Or we may have to use encoder based lookups in all associated lookups like icl_port_to_ddc_pin etc.
Thoughts?
Radhakrishna(RK) Sripada
Quoted 28 lines
BR,
Jani.Quoted 9 lines
v2: Move cleanup vbt later to handle safe encoder removal
Radhakrishna Sripada (4):
drm/i915: Moveintel_bios_driver_removelater drm/i915: Renameintel_bios_encoder_data_lookupas a port variant drm/i915: Introduceintel_encoder_phy_data_lookupdrm/i915: Separate tc check for legacy and non legacy tc physQuoted 10 lines
drivers/gpu/drm/i915/display/g4x_dp.c | 2 +- drivers/gpu/drm/i915/display/g4x_hdmi.c | 2 +- drivers/gpu/drm/i915/display/intel_bios.c | 15 +++++++++- drivers/gpu/drm/i915/display/intel_bios.h | 5 +++- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + .../drm/i915/display/intel_display_driver.c | 4 +-- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 9 files changed, 44 insertions(+), 18 deletions(-)--
Jani Nikula, Intel
Jani Nikula
maintainerQuoted 43 lines · Radhakrishna
Hi Jani,
Quoted 30 lines
-----Original Message-----
From: Jani Nikula <[email protected]>
Sent: Thursday, December 21, 2023 2:04 AM
To: Sripada, Radhakrishna <[email protected]>; intel- [email protected]
Subject: Re: [PATCH v2 0/4] TC phy check cleanupQuoted 6 lines · Radhakrishna Sripada
We are relying on end-less if-else ladders for a type-c phy capabilities check. Though it made sense when platforms supported legacy type-c support, modern platforms rely on the information passed by vbt. This cleanup restricts the if-else ladder to the platforms supporting legacy type-c phys and relies on vbt info for modern client and discrete platforms.
This series is moving the vbt handling in the wrong direction.
We want to *avoid* new lookups. The idea is that you do the lookup *once* when initializing the encoder, and after that you use
encoder->devdata.If you look at the
intel_phy_is_tc()call sites, you'll observe that almost all of the places have the encoder (or devdata) already available. They get the port fromencoder->port, and the phy fromintel_port_to_phy().So this throws away the information that's already available, and then goes to look it up again in the worst possible way.
Quoted 7 lines
You should convert
intel_phy_is_tc()to something likeintel_encoder_is_tc(), and pass encoder to it instead of phy. Similarly,intel_port_to_tc()should be converted tointel_encoder_to_tc().There are a couple of special cases that only have devdata or phy. But we can handle the special cases after making the common case straightforward.
Common case making a tc check out of encoder sure makes lot of sense
And agreed to you point. The question that arises in the special cases. For ex. duringvbt_defaultsinit inintel_bios.c, I can only handle for legacy tc ports.
Quoted 6 lines
In other cases where only phy info is available, I may have to iterate over all the
drm_encodersto obtain port info and compare it with phy info adding lot of lookup overhead. Or we may have to use encoder based lookups in all associated lookups likeicl_port_to_ddc_pinetc.Thoughts?
Frankly, the way I often handle stuff like this is just start making the changes for the things that obviously make sense. Such as looking the tc info up via the encoder. You can add the new function(s) and gradually switch over. It's mostly mechanical changes and pretty quick to do. I think it'll even clean up a bunch of local enum port and enum phy usages.
And often the answer to the rest just presents itself.
Sometimes the answer is, well, to leave an ugly wart in 1% of the cases while making 99% of the cases pretty. And that's still better than having 100% poor design.
Sometimes you find out you have to redo some of the stuff you did at first, but it's because you figure things out along the way. For me at least, this is how the bright ideas come to mind more often than via up front design attempts.
HTH,
Jani.
Quoted 30 lines
Radhakrishna(RK) Sripada
Quoted 28 lines
BR,
Jani.Quoted 9 lines
v2: Move cleanup vbt later to handle safe encoder removal
Radhakrishna Sripada (4):
drm/i915: Moveintel_bios_driver_removelater drm/i915: Renameintel_bios_encoder_data_lookupas a port variant drm/i915: Introduceintel_encoder_phy_data_lookupdrm/i915: Separate tc check for legacy and non legacy tc physQuoted 10 lines
drivers/gpu/drm/i915/display/g4x_dp.c | 2 +- drivers/gpu/drm/i915/display/g4x_hdmi.c | 2 +- drivers/gpu/drm/i915/display/intel_bios.c | 15 +++++++++- drivers/gpu/drm/i915/display/intel_bios.h | 5 +++- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + .../drm/i915/display/intel_display_driver.c | 4 +-- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 9 files changed, 44 insertions(+), 18 deletions(-)--
Jani Nikula, Intel
Signature · 1 line
Jani Nikula, Intel
Hi Jani,
Thank you for that insight. I will use it for future reference. And as in this case the 1%wart looks better. Need to evaluate if having a tc_phy_mask(as pointed by Imre) in platform info will make things pretty in this case.
Regards,
Radhakrishna(RK) Sripada
Quoted 118 lines
-----Original Message-----
From: Jani Nikula <[email protected]>
Sent: Friday, December 22, 2023 2:04 AM
To: Sripada, Radhakrishna <[email protected]>; intel- [email protected]
Subject: RE: [PATCH v2 0/4] TC phy check cleanupQuoted 10 lines · Radhakrishna
Hi Jani,
Quoted 8 lines
-----Original Message-----
From: Jani Nikula <[email protected]>
Sent: Thursday, December 21, 2023 2:04 AM
To: Sripada, Radhakrishna <[email protected]>; intel- [email protected]
Subject: Re: [PATCH v2 0/4] TC phy check cleanupOn Wed, 20 Dec 2023, Radhakrishna Sripada
Quoted 26 lines
Quoted 26 lines
Quoted 6 lines · wrote:
We are relying on end-less if-else ladders for a type-c phy capabilities check. Though it made sense when platforms supported legacy type-c support, modern platforms rely on the information passed by vbt. This cleanup restricts the if-else ladder to the platforms supporting legacy type-c phys and relies on vbt info for modern client and discrete platforms.
This series is moving the vbt handling in the wrong direction.
We want to *avoid* new lookups. The idea is that you do the lookup *once* when initializing the encoder, and after that you use
encoder->devdata.If you look at the
intel_phy_is_tc()call sites, you'll observe that almost all of the places have the encoder (or devdata) already available. They get the port fromencoder->port, and the phy fromintel_port_to_phy().So this throws away the information that's already available, and then goes to look it up again in the worst possible way.
You should convert
intel_phy_is_tc()to something likeintel_encoder_is_tc(), and pass encoder to it instead of phy. Similarly,intel_port_to_tc()should be converted tointel_encoder_to_tc().Quoted 6 lines
Quoted 3 lines
There are a couple of special cases that only have devdata or phy. But we can handle the special cases after making the common case straightforward.
Common case making a tc check out of encoder sure makes lot of sense And agreed to you point. The question that arises in the special cases. For ex. during
vbt_defaultsinit inintel_bios.c, I can only handle for legacy tcports.
Quoted 3 lines
In other cases where only phy info is available, I may have to iterate over all the
drm_encodersto obtain port info and compare it with phy info adding lot oflookup
Quoted 1 line
overhead. Or we may have to use encoder based lookups in all associated
lookups like
Quoted 3 lines
icl_port_to_ddc_pinetc.Thoughts?
Frankly, the way I often handle stuff like this is just start making the changes for the things that obviously make sense. Such as looking the tc info up via the encoder. You can add the new function(s) and gradually switch over. It's mostly mechanical changes and pretty quick to do. I think it'll even clean up a bunch of local enum port and enum phy usages.
And often the answer to the rest just presents itself.
Sometimes the answer is, well, to leave an ugly wart in 1% of the cases while making 99% of the cases pretty. And that's still better than having 100% poor design.
Sometimes you find out you have to redo some of the stuff you did at first, but it's because you figure things out along the way. For me at least, this is how the bright ideas come to mind more often than via up front design attempts.
HTH,
Jani.Quoted 30 lines
Radhakrishna(RK) Sripada
Quoted 28 lines
BR,
Jani.Quoted 9 lines
v2: Move cleanup vbt later to handle safe encoder removal
Radhakrishna Sripada (4):
drm/i915: Moveintel_bios_driver_removelater drm/i915: Renameintel_bios_encoder_data_lookupas a port variant drm/i915: Introduceintel_encoder_phy_data_lookupdrm/i915: Separate tc check for legacy and non legacy tc physQuoted 10 lines
drivers/gpu/drm/i915/display/g4x_dp.c | 2 +- drivers/gpu/drm/i915/display/g4x_hdmi.c | 2 +- drivers/gpu/drm/i915/display/intel_bios.c | 15 +++++++++- drivers/gpu/drm/i915/display/intel_bios.h | 5 +++- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 29 ++++++++++++------- .../drm/i915/display/intel_display_device.h | 1 + .../drm/i915/display/intel_display_driver.c | 4 +-- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 9 files changed, 44 insertions(+), 18 deletions(-)--
Jani Nikula, Intel--
Jani Nikula, Intel