lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zrue4VV8DCTBnH4F@louis-chauvet-laptop>
Date: Tue, 13 Aug 2024 19:58:57 +0200
From: Louis Chauvet <louis.chauvet@...tlin.com>
To: José Expósito <jose.exposito89@...il.com>
Cc: rodrigosiqueiramelo@...il.com, melissa.srw@...il.com,
	mairacanal@...eup.net, hamohammed.sa@...il.com, daniel@...ll.ch,
	maarten.lankhorst@...ux.intel.com, mripard@...nel.org,
	tzimmermann@...e.de, airlied@...il.com,
	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 07/17] drm/vkms: Use managed memory to create
 connectors

Le 13/08/24 - 12:44, José Expósito a écrit :
> 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 <jose.exposito89@...il.com>
> ---
>  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);

Again, connector is allocated with drmm_kzalloc, so drmm_kfree or nothing.

> +		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));

As for CRTC, you can create multiple encoder but connector is always 
attached to the first? I assume this is intentionnal? Maybe you can attach 
it to all the created encoders?

> +	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;
> -	}
> -

The encoder is not attached to the connector?

>  	drm_mode_config_reset(dev);
>  
>  	return 0;
> -
> -err_attach:
> -	drm_connector_cleanup(connector);
> -
> -	return ret;
>  }
> -- 
> 2.46.0
> 

-- 
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