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 | |
| 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>
| -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 | ||||
| -rw-r--r-- | include/drm/i915_drm.h | 13 |
4 files changed, 38 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. |
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h index eb4b35031a55..152b34da927c 100644 --- a/include/drm/i915_drm.h +++ b/include/drm/i915_drm.h | |||
| @@ -159,6 +159,7 @@ typedef struct _drm_i915_sarea { | |||
| 159 | #define DRM_I915_GEM_SW_FINISH 0x20 | 159 | #define DRM_I915_GEM_SW_FINISH 0x20 |
| 160 | #define DRM_I915_GEM_SET_TILING 0x21 | 160 | #define DRM_I915_GEM_SET_TILING 0x21 |
| 161 | #define DRM_I915_GEM_GET_TILING 0x22 | 161 | #define DRM_I915_GEM_GET_TILING 0x22 |
| 162 | #define DRM_I915_GEM_GET_APERTURE 0x23 | ||
| 162 | 163 | ||
| 163 | #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) | 164 | #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) |
| 164 | #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) | 165 | #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) |
| @@ -190,6 +191,7 @@ typedef struct _drm_i915_sarea { | |||
| 190 | #define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish) | 191 | #define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish) |
| 191 | #define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling) | 192 | #define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling) |
| 192 | #define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling) | 193 | #define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling) |
| 194 | #define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture) | ||
| 193 | 195 | ||
| 194 | /* Allow drivers to submit batchbuffers directly to hardware, relying | 196 | /* Allow drivers to submit batchbuffers directly to hardware, relying |
| 195 | * on the security mechanisms provided by hardware. | 197 | * on the security mechanisms provided by hardware. |
| @@ -600,4 +602,15 @@ struct drm_i915_gem_get_tiling { | |||
| 600 | uint32_t swizzle_mode; | 602 | uint32_t swizzle_mode; |
| 601 | }; | 603 | }; |
| 602 | 604 | ||
| 605 | struct drm_i915_gem_get_aperture { | ||
| 606 | /** Total size of the aperture used by i915_gem_execbuffer, in bytes */ | ||
| 607 | uint64_t aper_size; | ||
| 608 | |||
| 609 | /** | ||
| 610 | * Available space in the aperture used by i915_gem_execbuffer, in | ||
| 611 | * bytes | ||
| 612 | */ | ||
| 613 | uint64_t aper_available_size; | ||
| 614 | }; | ||
| 615 | |||
| 603 | #endif /* _I915_DRM_H_ */ | 616 | #endif /* _I915_DRM_H_ */ |
