All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: add DRM_PRIME_CAP_LOCAL
@ 2019-04-10  7:47 ` Gerd Hoffmann
  0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2019-04-10  7:47 UTC (permalink / raw)
  To: dri-devel
  Cc: Gerd Hoffmann, Dave Airlie, Maarten Lankhorst, Maxime Ripard,
	Sean Paul, David Airlie, Daniel Vetter, open list

Some drivers (for example qxl) support neither import nor export of
dma-bufs.  But you can still use dma-bufs to pass buffer references
from one process to another; drm_gem_prime_import() will figure the
dma-buf came from the same driver and just takes a reference in that
case instead of doing a full export/import.

Right now there is no way for userspace to figure it can do this.  Add
the new prime capability DRM_PRIME_CAP_LOCAL to indicate that.  Set the
bit for every driver which has the DRIVER_PRIME feature bit set.

Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/uapi/drm/drm.h      | 1 +
 drivers/gpu/drm/drm_ioctl.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 236b01a1fabf..b6157d48dc1a 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -632,6 +632,7 @@ struct drm_gem_open {
 #define DRM_CAP_PRIME			0x5
 #define  DRM_PRIME_CAP_IMPORT		0x1
 #define  DRM_PRIME_CAP_EXPORT		0x2
+#define  DRM_PRIME_CAP_LOCAL		0x4
 #define DRM_CAP_TIMESTAMP_MONOTONIC	0x6
 #define DRM_CAP_ASYNC_PAGE_FLIP		0x7
 /*
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index d337f161909c..00599758783b 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -241,6 +241,8 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_PRIME:
 		req->value |= dev->driver->prime_fd_to_handle ? DRM_PRIME_CAP_IMPORT : 0;
 		req->value |= dev->driver->prime_handle_to_fd ? DRM_PRIME_CAP_EXPORT : 0;
+		req->value |= (dev->driver->driver_features & DRIVER_PRIME)
+			? DRM_PRIME_CAP_LOCAL : 0;
 		return 0;
 	case DRM_CAP_SYNCOBJ:
 		req->value = drm_core_check_feature(dev, DRIVER_SYNCOBJ);
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] drm: add DRM_PRIME_CAP_LOCAL
@ 2019-04-10  7:47 ` Gerd Hoffmann
  0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2019-04-10  7:47 UTC (permalink / raw)
  To: dri-devel
  Cc: Gerd Hoffmann, Dave Airlie, Maarten Lankhorst, Maxime Ripard,
	Sean Paul, David Airlie, Daniel Vetter, open list

Some drivers (for example qxl) support neither import nor export of
dma-bufs.  But you can still use dma-bufs to pass buffer references
from one process to another; drm_gem_prime_import() will figure the
dma-buf came from the same driver and just takes a reference in that
case instead of doing a full export/import.

Right now there is no way for userspace to figure it can do this.  Add
the new prime capability DRM_PRIME_CAP_LOCAL to indicate that.  Set the
bit for every driver which has the DRIVER_PRIME feature bit set.

Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/uapi/drm/drm.h      | 1 +
 drivers/gpu/drm/drm_ioctl.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 236b01a1fabf..b6157d48dc1a 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -632,6 +632,7 @@ struct drm_gem_open {
 #define DRM_CAP_PRIME			0x5
 #define  DRM_PRIME_CAP_IMPORT		0x1
 #define  DRM_PRIME_CAP_EXPORT		0x2
+#define  DRM_PRIME_CAP_LOCAL		0x4
 #define DRM_CAP_TIMESTAMP_MONOTONIC	0x6
 #define DRM_CAP_ASYNC_PAGE_FLIP		0x7
 /*
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index d337f161909c..00599758783b 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -241,6 +241,8 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_PRIME:
 		req->value |= dev->driver->prime_fd_to_handle ? DRM_PRIME_CAP_IMPORT : 0;
 		req->value |= dev->driver->prime_handle_to_fd ? DRM_PRIME_CAP_EXPORT : 0;
+		req->value |= (dev->driver->driver_features & DRIVER_PRIME)
+			? DRM_PRIME_CAP_LOCAL : 0;
 		return 0;
 	case DRM_CAP_SYNCOBJ:
 		req->value = drm_core_check_feature(dev, DRIVER_SYNCOBJ);
-- 
2.18.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm: add DRM_PRIME_CAP_LOCAL
  2019-04-10  7:47 ` Gerd Hoffmann
  (?)
@ 2019-04-16  7:19 ` Daniel Vetter
  -1 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2019-04-16  7:19 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: dri-devel, Dave Airlie, Maarten Lankhorst, Maxime Ripard,
	Sean Paul, David Airlie, Daniel Vetter, open list

On Wed, Apr 10, 2019 at 09:47:12AM +0200, Gerd Hoffmann wrote:
> Some drivers (for example qxl) support neither import nor export of
> dma-bufs.  But you can still use dma-bufs to pass buffer references
> from one process to another; drm_gem_prime_import() will figure the
> dma-buf came from the same driver and just takes a reference in that
> case instead of doing a full export/import.
> 
> Right now there is no way for userspace to figure it can do this.  Add
> the new prime capability DRM_PRIME_CAP_LOCAL to indicate that.  Set the
> bit for every driver which has the DRIVER_PRIME feature bit set.

It can just try? Any driver that supports dma-buf (even if only for
self-import) should set DRIVER_PRIME. It's perfectly fine to reject any
other sharing.
-Daniel

> 
> Cc: Dave Airlie <airlied@redhat.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  include/uapi/drm/drm.h      | 1 +
>  drivers/gpu/drm/drm_ioctl.c | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index 236b01a1fabf..b6157d48dc1a 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -632,6 +632,7 @@ struct drm_gem_open {
>  #define DRM_CAP_PRIME			0x5
>  #define  DRM_PRIME_CAP_IMPORT		0x1
>  #define  DRM_PRIME_CAP_EXPORT		0x2
> +#define  DRM_PRIME_CAP_LOCAL		0x4
>  #define DRM_CAP_TIMESTAMP_MONOTONIC	0x6
>  #define DRM_CAP_ASYNC_PAGE_FLIP		0x7
>  /*
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index d337f161909c..00599758783b 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -241,6 +241,8 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
>  	case DRM_CAP_PRIME:
>  		req->value |= dev->driver->prime_fd_to_handle ? DRM_PRIME_CAP_IMPORT : 0;
>  		req->value |= dev->driver->prime_handle_to_fd ? DRM_PRIME_CAP_EXPORT : 0;
> +		req->value |= (dev->driver->driver_features & DRIVER_PRIME)
> +			? DRM_PRIME_CAP_LOCAL : 0;
>  		return 0;
>  	case DRM_CAP_SYNCOBJ:
>  		req->value = drm_core_check_feature(dev, DRIVER_SYNCOBJ);
> -- 
> 2.18.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-16  7:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-10  7:47 [PATCH] drm: add DRM_PRIME_CAP_LOCAL Gerd Hoffmann
2019-04-10  7:47 ` Gerd Hoffmann
2019-04-16  7:19 ` Daniel Vetter

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.