From: Daniel Vetter <daniel@ffwll.ch>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org,
laurent.pinchart@ideasonboard.com, dh.herrmann@gmail.com
Subject: Re: [RFC v2 4/8] drm/fb-helper: Ensure driver module is pinned in fb_open()
Date: Tue, 9 Jan 2018 11:18:02 +0100 [thread overview]
Message-ID: <20180109101802.GN26573@phenom.ffwll.local> (raw)
In-Reply-To: <20180103222110.45855-5-noralf@tronnes.org>
On Wed, Jan 03, 2018 at 11:21:06PM +0100, Noralf Trønnes wrote:
> If struct fb_ops is defined in a library like cma, fb_open() and fbcon
> takes a ref on the library instead of the driver module. Use
> fb_ops.fb_open/fb_release to ensure that the driver module is pinned.
>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
... I guess the patch to roll it out to the various vfun tables and
macros comes later?
-Daniel
> ---
> drivers/gpu/drm/drm_fb_helper.c | 40 ++++++++++++++++++++++++++++++++++++++++
> include/drm/drm_fb_helper.h | 13 +++++++++++++
> 2 files changed, 53 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 035784ddd133..2c6adf1d80c2 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -1207,6 +1207,46 @@ void drm_fb_helper_cfb_imageblit(struct fb_info *info,
> }
> EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit);
>
> +/**
> + * drm_fb_helper_fb_open - implementation for &fb_ops.fb_open
> + * @info: fbdev registered by the helper
> + * @user: 1=userspace, 0=fbcon
> + *
> + * If &fb_ops is wrapped in a library, pin the driver module.
> + */
> +int drm_fb_helper_fb_open(struct fb_info *info, int user)
> +{
> + struct drm_fb_helper *fb_helper = info->par;
> + struct drm_device *dev = fb_helper->dev;
> +
> + if (info->fbops->owner != dev->driver->fops->owner) {
> + if (!try_module_get(dev->driver->fops->owner))
> + return -ENODEV;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(drm_fb_helper_fb_open);
> +
> +/**
> + * drm_fb_helper_fb_release - implementation for &fb_ops.fb_release
> + * @info: fbdev registered by the helper
> + * @user: 1=userspace, 0=fbcon
> + *
> + * If &fb_ops is wrapped in a library, unpin the driver module.
> + */
> +int drm_fb_helper_fb_release(struct fb_info *info, int user)
> +{
> + struct drm_fb_helper *fb_helper = info->par;
> + struct drm_device *dev = fb_helper->dev;
> +
> + if (info->fbops->owner != dev->driver->fops->owner)
> + module_put(dev->driver->fops->owner);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(drm_fb_helper_fb_release);
> +
> /**
> * drm_fb_helper_set_suspend - wrapper around fb_set_suspend
> * @fb_helper: driver-allocated fbdev helper, can be NULL
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index b069433e7fc1..a593f01ff69e 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -297,6 +297,9 @@ void drm_fb_helper_cfb_copyarea(struct fb_info *info,
> void drm_fb_helper_cfb_imageblit(struct fb_info *info,
> const struct fb_image *image);
>
> +int drm_fb_helper_fb_open(struct fb_info *info, int user);
> +int drm_fb_helper_fb_release(struct fb_info *info, int user);
> +
> void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend);
> void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper,
> bool suspend);
> @@ -473,6 +476,16 @@ static inline void drm_fb_helper_cfb_imageblit(struct fb_info *info,
> {
> }
>
> +static inline int drm_fb_helper_fb_open(struct fb_info *info, int user)
> +{
> + return -ENODEV;
> +}
> +
> +static inline int drm_fb_helper_fb_release(struct fb_info *info, int user)
> +{
> + return -ENODEV;
> +}
> +
> static inline void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper,
> bool suspend)
> {
> --
> 2.14.2
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-01-09 10:18 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 22:21 [RFC v2 0/8] drm: Add generic fbdev emulation Noralf Trønnes
2018-01-03 22:21 ` [RFC v2 1/8] drm: provide management functions for drm_file Noralf Trønnes
2018-01-09 10:20 ` Daniel Vetter
2018-01-09 10:32 ` David Herrmann
2018-01-03 22:21 ` [RFC v2 2/8] drm/ioctl: Remove trailing whitespace Noralf Trønnes
2018-01-09 10:18 ` Daniel Vetter
2018-01-09 14:49 ` Laurent Pinchart
2018-01-03 22:21 ` [RFC v2 3/8] drm: Export some ioctl functions Noralf Trønnes
2018-01-09 10:16 ` Daniel Vetter
2018-01-09 10:31 ` David Herrmann
2018-01-09 14:48 ` Laurent Pinchart
2018-01-03 22:21 ` [RFC v2 4/8] drm/fb-helper: Ensure driver module is pinned in fb_open() Noralf Trønnes
2018-01-09 10:18 ` Daniel Vetter [this message]
2018-01-09 10:22 ` Daniel Vetter
2018-01-03 22:21 ` [RFC v2 5/8] drm/fb-helper: Don't restore if fbdev is not in use Noralf Trønnes
2018-01-09 10:28 ` Daniel Vetter
2018-01-03 22:21 ` [RFC v2 6/8] drm: Handle fbdev emulation in core Noralf Trønnes
2018-01-09 10:38 ` Daniel Vetter
2018-01-10 17:02 ` Noralf Trønnes
2018-01-11 7:45 ` Daniel Vetter
2018-01-11 14:09 ` Noralf Trønnes
2018-01-18 21:36 ` Daniel Vetter
2018-01-03 22:21 ` [RFC v2 7/8] drm/fb-helper: Add generic fbdev emulation Noralf Trønnes
2018-01-09 10:46 ` Daniel Vetter
2018-01-03 22:21 ` [RFC v2 8/8] drm/vc4: Test " Noralf Trønnes
2018-01-03 22:42 ` ✓ Fi.CI.BAT: success for drm: Add generic fbdev emulation (rev2) 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=20180109101802.GN26573@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=daniel.vetter@ffwll.ch \
--cc=dh.herrmann@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=noralf@tronnes.org \
/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.