drm: lcdif: FIFO underrun/solid color bug fix
Subsystems (4)
v2 cover drm: lcdif: FIFO underrun/solid color bug fix
This series brings a fix for the FIFO underrun/solid color bug (in the last commit) and two other changes that may help with reliability.
Paul Kocialkowski (2):
drm: lcdif: Set undocumented bit to clear FIFO at vsync
drm: lcdif: Wait for vblank before disabling DMA
drivers/gpu/drm/mxsfb/lcdif_kms.c | 18 ++++++++++++++---- drivers/gpu/drm/mxsfb/lcdif_regs.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/2 drm: lcdif: Set undocumented bit to clear FIFO at vsync
There is an undocumented bit used in the NXP BSP to clear the FIFO systematically at vsync. In normal operation, the FIFO should already be empty but it doesn't hurt to add it as an extra safety measure.
--- drivers/gpu/drm/mxsfb/lcdif_kms.c | 3 ++- drivers/gpu/drm/mxsfb/lcdif_regs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/mxsfb/lcdif_kms.c +2 -1
@@ -338,7 +338,8 @@ static void lcdif_set_mode(struct lcdif_drm_private *lcdif, u32 bus_flags)* Downstream set it to 256B burst size to improve the memory * efficiency so set it here too. */ - ctrl =CTRLDESCL0_3_P_SIZE (2 ) |CTRLDESCL0_3_T_SIZE (2 ) | + ctrl =CTRLDESCL0_3_STATE_CLEAR_VSYNC | +CTRLDESCL0_3_P_SIZE (2 ) |CTRLDESCL0_3_T_SIZE (2 ) |CTRLDESCL0_3_PITCH (lcdif->crtc.primary->state->fb->pitches[0 ]);writel (ctrl, lcdif->base +LCDC_V8_CTRLDESCL0_3 ); }
drivers/gpu/drm/mxsfb/lcdif_regs.h +1 -0
@@ -190,6 +190,7 @@#define CTRLDESCL0_1_WIDTH (n) ((n) & 0xffff)#define CTRLDESCL0_1_WIDTH_MASK GENMASK(15, 0) +#define CTRLDESCL0_3_STATE_CLEAR_VSYNC BIT(23)#define CTRLDESCL0_3_P_SIZE (n) (((n) << 20) & CTRLDESCL0_3_P_SIZE_MASK)#define CTRLDESCL0_3_P_SIZE_MASK GENMASK(22, 20)#define CTRLDESCL0_3_T_SIZE (n) (((n) << 16) & CTRLDESCL0_3_T_SIZE_MASK)
Signature · 1 line
2.53.0
Re: [PATCH v2 1/2] drm: lcdif: Set undocumented bit to clear FIFO at vsync
Quoted 10 lines · Paul Kocialkowski
There is an undocumented bit used in the NXP BSP to clear the FIFO systematically at vsync. In normal operation, the FIFO should already be empty but it doesn't hurt to add it as an extra safety measure.
Signed-off-by Paul Kocialkowski <[email protected]>Reviewed-by Lucas Stach <[email protected]>--- drivers/gpu/drm/mxsfb/lcdif_kms.c | 3 ++- drivers/gpu/drm/mxsfb/lcdif_regs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
Thanks!
Signature · 2 lines
Regards, Liu Ying
Re: [PATCH v2 1/2] drm: lcdif: Set undocumented bit to clear FIFO at vsync
In reply to Paul KocialkowskiQuoted 6 lines · Paul Kocialkowski
There is an undocumented bit used in the NXP BSP to clear the FIFO systematically at vsync. In normal operation, the FIFO should already be empty but it doesn't hurt to add it as an extra safety measure.
Signed-off-by Paul Kocialkowski <[email protected]>Reviewed-by Lucas Stach <[email protected]>
Quoted 31 lines
--- drivers/gpu/drm/mxsfb/lcdif_kms.c | 3 ++- drivers/gpu/drm/mxsfb/lcdif_regs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/mxsfb/lcdif_kms.c +2
-1@@ -338,7 +338,8 @@ static void lcdif_set_mode(struct lcdif_drm_private *lcdif, u32 bus_flags)* Downstream set it to 256B burst size to improve the memory * efficiency so set it here too. */ - ctrl =CTRLDESCL0_3_P_SIZE (2 ) |CTRLDESCL0_3_T_SIZE (2 ) | + ctrl =CTRLDESCL0_3_STATE_CLEAR_VSYNC | +CTRLDESCL0_3_P_SIZE (2 ) |CTRLDESCL0_3_T_SIZE (2 ) |CTRLDESCL0_3_PITCH (lcdif->crtc.primary->state->fb->pitches[0 ]);writel (ctrl, lcdif->base +LCDC_V8_CTRLDESCL0_3 ); }drivers/gpu/drm/mxsfb/lcdif_regs.h +1
-0@@ -190,6 +190,7 @@#define CTRLDESCL0_1_WIDTH (n) ((n) & 0xffff)#define CTRLDESCL0_1_WIDTH_MASK GENMASK(15, 0) +#define CTRLDESCL0_3_STATE_CLEAR_VSYNC BIT(23)#define CTRLDESCL0_3_P_SIZE (n) (((n) << 20) & CTRLDESCL0_3_P_SIZE_MASK)#define CTRLDESCL0_3_P_SIZE_MASK GENMASK(22, 20)#define CTRLDESCL0_3_T_SIZE (n) (((n) << 16) & CTRLDESCL0_3_T_SIZE_MASK)
PATCH v2 2/2 drm: lcdif: Wait for vblank before disabling DMA
In reply to Paul KocialkowskiIt is necessary to wait for the full frame to finish streaming through the DMA engine before we can safely disable it by removing the DISP_PARA_DISP_ON bit. Disabling it in-flight can leave the hardware confused and unable to resume streaming for the next frame.
This causes the FIFO underrun and empty status bits to be set and a single solid color to be shown on the display, coming from one of the pixels of the previous frame. The issue occurs sporadically when a new mode is set, which triggers the crtc disable and enable paths.
Setting the shadow load bit and waiting for it to be cleared by the DMA engine allows waiting for completion.
The NXP BSP driver addresses this issue with a hardcoded 25 ms sleep.
--- drivers/gpu/drm/mxsfb/lcdif_kms.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/mxsfb/lcdif_kms.c +12 -3
@@ -375,14 +375,23 @@ static void lcdif_disable_controller(struct lcdif_drm_private *lcdif)int ret; reg =readl (lcdif->base +LCDC_V8_CTRLDESCL0_5 ); +/* Disable the layer for DMA. */ reg &= ~CTRLDESCL0_5_EN ; +/* +* It is necessary to wait for the full frame to finish streaming +* through the DMA engine before we can safely disable it by removing +* the DISP_PARA_DISP_ON bit. Disabling it in-flight can leave the +* hardware confused and unable to resume streaming for the next frame. +*/ + reg |=CTRLDESCL0_5_SHADOW_LOAD_EN ;writel (reg, lcdif->base +LCDC_V8_CTRLDESCL0_5 ); +/* Wait for the frame to finish or timeout after 50 ms. */ ret =readl_poll_timeout (lcdif->base +LCDC_V8_CTRLDESCL0_5 , - reg, !(reg &CTRLDESCL0_5_EN ), -0 ,36000 );/* Wait ~2 frame times max */ + reg, !(reg &CTRLDESCL0_5_SHADOW_LOAD_EN ), +200 ,50000 );if (ret) -drm_err (lcdif->drm,"Failed to disable controller!\n" ); +drm_err (lcdif->drm,"Timed out waiting for final vblank!\n" ); reg =readl (lcdif->base +LCDC_V8_DISP_PARA ); reg &= ~DISP_PARA_DISP_ON ;
Signature · 1 line
2.53.0
Re: [PATCH v2 2/2] drm: lcdif: Wait for vblank before disabling DMA
Hi Paul,
Quoted 10 lines · Paul Kocialkowski
It is necessary to wait for the full frame to finish streaming through the DMA engine before we can safely disable it by removing the
DISP_PARA_DISP_ONbit. Disabling it in-flight can leave the hardware confused and unable to resume streaming for the next frame.This causes the FIFO underrun and empty status bits to be set and a single solid color to be shown on the display, coming from one of the pixels of the previous frame. The issue occurs sporadically when a new mode is set, which triggers the crtc disable and enable paths.
Quoted 8 lines
Setting the shadow load bit and waiting for it to be cleared by the DMA engine allows waiting for completion.
The NXP BSP driver addresses this issue with a hardcoded 25 ms sleep.
Fixes 9db35bb349a0 ("drm: lcdif: Add support for i.MX8MP LCDIF variant")Signed-off-by Paul Kocialkowski <[email protected]>Co-developed-by Lucas Stach <[email protected]>
There is a warning reported by checkpatch.pl:
WARNING: Co-developed-by: must be immediately followed by Signed-off-by:
#23:
With this fixed:
Thanks!
Signature · 2 lines
Regards, Liu Ying
Re: [PATCH v2 2/2] drm: lcdif: Wait for vblank before disabling DMA
In reply to Paul KocialkowskiAm Donnerstag, dem 02.04.2026 um 20:33 +0200 schrieb Paul Kocialkowski:
Quoted 10 lines
It is necessary to wait for the full frame to finish streaming through the DMA engine before we can safely disable it by removing the
DISP_PARA_DISP_ONbit. Disabling it in-flight can leave the hardware confused and unable to resume streaming for the next frame.This causes the FIFO underrun and empty status bits to be set and a single solid color to be shown on the display, coming from one of the pixels of the previous frame. The issue occurs sporadically when a new mode is set, which triggers the crtc disable and enable paths.
Quoted 8 lines
Setting the shadow load bit and waiting for it to be cleared by the DMA engine allows waiting for completion.
The NXP BSP driver addresses this issue with a hardcoded 25 ms sleep.
Fixes 9db35bb349a0 ("drm: lcdif: Add support for i.MX8MP LCDIF variant")Signed-off-by Paul Kocialkowski <[email protected]>Co-developed-by Lucas Stach <[email protected]>
Looks good to me. Since the co-developed tag requires a sign-off from me, I'll add that instead of a review tag. And you might want to move your sign-off down, as you are the one submitting the patch.
Quoted 35 lines
--- drivers/gpu/drm/mxsfb/lcdif_kms.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/mxsfb/lcdif_kms.c +12
-3@@ -375,14 +375,23 @@ static void lcdif_disable_controller(struct lcdif_drm_private *lcdif)int ret; reg =readl (lcdif->base +LCDC_V8_CTRLDESCL0_5 ); +/* Disable the layer for DMA. */ reg &= ~CTRLDESCL0_5_EN ; +/* +* It is necessary to wait for the full frame to finish streaming +* through the DMA engine before we can safely disable it by removing +* the DISP_PARA_DISP_ON bit. Disabling it in-flight can leave the +* hardware confused and unable to resume streaming for the next frame. +*/ + reg |=CTRLDESCL0_5_SHADOW_LOAD_EN ;writel (reg, lcdif->base +LCDC_V8_CTRLDESCL0_5 ); +/* Wait for the frame to finish or timeout after 50 ms. */ ret =readl_poll_timeout (lcdif->base +LCDC_V8_CTRLDESCL0_5 , - reg, !(reg &CTRLDESCL0_5_EN ), -0 ,36000 );/* Wait ~2 frame times max */ + reg, !(reg &CTRLDESCL0_5_SHADOW_LOAD_EN ), +200 ,50000 );if (ret) -drm_err (lcdif->drm,"Failed to disable controller!\n" ); +drm_err (lcdif->drm,"Timed out waiting for final vblank!\n" ); reg =readl (lcdif->base +LCDC_V8_DISP_PARA ); reg &= ~DISP_PARA_DISP_ON ;
Re: [PATCH v2 2/2] drm: lcdif: Wait for vblank before disabling DMA
Hi Lucas,
Quoted 16 lines · Lucas Stach
Am Donnerstag, dem 02.04.2026 um 20:33 +0200 schrieb Paul Kocialkowski:
Quoted 15 lines
It is necessary to wait for the full frame to finish streaming through the DMA engine before we can safely disable it by removing the
DISP_PARA_DISP_ONbit. Disabling it in-flight can leave the hardware confused and unable to resume streaming for the next frame.This causes the FIFO underrun and empty status bits to be set and a single solid color to be shown on the display, coming from one of the pixels of the previous frame. The issue occurs sporadically when a new mode is set, which triggers the crtc disable and enable paths.
Setting the shadow load bit and waiting for it to be cleared by the DMA engine allows waiting for completion.
The NXP BSP driver addresses this issue with a hardcoded 25 ms sleep.
Quoted 7 lines
Quoted 3 lines
Fixes 9db35bb349a0 ("drm: lcdif: Add support for i.MX8MP LCDIF variant")Signed-off-by Paul Kocialkowski <[email protected]>Co-developed-by Lucas Stach <[email protected]>Looks good to me. Since the co-developed tag requires a sign-off from me, I'll add that instead of a review tag. And you might want to move your sign-off down, as you are the one submitting the patch.
Sounds good to me! This can probably be done when picking up the patch, but if maintainers need me to respin the series to get all the tags in order myself, just let me know!
All the best,
Paul
Quoted 38 lines
Signed-off-by Lucas Stach <[email protected]>Quoted 35 lines
--- drivers/gpu/drm/mxsfb/lcdif_kms.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/mxsfb/lcdif_kms.c +12
-3@@ -375,14 +375,23 @@ static void lcdif_disable_controller(struct lcdif_drm_private *lcdif)int ret; reg =readl (lcdif->base +LCDC_V8_CTRLDESCL0_5 ); +/* Disable the layer for DMA. */ reg &= ~CTRLDESCL0_5_EN ; +/* +* It is necessary to wait for the full frame to finish streaming +* through the DMA engine before we can safely disable it by removing +* the DISP_PARA_DISP_ON bit. Disabling it in-flight can leave the +* hardware confused and unable to resume streaming for the next frame. +*/ + reg |=CTRLDESCL0_5_SHADOW_LOAD_EN ;writel (reg, lcdif->base +LCDC_V8_CTRLDESCL0_5 ); +/* Wait for the frame to finish or timeout after 50 ms. */ ret =readl_poll_timeout (lcdif->base +LCDC_V8_CTRLDESCL0_5 , - reg, !(reg &CTRLDESCL0_5_EN ), -0 ,36000 );/* Wait ~2 frame times max */ + reg, !(reg &CTRLDESCL0_5_SHADOW_LOAD_EN ), +200 ,50000 );if (ret) -drm_err (lcdif->drm,"Failed to disable controller!\n" ); +drm_err (lcdif->drm,"Timed out waiting for final vblank!\n" ); reg =readl (lcdif->base +LCDC_V8_DISP_PARA ); reg &= ~DISP_PARA_DISP_ON ;
Signature · 6 lines
Paul Kocialkowski, Independent contractor - sys-base - https://www.sys-base.io/ Free software developer - https://www.paulk.fr/ Expert in multimedia, graphics and embedded hardware support with Linux.
Re: [PATCH v2 2/2] drm: lcdif: Wait for vblank before disabling DMA
In reply to Paul KocialkowskiQuoted 10 lines · Paul Kocialkowski
It is necessary to wait for the full frame to finish streaming through the DMA engine before we can safely disable it by removing the
DISP_PARA_DISP_ONbit. Disabling it in-flight can leave the hardware confused and unable to resume streaming for the next frame.This causes the FIFO underrun and empty status bits to be set and a single solid color to be shown on the display, coming from one of the pixels of the previous frame. The issue occurs sporadically when a new mode is set, which triggers the crtc disable and enable paths.
Quoted 8 lines
Setting the shadow load bit and waiting for it to be cleared by the DMA engine allows waiting for completion.
The NXP BSP driver addresses this issue with a hardcoded 25 ms sleep.
Fixes 9db35bb349a0 ("drm: lcdif: Add support for i.MX8MP LCDIF variant")Signed-off-by Paul Kocialkowski <[email protected]>Co-developed-by Lucas Stach <[email protected]>
Quoted 35 lines
--- drivers/gpu/drm/mxsfb/lcdif_kms.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/mxsfb/lcdif_kms.c +12
-3@@ -375,14 +375,23 @@ static void lcdif_disable_controller(struct lcdif_drm_private *lcdif)int ret; reg =readl (lcdif->base +LCDC_V8_CTRLDESCL0_5 ); +/* Disable the layer for DMA. */ reg &= ~CTRLDESCL0_5_EN ; +/* +* It is necessary to wait for the full frame to finish streaming +* through the DMA engine before we can safely disable it by removing +* the DISP_PARA_DISP_ON bit. Disabling it in-flight can leave the +* hardware confused and unable to resume streaming for the next frame. +*/ + reg |=CTRLDESCL0_5_SHADOW_LOAD_EN ;writel (reg, lcdif->base +LCDC_V8_CTRLDESCL0_5 ); +/* Wait for the frame to finish or timeout after 50 ms. */ ret =readl_poll_timeout (lcdif->base +LCDC_V8_CTRLDESCL0_5 , - reg, !(reg &CTRLDESCL0_5_EN ), -0 ,36000 );/* Wait ~2 frame times max */ + reg, !(reg &CTRLDESCL0_5_SHADOW_LOAD_EN ), +200 ,50000 );if (ret) -drm_err (lcdif->drm,"Failed to disable controller!\n" ); +drm_err (lcdif->drm,"Timed out waiting for final vblank!\n" ); reg =readl (lcdif->base +LCDC_V8_DISP_PARA ); reg &= ~DISP_PARA_DISP_ON ;
Quoted 11 lines · Paul Kocialkowski
This series brings a fix for the FIFO underrun/solid color bug (in the last commit) and two other changes that may help with reliability.
Paul Kocialkowski (2):
drm: lcdif: Set undocumented bit to clear FIFO at vsync
drm: lcdif: Wait for vblank before disabling DMAdrivers/gpu/drm/mxsfb/lcdif_kms.c | 18 ++++++++++++++---- drivers/gpu/drm/mxsfb/lcdif_regs.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-)
Can this series be applied, please?
Thanks!
Lucas Stach
AppliedAm Mittwoch, dem 27.05.2026 um 12:35 +0200 schrieb Frieder Schrempf:
Quoted 8 lines · Paul Kocialkowski
Quoted 7 lines
This series brings a fix for the FIFO underrun/solid color bug (in the last commit) and two other changes that may help with reliability.
Paul Kocialkowski (2):
drm: lcdif: Set undocumented bit to clear FIFO at vsync
drm: lcdif: Wait for vblank before disabling DMA
Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/mxsfb/lcdif_kms.c | 18 ++++++++++++++---- drivers/gpu/drm/mxsfb/lcdif_regs.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-)Can this series be applied, please?
Applied to drm-misc-next.
Regards,
Lucas