All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: intel-gfx@lists.freedesktop.org,
	laurent.pinchart@ideasonboard.com,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/9] drm: Make ioctls available for in-kernel clients
Date: Thu, 24 May 2018 10:22:52 +0200	[thread overview]
Message-ID: <20180524082252.GE3438@phenom.ffwll.local> (raw)
In-Reply-To: <20180523143411.64070-4-noralf@tronnes.org>

On Wed, May 23, 2018 at 04:34:05PM +0200, Noralf Trønnes wrote:
> Make ioctl wrappers for functions that will be used by the in-kernel API.
> The following functions are touched:
> - drm_mode_create_dumb_ioctl()
> - drm_mode_destroy_dumb_ioctl()
> - drm_mode_addfb()
> - drm_mode_rmfb()
> 
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_crtc_internal.h | 19 +++++++++++++----
>  drivers/gpu/drm/drm_dumb_buffers.c  | 33 +++++++++++++++++++----------
>  drivers/gpu/drm/drm_framebuffer.c   | 42 ++++++++++++++++++++++++-------------
>  drivers/gpu/drm/drm_ioctl.c         |  4 ++--
>  4 files changed, 66 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
> index 5d307b23a4e6..c762614af453 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -62,6 +62,12 @@ int drm_mode_getresources(struct drm_device *dev,
>  
>  
>  /* drm_dumb_buffers.c */
> +int drm_mode_create_dumb(struct drm_device *dev,
> +			 struct drm_mode_create_dumb *args,
> +			 struct drm_file *file_priv);
> +int drm_mode_destroy_dumb(struct drm_device *dev, u32 handle,
> +			  struct drm_file *file_priv);
> +
>  /* IOCTLs */
>  int drm_mode_create_dumb_ioctl(struct drm_device *dev,
>  			       void *data, struct drm_file *file_priv);
> @@ -163,14 +169,19 @@ int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y,
>  				     const struct drm_framebuffer *fb);
>  void drm_fb_release(struct drm_file *file_priv);
>  
> +int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or,
> +		   struct drm_file *file_priv);
> +int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
> +		  struct drm_file *file_priv);
> +
>  
>  /* IOCTL */
> -int drm_mode_addfb(struct drm_device *dev,
> -		   void *data, struct drm_file *file_priv);
> +int drm_mode_addfb_ioctl(struct drm_device *dev,
> +			 void *data, struct drm_file *file_priv);
>  int drm_mode_addfb2(struct drm_device *dev,
>  		    void *data, struct drm_file *file_priv);
> -int drm_mode_rmfb(struct drm_device *dev,
> -		  void *data, struct drm_file *file_priv);
> +int drm_mode_rmfb_ioctl(struct drm_device *dev,
> +			void *data, struct drm_file *file_priv);
>  int drm_mode_getfb(struct drm_device *dev,
>  		   void *data, struct drm_file *file_priv);
>  int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
> diff --git a/drivers/gpu/drm/drm_dumb_buffers.c b/drivers/gpu/drm/drm_dumb_buffers.c
> index 39ac15ce4702..eed9687b8698 100644
> --- a/drivers/gpu/drm/drm_dumb_buffers.c
> +++ b/drivers/gpu/drm/drm_dumb_buffers.c
> @@ -53,10 +53,10 @@
>   * a hardware-specific ioctl to allocate suitable buffer objects.
>   */
>  
> -int drm_mode_create_dumb_ioctl(struct drm_device *dev,
> -			       void *data, struct drm_file *file_priv)
> +int drm_mode_create_dumb(struct drm_device *dev,
> +			 struct drm_mode_create_dumb *args,
> +			 struct drm_file *file_priv)
>  {
> -	struct drm_mode_create_dumb *args = data;
>  	u32 cpp, stride, size;
>  
>  	if (!dev->driver->dumb_create)
> @@ -91,6 +91,12 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
>  	return dev->driver->dumb_create(file_priv, dev, args);
>  }
>  
> +int drm_mode_create_dumb_ioctl(struct drm_device *dev,
> +			       void *data, struct drm_file *file_priv)
> +{
> +	return drm_mode_create_dumb(dev, data, file_priv);
> +}
> +
>  /**
>   * drm_mode_mmap_dumb_ioctl - create an mmap offset for a dumb backing storage buffer
>   * @dev: DRM device
> @@ -122,17 +128,22 @@ int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
>  					       &args->offset);
>  }
>  
> +int drm_mode_destroy_dumb(struct drm_device *dev, u32 handle,
> +			  struct drm_file *file_priv)
> +{
> +	if (!dev->driver->dumb_create)
> +		return -ENOSYS;
> +
> +	if (dev->driver->dumb_destroy)
> +		return dev->driver->dumb_destroy(file_priv, dev, handle);
> +	else
> +		return drm_gem_dumb_destroy(file_priv, dev, handle);
> +}
> +
>  int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
>  				void *data, struct drm_file *file_priv)
>  {
>  	struct drm_mode_destroy_dumb *args = data;
>  
> -	if (!dev->driver->dumb_create)
> -		return -ENOSYS;
> -
> -	if (dev->driver->dumb_destroy)
> -		return dev->driver->dumb_destroy(file_priv, dev, args->handle);
> -	else
> -		return drm_gem_dumb_destroy(file_priv, dev, args->handle);
> +	return drm_mode_destroy_dumb(dev, args->handle, file_priv);
>  }
> -
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index bfedceff87bb..44759aeed1e7 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -95,21 +95,20 @@ int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y,
>  /**
>   * drm_mode_addfb - add an FB to the graphics configuration
>   * @dev: drm device for the ioctl
> - * @data: data pointer for the ioctl
> - * @file_priv: drm file for the ioctl call
> + * @or: pointer to request structure
> + * @file_priv: drm file
>   *
>   * Add a new FB to the specified CRTC, given a user request. This is the
>   * original addfb ioctl which only supported RGB formats.
>   *
> - * Called by the user via ioctl.
> + * Called by the user via ioctl, or by an in-kernel client.
>   *
>   * Returns:
>   * Zero on success, negative errno on failure.
>   */
> -int drm_mode_addfb(struct drm_device *dev,
> -		   void *data, struct drm_file *file_priv)
> +int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or,
> +		   struct drm_file *file_priv)
>  {
> -	struct drm_mode_fb_cmd *or = data;
>  	struct drm_mode_fb_cmd2 r = {};
>  	int ret;
>  
> @@ -134,6 +133,12 @@ int drm_mode_addfb(struct drm_device *dev,
>  	return 0;
>  }
>  
> +int drm_mode_addfb_ioctl(struct drm_device *dev,
> +			 void *data, struct drm_file *file_priv)
> +{
> +	return drm_mode_addfb(dev, data, file_priv);
> +}
> +
>  static int fb_plane_width(int width,
>  			  const struct drm_format_info *format, int plane)
>  {
> @@ -367,29 +372,28 @@ static void drm_mode_rmfb_work_fn(struct work_struct *w)
>  
>  /**
>   * drm_mode_rmfb - remove an FB from the configuration
> - * @dev: drm device for the ioctl
> - * @data: data pointer for the ioctl
> - * @file_priv: drm file for the ioctl call
> + * @dev: drm device
> + * @fb_id: id of framebuffer to remove
> + * @file_priv: drm file
>   *
> - * Remove the FB specified by the user.
> + * Remove the specified FB.
>   *
> - * Called by the user via ioctl.
> + * Called by the user via ioctl, or by an in-kernel client.
>   *
>   * Returns:
>   * Zero on success, negative errno on failure.
>   */
> -int drm_mode_rmfb(struct drm_device *dev,
> -		   void *data, struct drm_file *file_priv)
> +int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
> +		  struct drm_file *file_priv)
>  {
>  	struct drm_framebuffer *fb = NULL;
>  	struct drm_framebuffer *fbl = NULL;
> -	uint32_t *id = data;
>  	int found = 0;
>  
>  	if (!drm_core_check_feature(dev, DRIVER_MODESET))
>  		return -EINVAL;
>  
> -	fb = drm_framebuffer_lookup(dev, file_priv, *id);
> +	fb = drm_framebuffer_lookup(dev, file_priv, fb_id);
>  	if (!fb)
>  		return -ENOENT;
>  
> @@ -435,6 +439,14 @@ int drm_mode_rmfb(struct drm_device *dev,
>  	return -ENOENT;
>  }
>  
> +int drm_mode_rmfb_ioctl(struct drm_device *dev,
> +			void *data, struct drm_file *file_priv)
> +{
> +	uint32_t *fb_id = data;
> +
> +	return drm_mode_rmfb(dev, *fb_id, file_priv);
> +}
> +
>  /**
>   * drm_mode_getfb - get FB info
>   * @dev: drm device for the ioctl
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 0d4cfb232576..9f659e1a19c5 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -637,9 +637,9 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPROPERTY, drm_mode_connector_property_set_ioctl, DRM_MASTER|DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_UNLOCKED),
> -	DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_UNLOCKED),
> +	DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb_ioctl, DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB2, drm_mode_addfb2, DRM_UNLOCKED),
> -	DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_UNLOCKED),
> +	DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb_ioctl, DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_PAGE_FLIP, drm_mode_page_flip_ioctl, DRM_MASTER|DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_DIRTYFB, drm_mode_dirtyfb_ioctl, DRM_MASTER|DRM_UNLOCKED),
>  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_DUMB, drm_mode_create_dumb_ioctl, DRM_UNLOCKED),
> -- 
> 2.15.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

  reply	other threads:[~2018-05-24  8:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 14:34 [PATCH 0/9] drm: Add generic fbdev emulation Noralf Trønnes
2018-05-23 14:34 ` [PATCH 1/9] drm: provide management functions for drm_file Noralf Trønnes
2018-05-23 14:34 ` [PATCH 2/9] drm/file: Don't set master on in-kernel clients Noralf Trønnes
2018-05-23 14:34 ` [PATCH 3/9] drm: Make ioctls available for " Noralf Trønnes
2018-05-24  8:22   ` Daniel Vetter [this message]
2018-05-23 14:34 ` [PATCH 4/9] drm: Begin an API " Noralf Trønnes
2018-05-23 21:45   ` Thomas Hellstrom
2018-05-24  8:32     ` Daniel Vetter
2018-05-24  9:25       ` Thomas Hellstrom
2018-05-24 10:14         ` Daniel Vetter
2018-05-24 16:51           ` Thomas Hellstrom
2018-05-24  8:42   ` Daniel Vetter
2018-05-28 13:26     ` Noralf Trønnes
2018-05-29  7:53       ` Daniel Vetter
2018-05-23 14:34 ` [PATCH 5/9] drm/fb-helper: Add generic fbdev emulation .fb_probe function Noralf Trønnes
2018-05-24  9:16   ` Daniel Vetter
2018-05-24 10:16     ` Daniel Vetter
2018-05-25 12:42     ` Noralf Trønnes
2018-05-29  7:54       ` Daniel Vetter
2018-12-28 20:38         ` Daniel Vetter
2019-01-03 17:06           ` Noralf Trønnes
2019-01-07 10:14             ` Daniel Vetter
2018-05-23 14:34 ` [PATCH 6/9] drm/pl111: Set .gem_prime_vmap and .gem_prime_mmap Noralf Trønnes
2018-05-30 19:04   ` Eric Anholt
2018-05-23 14:34 ` [PATCH 7/9] drm/cma-helper: Use the generic fbdev emulation Noralf Trønnes
2018-05-24 10:16   ` Daniel Vetter
2018-05-23 14:34 ` [PATCH 8/9] drm/client: Add client callbacks Noralf Trønnes
2018-05-24  9:52   ` Daniel Vetter
2018-05-23 14:34 ` [PATCH 9/9] drm/fb-helper: Finish the generic fbdev emulation Noralf Trønnes
2018-05-24  9:57   ` Daniel Vetter
2018-05-23 15:20 ` ✗ Fi.CI.CHECKPATCH: warning for drm: Add " Patchwork
2018-05-23 15:38 ` ✓ Fi.CI.BAT: success " Patchwork
2018-05-23 17:31 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-05-24 10:17 ` [PATCH 0/9] " Daniel Vetter

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=20180524082252.GE3438@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --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.