drm/bridge: trilinear: add the Sky1 DisplayPort transmitter
Subsystems (4)
PATCH v9 3/5 drm/bridge: trilinear: add the DPTX DRM bridge
In reply to Luo LiuAdd the DRM bridge that exposes the transmitter to KMS: connector detection, EDID mode enumeration with a downstream timing fallback, validation of a mode against the sink link capabilities, and the atomic enable and disable paths.
The bridge is meant to be attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR; the connector is created by drm_bridge_connector_init() from the bridge operations, so the driver only implements the bridge side and never creates a connector of its own.
A mode whose horizontal backporch has to be widened is rejected when the adjusted timings no longer fit the mode fields, so malformed timings supplied from userspace cannot wrap around and reach the hardware.
The bridge adds a device link to the controller on attach, so the transmitter resumes before the controller's resume commit and is suspended after the controller has stopped issuing commits. The link is created only if the transmitter has not been released, and is dropped on detach.
--- MAINTAINERS | 1 + drivers/gpu/drm/bridge/trilinear/dptx.h | 113 +++ drivers/gpu/drm/bridge/trilinear/dptx_drm.c | 746 ++++++++++++++++++++ drivers/gpu/drm/bridge/trilinear/dptx_drm.h | 17 + include/drm/bridge/trilinear_dp.h | 74 ++ 5 files changed, 951 insertions(+) create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx.h create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_drm.c create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_drm.h create mode 100644 include/drm/bridge/trilinear_dp.h
MAINTAINERS +1 -0
@@ -6530,6 +6530,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/display/cix,sky1-dp.yaml F: drivers/gpu/drm/bridge/trilinear/ +F: include/drm/bridge/trilinear_dp.h CLANG CONTEXT ANALYSIS M: Marco Elver <[email protected]>
drivers/gpu/drm/bridge/trilinear/dptx.h new file +113 -0
113 lines not on this page · raw message
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +746 -0
746 lines not on this page · raw message
drivers/gpu/drm/bridge/trilinear/dptx_drm.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* DisplayPort DRM helpers +* +* Copyright 2026 Cix Technology Group Co., Ltd. +*/ + +#ifndef DPTX_DRM_H +#define DPTX_DRM_H + +#include <linux/device.h> + +#include "dptx.h" + +struct dptx_dev *dptx_bridge_alloc (struct device *dev); + +#endif /* DPTX_DRM_H */
include/drm/bridge/trilinear_dp.h new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v9 5/5 drm/cix: add the Sky1 DisplayPort platform glue
In reply to Luo LiuAdd the platform driver that maps the Sky1 RCSU video adapter registers and programs the pixel format and pixel-per-clock mode for the Trilinear DisplayPort transmitter.
The DP protocol, link training and the DRM bridge live in the shared Trilinear bridge driver. This glue only fills in the SoC-specific parts through dptx_plat_data, declared in include/drm/bridge/trilinear_dp.h.
The remove callback tears the transmitter down before the device is deleted.
--- MAINTAINERS | 1 + drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/cix/Kconfig | 3 + drivers/gpu/drm/cix/Makefile | 3 + drivers/gpu/drm/cix/dptx/Kconfig | 15 +++ drivers/gpu/drm/cix/dptx/Makefile | 4 + drivers/gpu/drm/cix/dptx/cix_dptx.c | 179 ++++++++++++++++++++++++++++ 8 files changed, 207 insertions(+) create mode 100644 drivers/gpu/drm/cix/Kconfig create mode 100644 drivers/gpu/drm/cix/Makefile create mode 100644 drivers/gpu/drm/cix/dptx/Kconfig create mode 100644 drivers/gpu/drm/cix/dptx/Makefile create mode 100644 drivers/gpu/drm/cix/dptx/cix_dptx.c
MAINTAINERS +1 -0
@@ -6530,6 +6530,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/display/cix,sky1-dp.yaml F: drivers/gpu/drm/bridge/trilinear/ +F: drivers/gpu/drm/cix/dptx/ F: include/drm/bridge/trilinear_dp.h CLANG CONTEXT ANALYSIS
drivers/gpu/drm/Kconfig +1 -0
@@ -311,6 +311,7 @@ source "drivers/gpu/drm/aspeed/Kconfig" source "drivers/gpu/drm/ast/Kconfig" source "drivers/gpu/drm/atmel-hlcdc/Kconfig" source "drivers/gpu/drm/bridge/Kconfig" +source "drivers/gpu/drm/cix/Kconfig" source "drivers/gpu/drm/etnaviv/Kconfig" source "drivers/gpu/drm/exynos/Kconfig" source "drivers/gpu/drm/fsl-dcu/Kconfig"
drivers/gpu/drm/Makefile +1 -0
@@ -169,6 +169,7 @@ obj-y += tests/ obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o obj-y += arm/ +obj-y += cix/ obj-y += clients/ obj-y += display/ obj-$(CONFIG_DRM_TTM) += ttm/
drivers/gpu/drm/cix/Kconfig new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +source "drivers/gpu/drm/cix/dptx/Kconfig"
drivers/gpu/drm/cix/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_DRM_CIX_DP) += dptx/
drivers/gpu/drm/cix/dptx/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config DRM_CIX_DP + tristate "Cix Sky1 DisplayPort platform glue" + depends on ARCH_CIX || COMPILE_TEST + depends on COMMON_CLK && DRM && OF + depends on GENERIC_PHY + select DRM_TRILINEAR_DPTX + help + Platform glue for the Cix Sky1 DisplayPort output. It maps the + SoC video adapter registers and binds the shared Trilinear DPTX + bridge driver. + + To compile this driver as a module, choose M here: the module will + be called cix-dptx.
drivers/gpu/drm/cix/dptx/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +cix-dptx-y := cix_dptx.o +obj-$(CONFIG_DRM_CIX_DP) += cix-dptx.o
drivers/gpu/drm/cix/dptx/cix_dptx.c new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
2.25.1
v9 cover drm/bridge: trilinear: add the Sky1 DisplayPort transmitter
Add the Trilinear DisplayPort transmitter as a DRM bridge, with the CIX Sky1 platform glue behind a platform data structure.
The hardware layer, the DRM bridge and the core state machine live in drivers/gpu/drm/bridge/trilinear/, so other SoCs using the same transmitter can share them; the platform registers its own dptx_plat_data through include/drm/bridge/trilinear_dp.h. The transmitter drives up to four lanes at HBR3 and has two SST sources. MST is not implemented and stays disabled.
The USB-C transmitters and the native DP/eDP transmitter use different RCSU video-adapter register offsets and bit layouts, so the binding has one compatible for each. The Sky1 devicetree nodes are not included in this posting.
Scope: DPTX hardware, bridge and bindings only. Komeda (the Sky1 display controller that feeds these bridges) and the board DTS are separate series. Nothing in this posting wires a full display stack.
Tested on a Radxa Orion O6 board; the USB-C DisplayPort output works with the connector created by drm_bridge_connector_init().
Connector handling in this driver:
The bridge is meant to be attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR and drm_bridge_connector_init() creates the connector from the bridge operations. The driver implements the bridge side only and never registers a connector of its own.
Changes in v9:
- Link training applies the sink's voltage swing and pre-emphasis request before checking for a repeated setting, so the retry limit counts from the first attempt and the last adjustment is not discarded.
- dptx_deinit() sets dp->released together with the AUX unregister under the same lock, so dptx_bridge_detach() cannot return while the AUX channel is still registered.
Luo Liu (5):
dt-bindings: display: add CIX Sky1 DisplayPort transmitter drm/bridge: trilinear: add the DPTX hardware layer drm/bridge: trilinear: add the DPTX DRM bridge drm/bridge: trilinear: add the DPTX core and build glue drm/cix: add the Sky1 DisplayPort platform glue
.../bindings/display/cix,sky1-dp.yaml | 133 ++ MAINTAINERS | 11 + drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/bridge/Kconfig | 2 + drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/trilinear/Kconfig | 9 + drivers/gpu/drm/bridge/trilinear/Makefile | 4 + drivers/gpu/drm/bridge/trilinear/dptx.h | 113 ++ drivers/gpu/drm/bridge/trilinear/dptx_core.c | 1061 +++++++++++++ drivers/gpu/drm/bridge/trilinear/dptx_drm.c | 746 +++++++++ drivers/gpu/drm/bridge/trilinear/dptx_drm.h | 17 + drivers/gpu/drm/bridge/trilinear/dptx_hw.c | 1386 +++++++++++++++++ drivers/gpu/drm/bridge/trilinear/dptx_hw.h | 103 ++ drivers/gpu/drm/cix/Kconfig | 3 + drivers/gpu/drm/cix/Makefile | 3 + drivers/gpu/drm/cix/dptx/Kconfig | 15 + drivers/gpu/drm/cix/dptx/Makefile | 4 + drivers/gpu/drm/cix/dptx/cix_dptx.c | 179 +++ include/drm/bridge/trilinear_dp.h | 84 + 20 files changed, 3876 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/cix,sky1-dp.yaml create mode 100644 drivers/gpu/drm/bridge/trilinear/Kconfig create mode 100644 drivers/gpu/drm/bridge/trilinear/Makefile create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx.h create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_core.c create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_drm.c create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_drm.h create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_hw.c create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_hw.h create mode 100644 drivers/gpu/drm/cix/Kconfig create mode 100644 drivers/gpu/drm/cix/Makefile create mode 100644 drivers/gpu/drm/cix/dptx/Kconfig create mode 100644 drivers/gpu/drm/cix/dptx/Makefile create mode 100644 drivers/gpu/drm/cix/dptx/cix_dptx.c create mode 100644 include/drm/bridge/trilinear_dp.h
Signature · 1 line
2.25.1
PATCH v9 2/5 drm/bridge: trilinear: add the DPTX hardware layer
Add the register and PHY programming for the Trilinear DisplayPort
transmitter: controller reset, host and core enable, AUX transfers through the controller's AUX channel, sink capability parsing from the DPCD, and link training with rate downshifting when the sink cannot lock.
The transmitter drives up to four lanes at HBR3 and has two SST sources. The stream setup programs the main stream attributes, the pixel format and the optional VSC SDP per stream. MST is not implemented and is left disabled.
DP_SET_POWER is only accessed on sinks whose DPCD revision implements the register, so a v1.0 sink is not sent a request it cannot answer.
--- MAINTAINERS | 1 + drivers/gpu/drm/bridge/trilinear/dptx_hw.c | 1386 ++++++++++++++++++++ drivers/gpu/drm/bridge/trilinear/dptx_hw.h | 103 ++ 3 files changed, 1490 insertions(+) create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_hw.c create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_hw.h
MAINTAINERS +1 -0
@@ -6529,6 +6529,7 @@ R: CIX Linux Kernel Upstream Group <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/display/cix,sky1-dp.yaml +F: drivers/gpu/drm/bridge/trilinear/ CLANG CONTEXT ANALYSIS M: Marco Elver <[email protected]>
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +1386 -0
1,386 lines not on this page · raw message
drivers/gpu/drm/bridge/trilinear/dptx_hw.h new file +103 -0
103 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v9 4/5 drm/bridge: trilinear: add the DPTX core and build glue
In reply to Luo LiuAdd the probe path, system sleep handling, hotplug workers and the stream state machine that tie the hardware layer to the DRM bridge, and hook the driver into the DRM bridge Kconfig and Makefile.
Detection is driven by the controller's HPD interrupt. The USB-C transmitters do not route HPD to the controller, so a sink that was plugged in before the bridge was attached raises no event; replay that plug once the common PHY is in DP mode and the AUX channel answers. The native DP port wires HPD and is reported by the interrupt.
An atomic enable that arrives while the transmitter is suspended is refused instead of powering the host back up behind the sleep callbacks; the host is left for the resume path to bring up again.
The transmitter is torn down from the platform remove callback as well as from devres, so the device link is dropped while the device is still registered; device links are purged during device removal and must not be released afterwards.
--- drivers/gpu/drm/bridge/Kconfig | 2 + drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/trilinear/Kconfig | 9 + drivers/gpu/drm/bridge/trilinear/Makefile | 4 + drivers/gpu/drm/bridge/trilinear/dptx_core.c | 1061 ++++++++++++++++++ include/drm/bridge/trilinear_dp.h | 10 + 6 files changed, 1087 insertions(+) create mode 100644 drivers/gpu/drm/bridge/trilinear/Kconfig create mode 100644 drivers/gpu/drm/bridge/trilinear/Makefile create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_core.c
drivers/gpu/drm/bridge/Kconfig +2 -0
@@ -510,4 +510,6 @@ source "drivers/gpu/drm/bridge/imx/Kconfig" source "drivers/gpu/drm/bridge/synopsys/Kconfig" +source "drivers/gpu/drm/bridge/trilinear/Kconfig" + endmenu
drivers/gpu/drm/bridge/Makefile +1 -0
@@ -53,3 +53,4 @@ obj-y += analogix/ obj-y += cadence/ obj-y += imx/ obj-y += synopsys/ +obj-y += trilinear/
drivers/gpu/drm/bridge/trilinear/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config DRM_TRILINEAR_DPTX + tristate + depends on COMMON_CLK && DRM && OF + depends on GENERIC_PHY + select DRM_KMS_HELPER + select DRM_DISPLAY_HELPER + select DRM_DISPLAY_DP_HELPER
drivers/gpu/drm/bridge/trilinear/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +trilinear-dptx-y := dptx_core.o dptx_drm.o dptx_hw.o +obj-$(CONFIG_DRM_TRILINEAR_DPTX) += trilinear-dptx.o
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +1061 -0
1,061 lines not on this page · raw message
include/drm/bridge/trilinear_dp.h +10 -0
@@ -65,6 +65,16 @@ int trilinear_dptx_suspend(struct dptx_dev *dp);*/ int trilinear_dptx_resume (struct dptx_dev *dp); +/** +* trilinear_dptx_remove - tear down a DPTX bridge on driver removal +* @dp: DPTX device returned by trilinear_dptx_probe() +* +* Called from the platform remove callback, before the device is deleted. +* The device link to the display controller is dropped here, since device +* links are purged on removal and cannot be released afterwards. +*/ +void trilinear_dptx_remove (struct dptx_dev *dp); +/** * trilinear_dptx_shutdown - stop a DPTX bridge on system shutdown * @dp: DPTX device returned by trilinear_dptx_probe()
Signature · 1 line
2.25.1
PATCH v9 1/5 dt-bindings: display: add CIX Sky1 DisplayPort transmitter
In reply to Luo LiuAdd a binding for the Trilinear DisplayPort transmitter integrated on CIX Sky1. The USB-C and the native DP/eDP transmitters use different RCSU video-adapter register offsets and bit layouts, so each has its own compatible.
The binding describes the full video link: port@0 is the input from the display pipeline, and port@1 is the output towards the display connector, a bridge in front of it, or the USB-C combo PHY that carries the DP lanes to the receptacle. The driver drives the link through phys and gets its connector from drm_bridge_connector_init(), so it does not parse the output port; the port documents the board wiring.
--- .../bindings/display/cix,sky1-dp.yaml | 133 ++++++++++++++++++ MAINTAINERS | 8 ++ 2 files changed, 141 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/cix,sky1-dp.yaml
Documentation/devicetree/bindings/display/cix,sky1-dp.yaml new file +133 -0
@@ -0,0 +1,133 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/cix,sky1-dp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CIX Sky1 Trilinear DisplayPort Transmitter + +maintainers: + - Luo Liu <[email protected]> + +description: | + Trilinear DisplayPort transmitter on CIX Sky1. The transmitter takes its + video stream from the display pipeline through its input port and drives + the link through a generic PHY. Its output port describes where the DP + lanes go on the board: a display connector, a bridge, or the USB-C combo + PHY that carries them to the receptacle. + + The USB-C transmitters and the native DP/eDP transmitter use different + RCSU video-adapter register offsets and bit layouts, so each has its own + compatible: "cix,sky1-usbdp" for the USB-C transmitters and "cix,sky1-dp" + for the native DP/eDP one. + +properties: + compatible: + enum: + - cix,sky1-usbdp + - cix,sky1-dp + + reg: + items: + - description: DisplayPort transmitter registers. + - description: RCSU video adapter registers used for link setup. + + reg-names: + items: + - const: dp + - const: rcsu + + clocks: + items: + - description: APB clock of the controller. + - description: Video clock of stream 0. + - description: Video clock of stream 1. + + clock-names: + items: + - const: apb + - const: vid0 + - const: vid1 + + interrupts: + maxItems: 1 + + resets: + maxItems: 1 + description: DisplayPort controller reset. + + phys: + maxItems: 1 + description: DisplayPort PHY the controller transmits through. + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Video input from the Mali D71 display pipeline (Komeda) that feeds + this controller. + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: + Output of the controller. It connects to the display connector, to + a bridge in front of one, or to the USB-C combo PHY that carries + the DP lanes to the receptacle. + + required: + - port@0 + - port@1 + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - interrupts + - resets + - phys + - ports + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + dp@14064000 { + compatible = "cix,sky1-usbdp"; + reg = <0x14064000 0x4000>, + <0x14050000 0x400>; + reg-names = "dp", "rcsu"; + clocks = <&dpc0_apb>, <&dpc0_vid0>, <&dpc0_vid1>; + clock-names = "apb", "vid0", "vid1"; + interrupts = <GIC_SPI 332 IRQ_TYPE_LEVEL_HIGH>; + resets = <&dpc0_rst>; + phys = <&usbc0_dp_phy>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + endpoint { + remote-endpoint = <&dpu0_pipe0_out>; + }; + }; + + port@1 { + reg = <1>; + + endpoint { + remote-endpoint = <&dp0_connector_in>; + }; + }; + }; + };
MAINTAINERS +8 -0
@@ -6522,6 +6522,14 @@ M: Satish Kharat <[email protected]> S: Supported F: drivers/infiniband/hw/usnic/ +CIX SKY1 DISPLAYPORT TRANSMITTER DRIVER +M: Luo Liu <[email protected]> +M: Wuyi Shen <[email protected]> +R: CIX Linux Kernel Upstream Group <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/display/cix,sky1-dp.yaml + CLANG CONTEXT ANALYSIS M: Marco Elver <[email protected]> R: Bart Van Assche <[email protected]>
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH v9 5/5] drm/cix: add the Sky1 DisplayPort platform glue
In reply to Luo LiuThank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] drm/bridge: trilinear: dptx_deinit() races with dptx_bridge_attach() - [Medium] drm/bridge…
Thank you for your contribution! Sashiko AI review found 5 potential issues to consider:
- [Medium] drm/bridge: trilinear: dptx_deinit() races with dptx_bridge_attach()
- [Medium] drm/bridge: trilinear: unlocked device_link_del() races with purge
- [Low] drm/cix: MAINTAINERS omits drivers/gpu/drm/cix/ Kconfig and Makefile
- [Low] drm/bridge: trilinear: 32-bit overflow in dptx_hw_stream_timing_set()
- [Low] drm/cix: rely on undocumented dev_set_drvdata() in trilinear_dptx_probe()
--
commit dc89c829eff9a7f0dba586da4c0b1ecdf3d742f9
Author: Luo Liu <[email protected]>
drm/cix: add the Sky1 DisplayPort platform glue
This commit adds the Cix Sky1 DisplayPort platform glue driver, which maps the SoC RCSU video adapter registers, configures pixel format and pixel-per-clock settings, and binds the shared Trilinear DPTX bridge driver.
MAINTAINERS L: [email protected] · line 6539
Quoted 10 lines
MAINTAINERS +1
-0@@ -6535,6 +6535,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/display/cix,sky1-dp.yaml F: drivers/gpu/drm/bridge/trilinear/ +F: drivers/gpu/drm/cix/dptx/ F: include/drm/bridge/trilinear_dp.h
[Severity: Low]
Should this entry also cover drivers/gpu/drm/cix/Kconfig and drivers/gpu/drm/cix/Makefile (for example via F: drivers/gpu/drm/cix/)? Those two newly added files are not matched by any MAINTAINERS entry.
[ ... ]
Quoted 5 lines
drivers/gpu/drm/cix/dptx/cix_dptx.c new file +0
-0
[ ... ]
drivers/gpu/drm/cix/dptx/cix_dptx.c line 120
Quoted 6 lines
drivers/gpu/drm/cix/dptx/cix_dptx.c new file +6
-0+ dp =trilinear_dptx_probe (dev, soc_data, priv); +if (IS_ERR (dp)) +return PTR_ERR (dp); + +return 0 ; +}
[Severity: Low]
Should cix_dptx_probe() call platform_set_drvdata(pdev, dp) instead of discarding dp?
cix_dptx_remove(), cix_dptx_pm_suspend(), cix_dptx_pm_resume(), and cix_dptx_shutdown() all retrieve the struct dptx_dev pointer from drvdata. This currently works only because trilinear_dptx_probe() calls dev_set_drvdata(dev, dp) internally, even though the trilinear driver never reads drvdata and include/drm/bridge/trilinear_dp.h does not document that side effect.
Setting drvdata here and dropping dev_set_drvdata() from trilinear_dptx_probe() would match other shared DRM bridge libraries and avoid clobbering drvdata for future glue drivers.
drivers/gpu/drm/cix/dptx/cix_dptx.c line 125
Quoted 5 lines
drivers/gpu/drm/cix/dptx/cix_dptx.c new file +5
-0+ +static void cix_dptx_remove (struct platform_device *pdev) +{ +trilinear_dptx_remove (platform_get_drvdata (pdev)); +}
[Severity: Medium]
Can dptx_deinit() race with dptx_bridge_attach() and leave dp->hpd_event_work polling dp->phy after devres releases it?
In drivers/gpu/drm/bridge/trilinear/dptx_core.c, dptx_deinit() sets dp->hpd_stopped = true and drops dp->lock to call dptx_cancel_hpd_works(), setting dp->released = true only in a second dp->lock critical section:
CPU0 CPU1cix_dptx_remove()
dptx_deinit()
lock(&dp->lock)
dp->hpd_stopped = true
unlock(&dp->lock)
dptx_cancel_hpd_works()
dptx_bridge_attach()
lock(&dp->lock)
/* dp->released is still false */
dp->hpd_stopped = false
unlock(&dp->lock)
dptx_replay_deferred_hotplug()
queue_delayed_work(hpd_event_work)
dptx_hpd_event_work_func()
/* passes abort check, unlocks */
dptx_wait_phy_dp_mode()
lock(&dp->lock)
dp->released = true
unlock(&dp->lock)
devres_release_all()
devm_phy_release(dp->phy)
phy_get_mode(dp->phy) <-- use-after-freeBecause dp->hpd_stopped was cleared back to false and dptx_hpd_notify() only checks dp->hpd_stopped (not dp->released), out-of-band HPD notifications on cix,sky1-usbdp can also keep queueing HPD work after device removal. Setting dp->released = true alongside dp->hpd_stopped = true in the first dp->lock critical section of dptx_deinit() closes this window.
[Severity: Medium]
Can dropping dp->lock before device_link_del() in dptx_deinit() and dptx_bridge_detach() race with device_links_purge()?
Both dptx_deinit() and dptx_bridge_detach() clear dp->link under dp->lock, then drop dp->lock before calling device_link_del(link):
CPU0 CPU1dptx_bridge_detach()
lock(&dp->lock)
link = dp->link
dp->link = NULL
unlock(&dp->lock)
device_del(dp->dev)
bus_remove_device()
cix_dptx_remove() -> dptx_deinit()
/* sees dp->link == NULL */
device_links_purge(dp->dev)
__device_link_del(&link->kref) device_link_del(link)
<-- double delete / use-after-free
The symmetric race happens when dptx_deinit() steals dp->link and drops dp->lock while the consumer device is being deleted. Calling device_link_del(link) while still holding dp->lock (matching device_link_add() in dptx_bridge_attach()) serializes deletion before device_links_purge() can run.
[ ... ]
drivers/gpu/drm/cix/dptx/cix_dptx.c line 154
Quoted 10 lines
drivers/gpu/drm/cix/dptx/cix_dptx.c new file +10
-0+static const struct dptx_plat_data sky1_usbdp_data = { + .adapter_config = cix_dp_usbc_adapter_config, + .oob_hpd = true, + .max_bw_code =DP_LINK_BW_5_4 , +}; + +static const struct dptx_plat_data sky1_dp_data = { + .adapter_config = cix_dp_native_adapter_config, + .max_bw_code =DP_LINK_BW_5_4 , +};
[Severity: Low]
Can setting max_bw_code to DP_LINK_BW_5_4 trigger a 32-bit overflow in dptx_hw_stream_timing_set()?
drivers/gpu/drm/bridge/trilinear/dptx_hw.c:dptx_hw_stream_timing_set() {
...
dptx_hw_write(hw, DPTX_SECONDARY_DATA_WINDOW(stream_id),
(mode->htotal - mode->hdisplay) * (link_rate / 40) *
9 / mode->clock);
...
}Because link_rate is u32, this multiplication is evaluated in 32-bit unsigned arithmetic. At 540000 kHz, (link_rate / 40) * 9 is 121500, so any custom mode with horizontal blanking (mode->htotal - mode->hdisplay) of at least 35350 overflows U32_MAX before dividing by mode->clock.
Neither dptx_adjust_mode() nor dptx_bridge_atomic_check() bounds horizontal blanking, so this writes a miscalculated secondary data window to hardware. Computing the numerator in 64-bit arithmetic with div_u64() avoids the wraparound.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
AI reviewRe: [PATCH v9 2/5] drm/bridge: trilinear: add the DPTX hardware layer
In reply to Luo LiuThank you for your contribution! Sashiko AI review found 11 potential issues to consider: - [Medium] drm/bridge: trilinear: leave opts.dp.lanes unset in dptx_hw_link_rate() - [Medium] drm/bridge…
Thank you for your contribution! Sashiko AI review found 11 potential issues to consider:
- [Medium] drm/bridge: trilinear: leave opts.dp.lanes unset in dptx_hw_link_rate()
- [Medium] drm/bridge: trilinear: missing pre-emphasis and swing sum clamping
- [Medium] drm/bridge: trilinear: hardcode CTA limited range for RGB VSC SDP
- [Medium] drm/bridge: trilinear: omit DCI-P3 and xvYCC/BT.709 in VSC SDP check
- [Medium] drm/bridge: trilinear: leave unhandled interrupt bit 5 unmasked
- [Medium] drm/bridge: trilinear: ignore DPCD write error in dptx_hw_link_train_end()
- [Low] drm/bridge: trilinear: write DP_TRAINING_LANE0_SET before PHY update
- [Low] drm/bridge: trilinear: commit message claims unimplemented downshifting
- [Low] drm/bridge: trilinear: unnecessary single-implementation dptx_hw_ops vtable
- [Low] drm/bridge: trilinear: dptx_hw_stream_format_set() lacks YUV420 VSC check
- [Low] drm/bridge: trilinear: 32-bit overflow in dptx_hw_stream_timing_set()
--
commit e7608fe3dedcf10692a9cd8f3d2a2dbebc772270
Author: Luo Liu <[email protected]>
drm/bridge: trilinear: add the DPTX hardware layer
This commit adds the register and PHY programming layer for the Trilinear DisplayPort transmitter, including AUX transfers, DPCD capability parsing, link training, and per-stream timing and format setup.
Quoted 5 lines
Add the register and PHY programming for the Trilinear DisplayPort
transmitter: controller reset, host and core enable, AUX transfers through the controller's AUX channel, sink capability parsing from the DPCD, and link training with rate downshifting when the sink cannot lock.
[Severity: Low]
Is the commit message accurate about rate downshifting? In this patch, dptx_hw_link_train() only runs a single link training attempt at the caller-supplied bw_code and lane_cnt and does not implement rate downshifting.
Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +0
-0
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 242
Quoted 8 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +8
-0+#define DPTX_INTERRUPT_GP_TIMER_IRQ BIT(4) +#define DPTX_INTERRUPT_REPLY_TIMEOUT BIT(3) +#define DPTX_INTERRUPT_REPLY_RECEIVED BIT(2) +#define DPTX_INTERRUPT_HPD_IRQ BIT(1) +#define DPTX_INTERRUPT_HPD_EVENT BIT(0) + +#define DPTX_INTERRUPT_MASK_ALL 0x3f +#define DPTX_INTERRUPT_CFG 0x1c
[Severity: Medium]
Does DPTX_INTERRUPT_CFG leave interrupt bit 5 unmasked?
DPTX_INTERRUPT_MASK_ALL covers bits 0..5 (0x3f), where 1 masks an interrupt and 0 enables it. Writing DPTX_INTERRUPT_CFG (0x1c) to DPTX_INTERRUPT_MASK in dptx_hw_host_enable() unmasks bit 5 alongside HPD_EVENT and HPD_IRQ, even though dptx_hw_irq() only handles bits 0..4 and swallows any other unmasked cause bit as IRQ_HANDLED. Defining DPTX_INTERRUPT_CFG as DPTX_INTERRUPT_MASK_ALL & ~(DPTX_INTERRUPT_HPD_EVENT | DPTX_INTERRUPT_HPD_IRQ) (0x3c) keeps bit 5 masked.
[ ... ]
Quoted 4 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +4
-0+static int dptx_hw_link_rate (struct dp_hw *hw,struct phy *phy, +u8 bw_code,u8 lanes,bool downspread) +{ +union phy_configure_opts opts = {0 };
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 396
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +10
-0+u32 ready = (1 << lanes) -1 ; +u32 value; +int ret; + +dptx_hw_write (hw,DPTX_LINK_BW_SET , bw_code); + + opts.dp.link_rate =drm_dp_bw_code_to_link_rate (bw_code) /100 ; + opts.dp.ssc = downspread; + opts.dp.set_rate =1 ; + ret =phy_configure (phy, &opts);
[Severity: Medium]
Should dptx_hw_link_rate() set opts.dp.lanes and opts.dp.set_lanes before calling phy_configure()?
Because opts is zero-initialized, opts.dp.lanes is passed as 0 instead of 1, 2, or 4, which causes generic DP PHY drivers such as phy-cadence-torrent to reject phy_configure() with -EINVAL. In addition, opts.dp.set_lanes is never set anywhere in the driver and dptx_hw_link_configure() passes num_lanes rather than the active lane_cnt, so PHY drivers that implement set_lanes never reconfigure their active lanes.
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 463
Quoted 12 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +12
-0+static int dptx_hw_link_vs_emph (struct dp_hw *hw,struct phy *phy, +u8 lane_cnt) +{ +int ret; + + ret =drm_dp_dpcd_write (&hw->aux,DP_TRAINING_LANE0_SET , hw->train_setting, + lane_cnt); +if (ret <0 ) +return ret; + +return dptx_hw_phy_vs_emph_set (hw, phy, lane_cnt, hw->train_setting); +}
[Severity: Low]
Should dptx_hw_phy_vs_emph_set() run before writing DP_TRAINING_LANE0_SET to the sink?
Updating the sink DPCD first exposes it to stale drive levels if it starts evaluating immediately, and leaves the sink notified even if phy_configure() fails.
Quoted 11 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +11
-0+static void dptx_hw_link_adjust_train (struct dp_hw *hw,u8 lane_cnt, +const u8 *link_status) +{ +u8 voltage; +u8 preemphasis; +int i; + +for (i =0 ; i < lane_cnt; i++) { + voltage =drm_dp_get_adjust_request_voltage (link_status, i); + preemphasis = +drm_dp_get_adjust_request_pre_emphasis (link_status, i);
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 485
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +10
-0+ +if (voltage >=DP_TRAIN_VOLTAGE_SWING_LEVEL_3 ) + voltage |=DP_TRAIN_MAX_SWING_REACHED ; + +if (preemphasis >=DP_TRAIN_PRE_EMPH_LEVEL_2 ) + preemphasis |=DP_TRAIN_MAX_PRE_EMPHASIS_REACHED ; + + hw->train_setting[i] = voltage | preemphasis; + } +}
[Severity: Medium]
Can dptx_hw_link_adjust_train() pass out-of-spec swing and pre-emphasis levels to phy_configure()?
When a sink requests pre-emphasis level 3, this sets DP_TRAIN_MAX_PRE_EMPHASIS_REACHED at level 2 without clamping preemphasis to level 2, passing opts.dp.pre[i] = 3 in dptx_hw_phy_vs_emph_set(). It also does not enforce voltage + pre-emphasis <= 3, so combinations like swing level 2 with pre-emphasis level 2 are rejected with -EINVAL by generic DP PHY drivers such as phy-cadence-torrent and abort link training.
[ ... ]
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +10
-0+static void dptx_hw_link_train_end (struct dp_hw *hw) +{ +drm_dp_dpcd_writeb (&hw->aux,DP_TRAINING_PATTERN_SET ,0 ); +dptx_hw_write (hw,DPTX_TRAINING_PATTERN_SET ,0 ); +dptx_hw_write (hw,DPTX_DISABLE_SCRAMBLING ,0 ); +} + +static int dptx_hw_link_train (struct dp_hw *hw,struct phy *phy,u8 bw_code, +u8 lane_cnt,u8 num_lanes) +{
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 616
Quoted 4 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +4
-0+dptx_hw_link_train_end (hw); + +return ret; +}
[Severity: Medium]
Should dptx_hw_link_train_end() propagate a DPCD write error when link training otherwise succeeded?
If clearing DP_TRAINING_PATTERN_SET on the sink fails after clock recovery and channel equalization pass, dptx_hw_link_train() still returns 0 while the sink remains in training pattern mode, preventing callers from retrying or downshifting. Propagating the error when ret == 0 (while keeping any earlier training error) avoids reporting a false success.
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 1050
Quoted 3 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +3
-0+dptx_hw_write (hw,DPTX_SECONDARY_DATA_WINDOW (stream_id), + (mode->htotal - mode->hdisplay) * (link_rate /40 ) * +9 / mode->clock);
[Severity: Low]
Can this DPTX_SECONDARY_DATA_WINDOW calculation overflow 32-bit unsigned arithmetic?
Because link_rate is u32, the numerator wraps when horizontal blanking is at least 35350 pixels at HBR2 or 23567 pixels at HBR3 for a custom userspace mode, writing a truncated value to the register. Using 64-bit arithmetic with div_u64() avoids the wrap.
[ ... ]
Quoted 9 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +9
-0+static bool dptx_hw_needs_vsc_sdp (enum dp_pixelformat format, +u32 colorspace) +{ +if (format ==DP_PIXELFORMAT_YUV420 ) +return true; + +switch (colorspace) { +case DRM_MODE_COLORIMETRY_SYCC_601 : +case DRM_MODE_COLORIMETRY_OPYCC_601 :
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 1143
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +10
-0+case DRM_MODE_COLORIMETRY_BT2020_YCC : +case DRM_MODE_COLORIMETRY_BT2020_RGB : +case DRM_MODE_COLORIMETRY_BT2020_CYCC : +return true; +default : +break ; + } + +return false; +}
[Severity: Medium]
Should dptx_hw_needs_vsc_sdp() also return true for DCI-P3 RGB (D65 and Theater), xvYCC 601/709, and BT.709 YCbCr?
dptx_hw_vsc_colorimetry() maps all five colorspaces, but when dptx_hw_needs_vsc_sdp() returns false, dptx_hw_stream_misc() ignores colorspace and programs MISC0 as sRGB or BT.601. This leaves the DCI-P3 RGB cases unreachable for RGB streams and silently drops these colorspaces unless paired with YUV420.
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 1189
Quoted 11 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +11
-0+static int dptx_hw_stream_format_set (struct dp_hw *hw,unsigned int stream_id, +enum dp_pixelformat format,u32 colorspace, +u8 bpc,u8 content_type) +{ +struct drm_dp_vsc_sdp vsc = {}; +struct dp_sdp sdp; +bool enable; +ssize_t len; + + enable = hw->caps.vsc_supported && +dptx_hw_needs_vsc_sdp (format, colorspace);
[Severity: Low]
Should dptx_hw_stream_format_set() return an error when format is DP_PIXELFORMAT_YUV420 and hw->caps.vsc_supported is false?
If hw->caps.vsc_supported becomes false (for example, if a DPCD re-read hits an AUX error on DP_DPRX_FEATURE_ENUMERATION_LIST, which drm_dp_vsc_sdp_supported() converts to false), enable is false and dptx_hw_stream_misc() falls into its default case, programming RGB in MISC0 with DPTX_MAIN_STREAM_OVERRIDE left at 0 and returning 0 instead of failing cleanly.
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 1212
Quoted 2 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +2
-0+ vsc.dynamic_range =DP_DYNAMIC_RANGE_CTA ; + vsc.content_type = content_type;
[Severity: Medium]
Should vsc.dynamic_range be DP_DYNAMIC_RANGE_VESA when format is DP_PIXELFORMAT_RGB?
Hardcoding DP_DYNAMIC_RANGE_CTA signals limited dynamic range (16-235) for wide-gamut RGB modes such as BT.2020 RGB, mismatching the full-range RGB signaled in MISC0 when VSC SDP is disabled and crushing blacks and whites on the sink.
Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.h new file +0
-0
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.h line 60
Quoted 3 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.h new file +3
-0+struct dptx_hw_ops { +bool (*hpd_state)(struct dp_hw *hw); +bool (*sink_present)(struct dp_hw *hw);
[Severity: Low]
This isn't a bug, but is the 20-entry struct dptx_hw_ops vtable needed when dptx_hw_ops in dptx_hw.c is its only implementation? Declaring direct dptx_hw_*() functions in dptx_hw.h would avoid the indirect call boilerplate.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH v9 4/5] drm/bridge: trilinear: add the DPTX core and build glue
In reply to Luo LiuThank you for your contribution! Sashiko AI review found 9 potential issues to consider: - [Medium] drm/bridge: trilinear: dptx_deinit() attach race leaves HPD work uncancelled - [Medium]…
Thank you for your contribution! Sashiko AI review found 9 potential issues to consider:
- [Medium] drm/bridge: trilinear: dptx_deinit() attach race leaves HPD work uncancelled
- [Medium] drm/bridge: trilinear: UAF in device_link_del() after consumer device removal
- [Medium] drm/bridge: trilinear: device_link_del() outside dp->lock races with purge
- [Medium] drm/bridge: trilinear: 10s poll in dptx_wait_phy_dp_mode() stalls suspend
- [Medium] drm/bridge: trilinear: HPD work queued before drm_bridge_hpd_enable()
- [Medium] drm/bridge: trilinear: dptx_train_loop() lacks timeout/HPD abort under lock
- [Medium] drm/bridge: trilinear: undivided stream clock rate in dptx_ctrl_stream_on()
- [Low] drm/bridge: trilinear: 32-bit overflow in dptx_hw_stream_timing_set()
- [Low] drm/bridge: undocumented dev_set_drvdata() in trilinear_dptx_probe()
--
commit ce7e7d7a9064fd3b813169fe3cb4592f1803c9c6
Author: Luo Liu <[email protected]>
drm/bridge: trilinear: add the DPTX core and build glue
This commit adds the Trilinear DisplayPort transmitter core driver (probe, hotplug workers, stream state machine, and PM/teardown helpers) along with its Kconfig and Makefile entries.
Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +0
-0
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_core.c line 144
Quoted 3 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +3
-0+ dp->hw->ops->stream_timing (dp->hw, stream_id, mode, + dp->config.bpp, dp->mode.lane_cnt, + dp->mode.link_rate, dp->pixel_per_cycle);
[Severity: Low]
Can the secondary data window calculation in dptx_hw_stream_timing_set() overflow 32-bit arithmetic?
drivers/gpu/drm/bridge/trilinear/dptx_hw.c:dptx_hw_stream_timing_set() {
...
dptx_hw_write(hw, DPTX_SECONDARY_DATA_WINDOW(stream_id),
(mode->htotal - mode->hdisplay) * (link_rate / 40) *
9 / mode->clock);
...
}Because mode->htotal and mode->hdisplay are u16 and link_rate is u32, the numerator is computed in 32-bit unsigned arithmetic. At HBR2 (540000 kHz), any mode with horizontal blanking of at least 35350 pixels wraps modulo 2^32 before dividing by mode->clock, misprogramming the secondary data packet window.
Promoting the numerator to u64 with mul_u32_u32() and div_u64() avoids the overflow.
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_core.c line 166
Quoted 2 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +2
-0+ pixel_clock = (unsigned long )mode->clock *1000 ; + ret = dp->hw->ops->stream_clock_rate_set (dp->hw, stream_id, pixel_clock);
[Severity: Medium]
Should pixel_clock be divided by dp->pixel_per_cycle before calling stream_clock_rate_set()?
For non-YUV420 modes above DPTX_MAX_FREQ (600 MHz), dptx_pick_ppc() selects 2 pixels per cycle and dptx_hw_stream_timing_set() programs DPTX_USER_PIXEL_COUNT to 2, but stream_clock_rate_set() still passes the undivided pixel clock (up to 1.2 GHz) directly to clk_set_rate().
Unless the platform clock tree or adapter divides the video clock internally when 2ppc is enabled, clk_set_rate() can fail, clamp to 600 MHz, or clock the video input at twice the required rate, breaking output for modes above 600 MHz.
[ ... ]
Quoted 13 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +13
-0+for (i =0 ; i <DP_MAX_TRAINING_LOOP ; i++) { +for (j =0 ; j <=3 ; j++) { +if (!(dp->state &DPTX_STATE_READY )) { + ret = -ENODEV ; + goto err_restore; + } + + ret = dp->hw->ops->link_train (dp->hw, dp->phy, + mode->bw_code, + mode->lane_cnt, +DPTX_MAX_LANES ); +if (!ret) { + if (dp->active_stream_cnt &&
drivers/gpu/drm/bridge/trilinear/dptx_core.c line 292
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +10
-0+ (mode->bw_code != prev_bw || + mode->lane_cnt != prev_lanes)) +dptx_active_streams (dp); +return 0 ; + } + + ret =dptx_mode_configure (dp, mode->pclock, bw_code, + bpp, true); +if (ret <0 ) +break ;
[Severity: Medium]
Can dptx_train_loop() hold dp->lock through repeated AUX timeouts if the sink is unplugged or stops responding during link training?
Both callers (dptx_core_on() and dptx_hpd_irq_work_func()) hold dp->lock across dptx_train_loop(), so DPTX_STATE_READY cannot change inside the loop. When link_train() fails with -ETIMEDOUT, the loop ignores the error code and HPD state, downshifting through every link rate across DP_MAX_TRAINING_LOOP iterations.
Because drm_dp_dpcd_access() retries each failed DPCD access 32 times, this stalls dp->lock for hundreds of milliseconds (up to ~1.5 s if the 4 ms AUX or 100 ms PHY-ready poll ceiling is hit), blocking disconnect handling, suspend, and modeset callbacks, and masks -ETIMEDOUT as -EIO.
Aborting the loop when !dptx_get_hpd_state(dp) or when link_train() returns a transport error other than -EIO avoids the stall.
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_core.c line 581
Quoted 9 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +9
-0+static bool dptx_wait_phy_dp_mode (struct dptx_dev *dp) +{ +enum phy_mode mode; + +read_poll_timeout (phy_get_mode, mode, + mode ==PHY_MODE_DP ||dptx_hpd_wait_aborted (dp), +100 *USEC_PER_MSEC , +DP_HPD_MAX_TRIES *100 *USEC_PER_MSEC , false, + dp->phy);
[Severity: Medium]
Can this 10-second read_poll_timeout() in dptx_hpd_event_work_func() stall system suspend freezing?
hpd_event_work runs on system_freezable_wq. During suspend, try_to_freeze_tasks() waits for all WQ_FREEZABLE workqueues to drain before device suspend callbacks run dptx_pm_prepare() to set DPTX_STATE_SUSPENDED, so dptx_hpd_wait_aborted() stays false.
If the PHY transition depends on userspace or another freezable workqueue, the poll blocks freezing for the full 10 seconds (or causes freezing to fail if freeze_timeout_msecs is shorter). Re-arming hpd_event_work with a 100 ms delay and a retry counter instead of sleeping inside the worker avoids blocking suspend and teardown.
[ ... ]
Quoted 12 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +12
-0+static void dptx_replay_deferred_hotplug (struct dptx_dev *dp) +{ +guard (mutex)(&dp->lock); + +if (!dptx_deferred_hotplug_pending (dp)) +return ; + +if (dptx_get_hpd_state (dp)) { +queue_delayed_work (system_freezable_wq, &dp->hpd_event_work,0 ); +return ; + } +
drivers/gpu/drm/bridge/trilinear/dptx_core.c line 672
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +10
-0+if (!dp->oob_hpd ||phy_get_mode (dp->phy) !=PHY_MODE_DP ) +return ; + +if (!dp->hw->ops->sink_present (dp->hw)) +return ; + + dp->force_hpd = connector_status_connected; + +queue_delayed_work (system_freezable_wq, &dp->hpd_event_work,0 ); +}
[Severity: Medium]
Can the deferred hotplug queued here be silently dropped before bridge->hpd_cb is installed?
dptx_bridge_attach() calls dptx_replay_deferred_hotplug() with zero delay, which runs before drm_bridge_connector_init() and drm_kms_helper_poll_init() -> drm_bridge_hpd_enable() register bridge->hpd_cb. Because bridge->dev is already set, dptx_hpd_event_work_func() calls drm_bridge_hpd_notify() while bridge->hpd_cb is still NULL and the event is lost.
Since dptx_bridge_funcs does not implement .hpd_enable, the dropped hotplug is never replayed once HPD callbacks are wired up, leaving connector->status as unknown when no in-kernel DRM client probes at boot. Replaying deferred hotplug from .hpd_enable avoids losing the initial plug event.
[ ... ]
Quoted 6 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +6
-0+static void dptx_deinit (struct dptx_dev *dp) +{ +struct device_link *link =NULL ; + + scoped_guard(mutex, &dp->lock) { +if (!(dp->state &DPTX_STATE_CONFIGURED ))
drivers/gpu/drm/bridge/trilinear/dptx_core.c line 904
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +10
-0+return ; + +WRITE_ONCE (dp->hpd_stopped, true); +dptx_irq_off (dp); + } + +dptx_cancel_hpd_works (dp); + + scoped_guard(mutex, &dp->lock) { + dp->released = true;
[Severity: Medium]
Can a concurrent dptx_bridge_attach() race with dptx_deinit() and leave hpd_event_work running after teardown?
Because trilinear_dptx_remove() and dptx_dev_release() run before devm_drm_bridge_add() removes the bridge from bridge_list, a display controller can attach during the unlocked window around dptx_cancel_hpd_works(), while dp->released is still false:
CPU0 CPU1dptx_deinit()
lock(&dp->lock)
dp->hpd_stopped = true
unlock(&dp->lock)
dptx_cancel_hpd_works()
dptx_bridge_attach()
lock(&dp->lock)
/* dp->released is false */
dp->hpd_stopped = false
dp->attached = true
unlock(&dp->lock)
replay_deferred_hotplug()
queue_delayed_work(hpd_event_work) lock(&dp->lock)
dp->released = true
...
unlock(&dp->lock)devres_release_all()
drm_bridge_remove()
devm_phy_release()
dptx_hpd_event_work_func()
phy_get_mode(dp->phy) <-- use-after-freeThe worker can also call dptx_notify_hpd() after drm_bridge_remove() destroys bridge->hpd_mutex, and because dp->hpd_stopped stays false, dptx_hpd_notify() can continue queueing HPD work after teardown.
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_core.c line 915
Quoted 7 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +7
-0+ link = dp->link; + dp->link =NULL ; + } + +if (link) +device_link_del (link); +}
[Severity: Medium]
Can device_link_del(link) here (and in dptx_bridge_detach()) trigger a use-after-free if the consumer device is removed first?
dptx_bridge_attach() caches a raw struct device_link * in dp->link. If the display controller device (bridge->dev->dev) is removed while a client still holds /dev/dri/cardN open, device_del() -> device_links_purge() frees that link before deferred drm_mode_config_cleanup() runs dptx_bridge_detach(), and without clearing dp->link.
A subsequent dptx_deinit() or dptx_bridge_detach() then passes the freed pointer to device_link_del(). Using device_link_remove() with the consumer and supplier devices avoids dereferencing a stale link pointer.
[Severity: Medium]
Can releasing dp->lock before calling device_link_del(link) race with device_links_purge() on the other teardown path?
Both dptx_deinit() and dptx_bridge_detach() clear dp->link under dp->lock and call device_link_del(link) after unlocking:
CPU0 CPU1dptx_bridge_detach()
lock(&dp->lock)
link = dp->link
dp->link = NULL
unlock(&dp->lock)
device_del(dp->dev)
trilinear_dptx_remove()
dptx_deinit()
/* sees dp->link == NULL */
device_links_purge(dp->dev)
__device_link_del(&link->kref) device_link_del(link) <-- use-after-free
The symmetric race occurs when dptx_deinit() clears dp->link first and dptx_bridge_detach() returns to consumer device_del(). Removing the link while still holding dp->lock prevents the other path from reaching device_links_purge() first.
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_core.c line 999
Quoted 1 line
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +1
-0+dev_set_drvdata (dev, dp);
[Severity: Low]
Should trilinear_dptx_probe() leave dev_set_drvdata() to the platform glue driver, or document that it takes ownership of dev->driver_data?
trilinear_dptx_probe() returns struct dptx_dev *, all companion helpers take dp explicitly, and nothing in drivers/gpu/drm/bridge/trilinear/ calls dev_get_drvdata(). Silently overwriting drvdata breaks platform drivers that store their own private data before calling trilinear_dptx_probe().
Note that commit "drm/cix: add the Sky1 DisplayPort platform glue" currently relies on this side effect instead of calling platform_set_drvdata().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewRe: [PATCH v9 3/5] drm/bridge: trilinear: add the DPTX DRM bridge
In reply to Luo LiuThank you for your contribution! Sashiko AI review found 7 potential issues to consider: - [High] drm/bridge: trilinear: dptx_bridge_attach() omits downstream bridge chaining - [Medium] drm/bridge…
Thank you for your contribution! Sashiko AI review found 7 potential issues to consider:
- [High] drm/bridge: trilinear: dptx_bridge_attach() omits downstream bridge chaining
- [Medium] drm/bridge: unquantized bpc and missing zero info->bpc cap in dptx_cal_bpc()
- [Medium] drm/bridge: UAF of dp->dev in dptx_bridge_atomic_enable() error paths
- [Medium] drm/bridge: trilinear: UAF calling device_link_del() after consumer removal
- [Medium] drm/bridge: trilinear: dptx_bridge_atomic_check() validates link on DPMS off
- [Low] drm/bridge: unreachable RGB bpc fallback in dptx_pick_format_bpc()
- [Low] drm/bridge: 32-bit overflow in dptx_hw_stream_timing_set() from valid modes
--
commit a2fe608ed44e66c7e1c705abc9a47feab7f0a6e0
Author: Luo Liu <[email protected]>
drm/bridge: trilinear: add the DPTX DRM bridge
This commit adds the DRM bridge layer for the Trilinear DisplayPort transmitter, covering detection, EDID and downstream mode enumeration, mode validation, format and bpc selection, atomic enable and disable, and device-link management on attach and detach.
Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +0
-0
[ ... ]
Quoted 13 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +13
-0+static int dptx_cal_bpc (struct drm_connector_state *connector_state, +int format,int bpc) +{ +struct drm_display_info *info = + &connector_state->connector->display_info; + +if (dptx_bt2020_colorspace (connector_state)) + bpc =min (bpc,10 ); + +if (info->bpc) + bpc =min_t (int, bpc, info->bpc); + +if (connector_state->max_requested_bpc)
drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 273
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10
-0+ bpc =min (bpc, connector_state->max_requested_bpc); + +if (bpc <6 ) +return -EINVAL ; + +if (bpc <8 && format !=DRM_OUTPUT_COLOR_FORMAT_RGB444 ) +return -EINVAL ; + +return bpc; +}
[Severity: Medium]
Can dptx_cal_bpc() return an odd bpc value that the hardware register programming silently maps to 8 bpc?
max_requested_bpc comes from a continuous range property, so userspace can request values such as 7 or 9. dptx_cal_bpp() computes the transfer unit and user data count from that unquantized bpp, while dptx_hw_stream_misc() and dptx_hw_stream_format_set() in dptx_hw.c only encode discrete DP depths (6, 8, 10, 12, 16) and fall through to 8 bpc for anything else, corrupting stream framing and exceeding a 7-bpc cap.
Separately, when a sink leaves info->bpc as 0 (treated as 8 bpc elsewhere in the driver), skipping the info->bpc cap lets 10-bpc YCbCr 4:2:2 or BT.2020 RGB exceed the sink's default 8-bpc depth. Clamping against info->bpc ? info->bpc : 8 and rounding bpc down to the nearest discrete DP depth would prevent both mismatches.
[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 409
Quoted 13 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +13
-0+if (suggest_bpc >10 && + !compute_available_clock_rate (dp, conn_state,10 , + adjusted_mode->clock, + format, bpc, bpp)) { +if (color_format) + *color_format = format; +return 0 ; + } + +if (!compute_available_clock_rate (dp, conn_state, + suggest_bpc, + adjusted_mode->clock, + format, bpc, bpp)) {
[Severity: Low]
Does trying 10 bpc before suggest_bpc make 12-bpc RGB unreachable?
When a sink advertises more than 10 bpc, the first check succeeds and returns early at 10 bpc if link bandwidth allows; if 10 bpc does not fit, the higher suggest_bpc requires more bandwidth and can never succeed either.
[ ... ]
Quoted 6 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +6
-0+static int dptx_bridge_atomic_check (struct drm_bridge *bridge, +struct drm_bridge_state *bridge_state, +struct drm_crtc_state *crtc_state, +struct drm_connector_state *conn_state) +{ +struct dptx_dev *dp =bridge_to_dp (bridge);
drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 562
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10
-0+int bpc; +int bpp; +int ret; +bool vsc_supported; + +if (!conn_state->crtc) +return 0 ; + +if (!dptx_adjust_mode (&crtc_state->mode, &crtc_state->adjusted_mode)) +return -EINVAL ;
[Severity: Low]
Can a custom userspace mode accepted here overflow 32-bit arithmetic when programming the secondary data window?
Neither dptx_bridge_mode_valid() nor dptx_bridge_atomic_check() caps htotal - hdisplay below U16_MAX, so a custom mode with large horizontal blanking (over 35349 pixels at HBR2 or 23566 at HBR3) wraps modulo 2^32 in dptx_hw_stream_timing_set():
drivers/gpu/drm/bridge/trilinear/dptx_hw.c:dptx_hw_stream_timing_set() {
...
dptx_hw_write(hw, DPTX_SECONDARY_DATA_WINDOW(stream_id),
(mode->htotal - mode->hdisplay) * (link_rate / 40) *
9 / mode->clock);
...
}Because link_rate is u32, the numerator overflows before division by mode->clock and writes a corrupted secondary data window. Using 64-bit arithmetic with mul_u32_u32() and div_u64() would avoid the wraparound.
drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 571
Quoted 8 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +8
-0+ scoped_guard(mutex, &dp->lock) { + ret =dptx_pick_config (dp, conn_state, &crtc_state->mode, + &crtc_state->adjusted_mode, +NULL , &bpc, &bpp); + vsc_supported = dp->hw->ops->vsc_supported (dp->hw); + } +if (ret) +return ret;
[Severity: Medium]
Can dptx_bridge_atomic_check() reject a DPMS off commit after hot-swapping to a lower-bandwidth sink?
When an active high-bandwidth sink (such as 4-lane HBR2 at 4K@60Hz) is swapped for a lower-bandwidth sink, the HPD worker updates dp->link_max_lanes and dp->link_max_rate immediately. A subsequent DPMS off commit sets crtc_state->active to false while leaving conn_state->crtc non-NULL and mode_changed and connectors_changed false.
In drm_atomic_helper_check_modeset(), mode_valid() skips the connector in that case, but mode_fixup() still calls drm_atomic_bridge_chain_check(). Unconditionally running dptx_pick_config() against the new sink's lower limits then returns -EINVAL and prevents userspace from turning the output off. Skipping link validation when !crtc_state->active (or when !crtc_state->mode_changed && !crtc_state->connectors_changed) would avoid this.
[ ... ]
Quoted 9 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +9
-0+ ret = dp->ops->prepare (dp); +if (ret) { +if (ret != -ENODEV ) +dev_err (dp->dev,"failed to prepare DP output: %d\n" , + ret); +return ; + } + + ret =dptx_bridge_mode_set (dp, crtc_state, conn_state);
drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 634
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10
-0+if (ret) { +dev_err (dp->dev,"failed to set DP mode: %d\n" , ret); + goto err_unprepare; + } + + ret = dp->ops->encoder_enable (dp,0 , true); +if (ret) { +dev_err (dp->dev,"failed to enable DP output: %d\n" , ret); + goto err_unprepare; + }
[Severity: Medium]
Can these dev_err(dp->dev, ...) calls hit a use-after-free if the transmitter platform device is removed concurrently?
struct dptx_dev can outlive its backing platform device while the refcounted drm_bridge remains attached, and neither __devm_drm_bridge_alloc() nor probe takes a get_device(dp->dev) reference. Because dp->lock is not held across prepare(), dptx_bridge_mode_set(), and encoder_enable(), platform device removal can finish in between:
CPU0 CPU1dptx_bridge_atomic_enable()
dp->ops->prepare(dp) -> 0
device_del(dp->dev)
... -> dptx_deinit()
dp->released = true
put_device(dp->dev) (freed) dptx_bridge_mode_set() -> -ENODEV
dev_err(dp->dev, ...) <-- use-after-free
The same race applies to the encoder_enable() error path and to the prepare() error path after a non--ENODEV failure. Logging with drm_err(bridge->dev, ...) or holding a get_device(dp->dev) reference until dptx_bridge_destroy() would prevent this.
[ ... ]
Quoted 27 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +27
-0+static int dptx_bridge_attach (struct drm_bridge *bridge, +struct drm_encoder *encoder, +enum drm_bridge_attach_flags flags) +{ +struct dptx_dev *dp =bridge_to_dp (bridge); +int ret; + +if (!(flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR )) +return -EINVAL ; + + scoped_guard(mutex, &dp->lock) { +if (dp->released) { + ret = -ENODEV ; + }else { + ret = dp->hw->ops->aux_register (dp->hw, bridge->dev); +if (!ret) { + dp->link =device_link_add (bridge->dev->dev, + dp->dev, +DL_FLAG_STATELESS ); +if (dp->link) { +WRITE_ONCE (dp->hpd_stopped, false); + dp->attached = true; + }else { + dp->hw->ops->aux_unregister (dp->hw); + ret = -EINVAL ; + } + }
drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 689
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10
-0+ } + } +if (ret) +return ret; + +/* The bridge may have been attached long after the sink was plugged. */ + dp->ops->replay_deferred_hotplug (dp); + +return 0 ; +}
[Severity: High]
Does omitting downstream bridge chaining in dptx_bridge_attach() break out-of-band USB-C HPD delivery?
dptx_hpd_notify() relies on external drm_bridge_connector_hpd_notify() calls when dp->oob_hpd is set. Because neither probe nor dptx_bridge_attach() acquires and chains a downstream bridge from port@1, dp->bridge stays the last bridge in encoder->bridge_chain.
drm_bridge_connector_init() then sets connector->fwnode to the DP controller's of_node rather than the usb-c-connector node, so drm_connector_oob_hotplug_event() from typec_displayport fails to match in drm_connector_find_by_fwnode() and silently drops every USB-C hotplug event. Any downstream bridge or panel wired to port@1 as described in the DT binding also cannot be attached.
Quoted 11 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +11
-0+static void dptx_bridge_detach (struct drm_bridge *bridge) +{ +struct dptx_dev *dp =bridge_to_dp (bridge); +struct device_link *link; + +/* Stop workers before the connector goes away. */ + dp->ops->quiesce_hpd (dp); + + scoped_guard(mutex, &dp->lock) { + dp->attached = false; +
drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 711
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10
-0+if (!dp->released) + dp->hw->ops->aux_unregister (dp->hw); + + link = dp->link; + dp->link =NULL ; + } + +if (link) +device_link_del (link); +}
[Severity: Medium]
Can calling device_link_del() on the cached dp->link pointer hit a use-after-free if the consumer display controller is removed while userspace holds the DRM device open?
When a display controller defers drm_mode_config_cleanup() via drmm_mode_config_init() and userspace keeps /dev/dri/cardN open, device_del(bridge->dev->dev) runs device_links_purge() and frees all supplier links, including DL_FLAG_STATELESS ones, before the final drm_dev_put() invokes drm_encoder_cleanup() -> dptx_bridge_detach().
Passing the cached pointer to device_link_del() then dereferences freed memory and violates the drivers/base/core.c contract against calling device_link_del() after links are purged. Removing the link with device_link_remove(consumer, dp->dev) instead of caching a raw struct device_link pointer avoids dereferencing a purged link.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
回复: [PATCH v9 2/5] drm/bridge: trilinear: add the DPTX hardware layer
In reply to [email protected]Quoted 296 lines
-----邮件原件-----
发件人: [email protected] <[email protected]>
发送时间: 2026年12月4日 16:14
收件人: Luo Liu <[email protected]>
抄送: [email protected]; [email protected]; [email protected]; [email protected]
主题: Re: [PATCH v9 2/5] drm/bridge: trilinear: add the DPTX hardware layerEXTERNAL EMAIL
Thank you for your contribution! Sashiko AI review found 11 potential issues to consider:
- [Medium] drm/bridge: trilinear: leave opts.dp.lanes unset indptx_hw_link_rate()
- [Medium] drm/bridge: trilinear: missing pre-emphasis and swing sum clamping
- [Medium] drm/bridge: trilinear: hardcode CTA limited range for RGB VSC SDP
- [Medium] drm/bridge: trilinear: omit DCI-P3 and xvYCC/BT.709 in VSC SDP check
- [Medium] drm/bridge: trilinear: leave unhandled interrupt bit 5 unmasked
- [Medium] drm/bridge: trilinear: ignore DPCD write error indptx_hw_link_train_end()
- [Low] drm/bridge: trilinear: writeDP_TRAINING_LANE0_SETbefore PHY update
- [Low] drm/bridge: trilinear: commit message claims unimplemented downshifting
- [Low] drm/bridge: trilinear: unnecessary single-implementationdptx_hw_opsvtable
- [Low] drm/bridge: trilinear:dptx_hw_stream_format_set()lacks YUV420 VSC check
- [Low] drm/bridge: trilinear: 32-bit overflow indptx_hw_stream_timing_set()
--commit
e7608fe3dedcf10692a9cd8f3d2a2dbebc772270
Author: Luo Liu <[email protected]>drm/bridge: trilinear: add the DPTX hardware layer
This commit adds the register and PHY programming layer for the Trilinear DisplayPort transmitter, including AUX transfers, DPCD capability parsing, link training, and per-stream timing and format setup.
Quoted 5 lines
Add the register and PHY programming for the Trilinear DisplayPort
transmitter: controller reset, host and core enable, AUX transfers through the controller's AUX channel, sink capability parsing from the DPCD, and link training with rate downshifting when the sink cannot lock.[Severity: Low]
Is the commit message accurate about rate downshifting? In this patch,dptx_hw_link_train()only runs a single link training attempt at the caller-suppliedbw_codeandlane_cntand does not implement rate downshifting.Quoted 6 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +0
-0[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c
Quoted 3 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +3
-0+#define DPTX_INTERRUPT_GP_TIMER_IRQ BIT(4) #define +DPTX_INTERRUPT_REPLY_TIMEOUT BIT(3) #define +DPTX_INTERRUPT_REPLY_RECEIVED BIT(2) #define
DPTX_INTERRUPT_HPD_IRQdrivers/gpu/drm/bridge/trilinear/dptx_hw.c line 242
Quoted 4 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +4
-0+BIT(1) #define DPTX_INTERRUPT_HPD_EVENT BIT(0) + +#define DPTX_INTERRUPT_MASK_ALL 0x3f +#define DPTX_INTERRUPT_CFG 0x1c[Severity: Medium]
DoesDPTX_INTERRUPT_CFGleave interrupt bit 5 unmasked?
DPTX_INTERRUPT_MASK_ALLcovers bits 0..5 (0x3f), where 1 masks an interrupt and 0 enables it. WritingDPTX_INTERRUPT_CFG(0x1c) toDPTX_INTERRUPT_MASKindptx_hw_host_enable()unmasks bit 5 alongsideHPD_EVENTandHPD_IRQ, even thoughdptx_hw_irq()only handles bits 0..4 and swallows any other unmasked cause bit asIRQ_HANDLED. DefiningDPTX_INTERRUPT_CFGasDPTX_INTERRUPT_MASK_ALL& ~(DPTX_INTERRUPT_HPD_EVENT |DPTX_INTERRUPT_HPD_IRQ) (0x3c) keeps bit 5 masked.[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 396
Quoted 13 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +13
-0+static int dptx_hw_link_rate (struct dp_hw *hw,struct phy *phy, +u8 bw_code,u8 lanes,bool downspread) { +union phy_configure_opts opts = {0 }; +u32 ready = (1 << lanes) -1 ; +u32 value; +int ret; + +dptx_hw_write (hw,DPTX_LINK_BW_SET , bw_code); + + opts.dp.link_rate =drm_dp_bw_code_to_link_rate (bw_code) /100 ; + opts.dp.ssc = downspread; + opts.dp.set_rate =1 ; + ret =phy_configure (phy, &opts);[Severity: Medium]
Shoulddptx_hw_link_rate()set opts.dp.lanes and opts.dp.set_lanes before callingphy_configure()?Because opts is zero-initialized, opts.dp.lanes is passed as 0 instead of 1, 2, or 4, which causes generic DP PHY drivers such as phy-cadence-torrent to reject
phy_configure()with-EINVAL. In addition, opts.dp.set_lanes is never set anywhere in the driver anddptx_hw_link_configure()passesnum_lanesrather than the activelane_cnt, so PHY drivers that implementset_lanesnever reconfigure their active lanes.[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c
Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +5
-0+static int dptx_hw_link_vs_emph (struct dp_hw *hw,struct phy *phy, +u8 lane_cnt) { +int ret; + + ret = drm_dp_dpcd_write(&hw->aux, DP_TRAINING_LANE0_SET,
hw->train_setting,drivers/gpu/drm/bridge/trilinear/dptx_hw.c
Quoted 6 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +6
-0+ lane_cnt); +if (ret <0 ) +return ret; + +return dptx_hw_phy_vs_emph_set (hw, phy, lane_cnt, +hw->train_setting); }[Severity: Low]
Shoulddptx_hw_phy_vs_emph_set()run before writingDP_TRAINING_LANE0_SETto the sink?Updating the sink DPCD first exposes it to stale drive levels if it starts evaluating immediately, and leaves the sink notified even if
phy_configure()fails.Quoted 12 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +12
-0+static void dptx_hw_link_adjust_train (struct dp_hw *hw,u8 lane_cnt, +const u8 *link_status) { +u8 voltage; +u8 preemphasis; +int i; + +for (i =0 ; i < lane_cnt; i++) { + voltage =drm_dp_get_adjust_request_voltage (link_status, i); + preemphasis = + +drm_dp_get_adjust_request_pre_emphasis (link_status, i); +drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 533
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +10
-0+if (voltage >=DP_TRAIN_VOLTAGE_SWING_LEVEL_3 ) + voltage |=DP_TRAIN_MAX_SWING_REACHED ; + +if (preemphasis >=DP_TRAIN_PRE_EMPH_LEVEL_2 ) + preemphasis |= +DP_TRAIN_MAX_PRE_EMPHASIS_REACHED ; + + hw->train_setting[i] = voltage | preemphasis; + } +}[Severity: Medium]
Candptx_hw_link_adjust_train()pass out-of-spec swing and pre-emphasis levels tophy_configure()?When a sink requests pre-emphasis level 3, this sets
DP_TRAIN_MAX_PRE_EMPHASIS_REACHEDat level 2 without clamping preemphasis to level 2, passing opts.dp.pre[i] = 3 indptx_hw_phy_vs_emph_set(). It also does not enforce voltage + pre-emphasis <= 3, so combinations like swing level 2 with pre-emphasis level 2 are rejected with-EINVALby generic DP PHY drivers such as phy-cadence-torrent and abort link training.[ ... ]
Quoted 7 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +7
-0+static void dptx_hw_link_train_end (struct dp_hw *hw) { +drm_dp_dpcd_writeb (&hw->aux,DP_TRAINING_PATTERN_SET ,0 ); +dptx_hw_write (hw,DPTX_TRAINING_PATTERN_SET ,0 ); +dptx_hw_write (hw,DPTX_DISABLE_SCRAMBLING ,0 ); } + +static int dptx_hw_link_train (struct dp_hw *hw,struct phy *phy,u8 bw_code, +u8 lane_cnt,u8 num_lanes) {[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 616
Quoted 4 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +4
-0+dptx_hw_link_train_end (hw); + +return ret; +}[Severity: Medium]
Shoulddptx_hw_link_train_end()propagate a DPCD write error when link training otherwise succeeded?If clearing
DP_TRAINING_PATTERN_SETon the sink fails after clock recovery and channel equalization pass,dptx_hw_link_train()still returns 0 while the sink remains in training pattern mode, preventing callers from retrying or downshifting. Propagating the error when ret == 0 (while keeping any earlier training error) avoids reporting a false success.[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 1050
Quoted 3 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +3
-0+dptx_hw_write (hw,DPTX_SECONDARY_DATA_WINDOW (stream_id), + (mode->htotal - mode->hdisplay) * (link_rate /40 ) * +9 / mode->clock);[Severity: Low]
Can thisDPTX_SECONDARY_DATA_WINDOWcalculation overflow 32-bit unsigned arithmetic?Because
link_rateis u32, the numerator wraps when horizontal blanking is at least 35350 pixels at HBR2 or 23567 pixels at HBR3 for a custom userspace mode, writing a truncated value to the register. Using 64-bit arithmetic withdiv_u64()avoids the wrap.[ ... ]
Quoted 8 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +8
-0+static bool dptx_hw_needs_vsc_sdp (enum dp_pixelformat format, +u32 colorspace) { +if (format ==DP_PIXELFORMAT_YUV420 ) +return true; + +switch (colorspace) { +case DRM_MODE_COLORIMETRY_SYCC_601 : +case DRM_MODE_COLORIMETRY_OPYCC_601 :drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 1143
Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +10
-0+case DRM_MODE_COLORIMETRY_BT2020_YCC : +case DRM_MODE_COLORIMETRY_BT2020_RGB : +case DRM_MODE_COLORIMETRY_BT2020_CYCC : +return true; +default : +break ; + } + +return false; +}[Severity: Medium]
Shoulddptx_hw_needs_vsc_sdp()also return true for DCI-P3 RGB (D65 and Theater), xvYCC 601/709, and BT.709 YCbCr?
dptx_hw_vsc_colorimetry()maps all five colorspaces, but whendptx_hw_needs_vsc_sdp()returns false,dptx_hw_stream_misc()ignores colorspace and programs MISC0 as sRGB or BT.601. This leaves the DCI-P3 RGB cases unreachable for RGB streams and silently drops these colorspaces unless paired with YUV420.[ ... ]
Quoted 1 line
+static int dptx_hw_stream_format_set(struct
dp_hw*hw, unsigned int
stream_id,Quoted 1 line
+ enum
dp_pixelformatformat, u32colorspace,
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 1189
Quoted 8 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +8
-0+ u8 bpc, u8 content_type) { +struct drm_dp_vsc_sdp vsc = {}; +struct dp_sdp sdp; +bool enable; +ssize_t len; + + enable = hw->caps.vsc_supported && +dptx_hw_needs_vsc_sdp (format, colorspace);[Severity: Low]
Shoulddptx_hw_stream_format_set()return an error when format isDP_PIXELFORMAT_YUV420andhw->caps.vsc_supportedis false?If
hw->caps.vsc_supportedbecomes false (for example, if a DPCD re-read hits an AUX error onDP_DPRX_FEATURE_ENUMERATION_LIST, whichdrm_dp_vsc_sdp_supported()converts to false), enable is false anddptx_hw_stream_misc()falls into its default case, programming RGB in MISC0 withDPTX_MAIN_STREAM_OVERRIDEleft at 0 and returning 0 instead of failing cleanly.[ ... ]
drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 1212
Quoted 2 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +2
-0+ vsc.dynamic_range =DP_DYNAMIC_RANGE_CTA ; + vsc.content_type = content_type;[Severity: Medium]
Should vsc.dynamic_range beDP_DYNAMIC_RANGE_VESAwhen format isDP_PIXELFORMAT_RGB?Hardcoding
DP_DYNAMIC_RANGE_CTAsignals limited dynamic range (16-235) for wide-gamut RGB modes such as BT.2020 RGB, mismatching the full-range RGB signaled in MISC0 when VSC SDP is disabled and crushing blacks and whites on the sink.Quoted 6 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.h new file +0
-0[ ... ]
Quoted 8 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.h line 60
Quoted 3 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.h new file +3
-0+struct dptx_hw_ops { +bool (*hpd_state)(struct dp_hw *hw); +bool (*sink_present)(struct dp_hw *hw);[Severity: Low]
This isn't a bug, but is the 20-entry structdptx_hw_opsvtable needed whendptx_hw_opsindptx_hw.cis its only implementation? Declaring direct dptx_hw_*() functions indptx_hw.hwould avoid the indirect call boilerplate.
Thanks. This is intentional — it's the style of this driver: hardware access stays behind dptx_hw_ops, so the upper layers never touch SoC-specific code. Keeping it as is.
Quoted 5 lines
--
Sashiko AI
review · https://sashiko.dev/#/patchset/20261204074239.133559-1-Luo.Liu@c
ixtech.com?part=2