	.file	"extr_mtk-platform.c_mtk_desc_ring_alloc.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	mtk_desc_ring_alloc, @function
mtk_desc_ring_alloc:
.LFB0:
	.cfi_startproc
	endbr64
	push	r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	push	r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	sub	rsp, 8
	.cfi_def_cfa_offset 64
	mov	eax, DWORD PTR MTK_RING_MAX[rip]
	mov	r12, QWORD PTR 8[rdi]
	mov	r15d, DWORD PTR ENOMEM[rip]
	test	eax, eax
	jle	.L2
	mov	r13, rdi
	xor	ebx, ebx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L3:
	mov	ecx, DWORD PTR GFP_KERNEL[rip]
	mov	esi, DWORD PTR MTK_DESC_RING_SZ[rip]
	mov	rdx, rax
	mov	edi, DWORD PTR 0[r13]
	call	dma_alloc_coherent@PLT
	mov	QWORD PTR 8[rbp], rax
	mov	rbp, QWORD PTR [r12+rbx*8]
	cmp	QWORD PTR 8[rbp], 0
	je	.L6
	mov	ecx, DWORD PTR GFP_KERNEL[rip]
	mov	esi, DWORD PTR MTK_DESC_RING_SZ[rip]
	lea	rdx, 16[rbp]
	mov	edi, DWORD PTR 0[r13]
	call	dma_alloc_coherent@PLT
	mov	QWORD PTR 24[rbp], rax
	mov	rax, QWORD PTR [r12+rbx*8]
	cmp	QWORD PTR 24[rax], 0
	je	.L6
	mov	rdx, QWORD PTR 8[rax]
	mov	QWORD PTR 40[rax], rdx
	mov	rax, QWORD PTR [r12+rbx*8]
	add	rbx, 1
	cmp	DWORD PTR MTK_RING_MAX[rip], ebx
	mov	rdx, QWORD PTR 24[rax]
	mov	QWORD PTR 32[rax], rdx
	jle	.L2
.L7:
	mov	esi, DWORD PTR GFP_KERNEL[rip]
	mov	edi, 48
	mov	r14d, ebx
	call	kzalloc@PLT
	mov	QWORD PTR [r12+rbx*8], rax
	mov	rbp, rax
	test	rax, rax
	jne	.L3
.L6:
	lea	eax, -1[r14]
	test	r14d, r14d
	je	.L1
	cdqe
	sal	rax, 3
	lea	rdx, -8[r12+rax]
	lea	rbp, [r12+rax]
	lea	eax, -1[rbx]
	mov	rbx, rdx
	sal	rax, 3
	sub	rbx, rax
	.p2align 4,,10
	.p2align 3
.L8:
	mov	rax, QWORD PTR 0[rbp]
	mov	esi, DWORD PTR MTK_DESC_RING_SZ[rip]
	sub	rbp, 8
	mov	edi, DWORD PTR 0[r13]
	mov	ecx, DWORD PTR 16[rax]
	mov	rdx, QWORD PTR 24[rax]
	call	dma_free_coherent@PLT
	mov	rax, QWORD PTR 8[rbp]
	mov	esi, DWORD PTR MTK_DESC_RING_SZ[rip]
	mov	edi, DWORD PTR 0[r13]
	mov	rdx, QWORD PTR 8[rax]
	mov	ecx, DWORD PTR [rax]
	call	dma_free_coherent@PLT
	mov	rdi, QWORD PTR 8[rbp]
	call	kfree@PLT
	cmp	rbp, rbx
	jne	.L8
.L1:
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	mov	eax, r15d
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	.cfi_restore_state
	xor	r15d, r15d
	jmp	.L1
	.cfi_endproc
.LFE0:
	.size	mtk_desc_ring_alloc, .-mtk_desc_ring_alloc
	.comm	MTK_RING_MAX,4,4
	.comm	MTK_DESC_RING_SZ,4,4
	.comm	GFP_KERNEL,4,4
	.comm	ENOMEM,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_mtk-platform.c_mtk_desc_ring_alloc.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	mtk_desc_ring_alloc, %function
mtk_desc_ring_alloc:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	ldr	r10, .L19
	ldr	r3, .L19+4
	ldr	r2, [r10]
	ldr	r3, [r3]
	sub	sp, sp, #12
	cmp	r2, #0
	ldr	fp, [r0, #4]
	str	r3, [sp, #4]
	ble	.L2
	mov	r7, r0
	mov	r4, #0
	ldr	r8, .L19+8
	ldr	r9, .L19+12
	sub	r5, fp, #4
	b	.L7
.L3:
	mov	r2, r0
	ldr	r3, [r8]
	ldr	r1, [r9]
	ldr	r0, [r7]
	bl	dma_alloc_coherent
	str	r0, [r6, #4]
	ldr	r6, [r5]
	ldr	r3, [r6, #4]
	add	r2, r6, #8
	cmp	r3, #0
	beq	.L6
	ldr	r3, [r8]
	ldr	r1, [r9]
	ldr	r0, [r7]
	bl	dma_alloc_coherent
	str	r0, [r6, #12]
	ldr	r3, [r5]
	ldr	r2, [r3, #12]
	cmp	r2, #0
	beq	.L6
	ldr	r2, [r3, #4]
	ldr	r1, [r10]
	str	r2, [r3, #20]
	ldr	r3, [r5]
	add	r4, r4, #1
	ldr	r2, [r3, #12]
	cmp	r1, r4
	str	r2, [r3, #16]
	ble	.L2
.L7:
	mov	r0, #24
	ldr	r1, [r8]
	bl	kzalloc
	cmp	r0, #0
	mov	r6, r0
	str	r0, [r5, #4]!
	bne	.L3
.L6:
	cmp	r4, #0
	ldrne	r5, .L19+12
	addne	r4, fp, r4, lsl #2
	beq	.L1
.L8:
	ldr	r2, [r4, #-4]!
	ldr	r1, [r5]
	ldr	r3, [r2, #8]
	ldr	r0, [r7]
	ldr	r2, [r2, #12]
	bl	dma_free_coherent
	ldr	r2, [r4]
	ldr	r1, [r5]
	ldr	r3, [r2]
	ldr	r0, [r7]
	ldr	r2, [r2, #4]
	bl	dma_free_coherent
	ldr	r0, [r4]
	bl	kfree
	cmp	fp, r4
	bne	.L8
.L1:
	ldr	r0, [sp, #4]
	add	sp, sp, #12
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L2:
	mov	r3, #0
	str	r3, [sp, #4]
	ldr	r0, [sp, #4]
	add	sp, sp, #12
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L20:
	.align	2
.L19:
	.word	MTK_RING_MAX
	.word	ENOMEM
	.word	GFP_KERNEL
	.word	MTK_DESC_RING_SZ
	.size	mtk_desc_ring_alloc, .-mtk_desc_ring_alloc
	.comm	MTK_RING_MAX,4,4
	.comm	MTK_DESC_RING_SZ,4,4
	.comm	GFP_KERNEL,4,4
	.comm	ENOMEM,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
