	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_amdgpu_amdkfd_gpuvm_import_dmabuf ## -- Begin function amdgpu_amdkfd_gpuvm_import_dmabuf
	.p2align	4, 0x90
_amdgpu_amdkfd_gpuvm_import_dmabuf:     ## @amdgpu_amdkfd_gpuvm_import_dmabuf
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	8(%rsi), %rax
	cmpq	_amdgpu_dmabuf_ops@GOTPCREL(%rip), %rax
	jne	LBB0_1
## %bb.3:
	movq	%rcx, %r14
	movq	(%rsi), %rax
	movq	(%rax), %rcx
	cmpq	%rdi, (%rcx)
	je	LBB0_4
LBB0_1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_2:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_14:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movq	%r9, %rbx
	movq	%r8, %r13
	movl	%edx, %r15d
	movq	%rax, %rdi
	callq	_gem_to_amdgpu_bo
	movq	%rax, %r12
	movq	_AMDGPU_GEM_DOMAIN_VRAM@GOTPCREL(%rip), %rcx
	movq	_AMDGPU_GEM_DOMAIN_GTT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	(%rcx), %eax
	testl	%eax, (%r12)
	je	LBB0_1
## %bb.5:
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$40, %edi
	callq	_kzalloc
	movq	%rax, (%r13)
	testq	%rax, %rax
	je	LBB0_6
## %bb.7:
	testq	%rbx, %rbx
	je	LBB0_9
## %bb.8:
	movq	%r12, %rdi
	callq	_amdgpu_bo_size
	movl	%eax, (%rbx)
LBB0_9:
	movq	16(%rbp), %rbx
	testq	%rbx, %rbx
	je	LBB0_11
## %bb.10:
	movq	%r12, %rdi
	callq	_amdgpu_bo_mmap_offset
	movl	%eax, (%rbx)
LBB0_11:
	movq	(%r13), %rdi
	addq	$36, %rdi
	callq	_INIT_LIST_HEAD
	movq	(%r13), %rdi
	addq	$32, %rdi
	callq	_mutex_init
	movq	_AMDGPU_VM_PAGE_READABLE@GOTPCREL(%rip), %rax
	movq	_AMDGPU_VM_PAGE_WRITEABLE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	orl	(%rax), %ecx
	movq	_AMDGPU_VM_PAGE_EXECUTABLE@GOTPCREL(%rip), %rax
	orl	(%rax), %ecx
	movq	_AMDGPU_VM_MTYPE_NC@GOTPCREL(%rip), %rax
	orl	(%rax), %ecx
	movq	(%r13), %rax
	movl	%ecx, (%rax)
	movq	%r12, %rdi
	callq	_amdgpu_bo_ref
	movq	(%r13), %rdi
	movl	%eax, 28(%rdi)
	movl	%r15d, 24(%rdi)
	movq	_AMDGPU_GEM_DOMAIN_VRAM@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	(%r12), %ecx
	andl	%eax, %ecx
	jne	LBB0_13
## %bb.12:
	movq	_AMDGPU_GEM_DOMAIN_GTT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_13:
	movl	%eax, 4(%rdi)
	movq	$0, 16(%rdi)
	movl	(%r14), %esi
	movl	%esi, 12(%rdi)
	xorl	%ebx, %ebx
	xorl	%edx, %edx
	callq	_add_kgd_mem_to_kfd_bo_list
	movq	(%r13), %rdi
	addq	$8, %rdi
	callq	_amdgpu_sync_create
	jmp	LBB0_14
LBB0_6:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	jmp	LBB0_2
	.cfi_endproc
                                        ## -- End function
	.comm	_amdgpu_dmabuf_ops,4,2          ## @amdgpu_dmabuf_ops
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_AMDGPU_GEM_DOMAIN_VRAM,4,2     ## @AMDGPU_GEM_DOMAIN_VRAM
	.comm	_AMDGPU_GEM_DOMAIN_GTT,4,2      ## @AMDGPU_GEM_DOMAIN_GTT
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_AMDGPU_VM_PAGE_READABLE,4,2    ## @AMDGPU_VM_PAGE_READABLE
	.comm	_AMDGPU_VM_PAGE_WRITEABLE,4,2   ## @AMDGPU_VM_PAGE_WRITEABLE
	.comm	_AMDGPU_VM_PAGE_EXECUTABLE,4,2  ## @AMDGPU_VM_PAGE_EXECUTABLE
	.comm	_AMDGPU_VM_MTYPE_NC,4,2         ## @AMDGPU_VM_MTYPE_NC
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_amdgpu_amdkfd_gpuvm_import_dmabuf ; -- Begin function amdgpu_amdkfd_gpuvm_import_dmabuf
	.p2align	2
