Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: use amdgpu_bo_user bo for metadata and tiling flag

Tiling flag and metadata are only needed for BOs created by
amdgpu_gem_object_create(), so we can remove those from the
base class.

v2: * squash tiling_flags and metadata relared patches into one
* use BUG_ON for non ttm_bo_type_device type when accessing
tiling_flags and metadata._
v3: *include to_amdgpu_bo_user

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Nirmoy Das and committed by
Alex Deucher
cc1bcf85 22b40f7a

+35 -22
-2
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
··· 499 499 *dma_buf_kgd = (struct kgd_dev *)adev; 500 500 if (bo_size) 501 501 *bo_size = amdgpu_bo_size(bo); 502 - if (metadata_size) 503 - *metadata_size = bo->metadata_size; 504 502 if (metadata_buffer) 505 503 r = amdgpu_bo_get_metadata(bo, metadata_buffer, buffer_size, 506 504 metadata_size, &metadata_flags);
+35 -16
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 77 77 { 78 78 struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); 79 79 struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo); 80 + struct amdgpu_bo_user *ubo; 80 81 81 82 if (bo->tbo.pin_count > 0) 82 83 amdgpu_bo_subtract_pin_size(bo); ··· 95 94 } 96 95 amdgpu_bo_unref(&bo->parent); 97 96 98 - kfree(bo->metadata); 97 + if (bo->tbo.type == ttm_bo_type_device) { 98 + ubo = to_amdgpu_bo_user(bo); 99 + kfree(ubo->metadata); 100 + } 101 + 99 102 kfree(bo); 100 103 } 101 104 ··· 1162 1157 int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags) 1163 1158 { 1164 1159 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); 1160 + struct amdgpu_bo_user *ubo; 1165 1161 1162 + BUG_ON(bo->tbo.type != ttm_bo_type_device); 1166 1163 if (adev->family <= AMDGPU_FAMILY_CZ && 1167 1164 AMDGPU_TILING_GET(tiling_flags, TILE_SPLIT) > 6) 1168 1165 return -EINVAL; 1169 1166 1170 - bo->tiling_flags = tiling_flags; 1167 + ubo = to_amdgpu_bo_user(bo); 1168 + ubo->tiling_flags = tiling_flags; 1171 1169 return 0; 1172 1170 } 1173 1171 ··· 1184 1176 */ 1185 1177 void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 *tiling_flags) 1186 1178 { 1179 + struct amdgpu_bo_user *ubo; 1180 + 1181 + BUG_ON(bo->tbo.type != ttm_bo_type_device); 1187 1182 dma_resv_assert_held(bo->tbo.base.resv); 1183 + ubo = to_amdgpu_bo_user(bo); 1188 1184 1189 1185 if (tiling_flags) 1190 - *tiling_flags = bo->tiling_flags; 1186 + *tiling_flags = ubo->tiling_flags; 1191 1187 } 1192 1188 1193 1189 /** ··· 1210 1198 int amdgpu_bo_set_metadata (struct amdgpu_bo *bo, void *metadata, 1211 1199 uint32_t metadata_size, uint64_t flags) 1212 1200 { 1201 + struct amdgpu_bo_user *ubo; 1213 1202 void *buffer; 1214 1203 1204 + BUG_ON(bo->tbo.type != ttm_bo_type_device); 1205 + ubo = to_amdgpu_bo_user(bo); 1215 1206 if (!metadata_size) { 1216 - if (bo->metadata_size) { 1217 - kfree(bo->metadata); 1218 - bo->metadata = NULL; 1219 - bo->metadata_size = 0; 1207 + if (ubo->metadata_size) { 1208 + kfree(ubo->metadata); 1209 + ubo->metadata = NULL; 1210 + ubo->metadata_size = 0; 1220 1211 } 1221 1212 return 0; 1222 1213 } ··· 1231 1216 if (buffer == NULL) 1232 1217 return -ENOMEM; 1233 1218 1234 - kfree(bo->metadata); 1235 - bo->metadata_flags = flags; 1236 - bo->metadata = buffer; 1237 - bo->metadata_size = metadata_size; 1219 + kfree(ubo->metadata); 1220 + ubo->metadata_flags = flags; 1221 + ubo->metadata = buffer; 1222 + ubo->metadata_size = metadata_size; 1238 1223 1239 1224 return 0; 1240 1225 } ··· 1258 1243 size_t buffer_size, uint32_t *metadata_size, 1259 1244 uint64_t *flags) 1260 1245 { 1246 + struct amdgpu_bo_user *ubo; 1247 + 1261 1248 if (!buffer && !metadata_size) 1262 1249 return -EINVAL; 1263 1250 1251 + BUG_ON(bo->tbo.type != ttm_bo_type_device); 1252 + ubo = to_amdgpu_bo_user(bo); 1264 1253 if (buffer) { 1265 - if (buffer_size < bo->metadata_size) 1254 + if (buffer_size < ubo->metadata_size) 1266 1255 return -EINVAL; 1267 1256 1268 - if (bo->metadata_size) 1269 - memcpy(buffer, bo->metadata, bo->metadata_size); 1257 + if (ubo->metadata_size) 1258 + memcpy(buffer, ubo->metadata, ubo->metadata_size); 1270 1259 } 1271 1260 1272 1261 if (metadata_size) 1273 - *metadata_size = bo->metadata_size; 1262 + *metadata_size = ubo->metadata_size; 1274 1263 if (flags) 1275 - *flags = bo->metadata_flags; 1264 + *flags = ubo->metadata_flags; 1276 1265 1277 1266 return 0; 1278 1267 }
-4
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
··· 92 92 struct ttm_buffer_object tbo; 93 93 struct ttm_bo_kmap_obj kmap; 94 94 u64 flags; 95 - u64 tiling_flags; 96 - u64 metadata_flags; 97 - void *metadata; 98 - u32 metadata_size; 99 95 unsigned prime_shared_count; 100 96 /* per VM structure for page tables and with virtual addresses */ 101 97 struct amdgpu_vm_bo_base *vm_bo;