diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-12-24 11:13:40 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-01-07 12:19:06 -0500 |
commit | c9dc0f35986c0e2fc81e0b71ddc7e3adad733829 (patch) | |
tree | d59a7dc0157916e519d9aa04527f85eea670cec5 /drivers/gpu/drm/i915 | |
parent | f9b61ff6bce9a44555324b29e593fdffc9a115bc (diff) |
drm/i915: Add ioctl to set per-context parameters
Sometimes we wish to tweak how an individual context behaves. Since we
always create a context for every filp, this means that individual
processes can fine tune their behaviour even if they do not explicitly
create a context.
The first example parameter here is to enable multi-process GPU testing,
but the interface should be able to cope with passing arbitrarily complex
parameters.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
Testcase: igt/gem_reset_stats/ban-period-*
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915')
-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 | 69 |
3 files changed, 75 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 7fad6b8ac63a..8cbff3010e1c 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -1066,6 +1066,8 @@ const struct drm_ioctl_desc i915_ioctls[] = { | |||
1066 | DRM_IOCTL_DEF_DRV(I915_REG_READ, i915_reg_read_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), | 1066 | DRM_IOCTL_DEF_DRV(I915_REG_READ, i915_reg_read_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), |
1067 | DRM_IOCTL_DEF_DRV(I915_GET_RESET_STATS, i915_get_reset_stats_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), | 1067 | DRM_IOCTL_DEF_DRV(I915_GET_RESET_STATS, i915_get_reset_stats_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), |
1068 | DRM_IOCTL_DEF_DRV(I915_GEM_USERPTR, i915_gem_userptr_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), | 1068 | DRM_IOCTL_DEF_DRV(I915_GEM_USERPTR, i915_gem_userptr_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), |
1069 | DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_GETPARAM, i915_gem_context_getparam_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), | ||
1070 | DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_SETPARAM, i915_gem_context_setparam_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), | ||
1069 | }; | 1071 | }; |
1070 | 1072 | ||
1071 | int i915_max_ioctl = ARRAY_SIZE(i915_ioctls); | 1073 | int i915_max_ioctl = ARRAY_SIZE(i915_ioctls); |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index ee841349407e..71016f5192c5 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -2898,6 +2898,10 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, | |||
2898 | struct drm_file *file); | 2898 | struct drm_file *file); |
2899 | int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, | 2899 | int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, |
2900 | struct drm_file *file); | 2900 | struct drm_file *file); |
2901 | int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data, | ||
2902 | struct drm_file *file_priv); | ||
2903 | int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data, | ||
2904 | struct drm_file *file_priv); | ||
2901 | 2905 | ||
2902 | /* i915_gem_evict.c */ | 2906 | /* i915_gem_evict.c */ |
2903 | int __must_check i915_gem_evict_something(struct drm_device *dev, | 2907 | int __must_check i915_gem_evict_something(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 1d10c21f979b..b775ed4a189c 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -762,3 +762,72 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, | |||
762 | DRM_DEBUG_DRIVER("HW context %d destroyed\n", args->ctx_id); | 762 | DRM_DEBUG_DRIVER("HW context %d destroyed\n", args->ctx_id); |
763 | return 0; | 763 | return 0; |
764 | } | 764 | } |
765 | |||
766 | int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data, | ||
767 | struct drm_file *file) | ||
768 | { | ||
769 | struct drm_i915_file_private *file_priv = file->driver_priv; | ||
770 | struct drm_i915_gem_context_param *args = data; | ||
771 | struct intel_context *ctx; | ||
772 | int ret; | ||
773 | |||
774 | ret = i915_mutex_lock_interruptible(dev); | ||
775 | if (ret) | ||
776 | return ret; | ||
777 | |||
778 | ctx = i915_gem_context_get(file_priv, args->ctx_id); | ||
779 | if (IS_ERR(ctx)) { | ||
780 | mutex_unlock(&dev->struct_mutex); | ||
781 | return PTR_ERR(ctx); | ||
782 | } | ||
783 | |||
784 | args->size = 0; | ||
785 | switch (args->param) { | ||
786 | case I915_CONTEXT_PARAM_BAN_PERIOD: | ||
787 | args->value = ctx->hang_stats.ban_period_seconds; | ||
788 | break; | ||
789 | default: | ||
790 | ret = -EINVAL; | ||
791 | break; | ||
792 | } | ||
793 | mutex_unlock(&dev->struct_mutex); | ||
794 | |||
795 | return ret; | ||
796 | } | ||
797 | |||
798 | int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data, | ||
799 | struct drm_file *file) | ||
800 | { | ||
801 | struct drm_i915_file_private *file_priv = file->driver_priv; | ||
802 | struct drm_i915_gem_context_param *args = data; | ||
803 | struct intel_context *ctx; | ||
804 | int ret; | ||
805 | |||
806 | ret = i915_mutex_lock_interruptible(dev); | ||
807 | if (ret) | ||
808 | return ret; | ||
809 | |||
810 | ctx = i915_gem_context_get(file_priv, args->ctx_id); | ||
811 | if (IS_ERR(ctx)) { | ||
812 | mutex_unlock(&dev->struct_mutex); | ||
813 | return PTR_ERR(ctx); | ||
814 | } | ||
815 | |||
816 | switch (args->param) { | ||
817 | case I915_CONTEXT_PARAM_BAN_PERIOD: | ||
818 | if (args->size) | ||
819 | ret = -EINVAL; | ||
820 | else if (args->value < ctx->hang_stats.ban_period_seconds && | ||
821 | !capable(CAP_SYS_ADMIN)) | ||
822 | ret = -EPERM; | ||
823 | else | ||
824 | ctx->hang_stats.ban_period_seconds = args->value; | ||
825 | break; | ||
826 | default: | ||
827 | ret = -EINVAL; | ||
828 | break; | ||
829 | } | ||
830 | mutex_unlock(&dev->struct_mutex); | ||
831 | |||
832 | return ret; | ||
833 | } | ||