Add Lontium LT7911EXC eDP to MIPI DSI bridge
Subsystems (4)
v9 cover Add Lontium LT7911EXC eDP to MIPI DSI bridge
From: Sunyun Yang <[email protected]>
The LT7911EXC is an I2C-controlled bridge that receives eDP1.4 and output mipi dsi. This series introduces:
- A device tree binding YAML file describing the hardware
- A new DRM bridge driver implementing the basic functionality
---
Change in v9:
- dt-binding:
- drm/bridge:
1. DSI transfer callback returns success for reads without populating [sashiko-bot]
the receive buffer, leaking uninitialized memory. - fixed it by implementing a strict whitelist mechanism.
2. DSI transfer callback polls for eDP video readiness before the
upstream encoder is enabled, guaranteeing a timeout. - removed
3. The driver attempts I2C transfers while the hardware is held in
physical reset. - fixed
4. Missing DRM_MIPI_DSI Kconfig dependency causes linker errors. - fixed
5. request_firmware is called while holding the hardware lock and
halting the MCU, risking a system pipeline stall. - fixed
6. Sleeping functions are called from atomic context in the DRM bridge callbacks. - fixed
7. lt7911exc_dsi_host_transfer bypasses the required MCU hardware halt sequence. - fixed by internal firmware controls the panel initialization sequence and handles all MIPI DSI command transmission.
- Link to v8: https://lore.kernel.org/lkml/[email protected]/
Change in v8:
- dt-binding:
- drm/bridge:
1. Protect firmware upgrade and DRM bridge callback paths with ocm_lock. [sashiko-bot]
2. Remove the hardware reset from the remove callback, and ensure that all hardware reset operations are protected by ocm_lock.
3. crc reconstruction explicitly casts each byte to u32 before shifting
4. The display configuration is handled by the firmware, and the MIPI DSI host registration issue has been fixed.
5. The batch register read/write operations have already been updated to include return value checking.
6. The dev_err_probe() used outside of probe context has been fixed.
- Link to v7: https://lore.kernel.org/lkml/[email protected]/
Change in v7:
- dt-binding:
1. fix commit message typos(Receiver、signal) [sashiko-bot]
2. remove the ambiguity caused by "signal/dual".
- drm/bridge:
1. using devm_regulator_get_enable avoids power leaks. [sashiko-bot]
2. set reset gpio is low after cutting off power in lt7911exc_remove function, avoid backpowering.
3. synchronous request_firmware() call cause a permanent probe failure if the driver is built-in, probe executes before the root filesystem is mounted, which would cause this to fail with -ENOENT, we have removed this functionality. Use trigger to upgrade.
4. add depends on I2C and select REGMAP_I2C in Kconfig.
5. add return value of devm_drm_bridge_add() in probe().
6. add directly header files (linux/slab.h, linux/delay.h, linux/regulator/consumer.h)
- Link to v6: https://lore.kernel.org/lkml/[email protected]/
Change in v6:
- dt-binding:
- drm/bridge:
1. use #define FW_FILE "Lontium/lt7911exc_fw.bin" to match linux-firmware
- Link to v5: https://lore.kernel.org/lkml/[email protected]/
Change in v5:
- dt-binding:
- drm/bridge:
1. Change "mipi" to "mipi dsi" in the commit message. [Dmitry]
2. Change "eDP/MIPI" to "eDP/MIPI DSI" in Kconfig.
- Link to v4: https://lore.kernel.org/lkml/[email protected]/
Change in v4:
- dt-binding:
1. Fix the missing spaces on the "subject". [Krzysztof]
2. Fix the error descriptions for port@0 and port@1.
- drm/bridge:
- Link to v3: https://lore.kernel.org/lkml/[email protected]/
Change in v3:
- dt-binding:
- drm/bridge:
1. already submit lt7911exc_fw.bin to linux-firmware. [Dmitry]
2. remove lt7911exc_remove function.
3. drop the "lontium, " in lt7911exc_i2c_table.
- Link to v2: https://lore.kernel.org/lkml/[email protected]/
Change in v2:
- dt-binding:
1. reset pins use active low. [Dmitry]
- drm/bridge:
1. use atomic_* callbacks. [Quentin]
2. fix the incorrect formatting and spaces.
3. add the required header files. [Dmitry]
4. remove "enabled" flag.
5. remove *fw from the lt7911exc struct.
6. .max_register and .range_max use actual range.
7. regulator use bulk interface.
8. use dev_err_probe, devm_mutex_init and devm_drm_bridge_add.
9. Replace GPL v2 with GPL.
- Link to v1: https://lore.kernel.org/lkml/[email protected]/
---
Sunyun Yang (2):
dt-bindings: bridge: Add Lontium LT7911EXC eDP to MIPI DSI bridge drm/bridge: Add Lontium LT7911EXC eDP to MIPI DSI bridge
.../display/bridge/lontium,lt7911exc.yaml | 89 +++ drivers/gpu/drm/bridge/Kconfig | 16 + drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/lontium-lt7911exc.c | 657 ++++++++++++++++++ 4 files changed, 763 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/lontium,lt7911exc.yaml create mode 100644 drivers/gpu/drm/bridge/lontium-lt7911exc.c
Signature · 1 line
2.34.1
PATCH v9 1/2 dt-bindings: bridge: Add Lontium LT7911EXC eDP to MIPI DSI bridge
From: Sunyun Yang <[email protected]>
This commit adds the device tree binding schema for the Lontium LT7911EXC. This device is an I2C-controlled bridge that converts eDP 1.4 input to MIPI DSI output.
--- .../display/bridge/lontium,lt7911exc.yaml | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/lontium,lt7911exc.yaml
Documentation/devicetree/bindings/display/bridge/lontium,lt7911exc.yaml new file +89 -0
@@ -0,0 +1,89 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/bridge/lontium,lt7911exc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Lontium LT7911EXC eDP to MIPI DSI Bridge + +maintainers: + - Sunyun Yang <[email protected]> + +properties: + compatible: + enum: + - lontium,lt7911exc + + reg: + maxItems: 1 + + reset-gpios: + maxItems: 1 + description: GPIO connected to RST_ pin. + + vdd-supply: + description: Regulator for 1.2V MIPI phy power. + + vcc-supply: + description: Regulator for 3.3V IO power. + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Video port for eDP input. + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Video port for MIPI DSI output. + + required: + - port@0 + - port@1 + +required: + - compatible + - reg + - reset-gpios + - vdd-supply + - vcc-supply + - ports + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + mipi-bridge@41 { + compatible = "lontium,lt7911exc"; + reg = <0x41>; + reset-gpios = <&gpy8 8 GPIO_ACTIVE_LOW>; + vdd-supply = <<7911exc_1v2>; + vcc-supply = <<7911exc_3v3>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + bridge_in: endpoint { + remote-endpoint = <&edp_out>; + }; + }; + + port@1 { + reg = <1>; + bridge_out: endpoint { + remote-endpoint = <&panel_in>; + }; + }; + }; + }; + };
Signature · 1 line
2.34.1
PATCH v9 2/2 drm/bridge: Add Lontium LT7911EXC eDP to MIPI DSI bridge
In reply to [email protected]From: Sunyun Yang <[email protected]>
Add support for the Lontium LT7911EXC bridge chip, which converts eDP input to MIPI DSI output using an internal firmware-controlled pipeline.
The driver provides:
- DRM bridge integration for eDP-to-DSI routing
- MIPI DSI host interface for downstream panel attachment
- Firmware upgrade mechanism over I2C (erase/program/verify)
- GPIO-based reset and regulator management
Display timing and DSI packet generation are handled by the chip firmware and are not configured by the driver.
--- drivers/gpu/drm/bridge/Kconfig | 16 + drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/lontium-lt7911exc.c | 657 +++++++++++++++++++++ 3 files changed, 674 insertions(+) create mode 100644 drivers/gpu/drm/bridge/lontium-lt7911exc.c
drivers/gpu/drm/bridge/Kconfig +16 -0
@@ -132,6 +132,22 @@ config DRM_ITE_IT6505 help ITE IT6505 DisplayPort bridge chip driver. +config DRM_LONTIUM_LT7911EXC + tristate "Lontium eDP/MIPI DSI bridge" + depends on OF + depends on I2C + select CRC32 + select DRM_PANEL + select DRM_MIPI_DSI + select DRM_KMS_HELPER + select FW_LOADER + select REGMAP_I2C + help + DRM driver for the Lontium LT7911EXC bridge + chip.The LT7911EXC converts eDP input to MIPI + DSI output. + Please say Y if you have such hardware. + config DRM_LONTIUM_LT8912B tristate "Lontium LT8912B DSI/HDMI bridge" depends on OF
drivers/gpu/drm/bridge/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_DRM_I2C_NXP_TDA998X) += tda998x.o obj-$(CONFIG_DRM_INNO_HDMI) += inno-hdmi.o obj-$(CONFIG_DRM_ITE_IT6263) += ite-it6263.o obj-$(CONFIG_DRM_ITE_IT6505) += ite-it6505.o +obj-$(CONFIG_DRM_LONTIUM_LT7911EXC) += lontium-lt7911exc.o obj-$(CONFIG_DRM_LONTIUM_LT8912B) += lontium-lt8912b.o obj-$(CONFIG_DRM_LONTIUM_LT9211) += lontium-lt9211.o obj-$(CONFIG_DRM_LONTIUM_LT9611) += lontium-lt9611.o
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +657 -0
657 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v9 2/2] drm/bridge: Add Lontium LT7911EXC eDP to MIPI DSI bridge
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [High] State machine lockup and resource leak on firmware upgrade error paths. - [High] Missing…
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] State machine lockup and resource leak on firmware upgrade error paths.
- [High] Missing exclusivity check in lt7911exc_dsi_host_attach causes memory leaks and list corruption.
- [High] Data race and hardware state corruption due to lockless access in DRM atomic hooks.
- [High] Use-After-Free (UAF) due to sysfs attribute lifetime extending past driver removal.
- [Medium] Concurrency flaw in lt7911exc_firmware_store blocks sysfs writers and causes redundant upgrades. --
commit aa1e91d28c6a1d1b9faea6c1c05acd8d8780f392
Author: Sunyun Yang <[email protected]>
drm/bridge: Add Lontium LT7911EXC eDP to MIPI DSI bridge
Add support for the Lontium LT7911EXC bridge chip, which converts eDP input to MIPI DSI output using an internal firmware-controlled pipeline.
Quoted 5 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +0
-0
[ ... ]
Quoted 16 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +16
-0+static void lt7911exc_firmware_upgrade_work (struct work_struct *work) +{ + struct lt7911exc *lt7911exc = container_of(work, struct lt7911exc, work); +struct device *dev = lt7911exc->dev; +const struct firmware *fw; +u8 *buffer; +size_t total_size =FW_SIZE -4 ; +u32 crc32; +int ret; + + ret =request_firmware (&fw,FW_FILE , dev); +if (ret) { +dev_err (dev,"failed to load '%s'\n" ,FW_FILE ); + goto out_status_only; + } +
drivers/gpu/drm/bridge/lontium-lt7911exc.c line 340
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +10
-0+if (fw->size > total_size) { +dev_err (dev,"firmware too large (%zu > %zu)\n" , fw->size, total_size); + goto out_release_fw; + } + + buffer =kmalloc (total_size,GFP_KERNEL ); +if (!buffer) { + ret = -ENOMEM ; + goto out_release_fw; + }
Will jumping to out_release_fw leave the upgrade flag permanently set?
If the firmware size is too large or kmalloc() fails, the code jumps to out_release_fw, which calls release_firmware() and returns without clearing lt7911exc->upgrade.
Since the flag remains set to true, all subsequent attempts to write to the sysfs firmware attribute will fail with -EBUSY, and lt7911exc_atomic_pre_enable() will silently return early without enabling the MIPI stream.
[ ... ]
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +10
-0+out_release_fw: +release_firmware (fw); +return ; + +out_status_only: +mutex_lock (<7911exc->ocm_lock); + lt7911exc->upgrade = false; +mutex_unlock (<7911exc->ocm_lock); +} +
drivers/gpu/drm/bridge/lontium-lt7911exc.c line 400
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +10
-0+static void lt7911exc_atomic_pre_enable (struct drm_bridge *bridge,struct drm_atomic_state *state) +{ +struct lt7911exc *lt7911exc =bridge_to_lt7911exc (bridge); + +if (lt7911exc->upgrade) +return ; + +//enable mipi stream +regmap_write (lt7911exc->regmap,0xe0b0 ,0x01 ); +}
Can this unsynchronized check result in hardware state corruption?
This function checks lt7911exc->upgrade and proceeds to perform I2C writes without holding ocm_lock. If a display modeset happens concurrently with a firmware upgrade, the unsynchronized I2C write can interleave with the firmware flashing sequence (for example, while the MCU is halted or flash is being erased).
The same applies to lt7911exc_atomic_post_disable(). Both hooks likely need to hold ocm_lock while checking the flag and performing the register access.
[ ... ]
Quoted 13 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +13
-0+static int lt7911exc_dsi_host_attach (struct mipi_dsi_host *host,struct mipi_dsi_device *dev) +{ +struct lt7911exc *lt7911exc =dsi_host_to_lt7911exc (host); +struct drm_bridge *bridge; +struct drm_panel *panel; +int ret; + + ret =drm_of_find_panel_or_bridge (host->dev->of_node,1 ,0 , &panel, &bridge); +if (ret) +return ret; + +if (panel) { + bridge =drm_panel_bridge_add_typed (panel,DRM_MODE_CONNECTOR_DSI );
drivers/gpu/drm/bridge/lontium-lt7911exc.c line 458
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +10
-0+if (IS_ERR (bridge)) +return PTR_ERR (bridge); + } + lt7911exc->output.dev = dev; + lt7911exc->output.bridge = bridge; + lt7911exc->output.panel = panel; + +drm_bridge_add (<7911exc->bridge); +return 0 ; +}
Is an exclusivity check needed here to prevent memory leaks and list corruption?
The function unconditionally allocates a new panel bridge via drm_panel_bridge_add_typed() and calls drm_bridge_add(). If multiple downstream DSI devices are attached, the previous panel bridge allocation would be leaked.
Repeatedly calling drm_bridge_add() on the same bridge also re-initializes its hpd_mutex, which destroys any existing lock state and imbalances the bridge reference counts.
[ ... ]
Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +8
-0+static ssize_t lt7911exc_firmware_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t len) +{ +struct lt7911exc *lt7911exc =dev_get_drvdata (dev); + +mutex_lock (<7911exc->ocm_lock); +if (lt7911exc->upgrade) { +mutex_unlock (<7911exc->ocm_lock);
drivers/gpu/drm/bridge/lontium-lt7911exc.c line 527
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +10
-0+return -EBUSY ; + } + + lt7911exc->upgrade = true; +mutex_unlock (<7911exc->ocm_lock); + +schedule_work (<7911exc->work); + +return len; +}
Could this concurrency approach block sysfs writers and cause redundant upgrades?
The upgrade worker lt7911exc_firmware_upgrade_work() holds ocm_lock for the entire duration of the firmware flash process. If userspace writes to this attribute while an upgrade is running, the store function blocks on mutex_lock() instead of immediately returning -EBUSY.
Once the running upgrade completes, the worker clears the upgrade flag and releases the lock. The blocked sysfs writer will then acquire the lock, see the flag is false, set it back to true, and queue a second, redundant firmware upgrade.
[ ... ]
drivers/gpu/drm/bridge/lontium-lt7911exc.c line 627
Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt7911exc.c new file +8
-0+static void lt7911exc_remove (struct i2c_client *client) +{ +struct lt7911exc *lt7911exc =i2c_get_clientdata (client); + +mipi_dsi_host_unregister (<7911exc->dsi_host); +cancel_work_sync (<7911exc->work); +gpiod_set_value_cansleep (lt7911exc->reset_gpio,1 ); +}
Does this leave a use-after-free window between driver removal and sysfs group cleanup?
The lt7911exc_firmware sysfs attribute is registered via the driver's dev_groups. The driver core removes these groups after this remove callback returns.
Userspace can still write to the sysfs attribute after cancel_work_sync() is executed here. If this occurs, lt7911exc_firmware_store() will successfully call schedule_work() again. When the device's devres resources are later freed, the workqueue will access the freed memory.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2