public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Sean Paul <seanpaul@chromium.org>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 24/24] drm/gem: Add DEFINE_DRM_GEM_FOPS
Date: Mon, 13 Mar 2017 15:35:43 -0400	[thread overview]
Message-ID: <20170313193543.GV20329@art_vandelay> (raw)
In-Reply-To: <20170308141257.12119-25-daniel.vetter@ffwll.ch>

On Wed, Mar 08, 2017 at 03:12:57PM +0100, Daniel Vetter wrote:
> Sadly there's only 1 driver which can use it, everyone else is special
> for some reason:
> 
> - gma500 has a horrible runtime PM ioctl wrapper that probably doesn't
>   really work but meh.
> - i915 needs special compat_ioctl handler because regrets.
> - arcgpu needs to fixup the pgprot because (no idea why it can't do
>   that in the fault handler like everyone else).
> - tegra does even worse stuff with pgprot
> - udl does something with vm_flags too ...
> - cma helpers, etnaviv, mtk, msm, rockchip, omap all implement some
>   variation on prefaulting.
> - exynos is exynos, I got lost in the midlayers.
> - vc4 has to reinvent half of cma helpers because those are too much
>   midlayer, plus vm_flags dances.
> - vgem also seems unhappy with the default vm_flags.

I wonder whether a todo entry to clean this up would be appropriate.

Reviewed-by: Sean Paul <seanpaul@chromium.org>
> 
> So pretty sad divergence and I'm sure we could do better, but not
> really an idea. Oh well, maybe this macro here helps to encourage more
> consistency at least going forward.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/armada/armada_drv.c | 11 +----------
>  drivers/gpu/drm/drm_file.c          |  8 +++-----
>  include/drm/drm_gem.h               | 26 ++++++++++++++++++++++++++
>  3 files changed, 30 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1952e8748fea..f986e9ff093d 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -60,16 +60,7 @@ static void armada_drm_lastclose(struct drm_device *dev)
>  	armada_fbdev_lastclose(dev);
>  }
>  
> -static const struct file_operations armada_drm_fops = {
> -	.owner			= THIS_MODULE,
> -	.llseek			= no_llseek,
> -	.read			= drm_read,
> -	.poll			= drm_poll,
> -	.unlocked_ioctl		= drm_ioctl,
> -	.mmap			= drm_gem_mmap,
> -	.open			= drm_open,
> -	.release		= drm_release,
> -};
> +DEFINE_DRM_GEM_FOPS(armada_drm_fops);
>  
>  static struct drm_driver armada_drm_driver = {
>  	.lastclose		= armada_drm_lastclose,
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index 260a83563976..0701362dcca1 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -89,11 +89,9 @@ DEFINE_MUTEX(drm_global_mutex);
>   *             .mmap = drm_gem_mmap,
>   *     };
>   *
> - * For CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make
> - * this simpler.
> - *
> - * FIXME: We should have a macro for this (and the CMA version) so that drivers
> - * don't have to repeat it all the time.
> + * For plain GEM based drivers there is the DEFINE_DRM_GEM_FOPS() macro, and for
> + * CMA based drivers there is the DEFINE_DRM_GEM_CMA_FOPS() macro to make this
> + * simpler.
>   */
>  
>  static int drm_open_helper(struct file *filp, struct drm_minor *minor);
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index b9ade75ecd82..663d80358057 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -178,6 +178,32 @@ struct drm_gem_object {
>  	struct dma_buf_attachment *import_attach;
>  };
>  
> +/**
> + * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
> + * @name: name for the generated structure
> + *
> + * This macro autogenerates a suitable &struct file_operations for GEM based
> + * drivers, which can be assigned to &drm_driver.fops. Note that this structure
> + * cannot be shared between drivers, because it contains a reference to the
> + * current module using THIS_MODULE.
> + *
> + * Note that the declaration is already marked as static - if you need a
> + * non-static version of this you're probably doing it wrong and will break the
> + * THIS_MODULE reference by accident.
> + */
> +#define DEFINE_DRM_GEM_FOPS(name) \
> +	static const struct file_operations name = {\
> +		.owner		= THIS_MODULE,\
> +		.open		= drm_open,\
> +		.release	= drm_release,\
> +		.unlocked_ioctl	= drm_ioctl,\
> +		.compat_ioctl	= drm_compat_ioctl,\
> +		.poll		= drm_poll,\
> +		.read		= drm_read,\
> +		.llseek		= noop_llseek,\
> +		.mmap		= drm_gem_mmap,\
> +	}
> +
>  void drm_gem_object_release(struct drm_gem_object *obj);
>  void drm_gem_object_free(struct kref *kref);
>  int drm_gem_object_init(struct drm_device *dev,
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-03-13 19:35 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08 14:12 [PATCH 00/24] more docs and header splits Daniel Vetter
2017-03-08 14:12 ` [PATCH 01/24] drm/doc: Add todo about connector_list_iter Daniel Vetter
2017-03-08 15:12   ` [Intel-gfx] " Sean Paul
2017-03-08 14:12 ` [PATCH 02/24] drm: Extract drm_prime.h Daniel Vetter
2017-03-08 14:57   ` Gustavo Padovan
2017-03-13 16:42   ` Sean Paul
2017-03-14  9:12     ` [Intel-gfx] " Daniel Vetter
2017-03-14 15:42       ` Sean Paul
2017-03-08 14:12 ` [PATCH 03/24] drm: Move drm_lock_data out of drmP.h Daniel Vetter
2017-03-08 14:58   ` Gustavo Padovan
2017-03-08 14:12 ` [PATCH 04/24] drm: Extract drm_pci.h Daniel Vetter
2017-03-08 14:59   ` [Intel-gfx] " Gustavo Padovan
2017-03-08 14:12 ` [PATCH 05/24] drm: Remove drmP.h include from drm_kms_helper_common.c Daniel Vetter
2017-03-08 15:00   ` [Intel-gfx] " Gustavo Padovan
2017-03-08 14:12 ` [PATCH 06/24] drm/doc: document fallback behaviour for atomic events Daniel Vetter
2017-03-08 14:57   ` Laurent Pinchart
2017-03-08 14:12 ` [PATCH 07/24] drm: rename drm_fops.c to drm_file.c Daniel Vetter
2017-03-08 15:02   ` [Intel-gfx] " Gustavo Padovan
2017-03-08 14:12 ` [PATCH 08/24] drm: Remove DRM_MINOR_CNT Daniel Vetter
2017-03-08 14:14   ` David Herrmann
2017-03-13 16:56   ` Sean Paul
2017-03-08 14:12 ` [PATCH 09/24] drm: Extract drm_file.h Daniel Vetter
2017-03-08 15:05   ` Gustavo Padovan
2017-03-09 10:52     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 10/24] drm: Remove drm_pending_event->pid Daniel Vetter
2017-03-13 17:05   ` [Intel-gfx] " Sean Paul
2017-03-14 13:20     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 11/24] drm/doc: Document drm_file.[hc] Daniel Vetter
2017-03-13 17:53   ` Sean Paul
2017-03-14 13:25     ` Daniel Vetter
2017-03-14 13:27     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 12/24] drm/i915: Merge pre/postclose hooks Daniel Vetter
2017-03-08 15:07   ` Chris Wilson
2017-03-08 15:45     ` Daniel Vetter
2017-03-14 13:38       ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 13/24] drm/msm: switch to postclose Daniel Vetter
2017-03-13 18:59   ` Sean Paul
     [not found] ` <20170308141257.12119-1-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-03-08 14:12   ` [PATCH 14/24] drm/nouveau: Merge pre/postclose hooks Daniel Vetter
     [not found]     ` <20170308141257.12119-15-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-03-13 19:07       ` Sean Paul
