Skip to contentSkip to conversation

drm/bridge: trilinear: add the Sky1 DisplayPort transmitter

PATCH Superseded Luo Liu 2 participants 11 messages Dec 4

Subsystems (4)

v10 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Luo Liu

author
#0 lore raw

v10 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. A bridge wired in front of the connector is chained from port@1.

Changes in v10:
- port@1 is resolved at probe: a remote endpoint means a converter bridge ahead of the connector, which the bridge chains and releases on destroy; without one the port feeds the native DP PHY.
- Link training gives up when HPD drops, propagates failures other than -EIO, programs the PHY swing and pre-emphasis before the DPCD request, and clamps the pre-emphasis so swing plus pre-emphasis stays within 3.5 dB.
- The PHY is configured with the lane count being trained, and the enhanced-frame flag no longer leaks into the caller's lane count.
- The hotplug replay waits for the common PHY from the event work with a bounded retry instead of polling in interrupt context, and only the HPD interrupt sources are left unmasked.
- The stream clock is divided by the pixel-per-cycle factor.
- RGB tries 10 bpc first when BT.2020 or a deeper mode is requested, and the bpc is rounded down to a supported value.
- VSC is refused for 4:2:0 when the sink lacks support, its dynamic range follows the pixel format, and BT.709/XVYCC/DCI-P3 colorspaces are mapped.
- The secondary data window is computed in 64-bit arithmetic.
- atomic_check returns early when the CRTC is off.
- The platform glue stores the dptx_dev in drvdata.

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       |  114 ++
 drivers/gpu/drm/bridge/trilinear/dptx_core.c  | 1077 +++++++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_drm.c   |  769 +++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_drm.h   |   17 +
 drivers/gpu/drm/bridge/trilinear/dptx_hw.c    | 1418 +++++++++++++++++
 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           |  181 +++
 include/drm/bridge/trilinear_dp.h             |   84 +
 20 files changed, 3950 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
author
#1 lore raw

PATCH v10 1/5 dt-bindings: display: add CIX Sky1 DisplayPort transmitter

Add 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, gets its connector from drm_bridge_connector_init(), and chains a downstream bridge from port@1 when one is wired.

---
 .../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
new file mode 100644
index 000000000000..d382e38637b9
@@ -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
index 93abbb315065..e3557e931c94 100644
@@ -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
author
#2 lore raw

PATCH v10 2/5 drm/bridge: trilinear: add the DPTX hardware layer

In reply to Luo Liu

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 clock recovery and channel equalization.

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 | 1418 ++++++++++++++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_hw.h |  103 ++
 3 files changed, 1522 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
index e3557e931c94..01ff0666f63b 100644
@@ -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 +1418 -0

1,418 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
#3 lore raw

Re: [PATCH v10 2/5] drm/bridge: trilinear: add the DPTX hardware layer

Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [High] drm/bridge: trilinear: dptx_hw_link_vs_emph() returns positive byte count - [Medium] drm/bridge…

Thank you for your contribution! Sashiko AI review found 5 potential issues to consider:
- [High] drm/bridge: trilinear: dptx_hw_link_vs_emph() returns positive byte count
- [Medium] drm/bridge: dptx_hw_link_adjust_train() clamps pre-emphasis instead of swing
- [Medium] drm/bridge: trilinear: missing CR limits in dptx_hw_link_clock_recovery()
- [Low] drm/bridge: trilinear: duplicate DPCD power helpers in dptx_hw.c
- [Low] drm/bridge: trilinear: unnecessary single-implementation dptx_hw_ops vtable
--

commit f4828b3f444687387aa09825f7746b0c5c9153bf
Author: Luo Liu <[email protected]>

drm/bridge: trilinear: add the DPTX hardware layer

This commit adds the register, AUX channel, DPCD capability, link training, and main stream programming layer for the Trilinear DisplayPort transmitter.

Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +0 -0
new file mode 100644
index 0000000000000..bdf24e464b942

[ ... ]

drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 468

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 = dptx_hw_phy_vs_emph_set(hw, phy, lane_cnt, hw->train_setting);
+	if (ret)
+		return ret;
+
+	return drm_dp_dpcd_write(&hw->aux, DP_TRAINING_LANE0_SET,
+				 hw->train_setting, lane_cnt);
+}

[Severity: High]
Does dptx_hw_link_vs_emph() return a positive byte count on success?

drm_dp_dpcd_write() returns the number of bytes written (lane_cnt) rather than 0. Both dptx_hw_link_clock_recovery() and dptx_hw_link_channel_equalization() treat any non-zero return as an error, so link training aborts on the first clock-recovery iteration, skips channel equalization, and fails modeset enable.

Using drm_dp_dpcd_write_data() here returns 0 on a full write and a negative error code on failure or a short write.

Quoted 9 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +9 -0
+
+static void dptx_hw_link_adjust_train(struct dp_hw *hw, u8 lane_cnt,
+				      const u8 *link_status)
+{
+	u8 voltage;
+	u8 preemphasis;
+	u8 pre_level;
+	int i;
+

drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 487

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +10 -0
+	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);
+		pre_level = preemphasis >> DP_TRAIN_PRE_EMPHASIS_SHIFT;
+
+		if (voltage + pre_level > 3) {
+			pre_level = 3 - voltage;
+			preemphasis = pre_level << DP_TRAIN_PRE_EMPHASIS_SHIFT;
+		}

[Severity: Medium]
Should this clamp voltage swing instead of pre-emphasis when voltage + pre_level > 3?

Per the DisplayPort specification, when a requested combination exceeds 3, the transmitter keeps the requested pre-emphasis and clamps voltage to 3 - pre_level. Clamping pre-emphasis instead drops requested pre-emphasis during link training and fails DisplayPort compliance tests.

[ ... ]

