public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "José Expósito" <jose.exposito89@gmail.com>
To: louis.chauvet@bootlin.com
Cc: airlied@gmail.com, arthurgrillo@riseup.net, daniel@ffwll.ch,
	dri-devel@lists.freedesktop.org, hamohammed.sa@gmail.com,
	jeremie.dautheribes@bootlin.com, jose.exposito89@gmail.com,
	linux-kernel@vger.kernel.org, maarten.lankhorst@linux.intel.com,
	mairacanal@riseup.net, melissa.srw@gmail.com,
	miquel.raynal@bootlin.com, mripard@kernel.org,
	nicolejadeyee@google.com, rodrigosiqueiramelo@gmail.com,
	seanpaul@google.com, thomas.petazzoni@bootlin.com,
	tzimmermann@suse.de
Subject: [PATCH RFC 03/15] drm/vkms: Extract vkms_config header
Date: Thu,  5 Sep 2024 14:33:36 +0200	[thread overview]
Message-ID: <20240905123338.3061-1-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20240814-google-remove-crtc-index-from-parameter-v1-3-6e179abf9fd4@bootlin.com>

> Creating a new vkms_config structure will be more complex once we
> start adding more options.
> 
> Extract the vkms_config structure to its own header and source files
> and add functions to create and delete a vkms_config and to initialize
> debugfs.
> 
> Refactor, no functional changes.
> 
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> [Changes: Cherry picked and conflict solve]
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> ---
>  drivers/gpu/drm/vkms/Makefile      |  3 ++-
>  drivers/gpu/drm/vkms/vkms_config.c | 45 ++++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/vkms/vkms_config.h | 32 +++++++++++++++++++++++++++
>  drivers/gpu/drm/vkms/vkms_drv.c    | 41 ++++++++++------------------------
>  drivers/gpu/drm/vkms/vkms_drv.h    | 15 +------------
>  5 files changed, 91 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile
> index 8d3e46dde635..2b6db5870b97 100644
> --- a/drivers/gpu/drm/vkms/Makefile
> +++ b/drivers/gpu/drm/vkms/Makefile
> @@ -6,7 +6,8 @@ vkms-y := \
>  	vkms_formats.o \
>  	vkms_crtc.o \
>  	vkms_composer.o \
> -	vkms_writeback.o
> +	vkms_writeback.o \
> +	vkms_config.o
>  
>  obj-$(CONFIG_DRM_VKMS) += vkms.o
>  obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += tests/
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> new file mode 100644
> index 000000000000..ad5d814e6e83
> --- /dev/null
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
> @@ -0,0 +1,45 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +#include <drm/drm_debugfs.h>
> +
> +#include "vkms_config.h"
> +#include "vkms_drv.h"

I believe there are some missing includes. In the patch of my
configfs series equivalent to this one I have:


#include <linux/slab.h>

#include <drm/drm_print.h>
#include <drm/drm_debugfs.h>

#include "vkms_config.h"
#include "vkms_drv.h"

> +
> +struct vkms_config *vkms_config_create(void)
> +{
> +	struct vkms_config *config;
> +
> +	config = kzalloc(sizeof(*config), GFP_KERNEL);
> +	if (!config)
> +		return ERR_PTR(-ENOMEM);
> +
> +	return config;
> +}
> +
> +void vkms_config_destroy(struct vkms_config *config)
> +{
> +	kfree(config);
> +}
> +
> +static int vkms_config_show(struct seq_file *m, void *data)
> +{
> +	struct drm_debugfs_entry *entry = m->private;
> +	struct drm_device *dev = entry->dev;
> +	struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
> +
> +	seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback);
> +	seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor);
> +	seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay);
> +
> +	return 0;
> +}
> +
> +static const struct drm_debugfs_info vkms_config_debugfs_list[] = {
> +	{ "vkms_config", vkms_config_show, 0 },
> +};
> +
> +void vkms_config_register_debugfs(struct vkms_device *vkms_device)
> +{
> +	drm_debugfs_add_files(&vkms_device->drm, vkms_config_debugfs_list,
> +			      ARRAY_SIZE(vkms_config_debugfs_list));
> +}
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> new file mode 100644
> index 000000000000..b28483173874
> --- /dev/null
> +++ b/drivers/gpu/drm/vkms/vkms_config.h
> @@ -0,0 +1,32 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +
> +#ifndef _VKMS_CONFIG_H
> +#define _VKMS_CONFIG_H