2017-03-08 14:12   ` [PATCH 15/24] drm/radeon: " Daniel Vetter
     [not found]     ` <20170308141257.12119-16-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-03-08 14:25       ` Christian König
     [not found]         ` <79dc5480-6354-2379-8a7a-a2c099209256-5C7GfCeVMHo@public.gmane.org>
2017-03-09  3:58           ` Alex Deucher
2017-03-08 14:12   ` [PATCH 19/24] drm/amdgpu: " Daniel Vetter
2017-03-08 14:12 ` [PATCH 16/24] drm/tegra: switch to postclose Daniel Vetter
     [not found]   ` <20170308141257.12119-17-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-03-13 19:10     ` Sean Paul
2017-03-08 14:12 ` [PATCH 17/24] drm/vgem: " Daniel Vetter
2017-03-13 19:11   ` Sean Paul
2017-03-14 13:27     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 18/24] drm/etnaviv: " Daniel Vetter
2017-03-08 16:09   ` Lucas Stach
2017-03-08 18:15     ` Daniel Vetter
2017-03-09 10:03       ` Lucas Stach
2017-03-08 14:12 ` [PATCH 20/24] drm/exynos: Merge pre/postclose hooks Daniel Vetter
2017-03-13 19:18   ` [Intel-gfx] " Sean Paul
2017-03-14 13:28     ` Daniel Vetter
2017-03-15  0:54       ` Inki Dae
2017-03-08 14:12 ` [PATCH 21/24] drm/msm: Simplify vblank event delivery Daniel Vetter
2017-03-13 19:26   ` Sean Paul
2017-03-08 14:12 ` [PATCH 22/24] drm: Nerf the preclose callback for modern drivers Daniel Vetter
2017-03-09 10:48   ` Daniel Vetter
2017-03-13 19:29   ` [Intel-gfx] " Sean Paul
2017-03-14 13:50     ` Daniel Vetter
2017-03-08 14:12 ` [PATCH 23/24] drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers Daniel Vetter
2017-03-13 17:11   ` Liviu Dudau
2017-03-13 19:31   ` [Intel-gfx] " Sean Paul
2017-03-13 19:33     ` Sean Paul
2017-03-08 14:12 ` [PATCH 24/24] drm/gem: Add DEFINE_DRM_GEM_FOPS Daniel Vetter
2017-03-13 19:35   ` Sean Paul [this message]
2017-03-14 13:31     ` Daniel Vetter
2017-03-08 17:52 ` ✓ Fi.CI.BAT: success for more docs and header splits 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=20170313193543.GV20329@art_vandelay \
    --to=seanpaul@chromium.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox