[PATCH 07/19] drm: initial multiple nodes ioctl work.
Ilija Hadzic
ihadzic at research.bell-labs.com
Thu Apr 12 11:19:32 PDT 2012
From: Dave Airlie <airlied at redhat.com>
just adds some unchecked ioctls to setup the nodes.
Signed-off-by: Dave Airlie <airlied at redhat.com>
v2: - original ioctl numbers are now taken, use next available
- resolve some trivial conflicts due to bit-rot that
occurred since the original patch was created
v3: - added planes to ABI to address a comment from Ville Syrjala
Signed-off-by: Ilija Hadzic <ihadzic at research.bell-labs.com>
---
drivers/gpu/drm/drm_drv.c | 4 ++-
drivers/gpu/drm/drm_stub.c | 56 ++++++++++++++++++++++++++++++++++++++++++++
include/drm/drm.h | 3 ++
include/drm/drmP.h | 6 ++++
include/drm/drm_mode.h | 15 +++++++++++
5 files changed, 83 insertions(+), 1 deletions(-)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index a4d7d44..dd04322 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -159,7 +159,9 @@ static struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_MODE_DIRTYFB, drm_mode_dirtyfb_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_DUMB, drm_mode_create_dumb_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_MAP_DUMB, drm_mode_mmap_dumb_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_IOCTL_MODE_DESTROY_DUMB, drm_mode_destroy_dumb_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED)
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_DESTROY_DUMB, drm_mode_destroy_dumb_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_RENDER_NODE_CREATE, drm_render_node_create_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_RENDER_NODE_REMOVE, drm_render_node_remove_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED)
};
#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 53033d3..5ef0e46 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -522,3 +522,59 @@ void drm_put_dev(struct drm_device *dev)
kfree(dev);
}
EXPORT_SYMBOL(drm_put_dev);
+
+int drm_render_node_create_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_render_node_create *args = data;
+ int ret;
+ struct drm_minor *new_minor;
+ int total_ids, i;
+ uint32_t __user *ids_ptr;
+ ret = drm_create_minor_render(dev, &new_minor);
+ if (ret)
+ goto out;
+
+ args->node_minor_id = new_minor->index;
+
+ if (args->num_crtc == 0 && args->num_encoder == 0 &&
+ args->num_connector == 0 && args->num_plane == 0)
+ goto out;
+ if (args->num_crtc == 0 ||
+ args->num_encoder == 0 ||
+ args->num_connector == 0) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = drm_mode_group_init(dev, &new_minor->mode_group);
+ if (ret)
+ goto out;
+
+ ids_ptr = (uint32_t __user *)(unsigned long)args->id_list_ptr;
+ total_ids = args->num_crtc + args->num_encoder +
+ args->num_connector + args->num_plane;
+ for (i = 0; i < total_ids; i++) {
+ if (get_user(new_minor->mode_group.id_list[i], &ids_ptr[i])) {
+ ret = -EFAULT;
+ goto out_put;
+ }
+ }
+out_put:
+ drm_put_minor(&new_minor);
+out:
+ return ret;
+}
+
+int drm_render_node_remove_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_render_node_remove *args = data;
+ struct drm_minor *del_minor, *tmp;
+
+ list_for_each_entry_safe(del_minor, tmp, &dev->render_minor_list, render_node_list) {
+ if (del_minor->index == args->node_minor_id)
+ drm_put_minor(&del_minor);
+ }
+ return 0;
+}
diff --git a/include/drm/drm.h b/include/drm/drm.h
index 34a7b89..d2a893b 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -639,6 +639,9 @@ struct drm_get_cap {
#define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open)
#define DRM_IOCTL_GET_CAP DRM_IOWR(0x0c, struct drm_get_cap)
+#define DRM_IOCTL_RENDER_NODE_CREATE DRM_IOWR(0x0d, struct drm_render_node_create)
+#define DRM_IOCTL_RENDER_NODE_REMOVE DRM_IOWR(0x0e, struct drm_render_node_remove)
+
#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, struct drm_unique)
#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, struct drm_auth)
#define DRM_IOCTL_BLOCK DRM_IOWR(0x12, struct drm_block)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d9eee26..3bc5c71 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1458,6 +1458,12 @@ extern void drm_master_put(struct drm_master **master);
extern void drm_put_dev(struct drm_device *dev);
extern int drm_put_minor(struct drm_minor **minor);
+
+extern int drm_render_node_create_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+extern int drm_render_node_remove_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+
extern unsigned int drm_debug;
extern unsigned int drm_vblank_offdelay;
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index 2a2acda..c9b9fc1 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -441,4 +441,19 @@ struct drm_mode_destroy_dumb {
uint32_t handle;
};
+/* render node create and remove functions
+ if crtc/encoders/connectors/planes all == 0 then gpgpu node */
+struct drm_render_node_create {
+ __u32 node_minor_id;
+ __u32 num_crtc;
+ __u32 num_encoder;
+ __u32 num_connector;
+ __u32 num_plane;
+ __u64 id_list_ptr;
+};
+
+struct drm_render_node_remove {
+ __u32 node_minor_id;
+};
+
#endif
--
1.7.8.5
More information about the dri-devel
mailing list