All of lore.kernel.org
 help / color / mirror / Atom feed
From: "José Expósito" <jose.exposito89@gmail.com>
To: Louis Chauvet <louis.chauvet@bootlin.com>
Cc: hamohammed.sa@gmail.com, simona@ffwll.ch, melissa.srw@gmail.com,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@gmail.com,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 08/13] drm/vkms: Allow to configure multiple CRTCs
Date: Tue, 11 Feb 2025 11:44:37 +0100	[thread overview]
Message-ID: <Z6sqFdvtwSxHD-FO@fedora> (raw)
In-Reply-To: <Z5uDJFHnn1HzWOz4@louis-chauvet-laptop>

On Thu, Jan 30, 2025 at 02:48:20PM +0100, Louis Chauvet wrote:
> On 29/01/25 - 12:00, José Expósito wrote:
> > Add a list of CRTCs to vkms_config and helper functions to add and
> > remove as many CRTCs as wanted.
> > 
> > For backwards compatibility, add one CRTC to the default configuration.
> > 
> > A future patch will allow to attach planes and CRTCs, but for the
> > moment there are no changes in the way the output is configured.
> > 
> > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> > Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> 
> Co-developped-by: Louis Chauvet <louis.chauvet@bootlin.com>
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> 
> [...]
> 
> > diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
> 
> [...]
> 
> > +static void vkms_config_test_valid_crtc_number(struct kunit *test)
> > +{
> > +	struct vkms_config *config;
> > +	struct vkms_config_crtc *crtc_cfg;
> > +	int n;
> > +
> > +	config = vkms_config_default_create(false, false, false);
> > +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
> > +
> > +	/* Invalid: No CRTCs */
> > +	crtc_cfg = list_first_entry(&config->crtcs, typeof(*crtc_cfg), link);
> > +	vkms_config_destroy_crtc(config, crtc_cfg);
> > +	KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
> > +
> > +	/* Invalid: Too many CRTCs */
> > +	for (n = 0; n <= 32; n++)
> > +		vkms_config_add_crtc(config);
> > +
> > +	KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
> > +
> > +	vkms_config_destroy(config);
> > +}
> 
> Same as before, can you rename the fonction to 
> vkms_config_test_invalid_crtc_number
> 
> [...]
> 
> > diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> 
> [...]
> 
> > +struct vkms_config_crtc **vkms_config_get_crtcs(const struct vkms_config *config,
> > +						size_t *out_length)
> > +{
> > +	struct vkms_config_crtc **array;
> > +	struct vkms_config_crtc *crtc_cfg;
> > +	size_t length;
> > +	int n = 0;
> > +
> > +	length = list_count_nodes((struct list_head *)&config->crtcs);
> > +	if (length == 0) {
> > +		*out_length = length;
> > +		return NULL;
> > +	}
> > +
> > +	array = kmalloc_array(length, sizeof(*array), GFP_KERNEL);
> > +	if (!array)
> > +		return ERR_PTR(-ENOMEM);
> > +
> > +	list_for_each_entry(crtc_cfg, &config->crtcs, link) {
> > +		array[n] = crtc_cfg;
> > +		n++;
> > +	}
> > +
> > +	*out_length = length;
> > +	return array;
> > +}
> 
> Same as before, can't we use an iterator?
> 
> [...]
> 
> > +static bool valid_crtc_number(struct vkms_config *config)
> > +{
> > +	size_t n_crtcs;
> > +
> > +	n_crtcs = list_count_nodes(&config->crtcs);
> > +	if (n_crtcs <= 0 || n_crtcs >= 32) {
> > +		pr_err("The number of CRTCs must be between 1 and 31\n");
> 
> I agree we need some logs, but I think pr_err is too agressive (i.e may 
> be considered as an error by some test tools).
> 
> I think we should at least:
> - lower to warn/notice/info
> - use drm variants of the macro
> 
> > +		return false;
> > +	}
> > +
> > +	return true;
> > +}
> > +
> 
> [...]
> 
> > +struct vkms_config_crtc *vkms_config_add_crtc(struct vkms_config *config)
> > +{
> > +	struct vkms_config_crtc *crtc_cfg;
> > +
> > +	crtc_cfg = kzalloc(sizeof(*crtc_cfg), GFP_KERNEL);
> > +	if (!crtc_cfg)
> > +		return ERR_PTR(-ENOMEM);
> > +
> > +	vkms_config_crtc_set_writeback(crtc_cfg, false);
> > +
> > +	list_add_tail(&crtc_cfg->link, &config->crtcs);
> > +
> > +	return crtc_cfg;
> > +}
> > +
> > +void vkms_config_destroy_crtc(struct vkms_config *config,
> > +			      struct vkms_config_crtc *crtc_cfg)
> > +{
> > +	list_del(&crtc_cfg->link);
> > +	kfree(crtc_cfg);
> > +}
> 
> Same as before, the pair add/destroy seems strange.
> 
> > +++ b/drivers/gpu/drm/vkms/vkms_drv.c
> > @@ -181,7 +181,8 @@ 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,
> > +			      vkms_config_get_num_crtcs(config));
> 
> At this point we only create one crtc, can you move this change in the 
> commit where you create multiple crtc?

