All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/vc4: Check for valid formats
@ 2023-01-02 13:57 Maíra Canal
  2023-01-02 14:20 ` Thomas Zimmermann
  0 siblings, 1 reply; 10+ messages in thread
From: Maíra Canal @ 2023-01-02 13:57 UTC (permalink / raw)
  To: Maxime Ripard, Emma Anholt, David Airlie, Daniel Vetter
  Cc: Melissa Wen, Maíra Canal, André Almeida, dri-devel

Currently, vc4 is not checking valid formats before creating a
framebuffer, which is triggering the IGT test
igt@kms_addfb_basic@addfb25-bad-modifier to fail, as vc4 accepts
to create a framebuffer with an invalid modifier. Therefore, check
for valid formats before creating framebuffers on vc4 and vc5 in
order to avoid creating framebuffers with invalid formats.

Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/vc4/vc4_kms.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index 53d9f30460cf..5d1afd66fcc1 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -500,6 +500,27 @@ static struct drm_framebuffer *vc4_fb_create(struct drm_device *dev,
		mode_cmd = &mode_cmd_local;
	}

+	if (!drm_any_plane_has_format(dev, mode_cmd->pixel_format,
+				      mode_cmd->modifier[0])) {
+		drm_dbg_kms(dev, "Unsupported pixel format %p4cc / modifier 0x%llx\n",
+			    &mode_cmd->pixel_format, mode_cmd->modifier[0]);
+		return ERR_PTR(-EINVAL);
+	}
+
+	return drm_gem_fb_create(dev, file_priv, mode_cmd);
+}
+
+static struct drm_framebuffer *vc5_fb_create(struct drm_device *dev,
+					     struct drm_file *file_priv,
+					     const struct drm_mode_fb_cmd2 *mode_cmd)
+{
+	if (!drm_any_plane_has_format(dev, mode_cmd->pixel_format,
+				      mode_cmd->modifier[0])) {
+		drm_dbg_kms(dev, "Unsupported pixel format %p4cc / modifier 0x%llx\n",
+			    &mode_cmd->pixel_format, mode_cmd->modifier[0]);
+		return ERR_PTR(-EINVAL);
+	}
+
	return drm_gem_fb_create(dev, file_priv, mode_cmd);
 }

@@ -1033,7 +1054,7 @@ static const struct drm_mode_config_funcs vc4_mode_funcs = {
 static const struct drm_mode_config_funcs vc5_mode_funcs = {
	.atomic_check = vc4_atomic_check,
	.atomic_commit = drm_atomic_helper_commit,
-	.fb_create = drm_gem_fb_create,
+	.fb_create = vc5_fb_create,
 };

 int vc4_kms_load(struct drm_device *dev)
--
2.38.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-01-11 22:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-02 13:57 [PATCH] drm/vc4: Check for valid formats Maíra Canal
2023-01-02 14:20 ` Thomas Zimmermann
2023-01-02 14:29   ` Maíra Canal
2023-01-02 15:21     ` Thomas Zimmermann
2023-01-02 15:39       ` Maíra Canal
2023-01-02 15:46         ` Thomas Zimmermann
2023-01-03 10:00       ` Daniel Vetter
2023-01-11 13:28   ` Ville Syrjälä
2023-01-11 14:32     ` Maíra Canal
2023-01-11 22:16       ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.