#ifndef _VKMS_CONFIG_H_
#define _VKMS_CONFIG_H_

> +
> +#include <linux/types.h>
> +#include "vkms_drv.h"

You can avoid this import by forward declaring "vkms_device":

struct vkms_device;

> +
> +/**
> + * struct vkms_config - General configuration for VKMS driver
> + *
> + * @writeback: If true, a writeback buffer can be attached to the CRTC
> + * @cursor: If true, a cursor plane is created in the VKMS device
> + * @overlay: If true, NUM_OVERLAY_PLANES will be created for the VKMS device
> + * @dev: Used to store the current vkms device. Only set when the device is instancied.
> + */
> +struct vkms_config {
> +	bool writeback;
> +	bool cursor;
> +	bool overlay;
> +	struct vkms_device *dev;
> +};
> +
> +/**
> + * vkms_config_register_debugfs() - Register the debugfs file to display current configuration
> + */
> +void vkms_config_register_debugfs(struct vkms_device *vkms_device);
> +
> +struct vkms_config *vkms_config_create(void);
> +void vkms_config_destroy(struct vkms_config *config);
> +
> +#endif //_VKMS_CONFIG_H

#endif /* _VKMS_CONFIG_H_ */

> diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
> index e71b45fcb9b8..dbdb1f565a8f 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.c
> +++ b/drivers/gpu/drm/vkms/vkms_drv.c
> @@ -28,6 +28,7 @@
>  
>  #include "vkms_drv.h"
>  #include "vkms_crtc.h"
> +#include "vkms_config.h"
>  
>  #include <drm/drm_print.h>
>  #include <drm/drm_debugfs.h>

And here you can drop:

#include <drm/drm_print.h>
#include <drm/drm_debugfs.h>

