Skip to contentSkip to conversation

drm/qxl: drop prime import/export callbacks

PATCH In review Gerd Hoffmann 3 participants 11 messages Jan 10, 2019 – Apr 9, 2019

Subsystems (4)
lore
Share & tools
lore

Gerd Hoffmann

author maintainer
#0 lore raw

PATCH 1/1 drm/qxl: drop prime import/export callbacks

Also set prime_handle_to_fd and prime_fd_to_handle to NULL, so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.

---
 drivers/gpu/drm/qxl/qxl_drv.c   |  4 ----
 drivers/gpu/drm/qxl/qxl_prime.c | 14 --------------
 2 files changed, 18 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.c +0 -4
index 13c8a662f9..ccb090f3ab 100644
@@ -250,14 +250,10 @@ static struct drm_driver qxl_driver = {
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = qxl_debugfs_init,
 #endif
-	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_prime_export = drm_gem_prime_export,
 	.gem_prime_import = drm_gem_prime_import,
 	.gem_prime_pin = qxl_gem_prime_pin,
 	.gem_prime_unpin = qxl_gem_prime_unpin,
-	.gem_prime_get_sg_table = qxl_gem_prime_get_sg_table,
-	.gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
 	.gem_prime_vmap = qxl_gem_prime_vmap,
 	.gem_prime_vunmap = qxl_gem_prime_vunmap,
 	.gem_prime_mmap = qxl_gem_prime_mmap,
drivers/gpu/drm/qxl/qxl_prime.c +0 -14
index a55dece118..df65d3c1a7 100644
@@ -38,20 +38,6 @@ void qxl_gem_prime_unpin(struct drm_gem_object *obj)
 	WARN_ONCE(1, "not implemented");
 }
 
