	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function kgd_hqd_destroy
_kgd_hqd_destroy:                       ## @kgd_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, %r13d
	movl	%r8d, %r12d
                                        ## kill: def $ecx killed $ecx def $rcx
	movq	%rcx, -64(%rbp)                 ## 8-byte Spill
	movl	%edx, -44(%rbp)                 ## 4-byte Spill
	movq	%rsi, %r14
	movq	%rdi, %r15
	callq	_get_amdgpu_device
	movq	%r14, %rdi
	callq	_get_mqd
	movq	%rax, %rbx
	movq	%r15, -56(%rbp)                 ## 8-byte Spill
	movq	%r15, %rdi
	movl	%r12d, %esi
	movl	%r13d, %edx
	callq	_acquire_queue
	cmpq	$0, (%rbx)
	jne	LBB0_2
## %bb.1:
	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
LBB0_2:
	movq	_DRAIN_PIPE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, %ebx
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	cmpl	$128, %edx
	jne	LBB0_4
## %bb.3:
	movq	_RESET_WAVES@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ebx
LBB0_4:
	cmpl	$129, %edx
	cmovel	%eax, %ebx
	movq	_GC@GOTPCREL(%rip), %r14
	movl	(%r14), %edi
	movq	_mmCP_HQD_DEQUEUE_REQUEST@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	xorl	%esi, %esi
	callq	_SOC15_REG_OFFSET
	movl	%eax, %edi
	movl	%ebx, %esi
	callq	_WREG32
	movq	_HZ@GOTPCREL(%rip), %rax
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	imull	(%rax), %ecx
	imulq	$274877907, %rcx, %rbx          ## imm = 0x10624DD3
	shrq	$38, %rbx
	movq	_jiffies@GOTPCREL(%rip), %r12
	addl	(%r12), %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), %r15
	testl	%eax, (%r15)
	je	LBB0_9
	.p2align	4, 0x90
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r12), %edi
	movq	%rbx, %rsi
	callq	_time_after
	testq	%rax, %rax
	jne	LBB0_7
## %bb.8:                               ##   in Loop: Header=BB0_6 Depth=1
	movl	$500, %edi                      ## imm = 0x1F4
	movl	$1000, %esi                     ## imm = 0x3E8
	callq	_usleep_range
	movl	(%r14), %edi
	movl	(%r13), %edx
	xorl	%esi, %esi
	callq	_SOC15_REG_OFFSET
	movl	%eax, %edi
	callq	_RREG32
	testl	%eax, (%r15)
	jne	LBB0_6
LBB0_9:
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_release_queue
	xorl	%eax, %eax
	jmp	LBB0_10
LBB0_7:
	leaq	L_.str(%rip), %rdi
	callq	_pr_err
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_release_queue
	movq	_ETIME@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_10:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.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
	.comm	_ACTIVE,4,2                     ## @ACTIVE
	.comm	_CP_HQD_DEQUEUE_REQUEST__IQ_REQ_PEND_MASK,4,2 ## @CP_HQD_DEQUEUE_REQUEST__IQ_REQ_PEND_MASK
	.comm	_CP_HQD_IQ_TIMER,4,2            ## @CP_HQD_IQ_TIMER
	.comm	_PROCESSING_IQ,4,2              ## @PROCESSING_IQ
	.comm	_RETRY_TYPE,4,2                 ## @RETRY_TYPE
	.comm	_WAIT_TIME,4,2                  ## @WAIT_TIME
	.comm	_mmCP_HQD_IQ_TIMER,4,2          ## @mmCP_HQD_IQ_TIMER
	.no_dead_strip	_kgd_hqd_destroy
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function kgd_hqd_destroy
_kgd_hqd_destroy:                       ; @kgd_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	x0, x24
	bl	_get_mqd
	mov	x24, x0
	mov	x0, x19
	mov	x1, x23
	mov	x2, x22
	bl	_acquire_queue
	ldr	x8, [x24]
Lloh0:
	adrp	x22, _GC@GOTPAGE
Lloh1:
	ldr	x22, [x22, _GC@GOTPAGEOFF]
	cbnz	x8, LBB0_2
; %bb.1:
	ldr	w0, [x22]
Lloh2:
	adrp	x8, _RLC_CP_SCHEDULERS@GOTPAGE
