Skip to content

Commit

Permalink
drm/i915: Subtract total pinned bytes from available aperture size
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Eric Anholt <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
  • Loading branch information
keith-packard authored and airlied committed Nov 24, 2008
1 parent 28dfe52 commit 2678d9d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2678d9d

Please sign in to comment.