Skip to content

Commit 17b9a94

Browse files
lynxeye-devpH5
authored andcommitted
drm/imx: ipuv3-plane: fix PRG modifiers after drm managed resource conversion
The conversion to drm managed resources introduced two bugs: the plane is now always initialized with the linear-only list, while the list with the Vivante GPU modifiers should have been used when the PRG/PRE engines are present. This masked another issue, as ipu_plane_format_mod_supported() is now called before the private plane data is set up, so if a non-linear modifier is supplied in the plane modifier list, we run into a NULL pointer dereference checking for the PRG presence. To fix this just remove the check from this function, as we know that it will only be called with a non-linear modifier, if the plane init code has already determined that the PRG/PRE is present. Fixes: 699e7e5 ("drm/imx: ipuv3-plane: use drm managed resources") Signed-off-by: Lucas Stach <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Philipp Zabel <[email protected]>
1 parent 11e3c67 commit 17b9a94

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/gpu/drm/imx/ipuv3-plane.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,11 @@ static bool ipu_plane_format_mod_supported(struct drm_plane *plane,
349349
if (modifier == DRM_FORMAT_MOD_LINEAR)
350350
return true;
351351

352-
/* without a PRG there are no supported modifiers */
353-
if (!ipu_prg_present(ipu))
354-
return false;
355-
352+
/*
353+
* Without a PRG the possible modifiers list only includes the linear
354+
* modifier, so we always take the early return from this function and
355+
* only end up here if the PRG is present.
356+
*/
356357
return ipu_prg_format_supported(ipu, format, modifier);
357358
}
358359

@@ -878,6 +879,10 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
878879
formats = ipu_plane_rgb_formats;
879880
format_count = ARRAY_SIZE(ipu_plane_rgb_formats);
880881
}
882+
883+
if (ipu_prg_present(ipu))
884+
modifiers = pre_format_modifiers;
885+
881886
ipu_plane = drmm_universal_plane_alloc(dev, struct ipu_plane, base,
882887
possible_crtcs, &ipu_plane_funcs,
883888
formats, format_count, modifiers,
@@ -892,9 +897,6 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
892897
ipu_plane->dma = dma;
893898
ipu_plane->dp_flow = dp;
894899

895-
if (ipu_prg_present(ipu))
896-
modifiers = pre_format_modifiers;
897-
898900
drm_plane_helper_add(&ipu_plane->base, &ipu_plane_helper_funcs);
899901

900902
if (dp == IPU_DP_FLOW_SYNC_BG || dp == IPU_DP_FLOW_SYNC_FG)

0 commit comments

Comments
 (0)