Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\cma.c Create Date:2022-07-28 16:31:57
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:ma_declare_contiguous() - reserve custom contiguous area*@base: Base address of the reserved area optional, use 0 for any*@size: Size of the reserved area (in bytes),*@limit: End address of the reserved memory (optional, 0 for any)

Proto:int __init cma_declare_contiguous(phys_addr_t base, phys_addr_t size, phys_addr_t limit, phys_addr_t alignment, unsigned int order_per_bit, bool fixed, const char *name, struct cma **res_cma)

Type:int

Parameter:

TypeParameterName
phys_addr_tbase
phys_addr_tsize
phys_addr_tlimit
phys_addr_talignment
unsigned intorder_per_bit
boolfixed
const char *name
struct cma **res_cma
246  memblock_end = memblock_end_of_DRAM()
248  ret = 0
256  highmem_start = __pa(A number of key systems in x86 including ioremap() rely on the assumption* that high_memory defines the upper bound on direct map memory, then end* of ZONE_NORMAL - 1) + 1
257  pr_debug("%s(size %pa, base %pa, limit %pa alignment %pa)\n", __func__, & size, & base, & limit, & alignment)
260  If cma_area_count == ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(cma_areas) Then
261  pr_err("Not enough slots for CMA reserved regions!\n")
262  Return -ENOSPC
265  If Not size Then Return -EINVAL
268  If alignment && Not s_power_of_2() - check if a value is a power of two*@n: the value to check* Determine whether some value is a power of two, where zero is* *not* considered a power of two.* Return: true if @n is a power of 2, otherwise false. Then Return -EINVAL
277  alignment = max - return maximum of two values of the same or compatible types*@x: first value*@y: second value(alignment, (phys_addr_t)PAGE_SIZE << max_t - return maximum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(unsignedlong, Free memory management - zoned buddy allocator. - 1, Huge pages are a constant size ))
279  If fixed && base & alignment - 1 Then
280  ret = -EINVAL
281  pr_err("Region at %pa must be aligned to %pa bytes\n", & base, & alignment)
283  Go to err
285  base = @a is a power of 2 value (base, alignment)
286  size = @a is a power of 2 value (size, alignment)
287  limit &= ~(alignment - 1)
289  If Not base Then fixed = false
293  If Not IS_ALIGNED(size >> PAGE_SHIFT determines the page size , 1 << order_per_bit) Then Return -EINVAL
300  If fixed && base < highmem_start && base + size > highmem_start Then
301  ret = -EINVAL
302  pr_err("Region at %pa defined on low/high memory boundary (%pa)\n", & base, & highmem_start)
304  Go to err
312  If limit == 0 || limit > memblock_end Then limit = memblock_end
315  If base + size > limit Then
316  ret = -EINVAL
317  pr_err("Size (%pa) of region at %pa exceeds limit (%pa)\n", & size, & base, & limit)
319  Go to err
323  If fixed Then
326  ret = -EBUSY
327  Go to err
329  Else
330  addr = 0
338  If base < highmem_start && limit > highmem_start Then
344  If Not addr Then
347  If Not addr Then
348  ret = -ENOMEM
349  Go to err
357  kmemleak_ignore_phys - similar to kmemleak_ignore but taking a physical* address argument*@phys: physical address of the object
358  base = addr
361  ret = ma_init_reserved_mem() - create custom contiguous area from reserved memory*@base: Base address of the reserved area*@size: Size of the reserved area (in bytes),*@order_per_bit: Order of pages represented by one bit on bitmap.*@name: The name of the area
362  If ret Then Go to free_mem
365  pr_info("Reserved %ld MiB at %pa\n", (unsignedlong)size / SZ_1M, & base)
367  Return 0
369  free_mem :
370  memblock_free(base, size)
371  err :
372  pr_err("Failed to reserve %ld MiB\n", (unsignedlong)size / SZ_1M)
373  Return ret