diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-08-05 10:01:03 -0400 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-08-06 02:21:53 -0400 |
commit | 8eb8833e7ed362977c021116d2f34451a7009ca3 (patch) | |
tree | 2a82f703f978a4611e35955a83da4f5b04767b09 /include/drm/ttm | |
parent | e7642f35851da14b78be7a38b0bb0d4068254859 (diff) |
drm/ttm: add gem base object
Add drm_gem_object struct to ttm_buffer_object, so ttm objects are a gdm
object superclass. Add a function to check whenever a given bo actually
uses the embedded drm_gem_object.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20190805140119.7337-2-kraxel@redhat.com
Diffstat (limited to 'include/drm/ttm')
-rw-r--r-- | include/drm/ttm/ttm_bo_api.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 49d9cdfc58f2..082550cac92c 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h | |||
@@ -31,6 +31,7 @@ | |||
31 | #ifndef _TTM_BO_API_H_ | 31 | #ifndef _TTM_BO_API_H_ |
32 | #define _TTM_BO_API_H_ | 32 | #define _TTM_BO_API_H_ |
33 | 33 | ||
34 | #include <drm/drm_gem.h> | ||
34 | #include <drm/drm_hashtab.h> | 35 | #include <drm/drm_hashtab.h> |
35 | #include <drm/drm_vma_manager.h> | 36 | #include <drm/drm_vma_manager.h> |
36 | #include <linux/kref.h> | 37 | #include <linux/kref.h> |
@@ -127,6 +128,7 @@ struct ttm_tt; | |||
127 | /** | 128 | /** |
128 | * struct ttm_buffer_object | 129 | * struct ttm_buffer_object |
129 | * | 130 | * |
131 | * @base: drm_gem_object superclass data. | ||
130 | * @bdev: Pointer to the buffer object device structure. | 132 | * @bdev: Pointer to the buffer object device structure. |
131 | * @type: The bo type. | 133 | * @type: The bo type. |
132 | * @destroy: Destruction function. If NULL, kfree is used. | 134 | * @destroy: Destruction function. If NULL, kfree is used. |
@@ -169,6 +171,8 @@ struct ttm_tt; | |||
169 | */ | 171 | */ |
170 | 172 | ||
171 | struct ttm_buffer_object { | 173 | struct ttm_buffer_object { |
174 | struct drm_gem_object base; | ||
175 | |||
172 | /** | 176 | /** |
173 | * Members constant at init. | 177 | * Members constant at init. |
174 | */ | 178 | */ |
@@ -768,4 +772,23 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, | |||
768 | struct ttm_operation_ctx *ctx); | 772 | struct ttm_operation_ctx *ctx); |
769 | void ttm_bo_swapout_all(struct ttm_bo_device *bdev); | 773 | void ttm_bo_swapout_all(struct ttm_bo_device *bdev); |
770 | int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo); | 774 | int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo); |
775 | |||
776 | /** | ||
777 | * ttm_bo_uses_embedded_gem_object - check if the given bo uses the | ||
778 | * embedded drm_gem_object. | ||
779 | * | ||
780 | * Most ttm drivers are using gem too, so the embedded | ||
781 | * ttm_buffer_object.base will be initialized by the driver (before | ||
782 | * calling ttm_bo_init). It is also possible to use ttm without gem | ||
783 | * though (vmwgfx does that). | ||
784 | * | ||
785 | * This helper will figure whenever a given ttm bo is a gem object too | ||
786 | * or not. | ||
787 | * | ||
788 | * @bo: The bo to check. | ||
789 | */ | ||
790 | static inline bool ttm_bo_uses_embedded_gem_object(struct ttm_buffer_object *bo) | ||
791 | { | ||
792 | return bo->base.dev != NULL; | ||
793 | } | ||
771 | #endif | 794 | #endif |