-struct sg_table *qxl_gem_prime_get_sg_table(struct drm_gem_object *obj)
-{
-	WARN_ONCE(1, "not implemented");
-	return ERR_PTR(-ENOSYS);
-}
-
-struct drm_gem_object *qxl_gem_prime_import_sg_table(
-	struct drm_device *dev, struct dma_buf_attachment *attach,
-	struct sg_table *table)
-{
-	WARN_ONCE(1, "not implemented");
-	return ERR_PTR(-ENOSYS);
-}
-
 void *qxl_gem_prime_vmap(struct drm_gem_object *obj)
 {
 	WARN_ONCE(1, "not implemented");
Signature · 1 line
2.9.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Gerd Hoffmann

Also set prime_handle_to_fd and prime_fd_to_handle to NULL, so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.

Quoted 52 lines
---
 drivers/gpu/drm/qxl/qxl_drv.c   |  4 ----
 drivers/gpu/drm/qxl/qxl_prime.c | 14 --------------
 2 files changed, 18 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.c +0 -4
index 13c8a662f9..ccb090f3ab 100644
@@ -250,14 +250,10 @@ static struct drm_driver qxl_driver = {
 #if defined(CONFIG_DEBUG_FS)
        .debugfs_init = qxl_debugfs_init,
 #endif
-       .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-       .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
        .gem_prime_export = drm_gem_prime_export,
        .gem_prime_import = drm_gem_prime_import,
        .gem_prime_pin = qxl_gem_prime_pin,
        .gem_prime_unpin = qxl_gem_prime_unpin,
-       .gem_prime_get_sg_table = qxl_gem_prime_get_sg_table,
-       .gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
        .gem_prime_vmap = qxl_gem_prime_vmap,
        .gem_prime_vunmap = qxl_gem_prime_vunmap,
        .gem_prime_mmap = qxl_gem_prime_mmap,
drivers/gpu/drm/qxl/qxl_prime.c +0 -15
index a55dece118..df65d3c1a7 100644
@@ -38,20 +38,6 @@ void qxl_gem_prime_unpin(struct drm_gem_object *obj)
        WARN_ONCE(1, "not implemented");
 }
 
-struct sg_table *qxl_gem_prime_get_sg_table(struct drm_gem_object *obj)
-{
-       WARN_ONCE(1, "not implemented");
-       return ERR_PTR(-ENOSYS);
-}
-
-struct drm_gem_object *qxl_gem_prime_import_sg_table(
-       struct drm_device *dev, struct dma_buf_attachment *attach,
-       struct sg_table *table)
-{
-       WARN_ONCE(1, "not implemented");
-       return ERR_PTR(-ENOSYS);
-}
-
 void *qxl_gem_prime_vmap(struct drm_gem_object *obj)
 {
        WARN_ONCE(1, "not implemented");
--

2.9.3

Quoted 4 lines

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

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

maintainer
#2 lore raw
Quoted 6 lines · Dave Airlie
Quoted 4 lines · Gerd Hoffmann

Also set prime_handle_to_fd and prime_fd_to_handle to NULL, so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.

It's been pointed out to me that disables DRI3 for these devices, I'm not sure that is the solution we actually wanted.

any ideas?
Dave.

Quoted 56 lines
Quoted 2 lines
Quoted 52 lines
---
 drivers/gpu/drm/qxl/qxl_drv.c   |  4 ----
 drivers/gpu/drm/qxl/qxl_prime.c | 14 --------------
 2 files changed, 18 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.c +0 -4
index 13c8a662f9..ccb090f3ab 100644
@@ -250,14 +250,10 @@ static struct drm_driver qxl_driver = {
 #if defined(CONFIG_DEBUG_FS)
        .debugfs_init = qxl_debugfs_init,
 #endif
-       .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-       .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
        .gem_prime_export = drm_gem_prime_export,
        .gem_prime_import = drm_gem_prime_import,
        .gem_prime_pin = qxl_gem_prime_pin,
        .gem_prime_unpin = qxl_gem_prime_unpin,
-       .gem_prime_get_sg_table = qxl_gem_prime_get_sg_table,
-       .gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
        .gem_prime_vmap = qxl_gem_prime_vmap,
        .gem_prime_vunmap = qxl_gem_prime_vunmap,
        .gem_prime_mmap = qxl_gem_prime_mmap,
drivers/gpu/drm/qxl/qxl_prime.c +0 -15
index a55dece118..df65d3c1a7 100644
@@ -38,20 +38,6 @@ void qxl_gem_prime_unpin(struct drm_gem_object *obj)
        WARN_ONCE(1, "not implemented");
 }
 
-struct sg_table *qxl_gem_prime_get_sg_table(struct drm_gem_object *obj)
-{
-       WARN_ONCE(1, "not implemented");
-       return ERR_PTR(-ENOSYS);
-}
-
-struct drm_gem_object *qxl_gem_prime_import_sg_table(
-       struct drm_device *dev, struct dma_buf_attachment *attach,
-       struct sg_table *table)
-{
-       WARN_ONCE(1, "not implemented");
-       return ERR_PTR(-ENOSYS);
-}
-
 void *qxl_gem_prime_vmap(struct drm_gem_object *obj)
 {
        WARN_ONCE(1, "not implemented");
--

2.9.3

Quoted 4 lines
Quoted 4 lines

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

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

author maintainer
#3 lore raw
Quoted 4 lines · Dave Airlie
Quoted 3 lines · Dave Airlie
Quoted 1 line · Gerd Hoffmann
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Also set prime_handle_to_fd and prime_fd_to_handle to NULL, so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.

It's been pointed out to me that disables DRI3 for these devices, I'm not sure that is the solution we actually wanted.

any ideas?

Well. Lets have a look at where we stand:

* drm_gem_prime_export() works with qxl, you'll get a dma-buf handle.

* Other drivers trying to map that dma-buf (drm_gem_map_dma_buf() callback) will not work, due to the ->gem_prime_get_sg_table() callback not being there.

* drm_gem_prime_import() will work with buffers from the same qxl device, there is a shortcut for this special case. Otherwise it will not work, due to the ->gem_prime_import_sg_table() callback not being there.

Bottom line: you can use prime to pass qxl object handles from one application to another. But you can't actually export/import qxl buffer objects from/to other devices.

Problem is that we have no way to signal to userspace that prime can be used that way.

Setting DRM_PRIME_CAP_{IMPORT,EXPORT} even though the driver can't do that leads to other problems. Userspace thinks it can have other devices (intel vgpu for example) handle the rendering, then import the rendered buffer into qxl for scanout.

Should we add something like DRM_PRIME_CAP_SAME_DEVICE?

cheers,
Gerd

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

maintainer
#4 lore raw
Quoted 35 lines · Gerd Hoffmann
Quoted 4 lines · Dave Airlie
Quoted 3 lines · Dave Airlie
Quoted 1 line · Gerd Hoffmann
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Also set prime_handle_to_fd and prime_fd_to_handle to NULL, so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.

It's been pointed out to me that disables DRI3 for these devices, I'm not sure that is the solution we actually wanted.

any ideas?

Well. Lets have a look at where we stand:

* drm_gem_prime_export() works with qxl, you'll get a dma-buf handle.

* Other drivers trying to map that dma-buf (drm_gem_map_dma_buf() callback) will not work, due to the ->gem_prime_get_sg_table() callback not being there.

* drm_gem_prime_import() will work with buffers from the same qxl device, there is a shortcut for this special case. Otherwise it will not work, due to the ->gem_prime_import_sg_table() callback not being there.

Bottom line: you can use prime to pass qxl object handles from one application to another. But you can't actually export/import qxl buffer objects from/to other devices.

Problem is that we have no way to signal to userspace that prime can be used that way.

Quoted 6 lines

Setting DRM_PRIME_CAP_{IMPORT,EXPORT} even though the driver can't do that leads to other problems. Userspace thinks it can have other devices (intel vgpu for example) handle the rendering, then import the rendered buffer into qxl for scanout.

Should we add something like DRM_PRIME_CAP_SAME_DEVICE?

Yeah I expect we need some sort of same device only capability, so that dri3 userspace can work.

If we just fail importing in these cases what happens? userspace just gets confused, I know we used to print a backtrace if we hit the mmap path, but if we didn't do that what happens?

Dave.

author maintainer
#5 lore raw

Hi,

Quoted 8 lines
Quoted 1 line

Should we add something like DRM_PRIME_CAP_SAME_DEVICE?

Yeah I expect we need some sort of same device only capability, so that dri3 userspace can work.

If we just fail importing in these cases what happens? userspace just gets confused, I know we used to print a backtrace if we hit the mmap path, but if we didn't do that what happens?

Well, we printed a backtrace and returned -EINVAL. So it looked a bit scary due to the backtrace which is usually printed for more serious problems. But we also returned a proper error code.

Userspace was not happy. It was wayland (gnome-shell) which ran into it it, and it didn't came up with a working display.

cheers,
Gerd

author maintainer
#6 lore raw
In reply to David Airlie

Hi,

Quoted 8 lines
Quoted 1 line

Should we add something like DRM_PRIME_CAP_SAME_DEVICE?

Yeah I expect we need some sort of same device only capability, so that dri3 userspace can work.

If we just fail importing in these cases what happens? userspace just gets confused, I know we used to print a backtrace if we hit the mmap path, but if we didn't do that what happens?

Well, we printed a backtrace and returned -EINVAL. So it looked a bit scary due to the backtrace which is usually printed for more serious problems. But we also returned a proper error code.

Userspace was not happy. It was wayland (gnome-shell) which ran into it it, and it didn't came up with a working display.

cheers,
Gerd

maintainer
#7 lore raw
In reply to Gerd Hoffmann
Quoted 35 lines · Gerd Hoffmann
Quoted 4 lines · Dave Airlie
Quoted 3 lines · Dave Airlie
Quoted 1 line · Gerd Hoffmann
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Also set prime_handle_to_fd and prime_fd_to_handle to NULL, so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.

It's been pointed out to me that disables DRI3 for these devices, I'm not sure that is the solution we actually wanted.

any ideas?

Well. Lets have a look at where we stand:

* drm_gem_prime_export() works with qxl, you'll get a dma-buf handle.

* Other drivers trying to map that dma-buf (drm_gem_map_dma_buf() callback) will not work, due to the ->gem_prime_get_sg_table() callback not being there.

* drm_gem_prime_import() will work with buffers from the same qxl device, there is a shortcut for this special case. Otherwise it will not work, due to the ->gem_prime_import_sg_table() callback not being there.

Bottom line: you can use prime to pass qxl object handles from one application to another. But you can't actually export/import qxl buffer objects from/to other devices.

Problem is that we have no way to signal to userspace that prime can be used that way.

Quoted 6 lines

Setting DRM_PRIME_CAP_{IMPORT,EXPORT} even though the driver can't do that leads to other problems. Userspace thinks it can have other devices (intel vgpu for example) handle the rendering, then import the rendered buffer into qxl for scanout.

Should we add something like DRM_PRIME_CAP_SAME_DEVICE?

Yeah I expect we need some sort of same device only capability, so that dri3 userspace can work.

If we just fail importing in these cases what happens? userspace just gets confused, I know we used to print a backtrace if we hit the mmap path, but if we didn't do that what happens?

Dave.

author maintainer
#8 lore raw
In reply to Dave Airlie
Quoted 4 lines · Dave Airlie
Quoted 3 lines · Dave Airlie
Quoted 1 line · Gerd Hoffmann
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Also set prime_handle_to_fd and prime_fd_to_handle to NULL, so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.

It's been pointed out to me that disables DRI3 for these devices, I'm not sure that is the solution we actually wanted.

any ideas?

Well. Lets have a look at where we stand:

* drm_gem_prime_export() works with qxl, you'll get a dma-buf handle.

* Other drivers trying to map that dma-buf (drm_gem_map_dma_buf() callback) will not work, due to the ->gem_prime_get_sg_table() callback not being there.

* drm_gem_prime_import() will work with buffers from the same qxl device, there is a shortcut for this special case. Otherwise it will not work, due to the ->gem_prime_import_sg_table() callback not being there.

Bottom line: you can use prime to pass qxl object handles from one application to another. But you can't actually export/import qxl buffer objects from/to other devices.

Problem is that we have no way to signal to userspace that prime can be used that way.

Setting DRM_PRIME_CAP_{IMPORT,EXPORT} even though the driver can't do that leads to other problems. Userspace thinks it can have other devices (intel vgpu for example) handle the rendering, then import the rendered buffer into qxl for scanout.

Should we add something like DRM_PRIME_CAP_SAME_DEVICE?

cheers,
Gerd

maintainer
#9 lore raw
In reply to Dave Airlie
Quoted 6 lines · Dave Airlie
Quoted 4 lines · Gerd Hoffmann

Also set prime_handle_to_fd and prime_fd_to_handle to NULL, so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.

It's been pointed out to me that disables DRI3 for these devices, I'm not sure that is the solution we actually wanted.

any ideas?
Dave.

Quoted 60 lines
Quoted 2 lines
Quoted 56 lines
---
 drivers/gpu/drm/qxl/qxl_drv.c   |  4 ----
 drivers/gpu/drm/qxl/qxl_prime.c | 14 --------------
 2 files changed, 18 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.c +0 -4
index 13c8a662f9..ccb090f3ab 100644
@@ -250,14 +250,10 @@ static struct drm_driver qxl_driver = {
 #if defined(CONFIG_DEBUG_FS)
        .debugfs_init = qxl_debugfs_init,
 #endif
-       .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-       .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
        .gem_prime_export = drm_gem_prime_export,
        .gem_prime_import = drm_gem_prime_import,
        .gem_prime_pin = qxl_gem_prime_pin,
        .gem_prime_unpin = qxl_gem_prime_unpin,
-       .gem_prime_get_sg_table = qxl_gem_prime_get_sg_table,
-       .gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
        .gem_prime_vmap = qxl_gem_prime_vmap,
        .gem_prime_vunmap = qxl_gem_prime_vunmap,
        .gem_prime_mmap = qxl_gem_prime_mmap,
drivers/gpu/drm/qxl/qxl_prime.c +0 -15
index a55dece118..df65d3c1a7 100644
@@ -38,20 +38,6 @@ void qxl_gem_prime_unpin(struct drm_gem_object *obj)
        WARN_ONCE(1, "not implemented");
 }
 
-struct sg_table *qxl_gem_prime_get_sg_table(struct drm_gem_object *obj)
-{
-       WARN_ONCE(1, "not implemented");
-       return ERR_PTR(-ENOSYS);
-}
-
-struct drm_gem_object *qxl_gem_prime_import_sg_table(
-       struct drm_device *dev, struct dma_buf_attachment *attach,
-       struct sg_table *table)
-{
-       WARN_ONCE(1, "not implemented");
-       return ERR_PTR(-ENOSYS);
-}
-
 void *qxl_gem_prime_vmap(struct drm_gem_object *obj)
 {
        WARN_ONCE(1, "not implemented");
--

2.9.3

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

maintainer Reviewed-by on v1 1/1
#10 lore raw
In reply to Gerd Hoffmann
Quoted 6 lines · Gerd Hoffmann

Also set prime_handle_to_fd and prime_fd_to_handle to NULL, so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.

Quoted 56 lines
---
 drivers/gpu/drm/qxl/qxl_drv.c   |  4 ----
 drivers/gpu/drm/qxl/qxl_prime.c | 14 --------------
 2 files changed, 18 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.c +0 -4
index 13c8a662f9..ccb090f3ab 100644
@@ -250,14 +250,10 @@ static struct drm_driver qxl_driver = {
 #if defined(CONFIG_DEBUG_FS)
        .debugfs_init = qxl_debugfs_init,
 #endif
-       .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-       .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
        .gem_prime_export = drm_gem_prime_export,
        .gem_prime_import = drm_gem_prime_import,
        .gem_prime_pin = qxl_gem_prime_pin,
        .gem_prime_unpin = qxl_gem_prime_unpin,
-       .gem_prime_get_sg_table = qxl_gem_prime_get_sg_table,
-       .gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
        .gem_prime_vmap = qxl_gem_prime_vmap,
        .gem_prime_vunmap = qxl_gem_prime_vunmap,
        .gem_prime_mmap = qxl_gem_prime_mmap,
drivers/gpu/drm/qxl/qxl_prime.c +0 -15
index a55dece118..df65d3c1a7 100644
@@ -38,20 +38,6 @@ void qxl_gem_prime_unpin(struct drm_gem_object *obj)
        WARN_ONCE(1, "not implemented");
 }
 
-struct sg_table *qxl_gem_prime_get_sg_table(struct drm_gem_object *obj)
-{
-       WARN_ONCE(1, "not implemented");
-       return ERR_PTR(-ENOSYS);
-}
-
-struct drm_gem_object *qxl_gem_prime_import_sg_table(
-       struct drm_device *dev, struct dma_buf_attachment *attach,
-       struct sg_table *table)
-{
-       WARN_ONCE(1, "not implemented");
-       return ERR_PTR(-ENOSYS);
-}
-
 void *qxl_gem_prime_vmap(struct drm_gem_object *obj)
 {
        WARN_ONCE(1, "not implemented");
--

2.9.3

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