	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_kgd_gfx_v9_hqd_destroy         ## -- Begin function kgd_gfx_v9_hqd_destroy
	.p2align	4, 0x90
_kgd_gfx_v9_hqd_destroy:                ## @kgd_gfx_v9_hqd_destroy
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%r9d, -48(%rbp)                 ## 4-byte Spill
	movl	%r8d, -52(%rbp)                 ## 4-byte Spill
                                        ## kill: def $ecx killed $ecx def $rcx
	movq	%rcx, -64(%rbp)                 ## 8-byte Spill
	movl	%edx, %r15d
	movq	%rsi, %rbx
	movq	%rdi, %r13
	callq	_get_amdgpu_device
	movq	%rax, %r12
	movq	%rbx, %rdi
	callq	_get_mqd
	cmpq	$0, (%r12)
	je	LBB0_3
## %bb.1:
	movq	_EIO@GOTPCREL(%rip), %rax
LBB0_2:
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
	jmp	LBB0_13
LBB0_3:
	movq	%rax, %r14
	movl	%r15d, %r12d
	movq	-64(%rbp), %r15                 ## 8-byte Reload
	movq	%r13, %rdi
	movl	-52(%rbp), %esi                 ## 4-byte Reload
	movl	-48(%rbp), %edx                 ## 4-byte Reload
	callq	_acquire_queue
	cmpq	$0, (%r14)
	jne	LBB0_5
## %bb.4:
	movq	_GC@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_RLC_CP_SCHEDULERS@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	_scheduler1@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	xorl	%esi, %esi
	xorl	%r8d, %r8d
	callq	_WREG32_FIELD15_RLC
LBB0_5:
	movq	%r13, -48(%rbp)                 ## 8-byte Spill
	movq	_DRAIN_PIPE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, %ebx
	cmpl	$128, %r12d
	jne	LBB0_7
## %bb.6:
	movq	_RESET_WAVES@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ebx
LBB0_7:
	cmpl	$129, %r12d
	cmovel	%eax, %ebx
	movq	_GC@GOTPCREL(%rip), %r14
	movl	(%r14), %edi
	movq	_mmCP_HQD_DEQUEUE_REQUEST@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	callq	_SOC15_REG_OFFSET
	movl	%eax, %edi
	movl	%ebx, %esi
	callq	_WREG32_RLC
	movq	_HZ@GOTPCREL(%rip), %rax
	imull	(%rax), %r15d
	imulq	$274877907, %r15, %rbx          ## imm = 0x10624DD3
	shrq	$38, %rbx
	movq	_jiffies@GOTPCREL(%rip), %r15
	addl	(%r15), %ebx
	movl	(%r14), %edi
	movq	_mmCP_HQD_ACTIVE@GOTPCREL(%rip), %r13
	movl	(%r13), %edx
	xorl	%esi, %esi
	callq	_SOC15_REG_OFFSET
	movl	%eax, %edi
	callq	_RREG32
	movq	_CP_HQD_ACTIVE__ACTIVE_MASK@GOTPCREL(%rip), %r14
	testl	%eax, (%r14)
	je	LBB0_12
	.p2align	4, 0x90
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r15), %edi
	movq	%rbx, %rsi
	callq	_time_after
	testq	%rax, %rax
	jne	LBB0_10
## %bb.11:                              ##   in Loop: Header=BB0_9 Depth=1
	movl	$500, %edi                      ## imm = 0x1F4
	movl	$1000, %esi                     ## imm = 0x3E8
	callq	_usleep_range
	movq	_GC@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	(%r13), %edx
	xorl	%esi, %esi
	callq	_SOC15_REG_OFFSET
	movl	%eax, %edi
	callq	_RREG32
	testl	%eax, (%r14)
	jne	LBB0_9
LBB0_12:
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_release_queue
LBB0_13:
	movl	%r12d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_10:
	leaq	L_.str(%rip), %rdi
	callq	_pr_err
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_release_queue
	movq	_ETIME@GOTPCREL(%rip), %rax
	jmp	LBB0_2
	.cfi_endproc
                                        ## -- End function
	.comm	_EIO,4,2                        ## @EIO
	.comm	_GC,4,2                         ## @GC
	.comm	_RLC_CP_SCHEDULERS,4,2          ## @RLC_CP_SCHEDULERS
	.comm	_scheduler1,4,2                 ## @scheduler1
	.comm	_DRAIN_PIPE,4,2                 ## @DRAIN_PIPE
	.comm	_RESET_WAVES,4,2                ## @RESET_WAVES
	.comm	_mmCP_HQD_DEQUEUE_REQUEST,4,2   ## @mmCP_HQD_DEQUEUE_REQUEST
	.comm	_HZ,4,2                         ## @HZ
	.comm	_jiffies,4,2                    ## @jiffies
	.comm	_mmCP_HQD_ACTIVE,4,2            ## @mmCP_HQD_ACTIVE
	.comm	_CP_HQD_ACTIVE__ACTIVE_MASK,4,2 ## @CP_HQD_ACTIVE__ACTIVE_MASK
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"cp queue preemption time out.\n"

	.comm	_ETIME,4,2                      ## @ETIME
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_kgd_gfx_v9_hqd_destroy         ; -- Begin function kgd_gfx_v9_hqd_destroy
	.p2align	2
_kgd_gfx_v9_hqd_destroy:                ; @kgd_gfx_v9_hqd_destroy
	.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
	mov	x22, x5
	mov	x23, x4
	mov	x20, x3
	mov	x21, x2
	mov	x24, x1
	mov	x19, x0
	bl	_get_amdgpu_device
	mov	x25, x0
	mov	x0, x24
	bl	_get_mqd
	ldr	x8, [x25]
	cbz	x8, LBB0_3
