Skip to contentSkip to conversation

drm/bridge: trilinear: add the Sky1 DisplayPort transmitter

PATCH New Luo Liu 2 participants 9 messages Nov 27

Subsystems (4)
lore
Share & tools
lore

Luo Liu

author
#0 lore raw

v7 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 v7:
- The link-rate downshift thresholds are compared against the real link rates, so a 1.62 or 2.7 Gbps link is not raised to 5.4 Gbps when training fails.
- The bridge adds a device link to the controller, so the transmitter resumes before the controller's resume commit and suspends after its disable commit. An atomic enable that arrives while the transmitter is suspended is refused instead of re-initializing the host behind the system sleep callbacks.
- The device link is created only while the transmitter is alive and is dropped from the platform remove callback, before the device is deleted, since device links cannot be released after device removal.
- Every patch updates MAINTAINERS for the files it adds.

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   |  734 +++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_drm.h   |   17 +
 drivers/gpu/drm/bridge/trilinear/dptx_hw.c    | 1380 +++++++++++++++++
 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, 3858 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 v7 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 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
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 v7 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 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.

---
 MAINTAINERS                                |    1 +
 drivers/gpu/drm/bridge/trilinear/dptx_hw.c | 1380 ++++++++++++++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_hw.h |  103 ++
 3 files changed, 1484 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 +1380 -0

1,380 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 v7 2/5] drm/bridge: trilinear: add the DPTX hardware layer

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] drm/bridge: trilinear: dptx_hw_dpcd_power_up/down() duplicate DP helpers --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] drm/bridge: trilinear: dptx_hw_dpcd_power_up/down() duplicate DP helpers
--

commit 4572b1c38c3025ae29ace85b65751b014caf62e2
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 stream configuration.

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

[ ... ]

Quoted 33 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +33 -0
+static int dptx_hw_dpcd_power_up(struct dp_hw *hw,
+				 unsigned int delay_ms)
+{
+	u8 value;
+	int ret;
+
+	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;
+
+	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 857

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]
Could dptx_hw_dpcd_power_up() and dptx_hw_dpcd_power_down() use drm_dp_link_power_up() and drm_dp_link_power_down(&hw->aux, hw->dpcd[DP_DPCD_REV]) instead of open-coding the DP_SET_POWER read-modify-write sequence? Using the helpers also avoids accessing DP_SET_POWER on DPCD v1.0 sinks where that register does not exist.

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

PATCH v7 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.

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 | 734 ++++++++++++++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_drm.h |  17 +
 include/drm/bridge/trilinear_dp.h           |  74 ++
 5 files changed, 939 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 +113 -0

113 lines not on this page · raw message

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

734 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 v7 3/5] drm/bridge: trilinear: add the DPTX DRM bridge

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/bridge: trilinear: htotal and clock overflow in dptx_adjust_mode() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/bridge: trilinear: htotal and clock overflow in dptx_adjust_mode()
--

commit 121beb945da3bca1311595f6221c3e03dd980739
Author: Luo Liu <[email protected]>

drm/bridge: trilinear: add the DPTX DRM bridge

This commit adds the DRM bridge implementation for the Trilinear DisplayPort transmitter, handling connector detection, EDID and downstream mode enumeration, mode validation, and atomic modesetting callbacks.

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

[ ... ]

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

Quoted 12 lines
drivers/gpu/drm/bridge/trilinear/dptx_drm.c new file +12 -0
+static void dptx_adjust_mode(const struct drm_display_mode *mode,
+			     struct drm_display_mode *adjusted_mode)
+{
+	int diff = mode->htotal - mode->hsync_end;
+
+	if (diff < DPTX_MIN_H_BACKPORCH) {
+		adjusted_mode->htotal = mode->htotal +
+					DPTX_MIN_H_BACKPORCH - diff;
+		adjusted_mode->clock =
+			div_u64(mul_u32_u32(mode->clock, adjusted_mode->htotal),
+				mode->htotal);
+	}

[Severity: Medium]
Can adjusted_mode->htotal and adjusted_mode->clock overflow here when a userspace mode has a horizontal backporch smaller than DPTX_MIN_H_BACKPORCH?

Because adjusted_mode->htotal is a u16 and adjusted_mode->clock is a signed int, a custom mode with mode->hsync_end >= 65524 wraps adjusted_mode->htotal to 0..11 and truncates adjusted_mode->clock to 0 (or overflows adjusted_mode->clock past INT_MAX when mode->clock is near INT_MAX).

dptx_bridge_mode_valid() and dptx_bridge_atomic_check() only check the upper bound of adjusted_mode->clock, so the wrapped value passes validation and reaches dptx_bridge_atomic_enable(), where dptx_hw_stream_timing_set() underflows mode->htotal - mode->hdisplay and divides by zero on mode->clock:

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);
    ...
}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
author
#6 lore raw

PATCH v7 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.

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
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 +1061 -0

1,061 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 v7 4/5] drm/bridge: trilinear: add the DPTX core and build glue

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/bridge: trilinear: dptx_deinit() race skips aux_unregister() on detach --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/bridge: trilinear: dptx_deinit() race skips aux_unregister() on detach
--

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

drm/bridge: trilinear: add the DPTX core and build glue

This commit adds the Trilinear DPTX bridge core implementation, including probe, power management, hotplug handling, and stream management, along with Kconfig and Makefile build integration.

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

[ ... ]

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

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

Quoted 10 lines
drivers/gpu/drm/bridge/trilinear/dptx_core.c new file +10 -0
+		dptx_host_deinit(dp);
+		dp->hw->ops->aux_unregister(dp->hw);
+		dp->state &= ~(DPTX_STATE_CONFIGURED);
+		link = dp->link;
+		dp->link = NULL;
+	}
+
+	if (link)
+		device_link_del(link);
+}

[Severity: Medium]
Can dptx_bridge_detach() return while dp->hw->aux is still registered if it races with dptx_deinit()?

drivers/gpu/drm/bridge/trilinear/dptx_drm.c:dptx_bridge_detach() {
	...
	scoped_guard(mutex, &dp->lock) {
		dp->attached = false;

		if (!dp->released)
			dp->hw->ops->aux_unregister(dp->hw);

		link = dp->link;
		dp->link = NULL;
	}
	...
}

Because the device link uses DL_FLAG_STATELESS, the bridge device and the DRM consumer device can tear down concurrently:

CPU0 CPU1
dptx_deinit() dptx_bridge_detach()
lock(&dp->lock)
dp->released = true
unlock(&dp->lock)
dptx_cancel_hpd_works(dp)

                                        dptx_quiesce_hpd(dp)
                                        lock(&dp->lock)
                                        if (!dp->released) /* false */
                                        unlock(&dp->lock)
                                      /* DRM device teardown proceeds
                                         while dp->hw->aux is still
                                         registered with aux.drm_dev */

lock(&dp->lock)
dp->hw->ops->aux_unregister(dp->hw)

Also, dptx_deinit() checks dp->state & DPTX_STATE_CONFIGURED without holding dp->lock, while other paths update dp->state with non-atomic read-modify-write operations under dp->lock.

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

PATCH v7 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 | 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
index 6ebb17dd18e9..70f33f232b5b 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/dptx/
 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 +179 -0

179 lines not on this page · raw message

Signature · 1 line
2.25.1