_amdgpu_amdkfd_gpuvm_import_dmabuf:     ; @amdgpu_amdkfd_gpuvm_import_dmabuf
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	ldr	x8, [x1, #8]
Lloh0:
	adrp	x9, _amdgpu_dmabuf_ops@GOTPAGE
Lloh1:
	ldr	x9, [x9, _amdgpu_dmabuf_ops@GOTPAGEOFF]
	cmp	x8, x9
	b.ne	LBB0_2
; %bb.1:
	ldr	x8, [x1]
	ldr	x9, [x8]
	ldr	x9, [x9]
	cmp	x9, x0
	b.eq	LBB0_5
LBB0_2:
Lloh2:
	adrp	x8, _EINVAL@GOTPAGE
Lloh3:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_3:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_4:
	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
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
LBB0_5:
	mov	x23, x6
	mov	x24, x5
	mov	x19, x4
	mov	x20, x3
	mov	x21, x2
	mov	x0, x8
	bl	_gem_to_amdgpu_bo
	ldr	w8, [x0]
Lloh4:
	adrp	x25, _AMDGPU_GEM_DOMAIN_VRAM@GOTPAGE
Lloh5:
	ldr	x25, [x25, _AMDGPU_GEM_DOMAIN_VRAM@GOTPAGEOFF]
	ldr	w9, [x25]
Lloh6:
	adrp	x26, _AMDGPU_GEM_DOMAIN_GTT@GOTPAGE
Lloh7:
	ldr	x26, [x26, _AMDGPU_GEM_DOMAIN_GTT@GOTPAGEOFF]
	ldr	w10, [x26]
	orr	w9, w10, w9
	tst	w9, w8
	b.eq	LBB0_2
; %bb.6:
	mov	x22, x0
Lloh8:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh10:
	ldr	w1, [x8]
	mov	w0, #40
	bl	_kzalloc
	str	x0, [x19]
	cbz	x0, LBB0_12
; %bb.7:
	cbz	x24, LBB0_9
; %bb.8:
	mov	x0, x22
	bl	_amdgpu_bo_size
	str	w0, [x24]
LBB0_9:
	cbz	x23, LBB0_11
; %bb.10:
	mov	x0, x22
	bl	_amdgpu_bo_mmap_offset
	str	w0, [x23]
LBB0_11:
	ldr	x8, [x19]
	add	x0, x8, #36
	bl	_INIT_LIST_HEAD
	ldr	x8, [x19]
	add	x0, x8, #32
	bl	_mutex_init
Lloh11:
	adrp	x8, _AMDGPU_VM_PAGE_READABLE@GOTPAGE
Lloh12:
	ldr	x8, [x8, _AMDGPU_VM_PAGE_READABLE@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
Lloh14:
	adrp	x9, _AMDGPU_VM_PAGE_WRITEABLE@GOTPAGE
Lloh15:
	ldr	x9, [x9, _AMDGPU_VM_PAGE_WRITEABLE@GOTPAGEOFF]
Lloh16:
	ldr	w9, [x9]
	orr	w8, w9, w8
Lloh17:
	adrp	x9, _AMDGPU_VM_PAGE_EXECUTABLE@GOTPAGE
Lloh18:
	ldr	x9, [x9, _AMDGPU_VM_PAGE_EXECUTABLE@GOTPAGEOFF]
Lloh19:
	ldr	w9, [x9]
	orr	w8, w8, w9
Lloh20:
	adrp	x9, _AMDGPU_VM_MTYPE_NC@GOTPAGE
Lloh21:
	ldr	x9, [x9, _AMDGPU_VM_MTYPE_NC@GOTPAGEOFF]
Lloh22:
	ldr	w9, [x9]
	orr	w8, w8, w9
	ldr	x9, [x19]
	str	w8, [x9]
	mov	x0, x22
	bl	_amdgpu_bo_ref
	ldr	x8, [x19]
	stp	w21, w0, [x8, #24]
	ldr	w9, [x22]
	ldr	w10, [x25]
	ldr	w11, [x26]
	tst	w10, w9
	csel	w9, w11, w10, eq
	str	w9, [x8, #4]
	str	xzr, [x8, #16]
	ldr	w1, [x20]
	str	w1, [x8, #12]
	mov	x0, x8
	mov	w2, #0
	bl	_add_kgd_mem_to_kfd_bo_list
	ldr	x8, [x19]
	add	x0, x8, #8
	bl	_amdgpu_sync_create
	mov	w0, #0
	b	LBB0_4
LBB0_12:
Lloh23:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh24:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh23, Lloh24
	.cfi_endproc
                                        ; -- End function
	.comm	_amdgpu_dmabuf_ops,4,2          ; @amdgpu_dmabuf_ops
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_AMDGPU_GEM_DOMAIN_VRAM,4,2     ; @AMDGPU_GEM_DOMAIN_VRAM
	.comm	_AMDGPU_GEM_DOMAIN_GTT,4,2      ; @AMDGPU_GEM_DOMAIN_GTT
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_AMDGPU_VM_PAGE_READABLE,4,2    ; @AMDGPU_VM_PAGE_READABLE
	.comm	_AMDGPU_VM_PAGE_WRITEABLE,4,2   ; @AMDGPU_VM_PAGE_WRITEABLE
	.comm	_AMDGPU_VM_PAGE_EXECUTABLE,4,2  ; @AMDGPU_VM_PAGE_EXECUTABLE
	.comm	_AMDGPU_VM_MTYPE_NC,4,2         ; @AMDGPU_VM_MTYPE_NC
.subsections_via_symbols