; %bb.1:
Lloh0:
	adrp	x8, _EIO@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
LBB0_2:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_10
LBB0_3:
	mov	x24, x0
	mov	x0, x19
	mov	x1, x23
	mov	x2, x22
	bl	_acquire_queue
	ldr	x8, [x24]
Lloh2:
	adrp	x22, _GC@GOTPAGE
Lloh3:
	ldr	x22, [x22, _GC@GOTPAGEOFF]
	cbnz	x8, LBB0_5
; %bb.4:
	ldr	w0, [x22]
Lloh4:
	adrp	x8, _RLC_CP_SCHEDULERS@GOTPAGE
Lloh5:
	ldr	x8, [x8, _RLC_CP_SCHEDULERS@GOTPAGEOFF]
Lloh6:
	ldr	w2, [x8]
Lloh7:
	adrp	x8, _scheduler1@GOTPAGE
Lloh8:
	ldr	x8, [x8, _scheduler1@GOTPAGEOFF]
Lloh9:
	ldr	w3, [x8]
	mov	w1, #0
	mov	w4, #0
	bl	_WREG32_FIELD15_RLC
LBB0_5:
Lloh10:
	adrp	x8, _DRAIN_PIPE@GOTPAGE
Lloh11:
	ldr	x8, [x8, _DRAIN_PIPE@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
Lloh13:
	adrp	x9, _RESET_WAVES@GOTPAGE
Lloh14:
	ldr	x9, [x9, _RESET_WAVES@GOTPAGEOFF]
Lloh15:
	ldr	w9, [x9]
	cmp	w21, #128
	csel	w9, w9, w8, eq
	cmp	w21, #129
	csel	w21, w8, w9, eq
	ldr	w0, [x22]
Lloh16:
	adrp	x8, _mmCP_HQD_DEQUEUE_REQUEST@GOTPAGE
Lloh17:
	ldr	x8, [x8, _mmCP_HQD_DEQUEUE_REQUEST@GOTPAGEOFF]
Lloh18:
	ldr	w2, [x8]
	mov	w1, #0
	bl	_SOC15_REG_OFFSET
	mov	x1, x21
	bl	_WREG32_RLC
Lloh19:
	adrp	x8, _HZ@GOTPAGE
Lloh20:
	ldr	x8, [x8, _HZ@GOTPAGEOFF]
Lloh21:
	adrp	x21, _jiffies@GOTPAGE
Lloh22:
	ldr	x21, [x21, _jiffies@GOTPAGEOFF]
Lloh23:
	ldr	w26, [x8]
	ldr	w25, [x21]
	ldr	w0, [x22]
Lloh24:
	adrp	x23, _mmCP_HQD_ACTIVE@GOTPAGE
Lloh25:
	ldr	x23, [x23, _mmCP_HQD_ACTIVE@GOTPAGEOFF]
	ldr	w2, [x23]
	mov	w1, #0
	bl	_SOC15_REG_OFFSET
	bl	_RREG32
Lloh26:
	adrp	x24, _CP_HQD_ACTIVE__ACTIVE_MASK@GOTPAGE
Lloh27:
	ldr	x24, [x24, _CP_HQD_ACTIVE__ACTIVE_MASK@GOTPAGEOFF]
	ldr	w8, [x24]
	tst	w8, w0
	b.eq	LBB0_9
; %bb.6:
	mul	w8, w26, w20
	mov	w9, #19923
	movk	w9, #4194, lsl #16
	umull	x8, w8, w9
	lsr	x8, x8, #38
	add	w20, w8, w25
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x21]
	mov	x1, x20
	bl	_time_after
	cbnz	x0, LBB0_11
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	mov	w0, #500
	mov	w1, #1000
	bl	_usleep_range
	ldr	w0, [x22]
	ldr	w2, [x23]
	mov	w1, #0
	bl	_SOC15_REG_OFFSET
	bl	_RREG32
	ldr	w8, [x24]
	tst	w8, w0
	b.ne	LBB0_7
LBB0_9:
	mov	x0, x19
	bl	_release_queue
	mov	w0, #0
LBB0_10:
	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_11:
Lloh28:
	adrp	x0, l_.str@PAGE
Lloh29:
	add	x0, x0, l_.str@PAGEOFF
	bl	_pr_err
	mov	x0, x19
	bl	_release_queue
Lloh30:
	adrp	x8, _ETIME@GOTPAGE
Lloh31:
	ldr	x8, [x8, _ETIME@GOTPAGEOFF]
	b	LBB0_2
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh26, Lloh27
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh23
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh30, Lloh31
	.loh AdrpAdd	Lloh28, Lloh29
	.cfi_endproc
                                        ; -- End function
	.comm	_EIO,4,2                        ; @EIO
	.comm	_GC,4,2                         ; @GC
	.comm	_RLC_CP_SCHEDULERS,4,2          ; @RLC_CP_SCHEDULERS
	.comm	_scheduler1,4,2                 ; @scheduler1
	.comm	_DRAIN_PIPE,4,2                 ; @DRAIN_PIPE
	.comm	_RESET_WAVES,4,2                ; @RESET_WAVES
	.comm	_mmCP_HQD_DEQUEUE_REQUEST,4,2   ; @mmCP_HQD_DEQUEUE_REQUEST
	.comm	_HZ,4,2                         ; @HZ
	.comm	_jiffies,4,2                    ; @jiffies
	.comm	_mmCP_HQD_ACTIVE,4,2            ; @mmCP_HQD_ACTIVE
	.comm	_CP_HQD_ACTIVE__ACTIVE_MASK,4,2 ; @CP_HQD_ACTIVE__ACTIVE_MASK
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"cp queue preemption time out.\n"

	.comm	_ETIME,4,2                      ; @ETIME
.subsections_via_symbols