> @@ -85,22 +86,6 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state)
>  	drm_atomic_helper_cleanup_planes(dev, old_state);
>  }
>  
> -static int vkms_config_show(struct seq_file *m, void *data)
> -{
> -	struct drm_debugfs_entry *entry = m->private;
> -	struct drm_device *dev = entry->dev;
> -	struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
> -
> -	seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback);
> -	seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor);
> -	seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay);
> -
> -	return 0;
> -}
> -
> -static const struct drm_debugfs_info vkms_config_debugfs_list[] = {
> -	{ "vkms_config", vkms_config_show, 0 },
> -};
>  
>  static const struct drm_driver vkms_driver = {
>  	.driver_features	= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM,
> @@ -325,8 +310,7 @@ static int vkms_create(struct vkms_config *config)
>  	if (ret)
>  		goto out_unregister;
>  
> -	drm_debugfs_add_files(&vkms_device->drm, vkms_config_debugfs_list,
> -			      ARRAY_SIZE(vkms_config_debugfs_list));
> +	vkms_config_register_debugfs(vkms_device);
>  
>  	ret = drm_dev_register(&vkms_device->drm, 0);
>  	if (ret)
> @@ -344,21 +328,18 @@ static int vkms_create(struct vkms_config *config)
>  static int __init vkms_init(void)
>  {
>  	int ret;
> -	struct vkms_config *config;
> -
> -	config = kmalloc(sizeof(*config), GFP_KERNEL);
> -	if (!config)
> -		return -ENOMEM;
>  
> -	default_config = config;
> +	default_config = vkms_config_create();
> +	if (IS_ERR(default_config))
> +		return PTR_ERR(default_config);
>  
> -	config->cursor = enable_cursor;
> -	config->writeback = enable_writeback;
> -	config->overlay = enable_overlay;
> +	default_config->cursor = enable_cursor;
> +	default_config->writeback = enable_writeback;
> +	default_config->overlay = enable_overlay;
>  
> -	ret = vkms_create(config);
> +	ret = vkms_create(default_config);
>  	if (ret)
> -		kfree(config);
> +		vkms_config_destroy(default_config);
>  
>  	return ret;
>  }
> @@ -386,7 +367,7 @@ static void __exit vkms_exit(void)
>  	if (default_config->dev)
>  		vkms_destroy(default_config);
>  
> -	kfree(default_config);
> +	vkms_config_destroy(default_config);
>  }
>  
>  module_init(vkms_init);
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> index 08d0ef106e37..64574695f655 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.h
> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> @@ -25,20 +25,7 @@
>  
>  #define VKMS_LUT_SIZE 256
>  
> -/**
> - * struct vkms_config - General configuration for VKMS driver
> - *
> - * @writeback: If true, a writeback buffer can be attached to the CRTC
> - * @cursor: If true, a cursor plane is created in the VKMS device
> - * @overlay: If true, NUM_OVERLAY_PLANES will be created for the VKMS device
> - * @dev: Used to store the current vkms device. Only set when the device is instancied.
> - */
> -struct vkms_config {
> -	bool writeback;
> -	bool cursor;
> -	bool overlay;
> -	struct vkms_device *dev;
> -};
> +struct vkms_config;
>  
>  /**
>   * struct vkms_device - Description of a vkms device
> 

  reply	other threads:[~2024-09-05 12:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 14:36 [PATCH RFC 00/15] drm/vkms: Introduce detailed configuration Louis Chauvet
2024-08-14 14:36 ` [PATCH RFC 01/15] drm/vkms: Remove useles devres group Louis Chauvet
2024-08-19 14:23   ` Daniel Vetter
2024-08-14 14:36 ` [PATCH RFC 02/15] drm/vkms: remove possible crtc from parameters Louis Chauvet
2024-09-05 12:33   ` José Expósito
2024-08-14 14:36 ` [PATCH RFC 03/15] drm/vkms: Extract vkms_config header Louis Chauvet
2024-09-05 12:33   ` José Expósito [this message]
2024-08-14 14:36 ` [PATCH RFC 04/15] drm/vkms: Add a validation function for vkms configuration Louis Chauvet
2024-09-05 12:33   ` José Expósito
2024-08-14 14:36 ` [PATCH RFC 05/15] drm/vkms: Move default_config creation to its own function Louis Chauvet
2024-08-14 14:36 ` [PATCH RFC 06/15] drm/vkms: Introduce plane configuration Louis Chauvet
2024-09-05 12:33   ` José Expósito
2024-08-14 14:36 ` [PATCH RFC 07/15] drm/vkms: Introduce plane name configuration Louis Chauvet
2024-09-05 12:34   ` José Expósito
2024-08-14 14:36 ` [PATCH RFC 08/15] drm/vkms: Introduce plane rotation configuration Louis Chauvet
2024-08-14 14:36 ` [PATCH RFC 09/15] drm/vkms: Introduce configuration for plane color encoding Louis Chauvet
2024-08-14 14:36 ` [PATCH RFC 10/15] drm/vkms: Introduce configuration for plane color range Louis Chauvet
2024-08-14 14:36 ` [PATCH RFC 11/15] drm: writeback: Add drm_writeback_connector cleanup Louis Chauvet
2024-08-27 14:33   ` Maxime Ripard
2024-08-27 15:42     ` Louis Chauvet
2024-08-28  8:35       ` Jani Nikula
2024-08-28  9:07         ` Louis Chauvet
2024-08-28 15:17           ` Maxime Ripard
2024-08-14 14:36 ` [PATCH RFC 12/15] drm/vkms: Add configuration for CRTCs and encoders Louis Chauvet
2024-09-05 12:34   ` José Expósito
2024-08-14 14:36 ` [PATCH RFC 13/15] drm/vkms: Add name configuration for encoders Louis Chauvet
2024-08-14 14:36 ` [PATCH RFC 14/15] drm/vkms: Add name configuration for CRTCs Louis Chauvet
2024-08-14 14:36 ` [PATCH RFC 15/15] drm/vkms: Add test for config structure Louis Chauvet

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20240905123338.3061-1-jose.exposito89@gmail.com \
    --to=jose.exposito89@gmail.com \
    --cc=airlied@gmail.com \
    --cc=arthurgrillo@riseup.net \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=jeremie.dautheribes@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.chauvet@bootlin.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mairacanal@riseup.net \
    --cc=melissa.srw@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mripard@kernel.org \
    --cc=nicolejadeyee@google.com \
    --cc=rodrigosiqueiramelo@gmail.com \
    --cc=seanpaul@google.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

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

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