diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-02-16 04:56:40 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-03-29 23:53:07 -0400 |
commit | ca9cf68de1e7429e89adb3abdd092d4873e73e29 (patch) | |
tree | 052f119a5906d1756fe989b3082cba1a5de1fd1b /drivers/gpu | |
parent | 882e8cfcbc2157448976c9d37af4fc144949559f (diff) |
drm/ttm: add ttm_bo_init_reserved
This variant of ttm_bo_init returns the validated buffer object with
the reservation lock held when resv == NULL. This is convenient for
callers that want to use the BO immediately, e.g. for initializing its
contents.
Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 9a6dea976f02..412240a3ba90 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -1093,18 +1093,18 @@ int ttm_bo_validate(struct ttm_buffer_object *bo, | |||
1093 | } | 1093 | } |
1094 | EXPORT_SYMBOL(ttm_bo_validate); | 1094 | EXPORT_SYMBOL(ttm_bo_validate); |
1095 | 1095 | ||
1096 | int ttm_bo_init(struct ttm_bo_device *bdev, | 1096 | int ttm_bo_init_reserved(struct ttm_bo_device *bdev, |
1097 | struct ttm_buffer_object *bo, | 1097 | struct ttm_buffer_object *bo, |
1098 | unsigned long size, | 1098 | unsigned long size, |
1099 | enum ttm_bo_type type, | 1099 | enum ttm_bo_type type, |
1100 | struct ttm_placement *placement, | 1100 | struct ttm_placement *placement, |
1101 | uint32_t page_alignment, | 1101 | uint32_t page_alignment, |
1102 | bool interruptible, | 1102 | bool interruptible, |
1103 | struct file *persistent_swap_storage, | 1103 | struct file *persistent_swap_storage, |
1104 | size_t acc_size, | 1104 | size_t acc_size, |
1105 | struct sg_table *sg, | 1105 | struct sg_table *sg, |
1106 | struct reservation_object *resv, | 1106 | struct reservation_object *resv, |
1107 | void (*destroy) (struct ttm_buffer_object *)) | 1107 | void (*destroy) (struct ttm_buffer_object *)) |
1108 | { | 1108 | { |
1109 | int ret = 0; | 1109 | int ret = 0; |
1110 | unsigned long num_pages; | 1110 | unsigned long num_pages; |
@@ -1188,10 +1188,10 @@ int ttm_bo_init(struct ttm_bo_device *bdev, | |||
1188 | if (likely(!ret)) | 1188 | if (likely(!ret)) |
1189 | ret = ttm_bo_validate(bo, placement, interruptible, false); | 1189 | ret = ttm_bo_validate(bo, placement, interruptible, false); |
1190 | 1190 | ||
1191 | if (!resv) | ||
1192 | ttm_bo_unreserve(bo); | ||
1193 | |||
1194 | if (unlikely(ret)) { | 1191 | if (unlikely(ret)) { |
1192 | if (!resv) | ||
1193 | ttm_bo_unreserve(bo); | ||
1194 | |||
1195 | ttm_bo_unref(&bo); | 1195 | ttm_bo_unref(&bo); |
1196 | return ret; | 1196 | return ret; |
1197 | } | 1197 | } |
@@ -1204,6 +1204,35 @@ int ttm_bo_init(struct ttm_bo_device *bdev, | |||
1204 | 1204 | ||
1205 | return ret; | 1205 | return ret; |
1206 | } | 1206 | } |
1207 | EXPORT_SYMBOL(ttm_bo_init_reserved); | ||
1208 | |||
1209 | int ttm_bo_init(struct ttm_bo_device *bdev, | ||
1210 | struct ttm_buffer_object *bo, | ||
1211 | unsigned long size, | ||
1212 | enum ttm_bo_type type, | ||
1213 | struct ttm_placement *placement, | ||
1214 | uint32_t page_alignment, | ||
1215 | bool interruptible, | ||
1216 | struct file *persistent_swap_storage, | ||
1217 | size_t acc_size, | ||
1218 | struct sg_table *sg, | ||
1219 | struct reservation_object *resv, | ||
1220 | void (*destroy) (struct ttm_buffer_object *)) | ||
1221 | { | ||
1222 | int ret; | ||
1223 | |||
1224 | ret = ttm_bo_init_reserved(bdev, bo, size, type, placement, | ||
1225 | page_alignment, interruptible, | ||
1226 | persistent_swap_storage, acc_size, | ||
1227 | sg, resv, destroy); | ||
1228 | if (ret) | ||
1229 | return ret; | ||
1230 | |||
1231 | if (!resv) | ||
1232 | ttm_bo_unreserve(bo); | ||
1233 | |||
1234 | return 0; | ||
1235 | } | ||
1207 | EXPORT_SYMBOL(ttm_bo_init); | 1236 | EXPORT_SYMBOL(ttm_bo_init); |
1208 | 1237 | ||
1209 | size_t ttm_bo_acc_size(struct ttm_bo_device *bdev, | 1238 | size_t ttm_bo_acc_size(struct ttm_bo_device *bdev, |