Add eDP lane mapping support
Subsystems (6)
v6 cover Add eDP lane mapping support
This series adds configurable eDP physical lane mapping support via device tree data-lanes property.
Lane mapping is mainly used for below scenarios:
1. Correct PCB lane swap and differential line routing crossover without hardware changes;
2. Adapt mismatched lane pin definitions between SoC and eDP panel;
3. Support multiple panel hardware variants on the same board by configuring data-lanes in device tree only.
The series includes driver implementation and device tree binding updates to support custom lane mapping configuration from endpoint node, and keeps default linear lane order if no configuration is given.
Patch 1: Add endpoint data-lanes property to analogix-dp binding Patch 2: Add DRM DP helper API to validate DP lane counts Patch 3: Restore mandatory for samsung,link-rate and samsung,lane-count
properties
Patch 4: Add validation for samsung,lane-count property as preparation Patch 5: Implement lane mapping in analogix_dp driver
Damon Ding (5):
dt-bindings: display: bridge: analogix-dp: Add data-lanes support for
endpoint
drm/dp: Add helper to validate DP lane counts
drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties drm/bridge: analogix_dp: Add validation for samsung,lane-count
property
drm/bridge: analogix_dp: Add support for optional data-lanes mapping
.../bindings/display/bridge/analogix,dp.yaml | 19 +++-- .../rockchip/rockchip,analogix-dp.yaml | 1 + .../drm/bridge/analogix/analogix_dp_core.c | 70 +++++++++++++++++-- .../drm/bridge/analogix/analogix_dp_core.h | 4 +- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 15 ++-- .../gpu/drm/bridge/analogix/analogix_dp_reg.h | 4 ++ include/drm/display/drm_dp_helper.h | 6 ++ 7 files changed, 101 insertions(+), 18 deletions(-)
---
Changes in v2:
- Add lane mapping application scenarios in commit message.
- Remove redundant deprecated property 'data-lanes' for eDP node.
- Update port@1 $ref to /schemas/graph.yaml#/$defs/port-base.
Changes in v3:
- Squash [PATCH v2 2/3] into [PATCH v2 1/3].
- Add unevaluatedProperties: false to both the port@1 and endpoint nodes.
Changes in v4:
- Add validation for samsung,lane-count property as preparation.
Changes in v5:
- Add DRM DP helper API to validate DP lane counts.
- Apply DRM DP helper API to check the validity of samsung,lane-count property.
- Add Acked-by and Reviewed-by tags.
Changes in v6:
- Add a seperate commit to restore mandatory samsung DP DT properties.
- Add Reviewed-by tag.
Signature · 7 lines
2.34.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH v6 1/5 dt-bindings: display: bridge: analogix-dp: Add data-lanes support for endpoint
Add data-lanes property support to the port@1 endpoint for physical lane mapping configuration.
Lane mapping is mainly used for below scenarios:
1. Correct PCB lane swap and differential line routing crossover without hardware changes;
2. Adapt mismatched lane pin definitions between SoC and eDP panel;
3. Support multiple panel hardware variants on the same board by configuring data-lanes in device tree only.
Additionally, add data-lanes setting in Rockchip eDP DT node example to show actual lane mapping usage.
---
Changes in v2:
- Add lane mapping application scenarios in commit message.
- Remove redundant deprecated property 'data-lanes' for eDP node.
- Update port@1 $ref to /schemas/graph.yaml#/$defs/port-base.
Changes in v3:
- Squash data-lanes adjustment of Rockchip eDP DT example into this commit.
- Add unevaluatedProperties: false to both the port@1 and endpoint nodes.
Changes in v5
- Add Acked-by and Reviewed-by tags.
--- .../bindings/display/bridge/analogix,dp.yaml | 19 ++++++++++++++----- .../rockchip/rockchip,analogix-dp.yaml | 1 + 2 files changed, 15 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/display/bridge/analogix,dp.yaml +14 -5
@@ -42,13 +42,22 @@ properties: properties: port@0: $ref: /schemas/graph.yaml#/properties/port - description: - Input node to receive pixel data. + description: Input node to receive pixel data. port@1: - $ref: /schemas/graph.yaml#/properties/port - description: - Port node with one endpoint connected to a dp-connector node. + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: Port node with one endpoint connected to sink device node. + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + properties: + data-lanes: + minItems: 1 + maxItems: 4 + items: + enum: [ 0, 1, 2, 3 ] required: - port@0
Documentation/devicetree/bindings/display/rockchip/rockchip,analogix-dp.yaml +1 -0
@@ -160,6 +160,7 @@ examples: reg = <1>; edp_out_panel: endpoint { + data-lanes = <0 1>; remote-endpoint = <&panel_in_edp>; }; };
Signature · 1 line
2.34.1
PATCH v6 2/5 drm/dp: Add helper to validate DP lane counts
In reply to Damon DingAdd a generic helper function drm_dp_lane_count_is_valid() to check if a DisplayPort lane count is valid. According to the DP specification, only 1, 2, or 4 lanes are supported.
This helper avoids duplicating DP lane count validation logic across individual DisplayPort drivers.
---
Changes in v6:
- Add Reviewed-by tag.
--- include/drm/display/drm_dp_helper.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/drm/display/drm_dp_helper.h +6 -0
@@ -138,6 +138,12 @@ bool drm_dp_as_sdp_supported(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_Cint drm_dp_psr_setup_time (const u8 psr_cap[EDP_PSR_RECEIVER_CAP_SIZE ]); +static inline bool +drm_dp_lane_count_is_valid (int lane_count) +{ +return lane_count ==1 || lane_count ==2 || lane_count ==4 ; +} +static inline int drm_dp_max_link_rate (const u8 dpcd[DP_RECEIVER_CAP_SIZE ]) {
Signature · 7 lines
2.34.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH v6 3/5 drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
In reply to Damon DingRevert the change that made samsung,link-rate and samsung,lane-count optional for Exynos DP. Add error checking to fail probe early if the required DT properties are missing.
If these properties are zero, &link_train.link_rate and &link_train.lane_count used in the subsequent link training flow will also be zero, resulting in link training failure. Although all existing Exynos DP DT nodes already contain these two properties, this potential logic issue still needs to be fixed.
--- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +9 -4
@@ -1244,6 +1244,7 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) {struct device_node *dp_node = dp->dev->of_node;struct video_info *video_info = &dp->video_info; +u32 val;switch (dp->plat_data->dev_type) {case RK3288_DP :
@@ -1265,10 +1266,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" ); + video_info->max_link_rate = val; +if (of_property_read_u32 (dp_node,"samsung,lane-count" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,lane-count\n" ); + video_info->max_lane_count = val;break ; }
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v6 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Critical] Failing probe when deprecated DT properties are missing breaks DT ABI and prevents their…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Failing probe when deprecated DT properties are missing breaks DT ABI and prevents their deprecation. --
--- Patch [3]: [PATCH v6 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties --- commit b573dba50acc6087122ffa4a65680322f4d004f8
Author: Damon Ding <[email protected]>
drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
This commit reverts a change that made the samsung,link-rate and samsung,lane-count properties optional for Exynos DP. It adds error checking to fail the probe early if these properties are missing, aiming to prevent link training failures caused by zero values.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0
[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1264
Quoted 11 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3
-4@@ -1258,10 +1259,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" );
[Severity: Critical]
Does failing the probe when this property is missing break the DT ABI?
Since samsung,link-rate is a deprecated property, a modern schema-compliant Device Tree might intentionally omit it. If a system boots with such a DT, this check will fail the probe with -EINVAL and disable the display.
Could the driver instead fall back to hardware maximums or sensible defaults when the deprecated property is absent, rather than returning an error?
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1275
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +4
-0+ video_info->max_link_rate = val; +if (of_property_read_u32 (dp_node,"samsung,lane-count" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,lane-count\n" );
[Severity: Critical]
Does making samsung,lane-count mandatory similarly break backward compatibility for valid Device Trees that have intentionally omitted this deprecated property?
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1
-0+ video_info->max_lane_count = val;break ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v6 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
Quoted 35 lines · On 7/7/2026 12:17 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Failing probe when deprecated DT properties are missing breaks DT ABI and prevents their deprecation. ----- Patch [3]: [PATCH v6 3/5] drm/bridge:
analogix_dp: Restore mandatory samsung DP DT properties --- commitb573dba50acc6087122ffa4a65680322f4d004f8
Author: Damon Ding <[email protected]>drm/bridge:
analogix_dp: Restore mandatory samsung DP DT propertiesThis commit reverts a change that made the samsung,link-rate and samsung,lane-count properties optional for Exynos DP. It adds error checking to fail the probe early if these properties are missing, aiming to prevent link training failures caused by zero values.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1264
Quoted 11 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3
-4@@ -1258,10 +1259,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" );[Severity: Critical]
Does failing the probe when this property is missing break the DT ABI?
Quoted 7 lines
Since samsung,link-rate is a deprecated property, a modern schema-compliant Device Tree might intentionally omit it. If a system boots with such a DT, this check will fail the probe with
-EINVALand disable the display.Could the driver instead fall back to hardware maximums or sensible defaults when the deprecated property is absent, rather than returning an error?
I'm afraid it's difficult to provide a universal sensible default value here.
The samsung,lane-count and samsung,link-rate values vary significantly across Exynos DP device trees, so a generic fallback to hardware maximums cannot guarantee stable link training.
Even though these two properties are marked deprecated, all existing DTS files in our projects have already populated them completely. Moreover, the current link training logic relies on these two parameters; omitting either will directly cause link training failures at runtime.
Therefore, retaining the mandatory property check in probe is a reasonable approach for now.
Quoted 9 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1275
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +4
-0+ video_info->max_link_rate = val; +if (of_property_read_u32 (dp_node,"samsung,lane-count" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,lane-count\n" );[Severity: Critical]
Does making samsung,lane-count mandatory similarly break backward compatibility for valid Device Trees that have intentionally omitted this deprecated property?
I don't think so. Missing either property will inevitably cause link training failure, and all functional DTs have these deprecated properties filled in already.
Quoted 5 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1279
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1
-0+ video_info->max_lane_count = val;break ; }
Best regards,
Damon
Luca Ceresoli
reviewerRe: [PATCH v6 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
Hello Damon,
Quoted 51 lines · Damon Ding
Quoted 35 lines · On 7/7/2026 12:17 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Failing probe when deprecated DT properties are missing breaks DT ABI and prevents their deprecation. ----- Patch [3]: [PATCH v6 3/5] drm/bridge:
analogix_dp: Restore mandatory samsung DP DT properties --- commitb573dba50acc6087122ffa4a65680322f4d004f8
Author: Damon Ding <[email protected]>drm/bridge:
analogix_dp: Restore mandatory samsung DP DT propertiesThis commit reverts a change that made the samsung,link-rate and samsung,lane-count properties optional for Exynos DP. It adds error checking to fail the probe early if these properties are missing, aiming to prevent link training failures caused by zero values.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1264
Quoted 11 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3
-4@@ -1258,10 +1259,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" );[Severity: Critical]
Does failing the probe when this property is missing break the DT ABI?Quoted 7 lines
Since samsung,link-rate is a deprecated property, a modern schema-compliant Device Tree might intentionally omit it. If a system boots with such a DT, this check will fail the probe with
-EINVALand disable the display.Could the driver instead fall back to hardware maximums or sensible defaults when the deprecated property is absent, rather than returning an error?
I'm afraid it's difficult to provide a universal sensible default value here.
The samsung,lane-count and samsung,link-rate values vary significantly across Exynos DP device trees, so a generic fallback to hardware maximums cannot guarantee stable link training.
Quoted 7 lines
Even though these two properties are marked deprecated, all existing DTS files in our projects have already populated them completely. Moreover, the current link training logic relies on these two parameters; omitting either will directly cause link training failures at runtime.
Therefore, retaining the mandatory property check in probe is a reasonable approach for now.
I'm still not convinced we should turn an optional property into mandatory, after having been optional since 2016 (based on the commit in the Fixes:
tag).
The sure thing is we cannot break existing devices which upgrade to a new kernel.
Se the question is: if a device is missing one of these properties, or both, what happens? The video_info->max_link_rate and/or video_info->max_lane_count will be zero, correct? And if they are zero, is there even a remote possibility that the device will work somehow, maybe only with some rare low resolution or whatever?
If the answer is "yes, there is a remote possibility that one sich device, with some maybe rare configuration, will work", then no, we cannot make this property mandatory now. There can be devices out there working without these proberties, and they would be broken.
If the answer is "there is no way at all a device can work without one or both properties", with a good explanation based on the code flow and hardware docs, then we can consider this change.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: [PATCH v6 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
Hi Luca,
Quoted 75 lines · Luca Ceresoli
Hello Damon,
Quoted 51 lines · Damon Ding
Quoted 35 lines · On 7/7/2026 12:17 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Failing probe when deprecated DT properties are missing breaks DT ABI and prevents their deprecation. ----- Patch [3]: [PATCH v6 3/5] drm/bridge:
analogix_dp: Restore mandatory samsung DP DT properties --- commitb573dba50acc6087122ffa4a65680322f4d004f8
Author: Damon Ding <[email protected]>drm/bridge:
analogix_dp: Restore mandatory samsung DP DT propertiesThis commit reverts a change that made the samsung,link-rate and samsung,lane-count properties optional for Exynos DP. It adds error checking to fail the probe early if these properties are missing, aiming to prevent link training failures caused by zero values.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1264
Quoted 11 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3
-4@@ -1258,10 +1259,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" );[Severity: Critical]
Does failing the probe when this property is missing break the DT ABI?Quoted 7 lines
Since samsung,link-rate is a deprecated property, a modern schema-compliant Device Tree might intentionally omit it. If a system boots with such a DT, this check will fail the probe with
-EINVALand disable the display.Could the driver instead fall back to hardware maximums or sensible defaults when the deprecated property is absent, rather than returning an error?
I'm afraid it's difficult to provide a universal sensible default value here.
The samsung,lane-count and samsung,link-rate values vary significantly across Exynos DP device trees, so a generic fallback to hardware maximums cannot guarantee stable link training.
Quoted 7 lines
Even though these two properties are marked deprecated, all existing DTS files in our projects have already populated them completely. Moreover, the current link training logic relies on these two parameters; omitting either will directly cause link training failures at runtime.
Therefore, retaining the mandatory property check in probe is a reasonable approach for now.
I'm still not convinced we should turn an optional property into mandatory, after having been optional since 2016 (based on the commit in the Fixes:
tag).The sure thing is we cannot break existing devices which upgrade to a new kernel.
Se the question is: if a device is missing one of these properties, or both, what happens? The
video_info->max_link_rateand/orvideo_info->max_lane_countwill be zero, correct? And if they are zero, is there even a remote possibility that the device will work somehow, maybe only with some rare low resolution or whatever?
Quoted 9 lines
If the answer is "yes, there is a remote possibility that one sich device, with some maybe rare configuration, will work", then no, we cannot make this property mandatory now. There can be devices out there working without these proberties, and they would be broken.
If the answer is "there is no way at all a device can work without one or both properties", with a good explanation based on the code flow and hardware docs, then we can consider this change.
Sorry for the confusion, I just submitted the v7 series which crossed with your reply.
To answer your question: there is no way at all a device can work without these properties. Here is the code flow when either max_link_rate or max_lane_count is 0 (helped by AI):
analogix_dp_commit()
-> analogix_dp_full_link_train(dp, max_lanes = 0, max_rate = 0)
analogix_dp_full_link_train(max_lanes, max_rate):
// Read sink capabilities via DPCD and sanitize them
link_rate = read_dpcd(DP_MAX_LINK_RATE); // >= 0x06 after fixup
lane_count = read_dpcd(DP_MAX_LANE_COUNT);// >= 1 after fixup
// Clamp by the limits from DT
if (link_rate > max_rate) // 0x06 > 0, always true
link_rate = max_rate; // link_rate = 0
if (lane_count > max_lanes) // 1 > 0, always true
lane_count = max_lanes; // lane_count = 0
// Configure TX with the zeroed values
set_link_bandwidth(link_rate = 0)
// writel() is only executed for bwtype == 0x06/0x0a,
// so LINK_BW_SET is never written and stays at reset value;
// phy_configure() is called with link_rate = 0.
set_lane_count(lane_count = 0)
// writel(0, ANALOGIX_DP_LANE_COUNT_SET) enables 0 lanes;
// phy_configure() is called with lanes = 0.
// Program sink for link training
drm_dp_dpcd_write(DP_LINK_BW_SET, {link_rate = 0, lane_count = 0})
// DP spec requires link rate in {0x06, 0x0a, 0x14} and
// lane count in {1, 2, 4}. Writing zeros is illegal, so the
// sink cannot enter the training state.
// Training loop
for (lane = 0; lane < lane_count /* 0 */; lane++)
// loop body never executes; training_lane[] stays
// uninitialized and no training register is ever programmedSince the sanitized sink values are always non-zero (link_rate >= 0x06,lane_count >= 1), the clamping with a zero maximum unconditionally
forces the training parameters to zero. Clock recovery can never be achieved, so link training fails deterministically.
Best regards,
Damon
Luca Ceresoli
reviewerRe: [PATCH v6 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
Hello,
Quoted 130 lines · Damon Ding
Hi Luca,
Quoted 75 lines · Luca Ceresoli
Hello Damon,
Quoted 51 lines · Damon Ding
Quoted 35 lines · On 7/7/2026 12:17 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Failing probe when deprecated DT properties are missing breaks DT ABI and prevents their deprecation. ----- Patch [3]: [PATCH v6 3/5] drm/bridge:
analogix_dp: Restore mandatory samsung DP DT properties --- commitb573dba50acc6087122ffa4a65680322f4d004f8
Author: Damon Ding <[email protected]>drm/bridge:
analogix_dp: Restore mandatory samsung DP DT propertiesThis commit reverts a change that made the samsung,link-rate and samsung,lane-count properties optional for Exynos DP. It adds error checking to fail the probe early if these properties are missing, aiming to prevent link training failures caused by zero values.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1264
Quoted 11 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3
-4@@ -1258,10 +1259,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" );[Severity: Critical]
Does failing the probe when this property is missing break the DT ABI?Quoted 7 lines
Since samsung,link-rate is a deprecated property, a modern schema-compliant Device Tree might intentionally omit it. If a system boots with such a DT, this check will fail the probe with
-EINVALand disable the display.Could the driver instead fall back to hardware maximums or sensible defaults when the deprecated property is absent, rather than returning an error?
I'm afraid it's difficult to provide a universal sensible default value here.
The samsung,lane-count and samsung,link-rate values vary significantly across Exynos DP device trees, so a generic fallback to hardware maximums cannot guarantee stable link training.
Quoted 7 lines
Even though these two properties are marked deprecated, all existing DTS files in our projects have already populated them completely. Moreover, the current link training logic relies on these two parameters; omitting either will directly cause link training failures at runtime.
Therefore, retaining the mandatory property check in probe is a reasonable approach for now.
I'm still not convinced we should turn an optional property into mandatory, after having been optional since 2016 (based on the commit in the Fixes:
tag).The sure thing is we cannot break existing devices which upgrade to a new kernel.
Se the question is: if a device is missing one of these properties, or both, what happens? The
video_info->max_link_rateand/orvideo_info->max_lane_countwill be zero, correct? And if they are zero, is there even a remote possibility that the device will work somehow, maybe only with some rare low resolution or whatever?Quoted 9 lines
If the answer is "yes, there is a remote possibility that one sich device, with some maybe rare configuration, will work", then no, we cannot make this property mandatory now. There can be devices out there working without these proberties, and they would be broken.
If the answer is "there is no way at all a device can work without one or both properties", with a good explanation based on the code flow and hardware docs, then we can consider this change.
Sorry for the confusion, I just submitted the v7 series which crossed with your reply.
To answer your question: there is no way at all a device can work without these properties. Here is the code flow when either
max_link_rateormax_lane_countis 0 (helped by AI):analogix_dp_commit() -> analogix_dp_full_link_train(dp, max_lanes = 0, max_rate = 0) analogix_dp_full_link_train(max_lanes, max_rate): // Read sink capabilities via DPCD and sanitize them link_rate = read_dpcd(DP_MAX_LINK_RATE); // >= 0x06 after fixup lane_count = read_dpcd(DP_MAX_LANE_COUNT);// >= 1 after fixup // Clamp by the limits from DT if (link_rate > max_rate) // 0x06 > 0, always true link_rate = max_rate; // link_rate = 0 if (lane_count > max_lanes) // 1 > 0, always true lane_count = max_lanes; // lane_count = 0 // Configure TX with the zeroed values set_link_bandwidth(link_rate = 0) // writel() is only executed for bwtype == 0x06/0x0a, // so LINK_BW_SET is never written and stays at reset value; // phy_configure() is called with link_rate = 0. set_lane_count(lane_count = 0) // writel(0, ANALOGIX_DP_LANE_COUNT_SET) enables 0 lanes; // phy_configure() is called with lanes = 0. // Program sink for link training drm_dp_dpcd_write(DP_LINK_BW_SET, {link_rate = 0, lane_count = 0}) // DP spec requires link rate in {0x06, 0x0a, 0x14} and // lane count in {1, 2, 4}. Writing zeros is illegal, so the // sink cannot enter the training state. // Training loop for (lane = 0; lane < lane_count /* 0 */; lane++) // loop body never executes; training_lane[] stays // uninitialized and no training register is ever programmed
Quoted 4 lines
Since the sanitized sink values are always non-zero (
link_rate>=0x06,lane_count>= 1), the clamping with a zero maximum unconditionally forces the training parameters to zero. Clock recovery can never be achieved, so link training fails deterministically.
Thank you very much for the detailed analysis! To it is enough to proceed. I'll review your v7.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: [PATCH v6 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
Hi,
Quoted 133 lines · Luca Ceresoli
Hello,
Quoted 130 lines · Damon Ding
Hi Luca,
Quoted 75 lines · Luca Ceresoli
Hello Damon,
Quoted 51 lines · Damon Ding
Quoted 35 lines · On 7/7/2026 12:17 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Failing probe when deprecated DT properties are missing breaks DT ABI and prevents their deprecation. ----- Patch [3]: [PATCH v6 3/5] drm/bridge:
analogix_dp: Restore mandatory samsung DP DT properties --- commitb573dba50acc6087122ffa4a65680322f4d004f8
Author: Damon Ding <[email protected]>drm/bridge:
analogix_dp: Restore mandatory samsung DP DT propertiesThis commit reverts a change that made the samsung,link-rate and samsung,lane-count properties optional for Exynos DP. It adds error checking to fail the probe early if these properties are missing, aiming to prevent link training failures caused by zero values.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1264
Quoted 11 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3
-4@@ -1258,10 +1259,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" );[Severity: Critical]
Does failing the probe when this property is missing break the DT ABI?Quoted 7 lines
Since samsung,link-rate is a deprecated property, a modern schema-compliant Device Tree might intentionally omit it. If a system boots with such a DT, this check will fail the probe with
-EINVALand disable the display.Could the driver instead fall back to hardware maximums or sensible defaults when the deprecated property is absent, rather than returning an error?
I'm afraid it's difficult to provide a universal sensible default value here.
The samsung,lane-count and samsung,link-rate values vary significantly across Exynos DP device trees, so a generic fallback to hardware maximums cannot guarantee stable link training.
Quoted 7 lines
Even though these two properties are marked deprecated, all existing DTS files in our projects have already populated them completely. Moreover, the current link training logic relies on these two parameters; omitting either will directly cause link training failures at runtime.
Therefore, retaining the mandatory property check in probe is a reasonable approach for now.
I'm still not convinced we should turn an optional property into mandatory, after having been optional since 2016 (based on the commit in the Fixes:
tag).The sure thing is we cannot break existing devices which upgrade to a new kernel.
Se the question is: if a device is missing one of these properties, or both, what happens? The
video_info->max_link_rateand/orvideo_info->max_lane_countwill be zero, correct? And if they are zero, is there even a remote possibility that the device will work somehow, maybe only with some rare low resolution or whatever?Quoted 9 lines
If the answer is "yes, there is a remote possibility that one sich device, with some maybe rare configuration, will work", then no, we cannot make this property mandatory now. There can be devices out there working without these proberties, and they would be broken.
If the answer is "there is no way at all a device can work without one or both properties", with a good explanation based on the code flow and hardware docs, then we can consider this change.
Sorry for the confusion, I just submitted the v7 series which crossed with your reply.
To answer your question: there is no way at all a device can work without these properties. Here is the code flow when either
max_link_rateormax_lane_countis 0 (helped by AI):analogix_dp_commit() -> analogix_dp_full_link_train(dp, max_lanes = 0, max_rate = 0) analogix_dp_full_link_train(max_lanes, max_rate): // Read sink capabilities via DPCD and sanitize them link_rate = read_dpcd(DP_MAX_LINK_RATE); // >= 0x06 after fixup lane_count = read_dpcd(DP_MAX_LANE_COUNT);// >= 1 after fixup // Clamp by the limits from DT if (link_rate > max_rate) // 0x06 > 0, always true link_rate = max_rate; // link_rate = 0 if (lane_count > max_lanes) // 1 > 0, always true lane_count = max_lanes; // lane_count = 0 // Configure TX with the zeroed values set_link_bandwidth(link_rate = 0) // writel() is only executed for bwtype == 0x06/0x0a, // so LINK_BW_SET is never written and stays at reset value; // phy_configure() is called with link_rate = 0. set_lane_count(lane_count = 0) // writel(0, ANALOGIX_DP_LANE_COUNT_SET) enables 0 lanes; // phy_configure() is called with lanes = 0. // Program sink for link training drm_dp_dpcd_write(DP_LINK_BW_SET, {link_rate = 0, lane_count = 0}) // DP spec requires link rate in {0x06, 0x0a, 0x14} and // lane count in {1, 2, 4}. Writing zeros is illegal, so the // sink cannot enter the training state. // Training loop for (lane = 0; lane < lane_count /* 0 */; lane++) // loop body never executes; training_lane[] stays // uninitialized and no training register is ever programmed
Quoted 7 lines
Quoted 4 lines
Since the sanitized sink values are always non-zero (
link_rate>=0x06,lane_count>= 1), the clamping with a zero maximum unconditionally forces the training parameters to zero. Clock recovery can never be achieved, so link training fails deterministically.Thank you very much for the detailed analysis! To it is enough to proceed. I'll review your v7.
Can't the default for missing properties just be changed to 4 lanes and 0x14 rate and the DP link training would automatically train to less lanes / rates based on hardware capabilities (which would render the properties basically useless except for a small speedup during link training)?
Greetings,
-- Sebastian
Re: [PATCH v6 3/5] drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
Hi Sebastian,
Quoted 141 lines · Sebastian Reichel
Hi,
Quoted 138 lines · Luca Ceresoli
Hello,
Quoted 134 lines · Damon Ding
Hi Luca,
Quoted 75 lines · Luca Ceresoli
Hello Damon,
Quoted 51 lines · Damon Ding
Quoted 35 lines · On 7/7/2026 12:17 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Failing probe when deprecated DT properties are missing breaks DT ABI and prevents their deprecation. ----- Patch [3]: [PATCH v6 3/5] drm/bridge:
analogix_dp: Restore mandatory samsung DP DT properties --- commitb573dba50acc6087122ffa4a65680322f4d004f8
Author: Damon Ding <[email protected]>drm/bridge:
analogix_dp: Restore mandatory samsung DP DT propertiesThis commit reverts a change that made the samsung,link-rate and samsung,lane-count properties optional for Exynos DP. It adds error checking to fail the probe early if these properties are missing, aiming to prevent link training failures caused by zero values.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) · line 1264
Quoted 11 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3
-4@@ -1258,10 +1259,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" );[Severity: Critical]
Does failing the probe when this property is missing break the DT ABI?Quoted 7 lines
Since samsung,link-rate is a deprecated property, a modern schema-compliant Device Tree might intentionally omit it. If a system boots with such a DT, this check will fail the probe with
-EINVALand disable the display.Could the driver instead fall back to hardware maximums or sensible defaults when the deprecated property is absent, rather than returning an error?
I'm afraid it's difficult to provide a universal sensible default value here.
The samsung,lane-count and samsung,link-rate values vary significantly across Exynos DP device trees, so a generic fallback to hardware maximums cannot guarantee stable link training.
Quoted 7 lines
Even though these two properties are marked deprecated, all existing DTS files in our projects have already populated them completely. Moreover, the current link training logic relies on these two parameters; omitting either will directly cause link training failures at runtime.
Therefore, retaining the mandatory property check in probe is a reasonable approach for now.
I'm still not convinced we should turn an optional property into mandatory, after having been optional since 2016 (based on the commit in the Fixes:
tag).The sure thing is we cannot break existing devices which upgrade to a new kernel.
Se the question is: if a device is missing one of these properties, or both, what happens? The
video_info->max_link_rateand/orvideo_info->max_lane_countwill be zero, correct? And if they are zero, is there even a remote possibility that the device will work somehow, maybe only with some rare low resolution or whatever?Quoted 9 lines
If the answer is "yes, there is a remote possibility that one sich device, with some maybe rare configuration, will work", then no, we cannot make this property mandatory now. There can be devices out there working without these proberties, and they would be broken.
If the answer is "there is no way at all a device can work without one or both properties", with a good explanation based on the code flow and hardware docs, then we can consider this change.
Sorry for the confusion, I just submitted the v7 series which crossed with your reply.
To answer your question: there is no way at all a device can work without these properties. Here is the code flow when either
max_link_rateormax_lane_countis 0 (helped by AI):analogix_dp_commit() -> analogix_dp_full_link_train(dp, max_lanes = 0, max_rate = 0) analogix_dp_full_link_train(max_lanes, max_rate): // Read sink capabilities via DPCD and sanitize them link_rate = read_dpcd(DP_MAX_LINK_RATE); // >= 0x06 after fixup lane_count = read_dpcd(DP_MAX_LANE_COUNT);// >= 1 after fixup // Clamp by the limits from DT if (link_rate > max_rate) // 0x06 > 0, always true link_rate = max_rate; // link_rate = 0 if (lane_count > max_lanes) // 1 > 0, always true lane_count = max_lanes; // lane_count = 0 // Configure TX with the zeroed values set_link_bandwidth(link_rate = 0) // writel() is only executed for bwtype == 0x06/0x0a, // so LINK_BW_SET is never written and stays at reset value; // phy_configure() is called with link_rate = 0. set_lane_count(lane_count = 0) // writel(0, ANALOGIX_DP_LANE_COUNT_SET) enables 0 lanes; // phy_configure() is called with lanes = 0. // Program sink for link training drm_dp_dpcd_write(DP_LINK_BW_SET, {link_rate = 0, lane_count = 0}) // DP spec requires link rate in {0x06, 0x0a, 0x14} and // lane count in {1, 2, 4}. Writing zeros is illegal, so the // sink cannot enter the training state. // Training loop for (lane = 0; lane < lane_count /* 0 */; lane++) // loop body never executes; training_lane[] stays // uninitialized and no training register is ever programmedSince the sanitized sink values are always non-zero (
link_rate>=0x06,lane_count>= 1), the clamping with a zero maximum unconditionally forces the training parameters to zero. Clock recovery can never be achieved, so link training fails deterministically.
Quoted 9 lines
Quoted 2 lines
Thank you very much for the detailed analysis! To it is enough to proceed. I'll review your v7.
Can't the default for missing properties just be changed to 4 lanes and
0x14rate and the DP link training would automatically train to less lanes / rates based on hardware capabilities (which would render the properties basically useless except for a small speedup during link training)?
Sorry for the late reply.
What you described is already how the current link training works: the source reads sink‑side lane count and link‑rate capabilities from DPCD and configures accordingly.
However, &video_info->max_link_rate and &video_info->max_lane_count represent the source SoC's maximum hardware limits, not sink capabilities.
Taking Rockchip platforms as an example: RK3288/RK3399 support maximum 4-lane 2.7 Gbps, while RK3576/RK3588 can go up to 4-lane 5.4 Gbps. If a panel supports 5.4 Gbps 4-lane but is connected to RK3399, link training must be capped at 2.7 Gbps because of the source hardware limitation.
Exynos DTS files also carry different values for these two properties to reflect their respective source-side maximum capabilities. Therefore hardcoding a fallback of 4 lanes / 5.4 Gbps is not a viable general solution, as it would mismatch the real hardware limits on various SoCs.
Best regards,
Damon
PATCH v6 4/5 drm/bridge: analogix_dp: Add validation for samsung,lane-count property
In reply to Damon DingAdd validity check for samsung,lane-count to ensure DT-provided lane count values are specification-compliant.
---
Changes in v5:
- Apply DRM DP helper API to check the validity of DP lane count.
Changes in v6:
- Rebase after the new commit for restoring mandatory properties samsung,link-rate and samsung,lane-count.
--- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +2 -1
@@ -1270,7 +1270,8 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)return dev_err_probe (dp->dev, -EINVAL ,"Failed to get samsung,link-rate\n" ); video_info->max_link_rate = val; -if (of_property_read_u32 (dp_node,"samsung,lane-count" , &val)) +if (of_property_read_u32 (dp_node,"samsung,lane-count" , &val) || + !drm_dp_lane_count_is_valid (val))return dev_err_probe (dp->dev, -EINVAL ,"Failed to get samsung,lane-count\n" ); video_info->max_lane_count = val;
Signature · 1 line
2.34.1
Re: [PATCH v6 4/5] drm/bridge: analogix_dp: Add validation for samsung,lane-count property
Quoted 2 lines · Damon Ding
Add validity check for samsung,lane-count to ensure DT-provided lane count values are specification-compliant.
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v6 5/5 drm/bridge: analogix_dp: Add support for optional data-lanes mapping
In reply to Damon DingParse the optional 'data-lanes' device tree property to support custom physical lane mapping configuration.
If no valid configuration is found, fall back to the default lane map (0, 1, 2, 3) automatically and keep the driver running.
Lane mapping is mainly used for below scenarios:
1. Correct PCB lane swap and differential line routing crossover without hardware changes;
2. Adapt mismatched lane pin definitions between SoC and eDP panel;
3. Support multiple panel hardware variants on the same board by configuring data-lanes in device tree only.
---
Changes in v2:
- Add lane mapping application scenarios in commit message.
Changes in v5:
- Add Reviewed-by tag.
--- .../drm/bridge/analogix/analogix_dp_core.c | 56 +++++++++++++++++++ .../drm/bridge/analogix/analogix_dp_core.h | 4 +- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 15 +++-- .../gpu/drm/bridge/analogix/analogix_dp_reg.h | 4 ++ 4 files changed, 70 insertions(+), 9 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +56 -0
@@ -1240,6 +1240,59 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = { .detect = analogix_dp_bridge_detect, }; +static int analogix_dp_dt_parse_lanes_map (struct analogix_dp_device *dp) +{ +struct video_info *video_info = &dp->video_info; +struct device_node *endpoint; +u32 tmp[LANE_COUNT4 ]; +u32 map[LANE_COUNT4 ] = {0 ,1 ,2 ,3 }; +bool used[LANE_COUNT4 ] = {false}; +int num_lanes; +int ret, i; + +memcpy (video_info->lane_map, map,sizeof (map)); + + num_lanes =drm_of_get_data_lanes_count_ep (dp->dev->of_node,1 ,0 ,1 , + video_info->max_lane_count); +if (num_lanes <0 ) +return -EINVAL ; + + endpoint =of_graph_get_endpoint_by_regs (dp->dev->of_node,1 ,-1 ); +if (!endpoint) +return -EINVAL ; + + ret =of_property_read_u32_array (endpoint,"data-lanes" , tmp, num_lanes); +of_node_put (endpoint); +if (ret) +return -EINVAL ; + +for (i =0 ; i < num_lanes; i++) { +if (tmp[i] >=LANE_COUNT4 ) { +dev_dbg (dp->dev,"data-lanes[%d] = %u is out of range\n" , i, tmp[i]); +return -EINVAL ; + } + +if (used[tmp[i]]) { +dev_dbg (dp->dev,"data-lanes[%d] = %u is duplicate\n" , i, tmp[i]); +return -EINVAL ; + } + + used[tmp[i]] = true; + map[i] = tmp[i]; + } + +for (i =0 ; i <LANE_COUNT4 && num_lanes <LANE_COUNT4 ; i++) { +if (!used[i]) + map[num_lanes++] = i; + } + +dev_dbg (dp->dev,"Using parsed lane map: <%u %u %u %u>\n" , map[0 ], map[1 ], map[2 ], map[3 ]); + +memcpy (video_info->lane_map, map,sizeof (map)); + +return 0 ; +} +static int analogix_dp_dt_parse_pdata (struct analogix_dp_device *dp) {struct device_node *dp_node = dp->dev->of_node;
@@ -1278,6 +1331,9 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)break ; } +if (analogix_dp_dt_parse_lanes_map (dp)) +dev_dbg (dp->dev,"No valid data-lanes found, using default lane map\n" ); +return 0 ; }
drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +3 -1
@@ -137,6 +137,8 @@ struct video_info {int max_link_rate;enum link_lane_count_type max_lane_count; + +u32 lane_map[LANE_COUNT4 ]; };struct link_train {
@@ -177,7 +179,7 @@ struct analogix_dp_device {/* analogix_dp_reg.c */ void analogix_dp_enable_video_mute (struct analogix_dp_device *dp,bool enable);void analogix_dp_stop_video (struct analogix_dp_device *dp); -void analogix_dp_lane_swap (struct analogix_dp_device *dp,bool enable); +void analogix_dp_lane_mapping (struct analogix_dp_device *dp);void analogix_dp_init_analog_param (struct analogix_dp_device *dp);void analogix_dp_init_interrupt (struct analogix_dp_device *dp);void analogix_dp_reset (struct analogix_dp_device *dp);
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +7 -8
@@ -48,16 +48,15 @@ void analogix_dp_stop_video(struct analogix_dp_device *dp)writel (reg, dp->reg_base +ANALOGIX_DP_VIDEO_CTL_1 ); } -void analogix_dp_lane_swap (struct analogix_dp_device *dp,bool enable) +void analogix_dp_lane_mapping (struct analogix_dp_device *dp) { +u32 *lane_map = dp->video_info.lane_map;u32 reg; -if (enable) - reg =LANE3_MAP_LOGIC_LANE_0 |LANE2_MAP_LOGIC_LANE_1 | -LANE1_MAP_LOGIC_LANE_2 |LANE0_MAP_LOGIC_LANE_3 ; -else - reg =LANE3_MAP_LOGIC_LANE_3 |LANE2_MAP_LOGIC_LANE_2 | -LANE1_MAP_LOGIC_LANE_1 |LANE0_MAP_LOGIC_LANE_0 ; + reg = lane_map[0 ] <<LANE0_MAP_SHIFT ; + reg |= lane_map[1 ] <<LANE1_MAP_SHIFT ; + reg |= lane_map[2 ] <<LANE2_MAP_SHIFT ; + reg |= lane_map[3 ] <<LANE3_MAP_SHIFT ;writel (reg, dp->reg_base +ANALOGIX_DP_LANE_MAP ); }
@@ -140,7 +139,7 @@ void analogix_dp_reset(struct analogix_dp_device *dp)usleep_range (20 ,30 ); -analogix_dp_lane_swap (dp,0 ); +analogix_dp_lane_mapping (dp);writel (0x0 , dp->reg_base +ANALOGIX_DP_SYS_CTL_1 );writel (0x40 , dp->reg_base +ANALOGIX_DP_SYS_CTL_2 );
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.h +4 -0
@@ -209,6 +209,10 @@#define LANE0_MAP_LOGIC_LANE_1 (0x1 << 0)#define LANE0_MAP_LOGIC_LANE_2 (0x2 << 0)#define LANE0_MAP_LOGIC_LANE_3 (0x3 << 0) +#define LANE3_MAP_SHIFT (6) +#define LANE2_MAP_SHIFT (4) +#define LANE1_MAP_SHIFT (2) +#define LANE0_MAP_SHIFT (0)/* ANALOGIX_DP_ANALOG_CTL_1 */ #define TX_TERMINAL_CTRL_50_OHM (0x1 << 4)
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v6 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] The `data-lanes` array is interpreted backwards when configuring the `ANALOGIX_DP_LANE_MAP`…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The data-lanes array is interpreted backwards when configuring the ANALOGIX_DP_LANE_MAP register, applying the inverse of the intended hardware lane mapping.
- [High] The external PHY's analog configuration (voltage and pre-emphasis) ignores the logical-to-physical lane mapping.
- [Medium] Mismatched endpoint specifiers are used when counting data lanes versus reading the data-lanes property, which could lead to parsing the wrong endpoint. --
--- Patch [5]: [PATCH v6 5/5] drm/bridge: analogix_dp: Add support for optional data-lanes mapping --- commit 99a86aa8f074546e71df9c8b7f51f7d473ef6dac
Author: Damon Ding <[email protected]>
drm/bridge: analogix_dp: Add support for optional data-lanes mapping
Parse the optional data-lanes device tree property to support custom physical lane mapping configuration. If no valid configuration is found, fall back to the default lane map automatically.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0
[ ... ]
Quoted 9 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0@@ -1234,6 +1234,59 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {static int analogix_dp_dt_parse_lanes_map (struct analogix_dp_device *dp) {struct video_info *video_info = &dp->video_info;struct device_node *endpoint;u32 tmp[LANE_COUNT4 ];u32 map[LANE_COUNT4 ] = {0 ,1 ,2 ,3 };bool used[LANE_COUNT4 ] = {false};int num_lanes;
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0int ret, i;memcpy (video_info->lane_map, map,sizeof (map)); num_lanes =drm_of_get_data_lanes_count_ep (dp->dev->of_node,1 ,0 ,1 , video_info->max_lane_count);if (num_lanes <0 )return -EINVAL ; endpoint =of_graph_get_endpoint_by_regs (dp->dev->of_node,1 ,-1 );
[Severity: Medium]
Will this return the correct endpoint if there are multiple endpoints on port 1?
When counting the data lanes, drm_of_get_data_lanes_count_ep() is called with reg = 0. However, of_graph_get_endpoint_by_regs() uses reg = -1 (wildcard), which returns the first available endpoint.
If the device tree has multiple endpoints, could this result in counting lanes on one endpoint but reading the data-lanes property from a different one?
Quoted 11 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0if (!endpoint)return -EINVAL ; ret =of_property_read_u32_array (endpoint,"data-lanes" , tmp, num_lanes);of_node_put (endpoint);if (ret)return -EINVAL ;for (i =0 ; i < num_lanes; i++) {if (tmp[i] >=LANE_COUNT4 ) {dev_dbg (dp->dev,"data-lanes[%d] = %u is out of range\n" , i, tmp[i]);
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0return -EINVAL ; }if (used[tmp[i]]) {dev_dbg (dp->dev,"data-lanes[%d] = %u is duplicate\n" , i, tmp[i]);return -EINVAL ; } used[tmp[i]] = true; map[i] = tmp[i];
[Severity: High]
Does analogix_dp_set_lane_link_training() need to be updated to use this lane map?
This parsing logic creates a logical-to-physical mapping. However, looking at analogix_dp_set_lane_link_training(), it appears to still use the logical lane index to populate the physical PHY configuration structure:
for (lane = 0; lane < lane_count; lane++) {
...
phy_cfg.dp.voltage[lane] = vs;
phy_cfg.dp.pre[lane] = pe;
...Will this cause the external PHY to apply the analog settings to the wrong physical lanes when an asymmetric mapping is used?
Quoted 6 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0}for (i =0 ; i <LANE_COUNT4 && num_lanes <LANE_COUNT4 ; i++) {if (!used[i]) map[num_lanes++] = i; }
[ ... ]
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +0
-0
[ ... ]
Quoted 6 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +1
-0@@ -48,16 +48,15 @@ void analogix_dp_stop_video(struct analogix_dp_device *dp)void analogix_dp_lane_mapping (struct analogix_dp_device *dp) { +u32 *lane_map = dp->video_info.lane_map;u32 reg;
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c void analogix_dp_stop_video(struct analogix_dp_device *dp) · line 56
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +4
-6-if (enable) - reg =LANE3_MAP_LOGIC_LANE_0 |LANE2_MAP_LOGIC_LANE_1 | -LANE1_MAP_LOGIC_LANE_2 |LANE0_MAP_LOGIC_LANE_3 ; -else - reg =LANE3_MAP_LOGIC_LANE_3 |LANE2_MAP_LOGIC_LANE_2 | -LANE1_MAP_LOGIC_LANE_1 |LANE0_MAP_LOGIC_LANE_0 ; + reg = lane_map[0 ] <<LANE0_MAP_SHIFT ; + reg |= lane_map[1 ] <<LANE1_MAP_SHIFT ; + reg |= lane_map[2 ] <<LANE2_MAP_SHIFT ; + reg |= lane_map[3 ] <<LANE3_MAP_SHIFT ;
[Severity: High]
Does this logic configure the lane mapping backwards?
The lane map parsed from the device tree establishes lane_map[logical] = physical. However, this register assignment shifts the physical lane index (lane_map[i]) by the shift for the physical lane's register field (LANEi_MAP_SHIFT).
Because the hardware register expects the logical lane number to be written to the physical lane's bitfield, won't this write the physical lane number into the physical lane's field instead? This effectively applies the inverse permutation and could break output for any asymmetric lane mappings.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Gentle ping.
Quoted 64 lines · Damon Ding
This series adds configurable eDP physical lane mapping support via device tree data-lanes property.
Lane mapping is mainly used for below scenarios:
1. Correct PCB lane swap and differential line routing crossoverwithout hardware changes;2. Adapt mismatched lane pin definitions between SoC and eDP panel;
3. Support multiple panel hardware variants on the same board by configuring data-lanes in device tree only.The series includes driver implementation and device tree binding updates to support custom lane mapping configuration from endpoint node, and keeps default linear lane order if no configuration is given.
Patch 1: Add endpoint data-lanes property to analogix-dp binding Patch 2: Add DRM DP helper API to validate DP lane counts Patch 3: Restore mandatory for samsung,link-rate and samsung,lane-count
properties
Patch 4: Add validation for samsung,lane-count property as preparation Patch 5: Implement lane mapping inanalogix_dpdriverDamon Ding (5):
dt-bindings: display: bridge: analogix-dp: Add data-lanes support for
endpoint
drm/dp: Add helper to validate DP lane counts
drm/bridge:analogix_dp: Restore mandatory samsung DP DT properties drm/bridge:analogix_dp: Add validation for samsung,lane-count
property
drm/bridge:analogix_dp: Add support for optional data-lanes mapping.../bindings/display/bridge/analogix,dp.yaml | 19 +++-- .../rockchip/rockchip,analogix-dp.yaml | 1 + .../drm/bridge/analogix/analogix_dp_core.c | 70 +++++++++++++++++-- .../drm/bridge/analogix/analogix_dp_core.h | 4 +- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 15 ++-- .../gpu/drm/bridge/analogix/analogix_dp_reg.h | 4 ++ include/drm/display/drm_dp_helper.h | 6 ++ 7 files changed, 101 insertions(+), 18 deletions(-)---
Changes in v2:
- Add lane mapping application scenarios in commit message.
- Remove redundant deprecated property 'data-lanes' for eDP node.
- Update port@1 $ref to /schemas/graph.yaml#/$defs/port-base.Changes in v3:
- Squash [PATCH v2 2/3] into [PATCH v2 1/3].
- Add unevaluatedProperties: false to both the port@1 and endpoint nodes.Changes in v4:
- Add validation for samsung,lane-count property as preparation.Changes in v5:
- Add DRM DP helper API to validate DP lane counts.
- Apply DRM DP helper API to check the validity of samsung,lane-count property.
- Add Acked-by and Reviewed-by tags.Changes in v6:
- Add a seperate commit to restore mandatory samsung DP DT properties.
- Add Reviewed-by tag.