Since the code to add more than one CRTCs is unused but technically present, I
think that this is the right patch to use this function.

Anyway, at the moment it'll always return 1, so it is a no-op.

I didn't change it in v2, let me know if it works for you.

Thanks,
Jose

> >  	if (ret) {
> >  		DRM_ERROR("Failed to vblank\n");
> >  		goto out_devres;
> > -- 
> > 2.48.1
> > 

  reply	other threads:[~2025-02-11 10:44 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-29 11:00 [PATCH 00/13] drm/vkms: Allow to configure device José Expósito
2025-01-29 11:00 ` [PATCH 01/13] drm/vkms: Extract vkms_connector header José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-02-11 10:37     ` José Expósito
2025-01-29 11:00 ` [PATCH 02/13] drm/vkms: Add KUnit test scaffolding José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-01-29 11:00 ` [PATCH 03/13] drm/vkms: Extract vkms_config header José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-02-11 10:39     ` José Expósito
2025-01-29 11:00 ` [PATCH 04/13] drm/vkms: Move default_config creation to its own function José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-01-29 11:00 ` [PATCH 05/13] drm/vkms: Set device name from vkms_config José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-01-29 11:00 ` [PATCH 06/13] drm/vkms: Add a validation function for VKMS configuration José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-01-29 11:00 ` [PATCH 07/13] drm/vkms: Allow to configure multiple planes José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-02-11 10:43     ` José Expósito
2025-02-12 14:10       ` Louis Chauvet
2025-01-29 11:00 ` [PATCH 08/13] drm/vkms: Allow to configure multiple CRTCs José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-02-11 10:44     ` José Expósito [this message]
2025-02-12 14:12       ` Louis Chauvet
2025-02-13 15:26         ` José Expósito
2025-01-29 11:00 ` [PATCH 09/13] drm/vkms: Allow to attach planes and CRTCs José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-02-11 10:47     ` José Expósito
2025-02-12 14:10       ` Louis Chauvet
2025-02-13 15:32         ` José Expósito
2025-01-29 11:00 ` [PATCH 10/13] drm/vkms: Allow to configure multiple encoders José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-01-29 11:00 ` [PATCH 11/13] drm/vkms: Allow to attach encoders and CRTCs José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-01-29 11:00 ` [PATCH 12/13] drm/vkms: Allow to configure multiple connectors José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-01-29 11:00 ` [PATCH 13/13] drm/vkms: Allow to attach connectors and encoders José Expósito
2025-01-30 13:48   ` Louis Chauvet
2025-01-30 13:48 ` [PATCH 00/13] drm/vkms: Allow to configure device Louis Chauvet
2025-01-31  9:31   ` José Expósito
2025-01-31 13:02     ` Louis Chauvet
2025-01-31 17:13       ` 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=Z6sqFdvtwSxHD-FO@fedora \
    --to=jose.exposito89@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.chauvet@bootlin.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=melissa.srw@gmail.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.