From 7ba76a984c311954bfa98bcbaba8890087b9e5ca Mon Sep 17 00:00:00 2001 From: foonerd Date: Thu, 18 Dec 2025 17:03:45 +0000 Subject: [PATCH 1/2] drm/panel: waveshare-dsi: Add I2C retry logic for cold boot reliability The Waveshare DSI panel driver can fail to initialize on cold boot with "I2C write failed: -5" (EIO) errors. This occurs because the panel controller requires time to stabilize after power-up, but the driver attempts I2C communication immediately after obtaining the handle. Warm boots succeed because residual controller state keeps it responsive. Cold boots after extended power-off periods fail intermittently depending on timing conditions (ambient temperature, power supply characteristics). Add defensive initialization: - 100ms stabilization delay before first I2C write in probe - Retry logic (3 attempts, 50ms between retries) for I2C writes - Return value propagation from ws_panel_i2c_write These patterns follow established practice in production embedded panel drivers and resolve the cold boot initialization race. Signed-off-by: Andrew Seredyn --- drivers/gpu/drm/panel/panel-waveshare-dsi.c | 23 ++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-waveshare-dsi.c b/drivers/gpu/drm/panel/panel-waveshare-dsi.c index 711b4c36c62f4f..b16892487634a5 100644 --- a/drivers/gpu/drm/panel/panel-waveshare-dsi.c +++ b/drivers/gpu/drm/panel/panel-waveshare-dsi.c @@ -24,6 +24,10 @@ #define WS_DSI_DRIVER_NAME "ws-ts-dsi" +#define WS_I2C_RETRIES 3 /* Number of retry attempts for I2C operations */ +#define WS_I2C_RETRY_DELAY_MS 50 /* Delay between retries in milliseconds */ +#define WS_INIT_DELAY_MS 100 /* Initial stabilization delay for panel controller */ + struct ws_panel { struct drm_panel base; struct mipi_dsi_device *dsi; @@ -329,13 +333,19 @@ static struct ws_panel *panel_to_ts(struct drm_panel *panel) return container_of(panel, struct ws_panel, base); } -static void ws_panel_i2c_write(struct ws_panel *ts, u8 reg, u8 val) +static int ws_panel_i2c_write(struct ws_panel *ts, u8 reg, u8 val) { - int ret; + int ret, retries = WS_I2C_RETRIES; - ret = i2c_smbus_write_byte_data(ts->i2c, reg, val); - if (ret) - dev_err(&ts->i2c->dev, "I2C write failed: %d\n", ret); + while (retries--) { + ret = i2c_smbus_write_byte_data(ts->i2c, reg, val); + if (!ret) + return 0; + msleep(WS_I2C_RETRY_DELAY_MS); + } + dev_err(&ts->i2c->dev, "I2C write failed after %d retries: %d\n", + WS_I2C_RETRIES, ret); + return ret; } static int ws_panel_disable(struct drm_panel *panel) @@ -479,6 +489,9 @@ static int ws_panel_probe(struct i2c_client *i2c) ts->i2c = i2c; + /* Allow panel controller to stabilize after power-up */ + msleep(WS_INIT_DELAY_MS); + ws_panel_i2c_write(ts, 0xc0, 0x01); ws_panel_i2c_write(ts, 0xc2, 0x01); ws_panel_i2c_write(ts, 0xac, 0x01); From 55f8bc2c8e9a49350c8dda2663ceb144285d6f20 Mon Sep 17 00:00:00 2001 From: foonerd Date: Thu, 18 Dec 2025 17:06:13 +0000 Subject: [PATCH 2/2] drm/panel: waveshare-dsi-v2: Add DSI command retry logic for cold boot reliability Similar to the I2C-based Waveshare panel driver, the MIPI DSI DCS-based driver (v2) can fail on cold boot when the panel controller is not ready to receive commands immediately after reset. Add defensive initialization: - 50ms stabilization delay at start of DCS command sequence - Retry logic (3 attempts, 50ms between retries) for DCS writes This ensures reliable initialization across varying cold boot timing conditions. Signed-off-by: Andrew Seredyn --- .../gpu/drm/panel/panel-waveshare-dsi-v2.c | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-waveshare-dsi-v2.c b/drivers/gpu/drm/panel/panel-waveshare-dsi-v2.c index e15dae58a19db1..71a09b15acbe0a 100644 --- a/drivers/gpu/drm/panel/panel-waveshare-dsi-v2.c +++ b/drivers/gpu/drm/panel/panel-waveshare-dsi-v2.c @@ -22,6 +22,9 @@ #include