Quoted 3 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +3 -0
+static int dptx_hw_link_clock_recovery(struct dp_hw *hw, struct phy *phy,
+				       u8 lane_cnt)
+{

[ ... ]

Quoted 15 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +15 -0
+	for (i = 0; i < 512; i++) {
+		ret = dptx_hw_link_vs_emph(hw, phy, lane_cnt);
+		if (ret)
+			return ret;
+
+		drm_dp_link_train_clock_recovery_delay(&hw->aux, hw->dpcd);
+		ret = drm_dp_dpcd_read_link_status(&hw->aux, link_status);
+		if (ret < 0)
+			return ret;
+
+		train_done = drm_dp_clock_recovery_ok(link_status, lane_cnt);
+		if (train_done)
+			break;
+
+		memcpy(prev, hw->train_setting, lane_cnt);

drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 539

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +10 -0
+		dptx_hw_link_adjust_train(hw, lane_cnt, link_status);
+
+		if (!memcmp(hw->train_setting, prev, lane_cnt))
+			tries++;
+		else
+			tries = 0;
+
+		if (tries == DP_MAX_TRAINING_TRIES)
+			break;
+	}

[Severity: Medium]
Can this 512-iteration clock-recovery loop stall link training for seconds on a marginal or oscillating sink?

The loop never stops when DP_TRAIN_MAX_SWING_REACHED is set and does not enforce the DP 1.4 10-iteration limit (or a bounded cap such as 80 iterations for pre-DP 1.4 sinks).

On an oscillating pre-DP 1.4 sink with DP_TRAINING_AUX_RD_INTERVAL == 4, drm_dp_link_train_clock_recovery_delay() sleeps 16 to 32 ms per iteration, turning 512 iterations into an 8 to 16 second stall per training attempt.

[ ... ]

Quoted 39 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +39 -0
+static int dptx_hw_dpcd_power_up(struct dp_hw *hw,
+				 unsigned int delay_ms)
+{
+	u8 value;
+	int ret;
+
+	if (hw->dpcd[DP_DPCD_REV] < DP_DPCD_REV_11)
+		return 0;
+
+	ret = drm_dp_dpcd_readb(&hw->aux, DP_SET_POWER, &value);
+	if (ret < 0)
+		return ret;
+
+	value = (value & ~DP_SET_POWER_MASK) | DP_SET_POWER_D0;
+
+	ret = drm_dp_dpcd_writeb(&hw->aux, DP_SET_POWER, value);
+	if (ret < 0)
+		return ret;
+
+	msleep(delay_ms);
+
+	return 0;
+}
+
+static int dptx_hw_dpcd_power_down(struct dp_hw *hw, bool hpd)
+{
+	u8 value;
+	int ret;
+
+	if (!hpd)
+		return 0;
+
+	if (hw->dpcd[DP_DPCD_REV] < DP_DPCD_REV_11)
+		return 0;
+
+	ret = drm_dp_dpcd_readb(&hw->aux, DP_SET_POWER, &value);
+	if (ret < 0)
+		return ret;
+

drivers/gpu/drm/bridge/trilinear/dptx_hw.c line 882

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +10 -0
+	value = (value & ~DP_SET_POWER_MASK) | DP_SET_POWER_D3;
+
+	ret = drm_dp_dpcd_writeb(&hw->aux, DP_SET_POWER, value);
+	if (ret < 0)
+		return ret;
+
+	usleep_range(200, 205);
+
+	return 0;
+}

[Severity: Low]
Can dptx_hw_dpcd_power_up() and dptx_hw_dpcd_power_down() reuse drm_dp_link_power_up() and drm_dp_link_power_down()?

Those core helpers already check DP_DPCD_REV_11 and perform the DP_SET_POWER read-modify-write, avoiding duplicate DPCD power-state code.

[ ... ]

Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.h new file +0 -0
new file mode 100644
index 0000000000000..420ef242a4f61

[ ... ]

drivers/gpu/drm/bridge/trilinear/dptx_hw.h line 64

Quoted 7 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.h new file +7 -0
+struct dptx_hw_ops {
+	bool (*hpd_state)(struct dp_hw *hw);
+	bool (*sink_present)(struct dp_hw *hw);
+
+	void (*host_enable)(struct dp_hw *hw, bool enable);
+	void (*reset)(struct dp_hw *hw, bool assert);
+	void (*core_enable)(struct dp_hw *hw, int source_id, bool enable);

[Severity: Low]
Is the 20-method struct dptx_hw_ops vtable needed?

There is only one implementation (dptx_hw_ops in dptx_hw.c), assigned unconditionally in dptx_hw_init(). Declaring direct dptx_hw_*() functions in dptx_hw.h would avoid the boilerplate and indirect calls.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author
#4 lore raw

PATCH v10 3/5 drm/bridge: trilinear: add the DPTX DRM bridge

In reply to Luo Liu

Add 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     | 114 +++
 drivers/gpu/drm/bridge/trilinear/dptx_drm.c | 769 ++++++++++++++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_drm.h |  17 +
 include/drm/bridge/trilinear_dp.h           |  74 ++
 5 files changed, 975 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
index 01ff0666f63b..6ebb17dd18e9 100644
@@ -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 +114 -0

114 lines not on this page · raw message

drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +769 -0

769 lines not on this page · raw message

drivers/gpu/drm/bridge/trilinear/dptx_drm.h new file +17 -0
new file mode 100644
index 000000000000..fc30a7ce6e99
@@ -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
#5 lore raw

Re: [PATCH v10 3/5] drm/bridge: trilinear: add the DPTX DRM bridge

Thank you for your contribution! Sashiko AI review found 8 potential issues to consider: - [High] drm/bridge: trilinear: dptx_bridge_hpd_enable() skipped with downstream HPD - [Medium] drm/bridge…

Thank you for your contribution! Sashiko AI review found 8 potential issues to consider:
- [High] drm/bridge: trilinear: dptx_bridge_hpd_enable() skipped with downstream HPD
- [Medium] drm/bridge: trilinear: dptx_bridge_atomic_check() gates on crtc active
- [Medium] drm/bridge: trilinear: UAF of dp->dev in dptx_bridge_detach()
- [Medium] drm/bridge: trilinear: UAF of dp->dev in dptx_bridge_mode_set()
- [Medium] drm/bridge: trilinear: stale connector_state->max_bpc in dptx_cal_bpc()
- [Medium] drm/bridge: trilinear: detect_task echo filter bypassed with next_bridge
- [Low] drm/bridge: trilinear: dptx_format_ok() ignores connector ycbcr_420_allowed
- [Low] drm/bridge: trilinear: dptx_bridge_get_modes() skips clearing stale EDID
--

commit c57f0845c508835bad4ad01db002a262ef2f01b3
Author: Luo Liu <[email protected]>

drm/bridge: trilinear: add the DPTX DRM bridge

This patch adds the DRM bridge implementation for the Trilinear DisplayPort transmitter, including connector detection, EDID mode reading, mode validation, atomic check/enable/disable, and bridge attach/detach helpers.

Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +0 -0
new file mode 100644
index 0000000000000..02be7923528ff

[ ... ]

Quoted 34 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +34 -0
+static enum drm_connector_status dptx_bridge_detect(struct drm_bridge *bridge,
+						    struct drm_connector *connector)
+{
+	struct dptx_dev *dp = bridge_to_dp(bridge);
+	enum drm_connector_status status;
+
+	status = dp->ops->detect_status(dp);
+	WRITE_ONCE(dp->detect_task, current);
+
+	return status;
+}
+
+static void dptx_hpd_notify(struct dptx_dev *dp,
+			    enum drm_connector_status hpd_state)
+{
+	if (READ_ONCE(dp->detect_task) == current) {
+		WRITE_ONCE(dp->detect_task, NULL);
+		return;
+	}
+
+	if (READ_ONCE(dp->notify_task) == current) {
+		WRITE_ONCE(dp->notify_task, NULL);
+		return;
+	}
+
+	if (!dp->oob_hpd)
+		return;
+
+	guard(mutex)(&dp->lock);
+
+	if (dp->hpd_stopped ||
+	    hpd_state == connector_status_unknown)
+		return;
+

drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 90

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10 -0
+	dp->force_hpd = hpd_state;
+
+	if (!(dp->state & DPTX_STATE_SUSPENDED)) {
+		queue_delayed_work(system_freezable_wq, &dp->hpd_event_work, 0);
+		if (hpd_state == connector_status_connected)
+			queue_delayed_work(system_freezable_wq,
+					   &dp->hpd_irq_work,
+					   msecs_to_jiffies(20));
+	}
+}

[Severity: Medium]
Can chaining a downstream bridge that advertises DRM_BRIDGE_OP_DETECT bypass the detect_task echo filter?

drm_bridge_connector_init() selects the last bridge in the chain advertising DRM_BRIDGE_OP_DETECT as bridge_detect. When dp->oob_hpd is true and dp->next_bridge sets DRM_BRIDGE_OP_DETECT, drm_bridge_connector_detect_ctx() calls detect on dp->next_bridge instead of dptx_bridge_detect(), and then broadcasts hpd_notify to every bridge in the chain.

Because dp->detect_task is never set, dptx_hpd_notify() treats every connector probe as a new out-of-band hotplug event and queues hpd_event_work and hpd_irq_work. If dp->next_bridge does not also set DRM_BRIDGE_OP_HPD (leaving dp->bridge as bridge_hpd), hpd_event_work triggers drm_bridge_connector_handle_hpd(), which clears dp->notify_task before drm_kms_helper_connector_hotplug_event() reprobes the connector, creating an infinite hotplug and workqueue loop.

[ ... ]

Quoted 7 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +7 -0
+static int dptx_bridge_get_modes(struct drm_bridge *bridge,
+				 struct drm_connector *connector)
+{
+	struct dptx_dev *dp = bridge_to_dp(bridge);
+	const struct drm_edid *edid;
+	struct drm_display_mode *mode;
+	int ret;

drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 115

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10 -0
+
+	scoped_guard(mutex, &dp->lock) {
+		if (dp->released ||
+		    (dp->state & DPTX_STATE_SUSPENDED) ||
+		    !(dp->state & DPTX_STATE_INITIALIZED) ||
+		    !(dp->state & DPTX_STATE_CONNECTED))
+			return 0;
+
+		edid = drm_edid_read(connector);
+	}

[Severity: Low]
Should this early return clear the connector's EDID with drm_edid_connector_update(connector, NULL)?

drm_helper_probe_single_connector_modes() only clears the EDID property when connector->status is connector_status_disconnected. When a connector is forced on (DRM_FORCE_ON) after unplugging a sink, or probed while suspended (connector_status_unknown), returning 0 here skips the later drm_edid_connector_update(connector, NULL) call and leaves stale connector->edid_blob_ptr and connector->display_info from the previous sink while connector->modes is replaced with fallback modes.

Clearing the EDID outside dp->lock on this early-return path would match drm_bridge_connector_get_modes_edid().

[ ... ]

drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 260

Quoted 9 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +9 -0
+static int dptx_cal_bpc(struct drm_connector_state *connector_state,
+			int format, int bpc)
+{
+	int max_bpc = connector_state->max_bpc;
+
+	if (dptx_bt2020_colorspace(connector_state))
+		max_bpc = min(max_bpc, 10);
+
+	bpc = min(bpc, max_bpc);

[Severity: Medium]
Can connector_state->max_bpc be stale here after hotplugging a different sink?

drm_atomic_check_only() runs drm_atomic_connector_check() (which refreshes connector_state->max_bpc from display_info.bpc) only for connectors already in the atomic state before driver atomic_check(). On a CRTC-only modeset (for example changing MODE_ID without modifying connector properties), the connector is added later by drm_atomic_add_affected_connectors() with its previous max_bpc intact.

After swapping a 6-bpc sink for an 8-bpc or 10-bpc sink, a stale max_bpc of 6 causes dptx_cal_bpc() to reject valid YCbCr 4:2:0/4:2:2 modes and clamp RGB to 6 bpc; swapping from 10-bpc to 8-bpc allows 10-bpc YCbCr 4:2:2 to be selected for an 8-bpc sink. Computing max_bpc directly from connector->display_info.bpc (defaulting to 8 when 0) and clamping by connector_state->max_requested_bpc avoids stale values.

[ ... ]

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10 -0
+static bool dptx_format_ok(struct dptx_dev *dp,
+			   const struct drm_display_info *info,
+			   const struct drm_display_mode *mode,
+			   const struct drm_display_mode *adjusted_mode,
+			   int info_formats, int format)
+{
+	if (format == DRM_OUTPUT_COLOR_FORMAT_YCBCR420) {
+		if (!dp->hw->ops->vsc_supported(dp->hw))
+			return false;
+

drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 353

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10 -0
+		/*
+		 * Y420VDB sets the sink-wide 420 bit for every mode. This
+		 * VIC has to be 420-only or 420-also. 420 is one pixel
+		 * per cycle.
+		 */
+		if (!drm_mode_is_420(info, mode))
+			return false;
+
+		return adjusted_mode->clock <= DPTX_MAX_FREQ;
+	}

[Severity: Low]
Does dptx_format_ok() need to check conn_state->connector->ycbcr_420_allowed before allowing YCbCr 4:2:0?

drm_bridge_connector_init() clears connector->ycbcr_420_allowed when any bridge in the encoder's chain (such as a downstream bridge attached at dp->next_bridge) does not support YCbCr 4:2:0. Because dptx_format_ok() does not check connector->ycbcr_420_allowed, a 420-also mode whose clock exceeds RGB/4:2:2 link bandwidth can still be accepted and programmed as DP_PIXELFORMAT_YUV420, producing broken or blank output.

[ ... ]

Quoted 38 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +38 -0
+static int dptx_bridge_mode_set(struct dptx_dev *dp,
+				struct drm_crtc_state *crtc_state,
+				struct drm_connector_state *conn_state)
+{
+	struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
+	int color_format;
+	int link_rate;
+	int bw_code;
+	int bpc;
+	int bpp;
+	int ret;
+
+	ret = dp->ops->detect(dp);
+	if (ret)
+		return ret;
+
+	guard(mutex)(&dp->lock);
+
+	ret = dptx_pick_config(dp, conn_state, &crtc_state->mode,
+			       adjusted_mode, &color_format, &bpc, &bpp);
+	if (ret)
+		return ret;
+
+	dp->config.format = dptx_drm_format_to_dp(color_format);
+	dp->config.colorspace = conn_state->colorspace;
+	dp->config.content_type = conn_state->content_type;
+	dp->config.bpc = bpc;
+	dp->config.bpp = bpp;
+	drm_mode_copy(&dp->adjusted_mode, adjusted_mode);
+	dp->pixel_per_cycle = dptx_pick_ppc(adjusted_mode, dp->config.format);
+
+	link_rate = dptx_pick_link_rate(dp, adjusted_mode, bpp);
+	bw_code = drm_dp_link_rate_to_bw_code(link_rate);
+
+	ret = dp->ops->mode_configure(dp, adjusted_mode->clock, bw_code,
+				      bpp, false);
+	if (ret)
+		return ret;

drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 546

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10 -0
+
+	dev_dbg(dp->dev,
+		"%dx%d@%d fmt=%d bpc=%d bpp=%d link=%u lanes=%u ppc=%u\n",
+		adjusted_mode->hdisplay, adjusted_mode->vdisplay,
+		drm_mode_vrefresh(adjusted_mode), dp->config.format,
+		bpc, bpp, bw_code, dp->mode.lane_cnt,
+		dp->pixel_per_cycle);
+
+	return 0;
+}

[Severity: Medium]
Can concurrent platform device removal free dp->dev before dev_dbg(dp->dev, ...) runs?

struct dptx_dev stores dp->dev without taking a get_device() reference, and dptx_bridge_mode_set() does not re-check dp->released after reacquiring dp->lock:

CPU0 CPU1
dptx_bridge_mode_set()
dp->ops->detect(dp)

    /* drops dp->lock */
                                  platform_device_unregister()
                                    dptx_deinit()
                                      dp->released = true
                                    device_del(dp->dev)
                                    put_device(dp->dev)  /* freed */

guard(mutex)(&dp->lock)
...
dev_dbg(dp->dev, ...) <-- use-after-free

Checking dp->released right after acquiring dp->lock (or pinning dp->dev with get_device()/put_device() for the lifetime of the bridge) would close this window.

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10 -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);
+	int bpc;
+	int bpp;
+	int ret;

drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 566

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +10 -0
+	bool vsc_supported;
+
+	if (!conn_state->crtc)
+		return 0;
+
+	if (!crtc_state->active)
+		return 0;
+
+	if (!dptx_adjust_mode(&crtc_state->mode, &crtc_state->adjusted_mode))
+		return -EINVAL;

[Severity: Medium]
Returning early on !crtc_state->active looks like it violates the DRM atomic DPMS contract -- shouldn't this gate on crtc_state->enable instead?

include/drm/drm_crtc.h specifies that drivers must not consult crtc_state->active in atomic_check to reject commits, because DPMS ON on an already-enabled CRTC is expected to succeed. When userspace commits a modeset with enable=true and active=false, returning early here skips dptx_adjust_mode() and dptx_pick_config(), so mode_fixup() in drm_atomic_helper.c runs the CRTC's mode_fixup() on the unadjusted timings.

On the subsequent DPMS ON commit (active=true, mode_changed=false), dptx_bridge_atomic_check() then runs and can reject DPMS ON with -EINVAL (for an unsupported mode or after a sink swap during DPMS OFF), or mutate adjusted_mode->htotal/clock/flags while the CRTC's mode_fixup() is skipped, leaving CRTC and DPTX programmed with mismatched timings. Adjusting and validating when crtc_state->enable is true (and gating link revalidation on mode_changed || connectors_changed) avoids both problems.

[ ... ]

drivers/gpu/drm/bridge/trilinear/dptx_drm.c line 708

Quoted 6 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +6 -0
+static void dptx_bridge_hpd_enable(struct drm_bridge *bridge)
+{
+	struct dptx_dev *dp = bridge_to_dp(bridge);
+
+	dp->ops->replay_deferred_hotplug(dp);
+}

[Severity: High]
Will dptx_bridge_hpd_enable() ever be called when a downstream bridge advertises DRM_BRIDGE_OP_HPD?

When dp->next_bridge is a USB-C HPD bridge such as drm_aux_hpd_bridge (which sets DRM_BRIDGE_OP_HPD with no .hpd_enable hook), drm_bridge_connector_init() overwrites bridge_connector->bridge_hpd with dp->next_bridge because it sits later in encoder->bridge_chain. drm_bridge_connector_enable_hpd() then only calls drm_bridge_hpd_enable() on bridge_connector->bridge_hpd, so dptx_bridge_hpd_enable() never runs at boot.

With dp->oob_hpd set, any early HPD notification before connector HPD is enabled is dropped while the controller's own HPD pin is unwired, leaving an already-connected USB-C DisplayPort sink reported as disconnected until it is unplugged and replugged.

Quoted 12 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +12 -0
+
+static void dptx_bridge_detach(struct drm_bridge *bridge)
+{
+	struct dptx_dev *dp = bridge_to_dp(bridge);
+	struct device *consumer;
+
+	/* 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 730

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);
+
+		consumer = dp->link_consumer;
+		dp->link_consumer = NULL;
+	}
+
+	if (consumer)
+		device_link_remove(consumer, dp->dev);
+}

[Severity: Medium]
Can device_link_remove(consumer, dp->dev) dereference a freed dp->dev once dp->lock is dropped?

dp->link_consumer is cleared unconditionally without checking !dp->released, and struct dptx_dev holds no get_device() reference on dp->dev:

CPU0 CPU1
dptx_bridge_detach()
lock(&dp->lock)
consumer = dp->link_consumer
dp->link_consumer = NULL
unlock(&dp->lock)

                                  platform_device_unregister()
                                    dptx_deinit()
                                      /* dp->link_consumer is NULL */
                                    device_del(dp->dev)
                                      device_links_purge(dp->dev)
                                    put_device(dp->dev)  /* freed */
  device_link_remove(consumer,
                     dp->dev)  <-- use-after-free

Guarding the link removal with !dp->released while holding dp->lock (matching device_link_add() in dptx_bridge_attach()), or taking a get_device()/put_device() reference on dp->dev, would prevent this use-after-free.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
author
#6 lore raw

PATCH v10 4/5 drm/bridge: trilinear: add the DPTX core and build glue

In reply to Luo Liu

Add 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.

A port@1 with a remote endpoint points at a converter bridge in front of the connector, so the probe resolves it for the bridge to chain; a port@1 without one feeds the native DP PHY directly.

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 | 1077 ++++++++++++++++++
 include/drm/bridge/trilinear_dp.h            |   10 +
 6 files changed, 1103 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
index c7da6b02d7b6..d328d5f84dc7 100644
@@ -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
index 15cc821d85b7..9fe6bec55c51 100644
@@ -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
new file mode 100644
index 000000000000..7e2bf1f27035
@@ -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
new file mode 100644
index 000000000000..415842b8465d
@@ -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 +1077 -0

1,077 lines not on this page · raw message

include/drm/bridge/trilinear_dp.h +10 -0
index c65ebd103f47..06e5458f04ae 100644
@@ -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
#7 lore raw

Re: [PATCH v10 4/5] drm/bridge: trilinear: add the DPTX core and build glue

Thank you for your contribution! Sashiko AI review found 7 potential issues to consider: - [High] drm/bridge: trilinear: dptx_hw_link_vs_emph() returns byte count as error - [Medium] drm/bridge…

Thank you for your contribution! Sashiko AI review found 7 potential issues to consider:
- [High] drm/bridge: trilinear: dptx_hw_link_vs_emph() returns byte count as error
- [Medium] drm/bridge: trilinear: UAF on dp->dev calling device_link_remove() unlocked
- [Medium] drm/bridge: trilinear: dptx_deinit() lets detach skip aux_unregister()
- [Medium] drm/bridge: trilinear: UAF of dp->dev in dptx_bridge_mode_set()
- [Medium] drm/bridge: trilinear: port@1 chaining breaks OOB HPD replay and notify
- [Low] drm/bridge: trilinear: dptx_init() leaks IRQ_DISABLE_UNLAZY on error
- [Low] drm/bridge: trilinear: redundant OF lookup and __free() style in probe
--

commit 73b96bebc6d815be1eb22b178ab9b6dfb9d2585a
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, PM callbacks, hotplug workers, and stream/link state machine), exports trilinear_dptx_remove(), and hooks the driver into the DRM bridge Kconfig and Makefile.

Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +0 -0
new file mode 100644
index 0000000000000..5ca90acfb981f

[ ... ]

Quoted 2 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +2 -0
+static int dptx_train_loop(struct dptx_dev *dp)
+{

[ ... ]

drivers/gpu/drm/bridge/trilinear/dptx_core.c line 290

Quoted 13 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +13 -0
+			ret = dp->hw->ops->link_train(dp->hw, dp->phy,
+						      mode->bw_code,
+						      mode->lane_cnt);
+			if (!ret) {
+				if (dp->active_stream_cnt &&
+				    (mode->bw_code != prev_bw ||
+				     mode->lane_cnt != prev_lanes))
+					dptx_active_streams(dp);
+				return 0;
+			}
+
+			if (ret != -EIO)
+				goto err_restore;

[Severity: High]
Will link training always fail here when the first DPCD write succeeds?

In drivers/gpu/drm/bridge/trilinear/dptx_hw.c, dptx_hw_link_vs_emph() returns the result of drm_dp_dpcd_write() directly, which is the positive byte count (lane_cnt) on success rather than 0:

drivers/gpu/drm/bridge/trilinear/dptx_hw.c:dptx_hw_link_vs_emph() {
	...
	return drm_dp_dpcd_write(&hw->aux, DP_TRAINING_LANE0_SET,
				 hw->train_setting, lane_cnt);
}

Both dptx_hw_link_clock_recovery() and dptx_hw_link_channel_equalization() treat any non-zero return as an error (if (ret) return ret;), so positive lane_cnt propagates back to dptx_train_loop(), hits the ret != -EIO branch, and causes dptx_core_on() to power down the link on every enable.

Using drm_dp_dpcd_write_data() in dptx_hw_link_vs_emph() (or normalizing a non-negative return to 0) would fix this.

[ ... ]

Quoted 2 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +2 -0
+static int dptx_init(struct dptx_dev *dp)
+{

[ ... ]

Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +5 -0
+	irq_set_status_flags(dp->irq, IRQ_DISABLE_UNLAZY);
+	ret = devm_request_threaded_irq(dp->dev, dp->irq, NULL,
+					dptx_irq_handler, IRQF_ONESHOT,
+				       dev_name(dp->dev), dp);
+	if (ret < 0)

drivers/gpu/drm/bridge/trilinear/dptx_core.c line 892

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +10 -0
+		goto err_deinit;
+
+	return 0;
+
+err_deinit:
+	dptx_host_deinit(dp);
+err_configured:
+	dp->state &= ~DPTX_STATE_CONFIGURED;
+	return ret;
+}

[Severity: Low]
Does the err_deinit path leave IRQ_DISABLE_UNLAZY set on dp->irq if devm_request_threaded_irq() fails?

__free_irq() only clears IRQ_DISABLE_UNLAZY when freeing a registered action, so a failed request leaks the flag on the IRQ descriptor. Setting IRQ_DISABLE_UNLAZY after devm_request_threaded_irq() succeeds (or clearing it on err_deinit) avoids that.

drivers/gpu/drm/bridge/trilinear/dptx_core.c line 905

Quoted 13 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +13 -0
+
+static void dptx_deinit(struct dptx_dev *dp)
+{
+	struct device *consumer = NULL;
+
+	scoped_guard(mutex, &dp->lock) {
+		if (!(dp->state & DPTX_STATE_CONFIGURED))
+			return;
+
+		WRITE_ONCE(dp->hpd_stopped, true);
+		dp->released = true;
+		dptx_irq_off(dp);
+	}

[Severity: Medium]
Can dptx_bridge_mode_set() hit a use-after-free on dp->dev if platform removal runs between dp->ops->detect() and acquiring dp->lock?

Because dp->dev is not refcounted and the DL_FLAG_STATELESS device link does not unbind the display controller when the DPTX device is removed, trilinear_dptx_remove() can run concurrently with a modeset:

CPU0 CPU1
dptx_bridge_mode_set()
dp->ops->detect(dp)

    mutex_lock(&dp->lock)
    ...
    mutex_unlock(&dp->lock)
                                  trilinear_dptx_remove()
                                    dptx_deinit()
                                      dp->released = true
                                    device_del(dp->dev)
                                    put_device(dp->dev)  (freed)

mutex_lock(&dp->lock)
...
dev_dbg(dp->dev, ...) <-- use-after-free

dptx_bridge_mode_set() in dptx_drm.c does not recheck dp->released after acquiring dp->lock before calling dev_dbg(dp->dev, ...). Rechecking dp->released under dp->lock (or logging with drm_dbg_kms(dp->bridge.dev, ...)) avoids dereferencing a freed dp->dev.

drivers/gpu/drm/bridge/trilinear/dptx_core.c line 912

Quoted 7 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +7 -0
+
+	dptx_cancel_hpd_works(dp);
+
+	scoped_guard(mutex, &dp->lock) {
+		dptx_stop_streams(dp);
+		dptx_host_deinit(dp);
+		dp->hw->ops->aux_unregister(dp->hw);

[Severity: Medium]
Can setting dp->released before dptx_cancel_hpd_works() cause dptx_bridge_detach() to skip aux_unregister() and leave aux->drm_dev dangling?

In dptx_drm.c, dptx_bridge_detach() only calls aux_unregister() when !dp->released:

CPU0 CPU1
dptx_deinit()
mutex_lock(&dp->lock)
dp->released = true
mutex_unlock(&dp->lock)
dptx_cancel_hpd_works()

                                  dptx_bridge_detach()
                                    mutex_lock(&dp->lock)
                                    /* dp->released is true: skips
                                       aux_unregister() */
                                    mutex_unlock(&dp->lock)
                                  drm_dev_release(bridge->dev)  (freed)
  mutex_lock(&dp->lock)
  dptx_host_deinit()
    dptx_hw_dpcd_power_down()
      drm_dp_dpcd_readb(&hw->aux)  <-- use-after-free

aux_unregister(dp->hw)

While /dev/drm_dp_auxN and the I2C adapter stay registered, both dptx_hw_dpcd_power_down() (via drm_dp_dump_access() -> drm_dbg_dp()) and concurrent userspace AUX transfers can dereference the freed struct drm_device. Since dptx_hw_aux_unregister() is idempotent, dptx_bridge_detach() can unregister AUX unconditionally under dp->lock, and dptx_deinit() should avoid DPCD transfers with a stale aux->drm_dev.

drivers/gpu/drm/bridge/trilinear/dptx_core.c line 920

Quoted 8 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +8 -0
+		dp->state &= ~(DPTX_STATE_CONFIGURED);
+		consumer = dp->link_consumer;
+		dp->link_consumer = NULL;
+	}
+
+	if (consumer)
+		device_link_remove(consumer, dp->dev);
+}

[Severity: Medium]
Can calling device_link_remove() outside dp->lock race with platform device removal and cause a use-after-free on dp->dev?

Both dptx_deinit() and dptx_bridge_detach() clear dp->link_consumer under dp->lock and drop the lock before calling device_link_remove(). Because the link is DL_FLAG_STATELESS, supplier removal does not unbind the consumer first:

CPU0 CPU1
dptx_bridge_detach()
mutex_lock(&dp->lock)
consumer = dp->link_consumer
dp->link_consumer = NULL
mutex_unlock(&dp->lock)

                                  trilinear_dptx_remove()
                                    dptx_deinit()
                                      /* sees link_consumer == NULL */
                                    device_del(dp->dev)
                                    put_device(dp->dev)  (freed)
  device_link_remove(consumer, dp->dev)
    list_for_each_entry(..., &dp->dev->links.consumers, ...)
      <-- use-after-free

Calling device_link_remove() while holding dp->lock in both dptx_bridge_detach() and dptx_deinit() (matching device_link_add() in dptx_bridge_attach()) serializes link removal against supplier teardown.

[ ... ]

drivers/gpu/drm/bridge/trilinear/dptx_core.c line 958

Quoted 5 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +5 -0
+struct dptx_dev *trilinear_dptx_probe(struct device *dev,
+				      const struct dptx_plat_data *soc_data,
+				      void *priv)
+{
+	struct device_node *remote __free(device_node) = NULL;

[Severity: Low]
This isn't a bug, but remote is declared with __free(device_node) = NULL at the top of the function and assigned much later, whereas the cleanup API convention is to initialize __free() variables at acquisition.

In addition, of_drm_get_bridge_by_endpoint() already calls of_graph_get_remote_node() internally and returns ERR_PTR(-ENODEV) when no remote endpoint is present, so calling of_drm_get_bridge_by_endpoint() directly and ignoring -ENODEV drops both the redundant OF lookup and the remote variable.

[ ... ]

drivers/gpu/drm/bridge/trilinear/dptx_core.c line 1022

Quoted 11 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +11 -0
+	remote = of_graph_get_remote_node(dev->of_node, 1, 0);
+	if (remote) {
+		dp->next_bridge = of_drm_get_bridge_by_endpoint(dev->of_node,
+								1, 0);
+		if (IS_ERR(dp->next_bridge)) {
+			ret = PTR_ERR(dp->next_bridge);
+			dp->next_bridge = NULL;
+			dptx_deinit(dp);
+			return ERR_PTR(ret);
+		}
+	}

[Severity: Medium]
Does chaining a downstream bridge on port@1 break out-of-band HPD replay and notifications on USB-C DisplayPort?

In upstream USB-C DP Alt Mode topologies, the chain ends at a drm_aux_hpd_bridge (which sets DRM_BRIDGE_OP_HPD), and a dp-connector with hpd-gpios also sets DRM_BRIDGE_OP_HPD. drm_bridge_connector_init() picks the last bridge with DRM_BRIDGE_OP_HPD as bridge_connector->bridge_hpd, so drm_bridge_connector_enable_hpd() never calls dptx_bridge_hpd_enable() on &dp->bridge and dp->bridge.hpd_cb stays NULL.

As a result, boot-time dptx_replay_deferred_hotplug() never runs for an already-plugged USB-C sink, and dptx_notify_hpd() becomes a silent no-op, dropping notifications from delayed PHY DP-mode polling and system resume in dptx_pm_complete(). Conversely, wiring port@1 directly to a USB-C combo PHY that does not register a struct drm_bridge (as documented in cix,sky1-dp.yaml) makes of_drm_get_bridge_by_endpoint() return -EPROBE_DEFER indefinitely.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
author
#8 lore raw

PATCH v10 5/5 drm/cix: add the Sky1 DisplayPort platform glue

In reply to Luo Liu

Add 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 | 181 ++++++++++++++++++++++++++++
 8 files changed, 209 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
index 6ebb17dd18e9..b63870a11a5b 100644
@@ -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/
 F:	include/drm/bridge/trilinear_dp.h
 
 CLANG CONTEXT ANALYSIS
drivers/gpu/drm/Kconfig +1 -0
index 61111d50b1c6..a1808db8b9c8 100644
@@ -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
index 2c6bc093a923..6ed7456bb993 100644
@@ -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
new file mode 100644
index 000000000000..6cbaa5bf9fe9
@@ -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
new file mode 100644
index 000000000000..2cc5cba67848
@@ -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
new file mode 100644
index 000000000000..f5d3afe5699f
@@ -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
new file mode 100644
index 000000000000..64226bbd7c49
@@ -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 +181 -0

181 lines not on this page · raw message

Signature · 1 line
2.25.1
#9 lore raw

Re: [PATCH v10 5/5] drm/cix: add the Sky1 DisplayPort platform glue

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] drm/bridge: trilinear: unlocked device_link_remove() UAF on dp->dev - [Medium] drm/bridge…

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] drm/bridge: trilinear: unlocked device_link_remove() UAF on dp->dev
- [Medium] drm/bridge: trilinear: missing dp->released check in dptx_bridge_mode_set()
- [Low] drm/cix: bridge glue placed in top-level drm/cix/ instead of drm/bridge/
--

commit 1e4145188b36c3532088673583ce49d4b100b5b9
Author: Luo Liu <[email protected]>

drm/cix: add the Sky1 DisplayPort platform glue

This commit adds the Cix Sky1 platform glue driver that maps the RCSU video adapter registers and binds the shared Trilinear DisplayPort bridge driver.

[ ... ]

Quoted 17 lines
drivers/gpu/drm/Kconfig +1 -0
index 61111d50b1c65..a1808db8b9c8a 100644
@@ -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 +0 -0
index 2c6bc093a923a..6ed7456bb993a 100644

drivers/gpu/drm/Makefile obj-y += tests/ · line 175

Quoted 7 lines
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/

[Severity: Low]
Should this bridge platform glue live under drivers/gpu/drm/bridge/ (or drivers/gpu/drm/bridge/trilinear/) rather than a new top-level drivers/gpu/drm/cix/ directory?

drivers/gpu/drm/cix/ contains no drm_driver, only a single 181-line wrapper for the Trilinear bridge driver. Putting it at the top level exposes DRM_CIX_DP outside the Display Interface Bridges menu and adds four extra Kconfig/Makefile files, whereas comparable SoC bridge wrappers such as drivers/gpu/drm/bridge/th1520-dw-hdmi.c and drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-j721e.c sit under drivers/gpu/drm/bridge/.

[ ... ]

Quoted 5 lines
drivers/gpu/drm/cix/dptx/cix_dptx.c new file +0 -0
new file mode 100644
index 0000000000000..e25b3b365d7b8

[ ... ]

drivers/gpu/drm/cix/dptx/cix_dptx.c line 127

Quoted 4 lines
drivers/gpu/drm/cix/dptx/cix_dptx.c new file +4 -0
+static void cix_dptx_remove(struct platform_device *pdev)
+{
+	trilinear_dptx_remove(platform_get_drvdata(pdev));
+}

[Severity: Medium]
Can cix_dptx_remove() allow dp->dev to be freed while dptx_bridge_detach() is still about to pass it to device_link_remove()?

CPU0 (bridge detach) CPU1 (platform device delete)
dptx_bridge_detach()
lock(&dp->lock)
consumer = dp->link_consumer
dp->link_consumer = NULL
unlock(&dp->lock)

                                  device_unregister(dp->dev)
                                    device_del(dp->dev)
                                      cix_dptx_remove()
                                        dptx_deinit()
                                          lock(&dp->lock)
                                          /* link_consumer == NULL */
                                          unlock(&dp->lock)
                                      device_links_purge(dp->dev)
                                    put_device(dp->dev) /* freed */
  device_link_remove(consumer,
                     dp->dev)  <-- use-after-free

trilinear_dptx_probe() stores dp->dev without taking a device reference, and dptx_bridge_attach() adds a DL_FLAG_STATELESS link, so removing the supplier device does not unbind the consumer first. Because dptx_bridge_detach() clears dp->link_consumer and drops dp->lock before calling device_link_remove(), dptx_deinit() returns immediately and device_del() purges the link and frees dp->dev before device_link_remove() walks supplier->links.consumers.

Calling device_link_remove() while still holding dp->lock in dptx_bridge_detach() (matching the dp->lock -> device_links_write_lock ordering already used in dptx_bridge_attach()) would serialize link removal with dptx_deinit().

[Severity: Medium]
Can dptx_bridge_mode_set() dereference a freed dp->dev if cix_dptx_remove() runs between dp->ops->detect() and reacquiring dp->lock?

CPU0 (modeset) CPU1 (platform device delete)
dptx_bridge_mode_set()
dp->ops->detect(dp)

    /* locks, checks released,
       unlocks */
                                  device_unregister(dp->dev)
                                    cix_dptx_remove()
                                      dptx_deinit()
                                        dp->released = true
                                        device_link_remove(...)
                                    put_device(dp->dev) /* freed */

guard(mutex)(&dp->lock)
/* no dp->released check */
dev_dbg(dp->dev, ...) <-- use-after-free

dptx_bridge_mode_set() releases dp->lock when dp->ops->detect() returns and does not re-check dp->released after reacquiring it. Because dp->bridge keeps dp alive after dp->dev is freed, dptx_bridge_mode_set() mutates state on a released bridge and dereferences freed dp->dev in dev_dbg() when dynamic debug is enabled.

Checking dp->released and returning -ENODEV immediately after acquiring dp->lock in dptx_bridge_mode_set() would close this window.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
author
#10 lore raw

回复: [PATCH v10 5/5] drm/cix: add the Sky1 DisplayPort platform glue

Quoted 62 lines

-----邮件原件-----
发件人: [email protected] <[email protected]>
发送时间: 2026年12月4日 20:02
收件人: Luo Liu <[email protected]>
抄送: [email protected]; [email protected]; [email protected]; [email protected]
主题: Re: [PATCH v10 5/5] drm/cix: add the Sky1 DisplayPort platform glue

EXTERNAL EMAIL

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] drm/bridge: trilinear: unlocked device_link_remove() UAF on dp->dev
- [Medium] drm/bridge: trilinear: missing dp->released check in dptx_bridge_mode_set()
- [Low] drm/cix: bridge glue placed in top-level drm/cix/ instead of drm/bridge/
--

commit 1e4145188b36c3532088673583ce49d4b100b5b9
Author: Luo Liu <[email protected]>

drm/cix: add the Sky1 DisplayPort platform glue

This commit adds the Cix Sky1 platform glue driver that maps the RCSU video adapter registers and binds the shared Trilinear DisplayPort bridge driver.

[ ... ]

Quoted 17 lines
drivers/gpu/drm/Kconfig index renamed from drivers/gpu/drm/Kconfig +0 -0

61111d50b1c65..a1808db8b9c8a 100644

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 index renamed from drivers/gpu/drm/Makefile +0 -0

2c6bc093a923a..6ed7456bb993a 100644

drivers/gpu/drm/Makefile obj-y += tests/ · line 175

Quoted 7 lines
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/

[Severity: Low]
Should this bridge platform glue live under drivers/gpu/drm/bridge/ (or drivers/gpu/drm/bridge/trilinear/) rather than a new top-level drivers/gpu/drm/cix/ directory?

Quoted 7 lines

drivers/gpu/drm/cix/ contains no drm_driver, only a single 181-line wrapper for the Trilinear bridge driver. Putting it at the top level exposes DRM_CIX_DP outside the Display Interface Bridges menu and adds four extra Kconfig/Makefile files, whereas comparable SoC bridge wrappers such as drivers/gpu/drm/bridge/th1520-dw-hdmi.c and drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-j721e.c sit under drivers/gpu/drm/bridge/.

The CIX directory is intentional. It is not a wrapper around the Trilinear bridge: it implements the CIX-specific side, namely the RCSU video-adapter format and pixel-per-cycle programming, and it supplies the per-compatible platform data (USB-C versus native DP, out-of-band HPD, link limits) that the shared code in drivers/gpu/drm/bridge/ trilinear/ must not know about.

That code will keep growing as more CIX SoCs and output variants (eDP, HDMI through a converter) are supported, each with its own register layout and quirks. Keeping it in a private vendor directory keeps the Trilinear code SoC-agnostic and gives the CIX code a stable home instead of moving it later. If the Kconfig menu placement is the concern rather than the directory, I can source the CIX Kconfig from the bridge menu.

Quoted 84 lines

[ ... ]

Quoted 6 lines
drivers/gpu/drm/cix/dptx/cix_dptx.c new file +0 -0
new file mode 100644
index 0000000000000..e25b3b365d7b8

[ ... ]

drivers/gpu/drm/cix/dptx/cix_dptx.c line 127

Quoted 3 lines
drivers/gpu/drm/cix/dptx/cix_dptx.c new file +3 -0
+static void cix_dptx_remove(struct platform_device *pdev) {
+     trilinear_dptx_remove(platform_get_drvdata(pdev));
+}

[Severity: Medium]
Can cix_dptx_remove() allow dp->dev to be freed while dptx_bridge_detach() is still about to pass it to device_link_remove()?

CPU0 (bridge detach) CPU1 (platform device delete)
dptx_bridge_detach()
lock(&dp->lock)
consumer = dp->link_consumer
dp->link_consumer = NULL
unlock(&dp->lock)

                                  device_unregister(dp->dev)
                                    device_del(dp->dev)
                                      cix_dptx_remove()
                                        dptx_deinit()
                                          lock(&dp->lock)
                                          /* link_consumer == NULL
*/
                                          unlock(&dp->lock)
                                      device_links_purge(dp->dev)
                                    put_device(dp->dev) /* freed */
  device_link_remove(consumer,
                     dp->dev)  <-- use-after-free

trilinear_dptx_probe() stores dp->dev without taking a device reference, and dptx_bridge_attach() adds a DL_FLAG_STATELESS link, so removing the supplier device does not unbind the consumer first. Because dptx_bridge_detach() clears dp->link_consumer and drops dp->lock before calling device_link_remove(), dptx_deinit() returns immediately and device_del() purges the link and frees dp->dev before device_link_remove() walks supplier->links.consumers.

Calling device_link_remove() while still holding dp->lock in dptx_bridge_detach() (matching the dp->lock -> device_links_write_lock ordering already used in dptx_bridge_attach()) would serialize link removal with dptx_deinit().

[Severity: Medium]
Can dptx_bridge_mode_set() dereference a freed dp->dev if cix_dptx_remove() runs between dp->ops->detect() and reacquiring dp->lock?

CPU0 (modeset) CPU1 (platform device delete)
dptx_bridge_mode_set()
dp->ops->detect(dp)

    /* locks, checks released,
       unlocks */
                                  device_unregister(dp->dev)
                                    cix_dptx_remove()
                                      dptx_deinit()
                                        dp->released = true
                                        device_link_remove(...)
                                    put_device(dp->dev) /* freed */

guard(mutex)(&dp->lock)
/* no dp->released check */
dev_dbg(dp->dev, ...) <-- use-after-free

dptx_bridge_mode_set() releases dp->lock when dp->ops->detect() returns and does not re-check dp->released after reacquiring it. Because dp->bridge keeps dp alive after dp->dev is freed, dptx_bridge_mode_set() mutates state on a released bridge and dereferences freed dp->dev in dev_dbg() when dynamic debug is enabled.

Checking dp->released and returning -ENODEV immediately after acquiring dp->lock in dptx_bridge_mode_set() would close this window.

--
Sashiko AI
review · https://sashiko.dev/#/patchset/20261204114332.280808-1-Luo.Liu@c
ixtech.com?part=5