Skip to content

Commit 0709aba

Browse files
committed
drm/imx/ipuv3: Fix dumb-buffer allocation for non-RGB formats
Align pitch to multiples of 8 pixels for bpp values that do not map to RGB formats. The call to drm_driver_color_mode_format() fails with DRM_INVALID_FORMAT in these cases. Fall back to manually computing the pitch alignment from which drm_mode_size_dumb() can compute the correct pitch. Fixes userspace that allocates dumb buffers for YUV formats, where bpp equals 12. A common example is the IGT kms_getfb test. v2: - ignore width in calculation Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Fixes: b1d0e47 ("drm/imx/ipuv3: Compute dumb-buffer sizes with drm_mode_size_dumb()") Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Shawn Guo <shawnguo@kernel.org> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Pengutronix Kernel Team <kernel@pengutronix.de> Cc: Fabio Estevam <festevam@gmail.com> Cc: dri-devel@lists.freedesktop.org Cc: imx@lists.linux.dev Cc: linux-arm-kernel@lists.infradead.org Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Link: https://patch.msgid.link/20251104153832.189666-1-tzimmermann@suse.de
1 parent de0d6e1 commit 0709aba

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ static int imx_drm_dumb_create(struct drm_file *file_priv,
144144
struct drm_mode_create_dumb *args)
145145
{
146146
u32 fourcc;
147-
const struct drm_format_info *info;
148147
u64 pitch_align;
149148
int ret;
150149

@@ -156,12 +155,15 @@ static int imx_drm_dumb_create(struct drm_file *file_priv,
156155
* the allocated buffer.
157156
*/
158157
fourcc = drm_driver_color_mode_format(drm, args->bpp);
159-
if (fourcc == DRM_FORMAT_INVALID)
160-
return -EINVAL;
161-
info = drm_format_info(fourcc);
162-
if (!info)
163-
return -EINVAL;
164-
pitch_align = drm_format_info_min_pitch(info, 0, SZ_8);
158+
if (fourcc != DRM_FORMAT_INVALID) {
159+
const struct drm_format_info *info = drm_format_info(fourcc);
160+
161+
if (!info)
162+
return -EINVAL;
163+
pitch_align = drm_format_info_min_pitch(info, 0, 8);
164+
} else {
165+
pitch_align = DIV_ROUND_UP(args->bpp, SZ_8) * 8;
166+
}
165167
if (!pitch_align || pitch_align > U32_MAX)
166168
return -EINVAL;
167169
ret = drm_mode_size_dumb(drm, args, pitch_align, 0);

0 commit comments

Comments
 (0)