diff options
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_context.c | 55 | ||||
-rw-r--r-- | include/drm/i915_drm.h | 15 |
4 files changed, 76 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 3f3aca8c3767..ba75af12f1fd 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -1848,6 +1848,8 @@ struct drm_ioctl_desc i915_ioctls[] = { | |||
1848 | DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_COLORKEY, intel_sprite_set_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), | 1848 | DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_COLORKEY, intel_sprite_set_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
1849 | DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_COLORKEY, intel_sprite_get_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), | 1849 | DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_COLORKEY, intel_sprite_get_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
1850 | DRM_IOCTL_DEF_DRV(I915_GEM_WAIT, i915_gem_wait_ioctl, DRM_AUTH|DRM_UNLOCKED), | 1850 | DRM_IOCTL_DEF_DRV(I915_GEM_WAIT, i915_gem_wait_ioctl, DRM_AUTH|DRM_UNLOCKED), |
1851 | DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_CREATE, i915_gem_context_create_ioctl, DRM_UNLOCKED), | ||
1852 | DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_DESTROY, i915_gem_context_destroy_ioctl, DRM_UNLOCKED), | ||
1851 | }; | 1853 | }; |
1852 | 1854 | ||
1853 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); | 1855 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 6edc02b6dda4..03e7f9e683e3 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -1386,6 +1386,10 @@ void i915_gem_context_open(struct drm_device *dev, struct drm_file *file); | |||
1386 | void i915_gem_context_close(struct drm_device *dev, struct drm_file *file); | 1386 | void i915_gem_context_close(struct drm_device *dev, struct drm_file *file); |
1387 | int i915_switch_context(struct intel_ring_buffer *ring, | 1387 | int i915_switch_context(struct intel_ring_buffer *ring, |
1388 | struct drm_file *file, int to_id); | 1388 | struct drm_file *file, int to_id); |
1389 | int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, | ||
1390 | struct drm_file *file); | ||
1391 | int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, | ||
1392 | struct drm_file *file); | ||
1389 | 1393 | ||
1390 | /* i915_gem_gtt.c */ | 1394 | /* i915_gem_gtt.c */ |
1391 | int __must_check i915_gem_init_aliasing_ppgtt(struct drm_device *dev); | 1395 | int __must_check i915_gem_init_aliasing_ppgtt(struct drm_device *dev); |
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 6a7b67d9f43f..5642c4019b53 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -489,3 +489,58 @@ int i915_switch_context(struct intel_ring_buffer *ring, | |||
489 | drm_gem_object_unreference(&from_obj->base); | 489 | drm_gem_object_unreference(&from_obj->base); |
490 | return ret; | 490 | return ret; |
491 | } | 491 | } |
492 | |||
493 | int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, | ||
494 | struct drm_file *file) | ||
495 | { | ||
496 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
497 | struct drm_i915_gem_context_create *args = data; | ||
498 | struct drm_i915_file_private *file_priv = file->driver_priv; | ||
499 | struct i915_hw_context *ctx; | ||
500 | int ret; | ||
501 | |||
502 | if (!(dev->driver->driver_features & DRIVER_GEM)) | ||
503 | return -ENODEV; | ||
504 | |||
505 | ret = i915_mutex_lock_interruptible(dev); | ||
506 | if (ret) | ||
507 | return ret; | ||
508 | |||
509 | ret = create_hw_context(dev, file_priv, &ctx); | ||
510 | mutex_unlock(&dev->struct_mutex); | ||
511 | |||
512 | args->ctx_id = ctx->id; | ||
513 | DRM_DEBUG_DRIVER("HW context %d created\n", args->ctx_id); | ||
514 | |||
515 | return ret; | ||
516 | } | ||
517 | |||
518 | int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, | ||
519 | struct drm_file *file) | ||
520 | { | ||
521 | struct drm_i915_gem_context_destroy *args = data; | ||
522 | struct drm_i915_file_private *file_priv = file->driver_priv; | ||
523 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
524 | struct i915_hw_context *ctx; | ||
525 | int ret; | ||
526 | |||
527 | if (!(dev->driver->driver_features & DRIVER_GEM)) | ||
528 | return -ENODEV; | ||
529 | |||
530 | ret = i915_mutex_lock_interruptible(dev); | ||
531 | if (ret) | ||
532 | return ret; | ||
533 | |||
534 | ctx = i915_gem_context_get(file_priv, args->ctx_id); | ||
535 | if (!ctx) { | ||
536 | mutex_unlock(&dev->struct_mutex); | ||
537 | return -EINVAL; | ||
538 | } | ||
539 | |||
540 | do_destroy(ctx); | ||
541 | |||
542 | mutex_unlock(&dev->struct_mutex); | ||
543 | |||
544 | DRM_DEBUG_DRIVER("HW context %d destroyed\n", args->ctx_id); | ||
545 | return 0; | ||
546 | } | ||
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h index 5c28ee1d1911..5da73244486a 100644 --- a/include/drm/i915_drm.h +++ b/include/drm/i915_drm.h | |||
@@ -201,6 +201,8 @@ typedef struct _drm_i915_sarea { | |||
201 | #define DRM_I915_GET_SPRITE_COLORKEY 0x2a | 201 | #define DRM_I915_GET_SPRITE_COLORKEY 0x2a |
202 | #define DRM_I915_SET_SPRITE_COLORKEY 0x2b | 202 | #define DRM_I915_SET_SPRITE_COLORKEY 0x2b |
203 | #define DRM_I915_GEM_WAIT 0x2c | 203 | #define DRM_I915_GEM_WAIT 0x2c |
204 | #define DRM_I915_GEM_CONTEXT_CREATE 0x2d | ||
205 | #define DRM_I915_GEM_CONTEXT_DESTROY 0x2e | ||
204 | 206 | ||
205 | #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) | 207 | #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) |
206 | #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) | 208 | #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) |
@@ -245,6 +247,8 @@ typedef struct _drm_i915_sarea { | |||
245 | #define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey) | 247 | #define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey) |
246 | #define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey) | 248 | #define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey) |
247 | #define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait) | 249 | #define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait) |
250 | #define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create) | ||
251 | #define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy) | ||
248 | 252 | ||
249 | /* Allow drivers to submit batchbuffers directly to hardware, relying | 253 | /* Allow drivers to submit batchbuffers directly to hardware, relying |
250 | * on the security mechanisms provided by hardware. | 254 | * on the security mechanisms provided by hardware. |
@@ -897,4 +901,15 @@ struct drm_i915_gem_wait { | |||
897 | __s64 timeout_ns; | 901 | __s64 timeout_ns; |
898 | }; | 902 | }; |
899 | 903 | ||
904 | struct drm_i915_gem_context_create { | ||
905 | /* output: id of new context*/ | ||
906 | __u32 ctx_id; | ||
907 | __u32 pad; | ||
908 | }; | ||
909 | |||
910 | struct drm_i915_gem_context_destroy { | ||
911 | __u32 ctx_id; | ||
912 | __u32 pad; | ||
913 | }; | ||
914 | |||
900 | #endif /* _I915_DRM_H_ */ | 915 | #endif /* _I915_DRM_H_ */ |