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

drm/vmwgfx: Make use of PFN_ALIGN/PFN_UP helper macro

it's a refactor to make use of PFN_ALIGN/PFN_UP helper macro

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Signed-off-by: Zack Rusin <zackr@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210802033308.927-1-caihuoqing@baidu.com

authored by

Cai Huoqing and committed by
Zack Rusin
bc65754c 2bc5da52

+9 -14
+2 -3
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
··· 405 405 bool user) 406 406 { 407 407 static size_t struct_size, user_struct_size; 408 - size_t num_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; 408 + size_t num_pages = PFN_UP(size); 409 409 size_t page_array_size = ttm_round_pot(num_pages * sizeof(void *)); 410 410 411 411 if (unlikely(struct_size == 0)) { ··· 474 474 struct ttm_placement *placement, 475 475 struct ttm_buffer_object **p_bo) 476 476 { 477 - unsigned npages = PAGE_ALIGN(size) >> PAGE_SHIFT; 478 477 struct ttm_operation_ctx ctx = { false, false }; 479 478 struct ttm_buffer_object *bo; 480 479 size_t acc_size; ··· 484 485 return -ENOMEM; 485 486 486 487 acc_size = ttm_round_pot(sizeof(*bo)); 487 - acc_size += ttm_round_pot(npages * sizeof(void *)); 488 + acc_size += ttm_round_pot(PFN_UP(size) * sizeof(void *)); 488 489 acc_size += ttm_round_pot(sizeof(struct ttm_tt)); 489 490 490 491 ret = ttm_mem_global_alloc(&ttm_mem_glob, acc_size, &ctx);
+1 -1
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
··· 801 801 { 802 802 struct vmw_cmdbuf_alloc_info info; 803 803 804 - info.page_size = PAGE_ALIGN(size) >> PAGE_SHIFT; 804 + info.page_size = PFN_UP(size); 805 805 info.node = node; 806 806 info.done = false; 807 807
+1 -2
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
··· 607 607 if (num_entries < co_info[type].min_initial_entries) { 608 608 vcotbl->res.backup_size = co_info[type].min_initial_entries * 609 609 co_info[type].size; 610 - vcotbl->res.backup_size = 611 - (vcotbl->res.backup_size + PAGE_SIZE - 1) & PAGE_MASK; 610 + vcotbl->res.backup_size = PFN_ALIGN(vcotbl->res.backup_size); 612 611 } 613 612 614 613 vcotbl->scrubbed = true;
+1 -1
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
··· 100 100 int ret; 101 101 102 102 kmap_offset = 0; 103 - kmap_num = (width*height*4 + PAGE_SIZE - 1) >> PAGE_SHIFT; 103 + kmap_num = PFN_UP(width*height*4); 104 104 105 105 ret = ttm_bo_reserve(&bo->base, true, false, NULL); 106 106 if (unlikely(ret != 0)) {
+2 -3
drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
··· 256 256 if (!otables[i].enabled) 257 257 continue; 258 258 259 - otables[i].size = 260 - (otables[i].size + PAGE_SIZE - 1) & PAGE_MASK; 259 + otables[i].size = PFN_ALIGN(otables[i].size); 261 260 bo_size += otables[i].size; 262 261 } 263 262 ··· 384 385 while (likely(data_size > PAGE_SIZE)) { 385 386 data_size = DIV_ROUND_UP(data_size, PAGE_SIZE); 386 387 data_size *= VMW_PPN_SIZE; 387 - tot_size += (data_size + PAGE_SIZE - 1) & PAGE_MASK; 388 + tot_size += PFN_ALIGN(data_size); 388 389 } 389 390 390 391 return tot_size >> PAGE_SHIFT;
+1 -2
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
··· 353 353 static int vmw_resource_buf_alloc(struct vmw_resource *res, 354 354 bool interruptible) 355 355 { 356 - unsigned long size = 357 - (res->backup_size + PAGE_SIZE - 1) & PAGE_MASK; 356 + unsigned long size = PFN_ALIGN(res->backup_size); 358 357 struct vmw_buffer_object *backup; 359 358 int ret; 360 359
+1 -2
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
··· 981 981 goto no_reserve; 982 982 983 983 /* Map and copy shader bytecode. */ 984 - ret = ttm_bo_kmap(&buf->base, 0, PAGE_ALIGN(size) >> PAGE_SHIFT, 985 - &map); 984 + ret = ttm_bo_kmap(&buf->base, 0, PFN_UP(size), &map); 986 985 if (unlikely(ret != 0)) { 987 986 ttm_bo_unreserve(&buf->base); 988 987 goto no_reserve;