Skip to contentSkip to conversation

drm: Allow CAP_DUMB_BUFFERS on !MODESET

PATCH Superseded Ezequiel Garcia 3 participants 7 messages May 4, 2018 – May 9, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Allow CAP_DUMB_BUFFERS on !MODESET

It's perfectly possible to get dumb buffers out of drivers that don't support modeset. This is the case of vgem, which can be used to export dmabuf to run various tests. Therefore, move the dumb buffer capability check before the mode set check.

Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").

Fixes d5264ed3823a ("drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver")
---
 drivers/gpu/drm/drm_ioctl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_ioctl.c +3 -4
index af782911c505..deac011a0c25 100644
@@ -244,6 +244,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_SYNCOBJ:
 		req->value = drm_core_check_feature(dev, DRIVER_SYNCOBJ);
 		return 0;
+	case DRM_CAP_DUMB_BUFFER:
+		req->value |= dev->driver->dumb_create ? 1 : 0;
+		return 0;
 	}
 
 	/* Other caps only work with KMS drivers */
@@ -251,10 +254,6 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		return -ENOTSUPP;
 
 	switch (req->capability) {
-	case DRM_CAP_DUMB_BUFFER:
-		if (dev->driver->dumb_create)
-			req->value = 1;
-		break;
 	case DRM_CAP_VBLANK_HIGH_CRTC:
 		req->value = 1;
 		break;
Signature · 6 lines
2.16.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Op 04-05-18 om 16:25 schreef Ezequiel Garcia:

Quoted 19 lines

It's perfectly possible to get dumb buffers out of drivers that don't support modeset. This is the case of vgem, which can be used to export dmabuf to run various tests. Therefore, move the dumb buffer capability check before the mode set check.

Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").

Fixes d5264ed3823a ("drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver")
---
 drivers/gpu/drm/drm_ioctl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_ioctl.c +0 -0
index af782911c505..deac011a0c25 100644

drivers/gpu/drm/drm_ioctl.c static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ · line 248

Quoted 5 lines
drivers/gpu/drm/drm_ioctl.c +2 -0
@@ -244,6 +244,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_SYNCOBJ:
 		req->value = drm_core_check_feature(dev, DRIVER_SYNCOBJ);
 		return 0;
+	case DRM_CAP_DUMB_BUFFER:
+		req->value |= dev->driver->dumb_create ? 1 : 0;

Why the |= ?

Quoted 5 lines
drivers/gpu/drm/drm_ioctl.c +1 -0
+		return 0;
 	}
 
 	/* Other caps only work with KMS drivers */

drivers/gpu/drm/drm_ioctl.c static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ · line 259

Quoted 10 lines
drivers/gpu/drm/drm_ioctl.c +0 -4
@@ -251,10 +254,6 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		return -ENOTSUPP;
 
 	switch (req->capability) {
-	case DRM_CAP_DUMB_BUFFER:
-		if (dev->driver->dumb_create)
-			req->value = 1;
-		break;
 	case DRM_CAP_VBLANK_HIGH_CRTC:
 		req->value = 1;
 		break;

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 15 lines · Maarten Lankhorst

Op 04-05-18 om 16:25 schreef Ezequiel Garcia:

Quoted 14 lines

It's perfectly possible to get dumb buffers out of drivers that don't support modeset. This is the case of vgem, which can be used to export dmabuf to run various tests. Therefore, move the dumb buffer capability check before the mode set check.

Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").

Fixes d5264ed3823a ("drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver")
---
 drivers/gpu/drm/drm_ioctl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Quoted 12 lines

drivers/gpu/drm/drm_ioctl.c static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ · line 248

Quoted 10 lines
drivers/gpu/drm/drm_ioctl.c +2 -0
index af782911c505..deac011a0c25 100644
@@ -244,6 +244,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_SYNCOBJ:
 		req->value = drm_core_check_feature(dev, DRIVER_SYNCOBJ);
 		return 0;
+	case DRM_CAP_DUMB_BUFFER:
+		req->value |= dev->driver->dumb_create ? 1 : 0;

Why the |= ?

I'd say that's a silly copy-paste glitch. Will send a v2.

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/drm_ioctl.c +1 -0
+		return 0;
 	}
 
 	/* Other caps only work with KMS drivers */
@@ -251,10 +254,6 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		return -ENOTSUPP;
 
Quoted 10 lines

drivers/gpu/drm/drm_ioctl.c static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ · line 259

Quoted 8 lines
drivers/gpu/drm/drm_ioctl.c +0 -4
 	switch (req->capability) {
-	case DRM_CAP_DUMB_BUFFER:
-		if (dev->driver->dumb_create)
-			req->value = 1;
-		break;
 	case DRM_CAP_VBLANK_HIGH_CRTC:
 		req->value = 1;
 		break;

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

PATCH v2 1/1 drm: Allow CAP_DUMB_BUFFERS on !MODESET

In reply to Ezequiel Garcia

It's perfectly possible to get dumb buffers out of drivers that don't support modeset. This is the case of vgem, which can be used to export dmabuf to run various tests.

Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").

Fixes d5264ed3823a ("drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver")

---
Changes from v1:
* Drop the bitwise-OR assignment op

 drivers/gpu/drm/drm_ioctl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_ioctl.c +3 -4
index af782911c505..a5b879ce8f2c 100644
@@ -244,6 +244,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_SYNCOBJ:
 		req->value = drm_core_check_feature(dev, DRIVER_SYNCOBJ);
 		return 0;
+	case DRM_CAP_DUMB_BUFFER:
+		req->value = dev->driver->dumb_create ? 1 : 0;
+		return 0;
 	}
 
 	/* Other caps only work with KMS drivers */
