Skip to contentSkip to conversation

drm/bridge: trilinear: add the Sky1 DisplayPort transmitter

PATCH New Luo Liu 2 participants 8 messages Nov 30

Subsystems (4)
lore
Share & tools
lore

Luo Liu

author
#0 lore raw

v8 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 v8:
- 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.
- A mode whose widened horizontal backporch would no longer fit the mode fields, or whose adjusted pixel clock would overflow, is rejected instead of reaching the hardware with wrapped timings.
- dptx_deinit() reads the configured state under the lock that updates it.

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   |  746 +++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_drm.h   |   17 +
 drivers/gpu/drm/bridge/trilinear/dptx_hw.c    | 1386 +++++++++++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_hw.h    |  103 ++
 drivers/gpu/drm/cix/Kconfig                   |    3 +
 drivers/gpu/drm/cix/Makefile                  |    3 +
 drivers/gpu/drm/cix/dptx/Kconfig              |   15 +
 drivers/gpu/drm/cix/dptx/Makefile             |    4 +
 drivers/gpu/drm/cix/dptx/cix_dptx.c           |  179 +++
 include/drm/bridge/trilinear_dp.h             |   84 +
 20 files changed, 3876 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/cix,sky1-dp.yaml
 create mode 100644 drivers/gpu/drm/bridge/trilinear/Kconfig
 create mode 100644 drivers/gpu/drm/bridge/trilinear/Makefile
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx.h
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_core.c
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_drm.c
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_drm.h
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_hw.c
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_hw.h
 create mode 100644 drivers/gpu/drm/cix/Kconfig
 create mode 100644 drivers/gpu/drm/cix/Makefile
 create mode 100644 drivers/gpu/drm/cix/dptx/Kconfig
 create mode 100644 drivers/gpu/drm/cix/dptx/Makefile
 create mode 100644 drivers/gpu/drm/cix/dptx/cix_dptx.c
 create mode 100644 include/drm/bridge/trilinear_dp.h
Signature · 1 line
2.25.1
author
#1 lore raw

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

DP_SET_POWER is only accessed on sinks whose DPCD revision implements the register, so a v1.0 sink is not sent a request it cannot answer.

---
 MAINTAINERS                                |    1 +
 drivers/gpu/drm/bridge/trilinear/dptx_hw.c | 1386 ++++++++++++++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_hw.h |  103 ++
 3 files changed, 1490 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_hw.c
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_hw.h
MAINTAINERS +1 -0
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 +1386 -0

1,386 lines not on this page · raw message

drivers/gpu/drm/bridge/trilinear/dptx_hw.h new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

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

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/bridge: trilinear: off-by-one retry check in dptx_hw_link_clock_recovery() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/bridge: trilinear: off-by-one retry check in dptx_hw_link_clock_recovery()
--

commit 79d7005f35e737f691dac4559a73f058da476746
Author: Luo Liu <[email protected]>

drm/bridge: trilinear: add the DPTX hardware layer

This commit adds the register, AUX, DPCD, link training, and stream setup hardware 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..df4ba883edbaa

[ ... ]

Quoted 31 lines
drivers/gpu/drm/bridge/trilinear/dptx_hw.c new file +31 -0
+static int dptx_hw_link_clock_recovery(struct dp_hw *hw, struct phy *phy,
+				       u8 lane_cnt)
+{
+	u8 link_status[DP_LINK_STATUS_SIZE];
+	u8 prev[DPTX_MAX_LANES];
+	bool train_done = false;
+	int tries = 0;
+	int i;
+	int ret;
+
+	ret = dptx_hw_link_set_pattern(hw, DP_TRAINING_PATTERN_1);
+	if (ret < 0)
+		return ret;
+
+	memset(prev, 0xff, lane_cnt);
+
+	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;
+
+		if (!memcmp(hw->train_setting, prev, lane_cnt))

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

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

[Severity: Medium]
Should prev be saved and dptx_hw_link_adjust_train() be called before comparing hw->train_setting against prev?

Because memcmp() and the tries check run before dptx_hw_link_adjust_train() updates hw->train_setting from link_status, each iteration compares the setting just transmitted against the previous iteration's setting (starting with 0x00 vs 0xff on the first pass). As a result, the same drive setting is transmitted 6 times instead of DP_MAX_TRAINING_TRIES (5), and when tries reaches DP_MAX_TRAINING_TRIES the loop breaks before parsing the newly read link_status, discarding any new voltage swing or pre-emphasis adjustment the sink requested on that pass and failing clock recovery with -EIO.

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

PATCH v8 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     | 113 +++
 drivers/gpu/drm/bridge/trilinear/dptx_drm.c | 746 ++++++++++++++++++++
 drivers/gpu/drm/bridge/trilinear/dptx_drm.h |  17 +
 include/drm/bridge/trilinear_dp.h           |  74 ++
 5 files changed, 951 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx.h
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_drm.c
 create mode 100644 drivers/gpu/drm/bridge/trilinear/dptx_drm.h
 create mode 100644 include/drm/bridge/trilinear_dp.h
MAINTAINERS +1 -0
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 +746 -0

746 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
author
#5 lore raw

PATCH v8 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
#6 lore raw

Re: [PATCH v8 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 00155c57bf2032aceb755ea1f307b341e22e5c42
Author: Luo Liu <[email protected]>

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

This commit adds the core probe, power management, hotplug handling, and stream state machine for the Trilinear DPTX bridge driver, along with Kconfig and Makefile integration.

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

[ ... ]

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;
+
+	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);
+	}
+
+	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 before dp->hw->aux is unregistered when it races with dptx_deinit()?

dptx_bridge_detach() skips aux_unregister() when dp->released is set:

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);
	...
}

Because dptx_deinit() sets dp->released in the first critical section and drops dp->lock to cancel the HPD workers before calling aux_unregister() in the second critical section, the two teardowns can interleave:

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

                                    lock(&dp->lock)
                                    if (!dp->released) /* false */
                                    unlock(&dp->lock)
                                  /* drm_device teardown proceeds while
                                     aux is still registered */

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

dptx_bridge_detach() then returns to drm_bridge_detach(), allowing DRM device cleanup to free bridge->dev while dp->hw->aux is still registered and dp->hw->aux.drm_dev still points to the DRM device. Moving dp->released = true into the second critical section of dptx_deinit() (where aux_unregister() runs under the same lock acquisition) avoids this window.

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

PATCH v8 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