The Linux Kernel Mailing List
 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 v2 08/15] drm/vkms: Add a validation function for VKMS configuration
Date: Fri, 14 Feb 2025 16:53:11 +0100	[thread overview]
Message-ID: <Z69m50L8NzcYt45j@fedora> (raw)
In-Reply-To: <Z6362KrzjLUL6Mj6@louis-chauvet-laptop>

On Thu, Feb 13, 2025 at 02:59:52PM +0100, Louis Chauvet wrote:
> On 11/02/25 - 12:09, José Expósito wrote:
> > From: Louis Chauvet <louis.chauvet@bootlin.com>
> > 
> > As the configuration will be used by userspace, add a validator to avoid
> > creating a broken DRM device.
> > 
> > For the moment, the function always returns true, but rules will be
> > added in future patches.
> > 
> > Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
> > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> > Co-developed-by: José Expósito <jose.exposito89@gmail.com>
> > Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> 
> The compilation is broken when building as module:
> 
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index b9267aef4804..82335006c94a 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
> @@ -55,6 +55,7 @@ bool vkms_config_is_valid(struct vkms_config *config)
>  {
>         return true;
>  }
> +EXPORT_SYMBOL_IF_KUNIT(vkms_config_is_valid);

Fixed the issue in all patches, thanks!
 
> > [...]
> > 
> > diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> > index fcaa909fb2e0..0376dceaf6be 100644
> > --- a/drivers/gpu/drm/vkms/vkms_config.h
> > +++ b/drivers/gpu/drm/vkms/vkms_config.h
> > @@ -67,6 +67,16 @@ vkms_config_get_device_name(struct vkms_config *config)
> >  	return config->dev_name;
> >  }
> >  
> > +/**
> > + * vkms_config_is_valid() - Validate a configuration
> > + * @config: Configuration to validate
> > + *
> > + * Returns:
> > + * Whether the configuration is valid or not.
> > + * For example, a configuration without primary planes is not valid.
> > + */
> > +bool vkms_config_is_valid(struct vkms_config *config);
> > +
> 
> I think here we can take a const pointer.
> 
> >  /**
> >   * vkms_config_register_debugfs() - Register a debugfs file to show the device's
> >   * configuration
> > diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> > index a74a7fc3a056..95afc39ce985 100644
> > --- a/drivers/gpu/drm/vkms/vkms_drv.h
> > +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> > @@ -204,7 +204,7 @@ struct vkms_config;
> >  struct vkms_device {
> >  	struct drm_device drm;
> >  	struct platform_device *platform;
> > -	const struct vkms_config *config;
> > +	struct vkms_config *config;
> 
> So we can keep a const pointer here (for me the device should never modify 
> vkms_config)

I tryed keeping the const pointer, but, since list_count_nodes() is used in
several valid_* functions and it takes a non-const pointer, it causes
warnings.

We can fix them with a cast:

  n_planes = list_count_nodes((struct list_head *)&config->planes);

But I feel that keeping the "const" creates more issues than it solves.

Anyway, if you prefer this pointer to be const, I will change it in v3.

Jose
 
> >  };
> >  
> >  /*
> > diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
> > index 068a7f87ecec..414cc933af41 100644
> > --- a/drivers/gpu/drm/vkms/vkms_output.c
> > +++ b/drivers/gpu/drm/vkms/vkms_output.c
> > @@ -16,6 +16,9 @@ int vkms_output_init(struct vkms_device *vkmsdev)
> >  	int writeback;
> >  	unsigned int n;
> >  
> > +	if (!vkms_config_is_valid(vkmsdev->config))
> > +		return -EINVAL;
> > +
> >  	/*
> >  	 * Initialize used plane. One primary plane is required to perform the composition.
> >  	 *
> > -- 
> > 2.48.1
> > 

  reply	other threads:[~2025-02-14 15:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11 11:08 [PATCH v2 00/15] drm/vkms: Allow to configure device José Expósito
2025-02-11 11:08 ` [PATCH v2 01/15] drm/vkms: Fix use after free and double free on init error José Expósito
2025-02-11 14:33   ` Thomas Zimmermann
2025-02-12  8:52     ` José Expósito
2025-02-11 11:08 ` [PATCH v2 02/15] drm/vkms: Extract vkms_connector header José Expósito
2025-02-11 11:09 ` [PATCH v2 03/15] drm/vkms: Create vkms_connector struct José Expósito
2025-02-11 11:09 ` [PATCH v2 04/15] drm/vkms: Add KUnit test scaffolding José Expósito
2025-02-13 13:59   ` Louis Chauvet
2025-02-11 11:09 ` [PATCH v2 05/15] drm/vkms: Extract vkms_config header José Expósito
2025-02-13 13:59   ` Louis Chauvet
2025-02-13 15:36     ` José Expósito
2025-02-14 17:03       ` Louis Chauvet
2025-02-11 11:09 ` [PATCH v2 06/15] drm/vkms: Move default_config creation to its own function José Expósito
2025-02-13 13:59   ` Louis Chauvet
2025-02-11 11:09 ` [PATCH v2 07/15] drm/vkms: Set device name from vkms_config José Expósito
2025-02-11 11:09 ` [PATCH v2 08/15] drm/vkms: Add a validation function for VKMS configuration José Expósito
2025-02-13 13:59   ` Louis Chauvet
2025-02-14 15:53     ` José Expósito [this message]
2025-02-14 18:20       ` Louis Chauvet
2025-02-11 11:09 ` [PATCH v2 09/15] drm/vkms: Allow to configure multiple planes José Expósito
2025-02-13 13:59   ` Louis Chauvet
2025-02-11 11:09 ` [PATCH v2 10/15] drm/vkms: Allow to configure multiple CRTCs José Expósito
2025-02-13 13:59   ` Louis Chauvet
2025-02-11 11:09 ` [PATCH v2 11/15] drm/vkms: Allow to attach planes and CRTCs José Expósito
2025-02-11 11:09 ` [PATCH v2 12/15] drm/vkms: Allow to configure multiple encoders José Expósito
2025-02-13 13:59   ` Louis Chauvet
2025-02-11 11:09 ` [PATCH v2 13/15] drm/vkms: Allow to attach encoders and CRTCs José Expósito
2025-02-13 13:59   ` Louis Chauvet
2025-02-11 11:09 ` [PATCH v2 14/15] drm/vkms: Allow to configure multiple connectors José Expósito
2025-02-13 13:59   ` Louis Chauvet
2025-02-11 11:09 ` [PATCH v2 15/15] drm/vkms: Allow to attach connectors and encoders José Expósito
2025-02-13 13:59   ` 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=Z69m50L8NzcYt45j@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox