From nobody Mon Feb 9 17:22:31 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A591E23EAAF; Sat, 18 Oct 2025 02:02:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760752941; cv=none; b=XLJ/mwNmaOn7w+uFQSfCbMxmMEQLXQc/+xQ69uzYLDqxNIh7IAA5fLnihiLEL+GFZ9hlJ4lEiQOe7pDy+wMWqHI/vzcNNun1eIx3ZfePtioVyPmEjGuYHzzt2W42aoc279DIa6lzT9r19aNOkV7RTfZTYsXw+FjLRaR68+dR4r4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760752941; c=relaxed/simple; bh=fVDdjCNEywuKVVR+ob87bJbT3yLrYxF6TuXZfqLFmFk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h/vwVFNUR7lplfIeL6fNC5b0yfZdwBa0xePGdnCbBoMoEPfIwGRW7198DifjQUaZJS2YEfUBf4vws/wXedYfoLSfciJv8Uc35jXGyY5q4f5K9B7NNm6esoEuaZGSNnyr5M6lQA4KvkKWZax48Wktyi5Melzt9FfU8rS7umxjRE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=0t2FDjH/; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="0t2FDjH/" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 016D5C041FD; Sat, 18 Oct 2025 02:01:59 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5710F60701; Sat, 18 Oct 2025 02:02:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 43605102F236C; Sat, 18 Oct 2025 04:02:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760752937; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=a2sDvV26J4EK9UXYPJ7YJdfjFfAkgIEqv/WKwtJBGL0=; b=0t2FDjH/Lf8R/TTZoPdq6MUmxPwcBfEJXUH+OqH31wjVQxHRFF8gFake/3BAgCT7VcMSei +LWucmpiLCgNho3E88XXd6/WL90c9aG3pyKN6Ji/mvgwBUlMlGVitrpMslPJ/W9WxrLisr DzpPidXXdadZZe2o1B7ScBacCKySpAtDEWX0/gdXHGo67ejRTQd5KVyxS9HZNoZsoMLro7 Zk+AkgJjJagfX/Jvu4zaewcVHcyfc7noD4HgLMuggmXejgze8L9VCy43OhVM7eKFEmrISi H7GTDxlUG1z533Z/4A5VGNleRNonbQzlNZZpqA/MeUUxrUjWnlHnK1vbRhy21g== From: Louis Chauvet Date: Sat, 18 Oct 2025 04:01:13 +0200 Subject: [PATCH 13/22] drm/vkms: Introduce configfs for plane zpos property Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251018-vkms-all-config-v1-13-a7760755d92d@bootlin.com> References: <20251018-vkms-all-config-v1-0-a7760755d92d@bootlin.com> In-Reply-To: <20251018-vkms-all-config-v1-0-a7760755d92d@bootlin.com> To: Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , jose.exposito89@gmail.com, Jonathan Corbet Cc: victoria@system76.com, sebastian.wick@redhat.com, victoria@system76.com, airlied@gmail.com, thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=8351; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=fVDdjCNEywuKVVR+ob87bJbT3yLrYxF6TuXZfqLFmFk=; b=owEBbQKS/ZANAwAKASCtLsZbECziAcsmYgBo8vT+WZSXbTuj7/DTf+HAhR9Do2164ES3I8v6N 9OEk/emZ26JAjMEAAEKAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCaPL0/gAKCRAgrS7GWxAs 4sx6EAC15yign8j6nSsVp1cdrXAftYtyhyXg3yG9yAGfY0LBg2VNfCO4M94pXxYQRkENVopCzPU 4SkuWR/ixgPtkrqCcM5pX9Chy7agJ53k529J3m9jcATsYNwaWPVuwgThBshYf92Xfm/BEL1qh7n r7CwGn9H3eyq8NpB/1SjnCpu0mmhbIu5hlMH7m7WpVtpIg4+EVMiVXrLbIFWqHeOphEdghbW9eV KeD+Dp8jS0wJfuklkGMxyC20V22nZAip3LD9KziYZ7T54ShhLK3Yh0GhzJ2j0UZsWDPlyvKWez6 Wh6PcXoGupFHQ3w4ioydXaqcAfISgGMsclUlk7uyX/WrczVmE59LK3uzG43SLZXaoW3IA1xyQd8 NpT3lSIn5U8JyfS5jcj2chsDmuwnkol9ErLsK2Rh+MEZdfk0HZWxUsOTx1zUmOC3GkYT1iAyrou bjPKmJOIhjnSIgmo5HPiryjhfEdDLFGn0ujU7n8Iyf4aeLCzR91zOpAJFzDT+M22ocpQjhDeO+8 ZQNzCnImwOcXo3BNCzOzdE86yqKUWpEuPZ6XjbX6IxlZ0yTTReqz7838aVFlDi3IzxXifVU2cmH Drt51XNWXScwNvegqgMaBKrjgk6i9RAi623cr0koTsTEkm8Uo82U1lVovKGeOhah7YKqijZFyCy IbTAty8G2Vi9xCA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-Last-TLS-Session-Version: TLSv1.3 Modern compositor rely on zpos managment to offload some processing to deticated hardware. In order to test multiple configurations, add zpos configuration to configFS. Introduce multiple attributes to configure zpos: - zpos_enabled - Create or not the zpos property. If not created, the zpos is undefined. - zpos_mutable - If the zpos property is created, allow or not the userspace to modify it - zpos_initial - Intial value for zpos property. Must be between zpos_min and zpos_max - zpos_min - Minimal zpos value for this plane. Must be smaller than or equals to zpos_max - zpos_max - Maximal zpos value for this plane. Must be greater than or equals to zpos_min Signed-off-by: Louis Chauvet --- Documentation/gpu/vkms.rst | 9 +- drivers/gpu/drm/vkms/vkms_configfs.c | 199 +++++++++++++++++++++++++++++++= ++++ 2 files changed, 207 insertions(+), 1 deletion(-) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index deb14e7c48ea..d4ad4af45414 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -87,7 +87,7 @@ Start by creating one or more planes:: =20 sudo mkdir /config/vkms/my-vkms/planes/plane0 =20 -Planes have 8 configurable attribute: +Planes have 13 configurable attribute: =20 - type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those exposed by the "type" property of a plane) @@ -111,6 +111,13 @@ Planes have 8 configurable attribute: To remove a format, use a minus and its fourcc: -XR24 To add all formats use +* To remove all formats, use -* +- zpos_enabled: Enable or not the zpos property: 1 enable, 0 disable +- zpos_mutable: Create the zpos property as a mutable or imutable property= : 1 mutable, + 0 disable. No effect if zpos_enabled is not set. +- zpos_initial: Set the initial zpos value. Must be between zpos_min and z= pos_max. No + effect if zpos_enabled is not set. +- zpos_min: Set the minimal zpos value. No effect if zpos_enabled is not s= et. +- zpos_max: Set the maximal zpos value. No effect if zpos_enabled is not s= et. =20 Continue by creating one or more CRTCs:: =20 diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vk= ms_configfs.c index 528f22fa2df1..fd1be7292058 100644 --- a/drivers/gpu/drm/vkms/vkms_configfs.c +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0+ +#include "asm-generic/errno-base.h" #include #include #include @@ -679,6 +680,194 @@ static ssize_t plane_supported_formats_store(struct c= onfig_item *item, return count; } =20 +static ssize_t plane_zpos_enabled_show(struct config_item *item, char *pag= e) +{ + struct vkms_configfs_plane *plane; + bool enabled; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + scoped_guard(mutex, &plane->dev->lock) + enabled =3D vkms_config_plane_get_zpos_enabled(plane->config); + + return sprintf(page, "%d\n", enabled); +} + +static ssize_t plane_zpos_enabled_store(struct config_item *item, const ch= ar *page, + size_t count) +{ + struct vkms_configfs_plane *plane; + bool enabled; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + if (kstrtobool(page, &enabled)) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->lock) { + if (plane->dev->enabled) + return -EBUSY; + + vkms_config_plane_set_zpos_enabled(plane->config, enabled); + } + + return (ssize_t)count; +} + +static ssize_t plane_zpos_mutable_show(struct config_item *item, char *pag= e) +{ + struct vkms_configfs_plane *plane; + bool mutable; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + scoped_guard(mutex, &plane->dev->lock) + mutable =3D vkms_config_plane_get_zpos_mutable(plane->config); + + return sprintf(page, "%d\n", mutable); +} + +static ssize_t plane_zpos_mutable_store(struct config_item *item, const ch= ar *page, + size_t count) +{ + struct vkms_configfs_plane *plane; + bool mutable; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + if (kstrtobool(page, &mutable)) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->lock) { + if (plane->dev->enabled) + return -EBUSY; + + vkms_config_plane_set_zpos_mutable(plane->config, mutable); + } + + return (ssize_t)count; +} + +static ssize_t plane_zpos_initial_show(struct config_item *item, char *pag= e) +{ + struct vkms_configfs_plane *plane; + unsigned int initial; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + scoped_guard(mutex, &plane->dev->lock) + initial =3D vkms_config_plane_get_zpos_initial(plane->config); + + return sprintf(page, "%u\n", initial); +} + +static ssize_t plane_zpos_initial_store(struct config_item *item, const ch= ar *page, + size_t count) +{ + struct vkms_configfs_plane *plane; + unsigned int initial; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + if (kstrtouint(page, 10, &initial)) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->lock) { + if (plane->dev->enabled) + return -EBUSY; + + if (initial > vkms_config_plane_get_zpos_max(plane->config)) + return -EINVAL; + + if (initial < vkms_config_plane_get_zpos_min(plane->config)) + return -EINVAL; + + vkms_config_plane_set_zpos_initial(plane->config, initial); + } + + return (ssize_t)count; +} + +static ssize_t plane_zpos_min_show(struct config_item *item, char *page) +{ + struct vkms_configfs_plane *plane; + unsigned int min; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + scoped_guard(mutex, &plane->dev->lock) + min =3D vkms_config_plane_get_zpos_min(plane->config); + + return sprintf(page, "%u\n", min); +} + +static ssize_t plane_zpos_min_store(struct config_item *item, const char *= page, + size_t count) +{ + struct vkms_configfs_plane *plane; + unsigned int min; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + if (kstrtouint(page, 10, &min)) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->lock) { + if (plane->dev->enabled) + return -EBUSY; + + if (min > vkms_config_plane_get_zpos_max(plane->config)) + return -EINVAL; + + if (min > vkms_config_plane_get_zpos_initial(plane->config)) + return -EINVAL; + + vkms_config_plane_set_zpos_min(plane->config, min); + } + + return (ssize_t)count; +} + +static ssize_t plane_zpos_max_show(struct config_item *item, char *page) +{ + struct vkms_configfs_plane *plane; + unsigned int max; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + scoped_guard(mutex, &plane->dev->lock) + max =3D vkms_config_plane_get_zpos_max(plane->config); + + return sprintf(page, "%u\n", max); +} + +static ssize_t plane_zpos_max_store(struct config_item *item, const char *= page, + size_t count) +{ + struct vkms_configfs_plane *plane; + unsigned int max; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + if (kstrtouint(page, 10, &max)) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->lock) { + if (plane->dev->enabled) + return -EBUSY; + + if (max < vkms_config_plane_get_zpos_min(plane->config)) + return -EINVAL; + + if (max < vkms_config_plane_get_zpos_initial(plane->config)) + return -EINVAL; + + vkms_config_plane_set_zpos_max(plane->config, max); + } + + return (ssize_t)count; +} + CONFIGFS_ATTR(plane_, type); CONFIGFS_ATTR(plane_, supported_rotations); CONFIGFS_ATTR(plane_, default_rotation); @@ -687,6 +876,11 @@ CONFIGFS_ATTR(plane_, default_color_range); CONFIGFS_ATTR(plane_, supported_color_encoding); CONFIGFS_ATTR(plane_, default_color_encoding); CONFIGFS_ATTR(plane_, supported_formats); +CONFIGFS_ATTR(plane_, zpos_enabled); +CONFIGFS_ATTR(plane_, zpos_mutable); +CONFIGFS_ATTR(plane_, zpos_initial); +CONFIGFS_ATTR(plane_, zpos_min); +CONFIGFS_ATTR(plane_, zpos_max); =20 static struct configfs_attribute *plane_item_attrs[] =3D { &plane_attr_type, @@ -697,6 +891,11 @@ static struct configfs_attribute *plane_item_attrs[] = =3D { &plane_attr_supported_color_encoding, &plane_attr_default_color_encoding, &plane_attr_supported_formats, + &plane_attr_zpos_enabled, + &plane_attr_zpos_mutable, + &plane_attr_zpos_initial, + &plane_attr_zpos_min, + &plane_attr_zpos_max, NULL, }; =20 --=20 2.51.0