mirror of https://lore.kernel.org/lkml/
 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, 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,
	"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH RFC 1/4] drm/vkms: Switch to managed for connector
Date: Tue, 20 Aug 2024 11:09:11 +0200	[thread overview]
Message-ID: <20240820090912.2854-1-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20240814-google-vkms-managed-v1-1-7ab8b8921103@bootlin.com>

Hi Louis,

Thanks for these patches. Easy review as my configfs series included similar
patches :) I think that this series could be easily rebased on drm-misc-next,
but I don't know if that'd add a lot of work rebasing other series. I'd be nice
to get these 4 merged.

> The current VKMS driver uses non-managed function to create connectors. It
> is not an issue yet, but in order to support multiple devices easily,
> convert this code to use drm and device managed helpers.
> 
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>

Reviewed-by: José Expósito <jose.exposito89@gmail.com>

> ---
>  drivers/gpu/drm/vkms/vkms_drv.h    |  1 -
>  drivers/gpu/drm/vkms/vkms_output.c | 22 ++++++++++------------
>  2 files changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> index f74a5c2045f9..cea7b2640c5d 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.h
> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> @@ -43,7 +43,6 @@
>  struct vkms_output {
>  	struct drm_crtc crtc;
>  	struct drm_encoder encoder;
> -	struct drm_connector connector;
>  	struct drm_writeback_connector wb_connector;
>  	struct hrtimer vblank_hrtimer;
>  	ktime_t period_ns;
> diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
> index 20073a00b200..4767838c3a73 100644
> --- a/drivers/gpu/drm/vkms/vkms_output.c
> +++ b/drivers/gpu/drm/vkms/vkms_output.c
> @@ -3,6 +3,7 @@
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_edid.h>
>  #include <drm/drm_probe_helper.h>
> +#include <drm/drm_managed.h>

Nit: Keep includes sorted alphabetically if possible

>  
>  #include "vkms_writeback.h"
>  #include "vkms_plane.h"
> @@ -10,7 +11,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,
> @@ -54,7 +54,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int possible_crtc_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 = &output->encoder;
>  	struct drm_crtc *crtc = &output->crtc;
>  	struct vkms_plane *primary, *cursor = NULL;
> @@ -90,11 +90,15 @@ int vkms_output_init(struct vkms_device *vkmsdev, int possible_crtc_index)
>  	if (ret)
>  		return ret;
>  
> -	ret = drm_connector_init(dev, connector, &vkms_connector_funcs,
> -				 DRM_MODE_CONNECTOR_VIRTUAL);
> +	connector = drmm_kzalloc(&vkmsdev->drm, sizeof(*connector), GFP_KERNEL);

"&vkmsdev->drm" can be replaced with "dev".

> +	if (!connector)

For consistency with the init function, it'd be nice to log this error as well:

		DRM_ERROR("Failed to allocate connector\n");

> +		return -ENOMEM;
> +
> +	ret = drmm_connector_init(dev, connector, &vkms_connector_funcs,
> +				  DRM_MODE_CONNECTOR_VIRTUAL, NULL);
>  	if (ret) {
>  		DRM_ERROR("Failed to init connector\n");
> -		goto err_connector;
> +		return ret;
>  	}
>  
>  	drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
> @@ -103,7 +107,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int possible_crtc_index)
>  			       DRM_MODE_ENCODER_VIRTUAL, NULL);
>  	if (ret) {
>  		DRM_ERROR("Failed to init encoder\n");
> -		goto err_encoder;
> +		return ret;
>  	}
>  	/*
>  	 * This is an hardcoded value to select crtc for the encoder.
> @@ -130,11 +134,5 @@ int vkms_output_init(struct vkms_device *vkmsdev, int possible_crtc_index)
>  err_attach:
>  	drm_encoder_cleanup(encoder);
>  
> -err_encoder:
> -	drm_connector_cleanup(connector);
> -
> -err_connector:
> -	drm_crtc_cleanup(crtc);
> -

I think that, technically, err_encoder should call drm_crtc_cleanup() in this
patch. However, since a future patch will remove this code I don't find it that
relevant.

>  	return ret;
>  }

  reply	other threads:[~2024-08-20  9:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 10:06 [PATCH RFC 0/4] drm/vkms: Switch all vkms object to DRM managed objects Louis Chauvet
2024-08-14 10:06 ` [PATCH RFC 1/4] drm/vkms: Switch to managed for connector Louis Chauvet
2024-08-20  9:09   ` José Expósito [this message]
2024-08-20 10:03     ` Maíra Canal
2024-08-26 16:24     ` Louis Chauvet
2024-08-14 10:06 ` [PATCH RFC 2/4] drm/vkms: Switch to managed for encoder Louis Chauvet
2024-08-20  9:09   ` José Expósito
2024-08-26 16:24     ` Louis Chauvet
2024-08-14 10:06 ` [PATCH RFC 3/4] drm/vkms: Switch to managed for crtc Louis Chauvet
2024-08-20  9:09   ` José Expósito
2024-08-26 16:24     ` Louis Chauvet
2024-08-14 10:06 ` [PATCH RFC 4/4] drm/vkms: Rename all vkms_crtc instance to be consistent Louis Chauvet
2024-08-20  9:10   ` [PATCH RFC 4/4] drm/vkms: Rename all vkms_crtc instance to be José Expósito

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=20240820090912.2854-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

all inboxes | Powered by JetHome®