Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
	rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com,
	ville.syrjala@linux.intel.com, imre.deak@intel.com,
	tejas.upadhyay@intel.com, jouni.hogander@intel.com,
	javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v6 1/7] drm/client: Do not acquire module reference
Date: Wed, 15 Nov 2023 14:07:17 +0100	[thread overview]
Message-ID: <2d3de6cf-45ca-44a0-a62b-251c012d5e51@suse.de> (raw)
In-Reply-To: <20231102131056.7256-2-tzimmermann@suse.de>


[-- Attachment #1.1: Type: text/plain, Size: 2970 bytes --]



Am 02.11.23 um 14:08 schrieb Thomas Zimmermann:
> Do not acquire a reference on the module that provides a client's
> callback functions in drm_client_init(). The additional reference
> prevents the user from unloading the callback functions' module and
> thus creating dangling pointers.
> 
> This is only necessary if there is no direct dependency between the
> caller of drm_client_init() and the provider of the callbacks in
> struct drm_client_funcs. If this case ever existed, it has been
> removed from the DRM code. Callers of drm_client_init() also provide
> the callback implementation. The lifetime of the clients is tied to
> the dependency chain's outer-most module, which is the hardware's
> DRM driver. Before client helpers could be unloaded, the driver module
> would have to be unloaded, which also unregisters all clients.
> 
> Driver modules that set up DRM clients can now be unloaded.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Acked-by: Javier Martinez Canillas <javierm@redhat.com>

I've added this patch to drm-misc-next.

> ---
>   drivers/gpu/drm/drm_client.c | 12 +-----------
>   1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
> index c3027115d0552..9403b3f576f7b 100644
> --- a/drivers/gpu/drm/drm_client.c
> +++ b/drivers/gpu/drm/drm_client.c
> @@ -5,7 +5,6 @@
>   
>   #include <linux/iosys-map.h>
>   #include <linux/list.h>
> -#include <linux/module.h>
>   #include <linux/mutex.h>
>   #include <linux/seq_file.h>
>   #include <linux/slab.h>
> @@ -84,16 +83,13 @@ int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,
>   	if (!drm_core_check_feature(dev, DRIVER_MODESET) || !dev->driver->dumb_create)
>   		return -EOPNOTSUPP;
>   
> -	if (funcs && !try_module_get(funcs->owner))
> -		return -ENODEV;
> -
>   	client->dev = dev;
>   	client->name = name;
>   	client->funcs = funcs;
>   
>   	ret = drm_client_modeset_create(client);
>   	if (ret)
> -		goto err_put_module;
> +		return ret;
>   
>   	ret = drm_client_open(client);
>   	if (ret)
> @@ -105,10 +101,6 @@ int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,
>   
>   err_free:
>   	drm_client_modeset_free(client);
> -err_put_module:
> -	if (funcs)
> -		module_put(funcs->owner);
> -
>   	return ret;
>   }
>   EXPORT_SYMBOL(drm_client_init);
> @@ -177,8 +169,6 @@ void drm_client_release(struct drm_client_dev *client)
>   	drm_client_modeset_free(client);
>   	drm_client_close(client);
>   	drm_dev_put(dev);
> -	if (client->funcs)
> -		module_put(client->funcs->owner);
>   }
>   EXPORT_SYMBOL(drm_client_release);
>   

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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2023-11-15 13:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 13:08 [Intel-gfx] [PATCH v6 0/7] drm/i915: Convert fbdev to DRM client Thomas Zimmermann
2023-11-02 13:08 ` [Intel-gfx] [PATCH v6 1/7] drm/client: Do not acquire module reference Thomas Zimmermann
2023-11-15 13:07   ` Thomas Zimmermann [this message]
2023-11-02 13:08 ` [Intel-gfx] [PATCH v6 2/7] drm/client: Export drm_client_dev_unregister() Thomas Zimmermann
2023-11-02 13:08 ` [Intel-gfx] [PATCH v6 3/7] drm/i915: Unregister in-kernel clients Thomas Zimmermann
2023-11-02 13:08 ` [Intel-gfx] [PATCH v6 4/7] drm/i915: Move fbdev functions Thomas Zimmermann
2023-11-02 13:08 ` [Intel-gfx] [PATCH v6 5/7] drm/i915: Initialize fbdev DRM client with callback functions Thomas Zimmermann
2023-11-02 13:08 ` [Intel-gfx] [PATCH v6 6/7] drm/i915: Implement fbdev client callbacks Thomas Zimmermann
2023-11-02 13:08 ` [Intel-gfx] [PATCH v6 7/7] drm/i915: Implement fbdev emulation as in-kernel client Thomas Zimmermann
2023-11-02 23:07 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915: Convert fbdev to DRM client (rev6) Patchwork
2023-11-02 23:25 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork

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=2d3de6cf-45ca-44a0-a62b-251c012d5e51@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=javierm@redhat.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=jouni.hogander@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=tejas.upadhyay@intel.com \
    --cc=tvrtko.ursulin@linux.intel.com \
    --cc=ville.syrjala@linux.intel.com \
    /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