SND_MALLOC_PAGES(9) Management of Cards and Device SND_MALLOC_PAGES(9)NAME
snd_malloc_pages - allocate pages with the given size
SYNOPSIS
void * snd_malloc_pages(size_t size, gfp_t gfp_flags);
ARGUMENTS
size
the size to allocate in bytes
gfp_flags
the allocation conditions, GFP_XXX
DESCRIPTION
Allocates the physically contiguous pages with the given size.
RETURN
The pointer of the buffer, or NULL if no enough memory.
COPYRIGHT Kernel Hackers Manual 3.10 June 2014 SND_MALLOC_PAGES(9)
Check Out this Related Man Page
contig_malloc(9r)contig_malloc(9r)NAME
contig_malloc - General: Allocates physically contiguous memory
SYNOPSIS
#include <sys/malloc.h>
void * contig_malloc(
u_long size,
u_long alignment,
u_long addrlimit,
int type,
int flag );
ARGUMENTS
Specifies the size of the memory (in bytes) to allocate. Specifies the alignment of the memory to be allocated. For example, for a
256-byte alignment, you should pass the value 256. A 0 (zero) value means there is no alignment requirement. Specifies that the address of
all the allocated memory should be less than or equal to this address. A 0 (zero) value means that there is no address limit requirement.
Specifies the purpose for which the memory is being allocated (or freed). The memory type constants are defined in the file
/usr/sys/include/sys/malloc.h. Examples of memory type constants are M_DEVBUF (device driver memory), M_KTABLE (kernel table memory),
M_RTABLE (routing tables memory), and so forth. Specifies one of the following flags defined in /usr/sys/include/sys/malloc.h: Signifies
that contig_malloc should zero the allocated memory. Signifies that contig_malloc can block. Signifies that contig_malloc cannot block.
DESCRIPTION
The contig_malloc routine allocates physically contiguous memory during the boot process (before single-user mode). The routine carves out
an area of physically contiguous memory from a contiguous memory buffer and allocates memory from this buffer with proper alignment. The
call to contig_malloc is the same for statically or dynamically configured drivers. However, the point or points in time in which the stat-
ically or dynamically configured driver requests the memory differ.
A statically configured driver typically needs to call contig_malloc only before single-user mode. In this case, contig_malloc obtains the
memory from the contiguous memory buffer. When a statically configured driver frees this physically contiguous memory (by calling the con-
tig_free routine), the memory is returned to the virtual memory subsystem.
A dynamically configured driver typically needs physically contiguous memory after single-user mode. As stated previously, contig_malloc
carves out an area of physically contiguous memory from a contiguous memory buffer before single-user mode. Thus, this memory would not be
available to the dynamically configured driver after single-user mode. To solve this problem, a dynamically configured driver calls con-
tig_malloc by defining the CMA_Option attribute in the sysconfigtab file fragment.
The cma_dd subsystem calls contig_malloc on behalf of dynamically configured device drivers and obtains the memory allocation size (and
other information) from the CMA_Option attribute field. In this case, contig_malloc allocates physically contiguous memory from the con-
tiguous memory buffer and places it in a saved memory pool. When a dynamically configured driver needs to call contig_malloc after single-
user mode, the physically contiguous memory comes from this saved memory pool. When a dynamically configured driver frees this physically
contiguous memory (by calling the contig_free routine), the memory is returned to the saved memory pool (not to the virtual memory subsys-
tem). Thus, this physically contiguous memory is available to the dynamically configured driver upon subsequent reload requests that occur
after single-user mode.
RETURN VALUES
Upon successful completion, contig_malloc returns a pointer to the allocated memory. If contig_malloc cannot allocate the requested memory,
it returns a null pointer.
SEE ALSO
Routines: contig_free(9r)contig_malloc(9r)