@@ -251,10 +254,6 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		return -ENOTSUPP;
 
 	switch (req->capability) {
-	case DRM_CAP_DUMB_BUFFER:
-		if (dev->driver->dumb_create)
-			req->value = 1;
-		break;
 	case DRM_CAP_VBLANK_HIGH_CRTC:
 		req->value = 1;
 		break;
Signature · 6 lines
2.16.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
Quoted 5 lines · Ezequiel Garcia

It's perfectly possible to get dumb buffers out of drivers that don't support modeset. This is the case of vgem, which can be used to export dmabuf to run various tests.

Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").

Prime makes sense, because render-only drivers _really_ want to be able to share buffers.

But dumb buffers are really meant for dumb userspace running on kms drivers only, there's no need ever to tell userspace that dumb buffers are supported on non-kms drivers. It's kinda abuse of ioctls, but oh well, uapi is fixed forever. And you can still call the ioctls if you know they're there (which is always the case for the render-side of drm, there's no generic alloc ioctl for those).
-Daniel

Quoted 41 lines
Fixes d5264ed3823a ("drm: Return -ENOTSUPP when called for KMS cap with a non-KMS driver")

---
Changes from v1:
* Drop the bitwise-OR assignment op

 drivers/gpu/drm/drm_ioctl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_ioctl.c +3 -4
index af782911c505..a5b879ce8f2c 100644
@@ -244,6 +244,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_SYNCOBJ:
 		req->value = drm_core_check_feature(dev, DRIVER_SYNCOBJ);
 		return 0;
+	case DRM_CAP_DUMB_BUFFER:
+		req->value = dev->driver->dumb_create ? 1 : 0;
+		return 0;
 	}
 
 	/* Other caps only work with KMS drivers */
@@ -251,10 +254,6 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		return -ENOTSUPP;
 
 	switch (req->capability) {
-	case DRM_CAP_DUMB_BUFFER:
-		if (dev->driver->dumb_create)
-			req->value = 1;
-		break;
 	case DRM_CAP_VBLANK_HIGH_CRTC:
 		req->value = 1;
 		break;
Signature · 6 lines
2.16.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Hey Daniel,

Quoted 10 lines · Daniel Vetter
Quoted 5 lines · Ezequiel Garcia

It's perfectly possible to get dumb buffers out of drivers that don't support modeset. This is the case of vgem, which can be used to export dmabuf to run various tests.

Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").

Prime makes sense, because render-only drivers _really_ want to be able to share buffers.

Quoted 7 lines

But dumb buffers are really meant for dumb userspace running on kms drivers only, there's no need ever to tell userspace that dumb buffers are supported on non-kms drivers. It's kinda abuse of ioctls, but oh well, uapi is fixed forever. And you can still call the ioctls if you know they're there (which is always the case for the render-side of drm, there's no generic alloc ioctl for those).

Right, I see.

Well, I was mostly interested in dry testing, and vgem seemed a good candidate for a dma-buf exporter. For instance, this would be useful to test dmabuf video4linux pipelines.

Now, is this is a nack, then the other path is to support proper prime operations on virtio-gpu (which I'm also working on).

Thanks for reviewing!
Eze

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 21 lines · Ezequiel Garcia

Hey Daniel,

Quoted 10 lines · Daniel Vetter
Quoted 5 lines · Ezequiel Garcia

It's perfectly possible to get dumb buffers out of drivers that don't support modeset. This is the case of vgem, which can be used to export dmabuf to run various tests.

Inspired by commit f3f4c4d68a28 ("drm: Allow CAP_PRIME on !MODESET").

Prime makes sense, because render-only drivers _really_ want to be able to share buffers.

Quoted 7 lines

But dumb buffers are really meant for dumb userspace running on kms drivers only, there's no need ever to tell userspace that dumb buffers are supported on non-kms drivers. It's kinda abuse of ioctls, but oh well, uapi is fixed forever. And you can still call the ioctls if you know they're there (which is always the case for the render-side of drm, there's no generic alloc ioctl for those).

Quoted 5 lines

Right, I see.

Well, I was mostly interested in dry testing, and vgem seemed a good candidate for a dma-buf exporter. For instance, this would be useful to test dmabuf video4linux pipelines.

You can still use the ioctl ... we have tons of tests using vgem for buffer import/export in our igt gpu tests. Testing prime is exactly what vgem is for!

What you don't need is confuse generic userspace by enabling the getparam for dumb buffers. But such vgem-specific tests aren't generic userspace.

https://cgit.freedesktop.org/drm/igt-gpu-tools/

https://cgit.freedesktop.org/drm/igt-gpu-tools/tree/tests/prime_vgem.c

Cheers, Daniel

Quoted 6 lines

Now, is this is a nack, then the other path is to support proper prime operations on virtio-gpu (which I'm also working on).

Thanks for reviewing!
Eze

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel