	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function kfd_ioctl_alloc_memory_of_gpu
_kfd_ioctl_alloc_memory_of_gpu:         ## @kfd_ioctl_alloc_memory_of_gpu
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	(%rdx), %eax
	movl	%eax, -44(%rbp)
	cmpq	$0, 8(%rdx)
	je	LBB0_1
## %bb.3:
	movq	%rdx, %r12
	movq	%rsi, %rbx
	movl	4(%rdx), %r14d
	movl	16(%rdx), %edi
	callq	_kfd_device_by_id
	testq	%rax, %rax
	je	LBB0_1
## %bb.4:
	movq	%rax, %r15
	movq	_KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC@GOTPCREL(%rip), %rax
	testl	%r14d, (%rax)
	je	LBB0_8
## %bb.5:
	movq	_KFD_IOC_ALLOC_MEM_FLAGS_VRAM@GOTPCREL(%rip), %rax
	testl	%r14d, (%rax)
	je	LBB0_8
## %bb.6:
	movq	%r15, %rdi
	callq	_kfd_dev_is_large_bar
	testl	%eax, %eax
	je	LBB0_7
LBB0_8:
	movq	_KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL@GOTPCREL(%rip), %rax
	testl	%r14d, (%rax)
	je	LBB0_14
## %bb.9:
	movq	8(%r12), %r13
	movq	%r15, %rdi
	callq	_kfd_doorbell_process_slice
	cmpq	%rax, %r13
	jne	LBB0_1
## %bb.10:
	movq	%r15, %rdi
	movq	%rbx, %rsi
	callq	_kfd_get_process_doorbells
	movl	%eax, -44(%rbp)
	jmp	LBB0_11
LBB0_14:
	movq	_KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP@GOTPCREL(%rip), %rax
	testl	%r14d, (%rax)
	je	LBB0_11
## %bb.15:
	movq	8(%r12), %rax
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_1
## %bb.16:
	movl	(%r15), %edi
	callq	_amdgpu_amdkfd_get_mmio_remap_phys_addr
	movl	%eax, -44(%rbp)
	testl	%eax, %eax
	je	LBB0_17
LBB0_11:
	movq	%rbx, %rdi
	callq	_mutex_lock
	movq	%r15, %rdi
	movq	%rbx, -56(%rbp)                 ## 8-byte Spill
	movq	%rbx, %rsi
	callq	_kfd_bind_process_to_device
	movq	%rax, %r13
	movq	%rax, %rdi
	callq	_IS_ERR
	testq	%rax, %rax
	je	LBB0_18
## %bb.12:
	movq	%r13, %rdi
	callq	_PTR_ERR
	movq	%rax, %rbx
	jmp	LBB0_13
LBB0_18:
	movl	(%r15), %edi
	movl	24(%r12), %esi
	movq	8(%r12), %rdx
	movl	(%r13), %ecx
	movl	%r14d, (%rsp)
	leaq	-64(%rbp), %r8
	leaq	-44(%rbp), %r9
	callq	_amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu
	movq	%rax, %rbx
	testq	%rax, %rax
	je	LBB0_19
LBB0_13:
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	jmp	LBB0_23
LBB0_7:
	leaq	L_.str(%rip), %rdi
	callq	_pr_err
LBB0_1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_2:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_23:
	movl	%ebx, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_19:
	movq	-64(%rbp), %rsi
	movq	%r13, %rdi
	callq	_kfd_process_device_create_obj_handle
	testl	%eax, %eax
	js	LBB0_20
## %bb.21:
	movl	%eax, %ebx
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	movl	16(%r12), %edi
	movl	%ebx, %esi
	callq	_MAKE_HANDLE
	movl	%eax, 20(%r12)
	movl	-44(%rbp), %eax
	movl	%eax, (%r12)
	movq	_KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	testl	%r14d, (%rax)
	je	LBB0_23
## %bb.22:
	movq	_KFD_MMAP_TYPE_MMIO@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
	movl	16(%r12), %edi
	callq	_KFD_MMAP_GPU_ID
	orl	%r14d, %eax
	movl	%eax, (%r12)
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shll	%cl, %eax
	movl	%eax, (%r12)
	jmp	LBB0_23
LBB0_17:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_20:
	movq	_EFAULT@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subq	(%rax), %rbx
	movl	(%r15), %edi
	movq	-64(%rbp), %rsi
	callq	_amdgpu_amdkfd_gpuvm_free_memory_of_gpu
	jmp	LBB0_13
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC,4,2 ## @KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC
	.comm	_KFD_IOC_ALLOC_MEM_FLAGS_VRAM,4,2 ## @KFD_IOC_ALLOC_MEM_FLAGS_VRAM
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Alloc host visible vram on small bar is not allowed\n"

	.comm	_KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL,4,2 ## @KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL
	.comm	_KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP,4,2 ## @KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP
	.comm	_PAGE_SIZE,8,3                  ## @PAGE_SIZE
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_EFAULT,8,3                     ## @EFAULT
	.comm	_KFD_MMAP_TYPE_MMIO,4,2         ## @KFD_MMAP_TYPE_MMIO
	.comm	_PAGE_SHIFT,4,2                 ## @PAGE_SHIFT
	.no_dead_strip	_kfd_ioctl_alloc_memory_of_gpu
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function kfd_ioctl_alloc_memory_of_gpu
_kfd_ioctl_alloc_memory_of_gpu:         ; @kfd_ioctl_alloc_memory_of_gpu
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	ldr	w8, [x2]
	str	w8, [sp, #4]
	ldr	x8, [x2, #8]
	cbz	x8, LBB0_16
; %bb.1:
	mov	x19, x2
	mov	x20, x1
	ldr	w21, [x2, #4]
	ldr	w0, [x2, #16]
	bl	_kfd_device_by_id
	cbz	x0, LBB0_16
; %bb.2:
	mov	x22, x0
Lloh0:
	adrp	x8, _KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC@GOTPAGE
Lloh1:
	ldr	x8, [x8, _KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	tst	w8, w21
	b.eq	LBB0_5
; %bb.3:
Lloh3:
	adrp	x8, _KFD_IOC_ALLOC_MEM_FLAGS_VRAM@GOTPAGE
Lloh4:
	ldr	x8, [x8, _KFD_IOC_ALLOC_MEM_FLAGS_VRAM@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	tst	w8, w21
	b.eq	LBB0_5
; %bb.4:
	mov	x0, x22
	bl	_kfd_dev_is_large_bar
	cbz	w0, LBB0_15
LBB0_5:
Lloh6:
	adrp	x8, _KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL@GOTPAGE
Lloh7:
	ldr	x8, [x8, _KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL@GOTPAGEOFF]
Lloh8:
	ldr	w8, [x8]
	tst	w8, w21
	b.eq	LBB0_8
; %bb.6:
	ldr	x23, [x19, #8]
	mov	x0, x22
	bl	_kfd_doorbell_process_slice
	cmp	x23, x0
	b.ne	LBB0_16
; %bb.7:
	mov	x0, x22
	mov	x1, x20
	bl	_kfd_get_process_doorbells
	str	w0, [sp, #4]
	b	LBB0_11
LBB0_8:
Lloh9:
	adrp	x8, _KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP@GOTPAGE
Lloh10:
	ldr	x8, [x8, _KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	tst	w8, w21
	b.eq	LBB0_11
; %bb.9:
	ldr	x8, [x19, #8]
Lloh12:
	adrp	x9, _PAGE_SIZE@GOTPAGE
Lloh13:
	ldr	x9, [x9, _PAGE_SIZE@GOTPAGEOFF]
Lloh14:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_16
; %bb.10:
	ldr	w0, [x22]
	bl	_amdgpu_amdkfd_get_mmio_remap_phys_addr
	str	w0, [sp, #4]
	cbz	w0, LBB0_22
LBB0_11:
	mov	x0, x20
	bl	_mutex_lock
	mov	x0, x22
	mov	x1, x20
	bl	_kfd_bind_process_to_device
	mov	x24, x0
	bl	_IS_ERR
	cbz	x0, LBB0_13
; %bb.12:
	mov	x0, x24
	bl	_PTR_ERR
	mov	x23, x0
	b	LBB0_14
LBB0_13:
	ldr	w0, [x22]
	ldr	w1, [x19, #24]
	ldr	x2, [x19, #8]
	ldr	w3, [x24]
	add	x4, sp, #8
	add	x5, sp, #4
	mov	x6, x21
	bl	_amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu
	mov	x23, x0
	cbz	x0, LBB0_19
LBB0_14:
	mov	x0, x20
	bl	_mutex_unlock
	b	LBB0_18
LBB0_15:
Lloh15:
	adrp	x0, l_.str@PAGE
Lloh16:
	add	x0, x0, l_.str@PAGEOFF
	bl	_pr_err
LBB0_16:
Lloh17:
	adrp	x8, _EINVAL@GOTPAGE
Lloh18:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_17:
	ldr	w8, [x8]
	neg	w23, w8
LBB0_18:
	mov	x0, x23
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
LBB0_19:
	ldr	x1, [sp, #8]
	mov	x0, x24
	bl	_kfd_process_device_create_obj_handle
	tbnz	w0, #31, LBB0_23
; %bb.20:
	mov	x23, x0
	mov	x0, x20
	bl	_mutex_unlock
	ldr	w0, [x19, #16]
	mov	x1, x23
	bl	_MAKE_HANDLE
	str	w0, [x19, #20]
	ldr	w8, [sp, #4]
	str	w8, [x19]
Lloh19:
	adrp	x8, _KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP@GOTPAGE
Lloh20:
	ldr	x8, [x8, _KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP@GOTPAGEOFF]
Lloh21:
	ldr	w8, [x8]
	tst	w8, w21
	b.eq	LBB0_24
; %bb.21:
Lloh22:
	adrp	x8, _KFD_MMAP_TYPE_MMIO@GOTPAGE
Lloh23:
	ldr	x8, [x8, _KFD_MMAP_TYPE_MMIO@GOTPAGEOFF]
Lloh24:
	ldr	w20, [x8]
	ldr	w0, [x19, #16]
	bl	_KFD_MMAP_GPU_ID
	mov	w23, #0
	orr	w8, w0, w20
	str	w8, [x19]
Lloh25:
	adrp	x9, _PAGE_SHIFT@GOTPAGE
Lloh26:
	ldr	x9, [x9, _PAGE_SHIFT@GOTPAGEOFF]
Lloh27:
	ldr	w9, [x9]
	lsl	w8, w8, w9
	str	w8, [x19]
	b	LBB0_18
LBB0_22:
Lloh28:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh29:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_17
LBB0_23:
Lloh30:
	adrp	x8, _EFAULT@GOTPAGE
Lloh31:
	ldr	x8, [x8, _EFAULT@GOTPAGEOFF]
Lloh32:
	ldr	x8, [x8]
	neg	x23, x8
	ldr	w0, [x22]
	ldr	x1, [sp, #8]
	bl	_amdgpu_amdkfd_gpuvm_free_memory_of_gpu
	b	LBB0_14
LBB0_24:
	mov	w23, #0
	b	LBB0_18
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh30, Lloh31, Lloh32
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC,4,2 ; @KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC
	.comm	_KFD_IOC_ALLOC_MEM_FLAGS_VRAM,4,2 ; @KFD_IOC_ALLOC_MEM_FLAGS_VRAM
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Alloc host visible vram on small bar is not allowed\n"

	.comm	_KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL,4,2 ; @KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL
	.comm	_KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP,4,2 ; @KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP
	.comm	_PAGE_SIZE,8,3                  ; @PAGE_SIZE
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_EFAULT,8,3                     ; @EFAULT
	.comm	_KFD_MMAP_TYPE_MMIO,4,2         ; @KFD_MMAP_TYPE_MMIO
	.comm	_PAGE_SHIFT,4,2                 ; @PAGE_SHIFT
	.no_dead_strip	_kfd_ioctl_alloc_memory_of_gpu
.subsections_via_symbols