Lloh3:
	ldr	x8, [x8, _RLC_CP_SCHEDULERS@GOTPAGEOFF]
Lloh4:
	ldr	w2, [x8]
Lloh5:
	adrp	x8, _scheduler1@GOTPAGE
Lloh6:
	ldr	x8, [x8, _scheduler1@GOTPAGEOFF]
Lloh7:
	ldr	w3, [x8]
	mov	w1, #0
	mov	w4, #0
	bl	_WREG32_FIELD15
LBB0_2:
Lloh8:
	adrp	x8, _DRAIN_PIPE@GOTPAGE
Lloh9:
	ldr	x8, [x8, _DRAIN_PIPE@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
Lloh11:
	adrp	x9, _RESET_WAVES@GOTPAGE
Lloh12:
	ldr	x9, [x9, _RESET_WAVES@GOTPAGEOFF]
Lloh13:
	ldr	w9, [x9]
	cmp	w21, #128
	csel	w9, w9, w8, eq
	cmp	w21, #129
	csel	w21, w8, w9, eq
	ldr	w0, [x22]
Lloh14:
	adrp	x8, _mmCP_HQD_DEQUEUE_REQUEST@GOTPAGE
Lloh15:
	ldr	x8, [x8, _mmCP_HQD_DEQUEUE_REQUEST@GOTPAGEOFF]
Lloh16:
	ldr	w2, [x8]
	mov	w1, #0
	bl	_SOC15_REG_OFFSET
	mov	x1, x21
	bl	_WREG32
Lloh17:
	adrp	x8, _HZ@GOTPAGE
Lloh18:
	ldr	x8, [x8, _HZ@GOTPAGEOFF]
Lloh19:
	adrp	x21, _jiffies@GOTPAGE
Lloh20:
	ldr	x21, [x21, _jiffies@GOTPAGEOFF]
Lloh21:
	ldr	w26, [x8]
	ldr	w25, [x21]
	ldr	w0, [x22]
Lloh22:
	adrp	x23, _mmCP_HQD_ACTIVE@GOTPAGE
Lloh23:
	ldr	x23, [x23, _mmCP_HQD_ACTIVE@GOTPAGEOFF]
	ldr	w2, [x23]
	mov	w1, #0
	bl	_SOC15_REG_OFFSET
	bl	_RREG32
Lloh24:
	adrp	x24, _CP_HQD_ACTIVE__ACTIVE_MASK@GOTPAGE
Lloh25:
	ldr	x24, [x24, _CP_HQD_ACTIVE__ACTIVE_MASK@GOTPAGEOFF]
	ldr	w8, [x24]
	tst	w8, w0
	b.eq	LBB0_6
; %bb.3:
	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_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x21]
	mov	x1, x20
	bl	_time_after
	cbnz	x0, LBB0_7
; %bb.5:                                ;   in Loop: Header=BB0_4 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_4
LBB0_6:
	mov	x0, x19
	bl	_release_queue
	mov	w0, #0
	b	LBB0_8
LBB0_7:
Lloh26:
	adrp	x0, l_.str@PAGE
Lloh27:
	add	x0, x0, l_.str@PAGEOFF
	bl	_pr_err
	mov	x0, x19
	bl	_release_queue
Lloh28:
	adrp	x8, _ETIME@GOTPAGE
Lloh29:
	ldr	x8, [x8, _ETIME@GOTPAGEOFF]
Lloh30:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_8:
	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
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh21
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpAdd	Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.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
	.comm	_ACTIVE,4,2                     ; @ACTIVE
	.comm	_CP_HQD_DEQUEUE_REQUEST__IQ_REQ_PEND_MASK,4,2 ; @CP_HQD_DEQUEUE_REQUEST__IQ_REQ_PEND_MASK
	.comm	_CP_HQD_IQ_TIMER,4,2            ; @CP_HQD_IQ_TIMER
	.comm	_PROCESSING_IQ,4,2              ; @PROCESSING_IQ
	.comm	_RETRY_TYPE,4,2                 ; @RETRY_TYPE
	.comm	_WAIT_TIME,4,2                  ; @WAIT_TIME
	.comm	_mmCP_HQD_IQ_TIMER,4,2          ; @mmCP_HQD_IQ_TIMER
	.no_dead_strip	_kgd_hqd_destroy
.subsections_via_symbols
