ipu_prg_channel_configure() can fail when no PRE is available for the PRG
channel, but ipu_plane_atomic_update() ignores its return value.

Atomic check is expected to prevent this condition. If it still happens,
warn and abort the update instead of continuing with the original
framebuffer address after the PRG/PRE setup failed.

Fixes: 00514e859335 ("drm/imx: use PRG/PRE when possible")
Cc: [email protected]
Signed-off-by: Osama Abdelkader <[email protected]>
---
 drivers/gpu/drm/imx/ipuv3/ipuv3-plane.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/ipuv3-plane.c 
b/drivers/gpu/drm/imx/ipuv3/ipuv3-plane.c
index d6806d1ae6e1..78a3ea0581c0 100644
--- a/drivers/gpu/drm/imx/ipuv3/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3/ipuv3-plane.c
@@ -629,10 +629,14 @@ static void ipu_plane_atomic_update(struct drm_plane 
*plane,
         */
        if (ipu_state->use_pre) {
                axi_id = ipu_chan_assign_axi_id(ipu_plane->dma);
-               ipu_prg_channel_configure(ipu_plane->ipu_ch, axi_id, width,
-                                         height, fb->pitches[0],
-                                         fb->format->format, fb->modifier,
-                                         &eba);
+               if (WARN_ON_ONCE(ipu_prg_channel_configure(ipu_plane->ipu_ch,
+                                                          axi_id, width,
+                                                          height,
+                                                          fb->pitches[0],
+                                                          fb->format->format,
+                                                          fb->modifier,
+                                                          &eba)))
+                       return;
        }
 
        if (!old_state->fb ||
-- 
2.43.0

Reply via email to