summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>2025-11-03 17:43:39 +0200
committerRob Clark <robin.clark@oss.qualcomm.com>2025-11-03 07:58:43 -0800
commit227ec96232ba11bc830d25cc1e77fc3095a02033 (patch)
tree4a035bdaf13ffd16f78ee975ef5920efe052c7dd
parentcb9f145f638d7afa633632a9290d6ad06caeb8ee (diff)
drm/msm: fix allocation of dumb buffers for non-RGB formats
Several users (including IGT kms_getfb tests) allocate DUMB buffers for YUV data. Commit 538fa012cbdb ("drm/msm: Compute dumb-buffer sizes with drm_mode_size_dumb()") broke that usecase, since in those cases drm_driver_color_mode_format() returns DRM_FORMAT_INVALID. Handle the YUV usecase, aligning to 32-bit pixels. Fixes: 538fa012cbdb ("drm/msm: Compute dumb-buffer sizes with drm_mode_size_dumb()") Closes: https://lore.kernel.org/all/vptw5tquup34e3jen62znnw26qe76f3pys4lpsal5g3czwev6y@2q724ibos7by/ Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Patchwork: https://patchwork.freedesktop.org/patch/685197/ Message-ID: <20251103-drm-msm-fix-nv12-v2-1-75103b64576e@oss.qualcomm.com> Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 435c0067c264..017411a0bf45 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -701,7 +701,6 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args)
{
u32 fourcc;
- const struct drm_format_info *info;
u64 pitch_align;
int ret;
@@ -711,12 +710,16 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
* Use the result as pitch alignment.
*/
fourcc = drm_driver_color_mode_format(dev, args->bpp);
- if (fourcc == DRM_FORMAT_INVALID)
- return -EINVAL;
- info = drm_format_info(fourcc);
- if (!info)
- return -EINVAL;
- pitch_align = drm_format_info_min_pitch(info, 0, SZ_32);
+ if (fourcc != DRM_FORMAT_INVALID) {
+ const struct drm_format_info *info;
+
+ info = drm_format_info(fourcc);
+ if (!info)
+ return -EINVAL;
+ pitch_align = drm_format_info_min_pitch(info, 0, 32);
+ } else {
+ pitch_align = round_up(args->width, 32) * DIV_ROUND_UP(args->bpp, SZ_8);
+ }
if (!pitch_align || pitch_align > U32_MAX)
return -EINVAL;
ret = drm_mode_size_dumb(dev, args, pitch_align, 0);