treewide: Use util_is_power_of_two_nonzero{64|_uintptr} when needed

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26909>
This commit is contained in:
Yonggang Luo
2024-01-04 10:51:17 +08:00
committed by Marge Bot
parent c1d6d745cf
commit 0b9c96562b
10 changed files with 14 additions and 14 deletions

View File

@@ -1004,7 +1004,7 @@ nir_udiv_imm(nir_builder *build, nir_def *x, uint64_t y)
if (y == 1) {
return x;
} else if (util_is_power_of_two_nonzero(y)) {
} else if (util_is_power_of_two_nonzero64(y)) {
return nir_ushr_imm(build, x, ffsll(y) - 1);
} else {
return nir_udiv(build, x, nir_imm_intN_t(build, y, x->bit_size));
@@ -1016,7 +1016,7 @@ nir_umod_imm(nir_builder *build, nir_def *x, uint64_t y)
{
assert(y > 0 && y <= u_uintN_max(x->bit_size));
if (util_is_power_of_two_nonzero(y)) {
if (util_is_power_of_two_nonzero64(y)) {
return nir_iand_imm(build, x, y - 1);
} else {
return nir_umod(build, x, nir_imm_intN_t(build, y, x->bit_size));

View File

@@ -1280,7 +1280,7 @@ iris_resource_from_user_memory(struct pipe_screen *pscreen,
* pointer.
*/
size_t page_size = getpagesize();
assert(util_is_power_of_two_nonzero(page_size));
assert(util_is_power_of_two_nonzero_uintptr(page_size));
size_t offset = (uintptr_t)user_memory & (page_size - 1);
void *mem_start = (char *)user_memory - offset;
size_t mem_size = offset + res_size;

View File

@@ -521,7 +521,7 @@ clEnqueueFillBuffer(cl_command_queue d_queue, cl_mem d_mem,
if (!pattern)
return CL_INVALID_VALUE;
if (!util_is_power_of_two_nonzero(pattern_size) ||
if (!util_is_power_of_two_nonzero_uintptr(pattern_size) ||
pattern_size > 128 || size % pattern_size
|| offset % pattern_size) {
return CL_INVALID_VALUE;
@@ -1124,7 +1124,7 @@ clover::EnqueueSVMMemFill(cl_command_queue d_q,
return CL_INVALID_OPERATION;
if (svm_ptr == nullptr || pattern == nullptr ||
!util_is_power_of_two_nonzero(pattern_size) ||
!util_is_power_of_two_nonzero_uintptr(pattern_size) ||
pattern_size > 128 ||
!ptr_is_aligned(svm_ptr, pattern_size) ||
size % pattern_size)

View File

@@ -172,7 +172,7 @@ VkResult pvr_free_list_create(struct pvr_device *device,
size_alignment = (addr_alignment / ROGUE_FREE_LIST_ENTRY_SIZE) *
ROGUE_BIF_PM_PHYSICAL_PAGE_SIZE;
assert(util_is_power_of_two_nonzero(size_alignment));
assert(util_is_power_of_two_nonzero64(size_alignment));
initial_size = align64(initial_size, size_alignment);
max_size = align64(max_size, size_alignment);

View File

@@ -178,7 +178,7 @@ VkResult pvr_drm_winsys_buffer_create(struct pvr_winsys *ws,
uint32_t handle = 0;
VkResult result;
assert(util_is_power_of_two_nonzero(alignment));
assert(util_is_power_of_two_nonzero64(alignment));
size = ALIGN_POT(size, alignment);
size = ALIGN_POT(size, ws->page_size);
@@ -347,7 +347,7 @@ VkResult pvr_drm_heap_alloc_carveout(struct pvr_winsys_heap *const heap,
struct pvr_drm_winsys_vma *drm_vma;
VkResult result;
assert(util_is_power_of_two_nonzero(alignment));
assert(util_is_power_of_two_nonzero64(alignment));
drm_vma = vk_zalloc(drm_ws->base.alloc,
sizeof(*drm_vma),

View File

@@ -90,7 +90,7 @@ VkResult pvr_winsys_helper_heap_alloc(struct pvr_winsys_heap *const heap,
.heap = heap,
};
assert(util_is_power_of_two_nonzero(alignment));
assert(util_is_power_of_two_nonzero64(alignment));
/* pvr_srv_winsys_buffer_create() page aligns the size. We must do the same
* here to ensure enough heap space is allocated to be able to map the

View File

@@ -156,7 +156,7 @@ VkResult pvr_srv_winsys_buffer_create(struct pvr_winsys *ws,
struct pvr_srv_winsys_bo *srv_bo;
VkResult result;
assert(util_is_power_of_two_nonzero(alignment));
assert(util_is_power_of_two_nonzero64(alignment));
/* Kernel will page align the size, we do the same here so we have access to
* all the allocated memory.
@@ -359,7 +359,7 @@ VkResult pvr_srv_heap_alloc_carveout(struct pvr_winsys_heap *heap,
struct pvr_srv_winsys_vma *srv_vma;
VkResult result;
assert(util_is_power_of_two_nonzero(alignment));
assert(util_is_power_of_two_nonzero64(alignment));
/* pvr_srv_winsys_buffer_create() page aligns the size. We must do the same
* here to ensure enough heap space is allocated to be able to map the

View File

@@ -100,7 +100,7 @@ nvk_heap_grow_locked(struct nvk_device *dev, struct nvk_heap *heap)
assert(heap->bo_count == 1);
struct nouveau_ws_bo *old_bo = heap->bos[0].bo;
assert(util_is_power_of_two_nonzero(heap->total_size));
assert(util_is_power_of_two_nonzero64(heap->total_size));
assert(heap->total_size >= NVK_HEAP_MIN_SIZE);
assert(heap->total_size <= old_bo->size);
assert(heap->total_size < new_bo_size);

View File

@@ -806,7 +806,7 @@ void *
gc_alloc_size(gc_ctx *ctx, size_t size, size_t alignment)
{
assert(ctx);
assert(util_is_power_of_two_nonzero(alignment));
assert(util_is_power_of_two_nonzero_uintptr(alignment));
alignment = MAX2(alignment, alignof(gc_block_header));

View File

@@ -191,7 +191,7 @@ static ALWAYS_INLINE void
vk_multialloc_add_size_align(struct vk_multialloc *ma,
void **ptr, size_t size, size_t align)
{
assert(util_is_power_of_two_nonzero(align));
assert(util_is_power_of_two_nonzero_uintptr(align));
if (size == 0) {
*ptr = NULL;
return;