From: raof@ubuntu.com
To: dri-devel@lists.freedesktop.org
Cc: Christopher James Halse Rogers <raof@ubuntu.com>,
Christopher James Halse Rogers
<christopher.halse.rogers@canonical.com>
Subject: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.
Date: Tue, 4 Apr 2017 18:13:20 +1000 [thread overview]
Message-ID: <20170404081321.19263-2-raof@ubuntu.com> (raw)
In-Reply-To: <20170404081321.19263-1-raof@ubuntu.com>
From: Christopher James Halse Rogers <raof@ubuntu.com>
Until recently, on (at least) nouveau, radeon, and amdgpu attempting to scanout of an
imported dma-buf would silently result in the dma-buf sharing being broken.
While the hardware is capable of scanning out of imported dma-bufs (at least in some circumstances),
these drivers do not currently implement it, so attempts to scan out of such buffers will never succeed.
Add a userspace-visible drm capability and associated driver_feature so that userspace can discover
when scanning out of an imported dma-buf can work.
Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
---
drivers/gpu/drm/drm_ioctl.c | 3 +++
include/drm/drm_drv.h | 1 +
include/uapi/drm/drm.h | 21 +++++++++++++++++++++
3 files changed, 25 insertions(+)
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index a7c61c23685a..79ccf638668e 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -285,6 +285,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
case DRM_CAP_ADDFB2_MODIFIERS:
req->value = dev->mode_config.allow_fb_modifiers;
break;
+ case DRM_CAP_PRIME_SCANOUT:
+ req->value = drm_core_check_feature(dev, DRIVER_PRIME_SCANOUT);
+ break;
default:
return -EINVAL;
}
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 5699f42195fe..32cc0d956d7e 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -53,6 +53,7 @@ struct drm_mode_create_dumb;
#define DRIVER_RENDER 0x8000
#define DRIVER_ATOMIC 0x10000
#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
+#define DRIVER_PRIME_SCANOUT 0x40000
/**
* struct drm_driver - DRM driver structure
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index b2c52843bc70..c57213cdb702 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -647,6 +647,27 @@ struct drm_gem_open {
#define DRM_CAP_CURSOR_HEIGHT 0x9
#define DRM_CAP_ADDFB2_MODIFIERS 0x10
#define DRM_CAP_PAGE_FLIP_TARGET 0x11
+/**
+ * DRM_CAP_PRIME_SCANOUT
+ *
+ * The PRIME_SCANOUT capability returns whether the driver might be capable
+ * of scanning out of an imported PRIME buffer.
+ *
+ * This does not guarantee that any imported buffer can be scanned out, as
+ * there may be specific requirements that a given buffer might not satisfy.
+ *
+ * If this capability is false then imported PRIME buffers will definitely
+ * never be suitable for scanout.
+ *
+ * Note: Prior to the introduction of this capability, bugs in drivers would
+ * allow userspace to attempt to scan out of imported PRIME buffers. This would
+ * work once, but move the buffer into an inconsistent state where rendering from
+ * the exporting GPU would no longer be seen by the importing GPU.
+ *
+ * It is unsafe for driver-agnostic code to attempt to scan out of an imported
+ * PRIME buffer in the absense of this capability.
+ */
+#define DRM_CAP_PRIME_SCANOUT 0x12
/** DRM_IOCTL_GET_CAP ioctl argument type */
struct drm_get_cap {
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-04-04 8:13 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-04 8:13 [PATCH] Tell userspace if scanning out of an imported PRIME buffer is safe raof
2017-04-04 8:13 ` raof [this message]
2017-04-04 8:31 ` [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT Daniel Vetter
2017-04-04 10:11 ` Daniel Stone
2017-04-04 10:27 ` Christopher James Halse Rogers
2017-04-04 10:43 ` Lucas Stach
2017-04-04 11:53 ` Daniel Vetter
2017-04-05 0:20 ` Christopher James Halse Rogers
2017-04-05 6:27 ` Daniel Vetter
2017-04-05 6:52 ` Christopher James Halse Rogers
2017-04-05 8:15 ` Lucas Stach
2017-04-05 9:59 ` Daniel Vetter
2017-04-05 10:14 ` Lucas Stach
2017-04-05 11:13 ` Christopher James Halse Rogers
2017-04-05 11:21 ` Christian König
2017-04-10 8:52 ` Michel Dänzer
2017-04-10 9:03 ` Christian König
2017-04-10 14:10 ` Alex Deucher
2017-04-06 7:47 ` Christopher James Halse Rogers
2017-04-10 8:51 ` Michel Dänzer
2017-04-17 5:05 ` Christopher James Halse Rogers
2017-04-17 6:41 ` Michel Dänzer
2017-04-04 10:43 ` Daniel Stone
2017-04-04 11:15 ` Christian König
2017-04-04 11:32 ` Daniel Stone
2017-04-04 11:43 ` Christian König
2017-04-04 8:13 ` [PATCH 2/2] drm/i915: support DRIVER_PRIME_SCANOUT raof
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=20170404081321.19263-2-raof@ubuntu.com \
--to=raof@ubuntu.com \
--cc=christopher.halse.rogers@canonical.com \
--cc=dri-devel@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 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.