From patchwork Tue Aug 13 10:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761777 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 3434CC52D7C for ; Tue, 13 Aug 2024 10:51:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B3C4810E2EA; Tue, 13 Aug 2024 10:51:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XT9I0+i7"; dkim-atps=neutral Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 91F3810E2E8 for ; Tue, 13 Aug 2024 10:51:41 +0000 (UTC) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-428fb103724so35874375e9.1 for ; Tue, 13 Aug 2024 03:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546300; x=1724151100; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aX42+dlGnq5Uu/bZprAtS71gyG2lrM/6mSZ/7RZ5Qm0=; b=XT9I0+i7dsn4RBfUfRqlmYTmxpJ8XbwjlkFDl7BQRJIYro8KU/jaTlsb+GE1Rf4r5g 1NWs6Ibu4gg7wYfU69sdc1AduVWmbUxe2xILKe+2PFbymIS73z5DRUXnwCYvqcyoX9u4 X+3lo+xkHkKVzHwJmNHnfu7h95JQbK5INXndWY+sXzF2F/QtYnR6O6FcqdpKKFV8chw6 gwmi6qR5nKMUpQWWoiRug2mOZtGs8wWfDLivc0awbhaZE9lxsAO5pCmifAuavuS4Dsg+ lC7slIcVTY4ecTmlSU3+TcwHCNLO5LLVHdDqr+4qMaoyx/5X33c5pXaRdP5eofOaKjkS DnHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546300; x=1724151100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aX42+dlGnq5Uu/bZprAtS71gyG2lrM/6mSZ/7RZ5Qm0=; b=XFCKG1nVXZXa7SDtrL1l1PUmgTGbhz3j/iEkT/10eQQ/6pgtqGVvcyDCFkcRj1NoGB 4K5YX5sZjuIX0+uvAhNkGiPXyVqiAVhjrzZf1MLleOulqMyvjc7W2Mu0F8ygnD65rJyD oZgfAayZp6OUM+MRONxhUUXCs0ki7UKHQdjWfsMAn08lE+ZEqS+suU0vOw/Xhp/osBSY TNuzc5IE64wZzwOhE5csgRaITHIxileSyLwIxZ+rwtNoENTWRam6+18nXE0mDkfWlPt1 +PKeoa3MJ8pyjnhXfQpS4LnzZO/B+tWjI2bfd2LFWrudouZCVBK589x94/N9EsNuHOr8 X9VQ== X-Forwarded-Encrypted: i=1; AJvYcCUKkAP7S2TL4dgx+hw2u9NxUlegO76fPK3NnTMs2AjxrOfyLM05t/ALlImoG5nQsopcGbKrGU8NDU9AGqyBWHCy08cNIOIaEHhn+Yo0EQ1J X-Gm-Message-State: AOJu0YzvZKUAestBH2CK8jmv1u5fNojyap/MERIXuUXIIUChkd0MMR5x 95u0T/43tLTZY0W5dir0P+u48usEqTxcXngz+3eQhleNfSL4R9t0 X-Google-Smtp-Source: AGHT+IFnztvBdTmZK2l5Gnaz08NvYB3FWKUb0WnOFAD4K52NsHAruw7MbK8ufdnmNtvFmrN1DFmdNw== X-Received: by 2002:a05:600c:1552:b0:427:ee01:ebf0 with SMTP id 5b1f17b1804b1-429d62b74c7mr20852325e9.8.1723546299553; Tue, 13 Aug 2024 03:51:39 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:39 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 01/17] drm/vkms: Extract vkms_config header Date: Tue, 13 Aug 2024 12:44:12 +0200 Message-ID: <20240813105134.17439-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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: José Expósito --- drivers/gpu/drm/vkms/Makefile | 3 +- drivers/gpu/drm/vkms/vkms_config.c | 48 ++++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 25 ++++++++++++++++ drivers/gpu/drm/vkms/vkms_drv.c | 34 +++++---------------- drivers/gpu/drm/vkms/vkms_drv.h | 10 +------ drivers/gpu/drm/vkms/vkms_output.c | 1 + 6 files changed, 84 insertions(+), 37 deletions(-) create mode 100644 drivers/gpu/drm/vkms/vkms_config.c create mode 100644 drivers/gpu/drm/vkms/vkms_config.h diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index 1b28a6a32948..b371b5d70ee3 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -6,6 +6,7 @@ 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 diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c new file mode 100644 index 000000000000..c58eda76c238 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include +#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_debugfs_init(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..65da8cd6ff96 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_CONFIG_H_ +#define _VKMS_CONFIG_H_ + +#include + +struct vkms_device; + +struct vkms_config { + bool writeback; + bool cursor; + bool overlay; + /* only set when instantiated */ + struct vkms_device *dev; +}; + +/* VKMS Config */ +struct vkms_config *vkms_config_create(void); +void vkms_config_destroy(struct vkms_config *config); + +/* DebugFS */ +void vkms_config_debugfs_init(struct vkms_device *vkms_device); + +#endif /* _VKMS_CONFIG_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 8dc9dc13896e..6bf462985731 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -26,11 +26,9 @@ #include #include +#include "vkms_config.h" #include "vkms_drv.h" -#include -#include - #define DRIVER_NAME "vkms" #define DRIVER_DESC "Virtual Kernel Mode Setting" #define DRIVER_DATE "20180514" @@ -90,23 +88,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, .release = vkms_release, @@ -216,8 +197,7 @@ static int vkms_create(struct vkms_config *config) if (ret) goto out_devres; - drm_debugfs_add_files(&vkms_device->drm, vkms_config_debugfs_list, - ARRAY_SIZE(vkms_config_debugfs_list)); + vkms_config_debugfs_init(vkms_device); ret = drm_dev_register(&vkms_device->drm, 0); if (ret) @@ -239,9 +219,9 @@ static int __init vkms_init(void) int ret; struct vkms_config *config; - config = kmalloc(sizeof(*config), GFP_KERNEL); - if (!config) - return -ENOMEM; + config = vkms_config_create(); + if (IS_ERR(config)) + return PTR_ERR(config); default_config = config; @@ -251,7 +231,7 @@ static int __init vkms_init(void) ret = vkms_create(config); if (ret) - kfree(config); + vkms_config_destroy(config); return ret; } @@ -280,7 +260,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 5e46ea5b96dc..5c523ca27f22 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -115,15 +115,7 @@ struct vkms_output { spinlock_t composer_lock; }; -struct vkms_device; - -struct vkms_config { - bool writeback; - bool cursor; - bool overlay; - /* only set when instantiated */ - struct vkms_device *dev; -}; +struct vkms_config; struct vkms_device { struct drm_device drm; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 5ce70dd946aa..afe3945c1962 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ +#include "vkms_config.h" #include "vkms_drv.h" #include #include From patchwork Tue Aug 13 10:44:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761776 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 8EBF3C52D7B for ; Tue, 13 Aug 2024 10:51:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1404610E2E9; Tue, 13 Aug 2024 10:51:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AQnzdDZn"; dkim-atps=neutral Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 688D910E2E9 for ; Tue, 13 Aug 2024 10:51:42 +0000 (UTC) Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-530c2e5f4feso5419500e87.0 for ; Tue, 13 Aug 2024 03:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546300; x=1724151100; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lragSOY+WyXV5ZZ+AC/3nB1kh+DnIY/4SWizX87fSmc=; b=AQnzdDZnJ1XqSyA8j6/eGyK8KsLnRP57slNDbToz/XSMeOhEyBD2eO+lvFtVFUd7VJ /GHdVeRvDqSjNPvFgEpofZU1VdsotXfYegUq9WwMfrTyHh9kXChQp9kVLK+HC26ZrwKj brnX7B9TflLyhOZWQ6vzH5JpwoYkIyoi3g1qAZjiCE/Ac/qSxc1nO45/j/9ZiQkpj9y1 kMHF761KkR4OPqrIYy0kqhUnCiU7qyC6qFdluoH7WXdGQJVmp3gjmz+YT5IiyhwNmhHH XUsnVCw0S6QPjc1gftz6bgY+KSUZlaQxWAWkV8Ka4ym5aH4oMV7rwKzNVdauUMNLnkwD zvIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546300; x=1724151100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lragSOY+WyXV5ZZ+AC/3nB1kh+DnIY/4SWizX87fSmc=; b=oMZTjNF47pMA8ZDsto1s88RudTAL3HnVvzsmL33dH07whCE8PFGyZwGqZwnt4WoRIr 4Mihj2NZDtW/0ItN78tx/P5GHrttyRpsk2n1PxMYOIUNVzU75EAQ0TfTbVqmYT2mLcvl 58S8KdIsZgsC+jYQ7LyVaU2I8TBShGLZTajH/Pkg9g0IOlxF5LoHFMMvXrFlBuIb8M+2 9I3XYK8geBICvayVTvtr8wrG68dn1qRsTRtZxS975IyTK+G6uHin01ECezu43JxRiOkX W5RBX/wqkfTUU8codf9QvFxIdLM6p4oL4w6pCjGnCWQzhufk2EmwwyiUZzTjkyW+xKSA uOpw== X-Forwarded-Encrypted: i=1; AJvYcCUGATQkXAuHNrQl/iHiuQijvxEQ6Skfd7Hzo4heHjsNm+OXnoVkh9lfSlabD00qEhqmZvhQ/gojwT7LWTTsJVTkH6wR21F4L1hzvREMld6Z X-Gm-Message-State: AOJu0Yw9B/qvbLm2mvTQqz81FiaMpYd8efbGRFLd3vrXABs3llj/LAR4 gqokEnTmaYDJZ2iSAeX+g2S9HootdwJFmQ9IpAIgVxNZsAjPZEEL X-Google-Smtp-Source: AGHT+IFBmBPHwR0QDHZKoVinyy3tTqQhhWg3jOVvvlJ/Sxvq5wNS2shu8jAtd2HItIOh+bOK6z5ezA== X-Received: by 2002:a05:6512:10c6:b0:52e:95dd:a8ed with SMTP id 2adb3069b0e04-532136613e6mr2058293e87.35.1723546300375; Tue, 13 Aug 2024 03:51:40 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:40 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 02/17] drm/vkms: Move default_config creation to its own function Date: Tue, 13 Aug 2024 12:44:13 +0200 Message-ID: <20240813105134.17439-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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: José Expósito --- drivers/gpu/drm/vkms/vkms_config.c | 17 +++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 3 +++ drivers/gpu/drm/vkms/vkms_drv.c | 6 +----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index c58eda76c238..4c7cda16dfd8 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -19,6 +19,23 @@ struct vkms_config *vkms_config_create(void) return config; } +struct vkms_config *vkms_config_default_create(bool enable_cursor, + bool enable_writeback, + bool enable_overlay) +{ + struct vkms_config *config; + + config = vkms_config_create(); + if (IS_ERR(config)) + return config; + + config->cursor = enable_cursor; + config->writeback = enable_writeback; + config->overlay = enable_overlay; + + return 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 65da8cd6ff96..83181760b02b 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -17,6 +17,9 @@ struct vkms_config { /* VKMS Config */ struct vkms_config *vkms_config_create(void); +struct vkms_config *vkms_config_default_create(bool enable_cursor, + bool enable_writeback, + bool enable_overlay); void vkms_config_destroy(struct vkms_config *config); /* DebugFS */ diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 6bf462985731..4e36989589f9 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -219,16 +219,12 @@ static int __init vkms_init(void) int ret; struct vkms_config *config; - config = vkms_config_create(); + config = vkms_config_default_create(enable_cursor, enable_writeback, enable_overlay); if (IS_ERR(config)) return PTR_ERR(config); default_config = config; - config->cursor = enable_cursor; - config->writeback = enable_writeback; - config->overlay = enable_overlay; - ret = vkms_create(config); if (ret) vkms_config_destroy(config); From patchwork Tue Aug 13 10:44:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761778 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 6960AC52D7D for ; Tue, 13 Aug 2024 10:51:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD53610E2EC; Tue, 13 Aug 2024 10:51:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="i0MYMbLP"; dkim-atps=neutral Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6A47E10E2EA for ; Tue, 13 Aug 2024 10:51:44 +0000 (UTC) Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-52efd855adbso6672956e87.2 for ; Tue, 13 Aug 2024 03:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546302; x=1724151102; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dQhdCIG6a+LBFR6SphoPahDGZ++LmLY0vx0sk4HKH/c=; b=i0MYMbLPNUgfuUhdyJacZywVlPGm872HWRgFodFe9MSD/4pwiImkClBgLsivP1mcB7 FdUgfyoLE6C/K8uC2l4r5F/52wh2XG4/mWnQbhKE2E/K1JtpOeH1/w8/MRTaXRbEuKvY +COBwmhXF38dzKRG6Xts1sukhCOK/DxCqoEsXXoK0JQBj7o2vDJlAWcqzm40c/nj7PVF rL/hiHhCecB/a417QbyW1U2klj6k7tH03LfvuXcBHfOTZn8xtFA+2Z3Bup+msqmD0Ww1 RXw1J7PvCWBuoEPOZYN4fpukRJNGPUKFcWUQKLn9E+EI5MWVKKdSjZ9kEV0jlVEJPQVZ Pjvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546302; x=1724151102; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dQhdCIG6a+LBFR6SphoPahDGZ++LmLY0vx0sk4HKH/c=; b=cTWiifRqhyagspRzykukxBj+ApENl8Ljnqd+kHr7enZlXobaa7xZSapkzmE71Jd+6L eRUoefwEMjzOVsmUpGsFKA1gJLYtwhO1LiP4c8o/3+wPy2jJ0RUAXN+WQt/lfxNny3w1 IwyZkIhFv9lMG7UTwaOpRSvQnjdO3ZEoOWhLNjVfVMU3j27mAtagHCgoAKEzpdYkzLfv q4AjJJpOX/n1xaBfOvedwqABnJlVTn2EptuS/2D0p/S/Z4wEZlZeCUZNehNpEgwVqqiJ m6ON5acOzSd57rnzZNt5d0AVOnxi/cpGEk5E/CP2nax8sLXEeRffdYBH5I9r9pccLpOl D0nA== X-Forwarded-Encrypted: i=1; AJvYcCXxodfIsRj7AVnDHTEGr+SXjXs7yaCQfpX8OBaP77ggHHoItuOKSui/NhRMJfS9EGfdBpmJLq0NqjE=@lists.freedesktop.org X-Gm-Message-State: AOJu0Yz4FURjqBkt1omd1F42sAidPkAVfypoDG57llx4mG2vCAuHsw34 EaCnu0ybk9Sl+vSnAfPIHJNKqYFpPelnTF7dg7WuS5MlWmqBXGtv X-Google-Smtp-Source: AGHT+IGz72xfDrVPTMYgNZfRCFDLS7p2EH5rjzJWTApdrx62JJLa/NcdcQnhtxEsWIZrL7727HPLLA== X-Received: by 2002:a05:6512:282c:b0:52c:cd4f:b95b with SMTP id 2adb3069b0e04-53213657d99mr2098654e87.22.1723546302294; Tue, 13 Aug 2024 03:51:42 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:40 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 03/17] drm/vkms: Set device name from vkms_config Date: Tue, 13 Aug 2024 12:44:14 +0200 Message-ID: <20240813105134.17439-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" In order to be able to create multiple devices, the device name needs to be unique. Allow to set it in the VKMS configuration. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_config.c | 7 +++++-- drivers/gpu/drm/vkms/vkms_config.h | 3 ++- drivers/gpu/drm/vkms/vkms_drv.c | 2 +- drivers/gpu/drm/vkms/vkms_drv.h | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 4c7cda16dfd8..6ab8091bf72f 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -8,7 +8,7 @@ #include "vkms_config.h" #include "vkms_drv.h" -struct vkms_config *vkms_config_create(void) +struct vkms_config *vkms_config_create(char *dev_name) { struct vkms_config *config; @@ -16,6 +16,8 @@ struct vkms_config *vkms_config_create(void) if (!config) return ERR_PTR(-ENOMEM); + config->dev_name = dev_name; + return config; } @@ -25,7 +27,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, { struct vkms_config *config; - config = vkms_config_create(); + config = vkms_config_create(DEFAULT_DEVICE_NAME); if (IS_ERR(config)) return config; @@ -47,6 +49,7 @@ 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); + seq_printf(m, "dev_name=%s\n", vkmsdev->config->dev_name); 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); diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 83181760b02b..ba06aad32799 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -8,6 +8,7 @@ struct vkms_device; struct vkms_config { + char *dev_name; bool writeback; bool cursor; bool overlay; @@ -16,7 +17,7 @@ struct vkms_config { }; /* VKMS Config */ -struct vkms_config *vkms_config_create(void); +struct vkms_config *vkms_config_create(char *dev_name); struct vkms_config *vkms_config_default_create(bool enable_cursor, bool enable_writeback, bool enable_overlay); diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 4e36989589f9..2f9d1db0cfae 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -160,7 +160,7 @@ static int vkms_create(struct vkms_config *config) struct platform_device *pdev; struct vkms_device *vkms_device; - pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); + pdev = platform_device_register_simple(config->dev_name, -1, NULL, 0); if (IS_ERR(pdev)) return PTR_ERR(pdev); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 5c523ca27f22..87e44b51a03f 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -12,6 +12,8 @@ #include #include +#define DEFAULT_DEVICE_NAME "vkms" + #define XRES_MIN 10 #define YRES_MIN 10 From patchwork Tue Aug 13 10:44:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761781 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 6972EC52D7D for ; Tue, 13 Aug 2024 10:51:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C26C610E2F0; Tue, 13 Aug 2024 10:51:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="J//+aEs3"; dkim-atps=neutral Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2380C10E2ED for ; Tue, 13 Aug 2024 10:51:46 +0000 (UTC) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-42817bee9e8so39958395e9.3 for ; Tue, 13 Aug 2024 03:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546304; x=1724151104; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Jy+nd+TAf4IESSyfkjPEUCiVjjMM3g7sHyZYE6lpLK4=; b=J//+aEs38T1Zh0K7A8Mi2lcuuVDQcz2uoOMtGIjLdl46F2A2n7E19bslubd8RdQrQN guWhuHKOOm11PLiHnSVy96kICdBURMnlsJUVGvEi7MWq0+Cj8nh6ogauPqGrv+3u4fMU Ak8oPLlAqNhLgNMLrevrLSj5SKEjjRvvZTNq0+EUsp8p1hy0HokKFsy3tAdVwW/jZ7uz Z3J7oYVZcZTuHwcz/3loMlMosiCMk/HSvVb/CvG8Vn4aqdvBeogzxWm6+wys5aUONSaS hHA+ouwfhuPyO4Q/n9yXnSkUk7F40qLfESJkJq0iLOWzXb8W6J0ZTTuniShXa3RNVElh q2SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546304; x=1724151104; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jy+nd+TAf4IESSyfkjPEUCiVjjMM3g7sHyZYE6lpLK4=; b=lf6HoJhfDIdbDLPIzLm/nLJAbNKAAijBvfPpwlegTcU5pRK6u559p6DFUyWxbXpOEU HC4lIRxf+ySReOZg/easrLjhRp2/H389xU0hgcfD50A92e6a1dBPz4Fvnxg0MOlshNwx qT/+DdA/ZjrbDF5IxKZFaOxHNVDgsYVsSOTf2d4KPelkizPlVIQel+JMVyScKIgXbzUy ivVtkiHKE5Sd5iVIgYYEOboMVEOVa2pZNbIfBBzRu8YoW0igd/MFQ2w+lCu1BbsZcJMM CFWE3AWsl7yBNO1ByVlBY71Rznt3qNn0hyOMXXErwMudyVlUuqAnMOlC134ShgJHB1U2 /cjw== X-Forwarded-Encrypted: i=1; AJvYcCVL8WJq9DWrSC2vsNfcdjR+jyPMtqN9c0lvt6dqEvJbB03cmP+pOes/JJ4T+y9O7+b1sjaYKwRPPlaFYZOoQq60fv9ehVUs0hLsGyLqfuoI X-Gm-Message-State: AOJu0YxmQ/T2zhC9Z0q1SoXnwdBaAYNxdR9xKMBAh6wywuelh8ABN5lo F2+uuhY1XOaNc1/dr4mTeiId4VkmMLK1bafr1KL602cbwMmlmqV6vX82M5g4 X-Google-Smtp-Source: AGHT+IF3l5a4JzrfLhkKB4hv+VwVgn6Mbv1kVLmbzNJj3J6TXJA+MNrPOXrNN/qld+ZDEq9xJpiUQQ== X-Received: by 2002:a05:600c:474d:b0:426:5ef5:bcb1 with SMTP id 5b1f17b1804b1-429d47f1e4emr20048745e9.6.1723546304134; Tue, 13 Aug 2024 03:51:44 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:42 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 04/17] drm/vkms: Allow to configure multiple CRTCs Date: Tue, 13 Aug 2024 12:44:15 +0200 Message-ID: <20240813105134.17439-5-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Add a list of CRTC configurations to vkms_config and add as many CRTCs as configured during output initialization. For backwards compatibility, create a single CRTC in the default configuration. Since writeback support, vblank and composer states are now per CRTC, extract all the fields to the vkms_crtc structure and allow each vkms_device to have a list of CRTCs. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_composer.c | 30 ++++---- drivers/gpu/drm/vkms/vkms_config.c | 54 ++++++++++++++- drivers/gpu/drm/vkms/vkms_config.h | 15 +++- drivers/gpu/drm/vkms/vkms_crtc.c | 99 ++++++++++++++------------- drivers/gpu/drm/vkms/vkms_drv.c | 10 ++- drivers/gpu/drm/vkms/vkms_drv.h | 35 +++++++--- drivers/gpu/drm/vkms/vkms_output.c | 38 +++++----- drivers/gpu/drm/vkms/vkms_writeback.c | 27 ++++---- 8 files changed, 197 insertions(+), 111 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index e7441b227b3c..b1723cf02ed3 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -306,13 +306,13 @@ void vkms_composer_worker(struct work_struct *work) composer_work); struct drm_crtc *crtc = crtc_state->base.crtc; struct vkms_writeback_job *active_wb = crtc_state->active_writeback; - struct vkms_output *out = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); bool crc_pending, wb_pending; u64 frame_start, frame_end; u32 crc32 = 0; int ret; - spin_lock_irq(&out->composer_lock); + spin_lock_irq(&vkms_crtc->composer_lock); frame_start = crtc_state->frame_start; frame_end = crtc_state->frame_end; crc_pending = crtc_state->crc_pending; @@ -336,7 +336,7 @@ void vkms_composer_worker(struct work_struct *work) crtc_state->gamma_lut.base = NULL; } - spin_unlock_irq(&out->composer_lock); + spin_unlock_irq(&vkms_crtc->composer_lock); /* * We raced with the vblank hrtimer and previous work already computed @@ -354,10 +354,10 @@ void vkms_composer_worker(struct work_struct *work) return; if (wb_pending) { - drm_writeback_signal_completion(&out->wb_connector, 0); - spin_lock_irq(&out->composer_lock); + drm_writeback_signal_completion(&vkms_crtc->wb_connector, 0); + spin_lock_irq(&vkms_crtc->composer_lock); crtc_state->wb_pending = false; - spin_unlock_irq(&out->composer_lock); + spin_unlock_irq(&vkms_crtc->composer_lock); } /* @@ -407,31 +407,31 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *src_name, return 0; } -void vkms_set_composer(struct vkms_output *out, bool enabled) +void vkms_set_composer(struct vkms_crtc *vkms_crtc, bool enabled) { bool old_enabled; if (enabled) - drm_crtc_vblank_get(&out->crtc); + drm_crtc_vblank_get(&vkms_crtc->base); - spin_lock_irq(&out->lock); - old_enabled = out->composer_enabled; - out->composer_enabled = enabled; - spin_unlock_irq(&out->lock); + spin_lock_irq(&vkms_crtc->lock); + old_enabled = vkms_crtc->composer_enabled; + vkms_crtc->composer_enabled = enabled; + spin_unlock_irq(&vkms_crtc->lock); if (old_enabled) - drm_crtc_vblank_put(&out->crtc); + drm_crtc_vblank_put(&vkms_crtc->base); } int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name) { - struct vkms_output *out = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); bool enabled = false; int ret = 0; ret = vkms_crc_parse_source(src_name, &enabled); - vkms_set_composer(out, enabled); + vkms_set_composer(vkms_crtc, enabled); return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 6ab8091bf72f..3af750071f04 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -17,6 +17,7 @@ struct vkms_config *vkms_config_create(char *dev_name) return ERR_PTR(-ENOMEM); config->dev_name = dev_name; + config->crtcs = (struct list_head)LIST_HEAD_INIT(config->crtcs); return config; } @@ -26,20 +27,29 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, bool enable_overlay) { struct vkms_config *config; + struct vkms_config_crtc *crtc_cfg; config = vkms_config_create(DEFAULT_DEVICE_NAME); if (IS_ERR(config)) return config; config->cursor = enable_cursor; - config->writeback = enable_writeback; config->overlay = enable_overlay; + crtc_cfg = vkms_config_add_crtc(config, enable_writeback); + if (IS_ERR(crtc_cfg)) + return ERR_CAST(crtc_cfg); + return config; } void vkms_config_destroy(struct vkms_config *config) { + struct vkms_config_crtc *crtc_cfg, *crtc_tmp; + + list_for_each_entry_safe(crtc_cfg, crtc_tmp, &config->crtcs, list) + vkms_config_destroy_crtc(config, crtc_cfg); + kfree(config); } @@ -48,12 +58,20 @@ 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_crtc *crtc_cfg; + int n; seq_printf(m, "dev_name=%s\n", vkmsdev->config->dev_name); - 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); + n = 0; + list_for_each_entry(crtc_cfg, &vkmsdev->config->crtcs, list) { + seq_printf(m, "crtc(%d).writeback=%d\n", n, + crtc_cfg->writeback); + n++; + } + return 0; } @@ -66,3 +84,35 @@ void vkms_config_debugfs_init(struct vkms_device *vkms_device) drm_debugfs_add_files(&vkms_device->drm, vkms_config_debugfs_list, ARRAY_SIZE(vkms_config_debugfs_list)); } + +struct vkms_config_crtc *vkms_config_add_crtc(struct vkms_config *config, + bool enable_writeback) +{ + struct vkms_config_crtc *crtc_cfg; + + crtc_cfg = kzalloc(sizeof(*crtc_cfg), GFP_KERNEL); + if (!crtc_cfg) + return ERR_PTR(-ENOMEM); + + crtc_cfg->writeback = enable_writeback; + + crtc_cfg->index = 0; + if (!list_empty(&config->crtcs)) { + struct vkms_config_crtc *last; + + last = list_last_entry(&config->crtcs, struct vkms_config_crtc, + list); + crtc_cfg->index = last->index + 1; + } + + list_add_tail(&crtc_cfg->list, &config->crtcs); + + return crtc_cfg; +} + +void vkms_config_destroy_crtc(struct vkms_config *config, + struct vkms_config_crtc *crtc_cfg) +{ + list_del(&crtc_cfg->list); + kfree(crtc_cfg); +} diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index ba06aad32799..bc40a0e3859a 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -3,15 +3,22 @@ #ifndef _VKMS_CONFIG_H_ #define _VKMS_CONFIG_H_ +#include #include struct vkms_device; +struct vkms_config_crtc { + struct list_head list; + unsigned int index; + bool writeback; +}; + struct vkms_config { char *dev_name; - bool writeback; bool cursor; bool overlay; + struct list_head crtcs; /* only set when instantiated */ struct vkms_device *dev; }; @@ -26,4 +33,10 @@ void vkms_config_destroy(struct vkms_config *config); /* DebugFS */ void vkms_config_debugfs_init(struct vkms_device *vkms_device); +/* CRTCs */ +struct vkms_config_crtc *vkms_config_add_crtc(struct vkms_config *config, + bool enable_writeback); +void vkms_config_destroy_crtc(struct vkms_config *config, + struct vkms_config_crtc *crtc_cfg); + #endif /* _VKMS_CONFIG_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 40b4d084e3ce..41ab8f47331c 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -11,35 +11,34 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) { - struct vkms_output *output = container_of(timer, struct vkms_output, - vblank_hrtimer); - struct drm_crtc *crtc = &output->crtc; + struct vkms_crtc *vkms_crtc = timer_to_vkms_crtc(timer); + struct drm_crtc *crtc = &vkms_crtc->base; struct vkms_crtc_state *state; u64 ret_overrun; bool ret, fence_cookie; fence_cookie = dma_fence_begin_signalling(); - ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer, - output->period_ns); + ret_overrun = hrtimer_forward_now(&vkms_crtc->vblank_hrtimer, + vkms_crtc->period_ns); if (ret_overrun != 1) pr_warn("%s: vblank timer overrun\n", __func__); - spin_lock(&output->lock); + spin_lock(&vkms_crtc->lock); ret = drm_crtc_handle_vblank(crtc); if (!ret) DRM_ERROR("vkms failure on handling vblank"); - state = output->composer_state; - spin_unlock(&output->lock); + state = vkms_crtc->composer_state; + spin_unlock(&vkms_crtc->lock); - if (state && output->composer_enabled) { + if (state && vkms_crtc->composer_enabled) { u64 frame = drm_crtc_accurate_vblank_count(crtc); /* update frame_start only if a queued vkms_composer_worker() * has read the data */ - spin_lock(&output->composer_lock); + spin_lock(&vkms_crtc->composer_lock); if (!state->crc_pending) state->frame_start = frame; else @@ -47,9 +46,9 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) state->frame_start, frame); state->frame_end = frame; state->crc_pending = true; - spin_unlock(&output->composer_lock); + spin_unlock(&vkms_crtc->composer_lock); - ret = queue_work(output->composer_workq, &state->composer_work); + ret = queue_work(vkms_crtc->composer_workq, &state->composer_work); if (!ret) DRM_DEBUG_DRIVER("Composer worker already queued\n"); } @@ -62,32 +61,30 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) static int vkms_enable_vblank(struct drm_crtc *crtc) { struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc); - struct vkms_output *out = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); drm_calc_timestamping_constants(crtc, &crtc->mode); - hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - out->vblank_hrtimer.function = &vkms_vblank_simulate; - out->period_ns = ktime_set(0, vblank->framedur_ns); - hrtimer_start(&out->vblank_hrtimer, out->period_ns, HRTIMER_MODE_REL); + hrtimer_init(&vkms_crtc->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + vkms_crtc->vblank_hrtimer.function = &vkms_vblank_simulate; + vkms_crtc->period_ns = ktime_set(0, vblank->framedur_ns); + hrtimer_start(&vkms_crtc->vblank_hrtimer, vkms_crtc->period_ns, HRTIMER_MODE_REL); return 0; } static void vkms_disable_vblank(struct drm_crtc *crtc) { - struct vkms_output *out = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); - hrtimer_cancel(&out->vblank_hrtimer); + hrtimer_cancel(&vkms_crtc->vblank_hrtimer); } static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc, int *max_error, ktime_t *vblank_time, bool in_vblank_irq) { - struct drm_device *dev = crtc->dev; - struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); - struct vkms_output *output = &vkmsdev->output; + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc); if (!READ_ONCE(vblank->enabled)) { @@ -95,7 +92,7 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc, return true; } - *vblank_time = READ_ONCE(output->vblank_hrtimer.node.expires); + *vblank_time = READ_ONCE(vkms_crtc->vblank_hrtimer.node.expires); if (WARN_ON(*vblank_time == vblank->time)) return true; @@ -107,7 +104,7 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc, * the vblank core expects. Therefore we need to always correct the * timestampe by one frame. */ - *vblank_time -= output->period_ns; + *vblank_time -= vkms_crtc->period_ns; return true; } @@ -233,18 +230,18 @@ static void vkms_crtc_atomic_disable(struct drm_crtc *crtc, static void vkms_crtc_atomic_begin(struct drm_crtc *crtc, struct drm_atomic_state *state) { - struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); /* This lock is held across the atomic commit to block vblank timer * from scheduling vkms_composer_worker until the composer is updated */ - spin_lock_irq(&vkms_output->lock); + spin_lock_irq(&vkms_crtc->lock); } static void vkms_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_state *state) { - struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); if (crtc->state->event) { spin_lock(&crtc->dev->event_lock); @@ -259,9 +256,9 @@ static void vkms_crtc_atomic_flush(struct drm_crtc *crtc, crtc->state->event = NULL; } - vkms_output->composer_state = to_vkms_crtc_state(crtc->state); + vkms_crtc->composer_state = to_vkms_crtc_state(crtc->state); - spin_unlock_irq(&vkms_output->lock); + spin_unlock_irq(&vkms_crtc->lock); } static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = { @@ -272,30 +269,38 @@ static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = { .atomic_disable = vkms_crtc_atomic_disable, }; -int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *primary, struct drm_plane *cursor) +struct vkms_crtc *vkms_crtc_init(struct drm_device *dev, + struct drm_plane *primary, + struct drm_plane *cursor, + unsigned int index) { - struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc); - int ret; + struct vkms_crtc *crtc; - ret = drmm_crtc_init_with_planes(dev, crtc, primary, cursor, - &vkms_crtc_funcs, NULL); - if (ret) { - DRM_ERROR("Failed to init CRTC\n"); - return ret; + crtc = drmm_crtc_alloc_with_planes(dev, struct vkms_crtc, base, primary, + cursor, &vkms_crtc_funcs, NULL); + if (IS_ERR(crtc)) { + DRM_ERROR("Failed to alloc CRTC\n"); + return crtc; } - drm_crtc_helper_add(crtc, &vkms_crtc_helper_funcs); + crtc->base.index = index; + primary->possible_crtcs = drm_crtc_mask(&crtc->base); + if (cursor) + cursor->possible_crtcs = drm_crtc_mask(&crtc->base); - drm_mode_crtc_set_gamma_size(crtc, VKMS_LUT_SIZE); - drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE); + INIT_LIST_HEAD(&crtc->list); - spin_lock_init(&vkms_out->lock); - spin_lock_init(&vkms_out->composer_lock); + drm_crtc_helper_add(&crtc->base, &vkms_crtc_helper_funcs); - vkms_out->composer_workq = alloc_ordered_workqueue("vkms_composer", 0); - if (!vkms_out->composer_workq) - return -ENOMEM; + drm_mode_crtc_set_gamma_size(&crtc->base, VKMS_LUT_SIZE); + drm_crtc_enable_color_mgmt(&crtc->base, 0, false, VKMS_LUT_SIZE); + + spin_lock_init(&crtc->lock); + spin_lock_init(&crtc->composer_lock); + + crtc->composer_workq = alloc_ordered_workqueue("vkms_composer", 0); + if (!crtc->composer_workq) + return ERR_PTR(-ENOMEM); - return ret; + return crtc; } diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 2f9d1db0cfae..15a2ba26d190 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -54,9 +54,12 @@ DEFINE_DRM_GEM_FOPS(vkms_driver_fops); static void vkms_release(struct drm_device *dev) { struct vkms_device *vkms = drm_device_to_vkms_device(dev); + struct vkms_crtc *vkms_crtc; - if (vkms->output.composer_workq) - destroy_workqueue(vkms->output.composer_workq); + list_for_each_entry(vkms_crtc, &vkms->crtcs, list) { + if (vkms_crtc->composer_workq) + destroy_workqueue(vkms_crtc->composer_workq); + } } static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) @@ -177,6 +180,7 @@ static int vkms_create(struct vkms_config *config) } vkms_device->platform = pdev; vkms_device->config = config; + vkms_device->crtcs = (struct list_head)LIST_HEAD_INIT(vkms_device->crtcs); config->dev = vkms_device; ret = dma_coerce_mask_and_coherent(vkms_device->drm.dev, @@ -187,7 +191,7 @@ static int vkms_create(struct vkms_config *config) goto out_devres; } - ret = drm_vblank_init(&vkms_device->drm, 1); + ret = drm_vblank_init(&vkms_device->drm, list_count_nodes(&config->crtcs)); if (ret) { DRM_ERROR("Failed to vblank\n"); goto out_devres; diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 87e44b51a03f..3156ff896c33 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -4,6 +4,7 @@ #define _VKMS_DRV_H_ #include +#include #include #include @@ -98,10 +99,11 @@ struct vkms_crtc_state { u64 frame_end; }; -struct vkms_output { - struct drm_crtc crtc; - struct drm_encoder encoder; - struct drm_connector connector; +struct vkms_crtc { + struct list_head list; + + struct drm_crtc base; + struct drm_writeback_connector wb_connector; struct hrtimer vblank_hrtimer; ktime_t period_ns; @@ -119,19 +121,28 @@ struct vkms_output { struct vkms_config; +struct vkms_output { + struct drm_encoder encoder; + struct drm_connector connector; +}; + struct vkms_device { struct drm_device drm; struct platform_device *platform; struct vkms_output output; + struct list_head crtcs; const struct vkms_config *config; }; -#define drm_crtc_to_vkms_output(target) \ - container_of(target, struct vkms_output, crtc) - #define drm_device_to_vkms_device(target) \ container_of(target, struct vkms_device, drm) +#define drm_crtc_to_vkms_crtc(crtc) \ + container_of(crtc, struct vkms_crtc, base) + +#define timer_to_vkms_crtc(timer) \ + container_of(timer, struct vkms_crtc, vblank_hrtimer) + #define to_vkms_crtc_state(target)\ container_of(target, struct vkms_crtc_state, base) @@ -139,8 +150,10 @@ struct vkms_device { container_of(target, struct vkms_plane_state, base.base) /* CRTC */ -int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *primary, struct drm_plane *cursor); +struct vkms_crtc *vkms_crtc_init(struct drm_device *dev, + struct drm_plane *primary, + struct drm_plane *cursor, + unsigned int index); int vkms_output_init(struct vkms_device *vkmsdev, int index); @@ -156,11 +169,11 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, /* Composer Support */ void vkms_composer_worker(struct work_struct *work); -void vkms_set_composer(struct vkms_output *out, bool enabled); +void vkms_set_composer(struct vkms_crtc *vkms_crtc, bool enabled); void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state *plane, int y); void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer *src_buffer, int y); /* Writeback */ -int vkms_enable_writeback_connector(struct vkms_device *vkmsdev); +int vkms_enable_writeback_connector(struct vkms_crtc *vkms_crtc); #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index afe3945c1962..dcd32bc30e17 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -32,8 +32,7 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { .get_modes = vkms_conn_get_modes, }; -static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, int index, - struct drm_crtc *crtc) +static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, int index) { struct vkms_plane *overlay; @@ -42,7 +41,7 @@ static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, int index, return PTR_ERR(overlay); if (!overlay->base.possible_crtcs) - overlay->base.possible_crtcs = drm_crtc_mask(crtc); + overlay->base.possible_crtcs = BIT(index); return 0; } @@ -53,7 +52,8 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector = &output->connector; struct drm_encoder *encoder = &output->encoder; - struct drm_crtc *crtc = &output->crtc; + struct vkms_crtc *vkms_crtc; + struct vkms_config_crtc *crtc_cfg; struct vkms_plane *primary, *cursor = NULL; int ret; int writeback; @@ -65,7 +65,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) if (vkmsdev->config->overlay) { for (n = 0; n < NUM_OVERLAY_PLANES; n++) { - ret = vkms_add_overlay_plane(vkmsdev, index, crtc); + ret = vkms_add_overlay_plane(vkmsdev, index); if (ret) return ret; } @@ -77,15 +77,26 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) return PTR_ERR(cursor); } - ret = vkms_crtc_init(dev, crtc, &primary->base, &cursor->base); - if (ret) - return ret; + list_for_each_entry(crtc_cfg, &vkmsdev->config->crtcs, list) { + vkms_crtc = vkms_crtc_init(dev, &primary->base, &cursor->base, + crtc_cfg->index); + if (IS_ERR(vkms_crtc)) + return PTR_ERR(vkms_crtc); + + list_add_tail(&vkms_crtc->list, &vkmsdev->crtcs); + + if (crtc_cfg->writeback) { + writeback = vkms_enable_writeback_connector(vkms_crtc); + if (writeback) + DRM_ERROR("Failed to init writeback connector\n"); + } + } ret = drm_connector_init(dev, connector, &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL); if (ret) { DRM_ERROR("Failed to init connector\n"); - goto err_connector; + return ret; } drm_connector_helper_add(connector, &vkms_conn_helper_funcs); @@ -104,12 +115,6 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) goto err_attach; } - if (vkmsdev->config->writeback) { - writeback = vkms_enable_writeback_connector(vkmsdev); - if (writeback) - DRM_ERROR("Failed to init writeback connector\n"); - } - drm_mode_config_reset(dev); return 0; @@ -120,8 +125,5 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) err_encoder: drm_connector_cleanup(connector); -err_connector: - drm_crtc_cleanup(crtc); - return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index bc724cbd5e3a..b317cb291586 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -106,7 +106,7 @@ static void vkms_wb_cleanup_job(struct drm_writeback_connector *connector, struct drm_writeback_job *job) { struct vkms_writeback_job *vkmsjob = job->priv; - struct vkms_device *vkmsdev; + struct vkms_crtc *vkms_crtc; if (!job->fb) return; @@ -115,8 +115,8 @@ static void vkms_wb_cleanup_job(struct drm_writeback_connector *connector, drm_framebuffer_put(vkmsjob->wb_frame_info.fb); - vkmsdev = drm_device_to_vkms_device(job->fb->dev); - vkms_set_composer(&vkmsdev->output, false); + vkms_crtc = container_of(connector, struct vkms_crtc, wb_connector); + vkms_set_composer(vkms_crtc, false); kfree(vkmsjob); } @@ -125,11 +125,10 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, { struct drm_connector_state *connector_state = drm_atomic_get_new_connector_state(state, conn); - struct vkms_device *vkmsdev = drm_device_to_vkms_device(conn->dev); - struct vkms_output *output = &vkmsdev->output; - struct drm_writeback_connector *wb_conn = &output->wb_connector; + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(connector_state->crtc); + struct drm_writeback_connector *wb_conn = &vkms_crtc->wb_connector; struct drm_connector_state *conn_state = wb_conn->base.state; - struct vkms_crtc_state *crtc_state = output->composer_state; + struct vkms_crtc_state *crtc_state = vkms_crtc->composer_state; struct drm_framebuffer *fb = connector_state->writeback_job->fb; u16 crtc_height = crtc_state->base.crtc->mode.vdisplay; u16 crtc_width = crtc_state->base.crtc->mode.hdisplay; @@ -140,15 +139,15 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, if (!conn_state) return; - vkms_set_composer(&vkmsdev->output, true); + vkms_set_composer(vkms_crtc, true); active_wb = conn_state->writeback_job->priv; wb_frame_info = &active_wb->wb_frame_info; - spin_lock_irq(&output->composer_lock); + spin_lock_irq(&vkms_crtc->composer_lock); crtc_state->active_writeback = active_wb; crtc_state->wb_pending = true; - spin_unlock_irq(&output->composer_lock); + spin_unlock_irq(&vkms_crtc->composer_lock); wb_frame_info->offset = fb->offsets[0]; wb_frame_info->pitch = fb->pitches[0]; @@ -168,16 +167,16 @@ static const struct drm_connector_helper_funcs vkms_wb_conn_helper_funcs = { .atomic_check = vkms_wb_atomic_check, }; -int vkms_enable_writeback_connector(struct vkms_device *vkmsdev) +int vkms_enable_writeback_connector(struct vkms_crtc *vkms_crtc) { - struct drm_writeback_connector *wb = &vkmsdev->output.wb_connector; + struct drm_writeback_connector *wb = &vkms_crtc->wb_connector; drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); - return drm_writeback_connector_init(&vkmsdev->drm, wb, + return drm_writeback_connector_init(vkms_crtc->base.dev, wb, &vkms_wb_connector_funcs, NULL, vkms_wb_formats, ARRAY_SIZE(vkms_wb_formats), - 1); + drm_crtc_mask(&vkms_crtc->base)); } From patchwork Tue Aug 13 10:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761779 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 CFCAFC52D7C for ; Tue, 13 Aug 2024 10:51:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D3C710E2ED; Tue, 13 Aug 2024 10:51:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HKgnAhzp"; dkim-atps=neutral Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC86110E2EE for ; Tue, 13 Aug 2024 10:51:46 +0000 (UTC) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42816ca782dso40961405e9.2 for ; Tue, 13 Aug 2024 03:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546305; x=1724151105; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KWE8rKtVdiKUJxK18Sz+dZAuEs9UiARix9m9SAPeTeE=; b=HKgnAhzprphU3NGxZoWlix1OIiogZcmAxfAr2SC9sa9M2ifT/9CNPJzy4oQ8RSTdTW UNkUezcEljQSjqJyYzXGBTp4GR/TxIncmtdjGST1AexMkRqsIL8LBiq9APHPq9SwvI+B c8MNZxq1xfp2yeYHK+ugU7nZV8Cs6u4M6+9MeuP5pxv5SwL4ZnQSo73bs1GuWtU68dbb i0kNlNNTJUaHb3KEVssT1c2HiSHr4LcB0oTf1UZ7RWeexRcOQug+vbVT8smqaOunf4KA AJrgQGIWs4T+IoWmYnRt3JBrya0s6R40EizJ/b+XmiWEMTyt/fSPXdtsh2E/11o48bPq Bc0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546305; x=1724151105; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KWE8rKtVdiKUJxK18Sz+dZAuEs9UiARix9m9SAPeTeE=; b=IonIr30ZuezlQbLNrWj0lPCUDF3vb4Chew6UyA16dLix37iMyLzpfIOWxV176KBkiw 0aLwQJSa2vUDWKI1jB/9NwDtR6qN83Q2Ig2K/zXfELoEChMSeVuymgT7qlxVgbkhhqxK uRjrseMtQ05KE8DOIXuTP0NfMYICYpuEjOgvrG48xctBa86pdLZr0947szj/kRxOMPSH yUXVAQkC/X0UaBl/xYthm9oaHjSwB6Jh1Mk8lmf14lk//lk1huBpovggJCqgKmizOyVo H0wbCfQeOTp/UFknbWJqVaxzfG2hyZrA2WJBXCdCX0+L1MFP1KBmjPf3ld9L9C2seZXo ECQA== X-Forwarded-Encrypted: i=1; AJvYcCWKMEDaDgVF6lka7IAsG5jpME0XbSkyw2MGMtXNo2xvyq4dp99navIjMQE/mQDcm+87iqea4Hb7TE1vFNvMsTFDZHOKL+EPOmWPRn1iYxNJ X-Gm-Message-State: AOJu0Yzagp+fwcIcwsq4qoPZACO6zv7OVXEISazt43CjGtf0tHm+qjkI jEFG/yzWksJPtz8HnmXtd+8EdANU2PoiWPAk7BYHyT+4Wwz9ZzqN X-Google-Smtp-Source: AGHT+IEOoGiAX7Jk7kFX/Cpb+81DazihuxVSJAl0cnfxJtAI3Kt5FKlL5DDzE+cNeO48UflBpAHuFQ== X-Received: by 2002:a05:600c:5246:b0:426:5b21:9801 with SMTP id 5b1f17b1804b1-429d486ec8amr25687205e9.27.1723546304967; Tue, 13 Aug 2024 03:51:44 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:44 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 05/17] drm/vkms: Use managed memory to create encoders Date: Tue, 13 Aug 2024 12:44:16 +0200 Message-ID: <20240813105134.17439-6-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" A future patch will allow to create multiple encoders. Use managed memory to simplify the code. Refactor, no functional changes. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_drv.h | 1 - drivers/gpu/drm/vkms/vkms_output.c | 45 ++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 3156ff896c33..2466e8b0231f 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -122,7 +122,6 @@ struct vkms_crtc { struct vkms_config; struct vkms_output { - struct drm_encoder encoder; struct drm_connector connector; }; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index dcd32bc30e17..15f0b72af325 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -4,6 +4,7 @@ #include "vkms_drv.h" #include #include +#include #include static const struct drm_connector_funcs vkms_connector_funcs = { @@ -14,10 +15,6 @@ static const struct drm_connector_funcs vkms_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; -static const struct drm_encoder_funcs vkms_encoder_funcs = { - .destroy = drm_encoder_cleanup, -}; - static int vkms_conn_get_modes(struct drm_connector *connector) { int count; @@ -32,6 +29,31 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { .get_modes = vkms_conn_get_modes, }; +static struct drm_encoder *vkms_encoder_init(struct vkms_device *vkms_device, + uint32_t possible_crtcs) +{ + struct drm_encoder *encoder; + int ret; + + encoder = drmm_kzalloc(&vkms_device->drm, sizeof(*encoder), GFP_KERNEL); + if (!encoder) { + DRM_ERROR("Failed to allocate encoder\n"); + return ERR_PTR(-ENOMEM); + } + + ret = drmm_encoder_init(&vkms_device->drm, encoder, NULL, + DRM_MODE_ENCODER_VIRTUAL, NULL); + if (ret) { + DRM_ERROR("Failed to init encoder\n"); + kfree(encoder); + return ERR_PTR(ret); + } + + encoder->possible_crtcs = possible_crtcs; + + return encoder; +} + static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, int index) { struct vkms_plane *overlay; @@ -51,7 +73,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) struct vkms_output *output = &vkmsdev->output; struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector = &output->connector; - struct drm_encoder *encoder = &output->encoder; + struct drm_encoder *encoder; struct vkms_crtc *vkms_crtc; struct vkms_config_crtc *crtc_cfg; struct vkms_plane *primary, *cursor = NULL; @@ -101,13 +123,9 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) drm_connector_helper_add(connector, &vkms_conn_helper_funcs); - ret = drm_encoder_init(dev, encoder, &vkms_encoder_funcs, - DRM_MODE_ENCODER_VIRTUAL, NULL); - if (ret) { - DRM_ERROR("Failed to init encoder\n"); - goto err_encoder; - } - encoder->possible_crtcs = 1; + encoder = vkms_encoder_init(vkmsdev, BIT(0)); + if (IS_ERR(encoder)) + return PTR_ERR(encoder); ret = drm_connector_attach_encoder(connector, encoder); if (ret) { @@ -120,9 +138,6 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) return 0; err_attach: - drm_encoder_cleanup(encoder); - -err_encoder: drm_connector_cleanup(connector); return ret; From patchwork Tue Aug 13 10:44:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761780 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 BEAC5C52D7B for ; Tue, 13 Aug 2024 10:51:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D278810E2F1; Tue, 13 Aug 2024 10:51:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OxaOYIRX"; dkim-atps=neutral Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id 24CC710E2ED for ; Tue, 13 Aug 2024 10:51:48 +0000 (UTC) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4281d812d3eso52674065e9.3 for ; Tue, 13 Aug 2024 03:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546306; x=1724151106; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R6Mz2KhFZzROn/KIWb00LTNVvXvYG/m4Vfb07jwptv4=; b=OxaOYIRXPDmM2BpVYATRBmNvt11Qf7iReYV8ZWZBEHDhqKD6qWyWykaFDvKZF3mdiP esh5KOeHNQEThoiSxPKzxLTfwEwh3jvJz+GA033mvFwF95jJHzVde7TXaVSG/5FNK3n9 nsrwUFYa/Tu/BO9pqUJZwTo7xO5CMAY4QmoDKPqNeK+lyT8UHZW4NZ8ONX1aeNUKLR/3 Jnr8mlOiqEUSe2HYz4sIdPaGQfTbv+x0Yyc8kuvvoZZSEWyoxUhkWY9vXCAXKx/HrwhW Z/QURWBVJRwBzXITWVR7UNMxPijYrUfp2J8kfBwi5FCEv8isX+yBVVx6HHFRqLnja3Oi 4piQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546306; x=1724151106; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R6Mz2KhFZzROn/KIWb00LTNVvXvYG/m4Vfb07jwptv4=; b=FKECuQPI/ugtH389DJs/r+2rRoJ/zXbebS4/M3vkaS22uVdTJhGBRiIX5m4IWcFj1/ nQ6a0kBmSrvPPMoEeGwY54BJv9VmTQn5rjaJdjzrstpenlBlVS8GExBk1baiqM1hsDXm eZmz5jZfDalfNZjo6d8hmhrX6AM4QRWIselgQVNd1rawApjsRwMssIIAfoTUBwX0RHaL G90aGeh24HAGX8K05/+tWXftdBdN12A1J8GD2nLPc0/jU3lVYXf8nAAt7LgWVozvIOyI 3cCxvOcLt+ka8Dh1cBvhJwgyMXKB7r68EEbp3sqCq7EkGpLtsMoRYhqZPvrCCoop544R bOsw== X-Forwarded-Encrypted: i=1; AJvYcCUdsWU55V8fpdEg9hgQd4e6vgke9CsEakrx4JthiKo4F3HtVP9Pw1EozuVjQfTRAkfVbmBa/BlYglogAnWEV8fV35ehm9EZrKktpGgEMbCk X-Gm-Message-State: AOJu0Yy0QfYgI+01wjIY/9ZV34Aof3Vf4DZmPUMnhpZUMXpEmT3Yavmk JmmDfQ/o8m7NamEhnRi9Hjq2mB2M6W9w9fubU6wCEd4G2g7q9n4Y X-Google-Smtp-Source: AGHT+IFc1MxDOM9KHwmSg4MIeIUEJ0CdqAeobEZZY+JR1Ums0WJRTX2kswhgxVkQAvgh3eiXBXE65g== X-Received: by 2002:a05:600c:6d3:b0:426:59d3:8cae with SMTP id 5b1f17b1804b1-429d633e764mr21330055e9.13.1723546306306; Tue, 13 Aug 2024 03:51:46 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:45 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 06/17] drm/vkms: Allow to configure multiple encoders Date: Tue, 13 Aug 2024 12:44:17 +0200 Message-ID: <20240813105134.17439-7-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Add a list of encoder configurations to vkms_config and add as many encoders as configured during output initialization. For backwards compatibility, create a single encoder in the default configuration. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_config.c | 50 ++++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 13 ++++++++ drivers/gpu/drm/vkms/vkms_output.c | 14 ++++++--- 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 3af750071f04..6a8dfebee24e 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -18,6 +18,7 @@ struct vkms_config *vkms_config_create(char *dev_name) config->dev_name = dev_name; config->crtcs = (struct list_head)LIST_HEAD_INIT(config->crtcs); + config->encoders = (struct list_head)LIST_HEAD_INIT(config->encoders); return config; } @@ -28,6 +29,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, { struct vkms_config *config; struct vkms_config_crtc *crtc_cfg; + struct vkms_config_encoder *encoder_cfg; config = vkms_config_create(DEFAULT_DEVICE_NAME); if (IS_ERR(config)) @@ -40,16 +42,24 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, if (IS_ERR(crtc_cfg)) return ERR_CAST(crtc_cfg); + encoder_cfg = vkms_config_add_encoder(config, BIT(0)); + if (IS_ERR(encoder_cfg)) + return ERR_CAST(encoder_cfg); + return config; } void vkms_config_destroy(struct vkms_config *config) { struct vkms_config_crtc *crtc_cfg, *crtc_tmp; + struct vkms_config_encoder *encoder_cfg, *encoder_tmp; list_for_each_entry_safe(crtc_cfg, crtc_tmp, &config->crtcs, list) vkms_config_destroy_crtc(config, crtc_cfg); + list_for_each_entry_safe(encoder_cfg, encoder_tmp, &config->encoders, list) + vkms_config_destroy_encoder(config, encoder_cfg); + kfree(config); } @@ -59,6 +69,7 @@ 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_crtc *crtc_cfg; + struct vkms_config_encoder *encoder_cfg; int n; seq_printf(m, "dev_name=%s\n", vkmsdev->config->dev_name); @@ -72,6 +83,13 @@ static int vkms_config_show(struct seq_file *m, void *data) n++; } + n = 0; + list_for_each_entry(encoder_cfg, &vkmsdev->config->encoders, list) { + seq_printf(m, "encoder(%d).possible_crtcs=%d\n", n, + encoder_cfg->possible_crtcs); + n++; + } + return 0; } @@ -116,3 +134,35 @@ void vkms_config_destroy_crtc(struct vkms_config *config, list_del(&crtc_cfg->list); kfree(crtc_cfg); } + +struct vkms_config_encoder *vkms_config_add_encoder(struct vkms_config *config, + uint32_t possible_crtcs) +{ + struct vkms_config_encoder *encoder_cfg; + + encoder_cfg = kzalloc(sizeof(*encoder_cfg), GFP_KERNEL); + if (!encoder_cfg) + return ERR_PTR(-ENOMEM); + + encoder_cfg->possible_crtcs = possible_crtcs; + + encoder_cfg->index = 0; + if (!list_empty(&config->encoders)) { + struct vkms_config_encoder *last; + + last = list_last_entry(&config->encoders, + struct vkms_config_encoder, list); + encoder_cfg->index = last->index + 1; + } + + list_add_tail(&encoder_cfg->list, &config->encoders); + + return encoder_cfg; +} + +void vkms_config_destroy_encoder(struct vkms_config *config, + struct vkms_config_encoder *encoder_cfg) +{ + list_del(&encoder_cfg->list); + kfree(encoder_cfg); +} diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index bc40a0e3859a..b717b5c0d3d9 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -14,11 +14,18 @@ struct vkms_config_crtc { bool writeback; }; +struct vkms_config_encoder { + struct list_head list; + unsigned int index; + uint32_t possible_crtcs; +}; + struct vkms_config { char *dev_name; bool cursor; bool overlay; struct list_head crtcs; + struct list_head encoders; /* only set when instantiated */ struct vkms_device *dev; }; @@ -39,4 +46,10 @@ struct vkms_config_crtc *vkms_config_add_crtc(struct vkms_config *config, void vkms_config_destroy_crtc(struct vkms_config *config, struct vkms_config_crtc *crtc_cfg); +/* Encoders */ +struct vkms_config_encoder *vkms_config_add_encoder(struct vkms_config *config, + uint32_t possible_crtcs); +void vkms_config_destroy_encoder(struct vkms_config *config, + struct vkms_config_encoder *encoder_cfg); + #endif /* _VKMS_CONFIG_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 15f0b72af325..7afe37aea52d 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -30,7 +30,8 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { }; static struct drm_encoder *vkms_encoder_init(struct vkms_device *vkms_device, - uint32_t possible_crtcs) + uint32_t possible_crtcs, + unsigned int index) { struct drm_encoder *encoder; int ret; @@ -49,6 +50,7 @@ static struct drm_encoder *vkms_encoder_init(struct vkms_device *vkms_device, return ERR_PTR(ret); } + encoder->index = index; encoder->possible_crtcs = possible_crtcs; return encoder; @@ -74,6 +76,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector = &output->connector; struct drm_encoder *encoder; + struct vkms_config_encoder *encoder_cfg; struct vkms_crtc *vkms_crtc; struct vkms_config_crtc *crtc_cfg; struct vkms_plane *primary, *cursor = NULL; @@ -123,9 +126,12 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) drm_connector_helper_add(connector, &vkms_conn_helper_funcs); - encoder = vkms_encoder_init(vkmsdev, BIT(0)); - if (IS_ERR(encoder)) - return PTR_ERR(encoder); + list_for_each_entry(encoder_cfg, &vkmsdev->config->encoders, list) { + encoder = vkms_encoder_init(vkmsdev, encoder_cfg->possible_crtcs, + encoder_cfg->index); + if (IS_ERR(encoder)) + return PTR_ERR(encoder); + } ret = drm_connector_attach_encoder(connector, encoder); if (ret) { From patchwork Tue Aug 13 10:44:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761782 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 DE884C531DD for ; Tue, 13 Aug 2024 10:51:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2461810E2F3; Tue, 13 Aug 2024 10:51:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="T2h5SDR7"; dkim-atps=neutral Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E1D710E2EE for ; Tue, 13 Aug 2024 10:51:49 +0000 (UTC) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-428f5c0833bso36002095e9.0 for ; Tue, 13 Aug 2024 03:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546308; x=1724151108; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yPJvcbH5lYbi1tdr48EenmYPKkhD5TMeNHQFHVN3Exg=; b=T2h5SDR78fqv6SAVpDOQK5OD3Rc2pbl39GdFj4djxLWr5RKc4Srwx10RKoKcI8xWGZ 8zqI8HtAbe1SgfpaEO9Uc/HLZPClnARskUoRMOEc5tUCuNi0tiXzpj8ciqmoiun4OrOo G/PfMxHobkSjS65nnXUbjTuXXZCXqS0kRUuK2QH6p+L1Z7/UU1Lv0jrIKzXrVugfTyet DzyAdP6yTFnTYKL9hxkF+mpJSmiywUP1XkGZsZNUoM4lqVMw2C/GTR5FQLuav1jiKIiO NxbvDx0DVBosZcwxS/KvVFYDT/QvKKIrLEs0B2Nv5anqHbKfKCE//85tmxuoPX6E6Gzn AOCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546308; x=1724151108; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yPJvcbH5lYbi1tdr48EenmYPKkhD5TMeNHQFHVN3Exg=; b=UYpllTJf6o8Tgpbt8PXaBvd/HMNm8lHDTLPlyD3xxsOlMLmhUXq2c9uUE0Rg08lCzu j8j8bFa1zwGhx3q4wJliDMFOmDN5r72sJPjXXlTB7CM5B3DuvBqlcVJnuP3mm7w9bJw8 7AEqaUzFF9d5xvA+HIiJOO6Zfhs1+8PvJ7iHo2FlysHe+nhG7/hdEb3IhuLUA3fwmHdS zAJaHSssudU1/2XHBLjvUXl00tAu1kiFYcTV7TTVQyhctJeaLahymaPficYnxq3SeQ8r 5Oo9k9nXJKujFipPTplElJwznbDRhmVQXUBClwCuf4aYx8Jr3ecnLhu2dTlC1S0JIcFg 8pWQ== X-Forwarded-Encrypted: i=1; AJvYcCVjVCPxLIAMBA71Blmumi87BPjRgTiNma+7hAIfH08VK0Zv8gAhS94TurNXwbvuOXtkDrcdfgnzRQZv0NrGuIQDcp0HHT3zMghr5bv2ncx8 X-Gm-Message-State: AOJu0YyFGIl6Hpb7aBzcDLQ7p0Fqet4/OuCYR7jeiPqIwAuygs9YUxnk jSo9dxYxvH6rwKL97sLJFikaaT3DjEHnOq2NEB+aRxAH6fDlD/sK X-Google-Smtp-Source: AGHT+IHcFaaF5NVEVnvtNiV476r9AqohxbQTNIubIsJ2CbGH8C94GlKmoddxaTxdje9PNBr2TQhbQA== X-Received: by 2002:a05:600c:1c17:b0:426:6981:1bd with SMTP id 5b1f17b1804b1-429d6280c76mr19765785e9.5.1723546307600; Tue, 13 Aug 2024 03:51:47 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:46 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 07/17] drm/vkms: Use managed memory to create connectors Date: Tue, 13 Aug 2024 12:44:18 +0200 Message-ID: <20240813105134.17439-8-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" A future patch will allow to create multiple connectors. Use managed memory to simplify the code. Refactor, no functional changes. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_drv.h | 5 --- drivers/gpu/drm/vkms/vkms_output.c | 53 +++++++++++++++++------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 2466e8b0231f..cac37d21654a 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -121,14 +121,9 @@ struct vkms_crtc { struct vkms_config; -struct vkms_output { - struct drm_connector connector; -}; - struct vkms_device { struct drm_device drm; struct platform_device *platform; - struct vkms_output output; struct list_head crtcs; const struct vkms_config *config; }; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 7afe37aea52d..4413cf88afc7 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -9,7 +9,6 @@ static const struct drm_connector_funcs vkms_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = drm_connector_cleanup, .reset = drm_atomic_helper_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, @@ -29,6 +28,33 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { .get_modes = vkms_conn_get_modes, }; +static struct drm_connector *vkms_connector_init(struct vkms_device *vkms_device, + uint32_t possible_encoders) +{ + struct drm_connector *connector; + int ret; + + connector = drmm_kzalloc(&vkms_device->drm, sizeof(*connector), GFP_KERNEL); + if (!connector) { + DRM_ERROR("Failed to allocate connector\n"); + return ERR_PTR(-ENOMEM); + } + + ret = drmm_connector_init(&vkms_device->drm, connector, + &vkms_connector_funcs, + DRM_MODE_CONNECTOR_VIRTUAL, NULL); + if (ret) { + DRM_ERROR("Failed to init connector\n"); + kfree(connector); + return ERR_PTR(ret); + } + + connector->possible_encoders = possible_encoders; + drm_connector_helper_add(connector, &vkms_conn_helper_funcs); + + return connector; +} + static struct drm_encoder *vkms_encoder_init(struct vkms_device *vkms_device, uint32_t possible_crtcs, unsigned int index) @@ -72,9 +98,8 @@ static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, int index) int vkms_output_init(struct vkms_device *vkmsdev, int index) { - struct vkms_output *output = &vkmsdev->output; struct drm_device *dev = &vkmsdev->drm; - struct drm_connector *connector = &output->connector; + struct drm_connector *connector; struct drm_encoder *encoder; struct vkms_config_encoder *encoder_cfg; struct vkms_crtc *vkms_crtc; @@ -117,14 +142,9 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) } } - ret = drm_connector_init(dev, connector, &vkms_connector_funcs, - DRM_MODE_CONNECTOR_VIRTUAL); - if (ret) { - DRM_ERROR("Failed to init connector\n"); - return ret; - } - - drm_connector_helper_add(connector, &vkms_conn_helper_funcs); + connector = vkms_connector_init(vkmsdev, BIT(index)); + if (IS_ERR(connector)) + return PTR_ERR(connector); list_for_each_entry(encoder_cfg, &vkmsdev->config->encoders, list) { encoder = vkms_encoder_init(vkmsdev, encoder_cfg->possible_crtcs, @@ -133,18 +153,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) return PTR_ERR(encoder); } - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - DRM_ERROR("Failed to attach connector to encoder\n"); - goto err_attach; - } - drm_mode_config_reset(dev); return 0; - -err_attach: - drm_connector_cleanup(connector); - - return ret; } From patchwork Tue Aug 13 10:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761784 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 401E4C52D7D for ; Tue, 13 Aug 2024 10:51:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B917210E2F2; Tue, 13 Aug 2024 10:51:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kbtJVeBP"; dkim-atps=neutral Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 49CFF10E2FA for ; Tue, 13 Aug 2024 10:51:51 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-52f04150796so6887173e87.3 for ; Tue, 13 Aug 2024 03:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546309; x=1724151109; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z1b1Eswx9qL8T6Rd6UW0NQch1ATeb/MIAR8sy8FcP0k=; b=kbtJVeBPy+h+KVf/nghJ0XzlVBncKc39f41IHM6JKLJ+s5HmkhsflUVFRMUr5CMwd8 9riGQk3WIQ3alzjKdaGG6mCAVXfSJIreR90fYna8iFnOKjvd+tvvN93ctIcUba3b/Wi2 awKrPSG9+DJt5cVPhoyB5mZ0IwuoX1TtwQcb3CqnfuVHvatNB52Kqy5TtB4X1mvR5FR8 q0i3cIUyUjKICYfKs19R3oO6qsVZTYJXNvUfYXVCideX1b0y2EgrKBCDG9UcRcqYqCPl iE6LpNk7qfiSocaHsHSLI1jCWt9nFYNrbDqzAeOQaDkxLzBC4A04QwApl8Mk7NZOvcI/ 2OTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546309; x=1724151109; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z1b1Eswx9qL8T6Rd6UW0NQch1ATeb/MIAR8sy8FcP0k=; b=bJojHbQFLKiK3UFN52TofhtNzSO98ATBT/eXe28afPZ9dao6q0A/dYu38Ehmqqqr68 fYi/7bRgz7yw+FvffIl4W9sh6DllNewOnIxmONXrn6Di1DARsjEEVPaZ4CBi87Adzj2g F7UbUaY2JYxMhfFqogb9uaSqY1HnroBhqLay4KG9HoOJiVxuehfB7q2hksZqy1Vi/e00 TXXfLA0zYRCqWYUlm0yce+8NFuNUVB0zwVGh78QI2vo+qnijyXHAOzVJ2+3y//pEhNJv 0a1r4WYPT3dEoPgjwXhng+QBrc1LP9swhgJm/2eLHF5AAjncHS+6DuehtNB4iqFb2WCs gXnA== X-Forwarded-Encrypted: i=1; AJvYcCVsSnwWZCKeWU7ZaB5sacu2uYxTuez6gPqLfC5fbGGZZzdCNHe8G/o+RWwQIu/CWaR/I2z3FmaHKTSsKyubbsjvIY5LI9kfmAYutRJ8Hmra X-Gm-Message-State: AOJu0Yym4x03VLu7hnMbRBwBbb8NDTlZlcwBsK8TLqGBWN/+0XEMfWML BcivfXLw1NTYxm//BIm9sEDedj+N/uNapQN3n6U7oiOTUUjDcmBh X-Google-Smtp-Source: AGHT+IHDMdoPIt0vDtMzdf2vnVHY+f/UlarsLfOsG/b/9vpdwiWF/yN55OgcMzvIyUbn7rGva+IR1w== X-Received: by 2002:a05:6512:1592:b0:52b:bf8e:ffea with SMTP id 2adb3069b0e04-532136840a4mr1940424e87.40.1723546308846; Tue, 13 Aug 2024 03:51:48 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:48 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 08/17] drm/vkms: Allow to configure multiple connectors Date: Tue, 13 Aug 2024 12:44:19 +0200 Message-ID: <20240813105134.17439-9-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Add a list of connector configurations to vkms_config and add as many connector as configured during output initialization. For backwards compatibility, create a single connector in the default configuration. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_config.c | 40 ++++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 12 +++++++++ drivers/gpu/drm/vkms/vkms_output.c | 11 +++++--- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 6a8dfebee24e..a456f9db3c66 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -19,6 +19,7 @@ struct vkms_config *vkms_config_create(char *dev_name) config->dev_name = dev_name; config->crtcs = (struct list_head)LIST_HEAD_INIT(config->crtcs); config->encoders = (struct list_head)LIST_HEAD_INIT(config->encoders); + config->connectors = (struct list_head)LIST_HEAD_INIT(config->connectors); return config; } @@ -30,6 +31,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, struct vkms_config *config; struct vkms_config_crtc *crtc_cfg; struct vkms_config_encoder *encoder_cfg; + struct vkms_config_connector *connector_cfg; config = vkms_config_create(DEFAULT_DEVICE_NAME); if (IS_ERR(config)) @@ -46,6 +48,10 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, if (IS_ERR(encoder_cfg)) return ERR_CAST(encoder_cfg); + connector_cfg = vkms_config_add_connector(config, BIT(0)); + if (IS_ERR(connector_cfg)) + return ERR_CAST(connector_cfg); + return config; } @@ -53,6 +59,7 @@ void vkms_config_destroy(struct vkms_config *config) { struct vkms_config_crtc *crtc_cfg, *crtc_tmp; struct vkms_config_encoder *encoder_cfg, *encoder_tmp; + struct vkms_config_connector *connector_cfg, *connector_tmp; list_for_each_entry_safe(crtc_cfg, crtc_tmp, &config->crtcs, list) vkms_config_destroy_crtc(config, crtc_cfg); @@ -60,6 +67,9 @@ void vkms_config_destroy(struct vkms_config *config) list_for_each_entry_safe(encoder_cfg, encoder_tmp, &config->encoders, list) vkms_config_destroy_encoder(config, encoder_cfg); + list_for_each_entry_safe(connector_cfg, connector_tmp, &config->connectors, list) + vkms_config_destroy_connector(config, connector_cfg); + kfree(config); } @@ -70,6 +80,7 @@ static int vkms_config_show(struct seq_file *m, void *data) struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); struct vkms_config_crtc *crtc_cfg; struct vkms_config_encoder *encoder_cfg; + struct vkms_config_connector *connector_cfg; int n; seq_printf(m, "dev_name=%s\n", vkmsdev->config->dev_name); @@ -90,6 +101,13 @@ static int vkms_config_show(struct seq_file *m, void *data) n++; } + n = 0; + list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, list) { + seq_printf(m, "connector(%d).possible_encoders=%d\n", n, + connector_cfg->possible_encoders); + n++; + } + return 0; } @@ -166,3 +184,25 @@ void vkms_config_destroy_encoder(struct vkms_config *config, list_del(&encoder_cfg->list); kfree(encoder_cfg); } + +struct vkms_config_connector *vkms_config_add_connector(struct vkms_config *config, + uint32_t possible_encoders) +{ + struct vkms_config_connector *connector_cfg; + + connector_cfg = kzalloc(sizeof(*connector_cfg), GFP_KERNEL); + if (!connector_cfg) + return ERR_PTR(-ENOMEM); + + connector_cfg->possible_encoders = possible_encoders; + list_add_tail(&connector_cfg->list, &config->connectors); + + return connector_cfg; +} + +void vkms_config_destroy_connector(struct vkms_config *config, + struct vkms_config_connector *connector_cfg) +{ + list_del(&connector_cfg->list); + kfree(connector_cfg); +} diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index b717b5c0d3d9..f1dd59fc6300 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -20,12 +20,18 @@ struct vkms_config_encoder { uint32_t possible_crtcs; }; +struct vkms_config_connector { + struct list_head list; + uint32_t possible_encoders; +}; + struct vkms_config { char *dev_name; bool cursor; bool overlay; struct list_head crtcs; struct list_head encoders; + struct list_head connectors; /* only set when instantiated */ struct vkms_device *dev; }; @@ -52,4 +58,10 @@ struct vkms_config_encoder *vkms_config_add_encoder(struct vkms_config *config, void vkms_config_destroy_encoder(struct vkms_config *config, struct vkms_config_encoder *encoder_cfg); +/* Connectors */ +struct vkms_config_connector *vkms_config_add_connector(struct vkms_config *config, + uint32_t possible_encoders); +void vkms_config_destroy_connector(struct vkms_config *config, + struct vkms_config_connector *connector_cfg); + #endif /* _VKMS_CONFIG_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 4413cf88afc7..021a491de817 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -100,6 +100,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) { struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; + struct vkms_config_connector *connector_cfg; struct drm_encoder *encoder; struct vkms_config_encoder *encoder_cfg; struct vkms_crtc *vkms_crtc; @@ -142,10 +143,6 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) } } - connector = vkms_connector_init(vkmsdev, BIT(index)); - if (IS_ERR(connector)) - return PTR_ERR(connector); - list_for_each_entry(encoder_cfg, &vkmsdev->config->encoders, list) { encoder = vkms_encoder_init(vkmsdev, encoder_cfg->possible_crtcs, encoder_cfg->index); @@ -153,6 +150,12 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) return PTR_ERR(encoder); } + list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, list) { + connector = vkms_connector_init(vkmsdev, connector_cfg->possible_encoders); + if (IS_ERR(connector)) + return PTR_ERR(connector); + } + drm_mode_config_reset(dev); return 0; From patchwork Tue Aug 13 10:44:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761783 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 92676C52D7C for ; Tue, 13 Aug 2024 10:51:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF6BD10E2EF; Tue, 13 Aug 2024 10:51:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JxhE3Ks/"; dkim-atps=neutral Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 84D4210E2FA for ; Tue, 13 Aug 2024 10:51:51 +0000 (UTC) Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-429c4a4c6a8so27014935e9.0 for ; Tue, 13 Aug 2024 03:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546310; x=1724151110; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rMbXv874dHtsCrZeML3BpyopJo288L3/apBZJHbVOhk=; b=JxhE3Ks/oAnTb5ZA4I6rH4+WpG7XZIWhpUWZeunOLy3myUCybQ5mSk1vvp/klM3ZMA F2BxiTGJKCr2JxodSgAZDVi1pIr6oARYdiiP3bDnUwivvfpVcW/x9gQ623nxXphM3BAZ dolXlp8Nv7klE6hKdFTxpvYwVVVAvis7ZD8S+8soY7AWu49LltOcp4kyPrkC6hqCy833 f9AZQcLhoWF6ALKBUPWWbQwab4CZ2RZW45I8vaYvhQan8kLZzDRyBfPyn+MZOoLc5eDZ qH+ZadY06n/X6RMBo0w/5h/EKOFIaX4OE/E7AahMuaNVK2Vp7+9ivlQ7lIZKjGNxzFxG rypw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546310; x=1724151110; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rMbXv874dHtsCrZeML3BpyopJo288L3/apBZJHbVOhk=; b=OMAyQ6T9PBlXnyqTifGmaDd28nhxpnkofKa7sCoZa2/yJLNJYrsrHQx2jIau3by/Lh hkHpgSh8nRAfjryBpO4IJQ4wgFHLgdWMOKtMkqGaHneLzcBw+0sZJ7doiJXPR6BWeC01 N3oY4l8rlkTaVqRRXCBrvD+wYcMNbgo9LqtaRDsysxCGDaDWaKe75qYo29ikG2wulc4H 9sPBbUbnyHZE+hS8viVl6cQYd+aHZH1vzS+isSai5l95anBGKCdNR4anHZvdmNHUTqYG hpFpPTsUoxBzLs79wubx0DQVrfiOGYbfvcxGE9ZFpk8ybWtP6pNcnpJ/sWLt3IlSj2A6 0heA== X-Forwarded-Encrypted: i=1; AJvYcCVz8izvgDldZ3b+iEXvlp0AqOiOVMo0kMl9zesdnB+ugZmpYqIZmzwe0w0e67N/EeDl6Fm1WfsFwVURTJNJlmQIfciVJGilTFiYs7X50zc5 X-Gm-Message-State: AOJu0Yx4lboz+VBwXKjxlguahGp0aIk/6duzWFLokscdP1ERVfgwoSCD L3KQ01buYYDuy4q1mZ5xTFTnDbNmN4VLkNEgq1uFt33G46jAE+W6 X-Google-Smtp-Source: AGHT+IFOCeWvoZuGjI44xpEIh5rro/qgNHo4B3FX450VGqDCj0qY+tfMZ7moOEUZum//780E8hV+lw== X-Received: by 2002:a05:600c:4f53:b0:426:6d1a:d497 with SMTP id 5b1f17b1804b1-429d480dcb2mr19574965e9.12.1723546309738; Tue, 13 Aug 2024 03:51:49 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:49 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 09/17] drm/vkms: Allow to configure multiple overlay planes Date: Tue, 13 Aug 2024 12:44:20 +0200 Message-ID: <20240813105134.17439-10-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Add a list of overlay planes to vkms_config and add as many overlay planes as configured during output initialization. For backwards compatibility, add NUM_OVERLAY_PLANES to the default configuration. Note that a primary plane is created for each CRTC and it is not possible to configure it. A cursor plane is added conditionally if it is enabled in the CRTC configuration. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_config.c | 53 +++++++++++++++++++++++++++--- drivers/gpu/drm/vkms/vkms_config.h | 16 +++++++-- drivers/gpu/drm/vkms/vkms_drv.c | 2 +- drivers/gpu/drm/vkms/vkms_drv.h | 5 +-- drivers/gpu/drm/vkms/vkms_output.c | 43 ++++++++++++------------ drivers/gpu/drm/vkms/vkms_plane.c | 6 ++-- 6 files changed, 91 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index a456f9db3c66..d95a42a6745a 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -17,6 +17,7 @@ struct vkms_config *vkms_config_create(char *dev_name) return ERR_PTR(-ENOMEM); config->dev_name = dev_name; + config->planes = (struct list_head)LIST_HEAD_INIT(config->planes); config->crtcs = (struct list_head)LIST_HEAD_INIT(config->crtcs); config->encoders = (struct list_head)LIST_HEAD_INIT(config->encoders); config->connectors = (struct list_head)LIST_HEAD_INIT(config->connectors); @@ -32,15 +33,22 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, struct vkms_config_crtc *crtc_cfg; struct vkms_config_encoder *encoder_cfg; struct vkms_config_connector *connector_cfg; + struct vkms_config_plane *plane_cfg; + int n; config = vkms_config_create(DEFAULT_DEVICE_NAME); if (IS_ERR(config)) return config; - config->cursor = enable_cursor; - config->overlay = enable_overlay; + if (enable_overlay) { + for (n = 0; n < NUM_OVERLAY_PLANES; n++) { + plane_cfg = vkms_config_add_overlay_plane(config, BIT(0)); + if (IS_ERR(plane_cfg)) + return ERR_CAST(plane_cfg); + } + } - crtc_cfg = vkms_config_add_crtc(config, enable_writeback); + crtc_cfg = vkms_config_add_crtc(config, enable_cursor, enable_writeback); if (IS_ERR(crtc_cfg)) return ERR_CAST(crtc_cfg); @@ -57,10 +65,14 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, void vkms_config_destroy(struct vkms_config *config) { + struct vkms_config_plane *plane_cfg, *plane_tmp; struct vkms_config_crtc *crtc_cfg, *crtc_tmp; struct vkms_config_encoder *encoder_cfg, *encoder_tmp; struct vkms_config_connector *connector_cfg, *connector_tmp; + list_for_each_entry_safe(plane_cfg, plane_tmp, &config->planes, list) + vkms_config_destroy_overlay_plane(config, plane_cfg); + list_for_each_entry_safe(crtc_cfg, crtc_tmp, &config->crtcs, list) vkms_config_destroy_crtc(config, crtc_cfg); @@ -78,17 +90,24 @@ 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 *plane_cfg; struct vkms_config_crtc *crtc_cfg; struct vkms_config_encoder *encoder_cfg; struct vkms_config_connector *connector_cfg; int n; seq_printf(m, "dev_name=%s\n", vkmsdev->config->dev_name); - seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor); - seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay); + + n = 0; + list_for_each_entry(plane_cfg, &vkmsdev->config->planes, list) { + seq_printf(m, "plane(%d).possible_crtcs=%d\n", n, + plane_cfg->possible_crtcs); + n++; + } n = 0; list_for_each_entry(crtc_cfg, &vkmsdev->config->crtcs, list) { + seq_printf(m, "crtc(%d).cursor=%d\n", n, crtc_cfg->cursor); seq_printf(m, "crtc(%d).writeback=%d\n", n, crtc_cfg->writeback); n++; @@ -121,7 +140,30 @@ void vkms_config_debugfs_init(struct vkms_device *vkms_device) ARRAY_SIZE(vkms_config_debugfs_list)); } +struct vkms_config_plane *vkms_config_add_overlay_plane(struct vkms_config *config, + uint32_t possible_crtcs) +{ + struct vkms_config_plane *plane_cfg; + + plane_cfg = kzalloc(sizeof(*plane_cfg), GFP_KERNEL); + if (!plane_cfg) + return ERR_PTR(-ENOMEM); + + plane_cfg->possible_crtcs = possible_crtcs; + list_add_tail(&plane_cfg->list, &config->planes); + + return plane_cfg; +} + +void vkms_config_destroy_overlay_plane(struct vkms_config *config, + struct vkms_config_plane *plane_cfg) +{ + list_del(&plane_cfg->list); + kfree(plane_cfg); +} + struct vkms_config_crtc *vkms_config_add_crtc(struct vkms_config *config, + bool enable_cursor, bool enable_writeback) { struct vkms_config_crtc *crtc_cfg; @@ -130,6 +172,7 @@ struct vkms_config_crtc *vkms_config_add_crtc(struct vkms_config *config, if (!crtc_cfg) return ERR_PTR(-ENOMEM); + crtc_cfg->cursor = enable_cursor; crtc_cfg->writeback = enable_writeback; crtc_cfg->index = 0; diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index f1dd59fc6300..25dab63e7ae7 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -8,9 +8,15 @@ struct vkms_device; +struct vkms_config_plane { + struct list_head list; + uint32_t possible_crtcs; +}; + struct vkms_config_crtc { struct list_head list; unsigned int index; + bool cursor; bool writeback; }; @@ -27,8 +33,7 @@ struct vkms_config_connector { struct vkms_config { char *dev_name; - bool cursor; - bool overlay; + struct list_head planes; struct list_head crtcs; struct list_head encoders; struct list_head connectors; @@ -46,8 +51,15 @@ void vkms_config_destroy(struct vkms_config *config); /* DebugFS */ void vkms_config_debugfs_init(struct vkms_device *vkms_device); +/* Planes */ +struct vkms_config_plane *vkms_config_add_overlay_plane(struct vkms_config *config, + uint32_t possible_crtcs); +void vkms_config_destroy_overlay_plane(struct vkms_config *config, + struct vkms_config_plane *plane_cfg); + /* CRTCs */ struct vkms_config_crtc *vkms_config_add_crtc(struct vkms_config *config, + bool enable_cursor, bool enable_writeback); void vkms_config_destroy_crtc(struct vkms_config *config, struct vkms_config_crtc *crtc_cfg); diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 15a2ba26d190..b0a079eb4598 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -154,7 +154,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_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index cac37d21654a..76394285dc68 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -149,10 +149,11 @@ struct vkms_crtc *vkms_crtc_init(struct drm_device *dev, struct drm_plane *cursor, unsigned int index); -int vkms_output_init(struct vkms_device *vkmsdev, int index); +int vkms_output_init(struct vkms_device *vkmsdev); struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type, int index); + enum drm_plane_type type, + uint32_t possible_crtcs); /* CRC Support */ const char *const *vkms_get_crc_sources(struct drm_crtc *crtc, diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 021a491de817..a5b1ab326cdd 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -82,21 +82,22 @@ static struct drm_encoder *vkms_encoder_init(struct vkms_device *vkms_device, return encoder; } -static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, int index) +static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, + uint32_t possible_crtcs) { struct vkms_plane *overlay; - overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY, index); + overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY, possible_crtcs); if (IS_ERR(overlay)) return PTR_ERR(overlay); if (!overlay->base.possible_crtcs) - overlay->base.possible_crtcs = BIT(index); + overlay->base.possible_crtcs = possible_crtcs; return 0; } -int vkms_output_init(struct vkms_device *vkmsdev, int index) +int vkms_output_init(struct vkms_device *vkmsdev) { struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; @@ -106,29 +107,27 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) struct vkms_crtc *vkms_crtc; struct vkms_config_crtc *crtc_cfg; struct vkms_plane *primary, *cursor = NULL; + struct vkms_config_plane *plane_cfg; int ret; int writeback; - unsigned int n; - primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index); - if (IS_ERR(primary)) - return PTR_ERR(primary); - - if (vkmsdev->config->overlay) { - for (n = 0; n < NUM_OVERLAY_PLANES; n++) { - ret = vkms_add_overlay_plane(vkmsdev, index); - if (ret) - return ret; - } - } - - if (vkmsdev->config->cursor) { - cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); - if (IS_ERR(cursor)) - return PTR_ERR(cursor); + list_for_each_entry(plane_cfg, &vkmsdev->config->planes, list) { + ret = vkms_add_overlay_plane(vkmsdev, plane_cfg->possible_crtcs); + if (ret) + return ret; } list_for_each_entry(crtc_cfg, &vkmsdev->config->crtcs, list) { + primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, 0); + if (IS_ERR(primary)) + return PTR_ERR(primary); + + if (crtc_cfg->cursor) { + cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, 0); + if (IS_ERR(cursor)) + return PTR_ERR(cursor); + } + vkms_crtc = vkms_crtc_init(dev, &primary->base, &cursor->base, crtc_cfg->index); if (IS_ERR(vkms_crtc)) @@ -141,6 +140,8 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) if (writeback) DRM_ERROR("Failed to init writeback connector\n"); } + + cursor = NULL; } list_for_each_entry(encoder_cfg, &vkmsdev->config->encoders, list) { diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index e5c625ab8e3e..eb3edf4cb928 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -198,13 +198,13 @@ 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 index) + enum drm_plane_type type, uint32_t possible_crtcs) { struct drm_device *dev = &vkmsdev->drm; struct vkms_plane *plane; - plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 1 << index, - &vkms_plane_funcs, + plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, + possible_crtcs, &vkms_plane_funcs, vkms_formats, ARRAY_SIZE(vkms_formats), NULL, type, NULL); if (IS_ERR(plane)) From patchwork Tue Aug 13 10:44:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761787 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 49C61C52D7D for ; Tue, 13 Aug 2024 10:51:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DB2F10E2F6; Tue, 13 Aug 2024 10:51:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="O5fTSs79"; dkim-atps=neutral Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9FACC10E2EE for ; Tue, 13 Aug 2024 10:51:53 +0000 (UTC) Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-52efa16aad9so6971099e87.0 for ; Tue, 13 Aug 2024 03:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546312; x=1724151112; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZqQI2pSvN1r3euYPp2vCyWNVjuvi3Z3cQv0iU7vYqtw=; b=O5fTSs79yy8w8D7RfdOObpUc5Hj5z0SFp0TI4zlFgawoKDm38lhrZ3fJPudXof9sux XJG6os899PC/qm/whDK7M/lOVPB2otJQhEeLFQTqgYNJuF70s81ZHqFSEH3suGkW0Vjb Lg/kT1EbbRS7+r0v45aLmGppNhy1jTs5+TUNgC3lBJPol1FhrPTKdB6wDztii5F0gOVH 1T0LTzjAW8U+jLDIeUYb6VMUPTq6v2ekhMyFQPJ+dcXPCZrGUovARsHabAUSn5krUz5U jSN//3pVBkwi09qJ8bHYhP9xl30CZqPULrSaaKrFjCq1VFonaBr++z6WycE7UEx/jc/U 5h1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546312; x=1724151112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZqQI2pSvN1r3euYPp2vCyWNVjuvi3Z3cQv0iU7vYqtw=; b=i4xiR6Z6cV9D5H0sgzzfGSJBU21AHilxzS6SXar7ylpV1s/zYo7i7Za9V9hcmIBKW4 5p7LidbEgtgiBNvSROizjT7vCA5vvmVQm7uEQRz+wLLPgXjTLMH07bOFQhPKCq0Ji1Im o6YMmea6g6/m3kPElBkp46WOKJkaaAHWZmy6MtRULXc0fVRzVefECb4FNYQPDqfOfGUh 5caLd0xmnSjxve8rvotqjfykE5sJ3TUJ+Yble3ZENRnOlqW5KKHPzOKDdB4YonPjBm+z fsxunP6mo/AHEu2BHH3YFrI4BcqJUhsa3xYYnedPOmhxSd8jEj1NHokEKKGfcHImAeAX e0nA== X-Forwarded-Encrypted: i=1; AJvYcCVdKj5Ex2TQrefbckQm1uKtRn72xZYAcxeb1U+vEuttVHqY4GejxNN37IuSXPhVJH82FB2kyBtcgLwocZboQa/vLj0RKgT3JQyEKLn99Awi X-Gm-Message-State: AOJu0Yw3Cyi2ZXy4+TIWGv7cDQhw+KJF+n+wczaXiKBm1/IwWzvuV5Ve 2JIAxNN4mz3A+HwKOFfy6n279fQ8cxvMmEzu7dD7aIflOBFNF7Ez X-Google-Smtp-Source: AGHT+IEE/5oIBKt+yDiQMW0HbZMqJpQ32z2JEVYHvnsw69984l4lJ/4s/IJTZ5H3jFbn7gTtOtW3Rw== X-Received: by 2002:a05:6512:114c:b0:52c:d80e:55a5 with SMTP id 2adb3069b0e04-53213693ec2mr2061169e87.41.1723546311208; Tue, 13 Aug 2024 03:51:51 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:50 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 10/17] drm/vkms: Allow to change connector status Date: Tue, 13 Aug 2024 12:44:21 +0200 Message-ID: <20240813105134.17439-11-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Store the connector status in vkms_config_connector and use the stored value to update the connector status in the drm_connector_funcs.detect() function. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_config.c | 18 ++++++++++++++++-- drivers/gpu/drm/vkms/vkms_config.h | 12 +++++++++++- drivers/gpu/drm/vkms/vkms_output.c | 20 ++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index d95a42a6745a..e8e5c02c9d43 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -3,6 +3,7 @@ #include #include +#include #include #include "vkms_config.h" @@ -56,7 +57,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, if (IS_ERR(encoder_cfg)) return ERR_CAST(encoder_cfg); - connector_cfg = vkms_config_add_connector(config, BIT(0)); + connector_cfg = vkms_config_add_connector(config, BIT(0), connector_status_connected); if (IS_ERR(connector_cfg)) return ERR_CAST(connector_cfg); @@ -124,6 +125,8 @@ static int vkms_config_show(struct seq_file *m, void *data) list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, list) { seq_printf(m, "connector(%d).possible_encoders=%d\n", n, connector_cfg->possible_encoders); + seq_printf(m, "connector(%d).status=%d\n", n, + connector_cfg->status); n++; } @@ -229,7 +232,8 @@ void vkms_config_destroy_encoder(struct vkms_config *config, } struct vkms_config_connector *vkms_config_add_connector(struct vkms_config *config, - uint32_t possible_encoders) + uint32_t possible_encoders, + enum drm_connector_status status) { struct vkms_config_connector *connector_cfg; @@ -238,6 +242,7 @@ struct vkms_config_connector *vkms_config_add_connector(struct vkms_config *conf return ERR_PTR(-ENOMEM); connector_cfg->possible_encoders = possible_encoders; + connector_cfg->status = status; list_add_tail(&connector_cfg->list, &config->connectors); return connector_cfg; @@ -249,3 +254,12 @@ void vkms_config_destroy_connector(struct vkms_config *config, list_del(&connector_cfg->list); kfree(connector_cfg); } + +void vkms_update_connector_status(struct vkms_config *config, + struct vkms_config_connector *connector_cfg, + enum drm_connector_status status) +{ + connector_cfg->status = status; + if (config->dev) + drm_kms_helper_hotplug_event(&config->dev->drm); +} diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 25dab63e7ae7..3237406fa3a3 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -6,6 +6,8 @@ #include #include +#include + struct vkms_device; struct vkms_config_plane { @@ -29,6 +31,9 @@ struct vkms_config_encoder { struct vkms_config_connector { struct list_head list; uint32_t possible_encoders; + enum drm_connector_status status; + /* only set when instantiated */ + struct drm_connector *connector; }; struct vkms_config { @@ -72,8 +77,13 @@ void vkms_config_destroy_encoder(struct vkms_config *config, /* Connectors */ struct vkms_config_connector *vkms_config_add_connector(struct vkms_config *config, - uint32_t possible_encoders); + uint32_t possible_encoders, + enum drm_connector_status status); void vkms_config_destroy_connector(struct vkms_config *config, struct vkms_config_connector *connector_cfg); +void vkms_update_connector_status(struct vkms_config *config, + struct vkms_config_connector *connector_cfg, + enum drm_connector_status status); + #endif /* _VKMS_CONFIG_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index a5b1ab326cdd..511cc2c14c44 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -7,7 +7,25 @@ #include #include +static enum drm_connector_status vkms_connector_detect(struct drm_connector *connector, + bool force) +{ + struct vkms_device *vkmsdev = drm_device_to_vkms_device(connector->dev); + enum drm_connector_status status = connector->status; + struct vkms_config_connector *connector_cfg; + + list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, list) { + if (connector_cfg->connector == connector) { + status = connector_cfg->status; + break; + } + } + + return status; +} + static const struct drm_connector_funcs vkms_connector_funcs = { + .detect = vkms_connector_detect, .fill_modes = drm_helper_probe_single_connector_modes, .reset = drm_atomic_helper_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, @@ -155,6 +173,8 @@ int vkms_output_init(struct vkms_device *vkmsdev) connector = vkms_connector_init(vkmsdev, connector_cfg->possible_encoders); if (IS_ERR(connector)) return PTR_ERR(connector); + + connector_cfg->connector = connector; } drm_mode_config_reset(dev); From patchwork Tue Aug 13 10:44:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761786 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 E3701C52D7C for ; Tue, 13 Aug 2024 10:51:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 469EC10E2EE; Tue, 13 Aug 2024 10:51:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ecOn3loh"; dkim-atps=neutral Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0E5A010E2EE for ; Tue, 13 Aug 2024 10:51:54 +0000 (UTC) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4266f3e0df8so37527805e9.2 for ; Tue, 13 Aug 2024 03:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546312; x=1724151112; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2DZ0yno09DV6vF4OePQpExTeBzGL+DurmJi2vCnaEVY=; b=ecOn3loh5J0Fe0wcXmWypS68i5jBLRaHYD6GZpcYpz7N/dIeB5i5wYEC7tzdN/0q4g Zt0wu5+JjE+gg5GxvIZCYU3j1CoYvw40sfGzL71NhbGAZ4Gp/xX8MIVUtVYxw/dYaBo3 DIVGoefzRF8G3mWHiytAby7bSS7e2WK6uQ5xKd4I6Wc2CvMRbsPf5u+u3flEmxPTvAtR 84oNwV9JZNEcGOQqtpgbwhxH3r9yTGcdw23lcFL+pSWuTXVeffk4FrlORKygFQOELdNr V0hTrcElFPOQlwBWjFmaIszaZO2UAQt9XgyMDcvkAFOqIDGqQWybx5zVHSyPrONs4qWl EE5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546312; x=1724151112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2DZ0yno09DV6vF4OePQpExTeBzGL+DurmJi2vCnaEVY=; b=PAhlixCQ+lQe8Fd/0+IA6199L+0gV5c9HYO2k7uaY/xsbqXyBWyuW1RydvgysfBknY YYPUyW+4XZuRVx4gbJhXf5Dk9RL96/ORwYSJ8zhNblvwgEC0eu+rF9qIP7iuEN37uynb meNRvT2svpyS1X0bM4ARsgJuydqnHg3LO6NuccVJrulrAcmewP10KLetTmhcrnTT3uhM X+SRgpLL5iwTbJpD5nLnVTVZoUQhv0DbnG5iS8+Oa90IS2ZltPx3KwZOBFIhzr1aq9Q5 MkBAz8vbUcLphUoRyKRHh5CIzmsTaoIljNW0WLOmjWTY76ZoIluWfCR39+6BHmU9T9jF kaGw== X-Forwarded-Encrypted: i=1; AJvYcCXDufzjAgFVOxZG5tCKtMeliH2xWXULOEVUn0vHHPpJWGJbeyMVT+RMd0HbHJ08HHc5DnjGiZJP2uKXzibRR3046WA8aHhgFMfrFMHbqBXk X-Gm-Message-State: AOJu0Yw/6xLB93h8t4wvkl+ynD3sihwFkDrO9bCM9uCQJYukeKNldMUD ykA6QS2AVcJNo8Iojm0Bog/RhQkh2jCZ4SdJeheQVrNJilaY7YM9 X-Google-Smtp-Source: AGHT+IGgpvIqHt0WTDhpBJPlq78QSS4s/Hy1j9s/Fr8VBNAtgOUXDZ38YXLRqoUGqRmktkNgk0w2DQ== X-Received: by 2002:a05:600c:1391:b0:426:6416:aa73 with SMTP id 5b1f17b1804b1-429d4828df2mr20461065e9.12.1723546312199; Tue, 13 Aug 2024 03:51:52 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:51 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 11/17] drm/vkms: Add and remove VKMS instances via configfs Date: Tue, 13 Aug 2024 12:44:22 +0200 Message-ID: <20240813105134.17439-12-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Allow to create, enable, disable and destroy VKMS instances using configfs. For the moment, add one primary plane, one CRC, one encoder and one connector until we add support to configure them via configfs. Signed-off-by: José Expósito --- Documentation/gpu/vkms.rst | 32 +++++ drivers/gpu/drm/vkms/Kconfig | 1 + drivers/gpu/drm/vkms/Makefile | 3 +- drivers/gpu/drm/vkms/vkms_configfs.c | 198 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_configfs.h | 9 ++ drivers/gpu/drm/vkms/vkms_drv.c | 19 ++- drivers/gpu/drm/vkms/vkms_drv.h | 4 + 7 files changed, 262 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/drm/vkms/vkms_configfs.c create mode 100644 drivers/gpu/drm/vkms/vkms_configfs.h diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index ba04ac7c2167..9895a9ae76f4 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -51,6 +51,38 @@ To disable the driver, use :: sudo modprobe -r vkms +Configuring With Configfs +========================= + +It is possible to create and configure multiple VKMS instances via configfs. + +Start by mounting configfs and loading VKMS:: + + sudo mount -t configfs none /config + sudo modprobe vkms + +Once VKMS is loaded, ``/config/vkms`` is created automatically. Each directory +under ``/config/vkms`` represents a VKMS instance, create a new one:: + + sudo mkdir /config/vkms/my-vkms + +By default, the instance is disabled:: + + cat /config/vkms/my-vkms/enabled + 0 + +Once you are done configuring the VKMS instance, enable it:: + + echo "1" | sudo tee /config/vkms/my-vkms/enabled + +Finally, you can remove the VKMS instance disabling it:: + + echo "0" | sudo tee /config/vkms/my-vkms/enabled + +Or removing the top level directory:: + + sudo rmdir /config/vkms/my-vkms + Testing With IGT ================ diff --git a/drivers/gpu/drm/vkms/Kconfig b/drivers/gpu/drm/vkms/Kconfig index b9ecdebecb0b..de218b21a579 100644 --- a/drivers/gpu/drm/vkms/Kconfig +++ b/drivers/gpu/drm/vkms/Kconfig @@ -6,6 +6,7 @@ config DRM_VKMS select DRM_KMS_HELPER select DRM_GEM_SHMEM_HELPER select CRC32 + select CONFIGFS_FS default n help Virtual Kernel Mode-Setting (VKMS) is used for testing or for diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index b371b5d70ee3..81c257d37689 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -7,6 +7,7 @@ vkms-y := \ vkms_crtc.o \ vkms_composer.o \ vkms_writeback.o \ - vkms_config.o + vkms_config.o \ + vkms_configfs.o obj-$(CONFIG_DRM_VKMS) += vkms.o diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c new file mode 100644 index 000000000000..3f25295f7788 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -0,0 +1,198 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include + +#include "vkms_drv.h" +#include "vkms_config.h" +#include "vkms_configfs.h" + +/* To avoid registering configfs more than once or unregistering on error */ +static bool is_configfs_registered; + +/** + * struct vkms_configfs - Configfs configuration for a VKMS device + * + * @vkms_config: Configuration of the VKMS device + * @device_group: Top level configuration group that represents a VKMS device. + * Initialized when a new directory is created under "/config/vkms/" + * @lock: Lock used to project concurrent access to the configuration attributes + * @enabled: Protected by @lock. The device is created or destroyed when this + * option changes + */ +struct vkms_configfs { + struct vkms_config *vkms_config; + struct config_group device_group; + + /* protected by @lock */ + struct mutex lock; + bool enabled; +}; + +#define config_item_to_vkms_configfs(item) \ + container_of(to_config_group(item), struct vkms_configfs, device_group) + +static ssize_t device_enabled_show(struct config_item *item, char *page) +{ + struct vkms_configfs *configfs = config_item_to_vkms_configfs(item); + + return sprintf(page, "%d\n", configfs->enabled); +} + +static ssize_t device_enabled_store(struct config_item *item, const char *page, + size_t count) +{ + struct vkms_configfs *configfs = config_item_to_vkms_configfs(item); + bool enabled; + int ret = 0; + + if (kstrtobool(page, &enabled)) + return -EINVAL; + + mutex_lock(&configfs->lock); + + if (!configfs->enabled && enabled) + ret = vkms_create(configfs->vkms_config); + else if (configfs->enabled && !enabled) + vkms_destroy(configfs->vkms_config); + + if (ret) + goto err_unlock; + + configfs->enabled = enabled; + + mutex_unlock(&configfs->lock); + + return (ssize_t)count; + +err_unlock: + mutex_unlock(&configfs->lock); + return ret; +} + +CONFIGFS_ATTR(device_, enabled); + +static struct configfs_attribute *device_group_attrs[] = { + &device_attr_enabled, + NULL, +}; + +static const struct config_item_type device_group_type = { + .ct_attrs = device_group_attrs, + .ct_owner = THIS_MODULE, +}; + +static struct config_group *make_device_group(struct config_group *group, + const char *name) +{ + struct vkms_configfs *configfs; + struct vkms_config_crtc *crtc_cfg = NULL; + struct vkms_config_encoder *encoder_cfg = NULL; + struct vkms_config_connector *connector_cfg = NULL; + char *config_name; + int ret; + + if (strcmp(name, DEFAULT_DEVICE_NAME) == 0) + return ERR_PTR(-EINVAL); + + configfs = kzalloc(sizeof(*configfs), GFP_KERNEL); + if (!configfs) + return ERR_PTR(-ENOMEM); + + config_group_init_type_name(&configfs->device_group, name, &device_group_type); + mutex_init(&configfs->lock); + + config_name = config_item_name(&configfs->device_group.cg_item); + configfs->vkms_config = vkms_config_create(config_name); + if (IS_ERR(configfs->vkms_config)) { + ret = PTR_ERR(configfs->vkms_config); + goto err_kfree; + } + + crtc_cfg = vkms_config_add_crtc(configfs->vkms_config, false, false); + if (IS_ERR(crtc_cfg)) { + ret = PTR_ERR(crtc_cfg); + goto err_kfree; + } + + encoder_cfg = vkms_config_add_encoder(configfs->vkms_config, BIT(0)); + if (IS_ERR(encoder_cfg)) { + ret = PTR_ERR(encoder_cfg); + goto err_kfree; + } + + connector_cfg = vkms_config_add_connector(configfs->vkms_config, BIT(0), + connector_status_connected); + if (IS_ERR(connector_cfg)) { + ret = PTR_ERR(connector_cfg); + goto err_kfree; + } + + return &configfs->device_group; + +err_kfree: + kfree(configfs); + kfree(crtc_cfg); + kfree(encoder_cfg); + kfree(connector_cfg); + return ERR_PTR(ret); +} + +static void drop_device_group(struct config_group *group, + struct config_item *item) +{ + struct vkms_configfs *configfs = config_item_to_vkms_configfs(item); + + mutex_lock(&configfs->lock); + + if (configfs->enabled) + vkms_destroy(configfs->vkms_config); + + kfree(configfs->vkms_config); + + mutex_unlock(&configfs->lock); + + kfree(configfs); +} + +static struct configfs_group_operations device_group_ops = { + .make_group = &make_device_group, + .drop_item = &drop_device_group, +}; + +static struct config_item_type vkms_type = { + .ct_group_ops = &device_group_ops, + .ct_owner = THIS_MODULE, +}; + +static struct configfs_subsystem vkms_subsys = { + .su_group = { + .cg_item = { + .ci_name = "vkms", + .ci_type = &vkms_type, + }, + }, + .su_mutex = __MUTEX_INITIALIZER(vkms_subsys.su_mutex), +}; + +int vkms_configfs_register(void) +{ + int ret; + + if (is_configfs_registered) + return 0; + + config_group_init(&vkms_subsys.su_group); + ret = configfs_register_subsystem(&vkms_subsys); + + is_configfs_registered = ret == 0; + + return ret; +} + +void vkms_configfs_unregister(void) +{ + if (is_configfs_registered) + configfs_unregister_subsystem(&vkms_subsys); +} diff --git a/drivers/gpu/drm/vkms/vkms_configfs.h b/drivers/gpu/drm/vkms/vkms_configfs.h new file mode 100644 index 000000000000..b5d7fab877d5 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_configfs.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_CONFIGFS_H_ +#define _VKMS_CONFIGFS_H_ + +int vkms_configfs_register(void); +void vkms_configfs_unregister(void); + +#endif /* _VKMS_CONFIGFS_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index b0a079eb4598..f524a9550017 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -27,6 +27,7 @@ #include #include "vkms_config.h" +#include "vkms_configfs.h" #include "vkms_drv.h" #define DRIVER_NAME "vkms" @@ -157,7 +158,7 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev) return vkms_output_init(vkmsdev); } -static int vkms_create(struct vkms_config *config) +int vkms_create(struct vkms_config *config) { int ret; struct platform_device *pdev; @@ -231,12 +232,22 @@ static int __init vkms_init(void) ret = vkms_create(config); if (ret) - vkms_config_destroy(config); + goto err_kfree; + ret = vkms_configfs_register(); + if (ret) + goto err_destroy; + + return 0; + +err_destroy: + vkms_destroy(config); +err_kfree: + vkms_config_destroy(config); return ret; } -static void vkms_destroy(struct vkms_config *config) +void vkms_destroy(struct vkms_config *config) { struct platform_device *pdev; @@ -257,6 +268,8 @@ static void vkms_destroy(struct vkms_config *config) static void __exit vkms_exit(void) { + vkms_configfs_unregister(); + if (default_config->dev) vkms_destroy(default_config); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 76394285dc68..eb32440e9f94 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -143,6 +143,10 @@ struct vkms_device { #define to_vkms_plane_state(target)\ container_of(target, struct vkms_plane_state, base.base) +/* VKMS device */ +int vkms_create(struct vkms_config *config); +void vkms_destroy(struct vkms_config *config); + /* CRTC */ struct vkms_crtc *vkms_crtc_init(struct drm_device *dev, struct drm_plane *primary, From patchwork Tue Aug 13 10:44:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761788 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 21FB0C531DD for ; Tue, 13 Aug 2024 10:51:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D1DC610E2F7; Tue, 13 Aug 2024 10:51:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LMXBYb21"; dkim-atps=neutral Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id D738C10E2EE for ; Tue, 13 Aug 2024 10:51:54 +0000 (UTC) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-428e3129851so39288225e9.3 for ; Tue, 13 Aug 2024 03:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546313; x=1724151113; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HVBRH0DnuLVDwokIb7HrZrE7ZLWioaYtKcu7A5ZTgas=; b=LMXBYb217wEuOUKaV2hA3yTlz2/z1Qz6JiVQGHdxU1Nr9S3oUvzquxY7qkabmFYbaP Vi7J/PvyxofjF4Ghm+51Y+nSkXxF6BAl5edb7EB1NWrRT0LtP/DwBnFiXhaQm/ZBPWlK v5unDJNfqTzwBgNTPuyQpuLZKeoBJfGxqjFV3rNwWFlqWzGVhOyfLm6CWRppCpZVDObJ oC6tWx/isgk4Edg6NHpsiHyNgqcLmuRuCvncJw2sG7MbGHNjJEVdJ2MsiYor3Bik6fnt yrLa51NfTLABikRVfpfDjsiqvc/e8hsv5B3HTMzRZROosCM6F63wDOLND1El0MY96tke GEFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546313; x=1724151113; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HVBRH0DnuLVDwokIb7HrZrE7ZLWioaYtKcu7A5ZTgas=; b=m/KHEwGgai+FBX+RCF3Y5ZNHEJPcocbN/oEv7VvYlkPkMH7NZdFMHD1JAnDg/cxU5E u/nV8bYJMGlRVTimd/2Mkq9DSkGtnuZSkxkEdc8M8CYx4f8/HVVaiOMk4rWsDSwQfTng hGC5Ku+AxMGlb68P/P9ZFKJmARekBKnzNZXA5onGmDtfE5y4EfEo48WEvTpGMmhRpMbh 3eLrx7zU/aKOszueCeXsWWLWEdZhtq0AJ/FIJKsEr/mbr5RO+IfutEWIcPLKkAE9yhYV C9a6QGadm7zOPGU0R+5i+8BUcRxqq77eCziUq1r0xsoMfZh8Qj5S4bO46WQvWyRgtQ8o uBUA== X-Forwarded-Encrypted: i=1; AJvYcCUC1Kx1Bsr5r1m0wBk0uq+cV1frujtOqqzhU78v2jATNkGwhpKkCLlWatF9itYWg4TfB7XGY4zvZ0Xue6444ywb+N4VhO/rf8jBFrUUrc0F X-Gm-Message-State: AOJu0Yz9iePG+jvTtgCKoearohy38JbFyP3Z5MCVYK8hqhE0wd6jl/Q7 O1vYLeF6mEUCJffHoU1HNLzPBRatatGb/8h3Fh1uBepc70qfpLOW X-Google-Smtp-Source: AGHT+IGx0zK/ifNLLcqjgImibQLg2NAxwokcq14IJSh6ZqPBkiUD5RKQjid95Vj2DBXdcE20rEuz4A== X-Received: by 2002:a05:600c:3b1f:b0:427:ffa4:32d0 with SMTP id 5b1f17b1804b1-429d48711f6mr24333315e9.28.1723546313053; Tue, 13 Aug 2024 03:51:53 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:52 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 12/17] drm/vkms: Allow to configure multiple CRTCs via configfs Date: Tue, 13 Aug 2024 12:44:23 +0200 Message-ID: <20240813105134.17439-13-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Create a default subgroup at /config/vkms/crtcs to allow to create as many CRTCs as required. When a CRTC is created, allow to configure the equivalent of the module parameters enable_cursor and enable_writeback. Signed-off-by: José Expósito --- Documentation/gpu/vkms.rst | 22 +++- drivers/gpu/drm/vkms/vkms_config.h | 3 + drivers/gpu/drm/vkms/vkms_configfs.c | 149 +++++++++++++++++++++++++-- 3 files changed, 166 insertions(+), 8 deletions(-) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index 9895a9ae76f4..0886349ad4a0 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -71,6 +71,25 @@ By default, the instance is disabled:: cat /config/vkms/my-vkms/enabled 0 +And directories are created for each configurable item of the display pipeline:: + + tree /config/vkms/my-vkms + /config/vkms/my-vkms + ├── crtcs + └── enabled + +To add items to the display pipeline, create one or more directories under the +available paths. + +Start by creating one or more CRTCs:: + + sudo mkdir /config/vkms/my-vkms/crtcs/crtc0 + +CRTCs have 2 configurable attributes: + +- cursor: Enable or disable cursor plane support +- writeback: Enable or disable writeback connector support + Once you are done configuring the VKMS instance, enable it:: echo "1" | sudo tee /config/vkms/my-vkms/enabled @@ -79,8 +98,9 @@ Finally, you can remove the VKMS instance disabling it:: echo "0" | sudo tee /config/vkms/my-vkms/enabled -Or removing the top level directory:: +Or removing the top level directory and its subdirectories:: + sudo rmdir /config/vkms/my-vkms/crtcs/* sudo rmdir /config/vkms/my-vkms Testing With IGT diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index 3237406fa3a3..f96a0456a3d7 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -3,6 +3,7 @@ #ifndef _VKMS_CONFIG_H_ #define _VKMS_CONFIG_H_ +#include #include #include @@ -20,6 +21,8 @@ struct vkms_config_crtc { unsigned int index; bool cursor; bool writeback; + /* only used if created from configfs */ + struct config_group crtc_group; }; struct vkms_config_encoder { diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c index 3f25295f7788..04278a39cd3c 100644 --- a/drivers/gpu/drm/vkms/vkms_configfs.c +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -17,6 +17,8 @@ static bool is_configfs_registered; * @vkms_config: Configuration of the VKMS device * @device_group: Top level configuration group that represents a VKMS device. * Initialized when a new directory is created under "/config/vkms/" + * @crtcs_group: Default subgroup of @device_group at "/config/vkms/crtcs". + * Each of its items represent a CRTC * @lock: Lock used to project concurrent access to the configuration attributes * @enabled: Protected by @lock. The device is created or destroyed when this * option changes @@ -24,6 +26,7 @@ static bool is_configfs_registered; struct vkms_configfs { struct vkms_config *vkms_config; struct config_group device_group; + struct config_group crtcs_group; /* protected by @lock */ struct mutex lock; @@ -33,6 +36,141 @@ struct vkms_configfs { #define config_item_to_vkms_configfs(item) \ container_of(to_config_group(item), struct vkms_configfs, device_group) +#define crtcs_group_to_vkms_configfs(group) \ + container_of(group, struct vkms_configfs, crtcs_group) + +#define crtcs_item_to_vkms_configfs(item) \ + container_of(to_config_group(item), struct vkms_configfs, crtcs_group) + +#define crtcs_item_to_vkms_config_crtc(item) \ + container_of(to_config_group(item), struct vkms_config_crtc, crtc_group) + +static ssize_t crtc_cursor_show(struct config_item *item, char *page) +{ + struct vkms_config_crtc *crtc_cfg = crtcs_item_to_vkms_config_crtc(item); + + return sprintf(page, "%d\n", crtc_cfg->cursor); +} + +static ssize_t crtc_cursor_store(struct config_item *item, const char *page, + size_t count) +{ + struct vkms_configfs *configfs = crtcs_item_to_vkms_configfs(item->ci_parent); + struct vkms_config_crtc *crtc_cfg = crtcs_item_to_vkms_config_crtc(item); + bool cursor; + + if (kstrtobool(page, &cursor)) + return -EINVAL; + + mutex_lock(&configfs->lock); + + if (configfs->enabled) { + mutex_unlock(&configfs->lock); + return -EINVAL; + } + + crtc_cfg->cursor = cursor; + + mutex_unlock(&configfs->lock); + + return (ssize_t)count; +} + +static ssize_t crtc_writeback_show(struct config_item *item, char *page) +{ + struct vkms_config_crtc *crtc_cfg = crtcs_item_to_vkms_config_crtc(item); + + return sprintf(page, "%d\n", crtc_cfg->writeback); +} + +static ssize_t crtc_writeback_store(struct config_item *item, const char *page, + size_t count) +{ + struct vkms_configfs *configfs = crtcs_item_to_vkms_configfs(item->ci_parent); + struct vkms_config_crtc *crtc_cfg = crtcs_item_to_vkms_config_crtc(item); + bool writeback; + + if (kstrtobool(page, &writeback)) + return -EINVAL; + + mutex_lock(&configfs->lock); + + if (configfs->enabled) { + mutex_unlock(&configfs->lock); + return -EINVAL; + } + + crtc_cfg->writeback = writeback; + + mutex_unlock(&configfs->lock); + + return (ssize_t)count; +} + +CONFIGFS_ATTR(crtc_, cursor); +CONFIGFS_ATTR(crtc_, writeback); + +static struct configfs_attribute *crtc_group_attrs[] = { + &crtc_attr_cursor, + &crtc_attr_writeback, + NULL, +}; + +static const struct config_item_type crtc_group_type = { + .ct_attrs = crtc_group_attrs, + .ct_owner = THIS_MODULE, +}; + +static struct config_group *make_crtcs_group(struct config_group *group, + const char *name) +{ + struct vkms_configfs *configfs = crtcs_group_to_vkms_configfs(group); + struct vkms_config_crtc *crtc_cfg; + int ret; + + mutex_lock(&configfs->lock); + + if (configfs->enabled) { + ret = -EINVAL; + goto err_unlock; + } + + crtc_cfg = vkms_config_add_crtc(configfs->vkms_config, false, false); + if (IS_ERR(crtc_cfg)) { + ret = PTR_ERR(crtc_cfg); + goto err_unlock; + } + + config_group_init_type_name(&crtc_cfg->crtc_group, name, &crtc_group_type); + + mutex_unlock(&configfs->lock); + + return &crtc_cfg->crtc_group; + +err_unlock: + mutex_unlock(&configfs->lock); + return ERR_PTR(ret); +} + +static void drop_crtcs_group(struct config_group *group, + struct config_item *item) +{ + struct vkms_configfs *configfs = crtcs_group_to_vkms_configfs(group); + struct vkms_config_crtc *crtc_cfg = crtcs_item_to_vkms_config_crtc(item); + + vkms_config_destroy_crtc(configfs->vkms_config, crtc_cfg); +} + +static struct configfs_group_operations crtcs_group_ops = { + .make_group = &make_crtcs_group, + .drop_item = &drop_crtcs_group, +}; + +static struct config_item_type crtcs_group_type = { + .ct_group_ops = &crtcs_group_ops, + .ct_owner = THIS_MODULE, +}; + static ssize_t device_enabled_show(struct config_item *item, char *page) { struct vkms_configfs *configfs = config_item_to_vkms_configfs(item); @@ -87,7 +225,6 @@ static struct config_group *make_device_group(struct config_group *group, const char *name) { struct vkms_configfs *configfs; - struct vkms_config_crtc *crtc_cfg = NULL; struct vkms_config_encoder *encoder_cfg = NULL; struct vkms_config_connector *connector_cfg = NULL; char *config_name; @@ -110,11 +247,10 @@ static struct config_group *make_device_group(struct config_group *group, goto err_kfree; } - crtc_cfg = vkms_config_add_crtc(configfs->vkms_config, false, false); - if (IS_ERR(crtc_cfg)) { - ret = PTR_ERR(crtc_cfg); - goto err_kfree; - } + config_group_init_type_name(&configfs->crtcs_group, "crtcs", + &crtcs_group_type); + configfs_add_default_group(&configfs->crtcs_group, + &configfs->device_group); encoder_cfg = vkms_config_add_encoder(configfs->vkms_config, BIT(0)); if (IS_ERR(encoder_cfg)) { @@ -133,7 +269,6 @@ static struct config_group *make_device_group(struct config_group *group, err_kfree: kfree(configfs); - kfree(crtc_cfg); kfree(encoder_cfg); kfree(connector_cfg); return ERR_PTR(ret); From patchwork Tue Aug 13 10:44:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761785 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 69F25C52D7B for ; Tue, 13 Aug 2024 10:51:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E24C910E2F4; Tue, 13 Aug 2024 10:51:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BDrYfwGA"; dkim-atps=neutral Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 660F010E2EE for ; Tue, 13 Aug 2024 10:51:56 +0000 (UTC) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-42808071810so40378295e9.1 for ; Tue, 13 Aug 2024 03:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546315; x=1724151115; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F/G5AnsYa7zmUTR/MiH01m+WsCKhEwrbdAUk5c5JpIU=; b=BDrYfwGAQ1mUuDdQPrLOonO0uMxETKmYjGIGO1SE5l2bkFwXAZ5W/uA9wj1uQCwf+A 0vy1t5o57/E5NTHrY2fzeGcodO4Y3Ff1q9i/mkI11MnFSfgmeQ99o0J4dIEW0dUc+U+x KdFbkFNwHDu/zkUOBvu5BuVUrCQnC0zKhhllSeDU2tOs2dMgZMdhzUmetUM2c14jdUPE LKmNlEKaB0N1Qzsv0/+sjowEErxGU9rpTfuTUBsU6WC1HZGY7Zc5AtRnugv3UpV39+OM lLRt+yYXp5kRWWr7y/dRY//ghQWZuCxaMcYkIcFn1swlKA9USWTKwLLYGTPy+3h9B8xV 9QPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546315; x=1724151115; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F/G5AnsYa7zmUTR/MiH01m+WsCKhEwrbdAUk5c5JpIU=; b=H/scolfpYl5FaTY9kpWEiolUIAWWLG7K51cYr8UrGsImtkeNx/41gPsoOyrQkeZLic DliRYH1LN+yPJ4q7tWSECdpNFrIRim4o0D2OlKkybKnOmjAotqMGOzjK0PqzDegkqfMH EJ9lcJiqBeEnzBBa1RVeujBNPC8RhPskkuvXw/+JPONKNMK2Hwxz/MwqnufyrVXGGKZs FIAZMLDBXsDdMvs+vI8R92yjK0ttTG5gyhaiiwFbDNOyi6Nq2EPmXQ3BKfEnveVQ7qew w6wZLaBdEmsMhuUIAWy09AjerdldRRbHeaIKlAMdSE+Fid/GkjuqINEiK2nruYSIDdXY ZlWQ== X-Forwarded-Encrypted: i=1; AJvYcCVKXb3QUYKdqn0U8NKl6F/zItTQpYm44oxrg/NcvV71L9H4dk2bQzv95hQtZ7Rjzy1eUuC4sjpHHUMKAMqXyZPFDICnZmBBvGkR8kqNMJf1 X-Gm-Message-State: AOJu0YxVOmudczoHBKJeFFaz1cUCdaoGa3bFqEho1B8x0V0dqo5rtatO 0JBvL1Z6mVBTQ4IMA/GB+8UxL+7X6kkoCLrtBk8MIq2a/lfRvd0a X-Google-Smtp-Source: AGHT+IH8LR+1P5qUwpzWamxktmdZ24m1L+TeHAheXbr8p/lSB6gOBODyUIlICFjkqU13hylsNNiByA== X-Received: by 2002:a05:600c:450e:b0:425:7796:8e2c with SMTP id 5b1f17b1804b1-429d4805ac3mr20794595e9.12.1723546314557; Tue, 13 Aug 2024 03:51:54 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:53 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 13/17] drm/vkms: Allow to configure multiple encoders via configfs Date: Tue, 13 Aug 2024 12:44:24 +0200 Message-ID: <20240813105134.17439-14-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Create a default subgroup at /config/vkms/encoders to allow to create as many encoders as required. When the encoder is created the possible_crtcs subgroup is created allowing to link encoders and CRTCs. Signed-off-by: José Expósito --- Documentation/gpu/vkms.rst | 14 ++- drivers/gpu/drm/vkms/vkms_config.h | 3 + drivers/gpu/drm/vkms/vkms_configfs.c | 127 +++++++++++++++++++++++++-- 3 files changed, 136 insertions(+), 8 deletions(-) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index 0886349ad4a0..c69be063d3b4 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -76,7 +76,8 @@ And directories are created for each configurable item of the display pipeline:: tree /config/vkms/my-vkms /config/vkms/my-vkms ├── crtcs - └── enabled + ├── enabled + └── encoders To add items to the display pipeline, create one or more directories under the available paths. @@ -90,6 +91,15 @@ CRTCs have 2 configurable attributes: - cursor: Enable or disable cursor plane support - writeback: Enable or disable writeback connector support +Continue by creating one or more encoders:: + + sudo mkdir /config/vkms/my-vkms/encoders/encoder0 + +Encoders can be linked to CRTCs by creating a symbolic link under +``possible_crtcs``:: + + sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/encoders/encoder0/possible_crtcs + Once you are done configuring the VKMS instance, enable it:: echo "1" | sudo tee /config/vkms/my-vkms/enabled @@ -100,6 +110,8 @@ Finally, you can remove the VKMS instance disabling it:: Or removing the top level directory and its subdirectories:: + sudo rm /config/vkms/my-vkms/encoders/*/possible_crtcs/* + sudo rmdir /config/vkms/my-vkms/encoders/* sudo rmdir /config/vkms/my-vkms/crtcs/* sudo rmdir /config/vkms/my-vkms diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index f96a0456a3d7..f9423533a7f3 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -29,6 +29,9 @@ struct vkms_config_encoder { struct list_head list; unsigned int index; uint32_t possible_crtcs; + /* only used if created from configfs */ + struct config_group encoder_group; + struct config_group possible_crtcs_group; }; struct vkms_config_connector { diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c index 04278a39cd3c..c0b62fb93dc0 100644 --- a/drivers/gpu/drm/vkms/vkms_configfs.c +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -19,6 +19,8 @@ static bool is_configfs_registered; * Initialized when a new directory is created under "/config/vkms/" * @crtcs_group: Default subgroup of @device_group at "/config/vkms/crtcs". * Each of its items represent a CRTC + * @encoders_group: Default subgroup of @device_group at + * "/config/vkms/encoders". Each of its items represent a encoder * @lock: Lock used to project concurrent access to the configuration attributes * @enabled: Protected by @lock. The device is created or destroyed when this * option changes @@ -27,6 +29,7 @@ struct vkms_configfs { struct vkms_config *vkms_config; struct config_group device_group; struct config_group crtcs_group; + struct config_group encoders_group; /* protected by @lock */ struct mutex lock; @@ -45,6 +48,15 @@ struct vkms_configfs { #define crtcs_item_to_vkms_config_crtc(item) \ container_of(to_config_group(item), struct vkms_config_crtc, crtc_group) +#define encoders_group_to_vkms_configfs(group) \ + container_of(group, struct vkms_configfs, encoders_group) + +#define encoders_item_to_vkms_config_encoder(item) \ + container_of(to_config_group(item), struct vkms_config_encoder, encoder_group) + +#define encoder_possible_crtcs_item_to_vkms_config_encoder(item) \ + container_of(to_config_group(item), struct vkms_config_encoder, possible_crtcs_group) + static ssize_t crtc_cursor_show(struct config_item *item, char *page) { struct vkms_config_crtc *crtc_cfg = crtcs_item_to_vkms_config_crtc(item); @@ -171,6 +183,110 @@ static struct config_item_type crtcs_group_type = { .ct_owner = THIS_MODULE, }; +static int encoder_possible_crtcs_allow_link(struct config_item *src, + struct config_item *target) +{ + struct vkms_config_encoder *encoder_cfg; + struct vkms_config_crtc *crtc_cfg; + + if (target->ci_type != &crtc_group_type) + return -EINVAL; + + encoder_cfg = encoder_possible_crtcs_item_to_vkms_config_encoder(src); + crtc_cfg = crtcs_item_to_vkms_config_crtc(target); + + if (encoder_cfg->possible_crtcs & BIT(crtc_cfg->index)) + return -EINVAL; + + encoder_cfg->possible_crtcs |= BIT(crtc_cfg->index); + + return 0; +} + +static void encoder_possible_crtcs_drop_link(struct config_item *src, + struct config_item *target) +{ + struct vkms_config_encoder *encoder_cfg; + struct vkms_config_crtc *crtc_cfg; + + encoder_cfg = encoder_possible_crtcs_item_to_vkms_config_encoder(src); + crtc_cfg = crtcs_item_to_vkms_config_crtc(target); + + encoder_cfg->possible_crtcs &= ~BIT(crtc_cfg->index); +} + +static struct configfs_item_operations encoder_possible_crtcs_item_ops = { + .allow_link = &encoder_possible_crtcs_allow_link, + .drop_link = &encoder_possible_crtcs_drop_link, +}; + +static struct config_item_type encoder_possible_crtcs_group_type = { + .ct_item_ops = &encoder_possible_crtcs_item_ops, + .ct_owner = THIS_MODULE, +}; + +static const struct config_item_type encoder_group_type = { + .ct_owner = THIS_MODULE, +}; + +static struct config_group *make_encoders_group(struct config_group *group, + const char *name) +{ + struct vkms_configfs *configfs = encoders_group_to_vkms_configfs(group); + struct vkms_config_encoder *encoder_cfg; + int ret; + + mutex_lock(&configfs->lock); + + if (configfs->enabled) { + ret = -EINVAL; + goto err_unlock; + } + + encoder_cfg = vkms_config_add_encoder(configfs->vkms_config, 0); + if (IS_ERR(encoder_cfg)) { + ret = PTR_ERR(encoder_cfg); + goto err_unlock; + } + + config_group_init_type_name(&encoder_cfg->encoder_group, name, + &encoder_group_type); + + config_group_init_type_name(&encoder_cfg->possible_crtcs_group, + "possible_crtcs", + &encoder_possible_crtcs_group_type); + configfs_add_default_group(&encoder_cfg->possible_crtcs_group, + &encoder_cfg->encoder_group); + + mutex_unlock(&configfs->lock); + + return &encoder_cfg->encoder_group; + +err_unlock: + mutex_unlock(&configfs->lock); + return ERR_PTR(ret); +} + +static void drop_encoders_group(struct config_group *group, + struct config_item *item) +{ + struct vkms_configfs *configfs = encoders_group_to_vkms_configfs(group); + struct vkms_config_encoder *encoder_cfg = + encoders_item_to_vkms_config_encoder(item); + + vkms_config_destroy_encoder(configfs->vkms_config, encoder_cfg); +} + +static struct configfs_group_operations encoders_group_ops = { + .make_group = &make_encoders_group, + .drop_item = &drop_encoders_group, +}; + +static struct config_item_type encoders_group_type = { + .ct_group_ops = &encoders_group_ops, + .ct_owner = THIS_MODULE, +}; + static ssize_t device_enabled_show(struct config_item *item, char *page) { struct vkms_configfs *configfs = config_item_to_vkms_configfs(item); @@ -225,7 +341,6 @@ static struct config_group *make_device_group(struct config_group *group, const char *name) { struct vkms_configfs *configfs; - struct vkms_config_encoder *encoder_cfg = NULL; struct vkms_config_connector *connector_cfg = NULL; char *config_name; int ret; @@ -252,11 +367,10 @@ static struct config_group *make_device_group(struct config_group *group, configfs_add_default_group(&configfs->crtcs_group, &configfs->device_group); - encoder_cfg = vkms_config_add_encoder(configfs->vkms_config, BIT(0)); - if (IS_ERR(encoder_cfg)) { - ret = PTR_ERR(encoder_cfg); - goto err_kfree; - } + config_group_init_type_name(&configfs->encoders_group, "encoders", + &encoders_group_type); + configfs_add_default_group(&configfs->encoders_group, + &configfs->device_group); connector_cfg = vkms_config_add_connector(configfs->vkms_config, BIT(0), connector_status_connected); @@ -269,7 +383,6 @@ static struct config_group *make_device_group(struct config_group *group, err_kfree: kfree(configfs); - kfree(encoder_cfg); kfree(connector_cfg); return ERR_PTR(ret); } From patchwork Tue Aug 13 10:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761792 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 55E92C52D7C for ; Tue, 13 Aug 2024 10:52:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CDE3010E2EB; Tue, 13 Aug 2024 10:52:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PaZBITCN"; dkim-atps=neutral Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F33910E2F8 for ; Tue, 13 Aug 2024 10:51:58 +0000 (UTC) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-52fc4388a64so7337118e87.1 for ; Tue, 13 Aug 2024 03:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546316; x=1724151116; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GIG00hBvhxwE6VfxQ1Dl1AavFjjBn2BviUu5FBbH+3g=; b=PaZBITCNEEh7mxUYjAqRgn/8KrpuSaeSlCr1wIuK3SA9dpZvMw15hxOKH1dJV8D/Nu 8rmHK/2TaB0ZlPJBfbxVAuwskAojQWr8wrQlh6OUL4C+CZF8IFNaztrGskMjNDovaBB2 gMJF5WgzBdHna6dDmuLbQ2/N5gVzp8y5n2h4CWM+1zBjqZduSP6XX+i7chhZvXXI4BSk chcI7p6XNQpMOgTPml1r5JC7bd98xQ+YGtsvnVG/PYiZC1sMBdPnr3sLLPscZiIzHnhn u3b5iw3RSuWb7o5BcPMbVIthxBVZ5LDn6LbtE+SDx6pDLADzRxEAzf81LYtmarpHGlQL bCpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546316; x=1724151116; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GIG00hBvhxwE6VfxQ1Dl1AavFjjBn2BviUu5FBbH+3g=; b=kv6IHlMXNLb71plEuAl2XIFJG3Vx9j9RcrIhT+SUud5laDZlgaZ3mWPBJFOTf6wQnW N5xTTAGzRPSJVvB/qq2h92L0hMbLtfLu1BzXnNrJlUlTapk+k2xCpjw2uxWZXBUAu0nA i77RxB5+IVllPumsGyA5OpKaelEnjK0nDyU/cV+ygnANJHLzM+HmAG5nTwGxJsRkiM9T S/5jQeV5SLCYlWzwgMa+lI0BGZrvhLvmwl31VQLF7S0omJLWx8gIxa2HJy0xniZtm6bw BiDB+TXSj/TmtIceSYWvKP9zULQF+F77T3tqhXQJ/lzb/IMx0727HooGag5tSP2rt9o8 kadg== X-Forwarded-Encrypted: i=1; AJvYcCV2UVw1bi35Q/el4jVXdOn2zXQ7l3NFFnoffud1itTvplmsDeWEXbhH6Af6muUcImAj4umPhaJvB1nBFGNo5GizPvapjSlrWAxMHKr9oZu5 X-Gm-Message-State: AOJu0YwTyFe/Jm7eZAfz6gY1shhiLb0fVvfs+RlieYrB8TCnQiWr42vl E6UhMnC3dNQTKlNutjXUDtxGMX/isBM04wnua4Zpgt3yy1y5huCh X-Google-Smtp-Source: AGHT+IHG61sFSXaG2KPmxHnV7dm/Gc1K15rhK/tEp3tOyYNwnbyxbnWi9QRN7AYcotU8SvHARdSFyw== X-Received: by 2002:a05:6512:31ce:b0:52e:9b15:1c60 with SMTP id 2adb3069b0e04-53213680d76mr1857158e87.48.1723546315942; Tue, 13 Aug 2024 03:51:55 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:55 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 14/17] drm/vkms: Allow to configure multiple encoders Date: Tue, 13 Aug 2024 12:44:25 +0200 Message-ID: <20240813105134.17439-15-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Add a list of encoder configurations to vkms_config and add as many encoders as configured during output initialization. For backwards compatibility, create a single encoder in the default configuration. Signed-off-by: José Expósito --- Documentation/gpu/vkms.rst | 16 +++ drivers/gpu/drm/vkms/vkms_config.h | 3 + drivers/gpu/drm/vkms/vkms_configfs.c | 184 ++++++++++++++++++++++++--- 3 files changed, 188 insertions(+), 15 deletions(-) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index c69be063d3b4..b6ceb8c48310 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -75,6 +75,7 @@ And directories are created for each configurable item of the display pipeline:: tree /config/vkms/my-vkms /config/vkms/my-vkms + ├── connectors ├── crtcs ├── enabled └── encoders @@ -100,16 +101,31 @@ Encoders can be linked to CRTCs by creating a symbolic link under sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/encoders/encoder0/possible_crtcs +Next, create one or more connectors:: + + sudo mkdir /config/vkms/my-vkms/connectors/connector0 + +The status of the connector can be changed writing ``1`` (connected), ``2`` +(disconnected) or ``3`` (unknown) to the ``status`` attribute and they can be +linked to encoders by creating a symbolic link under ``possible_encoders``:: + + sudo ln -s /config/vkms/my-vkms/encoders/encoder0 /config/vkms/my-vkms/connectors/connector0/possible_encoders + Once you are done configuring the VKMS instance, enable it:: echo "1" | sudo tee /config/vkms/my-vkms/enabled +Note that the connector ``status`` can be changed once the VKMS instance is +enabled to emulate hot-plug/unplug. + Finally, you can remove the VKMS instance disabling it:: echo "0" | sudo tee /config/vkms/my-vkms/enabled Or removing the top level directory and its subdirectories:: + sudo rm /config/vkms/my-vkms/connectors/*/possible_encoders/* + sudo rmdir /config/vkms/my-vkms/connectors/* sudo rm /config/vkms/my-vkms/encoders/*/possible_crtcs/* sudo rmdir /config/vkms/my-vkms/encoders/* sudo rmdir /config/vkms/my-vkms/crtcs/* diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index f9423533a7f3..cf45e3f6ae92 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -40,6 +40,9 @@ struct vkms_config_connector { enum drm_connector_status status; /* only set when instantiated */ struct drm_connector *connector; + /* only used if created from configfs */ + struct config_group connector_group; + struct config_group possible_encoders_group; }; struct vkms_config { diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c index c0b62fb93dc0..d2369f53e2d8 100644 --- a/drivers/gpu/drm/vkms/vkms_configfs.c +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -21,6 +21,8 @@ static bool is_configfs_registered; * Each of its items represent a CRTC * @encoders_group: Default subgroup of @device_group at * "/config/vkms/encoders". Each of its items represent a encoder + * @connectors_group: Default subgroup of @device_group at + * "/config/vkms/connectors". Each of its items represent a connector * @lock: Lock used to project concurrent access to the configuration attributes * @enabled: Protected by @lock. The device is created or destroyed when this * option changes @@ -30,6 +32,7 @@ struct vkms_configfs { struct config_group device_group; struct config_group crtcs_group; struct config_group encoders_group; + struct config_group connectors_group; /* protected by @lock */ struct mutex lock; @@ -57,6 +60,18 @@ struct vkms_configfs { #define encoder_possible_crtcs_item_to_vkms_config_encoder(item) \ container_of(to_config_group(item), struct vkms_config_encoder, possible_crtcs_group) +#define connectors_group_to_vkms_configfs(group) \ + container_of(group, struct vkms_configfs, connectors_group) + +#define connectors_item_to_vkms_configfs(item) \ + container_of(to_config_group(item), struct vkms_configfs, connectors_group) + +#define connector_item_to_vkms_config_connector(item) \ + container_of(to_config_group(item), struct vkms_config_connector, connector_group) + +#define connector_possible_encoders_item_to_vkms_config_connector(item) \ + container_of(to_config_group(item), struct vkms_config_connector, possible_encoders_group) + static ssize_t crtc_cursor_show(struct config_item *item, char *page) { struct vkms_config_crtc *crtc_cfg = crtcs_item_to_vkms_config_crtc(item); @@ -287,6 +302,154 @@ static struct config_item_type encoders_group_type = { .ct_owner = THIS_MODULE, }; +static int connector_possible_encoders_allow_link(struct config_item *src, + struct config_item *target) +{ + struct vkms_config_connector *connector_cfg; + struct vkms_config_encoder *encoder_cfg; + + if (target->ci_type != &encoder_group_type) + return -EINVAL; + + connector_cfg = connector_possible_encoders_item_to_vkms_config_connector(src); + encoder_cfg = encoders_item_to_vkms_config_encoder(target); + + if (connector_cfg->possible_encoders & BIT(encoder_cfg->index)) + return -EINVAL; + + connector_cfg->possible_encoders |= BIT(encoder_cfg->index); + + return 0; +} + +static void connector_possible_encoders_drop_link(struct config_item *src, + struct config_item *target) +{ + struct vkms_config_connector *connector_cfg; + struct vkms_config_encoder *encoder_cfg; + + connector_cfg = connector_possible_encoders_item_to_vkms_config_connector(src); + encoder_cfg = encoders_item_to_vkms_config_encoder(target); + + connector_cfg->possible_encoders &= ~BIT(encoder_cfg->index); +} + +static struct configfs_item_operations connector_possible_encoders_item_ops = { + .allow_link = &connector_possible_encoders_allow_link, + .drop_link = &connector_possible_encoders_drop_link, +}; + +static struct config_item_type connector_possible_encoders_group_type = { + .ct_item_ops = &connector_possible_encoders_item_ops, + .ct_owner = THIS_MODULE, +}; + +static ssize_t connector_status_show(struct config_item *item, char *page) +{ + struct vkms_config_connector *connector_cfg = + connector_item_to_vkms_config_connector(item); + + return sprintf(page, "%d\n", connector_cfg->status); +} + +static ssize_t connector_status_store(struct config_item *item, const char *page, + size_t count) +{ + struct vkms_configfs *configfs; + struct vkms_config_connector *connector_cfg; + int status; + + if (kstrtoint(page, 10, &status)) + return -EINVAL; + + switch (status) { + case connector_status_connected: + case connector_status_disconnected: + case connector_status_unknown: + break; + default: + return -EINVAL; + } + + configfs = connectors_item_to_vkms_configfs(item->ci_parent); + connector_cfg = connector_item_to_vkms_config_connector(item); + + vkms_update_connector_status(configfs->vkms_config, connector_cfg, status); + + return (ssize_t)count; +} + +CONFIGFS_ATTR(connector_, status); + +static struct configfs_attribute *connector_group_attrs[] = { + &connector_attr_status, + NULL, +}; + +static const struct config_item_type connector_group_type = { + .ct_attrs = connector_group_attrs, + .ct_owner = THIS_MODULE, +}; + +static struct config_group *make_connectors_group(struct config_group *group, + const char *name) +{ + struct vkms_configfs *configfs = connectors_group_to_vkms_configfs(group); + struct vkms_config_connector *connector_cfg; + int ret; + + mutex_lock(&configfs->lock); + + if (configfs->enabled) { + ret = -EINVAL; + goto err_unlock; + } + + connector_cfg = vkms_config_add_connector(configfs->vkms_config, 0, + connector_status_connected); + if (IS_ERR(connector_cfg)) { + ret = PTR_ERR(connector_cfg); + goto err_unlock; + } + + config_group_init_type_name(&connector_cfg->connector_group, name, + &connector_group_type); + + config_group_init_type_name(&connector_cfg->possible_encoders_group, + "possible_encoders", + &connector_possible_encoders_group_type); + configfs_add_default_group(&connector_cfg->possible_encoders_group, + &connector_cfg->connector_group); + + mutex_unlock(&configfs->lock); + + return &connector_cfg->connector_group; + +err_unlock: + mutex_unlock(&configfs->lock); + return ERR_PTR(ret); +} + +static void drop_connectors_group(struct config_group *group, + struct config_item *item) +{ + struct vkms_configfs *configfs = connectors_group_to_vkms_configfs(group); + struct vkms_config_connector *connector_cfg = + connector_item_to_vkms_config_connector(item); + + vkms_config_destroy_connector(configfs->vkms_config, connector_cfg); +} + +static struct configfs_group_operations connectors_group_ops = { + .make_group = &make_connectors_group, + .drop_item = &drop_connectors_group, +}; + +static struct config_item_type connectors_group_type = { + .ct_group_ops = &connectors_group_ops, + .ct_owner = THIS_MODULE, +}; + static ssize_t device_enabled_show(struct config_item *item, char *page) { struct vkms_configfs *configfs = config_item_to_vkms_configfs(item); @@ -341,9 +504,7 @@ static struct config_group *make_device_group(struct config_group *group, const char *name) { struct vkms_configfs *configfs; - struct vkms_config_connector *connector_cfg = NULL; char *config_name; - int ret; if (strcmp(name, DEFAULT_DEVICE_NAME) == 0) return ERR_PTR(-EINVAL); @@ -358,8 +519,8 @@ static struct config_group *make_device_group(struct config_group *group, config_name = config_item_name(&configfs->device_group.cg_item); configfs->vkms_config = vkms_config_create(config_name); if (IS_ERR(configfs->vkms_config)) { - ret = PTR_ERR(configfs->vkms_config); - goto err_kfree; + kfree(configfs); + return ERR_CAST(configfs->vkms_config); } config_group_init_type_name(&configfs->crtcs_group, "crtcs", @@ -372,19 +533,12 @@ static struct config_group *make_device_group(struct config_group *group, configfs_add_default_group(&configfs->encoders_group, &configfs->device_group); - connector_cfg = vkms_config_add_connector(configfs->vkms_config, BIT(0), - connector_status_connected); - if (IS_ERR(connector_cfg)) { - ret = PTR_ERR(connector_cfg); - goto err_kfree; - } + config_group_init_type_name(&configfs->connectors_group, "connectors", + &connectors_group_type); + configfs_add_default_group(&configfs->connectors_group, + &configfs->device_group); return &configfs->device_group; - -err_kfree: - kfree(configfs); - kfree(connector_cfg); - return ERR_PTR(ret); } static void drop_device_group(struct config_group *group, From patchwork Tue Aug 13 10:44:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761791 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 1195DC52D7D for ; Tue, 13 Aug 2024 10:52:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 26C2110E2FD; Tue, 13 Aug 2024 10:52:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LRh5OUi1"; dkim-atps=neutral Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A77610E2F8 for ; Tue, 13 Aug 2024 10:51:58 +0000 (UTC) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-42816ca782dso40962575e9.2 for ; Tue, 13 Aug 2024 03:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546317; x=1724151117; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bEJ3c0tbXkLCUVM8w2XGUoLlD36QVGf/XlmxenxbwBg=; b=LRh5OUi1fIccsOX50vx+v7BHEkKtmI5WMmUsmTYvuQJhtfRE0DHyL4XnZ/qH1gTdWn uZkcY8l/0/+OFpio+gVd9OEL7uXnw8N3Bd9/tyBUI6iJfvucf0qXuG8EfgomW+GQQNdd +z04E5Ydr47eJE6V+LTbfckv2vDeApJm0uKJYQE2gm0Pn0MCBnJ76Fou4BKTnCNvxw+k z1fEpqlecWwk94Wm6pa59NSH4VBzYrOf2mS4MYlegYPRoZN2MgGUgsulcl6+qNK+glNH Bfs4dhcELV4bvCXprfCTWDLDGxk5MC0cGztgzefTW52CzAIpFNBM5x72uVZePiHida8r Zyxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546317; x=1724151117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bEJ3c0tbXkLCUVM8w2XGUoLlD36QVGf/XlmxenxbwBg=; b=Wi7ZU362abfaQvNsd7wBpWPuez2l3VwYC7nMvjVmsCLGtff0A9zoVX5ZtV0JlyuSu8 KXiSiU6HEv2nvhw/laU2jscMXe3m9dPRM/w+krcn1dhMs/apUmk6zm9xRVA8JjApH439 oK4Ysd3Pb7GP+Ezdhuc5wHzkZD8K2wCaO6+2RypX7NqOma9ndWXutwi321kW4fHAuq33 UMTtEiUSUn3yda8gNja7ma0NcIlM1qcw2WhyXY4e0V11jDPLUgzFoMoFdGcwVmc9Z8z6 I8FvUzc9vfPS2W6N1M0bzfqalzu228ZfOgnomgk3ZqCNTmSh2tpqltDiImTCWyqOBkJC Qdxg== X-Forwarded-Encrypted: i=1; AJvYcCVcKJLMs86dI3caK29ulgvG04Hv7MWNB5NDi58e8+Y2pjm3bne7PWO9oU9dtOn9d+GL6LGBHICLZ/I=@lists.freedesktop.org X-Gm-Message-State: AOJu0YyeK6e0CuqSZcC9D7y2L6DVnbBd0flZCTmSPPlkTDPc/Y9CnsER CC5V599XbfNVinZoJnbKSe7rd0gqa6EJKNNNvGqUerrqePc5hd3o X-Google-Smtp-Source: AGHT+IESV+wchjJ2FOAcWUm8UC3C3J1WBcWqWQE0yaBq8D5o1OiKaRZvZx0+aIIqhD8qLLziu5WRdw== X-Received: by 2002:a05:600c:2909:b0:428:e866:3933 with SMTP id 5b1f17b1804b1-429d4a5a815mr24149465e9.22.1723546316854; Tue, 13 Aug 2024 03:51:56 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:56 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 15/17] drm/vkms: Allow to configure multiple planes via configfs Date: Tue, 13 Aug 2024 12:44:26 +0200 Message-ID: <20240813105134.17439-16-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Create a default subgroup at /config/vkms/planes to allow to create as many overlay planes as required. When the plane is created the possible_crtcs subgroup is created allowing to link planes and CRTCs. Signed-off-by: José Expósito --- Documentation/gpu/vkms.rst | 13 ++- drivers/gpu/drm/vkms/vkms_config.h | 3 + drivers/gpu/drm/vkms/vkms_configfs.c | 121 +++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 1 deletion(-) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index b6ceb8c48310..ee71d1a569dd 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -78,7 +78,8 @@ And directories are created for each configurable item of the display pipeline:: ├── connectors ├── crtcs ├── enabled - └── encoders + ├── encoders + └── planes To add items to the display pipeline, create one or more directories under the available paths. @@ -111,6 +112,14 @@ linked to encoders by creating a symbolic link under ``possible_encoders``:: sudo ln -s /config/vkms/my-vkms/encoders/encoder0 /config/vkms/my-vkms/connectors/connector0/possible_encoders +Finally, create zero or more overlay planes:: + + sudo mkdir /config/vkms/my-vkms/planes/plane0 + +And link them with their ``possible_crtcs``:: + + sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/planes/plane0/possible_crtcs + Once you are done configuring the VKMS instance, enable it:: echo "1" | sudo tee /config/vkms/my-vkms/enabled @@ -128,6 +137,8 @@ Or removing the top level directory and its subdirectories:: sudo rmdir /config/vkms/my-vkms/connectors/* sudo rm /config/vkms/my-vkms/encoders/*/possible_crtcs/* sudo rmdir /config/vkms/my-vkms/encoders/* + sudo rm /config/vkms/my-vkms/planes/*/possible_crtcs/* + sudo rmdir /config/vkms/my-vkms/planes/* sudo rmdir /config/vkms/my-vkms/crtcs/* sudo rmdir /config/vkms/my-vkms diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index cf45e3f6ae92..2ec08bb58ec4 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -14,6 +14,9 @@ struct vkms_device; struct vkms_config_plane { struct list_head list; uint32_t possible_crtcs; + /* only used if created from configfs */ + struct config_group plane_group; + struct config_group possible_crtcs_group; }; struct vkms_config_crtc { diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c index d2369f53e2d8..0b5ac0767da0 100644 --- a/drivers/gpu/drm/vkms/vkms_configfs.c +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -23,6 +23,8 @@ static bool is_configfs_registered; * "/config/vkms/encoders". Each of its items represent a encoder * @connectors_group: Default subgroup of @device_group at * "/config/vkms/connectors". Each of its items represent a connector + * @planes_group: Default subgroup of @device_group at "/config/vkms/planes". + * Each of its items represent an overlay plane * @lock: Lock used to project concurrent access to the configuration attributes * @enabled: Protected by @lock. The device is created or destroyed when this * option changes @@ -33,6 +35,7 @@ struct vkms_configfs { struct config_group crtcs_group; struct config_group encoders_group; struct config_group connectors_group; + struct config_group planes_group; /* protected by @lock */ struct mutex lock; @@ -72,6 +75,15 @@ struct vkms_configfs { #define connector_possible_encoders_item_to_vkms_config_connector(item) \ container_of(to_config_group(item), struct vkms_config_connector, possible_encoders_group) +#define planes_group_to_vkms_configfs(group) \ + container_of(group, struct vkms_configfs, planes_group) + +#define planes_item_to_vkms_config_plane(item) \ + container_of(to_config_group(item), struct vkms_config_plane, plane_group) + +#define plane_possible_crtcs_item_to_vkms_config_plane(item) \ + container_of(to_config_group(item), struct vkms_config_plane, possible_crtcs_group) + static ssize_t crtc_cursor_show(struct config_item *item, char *page) { struct vkms_config_crtc *crtc_cfg = crtcs_item_to_vkms_config_crtc(item); @@ -450,6 +462,110 @@ static struct config_item_type connectors_group_type = { .ct_owner = THIS_MODULE, }; +static int plane_possible_crtcs_allow_link(struct config_item *src, + struct config_item *target) +{ + struct vkms_config_plane *plane_cfg; + struct vkms_config_crtc *crtc_cfg; + + if (target->ci_type != &crtc_group_type) + return -EINVAL; + + plane_cfg = plane_possible_crtcs_item_to_vkms_config_plane(src); + crtc_cfg = crtcs_item_to_vkms_config_crtc(target); + + if (plane_cfg->possible_crtcs & BIT(crtc_cfg->index)) + return -EINVAL; + + plane_cfg->possible_crtcs |= BIT(crtc_cfg->index); + + return 0; +} + +static void plane_possible_crtcs_drop_link(struct config_item *src, + struct config_item *target) +{ + struct vkms_config_plane *plane_cfg; + struct vkms_config_crtc *crtc_cfg; + + plane_cfg = plane_possible_crtcs_item_to_vkms_config_plane(src); + crtc_cfg = crtcs_item_to_vkms_config_crtc(target); + + plane_cfg->possible_crtcs &= ~BIT(crtc_cfg->index); +} + +static struct configfs_item_operations plane_possible_crtcs_item_ops = { + .allow_link = &plane_possible_crtcs_allow_link, + .drop_link = &plane_possible_crtcs_drop_link, +}; + +static struct config_item_type plane_possible_crtcs_group_type = { + .ct_item_ops = &plane_possible_crtcs_item_ops, + .ct_owner = THIS_MODULE, +}; + +static const struct config_item_type plane_group_type = { + .ct_owner = THIS_MODULE, +}; + +static struct config_group *make_planes_group(struct config_group *group, + const char *name) +{ + struct vkms_configfs *configfs = planes_group_to_vkms_configfs(group); + struct vkms_config_plane *plane_cfg; + int ret; + + mutex_lock(&configfs->lock); + + if (configfs->enabled) { + ret = -EINVAL; + goto err_unlock; + } + + plane_cfg = vkms_config_add_overlay_plane(configfs->vkms_config, 0); + if (IS_ERR(plane_cfg)) { + ret = PTR_ERR(plane_cfg); + goto err_unlock; + } + + config_group_init_type_name(&plane_cfg->plane_group, name, + &plane_group_type); + + config_group_init_type_name(&plane_cfg->possible_crtcs_group, + "possible_crtcs", + &plane_possible_crtcs_group_type); + configfs_add_default_group(&plane_cfg->possible_crtcs_group, + &plane_cfg->plane_group); + + mutex_unlock(&configfs->lock); + + return &plane_cfg->plane_group; + +err_unlock: + mutex_unlock(&configfs->lock); + return ERR_PTR(ret); +} + +static void drop_planes_group(struct config_group *group, + struct config_item *item) +{ + struct vkms_configfs *configfs = planes_group_to_vkms_configfs(group); + struct vkms_config_plane *plane_cfg = + planes_item_to_vkms_config_plane(item); + + vkms_config_destroy_overlay_plane(configfs->vkms_config, plane_cfg); +} + +static struct configfs_group_operations planes_group_ops = { + .make_group = &make_planes_group, + .drop_item = &drop_planes_group, +}; + +static struct config_item_type planes_group_type = { + .ct_group_ops = &planes_group_ops, + .ct_owner = THIS_MODULE, +}; + static ssize_t device_enabled_show(struct config_item *item, char *page) { struct vkms_configfs *configfs = config_item_to_vkms_configfs(item); @@ -538,6 +654,11 @@ static struct config_group *make_device_group(struct config_group *group, configfs_add_default_group(&configfs->connectors_group, &configfs->device_group); + config_group_init_type_name(&configfs->planes_group, "planes", + &planes_group_type); + configfs_add_default_group(&configfs->planes_group, + &configfs->device_group); + return &configfs->device_group; } From patchwork Tue Aug 13 10:44:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761789 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 0FDF1C52D7B for ; Tue, 13 Aug 2024 10:52:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80FF010E2F8; Tue, 13 Aug 2024 10:52:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KDwUk2pI"; dkim-atps=neutral Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA32B10E2F8 for ; Tue, 13 Aug 2024 10:51:59 +0000 (UTC) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-427fc97a88cso41139515e9.0 for ; Tue, 13 Aug 2024 03:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546318; x=1724151118; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NDXFx9oyQqvcOYhB99pL1IoGdV1beOFs/38ZJyCSxSU=; b=KDwUk2pIKgGY1bQma+jqD01FDEObrih0490LO2dQfJezR2V/ijoEbzagLXoo+nSFTr AOq32bWO4HeSA9v8laYORG8Pu9k+7sL7Vn4E8Ye4KkXJwtBAEfpSnQ45c4TLUI3i8sWz fXizdmXFyiH10s6hG2R89HEgw/Xpeh9E+LVdUxZiEAeOWhABWrboQSS2SGe0l3XvjbLf aOjcXC9z09vvQWofvyWslAaAC++S59h0nxpuwbgsYpghxWqqu7a1HnRcnNPUKxt1pRkN 3CF3pc7oft605aOUYlnk3Cowh7TEs4dfx2pzZ4JLCn0odBwmdtk1FFjp8ozYXBfuY8HK 4PoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546318; x=1724151118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NDXFx9oyQqvcOYhB99pL1IoGdV1beOFs/38ZJyCSxSU=; b=oAA6vyVgNmec4phy9/uDfwzDrM6CdeSl90UV/hy5OFCNMmTX4V3Mic3wJOubjQdkyO CLxsJDbQ+0YVHlIyY/oXLuXo4c4XDHsl65YRzyEw2QNDNEf7vtH26F1vHAR7z7/tptfl f8w8cTmFtHYFZ6Dch93+78DasO3sNWeRYvnAYr2A9fMKsdQTUgbWrKJxqG8mI967eZ/r 5BOERHJ4DVp01kbTsNQA3dPaYVoaNwZXxQE94uD9S9ouZN6TzZAZB/0JDb4XAmS5MIGB G8HObDgHjo/pEQpdDEZUnZz0fUB8KV3q5d42qrZsiT6U18l5pRnlpYCgwCsdB4KXfnMo +BYA== X-Forwarded-Encrypted: i=1; AJvYcCURauPvQKhvYlUphZeACh3/FcFufODzWO1KpYDPbbJh2Z6JjyLBxaNg05c4V1tTLQggH98N4HSMzja9iXkEHqWlwNZZ4fsJzFiYp1CJzym1 X-Gm-Message-State: AOJu0Yw3RBWm2gzdYQbX67X3ggO8Qz1Y4PfARv3pbao8vOek0PzHECft yszKGH67xwzXco9nHyittgbwghQ1ZibXnPLH+5/EsQI9OGLc5881 X-Google-Smtp-Source: AGHT+IHLXkMedbpCr6hlAG1DdMuIvHHufBsDrmGhHYgCZ8y3pi5ipgfYN1AcQBwWX1VrGZkNd/p4RA== X-Received: by 2002:a05:600c:450d:b0:428:6f4:57ff with SMTP id 5b1f17b1804b1-429d48952demr21162335e9.35.1723546318022; Tue, 13 Aug 2024 03:51:58 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:57 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 16/17] drm/vkms: Allow to configure the default device creation Date: Tue, 13 Aug 2024 12:44:27 +0200 Message-ID: <20240813105134.17439-17-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Add a new module param to allow to create or not the default VKMS instance. Useful when combined with configfs to avoid having additional VKMS instances. Signed-off-by: José Expósito --- drivers/gpu/drm/vkms/vkms_drv.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index f524a9550017..248cb7166256 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -50,6 +50,10 @@ static bool enable_overlay; module_param_named(enable_overlay, enable_overlay, bool, 0444); MODULE_PARM_DESC(enable_overlay, "Enable/Disable overlay support"); +static bool create_default_dev = true; +module_param_named(create_default_dev, create_default_dev, bool, 0444); +MODULE_PARM_DESC(create_default_dev, "Create or not the default VKMS device"); + DEFINE_DRM_GEM_FOPS(vkms_driver_fops); static void vkms_release(struct drm_device *dev) @@ -230,9 +234,11 @@ static int __init vkms_init(void) default_config = config; - ret = vkms_create(config); - if (ret) - goto err_kfree; + if (create_default_dev) { + ret = vkms_create(config); + if (ret) + goto err_kfree; + } ret = vkms_configfs_register(); if (ret) From patchwork Tue Aug 13 10:44:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 13761790 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 B726AC52D7C for ; Tue, 13 Aug 2024 10:52:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F58B10E2FC; Tue, 13 Aug 2024 10:52:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lHJxoQ7a"; dkim-atps=neutral Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01C9E10E2F8 for ; Tue, 13 Aug 2024 10:52:01 +0000 (UTC) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4281faefea9so39558605e9.2 for ; Tue, 13 Aug 2024 03:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723546319; x=1724151119; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZftJBc7W5kwvvNABWDGPxvru4sevjwR+IU4HN2kbDT8=; b=lHJxoQ7aLXhBKEMBOHtBy+I1CW01q/P2g5JJ16V+WU5RJbtPMYe5maGsJWJexyTao0 V8t1yLP/YQAppdIUYViJNPC8+uKtu4ZgobfYuEFAMo6yFwqryk4NRBEenwkCz96xChXS syb/yxT2CUclV2/bOzCg+GWenNfY9e9j5YtKR5zxXha6PboRFMuJu/yJIycVcEq+sie6 CTfED+Vmn6PU4JGN5xUG30gq1leimoTVot5ETYtobi9+ijKaRb/olfKSOs7mDtcrJkIX +0z84kkufvI29lP/zFl9cawoosgx2LeI5DVM7+z0eLbu2diimMGyabjS3CdGaPWWkKmp eZrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723546319; x=1724151119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZftJBc7W5kwvvNABWDGPxvru4sevjwR+IU4HN2kbDT8=; b=ItHv+3+SR0RtrDxayiNREI1b0VueXYVfk+fjfQAtv1gpl1WNDWuLYajYcbZyafDXMj 4kZBRobl+u4+YCcCk9e9tk8E1qjXDuAHfGabIPjMIemypU3wOJjhb8gfDY0L3G1bgK4H 2PNMq748+w429z/UwX0fVNIkGHO97EvHJRwHb5KLw/1gjXiGmEkgbK/DDhpnPpx4cvQp ZD9ee3n5J/92Xi/3nv0DPjwz1N5HjMLipoo6YCALB2vj+eHOv1ed/sFl+/DAsDSixTq2 Hg588t/Y2/3A0P1v521RE6KzaD98cTzOZocuSZGSmNbbsVCp1bIk5eNGpxQr6Qjv8asj iIxA== X-Forwarded-Encrypted: i=1; AJvYcCUaM3qeGGdN0bz/ct07aAxjU8nel10hT2ZGVKNOPk97IwBUpcHUQNVFWZdNfqnBqWA/bcdhD01Og3UTeRruEEdD5W9rBR+q7m+6X85ow3sV X-Gm-Message-State: AOJu0YxckIs8rFaoH1TcTXGmtbWm+yweYngboRrL/XBh4OiV//PmF9St 6NtUv8/RhGOnIRZkEYaPrak8izCaiQubBVHd5YSO8ttq1Q6T5TPI X-Google-Smtp-Source: AGHT+IGmYYsdBOSQGdHs8roYpDqyGK4MJTVsNTujjltjUQNx3CKHicYkYjxIfPWC0fDyWxdLgRP2XA== X-Received: by 2002:a05:600c:4453:b0:428:f1b4:3473 with SMTP id 5b1f17b1804b1-429d486e85fmr22635355e9.26.1723546319268; Tue, 13 Aug 2024 03:51:59 -0700 (PDT) Received: from fedora.. ([213.94.26.172]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d877e066sm17290785e9.1.2024.08.13.03.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:51:58 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: rodrigosiqueiramelo@gmail.com Cc: melissa.srw@gmail.com, mairacanal@riseup.net, hamohammed.sa@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, louis.chauvet@bootlin.com, =?utf-8?b?Sm9zw6kg?= =?utf-8?b?RXhww7NzaXRv?= Subject: [RFC PATCH 17/17] drm/vkms: Remove completed task from the TODO list Date: Tue, 13 Aug 2024 12:44:28 +0200 Message-ID: <20240813105134.17439-18-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240813105134.17439-1-jose.exposito89@gmail.com> References: <20240813105134.17439-1-jose.exposito89@gmail.com> MIME-Version: 1.0 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" Remove the configfs related TODO items from the "Runtime Configuration" section. Signed-off-by: José Expósito --- Documentation/gpu/vkms.rst | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index ee71d1a569dd..a8c187f6c0af 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -229,19 +229,12 @@ Runtime Configuration We want to be able to reconfigure vkms instance without having to reload the module. Use/Test-cases: -- Hotplug/hotremove connectors on the fly (to be able to test DP MST handling - of compositors). - -- Configure planes/crtcs/connectors (we'd need some code to have more than 1 of - them first). +- Hotremove connectors on the fly (to be able to test DP MST handling of + compositors). - Change output configuration: Plug/unplug screens, change EDID, allow changing the refresh rate. -The currently proposed solution is to expose vkms configuration through -configfs. All existing module options should be supported through configfs -too. - Writeback support -----------------