drm/bridge: lt9611c: improve HPD handling and driver robustness
Subsystems (3)
cover drm/bridge: lt9611c: improve HPD handling and driver robustness
From: Mohit Dsor <[email protected]>
This series improves HPD handling and overall robustness of the lt9611c bridge driver.
The HPD status read from the internal MCU may fail when the device is not fully initialized, leading to spurious disconnect events. This series mitigates such issues by falling back to a cached HPD state and adds support for explicit HPD enable handling.
Additionally, it fixes DT parsing and bridge refcount handling, corrects chip type initialization, and cleans up probe and remove paths.
Tested on LT9611UXD platforms.
Mohit Dsor (5):
drm/bridge: lt9611c: fallback to cached HPD status on read failure drm/bridge: lt9611c: implement hpd_enable callback drm/bridge: lt9611c: fix DT parsing and bridge refcount drm/bridge: lt9611c: fix chip type initialization drm/bridge: lt9611c: clean up probe error and remove paths
drivers/gpu/drm/bridge/lontium-lt9611c.c | 39 +++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/1 drm: bridge: add support for lontium LT9611UXD bridge
From: Mohit Dsor <[email protected]>
Add support for Lontium LT9611UXD HDMI bridge. Lontium LT9611UXD is a DSI to HDMI bridge which supports DSI ports and I2S port as an input and HDMI port as output. Despite name being similar to LT9611 and LT9611UXD, these devices are different enough to warrant separate driver.
--- drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/lontium-lt9611uxd.c | 1140 ++++++++++++++++++++ 2 files changed, 1141 insertions(+) create mode 100644 drivers/gpu/drm/bridge/lontium-lt9611uxd.c
drivers/gpu/drm/bridge/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_DRM_LONTIUM_LT8912B) += lontium-lt8912b.o obj-$(CONFIG_DRM_LONTIUM_LT9211) += lontium-lt9211.o obj-$(CONFIG_DRM_LONTIUM_LT9611) += lontium-lt9611.o obj-$(CONFIG_DRM_LONTIUM_LT9611UXC) += lontium-lt9611uxc.o +obj-$(CONFIG_DRM_LONTIUM_LT9611UXD) += lontium-lt9611uxd.o obj-$(CONFIG_DRM_LONTIUM_LT8713SX) += lontium-lt8713sx.o obj-$(CONFIG_DRM_LVDS_CODEC) += lvds-codec.o obj-$(CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW) += megachips-stdpxxxx-ge-b850v3-fw.o
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +1140 -0
1,140 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH] drm: bridge: add support for lontium LT9611UXD bridge
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider: - [Critical] Missing error checks for `regmap_bulk_read()` cause the driver to leak uninitialized kernel…
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider:
- [Critical] Missing error checks for regmap_bulk_read() cause the driver to leak uninitialized kernel stack memory to userspace.
- [High] Requesting the threaded IRQ before drm_bridge_add() creates a race condition where the IRQ handler triggers a hotplug notification on an uninitialized mutex.
- [High] The driver blocks the probe thread with an arbitrary 3-second sleep and synchronous firmware request.
- [High] Missing MCU pause sequence and inconsistent locking during multi-register I2C flows causes hardware protocol violations.
- [High] The hardware reset sequence incorrectly assumes gpiod_set_value_cansleep(..., 1) implies physical high, permanently holding the chip in reset if configured as active-low.
- [High] Concurrent sysfs writes to the firmware store can cause a race condition leading to a Use-After-Free of the firmware object.
- [High] The sysfs interface allows access to a destroyed mutex and powered-down device during driver removal.
- [Medium] The driver leaks the loaded struct firmware object when firmware size validation fails.
- [Medium] Device tree node references for primary and secondary DSI interfaces are leaked on error paths during probe.
- [Medium] The edid_read boolean flag is never cleared, causing hotplug events to skip waiting for the new EDID.
--
commit 437e6d5b427406deebe87f22d20ccf090df265b9
Author: Mohit Dsor <[email protected]>
drm: bridge: add support for lontium LT9611UXD bridge
This commit introduces the driver for the Lontium LT9611UXD HDMI bridge. It supports DSI and I2S ports as input and an HDMI port as output.
Quoted 4 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +0
-0
[ ... ]
Quoted 1 line
+static int lt9611uxd_i2c_read_write_flow(struct lt9611uxd *lt9611uxd, u8 *params,
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 128
Quoted 4 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +4
-0+regmap_bulk_read (lt9611uxd->regmap,0xe085 , return_buffer, return_count); + +return 0 ; +}
[Severity: Critical]
Does this code leak uninitialized stack memory to userspace? The return value of regmap_bulk_read() is discarded and 0 is unconditionally returned. If the I2C read fails, the uninitialized memory in return_buffer (such as the packet array in lt9611uxd_get_edid_block()) could be copied to the EDID buffer.
[ ... ]
Quoted 2 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +2
-0+static int lt9611uxd_prepare_firmware_data (struct lt9611uxd *lt9611uxd) +{
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 139
Quoted 3 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +3
-0+/* ensure filesystem ready */ +msleep (3000 ); + ret =request_firmware (<9611uxd->fw,FW_FILE , dev);
[Severity: High]
Does this synchronous sleep and firmware request block the probe thread? Delaying the probe by 3 seconds could significantly slow down boot, or cause a deadlock if the filesystem containing the firmware is not mounted yet.
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 149
Quoted 5 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +5
-0+if (lt9611uxd->fw->size >FW_SIZE -1 ) { +dev_err (dev,"firmware too large (%zu > %d)\n" , lt9611uxd->fw->size,FW_SIZE -1 ); + lt9611uxd->fw =NULL ; +return -EINVAL ; + }
[Severity: Medium]
Does this code leak the struct firmware object? The pointer is nullified before a call to release_firmware() can occur.
[ ... ]
Quoted 5 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +5
-0+static int lt9611uxd_wait_for_edid (struct lt9611uxd *lt9611uxd) +{ +return wait_event_interruptible_timeout (lt9611uxd->wq, lt9611uxd->edid_read, +msecs_to_jiffies (500 )); +}
[ ... ]
Quoted 2 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +2
-0+static irqreturn_t lt9611uxd_irq_thread_handler (int irq,void *dev_id) +{
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 451
Quoted 5 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +5
-0+/* Check for EDID ready */ +if (irq_status &BIT (0 )) { + lt9611uxd->edid_read = true; +wake_up_all (<9611uxd->wq); + }
[Severity: Medium]
Is the edid_read flag ever cleared back to false? If a monitor is unplugged and replugged, this flag might remain true, causing lt9611uxd_wait_for_edid() to skip waiting for the new EDID.
[ ... ]
Quoted 2 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +2
-0+static void lt9611uxd_hpd_work (struct work_struct *work) +{
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 485
Quoted 4 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +4
-0+drm_bridge_hpd_notify (<9611uxd->bridge, connected ? + connector_status_connected : + connector_status_disconnected); +}
[Severity: High]
Can this notify the DRM core before the bridge is fully initialized? The threaded IRQ is requested early in probe, potentially triggering this work before drm_bridge_add() initializes the bridge mutex.
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 495
Quoted 9 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +9
-0+static void lt9611uxd_reset (struct lt9611uxd *lt9611uxd) +{ +gpiod_set_value_cansleep (lt9611uxd->reset_gpio,1 ); +msleep (20 ); +gpiod_set_value_cansleep (lt9611uxd->reset_gpio,0 ); +msleep (20 ); +gpiod_set_value_cansleep (lt9611uxd->reset_gpio,1 ); +msleep (400 ); +}
[Severity: High]
Does this sequence incorrectly assume that 1 implies a physical high signal? If the GPIO is configured as active-low, leaving it at 1 will permanently assert the reset line.
[ ... ]
Quoted 3 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +3
-0+static int lt9611uxd_get_edid_block (void *data,u8 *buf, +unsigned int block,size_t len) +{
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 690
Quoted 4 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +4
-0+for (i =0 ; i <4 ; i++) { + cmd[4 ] = block *4 + i; + ret =lt9611uxd_i2c_read_write_flow (lt9611uxd, cmd,sizeof (cmd), + packet,sizeof (packet));
[Severity: High]
Should this call to lt9611uxd_i2c_read_write_flow() be protected by mutex_lock(<9611uxd->ocm_lock)? Other callers hold this lock to pause the MCU and prevent concurrent access violations.
[ ... ]
Quoted 3 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +3
-0+static int lt9611uxd_parse_dt (struct device *dev, +struct lt9611uxd *lt9611uxd) +{
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 814
Quoted 2 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +2
-0+return drm_of_find_panel_or_bridge (dev->of_node,2 ,-1 ,NULL , <9611uxd->next_bridge); +}
[Severity: Medium]
Does this code leak the device tree node references acquired earlier by of_graph_get_remote_node()?
[ ... ]
Quoted 1 line
+static
ssize_tlt9611uxd_firmware_store(struct device *dev, structdevice_attribute*attr,
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 907
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +10
-0+out: +lt9611uxd_unlock (lt9611uxd); +lt9611uxd_reset (lt9611uxd); +if (lt9611uxd->fw) { +release_firmware (lt9611uxd->fw); + lt9611uxd->fw =NULL ; + } + +return ret <0 ? ret : len; +}
[Severity: High]
Can a concurrent write to this sysfs attribute cause a Use-After-Free? The firmware pointer is evaluated and released outside the protection of lt9611uxd->ocm_lock, meaning another thread could be using it.
[ ... ]
Quoted 2 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +2
-0+static int lt9611uxd_probe (struct i2c_client *client) +{
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 962
Quoted 5 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +5
-0+ ret =lt9611uxd_parse_dt (dev, lt9611uxd); +if (ret) { +dev_err (dev,"failed to parse device tree\n" ); +return ret; + }
[Severity: Medium]
Does this early return bypass the cleanup path that releases the DT nodes?
[ ... ]
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 1111
Quoted 12 lines
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +12
-0+static void lt9611uxd_remove (struct i2c_client *client) +{ +struct lt9611uxd *lt9611uxd =i2c_get_clientdata (client); + +free_irq (client->irq, lt9611uxd); +cancel_work_sync (<9611uxd->work); +drm_bridge_remove (<9611uxd->bridge); +mutex_destroy (<9611uxd->ocm_lock); +regulator_bulk_disable (ARRAY_SIZE (lt9611uxd->supplies), lt9611uxd->supplies); +of_node_put (lt9611uxd->dsi1_node); +of_node_put (lt9611uxd->dsi0_node); +}
[Severity: High]
Is it safe to destroy the mutex and disable regulators here while sysfs attributes are still active? Because the sysfs attributes are registered via dev_groups, they are not removed until after lt9611uxd_remove() completes.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH] drm: bridge: add support for lontium LT9611UXD bridge
In reply to [email protected]Hello,
drivers/gpu/drm/bridge/lontium-lt9611uxd.c line 1116
Quoted 4 lines · On Sun, Jun 28, 2026 at 02:11:16AM +0530, [email protected] wrote:
drivers/gpu/drm/bridge/lontium-lt9611uxd.c new file +4
-0+static const struct i2c_device_id lt9611uxd_id[] = { + {"lontium,lt9611uxd" }, + {/* sentinel */ } +};
Please use a named initializer here, i.e.
static const struct i2c_device_id lt9611uxd_id[] = {
{ .name = "lontium,lt9611uxd" },
{ /* sentinel */ }
};See
https://lore.kernel.org/lkml/[email protected]/
for a rationale.
Best regards
Uwe