diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-06-07 10:38:42 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-09-20 08:22:55 -0400 |
commit | 37e680a15ff6375ff02773161f817e90a38c51f7 (patch) | |
tree | d1b6fae7751c04ce051016019b4d4ebd0ee0d48c /drivers/gpu/drm/i915/i915_drv.h | |
parent | 8c0bd3c02d52eff11396e81b4d217ee668e03528 (diff) |
drm/i915: Introduce drm_i915_gem_object_ops
In order to specialise functions depending upon the type of object, we
can attach vfuncs to each object via a new ->ops pointer.
For instance, this will be used in future patches to only bind pages from
a dma-buf for the duration that the object is used by the GPU - and so
prevent them from pinning those pages for the entire of the object.
v2: Bonus comments.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_drv.h')
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 26c6959a524a..ada8ea172d05 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -899,9 +899,29 @@ enum i915_cache_level { | |||
899 | I915_CACHE_LLC_MLC, /* gen6+, in docs at least! */ | 899 | I915_CACHE_LLC_MLC, /* gen6+, in docs at least! */ |
900 | }; | 900 | }; |
901 | 901 | ||
902 | struct drm_i915_gem_object_ops { | ||
903 | /* Interface between the GEM object and its backing storage. | ||
904 | * get_pages() is called once prior to the use of the associated set | ||
905 | * of pages before to binding them into the GTT, and put_pages() is | ||
906 | * called after we no longer need them. As we expect there to be | ||
907 | * associated cost with migrating pages between the backing storage | ||
908 | * and making them available for the GPU (e.g. clflush), we may hold | ||
909 | * onto the pages after they are no longer referenced by the GPU | ||
910 | * in case they may be used again shortly (for example migrating the | ||
911 | * pages to a different memory domain within the GTT). put_pages() | ||
912 | * will therefore most likely be called when the object itself is | ||
913 | * being released or under memory pressure (where we attempt to | ||
914 | * reap pages for the shrinker). | ||
915 | */ | ||
916 | int (*get_pages)(struct drm_i915_gem_object *); | ||
917 | void (*put_pages)(struct drm_i915_gem_object *); | ||
918 | }; | ||
919 | |||
902 | struct drm_i915_gem_object { | 920 | struct drm_i915_gem_object { |
903 | struct drm_gem_object base; | 921 | struct drm_gem_object base; |
904 | 922 | ||
923 | const struct drm_i915_gem_object_ops *ops; | ||
924 | |||
905 | /** Current space allocated to this object in the GTT, if any. */ | 925 | /** Current space allocated to this object in the GTT, if any. */ |
906 | struct drm_mm_node *gtt_space; | 926 | struct drm_mm_node *gtt_space; |
907 | struct list_head gtt_list; | 927 | struct list_head gtt_list; |
@@ -1306,7 +1326,8 @@ int i915_gem_wait_ioctl(struct drm_device *dev, void *data, | |||
1306 | struct drm_file *file_priv); | 1326 | struct drm_file *file_priv); |
1307 | void i915_gem_load(struct drm_device *dev); | 1327 | void i915_gem_load(struct drm_device *dev); |
1308 | int i915_gem_init_object(struct drm_gem_object *obj); | 1328 | int i915_gem_init_object(struct drm_gem_object *obj); |
1309 | void i915_gem_object_init(struct drm_i915_gem_object *obj); | 1329 | void i915_gem_object_init(struct drm_i915_gem_object *obj, |
1330 | const struct drm_i915_gem_object_ops *ops); | ||
1310 | struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, | 1331 | struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, |
1311 | size_t size); | 1332 | size_t size); |
1312 | void i915_gem_free_object(struct drm_gem_object *obj); | 1333 | void i915_gem_free_object(struct drm_gem_object *obj); |
@@ -1319,7 +1340,7 @@ int __must_check i915_gem_object_unbind(struct drm_i915_gem_object *obj); | |||
1319 | void i915_gem_release_mmap(struct drm_i915_gem_object *obj); | 1340 | void i915_gem_release_mmap(struct drm_i915_gem_object *obj); |
1320 | void i915_gem_lastclose(struct drm_device *dev); | 1341 | void i915_gem_lastclose(struct drm_device *dev); |
1321 | 1342 | ||
1322 | int __must_check i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj); | 1343 | int __must_check i915_gem_object_get_pages(struct drm_i915_gem_object *obj); |
1323 | int __must_check i915_mutex_lock_interruptible(struct drm_device *dev); | 1344 | int __must_check i915_mutex_lock_interruptible(struct drm_device *dev); |
1324 | int i915_gem_object_sync(struct drm_i915_gem_object *obj, | 1345 | int i915_gem_object_sync(struct drm_i915_gem_object *obj, |
1325 | struct intel_ring_buffer *to); | 1346 | struct intel_ring_buffer *to); |