From patchwork Wed Aug 14 14:36:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06DE6C52D7D for ; Wed, 14 Aug 2024 14:36:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 783B210E4AC; Wed, 14 Aug 2024 14:36:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="i+kmEQDo"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id D328A10E4AC for ; Wed, 14 Aug 2024 14:36:31 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id BD3991C0008; Wed, 14 Aug 2024 14:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eF/g/e9xyf2rr4km0n8jSrkU5dfzWS16jpF7TN6tyR0=; b=i+kmEQDoTc5UcmhFyS/BGglA4SyL3EormN70z0AGzVYTJMMVe7j4PxnqsikIn6tzJPma2J ptBagwhWlbaliy+DPR/uiBUxXhs0TDr/rXM9uFA6JEJ75ByRZ10hSvp/HqewvrS0l/8l0/ GaYRC6vg534VhV8LJAb6aOF27SEA+DnKrNQDfI2xEru33m5EDTfAKadQyw2pwmviBna6ON Ct3YxeO2mZWEMy5Bw4OdTjOKR5uV5BIU5w6UVlB+y6Ybv4QwLyzeWkqc+z9o+7fEmGD4GI Hp81XAYiqRvrsYbTdiT1yNYtV8LC7Ru+0gwDzoT5RwaFRuuIOnfh32SflMvViw== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:23 +0200 Subject: [PATCH RFC 01/15] drm/vkms: Remove useles devres group MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-1-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2158; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=QLAjOjwHapYP9G4IFhnwtelvbUro7gbDDe4ixI5k8dA=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDqaNNbQt4vZtJxwAG1VpPbZq4w8JjIi8Xkj utFmLTi+76JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6gAKCRAgrS7GWxAs 4rEyEADAM3Zuqga1gLTTIqu2xnxwAtMPs6sMRnWsHhnXd4novePYULsml77ZAacX3ar4FTEwVjP oE3Xb8DbSJeNe6G1bZ7Dm+zIgBbg8vzteM4W0MjDvXc3COrz9sOEwE/qev0m2YP9Yx304SYu2Ug nHM7Pcft8eDjMQmAzcLOAynYNOPJ6mZgTo6nfHnvLQ7rGDVIxAuHNSqSpiJ+Qdj6sGd6s0C+YWS vXaeJvL9MUsXi6Rdk004sCYFq6Op4DooRdKJkmMLst0qUd15ffRlftoJ5y6Dsaov2751gf+QrI6 uAodQE/zloe4dRbtZM3TwcLeF+HJh6tTkcZKD64od/D5bWp4P6KdO1FCewTGBoaoihrBuSTBhSo bkiMrM5Z5do03orRDnFgDPrMbBO9Z3IdA+TufcGoZ3CFRQu5FkUohIVYUXssFY+2MJogtz8vTaZ MyZ7ubjJcy0k9g+Jg0McugpDmkcmyAKuQL9rEzFsx2YlU4B1QIZI1czmR0LOjKUDNf5QFhv2FM/ ZouyewjgaNGLy9pX6XcRl8lLNE/w0yrwnEF4fgV/lor158KJBijfeOcCdph9/pH9PzEmgazvul9 lcziSWUtohrd6j7lqlyUyfHgolJ0OFVa6VK3qLU+YGdzbICLuIbwj6ArKkLOeijGUKUC3yl8MBk oVvSOBnDMoIfJpQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As the driver now uses drm managed allocation, the devres group is not needed anymore, so remove it. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index e79832e10f3c..7ac3ab7e16e5 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -297,16 +297,11 @@ static int vkms_create(struct vkms_config *config) if (IS_ERR(pdev)) return PTR_ERR(pdev); - if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) { - ret = -ENOMEM; - goto out_unregister; - } - vkms_device = devm_drm_dev_alloc(&pdev->dev, &vkms_driver, struct vkms_device, drm); if (IS_ERR(vkms_device)) { ret = PTR_ERR(vkms_device); - goto out_devres; + goto out_unregister; } vkms_device->platform = pdev; vkms_device->config = config; @@ -317,32 +312,30 @@ static int vkms_create(struct vkms_config *config) if (ret) { DRM_ERROR("Could not initialize DMA support\n"); - goto out_devres; + goto out_unregister; } ret = drm_vblank_init(&vkms_device->drm, 1); if (ret) { DRM_ERROR("Failed to vblank\n"); - goto out_devres; + goto out_unregister; } ret = vkms_modeset_init(vkms_device); if (ret) - goto out_devres; + goto out_unregister; drm_debugfs_add_files(&vkms_device->drm, vkms_config_debugfs_list, ARRAY_SIZE(vkms_config_debugfs_list)); ret = drm_dev_register(&vkms_device->drm, 0); if (ret) - goto out_devres; + goto out_unregister; drm_fbdev_shmem_setup(&vkms_device->drm, 0); return 0; -out_devres: - devres_release_group(&pdev->dev, NULL); out_unregister: platform_device_unregister(pdev); return ret; @@ -383,7 +376,6 @@ static void vkms_destroy(struct vkms_config *config) drm_dev_unregister(&config->dev->drm); drm_atomic_helper_shutdown(&config->dev->drm); - devres_release_group(&pdev->dev, NULL); platform_device_unregister(pdev); config->dev = NULL; From patchwork Wed Aug 14 14:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35AF9C52D7B for ; Wed, 14 Aug 2024 14:36:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B43710E4AD; Wed, 14 Aug 2024 14:36:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="AoG8OPrO"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id ECF3E10E4AC for ; Wed, 14 Aug 2024 14:36:32 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id B0EA51C0005; Wed, 14 Aug 2024 14:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fjT0T1cDM1LYJFW8u10bh1Tm6iF9xcPCR84CrhIb5P0=; b=AoG8OPrOjndHgrPiSdy/9sdp+9BXVKUVWznI+EIuGNARGRB81pD8ZYvaihBEvnZY1adU/J csQq11NhRrAhS9FxX/soLqMC+kLiI/3gvOB/F0yPPEyX8tcRupzncuLKHCsrigAZNzxRCh 4BlVLF7ue7a+vcuslOvDoXAtOY3RXGJBUm0CQiq3DrmQjldmoQK8Ua9+FR4yGSkddclGMu EZ7XBi96wybIwiOD1d5auHxrgkxq9qucC/38ScZdtQJUdpUh5G2ZgRoP5/t9x+5jKjYiGy DQwMa+vwRsT9tYGzlOZ0L2AnadDqDq4CzFGJ34mtneTlM13EOBEy7Sd6R2Rx0g== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:24 +0200 Subject: [PATCH RFC 02/15] drm/vkms: remove possible crtc from parameters MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-2-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4108; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=MfhwABS17LHUoJ+jq0vYojOPf4se4zR6qFsIZKDDr88=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDquZQ5+AoQGUj3+2cFFoN4u9cdx+UkSdRXs xj7OCwvdhGJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6gAKCRAgrS7GWxAs 4stqD/9mwWDPROPr03dSkdO8YCxBmJEv6IrxBZtDYGxCC8RyLOaghd59KJYilvHzepIsw1xTTQk cees94xvHFZaHmaeKQAFfh8VKE0wr1cMBz1+z1Efy8/Xta9QFR1mXYjlztblF196GSeBHZoftLD 8GYYLMfkR1SVACsxCx3nHJTK81YB39F5J8CypeKtObWtAC2Isk1GK1a2nqQygAAUM/HjRsgCDKu NJjtmkGwdJ5bGKC1+iLO52MVP9KWEHpZURHy/vj4Mt4VotJLpfwz1yf9wDMVZZpr7A1HiMI7Z7p 3NbPmFZkvpEw/ojKhq33nR2EJ10vNxjy9u0WYCqQJSvEzWXNr7IpR00+PKDO54VcXeNIL0pQ44Z 2CGL3wvSKYg3k0+BxYukfVpcq2X7pN3T0lle/GyCbQAPZQfuMlPazy9ofw/jgVMCM8CvCXdlV/r s/oJXAFeC6lpKkXNINH64F2id+My4Uo9yayyFuG4cyKb06T9EJ29JzAMybvZNTBgztfZY6UdaHY f8qAm/9cMuDijz5zQlXS4p5jVqrPfKgwZR/NmlTcn0U9bdQvMffuP31iAdOnL4IpJM62IEwXENs NnrKoScH6Kzei++w3GlFKkm1orxiiWQGQ/opVz2lXb4Kfdz/3mqc0X/RN/c/TMbL85J++iZ/gTs mWbH+Y9Jx/2kyCQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As the crtc mask is dynamic, avoid hardcoding it. It is already computed once all the planes are created, so it should be a no-op Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.c | 10 +++++----- drivers/gpu/drm/vkms/vkms_plane.c | 5 +++-- drivers/gpu/drm/vkms/vkms_plane.h | 4 +--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 7ac3ab7e16e5..e71b45fcb9b8 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -166,7 +166,7 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { .get_modes = vkms_conn_get_modes, }; -static int vkms_output_init(struct vkms_device *vkmsdev, int possible_crtc) +static int vkms_output_init(struct vkms_device *vkmsdev) { struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; @@ -184,20 +184,20 @@ static int vkms_output_init(struct vkms_device *vkmsdev, int possible_crtc) * The overlay and cursor planes are not mandatory, but can be used to perform complex * composition. */ - primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, possible_crtc); + primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY); if (IS_ERR(primary)) return PTR_ERR(primary); if (vkmsdev->config->overlay) { for (n = 0; n < NUM_OVERLAY_PLANES; n++) { - overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY, possible_crtc); + overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY); if (IS_ERR(overlay)) return PTR_ERR(overlay); } } if (vkmsdev->config->cursor) { - cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, possible_crtc); + cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR); if (IS_ERR(cursor)) return PTR_ERR(cursor); } @@ -284,7 +284,7 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev) dev->mode_config.preferred_depth = 0; dev->mode_config.helper_private = &vkms_mode_config_helpers; - return vkms_output_init(vkmsdev, 0); + return vkms_output_init(vkmsdev); } static int vkms_create(struct vkms_config *config) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index e549c9523a34..b5740c27180b 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -222,12 +223,12 @@ static const struct drm_plane_helper_funcs vkms_plane_helper_funcs = { }; struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type, int possible_crtc_index) + enum drm_plane_type type) { struct drm_device *dev = &vkmsdev->drm; struct vkms_plane *plane; - plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 1 << possible_crtc_index, + plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 0, &vkms_plane_funcs, vkms_formats, ARRAY_SIZE(vkms_formats), NULL, type, NULL); diff --git a/drivers/gpu/drm/vkms/vkms_plane.h b/drivers/gpu/drm/vkms/vkms_plane.h index 90554c9fe250..95b2428331b8 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.h +++ b/drivers/gpu/drm/vkms/vkms_plane.h @@ -52,11 +52,9 @@ struct vkms_frame_info { * * @vkmsdev: vkms device containing the plane * @type: type of plane to initialize - * @possible_crtc_index: Crtc which can be attached to the plane. The caller must ensure that - * possible_crtc_index is positive and less or equals to 31. */ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type, int possible_crtc_index); + enum drm_plane_type type); #define drm_plane_state_to_vkms_plane_state(target) \ container_of(target, struct vkms_plane_state, base.base) From patchwork Wed Aug 14 14:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B9F4C531DE for ; Wed, 14 Aug 2024 14:36:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 51F6810E4B9; Wed, 14 Aug 2024 14:36:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="C458gg2G"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id D374F10E4AC for ; Wed, 14 Aug 2024 14:36:33 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id AC08F1C000C; Wed, 14 Aug 2024 14:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h2GRQG3+68xpPpdmixJy2qEGneq+xdxw04MgwhZUFtM=; b=C458gg2GmZDtWcF8qOuprNuR098Rm8vK3L5MDTpl/1CRSwXgH5Y1XHAynS7QFNKMi9UrNJ Hniv6JW6iwor668Yrbcw6rG8xkC0/ct3+f4HT/7b0lki3j0mOi/8h9EwuhoBp9b1F//r0t 6npdxWWuP6eovNJ3iDGvdlyE0z+Xr5wNFmsGhhLA3/0548rS/POo5KA2S4aBHjFiJ1MYT1 EKlaizPipzAZvN/TjP0Gjkl5TbIAYCXWY5W3607LL9sLsn+IjyuWVKs83NGvVMMdvEqcAj xVW2ZTpTzXmix9VCrcH9gG8FVnbc5i1CPrhKdNdUTDIVoSNFyzN29O2Qrthbgg== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:25 +0200 Subject: [PATCH RFC 03/15] drm/vkms: Extract vkms_config header MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-3-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7229; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=V7P72XzOB4k0LOPzKgUwfRqs4e+ciILS7LbVX8zwFZs=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDq6PPu0VrIWlnaEBesNGvrZbbFATjh9YYcT 98NU2GHstyJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6gAKCRAgrS7GWxAs 4qbREADM8hMudEHHQuHnXmAfj3M29YIany3F1dIca4TfK8ywIS+9T6RiGHhrI1fTC+fqV6QqJts kZT08CJv+zsgwUN6cPLPMWMni1WoE/Gp4oDpQb5l86LtnsxZMPV+ITROgbHPuB0dLAuIGhJ/94y irvQVIIJhhseYWKcyX6AA8SgJV2B+jgh0d83eoqvfFhuDBPf9Az8Nf3iB6t1VcEuV1HJH/S7N+7 BQHuxK2oSGwWvObOd9YVDJoIBtEEYrAB9MGXcoS43Po2/ESa0r1fk8skLb2nnYlOZhEG0FJF3EM qKjC5q4Jc6NT6yh5dObtrS3rpmso+dF0TTKYEoJbKjb2BgtX6n2Fi6l1g/AkucN77jicr+o9eI1 ocUnABmqx7U2K2I9Ki256+LvhKLWVySuyNBb4rkQioOYUBth90esjY+TUCtosu6pBGM/bxjzne2 wB+L/9xCHlYokB0bkWIIscreVlv6SVfnIGN5dngf/ySQ7NxaNwuYhsxOwT3D7a1hicAyywiPCgo 7fV2qLv9cRt5aRMQ5n0iperN3qRPu7yt8G1S0YqDsKqeHO/V+4x51Fl/4FpiVAPTCQasQMNoDLI Wv5Rgc2GsvQWTf8qsjc8KcuguUdAdAJXnw8t8W5pHHTNVZeWAhGEiJZlAa4VdgaeRiWxr4x/Gju NiQdbNVcSLLqIAw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Creating a new vkms_config structure will be more complex once we start adding more options. Extract the vkms_config structure to its own header and source files and add functions to create and delete a vkms_config and to initialize debugfs. Refactor, no functional changes. Signed-off-by: Louis Chauvet [Changes: Cherry picked and conflict solve] Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/Makefile | 3 ++- drivers/gpu/drm/vkms/vkms_config.c | 45 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 32 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_drv.c | 41 ++++++++++------------------------ drivers/gpu/drm/vkms/vkms_drv.h | 15 +------------ 5 files changed, 91 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index 8d3e46dde635..2b6db5870b97 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -6,7 +6,8 @@ vkms-y := \ vkms_formats.o \ vkms_crtc.o \ vkms_composer.o \ - vkms_writeback.o + vkms_writeback.o \ + vkms_config.o obj-$(CONFIG_DRM_VKMS) += vkms.o obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += tests/ diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c new file mode 100644 index 000000000000..ad5d814e6e83 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "vkms_config.h" +#include "vkms_drv.h" + +struct vkms_config *vkms_config_create(void) +{ + struct vkms_config *config; + + config = kzalloc(sizeof(*config), GFP_KERNEL); + if (!config) + return ERR_PTR(-ENOMEM); + + return config; +} + +void vkms_config_destroy(struct vkms_config *config) +{ + kfree(config); +} + +static int vkms_config_show(struct seq_file *m, void *data) +{ + struct drm_debugfs_entry *entry = m->private; + struct drm_device *dev = entry->dev; + struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); + + seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); + seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor); + seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay); + + return 0; +} + +static const struct drm_debugfs_info vkms_config_debugfs_list[] = { + { "vkms_config", vkms_config_show, 0 }, +}; + +void vkms_config_register_debugfs(struct vkms_device *vkms_device) +{ + drm_debugfs_add_files(&vkms_device->drm, vkms_config_debugfs_list, + ARRAY_SIZE(vkms_config_debugfs_list)); +} diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h new file mode 100644 index 000000000000..b28483173874 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_CONFIG_H +#define _VKMS_CONFIG_H + +#include +#include "vkms_drv.h" + +/** + * struct vkms_config - General configuration for VKMS driver + * + * @writeback: If true, a writeback buffer can be attached to the CRTC + * @cursor: If true, a cursor plane is created in the VKMS device + * @overlay: If true, NUM_OVERLAY_PLANES will be created for the VKMS device + * @dev: Used to store the current vkms device. Only set when the device is instancied. + */ +struct vkms_config { + bool writeback; + bool cursor; + bool overlay; + struct vkms_device *dev; +}; + +/** + * vkms_config_register_debugfs() - Register the debugfs file to display current configuration + */ +void vkms_config_register_debugfs(struct vkms_device *vkms_device); + +struct vkms_config *vkms_config_create(void); +void vkms_config_destroy(struct vkms_config *config); + +#endif //_VKMS_CONFIG_H diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index e71b45fcb9b8..dbdb1f565a8f 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -28,6 +28,7 @@ #include "vkms_drv.h" #include "vkms_crtc.h" +#include "vkms_config.h" #include #include @@ -85,22 +86,6 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) drm_atomic_helper_cleanup_planes(dev, old_state); } -static int vkms_config_show(struct seq_file *m, void *data) -{ - struct drm_debugfs_entry *entry = m->private; - struct drm_device *dev = entry->dev; - struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); - - seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); - seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor); - seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay); - - return 0; -} - -static const struct drm_debugfs_info vkms_config_debugfs_list[] = { - { "vkms_config", vkms_config_show, 0 }, -}; static const struct drm_driver vkms_driver = { .driver_features = DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM, @@ -325,8 +310,7 @@ static int vkms_create(struct vkms_config *config) if (ret) goto out_unregister; - drm_debugfs_add_files(&vkms_device->drm, vkms_config_debugfs_list, - ARRAY_SIZE(vkms_config_debugfs_list)); + vkms_config_register_debugfs(vkms_device); ret = drm_dev_register(&vkms_device->drm, 0); if (ret) @@ -344,21 +328,18 @@ static int vkms_create(struct vkms_config *config) static int __init vkms_init(void) { int ret; - struct vkms_config *config; - - config = kmalloc(sizeof(*config), GFP_KERNEL); - if (!config) - return -ENOMEM; - default_config = config; + default_config = vkms_config_create(); + if (IS_ERR(default_config)) + return PTR_ERR(default_config); - config->cursor = enable_cursor; - config->writeback = enable_writeback; - config->overlay = enable_overlay; + default_config->cursor = enable_cursor; + default_config->writeback = enable_writeback; + default_config->overlay = enable_overlay; - ret = vkms_create(config); + ret = vkms_create(default_config); if (ret) - kfree(config); + vkms_config_destroy(default_config); return ret; } @@ -386,7 +367,7 @@ static void __exit vkms_exit(void) if (default_config->dev) vkms_destroy(default_config); - kfree(default_config); + vkms_config_destroy(default_config); } module_init(vkms_init); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 08d0ef106e37..64574695f655 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -25,20 +25,7 @@ #define VKMS_LUT_SIZE 256 -/** - * struct vkms_config - General configuration for VKMS driver - * - * @writeback: If true, a writeback buffer can be attached to the CRTC - * @cursor: If true, a cursor plane is created in the VKMS device - * @overlay: If true, NUM_OVERLAY_PLANES will be created for the VKMS device - * @dev: Used to store the current vkms device. Only set when the device is instancied. - */ -struct vkms_config { - bool writeback; - bool cursor; - bool overlay; - struct vkms_device *dev; -}; +struct vkms_config; /** * struct vkms_device - Description of a vkms device From patchwork Wed Aug 14 14:36:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51080C52D7B for ; Wed, 14 Aug 2024 14:36:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D545E10E4AE; Wed, 14 Aug 2024 14:36:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="X6J02Nz3"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id E651710E4AC for ; Wed, 14 Aug 2024 14:36:34 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id B76161C000B; Wed, 14 Aug 2024 14:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zlMFKXhNy+QFNkiK0joc1nv/SfFzfMcnr1sereJaSMs=; b=X6J02Nz3n2BflHni7sipfFKg7daLubwcy+5ZXOyeoh9yCbqFT/9L7mPiMCnVT/9uoMlM+h 4h5yl9STXBFFLXIiGGq/t0BrOL8gkfG1F/Y6v2P4bVDdIxn7vcnHzaonMTH9ub8uuh9uRn BrNKQgvEG/AhBEJauYjnkfjqiWc3Uw3hJjF7i5C2kmZatRNY7qeGnFAE1FyVQHKX39LXwf XwDku/VGAr6iUEgxopDLjyD1d8U0f5fWkNthymdXD9mBYJZciN9BDyyUitUHl04oGr3QBs 6LWQvk9giCnY/3tylERnIU+/vz4dtOsom7C5vWWUkfW9EotaCyRxoBHJXV0wyg== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:26 +0200 Subject: [PATCH RFC 04/15] drm/vkms: Add a validation function for vkms configuration MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-4-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1731; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=k7I96F7fMqbLXLeLk7zFFk8rPM2kYDQilJV7tZIaSXM=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDqcjf8hNFzSHEsjIFpOkdKSbr2Zb+Illq2/ Lz3M5mZo8CJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6gAKCRAgrS7GWxAs 4u6+D/9X3Kjuc5A5W9Lp00RntaOrtOOO76OkBUCrm5i8YJ9Kupap4BDAycCpD6fTyFVLqipz93X qLSu2oFLXzxaCfqgByXJKrCv5l1Xeu1RdGJuO/Qk/TiZM0wqOggwX+/s3K0QA5j6Iz7VT7sMZhX ywWWIkDFE8lYUx89p8FKNS+stC8HTQIVD2G/A/YnhMVsZISLXb2aRulGCbX8zWIK1WGjleWDYGl 5YrJ0BJMHi5BBRl3Rhm8s+zpUSEPRKnDirT6CqOBKI3QtRREmrMb3OvZFv6JdynWXU5bo1OCKcg R86QOhfQyvFov9lJKDXMLYKLnX9cXxHyHXuhp2a3MKmPH2CdBX0AcI2s0zbeMgeElgT/ReGKE37 py88o7S/Prd3X4XhuwxzNRkUaEJJk8V4cTWz+CAG1DHpSClpdKDeP2TEDQL0VhS8S8too/H9vqd xMWB1+9A+k55LFmh6and/1MFPgF4OL2BVJuB+DL6j1zK15JMwEKbPQBf5wTNdxpgPSZpTofz535 VEfB0fEDXiD0xfnfDyBbCF+dW5uUQ/jsn6Q15bvOee5XIbX3xCR7Bu/bwxE1H96IkPx4Q/oE/Vw leF1zvyHTdMu8h/PAKGv6sy9jiZWmnby1uaPP6eMJHhPVhI9FKvm8P4KDHx88jD0qrgpWRXdpBl oK9TOCYYe6x+/Sg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As the configuration will be used by userspace, add a validator to avoid creating a broken DRM device Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 5 +++++ drivers/gpu/drm/vkms/vkms_config.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index ad5d814e6e83..d8348af9587e 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -21,6 +21,11 @@ void vkms_config_destroy(struct vkms_config *config) kfree(config); } +bool vkms_config_is_valid(struct vkms_config *config) +{ + return true; +} + 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 b28483173874..363f5bc8f64b 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -29,4 +29,18 @@ void vkms_config_register_debugfs(struct vkms_device *vkms_device); struct vkms_config *vkms_config_create(void); void vkms_config_destroy(struct vkms_config *config); +/** + * vkms_config_is_valid() - Validate a configuration + * + * Check if all the property defined in the configuration are valids. This will return false for + * example if: + * - no or many primary planes are present; + * - the default rotation of a plane is not in its supported rotation; + * - a CRTC don't have any encoder... + * + * @vkms_config: Configuration to validate + */ +bool vkms_config_is_valid(struct vkms_config *vkms_config); + + #endif //_VKMS_CONFIG_H From patchwork Wed Aug 14 14:36:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E8DDC531DD for ; Wed, 14 Aug 2024 14:36:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 47C8C10E4B3; Wed, 14 Aug 2024 14:36:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="N8hkJupm"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id D36FA10E4AC for ; Wed, 14 Aug 2024 14:36:35 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id ABA961C0009; Wed, 14 Aug 2024 14:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0gGkNGJMzZViUMrQFxHqtTa4PKI8hM4Nr9e+8KnU9Ck=; b=N8hkJupmXvzURO5c1YBNRAT+vUTz60dVFana44g3+2uN5ecaWhul6r9+/I0C6LD8tAIWKi WmUAanFFOznSw0c7bS0J+Po9lv+FZS85BNs+Nm1SLCcXnB88eP1INqsyR6RbQ9Yl2jDcs1 QlW2rpJOEY7CajS8U4XqSJItLOOh04agxxPnBG0qa0VIAWetSDebR/xa9Si6NVMbmXRuC8 bTQyOKnroPJtE05+flkPeQdAajDZKfv6wJJI/yAndvTQ17RF1M9xJowqOl+aP0NbupMq7Q CpCyLmIzKzrOckHXyhvdWy2kg3UpRwhPgvcJPzN695aaKhfUDb/D6AiNgQtZNA== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:27 +0200 Subject: [PATCH RFC 05/15] drm/vkms: Move default_config creation to its own function MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-5-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2836; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=eoc3G8Sjl8nrWI19alC5LCkl998LvHQCHg6UVKRKeXA=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDq8uWzI7dOx+vw/of7Iu7jWUg6t9LR0ieff obWSDZUJaCJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6gAKCRAgrS7GWxAs 4sjED/43s19ysPK+BTYVWwULWU0Bz3OWjgm/5+urxVXoSBaUZdT3lhF6S1tH1DkV0xe7ftKpJbO 9t/XAXd62UAls5k4NTCWan5coh2tsV+MwiYmmzYVAGiBdzN9HUyRUlpyssjQM+iQKZlvStrSwRL E04uZRVDVIY8j801rG3KjKA+LSWUNbuPI0dXhXXCTneJjld3VSLexZVaq2+wqKlXc16jqUVADiI RkO+Yg9wn54Nzd0Q46TIglgIne/quzxGJ8LCp2KpVYKGxTuEsYa62ixaEQ1GhsE/U5KAL2a72Cz z5Ih8EzVnX2qEDKFyrzWjkOs4O6jFiiZcRjjVkZTGhM23fYjiInxnlHuAplf14WcxFNvPABI9OT YPjGPA4GmNCTLIiEEI8FD1VjIcDOFJJGpetVVVCaPZpvx8wuuQSsY1GlgHMAPAagWWDJZ0CVK+3 83Qe9DRoJd5v5LQ8dO+RRlggLx8TDi4Si+9qqEAj39DD3645s9hrdRsNHIm77ZJgcZg7deXv+me ovJhTqUnnWZKxAsqPpJBQcOUg2nEFb7zqgY/X3J3xU9IU1w/Qq24emrqUffhg2Apv4C5muGqmCO /tVgsQckX/KuUkzacCYAsRoWuDM2K47E4c5vSl0Ug4wALL3mu2SGX/6ykF1j8m83SG0ys1dlEoM 01wEvqHZRlXOdcQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Extract the initialization of the default configuration to a function. Refactor, no functional changes. Signed-off-by: Louis Chauvet [Changes: Cherry pick and solve conflicts] Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_config.c | 16 ++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 9 +++++++++ drivers/gpu/drm/vkms/vkms_drv.c | 7 +------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index d8348af9587e..27b49a2ad9c8 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -16,6 +16,22 @@ struct vkms_config *vkms_config_create(void) return config; } +struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable_overlay, + bool enable_cursor) +{ + struct vkms_config *vkms_config = vkms_config_create(); + + if (IS_ERR(vkms_config)) + return vkms_config; + + vkms_config->writeback = enable_writeback; + vkms_config->overlay = enable_overlay; + vkms_config->cursor = enable_cursor; + + return vkms_config; +} + + void vkms_config_destroy(struct vkms_config *config) { kfree(config); diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 363f5bc8f64b..50c3b021a66b 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -43,4 +43,13 @@ void vkms_config_destroy(struct vkms_config *config); bool vkms_config_is_valid(struct vkms_config *vkms_config); +/** + * vkms_config_alloc_default() - Allocate the configuration for the default device + * @enable_writeback: Enable the writeback connector for this configuration + * @enable_overlay: Create some overlay planes + * @enable_cursor: Create a cursor plane + */ +struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable_overlay, + bool enable_cursor); + #endif //_VKMS_CONFIG_H diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index dbdb1f565a8f..af237daa3c5c 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -328,15 +328,10 @@ static int vkms_create(struct vkms_config *config) static int __init vkms_init(void) { int ret; - - default_config = vkms_config_create(); + default_config = vkms_config_alloc_default(enable_writeback, enable_overlay, enable_cursor); if (IS_ERR(default_config)) return PTR_ERR(default_config); - default_config->cursor = enable_cursor; - default_config->writeback = enable_writeback; - default_config->overlay = enable_overlay; - ret = vkms_create(default_config); if (ret) vkms_config_destroy(default_config); From patchwork Wed Aug 14 14:36:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 902DAC3DA4A for ; Wed, 14 Aug 2024 14:36:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D290A10E4B1; Wed, 14 Aug 2024 14:36:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="GFTHlHcd"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id D7C0C10E4AF for ; Wed, 14 Aug 2024 14:36:36 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id B3E191C000F; Wed, 14 Aug 2024 14:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wftNDmHqRzwOoleVY8/nmCBsAAj3VFWoTG4QPHJxvfs=; b=GFTHlHcd7RcvU9ksS5f/cbKthq3wc7ML+WTlXSRiqpRQQL8UHiv08qXBG2iG4iXeDerZgo askisTm4YR2If0w4SP7OIhs1h28MfVZCXhVJNCReqwArNVuXEKgVXpPLbVULQ4G6xy5RmD LX5L1h+hHzb+2cErBU47ZpS+Ivi9UBvJZB5TdZE+OgwF9LcowWRasX1aiB+//Bq+KvIzS/ SmqnGc7wV4LHhCc5lTcDkdiEgOOxq+HjKrlPyQN3aHZ2KgOiaGhJUmoa5+gpsFtCvjjokc FT1j7OAMIoyIM7PCPduZoKeXV6tB41SIYw7IXnaloUOYpRbsnDycthYHUj+Rhg== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:28 +0200 Subject: [PATCH RFC 06/15] drm/vkms: Introduce plane configuration MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-6-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=10299; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=aB8xMB4+876GsvcKZ9oy6yejZUx8h23D4RX0/e+YEU4=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDqBeUn7g4JH1LZAaBa9pbWQpWMEqNUuSdIP F8M/ifRFpGJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6gAKCRAgrS7GWxAs 4hujD/9SzbmsaMisWiyw5nmoNFyzb//632QUNDKuf9Kajyo/3WKF8bChPT5PWO1UrCMGjaqaCbt dYemH12P3hXYKcP6FlMCbBZBe3Q+UU+nTHOtxsWz8MVgmwiM73oai8ULXtIWFZ74zc4pL2DFoHU 5L5tjp4D8GfBfJDA3CoJpr/HshXWO79Tc/IoJQgKOXvsM/41OkNZ4T+Yvn2wlZVCfGdL/61Nfag 65pvbBBjBZWkq2XrLOzqVIUY36hiPSC2ke/dhQciCmpGhH+NPygvz73G33eIOd/feZBGC56PK2F vskrs5usz0npM4BMeW9HUagZpwqyFVxoEmeHKOFzVWMygXG32WyTynWvf5je1W2VwPfqmuJFq30 c92KxQNUKkjRJdQ5PAL/YkfMsM6qKhX3HjXVSJlhM50GbejKj/WjT8IUYuoJDHSEUERnFGz59La xFLk02rsgAcfkfAGC6Lq69KnuZxMR1Z3hCd7A7DSg0dR5F0m0XDmL9AANsvzpVpZIrWnFDKm9zo w7PO9KalZzH2RDykBBGxknJC/5TUS7s+JSUV7VDuhsxDfy3JRpwDQi/OQoxrGzqoQmNfnavRUE2 n+86rsiyanKFS6ActgnmY6R63fpNfHACZB+QN5zeqwbo2tpeEsOBisJc8XnaQCPJd3G7Dq8AaYS jaCUfNtWr0VxECg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current vkms driver only allows the usage of one primary, eight overlays and one cursor plane. This new configuration structure aims to make the configuration more flexible. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 90 ++++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_config.h | 44 +++++++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.c | 33 +++++--------- drivers/gpu/drm/vkms/vkms_plane.c | 4 +- drivers/gpu/drm/vkms/vkms_plane.h | 3 +- 5 files changed, 141 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 27b49a2ad9c8..b1c6160d350f 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -13,32 +13,111 @@ struct vkms_config *vkms_config_create(void) if (!config) return ERR_PTR(-ENOMEM); + INIT_LIST_HEAD(&config->planes); + return config; } struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable_overlay, bool enable_cursor) { + struct vkms_config_plane *plane; struct vkms_config *vkms_config = vkms_config_create(); if (IS_ERR(vkms_config)) return vkms_config; vkms_config->writeback = enable_writeback; - vkms_config->overlay = enable_overlay; - vkms_config->cursor = enable_cursor; + + plane = vkms_config_create_plane(vkms_config); + if (!plane) + goto err_alloc; + + plane->type = DRM_PLANE_TYPE_PRIMARY; + + if (enable_overlay) { + for (int i = 0; i < NUM_OVERLAY_PLANES; i++) { + plane = vkms_config_create_plane(vkms_config); + if (!plane) + goto err_alloc; + plane->type = DRM_PLANE_TYPE_OVERLAY; + } + } + if (enable_cursor) { + plane = vkms_config_create_plane(vkms_config); + if (!plane) + goto err_alloc; + plane->type = DRM_PLANE_TYPE_CURSOR; + } return vkms_config; +err_alloc: + vkms_config_destroy(vkms_config); + return ERR_PTR(-ENOMEM); } +struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_config) +{ + if (!vkms_config) + return NULL; + + struct vkms_config_plane *vkms_config_overlay = kzalloc(sizeof(*vkms_config_overlay), + GFP_KERNEL); + + if (!vkms_config_overlay) + return NULL; + + vkms_config_overlay->type = DRM_PLANE_TYPE_OVERLAY; + + list_add(&vkms_config_overlay->link, &vkms_config->planes); + + return vkms_config_overlay; +} + +void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_overlay) +{ + if (!vkms_config_overlay) + return; + list_del(&vkms_config_overlay->link); + kfree(vkms_config_overlay); +} void vkms_config_destroy(struct vkms_config *config) { + struct vkms_config_plane *vkms_config_plane, *tmp_plane; + + list_for_each_entry_safe(vkms_config_plane, tmp_plane, &config->planes, link) { + vkms_config_delete_plane(vkms_config_plane); + } + kfree(config); } bool vkms_config_is_valid(struct vkms_config *config) { + struct vkms_config_plane *config_plane; + + bool has_cursor = false; + bool has_primary = false; + + list_for_each_entry(config_plane, &config->planes, link) { + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { + // Multiple primary planes for only one CRTC + if (has_primary) + return false; + has_primary = true; + } + if (config_plane->type == DRM_PLANE_TYPE_CURSOR) { + // Multiple cursor planes for only one CRTC + if (has_cursor) + return false; + has_cursor = true; + } + } + + if (!has_primary) + return false; + return true; } @@ -47,10 +126,13 @@ static int vkms_config_show(struct seq_file *m, void *data) struct drm_debugfs_entry *entry = m->private; struct drm_device *dev = entry->dev; struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); + struct vkms_config_plane *config_plane; seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); - seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor); - seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay); + list_for_each_entry(config_plane, &vkmsdev->config->planes, link) { + seq_puts(m, "plane:\n"); + seq_printf(m, "\ttype: %d\n", config_plane->type); + } return 0; } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 50c3b021a66b..77c1c3934189 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -10,15 +10,34 @@ * struct vkms_config - General configuration for VKMS driver * * @writeback: If true, a writeback buffer can be attached to the CRTC - * @cursor: If true, a cursor plane is created in the VKMS device - * @overlay: If true, NUM_OVERLAY_PLANES will be created for the VKMS device + * @planes: List of planes configured for this device. They are created by the function + * vkms_config_create_plane(). * @dev: Used to store the current vkms device. Only set when the device is instancied. */ struct vkms_config { bool writeback; - bool cursor; - bool overlay; struct vkms_device *dev; + + struct list_head planes; +}; + +/** + * struct vkms_config_plane + * + * @link: Link to the others planes + * @type: Type of the plane. The creator of configuration needs to ensures that at least one + * plane is primary. + * @plane: Internal usage. This pointer should never be considered as valid. It can be used to + * store a temporary reference to a vkms plane during device creation. This pointer is + * not managed by the configuration and must be managed by other means. + */ +struct vkms_config_plane { + struct list_head link; + + enum drm_plane_type type; + + /* Internal usage */ + struct vkms_plane *plane; }; /** @@ -42,6 +61,23 @@ void vkms_config_destroy(struct vkms_config *config); */ bool vkms_config_is_valid(struct vkms_config *vkms_config); +/** + * vkms_config_create_plane() - Create a plane configuration + * + * This will allocate and add a new plane to @vkms_config. This plane will have by default the + * maximum supported values. + * @vkms_config: Configuration where to insert new plane + */ +struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_config); + +/** + * vkms_config_delete_plane() - Remove a plane configuration and frees its memory + * + * This will delete a plane configuration from the parent configuration. This will NOT + * cleanup and frees the vkms_plane that can be stored in @vkms_config_plane. + * @vkms_config_plane: Plane configuration to cleanup + */ +void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane); /** * vkms_config_alloc_default() - Allocate the configuration for the default device diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index af237daa3c5c..403006a0bb61 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -153,38 +153,27 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { static int vkms_output_init(struct vkms_device *vkmsdev) { + struct vkms_config_plane *config_plane; struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; struct drm_encoder *encoder; struct vkms_crtc *crtc; struct drm_plane *plane; - struct vkms_plane *primary, *cursor, *overlay = NULL; + struct vkms_plane *primary, *cursor = NULL; int ret; int writeback; - unsigned int n; - /* - * Initialize used plane. One primary plane is required to perform the composition. - * - * The overlay and cursor planes are not mandatory, but can be used to perform complex - * composition. - */ - primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY); - if (IS_ERR(primary)) - return PTR_ERR(primary); - - if (vkmsdev->config->overlay) { - for (n = 0; n < NUM_OVERLAY_PLANES; n++) { - overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY); - if (IS_ERR(overlay)) - return PTR_ERR(overlay); + list_for_each_entry(config_plane, &vkmsdev->config->planes, link) { + config_plane->plane = vkms_plane_init(vkmsdev, config_plane); + if (IS_ERR(config_plane->plane)) { + ret = PTR_ERR(config_plane->plane); + return ret; } - } - if (vkmsdev->config->cursor) { - cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR); - if (IS_ERR(cursor)) - return PTR_ERR(cursor); + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) + primary = config_plane->plane; + else if (config_plane->type == DRM_PLANE_TYPE_CURSOR) + cursor = config_plane->plane; } /* [1]: Initialize the crtc component */ diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index b5740c27180b..dc9bccf60071 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -223,7 +223,7 @@ static const struct drm_plane_helper_funcs vkms_plane_helper_funcs = { }; struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type) + struct vkms_config_plane *config) { struct drm_device *dev = &vkmsdev->drm; struct vkms_plane *plane; @@ -231,7 +231,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 0, &vkms_plane_funcs, vkms_formats, ARRAY_SIZE(vkms_formats), - NULL, type, NULL); + NULL, config->type, NULL); if (IS_ERR(plane)) return plane; diff --git a/drivers/gpu/drm/vkms/vkms_plane.h b/drivers/gpu/drm/vkms/vkms_plane.h index 95b2428331b8..82049966ee7e 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.h +++ b/drivers/gpu/drm/vkms/vkms_plane.h @@ -9,6 +9,7 @@ #include #include "vkms_formats.h" +#include "vkms_config.h" struct vkms_plane { struct drm_plane base; @@ -54,7 +55,7 @@ struct vkms_frame_info { * @type: type of plane to initialize */ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type); + struct vkms_config_plane *config); #define drm_plane_state_to_vkms_plane_state(target) \ container_of(target, struct vkms_plane_state, base.base) From patchwork Wed Aug 14 14:36:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07FA6C52D7D for ; Wed, 14 Aug 2024 14:36:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 73A4E10E4AF; Wed, 14 Aug 2024 14:36:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="MXGRxFmD"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB90810E4AF for ; Wed, 14 Aug 2024 14:36:37 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id B0DD11C0010; Wed, 14 Aug 2024 14:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dRWAqKA456PEAxWaDDwcuxE5W1Q6ZbfOxo+io/+QmQI=; b=MXGRxFmDKodAsLwrwTUu4iPTbsj2NEo1/e7JBsbVWwxHdYePzbO2xzWiMhORdW2/LEFhlK 24YyiXLfp/9FLM507t//+mcDt5j1F7RetDpAQXZDVIa6TPnnePhFRkxb5wAKdsYRFNGdLI uqy9eExBHM3N4aUjjf+m+ilFfQoQ88nHyIG5OEWBHg+zqEmT77RJGjdEaW3KgZLi8K15+m Wz5HHl9HzddhZFtH4qwx1PATxLXBqgBEt+15AojBBURFhrRlDKqJpzXCbWnTqle5xmPVbD zasURkafKpks/m9NGgSQ8jV/47ASyku2HUTK/8gRywtA7aZ6ZWnTG9tVj6iZ/g== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:29 +0200 Subject: [PATCH RFC 07/15] drm/vkms: Introduce plane name configuration MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-7-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3609; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=+iZgtQZR6Ktwhu+GqlUxVEhFVxw8MKckjIPLA9mX6qQ=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDq9ALWKsv6owkvIaNijjmwfjKqyqMgB/cPv aahY4LqckWJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6gAKCRAgrS7GWxAs 4jSiEACvx0hwL19ubQAsK6eB+31JSMV19Bd+CWgIZGO5k8/Votg/z64EMbBu7SRnTSTBjD6PAS/ i//b9thOQcDdJvoJtjeA6ATniGI+fmctOQ7KEZ6BgE3tlpBbeY5LnorbffgGVj3m2vCuUEXVJNe LejOupotcvKpB9bAt27IglJenV1lXfM1gFrxKk4gMYezFVnXvAOxvfuZYrhl8Zb86lgh4I0Gqpj fxpM0BLQV5lFqqnPPHqmAL7E0zsfmJWw01QzNkvhEDWdwnJxYWi5qNY/CCIZU5Lf40bI/bb6Xss Ccuzv0dptIh9q73oq9XVERgzhoxmia+lfuAMewDNW73SH9OJ90NrMUYhWoq03fXVDQ78lLFUz5V 543ReTkXJ4BP+RiAgeIlxQwGaQgHUZgIdr60KvQ/O99CVkmrAtIohkuaf3SPTf8RZ/QBZRQ4cjG XEUmlmEBOQtBYDGtR7csWjGQ9PB+goaqv3BS7rAtW7f+/kM1xjmRGHHhHVbd63vVdDpnE8QeUpr 71d0eu6PrD9bC5ahp9UxlbOHtuSRERaoA0nYGMV2ZgVYUPZFWq7Wz0eRzsVWrQbGCSDEUn49Iom qqrQrJQocBHELeYpONibwf5/f/xWr1HDEzfyM4S6tc+LpOm4d+1wejwUFc7v/A1UwRlohRvQ3MQ jWLzRPsPYV8tLQA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As a plane will be a folder in ConfigFS, add name configuration for plane so it will reflect the folder name. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 14 ++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 2 ++ drivers/gpu/drm/vkms/vkms_plane.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index b1c6160d350f..b8e235a22e90 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -34,6 +34,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable goto err_alloc; plane->type = DRM_PLANE_TYPE_PRIMARY; + plane->name = kzalloc(sizeof("primary"), GFP_KERNEL); + if (!plane->name) + goto err_alloc; + sprintf(plane->name, "primary"); if (enable_overlay) { for (int i = 0; i < NUM_OVERLAY_PLANES; i++) { @@ -41,6 +45,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!plane) goto err_alloc; plane->type = DRM_PLANE_TYPE_OVERLAY; + plane->name = kzalloc(10, GFP_KERNEL); + if (!plane->name) + goto err_alloc; + snprintf(plane->name, 10, "plane-%d", i); } } if (enable_cursor) { @@ -48,6 +56,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!plane) goto err_alloc; plane->type = DRM_PLANE_TYPE_CURSOR; + plane->name = kzalloc(sizeof("cursor"), GFP_KERNEL); + if (!plane->name) + goto err_alloc; + sprintf(plane->name, "cursor"); } return vkms_config; @@ -79,6 +91,7 @@ void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_overlay) if (!vkms_config_overlay) return; list_del(&vkms_config_overlay->link); + kfree(vkms_config_overlay->name); kfree(vkms_config_overlay); } @@ -131,6 +144,7 @@ static int vkms_config_show(struct seq_file *m, void *data) seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); list_for_each_entry(config_plane, &vkmsdev->config->planes, link) { seq_puts(m, "plane:\n"); + seq_printf(m, "\tname: %s\n", config_plane->name); seq_printf(m, "\ttype: %d\n", config_plane->type); } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 77c1c3934189..792c5e904aa1 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -25,6 +25,7 @@ struct vkms_config { * struct vkms_config_plane * * @link: Link to the others planes + * @name: Name of the plane * @type: Type of the plane. The creator of configuration needs to ensures that at least one * plane is primary. * @plane: Internal usage. This pointer should never be considered as valid. It can be used to @@ -34,6 +35,7 @@ struct vkms_config { struct vkms_config_plane { struct list_head link; + char *name; enum drm_plane_type type; /* Internal usage */ diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index dc9bccf60071..d2b1b524499f 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -231,7 +231,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 0, &vkms_plane_funcs, vkms_formats, ARRAY_SIZE(vkms_formats), - NULL, config->type, NULL); + NULL, config->type, config->name); if (IS_ERR(plane)) return plane; From patchwork Wed Aug 14 14:36:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3937CC52D7D for ; Wed, 14 Aug 2024 14:36:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8264110E4B0; Wed, 14 Aug 2024 14:36:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="OWddzPar"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id DDF7310E4AF for ; Wed, 14 Aug 2024 14:36:38 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id A9E3C1C000D; Wed, 14 Aug 2024 14:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LK1EgB/4twCKJpxkgjhlb8wicG63JKzh5KKMfEjM5zI=; b=OWddzParWxfSNCFFG52mbmKIMer+fpp7rc3t/kiid0ciSF3/49tQ6bgBleLx7gSUCwgYQH 9E8czTE3yzCT7VO4WNFQa7kqmQYjggLmvLxVX38wZFgYTapWubAdkNa16frhZ4aVI1wbCX DMtfpEJgGAJf+/y1TYrEYrbzXe/P0/0Z8Au6ZBDqZW4u0tnSXDM+UUa0Qiu3ayzWxlB84K Aq/NajZ4mH2DMJt0AABg++n7KNS57VEkmrHRDbJ/1SpNA+3phhHgQQ4xOq024CNuFU/+AH NP6vs8Pqz7JNypgmkx2h0sz+rLCwOLVGWQmV9pMa0YMEExoiOJys/iTL0AJ4GA== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:30 +0200 Subject: [PATCH RFC 08/15] drm/vkms: Introduce plane rotation configuration MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-8-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3736; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=c5MBjt3UhZKnqUp2mCLTQStcuKGhOS2gJkqsBSwtG/g=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDqLAJ4ql/Jqx4j92ZfOLMCDhYcIhl+dMs/I GdY7mxB2LuJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6gAKCRAgrS7GWxAs 4nHJD/96MjTVqDlBQ7p9Pnos9sm5CF5QqCW2vCy58KMUreLa1mtrMcvLBjNDWId8zH5VkAdTb0U GSIV4rgn66I75kObPlLdH3mV8/Whqgy4ZSnHz5T77xJhqHi13olATeaXZCcJYcSDDY5CfXuMBUQ MrmgLMO1N9Uw7F8Pfp3KQIS6jmmooqkuPEdiZ3Wp29yIsnjrYe0C3dFmBhHcq8ovP52aMlWmGCK NNTxYFnvj1/O3tD+svIDd8SncFC4xkG4Yt/r2rTj11sjUHh/WNuut9vlXB4Vpk+CetJfFnpA9Sg 8r/SK+WItJKG+irijTX1IOgzhO/lzNGfEb6C9N7DsOv6+dlJ+srS/Y6q58i4hSFx6kL+A02xJ6g g9VCpgZyplDJpMrjTesftp6oeLGcsQb33lnToYuDRrchracK+Efh1lmpLuUp8Syo6AIvVeXo6Yw oJTHkEhZa4kX1P0qkbilKXk9730zVovf6kJrhQxHUHrl5zeUTpcsNNIHBEWFPh2eAIaFuUEvtKq yn5sqz+zM4wZnn2RB11cCTpL6UnldIJvWOel8p/t2aRhsNWtr7eKc7+aynpwQehx2nPeQ13T90I Gq5QT/N6krGXm6Ays0RgeKNpKGyEe4nO/DiH7xKh7TXvOz6CqJhGK1r/X4HwQwFXSjrt96cnxA3 CKIBHqrrKN5aQkg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" VKMS driver supports all the rotation on planes, but for testing it can be useful to only advertise few of them. This new configuration interface will allow configuring the rotation per planes. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 9 +++++++++ drivers/gpu/drm/vkms/vkms_config.h | 4 ++++ drivers/gpu/drm/vkms/vkms_plane.c | 5 +++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index b8e235a22e90..2a24da9c0fc9 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -80,6 +80,8 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf return NULL; vkms_config_overlay->type = DRM_PLANE_TYPE_OVERLAY; + vkms_config_overlay->supported_rotations = DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK; + vkms_config_overlay->default_rotation = DRM_MODE_ROTATE_0; list_add(&vkms_config_overlay->link, &vkms_config->planes); @@ -114,6 +116,11 @@ bool vkms_config_is_valid(struct vkms_config *config) bool has_primary = false; list_for_each_entry(config_plane, &config->planes, link) { + // Default rotation not in supported rotations + if ((config_plane->default_rotation & config_plane->supported_rotations) != + config_plane->default_rotation) + return false; + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { // Multiple primary planes for only one CRTC if (has_primary) @@ -146,6 +153,8 @@ static int vkms_config_show(struct seq_file *m, void *data) seq_puts(m, "plane:\n"); seq_printf(m, "\tname: %s\n", config_plane->name); seq_printf(m, "\ttype: %d\n", config_plane->type); + seq_printf(m, "\tsupported rotations: 0x%x\n", config_plane->supported_rotations); + seq_printf(m, "\tdefault rotation: 0x%x\n", config_plane->default_rotation); } return 0; diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 792c5e904aa1..77a72a3a637c 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -28,6 +28,8 @@ struct vkms_config { * @name: Name of the plane * @type: Type of the plane. The creator of configuration needs to ensures that at least one * plane is primary. + * @default_rotation: Default rotation that should be used by this plane + * @supported_rotation: Rotation that this plane will support * @plane: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms plane during device creation. This pointer is * not managed by the configuration and must be managed by other means. @@ -37,6 +39,8 @@ struct vkms_config_plane { char *name; enum drm_plane_type type; + unsigned int default_rotation; + unsigned int supported_rotations; /* Internal usage */ struct vkms_plane *plane; diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index d2b1b524499f..3a2b8b0b5980 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -237,8 +237,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_helper_add(&plane->base, &vkms_plane_helper_funcs); - drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, - DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK); + drm_plane_create_rotation_property(&plane->base, + config->default_rotation, + config->supported_rotations); drm_plane_create_color_properties(&plane->base, BIT(DRM_COLOR_YCBCR_BT601) | From patchwork Wed Aug 14 14:36:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6F74DC52D7B for ; Wed, 14 Aug 2024 14:36:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E35EC10E4B4; Wed, 14 Aug 2024 14:36:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="R8BbihmT"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id D700A10E4B2 for ; Wed, 14 Aug 2024 14:36:39 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id A1FB81C0011; Wed, 14 Aug 2024 14:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646198; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=exr93NbJHH1MlNSiTo8r2EJM59HebLID6gRxLw+2zrQ=; b=R8BbihmTed7j0v5zUZhIHIvmMbpwnJErHuffKS3/bRRRGXjNWq9VHrhK1dAcNg+kAbH2df ihdk03anLjK08GhQZRRz3Z/jJpv1rjtLSHJgJqA1IHlJmzRTxdY6moBTgHRFQb1KfXBCCs yLrRjsMMgeD6+RkxUqCtckZboqeWP9LEvGWH/dJCsxMxkVGqZt+jjN6ehqWnLNnMGlyzMN AgdlQaDWxmxjakLJ2evYzcly83Sl90r5R/+yCu2K6gBQfOrbfU20+2uDMgsSF0qKDf1jVO rBPNjs4e7CF8ErX90C76Fqz9adWLJCfc/4ryZYSBn0XGvk9mTBUW3M8s1Y2nzw== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:31 +0200 Subject: [PATCH RFC 09/15] drm/vkms: Introduce configuration for plane color encoding MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-9-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4266; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=roexYR8lijwFeTIa49SgBUoPN3tjM1s+BV+z3H4eZvQ=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDrPPw2Fuyl3KoFXT298AI8LDJ6IEG6Ak70T OevBVrEpBOJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6wAKCRAgrS7GWxAs 4r/bEADCmLzL4RFCr1UjfTq3vAQLCzYLM2TFMx99cBrPfBjpeEzjG0wyQ+KjSss1WKS+pntK/cJ 2LcmAOlLnYXrfmgxWad3XBKE3/b7UpdiYp+fc2gDWSu6HAG2fULmC05nKz0ScFhlToVCtFo7MVy iKOzzOqSmq2IGaRodMSK9aCNZ4I8SnObLx7N9wph5IqPl+B+jAlT5g4hmezIzOzI5/bDGZtJwBM cdhRvHWXv4Eh+wcYJD/xmv6NWLH5vjVuof8y5eFHj20psTc1rLyxk/tY21EKYuUknB3tSGua/Ho xXbJzpo5zykKOXDSoFuWf68qiEMhS7UGcc/sg3l00DhCazSVTDBNYxkH9E/ZYJtLYWhNiOc6fYE J43pQ71YtxijtoGVEiqc/3FtViJPNYLIy3z+tEANyQ59bEs1aOKw1EgZ8TQupXyaO9tTOhYFVQh te4TXlOmUtLjE+z50YoUY0AhTtcpL2QfYIekuhQtCK0s8gqrHJtYfuiiyhIaG+oioN4Bos32IfQ kDZ+8QLGWn0PdANODpoHchxnjhXjZDnIDHnZQfn+ir8NsLtQw3wWJJlKIuKAlmtZdnd+IMqtVx/ F7SSRJYGjpx0TdJaBeA0I6Q3v5V/WPai7t4N6W/AcSwreC2o7UopGs5sjH2K4IPY74EKC7wuhLZ 0AkGkH2+KylG9XQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" VKMS driver supports all the color encoding on planes, but for testing it can be useful to only advertise few of them. This new configuration interface will allow configuring the color encoding per planes. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 15 +++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 4 ++++ drivers/gpu/drm/vkms/vkms_plane.c | 6 ++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 2a24da9c0fc9..dabb8cb13314 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -82,6 +82,11 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf vkms_config_overlay->type = DRM_PLANE_TYPE_OVERLAY; vkms_config_overlay->supported_rotations = DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK; vkms_config_overlay->default_rotation = DRM_MODE_ROTATE_0; + vkms_config_overlay->supported_color_encoding = BIT(DRM_COLOR_YCBCR_BT601) | + BIT(DRM_COLOR_YCBCR_BT709) | + BIT(DRM_COLOR_YCBCR_BT2020); + vkms_config_overlay->default_color_encoding = DRM_COLOR_YCBCR_BT601; + list_add(&vkms_config_overlay->link, &vkms_config->planes); @@ -121,6 +126,12 @@ bool vkms_config_is_valid(struct vkms_config *config) config_plane->default_rotation) return false; + // Default color range not in supported color range + if ((BIT(config_plane->default_color_encoding) & + config_plane->supported_color_encoding) != + BIT(config_plane->default_color_encoding)) + return false; + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { // Multiple primary planes for only one CRTC if (has_primary) @@ -155,6 +166,10 @@ static int vkms_config_show(struct seq_file *m, void *data) seq_printf(m, "\ttype: %d\n", config_plane->type); seq_printf(m, "\tsupported rotations: 0x%x\n", config_plane->supported_rotations); seq_printf(m, "\tdefault rotation: 0x%x\n", config_plane->default_rotation); + seq_printf(m, "\tsupported color encoding: 0x%x\n", + config_plane->supported_color_encoding); + seq_printf(m, "\tdefault color encoding: %d\n", + config_plane->default_color_encoding); } return 0; diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 77a72a3a637c..c8802bfb9ab2 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -30,6 +30,8 @@ struct vkms_config { * plane is primary. * @default_rotation: Default rotation that should be used by this plane * @supported_rotation: Rotation that this plane will support + * @default_color_encoding: Default color encoding that should be used by this plane + * @supported_color_encoding: Color encoding that this plane will support * @plane: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms plane during device creation. This pointer is * not managed by the configuration and must be managed by other means. @@ -41,6 +43,8 @@ struct vkms_config_plane { enum drm_plane_type type; unsigned int default_rotation; unsigned int supported_rotations; + enum drm_color_encoding default_color_encoding; + unsigned int supported_color_encoding; /* Internal usage */ struct vkms_plane *plane; diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 3a2b8b0b5980..ef20da7ccb17 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -242,12 +242,10 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, config->supported_rotations); drm_plane_create_color_properties(&plane->base, - BIT(DRM_COLOR_YCBCR_BT601) | - BIT(DRM_COLOR_YCBCR_BT709) | - BIT(DRM_COLOR_YCBCR_BT2020), + config->supported_color_encoding, BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | BIT(DRM_COLOR_YCBCR_FULL_RANGE), - DRM_COLOR_YCBCR_BT601, + config->default_color_encoding, DRM_COLOR_YCBCR_FULL_RANGE); return plane; From patchwork Wed Aug 14 14:36:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1CA3C52D7D for ; Wed, 14 Aug 2024 14:36:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F08E410E4BD; Wed, 14 Aug 2024 14:36:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="ZrQhpDcb"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9EA0710E4B2 for ; Wed, 14 Aug 2024 14:36:40 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 8E6191C0018; Wed, 14 Aug 2024 14:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qTzJTdqCcC1+FQ3s6IZb2V6Dy36Za0dGp0XBs510Djs=; b=ZrQhpDcbqqyl4hg/GfPX8VSMqaaLqN2dKzG46VH3h2Y7YzRQHbar44c5HpvUIq81KdNt63 YcMoy/rMiWb02lixQ7CAaufsaz5dAp9zN4F9L1FrJIzldjQMFip0QChBVxHd4IylAq2qgz ut+M20ceSUUNyEi3eVgosPGuQRuq4co46IsGIseBkuX6WxPJpGPR+K1Fo1J2PSsX3Wqwc3 PFHJJ/n5EKaNdjNpThiZy3XdcwjP1PhwvqbuW3IquXgyeM0UyHWAU6BGwMBPsAZVNFg/xO bodgvHvasKfee5fZGGub4V+LhXXMvQUja0WVTzWbQMKMwUFPlL3jn2WiGseJ2Q== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:32 +0200 Subject: [PATCH RFC 10/15] drm/vkms: Introduce configuration for plane color range MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-10-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4055; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=n9VPKadJ0Gfeu1GqQvFJ1hXBtbm3Y/iFV6hNgIT98iA=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDriBn6dfYmApqULXo+hRdf5GNGoUO/I7qN0 dRdo/RXo/SJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6wAKCRAgrS7GWxAs 4ivuD/4tmWZQtc4L41tnQ+2Rapur8BHqHMgmPqu5nPpnVMtp0i7xwLv+Jd5xEuOloLQkuD2bqiF N79ThDvPjAizfR2OCJyj3n00pB0b58tvFrlXG/oChy3t70R4IIuWPTd+GJqOUVOJG+PHYsCKQwT PeLnAXP3v6xz3qSq72+r0CB1EKE1jlHR11BtLPPQx/VU150KRsRh9rfUjhwXqTym4qOw9O8zv/2 DJJ+9xQ5T44bghwF4DmxD3MZeVLsASl2Ha5Q6jNMCQylgVxMwPs6IZv011GwCFWJaNBRgVCVA0Y kEkVR06Bl9ZstUWhO/vxTIheut8uv6kqv3GhXMKuD3oX22rB4KVglCAiqnNPCui2EJt3Bi8WMzK TfQ4zL2iwqA04XdpzamZjnlTC32bAKpONwzLtA7UXs5kSRUgwOt57oHlEApQ7C6j1eyFKE3il+d GiNXB0N8uvx8+72/pEoB+9o/lTcmmS7HpKnQBG/N0kND/xNzuBt5zarWdQa34Ifb4qZzboFPPsl oBji4I9uFcjZf45B0TkKneYu9VSbTbzE4vTOlDAnbpnDoZkv/uEL2kHVuB8GFmd3hFScuT7E4UH xl0FKezyDEp7WNGov/DxJNOUbcQbz/YrvqX6XTSgMdL6OEgcDSM2XX+i9Z3Cz7kladWKehS9pVp bsKWEVqH0Mvwxkw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" VKMS driver supports all the color range on planes, but for testing it can be useful to only advertise few of them. This new configuration interface will allow configuring the color range per planes. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 15 ++++++++++++++- drivers/gpu/drm/vkms/vkms_config.h | 4 ++++ drivers/gpu/drm/vkms/vkms_plane.c | 5 ++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index dabb8cb13314..e9e30974523a 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -86,7 +86,9 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf BIT(DRM_COLOR_YCBCR_BT709) | BIT(DRM_COLOR_YCBCR_BT2020); vkms_config_overlay->default_color_encoding = DRM_COLOR_YCBCR_BT601; - + vkms_config_overlay->supported_color_range = BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | + BIT(DRM_COLOR_YCBCR_FULL_RANGE); + vkms_config_overlay->default_color_range = DRM_COLOR_YCBCR_FULL_RANGE; list_add(&vkms_config_overlay->link, &vkms_config->planes); @@ -132,6 +134,13 @@ bool vkms_config_is_valid(struct vkms_config *config) BIT(config_plane->default_color_encoding)) return false; + + // Default color range not in supported color range + if ((BIT(config_plane->default_color_range) & + config_plane->supported_color_range) != + BIT(config_plane->default_color_range)) + return false; + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { // Multiple primary planes for only one CRTC if (has_primary) @@ -170,6 +179,10 @@ static int vkms_config_show(struct seq_file *m, void *data) config_plane->supported_color_encoding); seq_printf(m, "\tdefault color encoding: %d\n", config_plane->default_color_encoding); + seq_printf(m, "\tsupported color range: 0x%x\n", + config_plane->supported_color_range); + seq_printf(m, "\tdefault color range: %d\n", + config_plane->default_color_range); } return 0; diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index c8802bfb9ab2..d668aeab9d26 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -32,6 +32,8 @@ struct vkms_config { * @supported_rotation: Rotation that this plane will support * @default_color_encoding: Default color encoding that should be used by this plane * @supported_color_encoding: Color encoding that this plane will support + * @default_color_range: Default color range that should be used by this plane + * @supported_color_range: Color range that this plane will support * @plane: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms plane during device creation. This pointer is * not managed by the configuration and must be managed by other means. @@ -45,6 +47,8 @@ struct vkms_config_plane { unsigned int supported_rotations; enum drm_color_encoding default_color_encoding; unsigned int supported_color_encoding; + enum drm_color_range default_color_range; + unsigned int supported_color_range; /* Internal usage */ struct vkms_plane *plane; diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index ef20da7ccb17..e7e890f730dd 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -243,10 +243,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_create_color_properties(&plane->base, config->supported_color_encoding, - BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | - BIT(DRM_COLOR_YCBCR_FULL_RANGE), + config->supported_color_range, config->default_color_encoding, - DRM_COLOR_YCBCR_FULL_RANGE); + config->default_color_range); return plane; } From patchwork Wed Aug 14 14:36:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D23EC3DA4A for ; Wed, 14 Aug 2024 14:36:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E249910E4B2; Wed, 14 Aug 2024 14:36:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="nU09Wv9Z"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 90C5810E4B2 for ; Wed, 14 Aug 2024 14:36:41 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 853BB1C0014; Wed, 14 Aug 2024 14:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mejIIXPURaek6mjtWd5mqBmpe3HOEF3GsOx95SQDqq4=; b=nU09Wv9Zj0DTXtTaKtchzwscuZiS12inNG2Jw/2EjbLRSnYDxmMJuhvZ69PZXxDWgTZl80 oC+o4sENhLpu3pgb5ErwlMD5QYSCfE8YjQM4B4ia0PiTSnOz09nVBm7VFn2mqjE0aEzAO5 zaFwULtCAVdfTU8qZM7+kFBhckWjZBAAw4AfmAxfJK3/YARrZUVCHyN2ahmPAF2CyB18I1 LJqUfUugFkkNpzPNLjOx1JarMnPSZMYV4ilUFQ0LKFHq20DBW5p4oYBq1mlwWAPH1zqTo0 jXsHLxDGb3kpCY4KkCYfRpFCKjEy09+M6z1JPjONbyyvleWJXPNlmXpo9rMOng== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:33 +0200 Subject: [PATCH RFC 11/15] drm: writeback: Add drm_writeback_connector cleanup MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-11-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2853; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=6odxYTXA8ortXBUomxRjgorI0mo39N/O6CGAuFuXVcs=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDrBA7inbkZtwi0MgSJNciMd8SobTqox5trU XlkRcpuF1SJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6wAKCRAgrS7GWxAs 4lhFEACNrxekua9mWX20TEWhv9sE/GhKeSR4A5A6U8B8kWrddIESqC0zODhuxosYvKduF51Vh2m bAn67DXGORWvAtTTziGKbBmRz0pDtnPsxBeIR9ntA63xQQLVwT1n6chdF0L2vjy19tVSfZY0aYn aAfiBxqDwRJbi/blbhg4Q3g8wxYtz1Bzk0gN2JqFWxb8cAXki2/k6mdSKW0+pZSxIhWksGT0kjd Lag4w9yl+/iuHh93rcoWSesYP3FNknZ+KQgXuIZfGZ5/VLCyU2IM+VdqKb85FaTKJbYNBg8u6I0 OzZlWcjPwnmGd1/pBxXZh7inWMv1+FkysIB9oZTdvfxlg4KCxmIfS19t+0r84ScUxYWyHuvyoRe lk4szoFyE7syRWqscQbhRKUMu00Y2vAc/uBcEk582giDv0CgV6jkbwaIDsXh4KJ2GbQaaYQh4sP pAM4RbLJZljJRQoa/zRurzXI6/flDTQ+rXzHg6i+FveoXLe+3EfwKzrEpqlU10O+614cUkHuBVx bTNsuOPeK9HmERQaH9HUCAPkaUlsjCX62h9u3KViMRy7APkVgbOA3H1BqGi3hbaD55rv9SzfcjM Rn49P7munhIk7iW6RANw6WGSFGhT8v9Jb9wXGoJ69/1g3Re5eyPIoAGhLayjrIeapWLtskREFFj fbJN+lwKox6s1ag== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently drm_writeback_connector are created by drm_writeback_connector_init or drm_writeback_connector_init_with_encoder. Both of the function uses drm_connector_init and drm_encoder_init, but there is no way to properly clean those structure from outside. This patch introduce the new function drm_writeback_connector_cleanup to allow a proper cleanup. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/drm_writeback.c | 10 ++++++++++ include/drm/drm_writeback.h | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c index a031c335bdb9..505a4eb40f93 100644 --- a/drivers/gpu/drm/drm_writeback.c +++ b/drivers/gpu/drm/drm_writeback.c @@ -184,6 +184,7 @@ int drm_writeback_connector_init(struct drm_device *dev, drm_encoder_helper_add(&wb_connector->encoder, enc_helper_funcs); wb_connector->encoder.possible_crtcs = possible_crtcs; + wb_connector->managed_encoder = true; ret = drm_encoder_init(dev, &wb_connector->encoder, &drm_writeback_encoder_funcs, @@ -290,6 +291,15 @@ int drm_writeback_connector_init_with_encoder(struct drm_device *dev, } EXPORT_SYMBOL(drm_writeback_connector_init_with_encoder); +void drm_writeback_connector_cleanup(struct drm_writeback_connector *wb_connector) +{ + drm_connector_cleanup(&wb_connector->base); + drm_property_blob_put(wb_connector->pixel_formats_blob_ptr); + if (wb_connector->managed_encoder) + drm_encoder_cleanup(&wb_connector->encoder); +} +EXPORT_SYMBOL(drm_writeback_connector_cleanup); + int drm_writeback_set_fb(struct drm_connector_state *conn_state, struct drm_framebuffer *fb) { diff --git a/include/drm/drm_writeback.h b/include/drm/drm_writeback.h index 17e576c80169..e651c0c0c84c 100644 --- a/include/drm/drm_writeback.h +++ b/include/drm/drm_writeback.h @@ -35,6 +35,15 @@ struct drm_writeback_connector { */ struct drm_encoder encoder; + /** + * @managed_encoder: Sets to true if @encoder was created by drm_writeback_connector_init() + * + * If the user used drm_writeback_connector_init_with_encoder() to create the connector, + * @encoder is not valid and not managed by drm_writeback_connector. This fields allows + * the drm_writeback_cleanup() function to properly destroy the encoder if needed. + */ + bool managed_encoder; + /** * @pixel_formats_blob_ptr: * @@ -161,6 +170,8 @@ int drm_writeback_connector_init_with_encoder(struct drm_device *dev, const struct drm_connector_funcs *con_funcs, const u32 *formats, int n_formats); +void drm_writeback_connector_cleanup(struct drm_writeback_connector *wb_connector); + int drm_writeback_set_fb(struct drm_connector_state *conn_state, struct drm_framebuffer *fb); From patchwork Wed Aug 14 14:36:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A00FC52D7B for ; Wed, 14 Aug 2024 14:36:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8AF2210E4B5; Wed, 14 Aug 2024 14:36:47 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="HgqOgMPN"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 86C9C10E4B0 for ; Wed, 14 Aug 2024 14:36:42 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7468D1C0002; Wed, 14 Aug 2024 14:36:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646201; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hi1TEW7eGWLARBXasnPACvRwfa310YzOI/mLeLTA3eY=; b=HgqOgMPN2QYNm/a9KHW28iVFp0/evBz1pU97MyT9JHeE7AbAnHZdswcL7fHjzIGjz2YqCV qSvIRFZ2aCjXilvd1LKQLemFIIPwCkgOgmds7PZWodSzYk2HusLfB5tUNBZCk25DA5/fGp diFMcyGcEh2XLYvBbQNsAQCTyZnXlHOLpMNgE3mGA8I5ZNMXvyRHaddnekBmfCKvRp02vm Lq0rNxLX2VJSZD5kSndmZomyXYmUKaUAlLSUjxxLuacbKML0b5SnmGM+J0MOZYdJvOIERq uWjlRiVqsP2H3XVz2R/B/566qmEYqwafGZ99Mbcga+P4EoRQJvSf5xpJwFPdJA== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:34 +0200 Subject: [PATCH RFC 12/15] drm/vkms: Add configuration for CRTCs and encoders MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-12-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=23979; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=46j34JKKy712RzuP5JY2IZ6oP0Ml2QvEJ9sWjcs6B+Y=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDr8ZdUaO0h2dEAzSwdtgIh/pJFagSx51udc tqOsworcY2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6wAKCRAgrS7GWxAs 4l71EADORjvvKFvJ8IVvxSpM5ZJbfDegj+kmCq8vCDyynUQzHwYb4Y/KJjtz7ok4wCoTUvofz9s h3kuyWUh8tBQGZsLSCH24iVnNb2PLplUcJ/JKuOXTd+zCAi25UdRlpU9f+cik3tlYlanD2lSPBo OaWEE+GvODUAx15qXqRhiS6VWRllzXyay8q8s0AFq2hiAAnYNGas6I7wplm8+g+2kmOFl1Vj/LI Sk5UzmQrVC/v8tLww7TO24LNOU9rBAoXCMmxKBHxoJgRePnd7xSgr2pppT1oyHF10KnYL9l+PZH d2aKojUfVSzHxnc3d3gmIjEu9woGWInHwo2mFLhP65YnVJs//Ukhm6isWnaARhTvy8Zsr2VuhnI Zy39S5QdOHXP3WXLR4eUdeXic5JS0MSDYIJAvIBDhj7aU0UondyPsh0jvd7HutcGOi0bVayTDUv ifk1rGyPVQuZzVx4Wi7giiOTPKAPv8Y//VOOD5f7KYvZfYHPNfq4D5jYEJEJNpgQ0+e7KEkuDq5 HxOTXSeP8PO57moZa8O6TpaX+wCbNozJGkJcVRZF6PCu9aWFKTnrXP4n4qFgkg4TJ7N69fucjwS RHy1ZOAb85PNhCKuY1wf713nx1V2aHKE5lgKbfFwDP7On6J3cphECRrMakDH0e6NCZC1nOw1BHc AGeK1ygFOX8ZFoQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current VKMS driver can only uses one CRTC and one encoder. This patch introduce in the same time CRTC and encoders as they are tighly linked. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 266 +++++++++++++++++++++++++++++++++---- drivers/gpu/drm/vkms/vkms_config.h | 102 +++++++++++++- drivers/gpu/drm/vkms/vkms_crtc.c | 20 ++- drivers/gpu/drm/vkms/vkms_crtc.h | 3 +- drivers/gpu/drm/vkms/vkms_drv.c | 87 ++++++------ 5 files changed, 405 insertions(+), 73 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index e9e30974523a..fcd4a128c21b 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -14,6 +14,8 @@ struct vkms_config *vkms_config_create(void) return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&config->planes); + INIT_LIST_HEAD(&config->crtcs); + INIT_LIST_HEAD(&config->encoders); return config; } @@ -22,12 +24,24 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable bool enable_cursor) { struct vkms_config_plane *plane; + struct vkms_config_encoder *encoder; + struct vkms_config_crtc *crtc; struct vkms_config *vkms_config = vkms_config_create(); if (IS_ERR(vkms_config)) return vkms_config; - vkms_config->writeback = enable_writeback; + crtc = vkms_config_create_crtc(vkms_config); + if (!crtc) + goto err_alloc; + crtc->writeback = enable_writeback; + + encoder = vkms_config_create_encoder(vkms_config); + if (!encoder) + goto err_alloc; + + if (vkms_config_encoder_attach_crtc(encoder, crtc)) + goto err_alloc; plane = vkms_config_create_plane(vkms_config); if (!plane) @@ -39,6 +53,9 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable goto err_alloc; sprintf(plane->name, "primary"); + if (vkms_config_plane_attach_crtc(plane, crtc)) + goto err_alloc; + if (enable_overlay) { for (int i = 0; i < NUM_OVERLAY_PLANES; i++) { plane = vkms_config_create_plane(vkms_config); @@ -49,6 +66,9 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!plane->name) goto err_alloc; snprintf(plane->name, 10, "plane-%d", i); + + if (vkms_config_plane_attach_crtc(plane, crtc)) + goto err_alloc; } } if (enable_cursor) { @@ -60,6 +80,9 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!plane->name) goto err_alloc; sprintf(plane->name, "cursor"); + + if (vkms_config_plane_attach_crtc(plane, crtc)) + goto err_alloc; } return vkms_config; @@ -89,38 +112,196 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_conf vkms_config_overlay->supported_color_range = BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | BIT(DRM_COLOR_YCBCR_FULL_RANGE); vkms_config_overlay->default_color_range = DRM_COLOR_YCBCR_FULL_RANGE; + xa_init_flags(&vkms_config_overlay->possible_crtcs, XA_FLAGS_ALLOC); list_add(&vkms_config_overlay->link, &vkms_config->planes); return vkms_config_overlay; } -void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_overlay) +struct vkms_config_crtc *vkms_config_create_crtc(struct vkms_config *vkms_config) { - if (!vkms_config_overlay) + if (!vkms_config) + return NULL; + + struct vkms_config_crtc *vkms_config_crtc = kzalloc(sizeof(*vkms_config_crtc), + GFP_KERNEL); + + if (!vkms_config_crtc) + return NULL; + + list_add(&vkms_config_crtc->link, &vkms_config->crtcs); + xa_init_flags(&vkms_config_crtc->possible_planes, XA_FLAGS_ALLOC); + xa_init_flags(&vkms_config_crtc->possible_encoders, XA_FLAGS_ALLOC); + + return vkms_config_crtc; +} + +struct vkms_config_encoder *vkms_config_create_encoder(struct vkms_config *vkms_config) +{ + if (!vkms_config) + return NULL; + + struct vkms_config_encoder *vkms_config_encoder = kzalloc(sizeof(*vkms_config_encoder), + GFP_KERNEL); + + if (!vkms_config_encoder) + return NULL; + + list_add(&vkms_config_encoder->link, &vkms_config->encoders); + xa_init_flags(&vkms_config_encoder->possible_crtcs, XA_FLAGS_ALLOC); + + return vkms_config_encoder; +} + +void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane, + struct vkms_config *vkms_config) +{ + struct vkms_config_crtc *crtc_config; + struct vkms_config_plane *plane; + + if (!vkms_config_plane) + return; + list_del(&vkms_config_plane->link); + xa_destroy(&vkms_config_plane->possible_crtcs); + + list_for_each_entry(crtc_config, &vkms_config->crtcs, link) { + unsigned long idx = 0; + + xa_for_each(&crtc_config->possible_planes, idx, plane) { + if (plane == vkms_config_plane) + xa_erase(&crtc_config->possible_planes, idx); + } + } + + kfree(vkms_config_plane->name); + kfree(vkms_config_plane); +} + +void vkms_config_delete_crtc(struct vkms_config_crtc *vkms_config_crtc, + struct vkms_config *vkms_config) +{ + struct vkms_config_crtc *crtc_config; + struct vkms_config_plane *plane_config; + struct vkms_config_encoder *encoder_config; + + if (!vkms_config_crtc) + return; + list_del(&vkms_config_crtc->link); + xa_destroy(&vkms_config_crtc->possible_planes); + xa_destroy(&vkms_config_crtc->possible_encoders); + + list_for_each_entry(plane_config, &vkms_config->planes, link) { + unsigned long idx = 0; + + xa_for_each(&plane_config->possible_crtcs, idx, crtc_config) { + if (crtc_config == vkms_config_crtc) + xa_erase(&plane_config->possible_crtcs, idx); + } + } + + list_for_each_entry(encoder_config, &vkms_config->encoders, link) { + unsigned long idx = 0; + + xa_for_each(&encoder_config->possible_crtcs, idx, crtc_config) { + if (crtc_config == vkms_config_crtc) + xa_erase(&encoder_config->possible_crtcs, idx); + } + } + + kfree(vkms_config_crtc); +} + +void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder, + struct vkms_config *vkms_config) +{ + if (!vkms_config_encoder) return; - list_del(&vkms_config_overlay->link); - kfree(vkms_config_overlay->name); - kfree(vkms_config_overlay); + list_del(&vkms_config_encoder->link); + xa_destroy(&vkms_config_encoder->possible_crtcs); + + struct vkms_config_crtc *crtc_config; + struct vkms_config_encoder *encoder; + + list_for_each_entry(crtc_config, &vkms_config->crtcs, link) { + unsigned long idx = 0; + + xa_for_each(&crtc_config->possible_encoders, idx, encoder) { + if (encoder == vkms_config_encoder) + xa_erase(&crtc_config->possible_encoders, idx); + } + } + + kfree(vkms_config_encoder); } void vkms_config_destroy(struct vkms_config *config) { struct vkms_config_plane *vkms_config_plane, *tmp_plane; + struct vkms_config_encoder *vkms_config_encoder, *tmp_encoder; + struct vkms_config_crtc *vkms_config_crtc, *tmp_crtc; + list_for_each_entry_safe(vkms_config_plane, tmp_plane, &config->planes, link) { - vkms_config_delete_plane(vkms_config_plane); + vkms_config_delete_plane(vkms_config_plane, config); + } + list_for_each_entry_safe(vkms_config_encoder, tmp_encoder, &config->encoders, link) { + vkms_config_delete_encoder(vkms_config_encoder, config); + } + list_for_each_entry_safe(vkms_config_crtc, tmp_crtc, &config->crtcs, link) { + vkms_config_delete_crtc(vkms_config_crtc, config); } kfree(config); } +int __must_check vkms_config_plane_attach_crtc(struct vkms_config_plane *vkms_config_plane, + struct vkms_config_crtc *vkms_config_crtc) +{ + u32 crtc_idx, encoder_idx; + int ret; + + ret = xa_alloc(&vkms_config_plane->possible_crtcs, &crtc_idx, vkms_config_crtc, + xa_limit_32b, GFP_KERNEL); + if (ret) + return ret; + + ret = xa_alloc(&vkms_config_crtc->possible_planes, &encoder_idx, vkms_config_plane, + xa_limit_32b, GFP_KERNEL); + if (ret) { + xa_erase(&vkms_config_plane->possible_crtcs, crtc_idx); + return ret; + } + + return ret; +} + +int __must_check vkms_config_encoder_attach_crtc(struct vkms_config_encoder *vkms_config_encoder, + struct vkms_config_crtc *vkms_config_crtc) +{ + u32 crtc_idx, encoder_idx; + int ret; + + ret = xa_alloc(&vkms_config_encoder->possible_crtcs, &crtc_idx, vkms_config_crtc, + xa_limit_32b, GFP_KERNEL); + if (ret) + return ret; + + ret = xa_alloc(&vkms_config_crtc->possible_encoders, &encoder_idx, vkms_config_encoder, + xa_limit_32b, GFP_KERNEL); + if (ret) { + xa_erase(&vkms_config_encoder->possible_crtcs, crtc_idx); + return ret; + } + + return ret; +} + bool vkms_config_is_valid(struct vkms_config *config) { struct vkms_config_plane *config_plane; - - bool has_cursor = false; - bool has_primary = false; + struct vkms_config_crtc *config_crtc; + struct vkms_config_encoder *config_encoder; list_for_each_entry(config_plane, &config->planes, link) { // Default rotation not in supported rotations @@ -141,22 +322,47 @@ bool vkms_config_is_valid(struct vkms_config *config) BIT(config_plane->default_color_range)) return false; - if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { - // Multiple primary planes for only one CRTC - if (has_primary) - return false; - has_primary = true; - } - if (config_plane->type == DRM_PLANE_TYPE_CURSOR) { - // Multiple cursor planes for only one CRTC - if (has_cursor) - return false; - has_cursor = true; - } + // No CRTC linked to this plane + if (xa_empty(&config_plane->possible_crtcs)) + return false; + } + + list_for_each_entry(config_encoder, &config->encoders, link) { + // No CRTC linked to this encoder + if (xa_empty(&config_encoder->possible_crtcs)) + return false; } - if (!has_primary) - return false; + list_for_each_entry(config_crtc, &config->crtcs, link) { + bool has_primary = false; + bool has_cursor = false; + unsigned long idx = 0; + + // No encoder attached to this CRTC + if (xa_empty(&config_crtc->possible_encoders)) + return false; + + xa_for_each(&config_crtc->possible_planes, idx, config_plane) { + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) { + // Multiple primary planes for only one CRTC + if (has_primary) + return false; + + has_primary = true; + } + if (config_plane->type == DRM_PLANE_TYPE_CURSOR) { + // Multiple cursor planes for only one CRTC + if (has_cursor) + return false; + + has_cursor = true; + } + } + + // No primary plane for this CRTC + if (!has_primary) + return false; + } return true; } @@ -167,8 +373,9 @@ static int vkms_config_show(struct seq_file *m, void *data) struct drm_device *dev = entry->dev; struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); struct vkms_config_plane *config_plane; + struct vkms_config_crtc *config_crtc; + struct vkms_config_encoder *config_encoder; - seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); list_for_each_entry(config_plane, &vkmsdev->config->planes, link) { seq_puts(m, "plane:\n"); seq_printf(m, "\tname: %s\n", config_plane->name); @@ -185,6 +392,15 @@ static int vkms_config_show(struct seq_file *m, void *data) config_plane->default_color_range); } + list_for_each_entry(config_encoder, &vkmsdev->config->encoders, link) { + seq_puts(m, "encoder:\n"); + } + + list_for_each_entry(config_crtc, &vkmsdev->config->crtcs, link) { + seq_puts(m, "crtc:\n"); + seq_printf(m, "\twriteback: %d\n", config_crtc->writeback); + } + return 0; } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index d668aeab9d26..8f247fc09373 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -9,16 +9,59 @@ /** * struct vkms_config - General configuration for VKMS driver * - * @writeback: If true, a writeback buffer can be attached to the CRTC * @planes: List of planes configured for this device. They are created by the function * vkms_config_create_plane(). + * @crtcs: List of crtcs configured for this device. They are created by the function + * vkms_config_create_crtc(). + * @encoders: List of encoders configured for this device. They are created by the function + * vkms_config_create_encoder(). * @dev: Used to store the current vkms device. Only set when the device is instancied. */ struct vkms_config { - bool writeback; struct vkms_device *dev; struct list_head planes; + struct list_head crtcs; + struct list_head encoders; +}; + +/** + * struct vkms_config_crtc + * + * @link: Link to the others CRTCs + * @possible_planes: List of planes that can be used with this CRTC + * @possible_encoders: List of encoders that can be used with this CRTC + * @crtc: Internal usage. This pointer should never be considered as valid. It can be used to + * store a temporary reference to a vkms crtc during device creation. This pointer is + * not managed by the configuration and must be managed by other means. + */ +struct vkms_config_crtc { + struct list_head link; + + bool writeback; + struct xarray possible_planes; + struct xarray possible_encoders; + + /* Internal usage */ + struct vkms_crtc *crtc; +}; + +/** + * struct vkms_config_encoder + * + * @link: Link to the others encoders + * @possible_crtcs: List of CRTC that can be used with this encoder + * @encoder: Internal usage. This pointer should never be considered as valid. It can be used to + * store a temporary reference to a vkms encoder during device creation. This pointer is + * not managed by the configuration and must be managed by other means. + */ +struct vkms_config_encoder { + struct list_head link; + + struct xarray possible_crtcs; + + /* Internal usage */ + struct drm_encoder *encoder; }; /** @@ -34,6 +77,7 @@ struct vkms_config { * @supported_color_encoding: Color encoding that this plane will support * @default_color_range: Default color range that should be used by this plane * @supported_color_range: Color range that this plane will support + * @possible_crtcs: List of CRTC that can be used with this plane. * @plane: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms plane during device creation. This pointer is * not managed by the configuration and must be managed by other means. @@ -50,6 +94,7 @@ struct vkms_config_plane { enum drm_color_range default_color_range; unsigned int supported_color_range; + struct xarray possible_crtcs; /* Internal usage */ struct vkms_plane *plane; }; @@ -84,14 +129,63 @@ bool vkms_config_is_valid(struct vkms_config *vkms_config); */ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *vkms_config); +/** + * vkms_config_create_crtc() - Create a crtc configuration + * + * This will allocate and add a new crtc configuration to @vkms_config. + * @vkms_config: Configuration where to insert new crtc configuration + */ +struct vkms_config_crtc *vkms_config_create_crtc(struct vkms_config *vkms_config); + +/** + * vkms_config_create_encoder() - Create an encoder configuration + * + * This will allocate and add a new encoder configuration to @vkms_config. + * @vkms_config: Configuration where to insert new encoder configuration + */ +struct vkms_config_encoder *vkms_config_create_encoder(struct vkms_config *vkms_config); + +int __must_check vkms_config_plane_attach_crtc(struct vkms_config_plane *vkms_config_plane, + struct vkms_config_crtc *vkms_config_crtc); +int __must_check vkms_config_encoder_attach_crtc(struct vkms_config_encoder *vkms_config_encoder, + struct vkms_config_crtc *vkms_config_crtc); + /** * vkms_config_delete_plane() - Remove a plane configuration and frees its memory * * This will delete a plane configuration from the parent configuration. This will NOT - * cleanup and frees the vkms_plane that can be stored in @vkms_config_plane. + * cleanup and frees the vkms_plane that can be stored in @vkms_config_plane. It will also remove + * any reference to this plane in @vkms_config. + * * @vkms_config_plane: Plane configuration to cleanup + * @vkms_config: Parent configuration + */ +void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane, + struct vkms_config *vkms_config); +/** + * vkms_config_delete_crtc() - Remove a CRTC configuration and frees its memory + * + * This will delete a CRTC configuration from the parent configuration. This will NOT + * cleanup and frees the vkms_crtc that can be stored in @vkms_config_crtc. It will also remove + * any reference to this CRTC in @vkms_config. + * + * @vkms_config_crtc: Plane configuration to cleanup + * @vkms_config: Parent configuration + */ +void vkms_config_delete_crtc(struct vkms_config_crtc *vkms_config_crtc, + struct vkms_config *vkms_config); +/** + * vkms_config_delete_encoder() - Remove an encoder configuration and frees its memory + * + * This will delete an encoder configuration from the parent configuration. This will NOT + * cleanup and frees the vkms_encoder that can be stored in @vkms_config_encoder. It will also + * remove any reference to this CRTC in @vkms_config. + * + * @vkms_config_encoder: Plane configuration to cleanup + * @vkms_config: Parent configuration */ -void vkms_config_delete_plane(struct vkms_config_plane *vkms_config_plane); +void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder, + struct vkms_config *vkms_config); /** * vkms_config_alloc_default() - Allocate the configuration for the default device diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 6f6d3118b2f2..654238dbba7f 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -281,9 +281,17 @@ static void vkms_crtc_destroy_workqueue(struct drm_device *dev, void *raw_vkms_c destroy_workqueue(vkms_crtc->composer_workq); } +static void vkms_crtc_cleanup_writeback_connector(struct drm_device *dev, void *data) +{ + struct vkms_crtc *vkms_crtc = data; + + drm_writeback_connector_cleanup(&vkms_crtc->wb_connector); +} + struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkmsdev, struct drm_plane *primary, - struct drm_plane *cursor) + struct drm_plane *cursor, + struct vkms_config_crtc *config) { struct drm_device *dev = &vkmsdev->drm; struct vkms_crtc *vkms_crtc; @@ -317,5 +325,15 @@ struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkmsdev, if (ret) return ERR_PTR(ret); + if (config->writeback) { + ret = vkms_enable_writeback_connector(vkmsdev, vkms_crtc); + if (ret) + return ERR_PTR(ret); + ret = drmm_add_action_or_reset(&vkmsdev->drm, vkms_crtc_cleanup_writeback_connector, + vkms_crtc); + if (ret) + return ERR_PTR(ret); + } + return vkms_crtc; } diff --git a/drivers/gpu/drm/vkms/vkms_crtc.h b/drivers/gpu/drm/vkms/vkms_crtc.h index dde28884a0a5..a271e95f1cfe 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.h +++ b/drivers/gpu/drm/vkms/vkms_crtc.h @@ -86,5 +86,6 @@ struct vkms_crtc { */ struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkmsdev, struct drm_plane *primary, - struct drm_plane *cursor); + struct drm_plane *cursor, + struct vkms_config_crtc *config); #endif //_VKMS_CRTC_H diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 403006a0bb61..6deff5099322 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -153,13 +153,12 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { static int vkms_output_init(struct vkms_device *vkmsdev) { - struct vkms_config_plane *config_plane; + struct vkms_config_encoder *config_encoder; struct drm_device *dev = &vkmsdev->drm; + struct vkms_config_plane *config_plane; + struct vkms_config_crtc *config_crtc; struct drm_connector *connector; - struct drm_encoder *encoder; - struct vkms_crtc *crtc; - struct drm_plane *plane; - struct vkms_plane *primary, *cursor = NULL; + unsigned long idx; int ret; int writeback; @@ -169,22 +168,30 @@ static int vkms_output_init(struct vkms_device *vkmsdev) ret = PTR_ERR(config_plane->plane); return ret; } - - if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) - primary = config_plane->plane; - else if (config_plane->type == DRM_PLANE_TYPE_CURSOR) - cursor = config_plane->plane; } - /* [1]: Initialize the crtc component */ - crtc = vkms_crtc_init(vkmsdev, &primary->base, - cursor ? &cursor->base : NULL); - if (IS_ERR(crtc)) - return PTR_ERR(crtc); + list_for_each_entry(config_crtc, &vkmsdev->config->crtcs, link) { + struct drm_plane *primary = NULL, *cursor = NULL; + + xa_for_each(&config_crtc->possible_planes, idx, config_plane) { + if (config_plane->type == DRM_PLANE_TYPE_PRIMARY) + primary = &config_plane->plane->base; + else if (config_plane->type == DRM_PLANE_TYPE_CURSOR) + cursor = &config_plane->plane->base; + } + + config_crtc->crtc = vkms_crtc_init(vkmsdev, primary, cursor, config_crtc); - /* Enable the output's CRTC for all the planes */ - drm_for_each_plane(plane, &vkmsdev->drm) { - plane->possible_crtcs |= drm_crtc_mask(&crtc->base); + if (IS_ERR(config_crtc->crtc)) { + ret = PTR_ERR(config_crtc->crtc); + return ret; + } + } + + list_for_each_entry(config_crtc, &vkmsdev->config->crtcs, link) { + xa_for_each(&config_crtc->possible_planes, idx, config_plane) { + config_plane->plane->base.possible_crtcs |= drm_crtc_mask(&config_crtc->crtc->base); + } } /* Initialize the connector component */ @@ -201,32 +208,28 @@ static int vkms_output_init(struct vkms_device *vkmsdev) drm_connector_helper_add(connector, &vkms_conn_helper_funcs); - /* Initialize the encoder component */ - encoder = drmm_kzalloc(&vkmsdev->drm, sizeof(*encoder), GFP_KERNEL); - if (!encoder) - return -ENOMEM; - - ret = drmm_encoder_init(dev, encoder, &vkms_encoder_funcs, - DRM_MODE_ENCODER_VIRTUAL, NULL); - if (ret) { - DRM_ERROR("Failed to init encoder\n"); - return ret; - } - - encoder->possible_crtcs = drm_crtc_mask(&crtc->base); - /* Attach the encoder and the connector */ - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - DRM_ERROR("Failed to attach connector to encoder\n"); - return ret; - } + list_for_each_entry(config_encoder, &vkmsdev->config->encoders, link) { + config_encoder->encoder = drmm_kzalloc(&vkmsdev->drm, + sizeof(*config_encoder->encoder), + GFP_KERNEL); + if (!config_encoder->encoder) + return -ENOMEM; + ret = drmm_encoder_init(dev, config_encoder->encoder, &vkms_encoder_funcs, + DRM_MODE_ENCODER_VIRTUAL, NULL); + if (ret) { + DRM_ERROR("Failed to init encoder\n"); + return ret; + } - /* Initialize the writeback component */ - if (vkmsdev->config->writeback) { - writeback = vkms_enable_writeback_connector(vkmsdev, crtc); - if (writeback) - DRM_ERROR("Failed to init writeback connector\n"); + xa_for_each(&config_encoder->possible_crtcs, idx, config_crtc) { + config_encoder->encoder->possible_crtcs |= drm_crtc_mask(&config_crtc->crtc->base); + } + if (IS_ERR(config_encoder->encoder)) + return PTR_ERR(config_encoder->encoder); + ret = drm_connector_attach_encoder(connector, config_encoder->encoder); + if (ret) + return ret; } drm_mode_config_reset(dev); From patchwork Wed Aug 14 14:36:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA764C531DF for ; Wed, 14 Aug 2024 14:36:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A2D910E4BB; Wed, 14 Aug 2024 14:36:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="S0CZ3pId"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 868B710E4B0 for ; Wed, 14 Aug 2024 14:36:43 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 695151C0013; Wed, 14 Aug 2024 14:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Iv9G0qT3QDgWb7mJla/RT5pO59ye8gTf1MNCr9gFUH0=; b=S0CZ3pIdYc0MG0mTR5Ntzwhm/ivfK793sCZtSr+1lfpdt6l2+WQ7KMCSg4WBUNDsRxrDXI J/PxcGPj/zNBcv3peTnfo+nA7XT7m9JE1Go6WSEoFmZK3POZbA7lFFIrmXcek6rS55TAz7 iHT5Ux/7WrjlI+75DLVK/J8n5ZyobFGTpZk+sTIIIFsPrmZSsRYP4+cirtwwxRdgTfTVxh Xe9FftWq1CA2+pU+4G/LowYt2fy9X23KG7+xTJ9FAwrkN71Jf1/do9farSsNXYDn+GTy+f cH6eJW+4JHuo5ptRF582y1C0Fgtk7pIJJHAwtz+HUNfZ2XlVc5cL7VCmCklw9w== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:35 +0200 Subject: [PATCH RFC 13/15] drm/vkms: Add name configuration for encoders MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-13-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2974; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=7ECEXMl0/sjLnYGUbuJj1pxIV+1npiLzlGfXdPZbOiQ=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDrxIqYar9la9HQlFNEf9xCptfEMltxbvRGS V8eIljbQaWJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6wAKCRAgrS7GWxAs 4nxMEACCHj59aLFDqD8+GAzzBA8IMbwVpDf4E4CLJT1rk5OA0WUHbHMg8xYB2nI3ieiPt/3rZlh o4CuzlDj58qNv1kX0tbn03M4eWFW6onC+mnmi9nDo4IveT+vB/8y1o1A1v+EEiWVfRJd2ZdiFUs 2prGrer7ChxaPoRVy8/3npB4Nw270dQqR/p6ZoIQ/U0jTBD6OcUXuGHOTfPDl7f604iILIlHH4H 2NC9bNgmrs5mnRdi0sgkkfVf8NNV6HP5TdWI1dVkApW1/klzch3HsmBE4Q6hAydCodMHLbmK1nU 7XLnef1dSsiD1pKGRnRbw1hP/eJypx1Fiddo0bLZ6oyGpTU4Ciq0NBakAbF3O6SzqDXnAGzQYEl 5bRveUyuhcxcEgqKHbyxC2cVbzFFE1H//MX5lqSoZC3eHDjLulAex/Nk9tZ0WEeiTWrATn5XgL6 iFAf1WYddQwS/whJ3a0v0IDnyyj/dLOEIwSgWifmGYq+59IRRbcPqPCp0vvvIW8gxWKSYrGDIvg NcS0uOMIlJICShZrwsCbWxP8R4WF8QWMr4QwuojOjtBsbYVFH5HrNoeZ0vhUx2yw3QJw7enFNzx 9V4ScEPGBmLg62fm3Wx5V4AEAqklj3O+sciPb1dRUlih0YaKQdmnZV6Xe2LtNz9/Xw+5CqcNTC8 t4cXU9O/g95nBtQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As an encoder will be a directory in ConfigFS, add the configuration for encoder name so we will be able to reflect the configfs directory name in the drm name. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_config.h | 2 ++ drivers/gpu/drm/vkms/vkms_drv.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index fcd4a128c21b..7ef525091967 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -39,6 +39,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable encoder = vkms_config_create_encoder(vkms_config); if (!encoder) goto err_alloc; + encoder->name = kzalloc(sizeof("Main Encoder"), GFP_KERNEL); + if (!encoder->name) + goto err_alloc; + sprintf(encoder->name, "Main Encoder"); if (vkms_config_encoder_attach_crtc(encoder, crtc)) goto err_alloc; @@ -232,6 +236,7 @@ void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder, } } + kfree(vkms_config_encoder->name); kfree(vkms_config_encoder); } @@ -394,6 +399,7 @@ static int vkms_config_show(struct seq_file *m, void *data) list_for_each_entry(config_encoder, &vkmsdev->config->encoders, link) { seq_puts(m, "encoder:\n"); + seq_printf(m, "\tname: %s\n", config_encoder->name); } list_for_each_entry(config_crtc, &vkmsdev->config->crtcs, link) { diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 8f247fc09373..4223edd94ec2 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -50,6 +50,7 @@ struct vkms_config_crtc { * struct vkms_config_encoder * * @link: Link to the others encoders + * @name: Name of the encoder * @possible_crtcs: List of CRTC that can be used with this encoder * @encoder: Internal usage. This pointer should never be considered as valid. It can be used to * store a temporary reference to a vkms encoder during device creation. This pointer is @@ -58,6 +59,7 @@ struct vkms_config_crtc { struct vkms_config_encoder { struct list_head link; + char *name; struct xarray possible_crtcs; /* Internal usage */ diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 6deff5099322..cd3920270905 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -216,7 +216,7 @@ static int vkms_output_init(struct vkms_device *vkmsdev) if (!config_encoder->encoder) return -ENOMEM; ret = drmm_encoder_init(dev, config_encoder->encoder, &vkms_encoder_funcs, - DRM_MODE_ENCODER_VIRTUAL, NULL); + DRM_MODE_ENCODER_VIRTUAL, config_encoder->name); if (ret) { DRM_ERROR("Failed to init encoder\n"); return ret; From patchwork Wed Aug 14 14:36:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99C9FC3DA4A for ; Wed, 14 Aug 2024 14:36:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF9C410E4B6; Wed, 14 Aug 2024 14:36:47 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="mvByp2Kl"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 92FAB10E4B5 for ; Wed, 14 Aug 2024 14:36:44 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 67E001C0005; Wed, 14 Aug 2024 14:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oNBsa5gXilZCMjJcUNu6qYchNDHM9vRKFj8hM50g5XU=; b=mvByp2Kl74mGE6PCxWmChgXv4lBKtvySDTcybijrJMUAxOd+vy1QvAIb8AhuCWJLWFpieU U3+Xd25mFABra3b1K3SHpELivWo1+TBqxo5M/+dgSNaUuypY8hQ4KXw/W8HI1jgT/7LTqZ YnaSR+f8HKUCXXYJIwHsQbyQo2AF92v2QhKTnx8lU+V38+GjTPimkMt2Xbecwwtr0qLfPA FcBt+B1jci95dlCZXoWgRW4k9fMRJxGFiUF8WtO5gyDJO3W2rJwUQDoARtb4aAvpCVq6lN m4KGvseCqgs8weym9R9KqQwgftsukbk/qANaeA9HnZTCGKkFXDGTevPW44qrNQ== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:36 +0200 Subject: [PATCH RFC 14/15] drm/vkms: Add name configuration for CRTCs MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-14-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2567; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=tjoJrPo5BIMBI2L17f4sY05IB9HzBOdBn35thdcKzcY=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDrCscwQsdTCWw/uxtxJAmPQDMbjohNTLsUx iPCzx0eA5iJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6wAKCRAgrS7GWxAs 4szQD/4rCaqKNfLW9uhjCTCTuwJ20GY0AiBdTH4uC7GxNKeazdSaRvBhCR+gxgvo3q/KeYZU98d LAjUvLGaT2VuQ+bsBri4pPiuhei3xyQZOw+XhOU0zQ4tQpQ6Ri43vSi4uz+hLhGKsY55GfRlAtD 4tqAl88TKyCY2d11Ycj+nXi7xfyI1s8bGEZQYY45UwxotFdRBspHGFdUcJvjuMn1ZpIXrWdfekd bKLPeSaxwaz8T3mkeJkFmawMJwcZZVmTJNKmzXD/NXRoFhwZLbwGCvO41lstUn8jxB2l64rwAxh 8WK51LtUXg+X3GOHivCl0trkdfSPhctupA8ArV2WHo1wrQkWbmmGq3mHElsneFFppgtZwtiHs17 mAuKZ+mwLsYVJI0CM3df7n77dGXb6NqJy9lI5WxkjsxmE1S69EpoVYcg4dYAsNBYSQY8h9sVjB+ V94MSdZyqJBQ1icnQLbBR0I9NSDmX0rK+GBDXj4zPr0z1bq+SOuvygZLqwo5aVN012LugjtICHV weDXWBrnNMu80tqAbFdWOkbAdwSUl60XsxG+jVtFj61KKMLkMgnJbWwBcVSaEibQ+wxgv5WBZBU AW9ekDYZjZxGYcprYM/QzhQsPC39b+zeLg9H99Zmvx/rTk2+znc9Z7I20UTnBSpsvVkTOdbnKfp SmWPO+02ojaYD6g== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As a CRTC will be a directory in ConfigFS, add the name configuration for CRTC name so we will be able to reflect the configfs directory name in the drm name. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_config.c | 5 +++++ drivers/gpu/drm/vkms/vkms_config.h | 2 ++ drivers/gpu/drm/vkms/vkms_crtc.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 7ef525091967..a6bf7ae6d216 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -35,6 +35,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable if (!crtc) goto err_alloc; crtc->writeback = enable_writeback; + crtc->name = kzalloc(sizeof("Main CRTC"), GFP_KERNEL); + if (!crtc->name) + goto err_alloc; + sprintf(crtc->name, "Main CRTC"); encoder = vkms_config_create_encoder(vkms_config); if (!encoder) @@ -213,6 +217,7 @@ void vkms_config_delete_crtc(struct vkms_config_crtc *vkms_config_crtc, } } + kfree(vkms_config_crtc->name); kfree(vkms_config_crtc); } diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 4223edd94ec2..4a4c16dea785 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -29,6 +29,7 @@ struct vkms_config { * struct vkms_config_crtc * * @link: Link to the others CRTCs + * @name: Name of the CRTC * @possible_planes: List of planes that can be used with this CRTC * @possible_encoders: List of encoders that can be used with this CRTC * @crtc: Internal usage. This pointer should never be considered as valid. It can be used to @@ -38,6 +39,7 @@ struct vkms_config { struct vkms_config_crtc { struct list_head link; + char *name; bool writeback; struct xarray possible_planes; struct xarray possible_encoders; diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 654238dbba7f..5b659d67b9ce 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -298,7 +298,7 @@ struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkmsdev, int ret; vkms_crtc = drmm_crtc_alloc_with_planes(dev, struct vkms_crtc, base, primary, cursor, - &vkms_crtc_funcs, NULL); + &vkms_crtc_funcs, config->name); if (IS_ERR(vkms_crtc)) { DRM_DEV_ERROR(vkmsdev->drm.dev, "Failed to init CRTC\n"); return vkms_crtc; From patchwork Wed Aug 14 14:36:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763592 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1F4BC531DD for ; Wed, 14 Aug 2024 14:36:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D38110E4B7; Wed, 14 Aug 2024 14:36:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="K3jN91+K"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6544810E4B5 for ; Wed, 14 Aug 2024 14:36:45 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 536561C000B; Wed, 14 Aug 2024 14:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723646204; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oh5J5yJD1QGXQVNHCbk2GC0MqGv1gEpAaQW/069rk7E=; b=K3jN91+Kx3zJmu5DOH+VR/lCakJNEz3osLVwNK/5/8HdfAidm8TwP+lQhCMvz6SnfMYL7G J+cnoWE9mSk0pbKt27mAJI2VSvv+uksRK8SI5qRMI9U/nH2i5KmthbvC5u2lEXWgdGMO9a C7aBjVNHHpXgrZjD7Iw1HfMTlPbaBhOmqHLV0Z5ltO043AZvtrDPy7QMaVtn3gP58JWn9R 9t4xSGTbACmwMctANsHqYSmczN0JO29C2Zt0bzgn/naE/Kn+ENqhPAC3fBXBLm93scka/F 4Y0XgncbqNq9haVStqB4MVZhH4Lbmcl9ekW264MFqYcreP8Y1inyPHpTbCQdjQ== From: Louis Chauvet Date: Wed, 14 Aug 2024 16:36:37 +0200 Subject: [PATCH RFC 15/15] drm/vkms: Add test for config structure MIME-Version: 1.0 Message-Id: <20240814-google-remove-crtc-index-from-parameter-v1-15-6e179abf9fd4@bootlin.com> References: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-0-6e179abf9fd4@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=6983; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=IzCagxCQflBHvQnmqL8UXu+1mbrEZiyd8TFVurkvc4Q=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvMDrRPo9xTG6T0MkQPgb/eR9WdxHXLHpuhS3/ zCR4KmcVIyJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrzA6wAKCRAgrS7GWxAs 4iJdD/wOfjpz39KFwiLAqQRxLg8+8Y9opnQ/2NpCNdKRAXp95hA9y1KJX3e+OQf11SzOwl/5Ffc 9VR27pfOH2BUbnMnCtBCbyrw0gtwdGAb8K0YRXOgk4oi/ZrHOUfHFV5AAAVvHLsbr+rHdgW7WdH OS1/QMu4fky2YNPNib6AA4CFQD9bR9sQUuUlWE16KQPpqUc+ABP290J1z8kY/S08oIzRyQpkEGI YPd+n49wTGfVKFAHF350vEl/uK4ezCAmAquDn6MPhqiL43axuDiD8wgn4xGPC8qwTAZVXgQGg1q V3Lxx6/LXybp6+dEJe6trJwvMYnD9LSvNZXAFYcCmEBvPBs/jz3o0XNB3b85PJFtxsGu33z9TDg BLH5vjvij32u27bIUdhSsneSqKQe0teDfyvaLPjlYt/YkZGZd0VvdBMAwTYGGAOtUg6VRSdNdgc GgYG+lcOCTA3tbms86f3AAy1uHKylWB7em1cJZ1PdnSXEAAA4epdF1+40tvCT0Wnio2WEU2GcFI 4YmshbY6UgNBwpVh6LSIG1irGgV7RKxUM0u5rFGbh9e/vWlupF1OlRxH6fc8aY0W9BPW6z7Uwgo 4qMfvfEu7VMimfmpp3hM7zG4+NxkMMG7RNS8iVoLQE+15r0AuaFVxf3SPy2X28QB5MQhLC9lr8w b1nC7tm9T57q6VA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The config structure is a bit complex in term of memory management. Add basic test to avoid breaking it in the future. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/tests/Makefile | 1 + drivers/gpu/drm/vkms/tests/vkms_config_test.c | 135 ++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/drivers/gpu/drm/vkms/tests/Makefile b/drivers/gpu/drm/vkms/tests/Makefile index 2d1df668569e..ec71b5fe7f9d 100644 --- a/drivers/gpu/drm/vkms/tests/Makefile +++ b/drivers/gpu/drm/vkms/tests/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += vkms_format_test.o +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += vkms_config_test.o diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c new file mode 100644 index 000000000000..6ec0021a8df3 --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "../vkms_config.h" + +static void vkms_config_test_basic_allocation(struct kunit *test) +{ + struct vkms_config *config = vkms_config_create(); + + KUNIT_EXPECT_TRUE_MSG(test, list_empty(&config->encoders), + "Encoder list is not empty after allocation"); + KUNIT_EXPECT_TRUE_MSG(test, list_empty(&config->crtcs), + "CRTC list is not empty after allocation"); + KUNIT_EXPECT_TRUE_MSG(test, list_empty(&config->planes), + "Plane list is not empty after allocation"); + + vkms_config_destroy(config); +} + +static void vkms_config_test_simple_config(struct kunit *test) +{ + struct vkms_config *config = vkms_config_create(); + + struct vkms_config_plane *plane_1 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_2 = vkms_config_create_plane(config); + struct vkms_config_crtc *crtc = vkms_config_create_crtc(config); + struct vkms_config_encoder *encoder = vkms_config_create_encoder(config); + + KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config)); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->planes), 2); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->crtcs), 1); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->encoders), 1); + + plane_1->type = DRM_PLANE_TYPE_PRIMARY; + plane_2->type = DRM_PLANE_TYPE_CURSOR; + + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_1, crtc), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_2, crtc), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder, crtc), 0); + + KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config)); + + vkms_config_delete_plane(plane_1, config); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->planes), 1); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->crtcs), 1); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->encoders), 1); + + KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config)); + + plane_2->type = DRM_PLANE_TYPE_PRIMARY; + + KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config)); + + vkms_config_destroy(config); +} + +static void vkms_config_test_complex_config(struct kunit *test) +{ + struct vkms_config *config = vkms_config_create(); + + struct vkms_config_plane *plane_1 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_2 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_3 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_4 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_5 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_6 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_7 = vkms_config_create_plane(config); + struct vkms_config_plane *plane_8 = vkms_config_create_plane(config); + struct vkms_config_crtc *crtc_1 = vkms_config_create_crtc(config); + struct vkms_config_crtc *crtc_2 = vkms_config_create_crtc(config); + struct vkms_config_encoder *encoder_1 = vkms_config_create_encoder(config); + struct vkms_config_encoder *encoder_2 = vkms_config_create_encoder(config); + struct vkms_config_encoder *encoder_3 = vkms_config_create_encoder(config); + struct vkms_config_encoder *encoder_4 = vkms_config_create_encoder(config); + + KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config)); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->planes), 8); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->crtcs), 2); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->encoders), 4); + + plane_1->type = DRM_PLANE_TYPE_PRIMARY; + plane_2->type = DRM_PLANE_TYPE_CURSOR; + plane_3->type = DRM_PLANE_TYPE_OVERLAY; + plane_4->type = DRM_PLANE_TYPE_OVERLAY; + plane_5->type = DRM_PLANE_TYPE_PRIMARY; + plane_6->type = DRM_PLANE_TYPE_CURSOR; + plane_7->type = DRM_PLANE_TYPE_OVERLAY; + plane_8->type = DRM_PLANE_TYPE_OVERLAY; + + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_1, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_2, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_3, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_4, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_5, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_6, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_7, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_8, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_3, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_plane_attach_crtc(plane_4, crtc_2), 0); + + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_1, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_2, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_3, crtc_1), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_3, crtc_2), 0); + KUNIT_EXPECT_EQ(test, vkms_config_encoder_attach_crtc(encoder_4, crtc_2), 0); + + KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config)); + + vkms_config_delete_plane(plane_4, config); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->planes), 7); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->crtcs), 2); + KUNIT_EXPECT_EQ(test, list_count_nodes(&config->encoders), 4); + + KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config)); + + vkms_config_destroy(config); +} + +static struct kunit_case vkms_config_test_cases[] = { + KUNIT_CASE(vkms_config_test_basic_allocation), + KUNIT_CASE(vkms_config_test_simple_config), + KUNIT_CASE(vkms_config_test_complex_config), + {} +}; + +static struct kunit_suite vkms_config_test_suite = { + .name = "vkms-config", + .test_cases = vkms_config_test_cases, +}; + +kunit_test_suite(vkms_config_test_suite); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Kunit test for vkms config utility");