[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d6cdfa19-688e-4169-ab30-d71335caee35@suse.de>
Date: Mon, 20 Oct 2025 16:24:29 +0200
From: Thomas Zimmermann <tzimmermann@...e.de>
To: Ruben Wauters <rubenru09@....com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] drm/gud: rearrange gud_probe() to prepare for function
splitting
Hi,
looks good.
Am 20.10.25 um 15:56 schrieb Ruben Wauters:
> gud_probe() is currently very large and does many things, including
> pipeline setup and feature detection, as well as having USB functions.
>
> This patch re-orders the code in gud_probe() to make it more organised
> and easier to split apart in the future.
>
> Signed-off-by: Ruben Wauters <rubenru09@....com>
Reviewed-by: Thomas Zimmermann <tzimmermann@...e.de>
If I'm not mistaken, you should by now have commit rights to the
drm-misc repo. Give it a few more days for others to review and if
nothing comes in, you're welcome to merge the patch into drm-misc-next.
Best regards
Thomas
> ---
> Changelog:
>
> v2
> - rename gud_get_properties to gud_plane_add_properties and move
> function call to proper location
> - move usb_set_intfdata and block with dma setup to just under gdrm init
> - add proper spacing for init comments
> ---
> drivers/gpu/drm/gud/gud_drv.c | 45 +++++++++++++++++++----------------
> 1 file changed, 24 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/gud/gud_drv.c b/drivers/gpu/drm/gud/gud_drv.c
> index b7345c8d823d..42135a48d92e 100644
> --- a/drivers/gpu/drm/gud/gud_drv.c
> +++ b/drivers/gpu/drm/gud/gud_drv.c
> @@ -249,7 +249,7 @@ int gud_usb_set_u8(struct gud_device *gdrm, u8 request, u8 val)
> return gud_usb_set(gdrm, request, 0, &val, sizeof(val));
> }
>
> -static int gud_get_properties(struct gud_device *gdrm)
> +static int gud_plane_add_properties(struct gud_device *gdrm)
> {
> struct gud_property_req *properties;
> unsigned int i, num_properties;
> @@ -463,10 +463,6 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
> return PTR_ERR(gdrm);
>
> drm = &gdrm->drm;
> - drm->mode_config.funcs = &gud_mode_config_funcs;
> - ret = drmm_mode_config_init(drm);
> - if (ret)
> - return ret;
>
> gdrm->flags = le32_to_cpu(desc.flags);
> gdrm->compression = desc.compression & GUD_COMPRESSION_LZ4;
> @@ -483,11 +479,28 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
> if (ret)
> return ret;
>
> + usb_set_intfdata(intf, gdrm);
> +
> + dma_dev = usb_intf_get_dma_device(intf);
> + if (dma_dev) {
> + drm_dev_set_dma_dev(drm, dma_dev);
> + put_device(dma_dev);
> + } else {
> + dev_warn(dev, "buffer sharing not supported"); /* not an error */
> + }
> +
> + /* Mode config init */
> + ret = drmm_mode_config_init(drm);
> + if (ret)
> + return ret;
> +
> drm->mode_config.min_width = le32_to_cpu(desc.min_width);
> drm->mode_config.max_width = le32_to_cpu(desc.max_width);
> drm->mode_config.min_height = le32_to_cpu(desc.min_height);
> drm->mode_config.max_height = le32_to_cpu(desc.max_height);
> + drm->mode_config.funcs = &gud_mode_config_funcs;
>
> + /* Format init */
> formats_dev = devm_kmalloc(dev, GUD_FORMATS_MAX_NUM, GFP_KERNEL);
> /* Add room for emulated XRGB8888 */
> formats = devm_kmalloc_array(dev, GUD_FORMATS_MAX_NUM + 1, sizeof(*formats), GFP_KERNEL);
> @@ -587,6 +600,7 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
> return -ENOMEM;
> }
>
> + /* Pipeline init */
> ret = drm_universal_plane_init(drm, &gdrm->plane, 0,
> &gud_plane_funcs,
> formats, num_formats,
> @@ -598,12 +612,9 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
> drm_plane_helper_add(&gdrm->plane, &gud_plane_helper_funcs);
> drm_plane_enable_fb_damage_clips(&gdrm->plane);
>
> - devm_kfree(dev, formats);
> - devm_kfree(dev, formats_dev);
> -
> - ret = gud_get_properties(gdrm);
> + ret = gud_plane_add_properties(gdrm);
> if (ret) {
> - dev_err(dev, "Failed to get properties (error=%d)\n", ret);
> + dev_err(dev, "Failed to add properties (error=%d)\n", ret);
> return ret;
> }
>
> @@ -621,16 +632,7 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
> }
>
> drm_mode_config_reset(drm);
> -
> - usb_set_intfdata(intf, gdrm);
> -
> - dma_dev = usb_intf_get_dma_device(intf);
> - if (dma_dev) {
> - drm_dev_set_dma_dev(drm, dma_dev);
> - put_device(dma_dev);
> - } else {
> - dev_warn(dev, "buffer sharing not supported"); /* not an error */
> - }
> + drm_kms_helper_poll_init(drm);
>
> drm_debugfs_add_file(drm, "stats", gud_stats_debugfs, NULL);
>
> @@ -638,7 +640,8 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
> if (ret)
> return ret;
>
> - drm_kms_helper_poll_init(drm);
> + devm_kfree(dev, formats);
> + devm_kfree(dev, formats_dev);
>
> drm_client_setup(drm, NULL);
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
Powered by blists - more mailing lists