diff options
author | Eric Anholt <eric@anholt.net> | 2008-10-23 00:40:13 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2008-11-02 19:56:49 -0500 |
commit | 5a125c3c79167e78ba44efef03af7090ef28eeaf (patch) | |
tree | b8c3a9e44ea44b7afc821c0422a7ea6360814f03 /drivers | |
parent | 4e270e9b8a9d246290f3901f1fb6c5efdb734ddf (diff) |
i915: Add GEM ioctl to get available aperture size.
This will let userland know when to submit its batchbuffers, before they get
too big to fit in the aperture.
Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 22 |
3 files changed, 25 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 01de536e0211..256e22963ae4 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -960,6 +960,7 @@ struct drm_ioctl_desc i915_ioctls[] = { | |||
960 | DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, 0), | 960 | DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, 0), |
961 | DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0), | 961 | DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0), |
962 | DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0), | 962 | DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0), |
963 | DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0), | ||
963 | }; | 964 | }; |
964 | 965 | ||
965 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); | 966 | 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 901e80cf5813..cc8a9f3f7a60 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -502,6 +502,8 @@ int i915_gem_set_tiling(struct drm_device *dev, void *data, | |||
502 | struct drm_file *file_priv); | 502 | struct drm_file *file_priv); |
503 | int i915_gem_get_tiling(struct drm_device *dev, void *data, | 503 | int i915_gem_get_tiling(struct drm_device *dev, void *data, |
504 | struct drm_file *file_priv); | 504 | struct drm_file *file_priv); |
505 | int i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, | ||
506 | struct drm_file *file_priv); | ||
505 | void i915_gem_load(struct drm_device *dev); | 507 | void i915_gem_load(struct drm_device *dev); |
506 | int i915_gem_proc_init(struct drm_minor *minor); | 508 | int i915_gem_proc_init(struct drm_minor *minor); |
507 | void i915_gem_proc_cleanup(struct drm_minor *minor); | 509 | void i915_gem_proc_cleanup(struct drm_minor *minor); |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 17ae330ff269..c1733ac4a7f5 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -79,6 +79,28 @@ i915_gem_init_ioctl(struct drm_device *dev, void *data, | |||
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
81 | 81 | ||
82 | int | ||
83 | i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, | ||
84 | struct drm_file *file_priv) | ||
85 | { | ||
86 | drm_i915_private_t *dev_priv = dev->dev_private; | ||
87 | struct drm_i915_gem_get_aperture *args = data; | ||
88 | struct drm_i915_gem_object *obj_priv; | ||
89 | |||
90 | if (!(dev->driver->driver_features & DRIVER_GEM)) | ||
91 | return -ENODEV; | ||
92 | |||
93 | args->aper_size = dev->gtt_total; | ||
94 | args->aper_available_size = args->aper_size; | ||
95 | |||
96 | list_for_each_entry(obj_priv, &dev_priv->mm.active_list, list) { | ||
97 | if (obj_priv->pin_count > 0) | ||
98 | args->aper_available_size -= obj_priv->obj->size; | ||
99 | } | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | |||
82 | 104 | ||
83 | /** | 105 | /** |
84 | * Creates a new mm object and returns a handle to it. | 106 | * Creates a new mm object and returns a handle to it. |