summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2008-11-21 07:54:54 +0100
committerDave Airlie <airlied@redhat.com>2008-11-25 00:28:06 +0100
commit2678d9d6964b29ecd1975870c7a850242b29bc5c (patch)
treebce313afee7ef1eed42c622f7cd0e142e1ca4cdf /drivers/gpu/drm/i915
parentdrm/i915: Avoid BUG_ONs on VT switch with a wedged chipset. (diff)
downloadlinux-2678d9d6964b29ecd1975870c7a850242b29bc5c.tar.xz
linux-2678d9d6964b29ecd1975870c7a850242b29bc5c.zip
drm/i915: Subtract total pinned bytes from available aperture size
The old code was wandering through the active list looking for pinned buffers; there may be other pinned buffers around. Fortunately, we keep a count of the total amount of pinned memory and can use that instead. Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/i915')
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index edc805afde05..6e4c6dd50659 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -85,20 +85,14 @@ int
i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
- drm_i915_private_t *dev_priv = dev->dev_private;
struct drm_i915_gem_get_aperture *args = data;
- struct drm_i915_gem_object *obj_priv;
if (!(dev->driver->driver_features & DRIVER_GEM))
return -ENODEV;
args->aper_size = dev->gtt_total;
- args->aper_available_size = args->aper_size;
-
- list_for_each_entry(obj_priv, &dev_priv->mm.active_list, list) {
- if (obj_priv->pin_count > 0)
- args->aper_available_size -= obj_priv->obj->size;
- }
+ args->aper_available_size = (args->aper_size -
+ atomic_read(&dev->pin_memory));
return 0;
}