public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "José Expósito" <jose.exposito89@gmail.com>
To: louis.chauvet@bootlin.com
Cc: hamohammed.sa@gmail.com, simona@ffwll.ch, melissa.srw@gmail.com,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@gmail.com,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH v3 07/14] drm/vkms: Add a validation function for VKMS configuration
Date: Mon, 17 Feb 2025 11:01:13 +0100	[thread overview]
Message-ID: <20250217100120.7620-8-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20250217100120.7620-1-jose.exposito89@gmail.com>

From: Louis Chauvet <louis.chauvet@bootlin.com>

As the configuration will be used by userspace, add a validator to avoid
creating a broken DRM device.

For the moment, the function always returns true, but rules will be
added in future patches.

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
Co-developed-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/gpu/drm/vkms/tests/vkms_config_test.c |  2 ++
 drivers/gpu/drm/vkms/vkms_config.c            |  6 ++++++
 drivers/gpu/drm/vkms/vkms_config.h            | 10 ++++++++++
 drivers/gpu/drm/vkms/vkms_output.c            |  3 +++
 4 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index 92798590051b..6e07139d261c 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -54,6 +54,8 @@ static void vkms_config_test_default_config(struct kunit *test)
 	KUNIT_EXPECT_EQ(test, config->writeback, params->enable_writeback);
 	KUNIT_EXPECT_EQ(test, config->overlay, params->enable_overlay);
 
+	KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
 	vkms_config_destroy(config);
 }
 
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 9fb08d94a351..d1947537834c 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -51,6 +51,12 @@ void vkms_config_destroy(struct vkms_config *config)
 }
 EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy);
 
+bool vkms_config_is_valid(const struct vkms_config *config)
+{
+	return true;
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_is_valid);
+
 static int vkms_config_show(struct seq_file *m, void *data)
 {
 	struct drm_debugfs_entry *entry = m->private;
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index fcaa909fb2e0..31c758631c37 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -67,6 +67,16 @@ vkms_config_get_device_name(struct vkms_config *config)
 	return config->dev_name;
 }
 
+/**
+ * vkms_config_is_valid() - Validate a configuration
+ * @config: Configuration to validate
+ *
+ * Returns:
+ * Whether the configuration is valid or not.
+ * For example, a configuration without primary planes is not valid.
+ */
+bool vkms_config_is_valid(const struct vkms_config *config);
+
 /**
  * vkms_config_register_debugfs() - Register a debugfs file to show the device's
  * configuration
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index 068a7f87ecec..414cc933af41 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -16,6 +16,9 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 	int writeback;
 	unsigned int n;
 
+	if (!vkms_config_is_valid(vkmsdev->config))
+		return -EINVAL;
+
 	/*
 	 * Initialize used plane. One primary plane is required to perform the composition.
 	 *
-- 
2.48.1


  parent reply	other threads:[~2025-02-17 10:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17 10:01 [PATCH v3 00/14] drm/vkms: Allow to configure device José Expósito
2025-02-17 10:01 ` [PATCH v3 01/14] drm/vkms: Extract vkms_connector header José Expósito
2025-02-17 10:01 ` [PATCH v3 02/14] drm/vkms: Create vkms_connector struct José Expósito
2025-02-17 10:01 ` [PATCH v3 03/14] drm/vkms: Add KUnit test scaffolding José Expósito
2025-02-17 10:01 ` [PATCH v3 04/14] drm/vkms: Extract vkms_config header José Expósito
2025-02-17 10:01 ` [PATCH v3 05/14] drm/vkms: Move default_config creation to its own function José Expósito
2025-02-17 10:01 ` [PATCH v3 06/14] drm/vkms: Set device name from vkms_config José Expósito
2025-02-17 10:01 ` José Expósito [this message]
2025-02-17 10:01 ` [PATCH v3 08/14] drm/vkms: Allow to configure multiple planes José Expósito
2025-02-17 15:45   ` Louis Chauvet
2025-02-17 16:34     ` José Expósito
2025-02-17 17:06       ` Louis Chauvet
2025-02-17 10:01 ` [PATCH v3 09/14] drm/vkms: Allow to configure multiple CRTCs José Expósito
2025-02-17 15:45   ` Louis Chauvet
2025-02-17 10:01 ` [PATCH v3 10/14] drm/vkms: Allow to attach planes and CRTCs José Expósito
2025-02-17 15:45   ` Louis Chauvet
2025-02-17 10:01 ` [PATCH v3 11/14] drm/vkms: Allow to configure multiple encoders José Expósito
2025-02-17 15:45   ` Louis Chauvet
2025-02-17 10:01 ` [PATCH v3 12/14] drm/vkms: Allow to attach encoders and CRTCs José Expósito
2025-02-17 15:45   ` Louis Chauvet
2025-02-17 10:01 ` [PATCH v3 13/14] drm/vkms: Allow to configure multiple connectors José Expósito
2025-02-17 15:45   ` Louis Chauvet
2025-02-18 10:11     ` José Expósito
2025-02-17 10:01 ` [PATCH v3 14/14] drm/vkms: Allow to attach connectors and encoders José Expósito
2025-02-17 15:45   ` Louis Chauvet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250217100120.7620-8-jose.exposito89@gmail.com \
    --to=jose.exposito89@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.chauvet@bootlin.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=melissa.srw@gmail.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox