DMA Linux Implementation API

group aml_dma_linux

AML DMA engine implementation with with a FIFO request queue and a pool of threads.

This module implements AML dma abstraction for memory movements on host. DMA requests are posted to a FIFO queue. The queue is polled by a pool of threads executing them.

#include <aml/dma/linux.h>

See also

“AML Asynchronous work utils”

Defines

AML_DMA_LINUX_REQUEST_FLAGS_OWNED

Request Flag of requests created but not returned to user that need to be destroyed.

AML_DMA_LINUX_REQUEST_FLAGS_DONE

Request Flag turned on when request is finished.

Functions

int aml_dma_linux_create(struct aml_dma **dma, const size_t num_threads)

Create a dma engine with a custom amount of workers.

Parameters:
  • dma[out] A pointer where to allocate the dma engine.

  • num_threads[in] The number of workers running the dma operations.

Returns:

-AML_ENOMEM on error, exclusively caused when being out of memory.

Returns:

AML_SUCCESS on success. On success, the created dma must be destroyed with aml_dma_linux_destroy().

int aml_dma_linux_destroy(struct aml_dma **dma)

Delete a linux dma created with aml_dma_linux_create().

Parameters:

dma[inout] A pointer where the dma engine has been allocated. The pointer content is set to NULL after deallocation.

Returns:

AML_SUCCESS.

void aml_dma_linux_exec_request(struct aml_task_in *input, struct aml_task_out *output)

The work item provided to the task scheduler. This function calls the operator in input with its arguments and stored the result error code in output.

Parameters:
  • input[in] A pointer to struct aml_dma_linux_task_in.

  • output[out] A pointer to an int where to store the result of the dma operator.

int aml_dma_linux_request_create(struct aml_dma_data *data, struct aml_dma_request **req, struct aml_layout *dest, struct aml_layout *src, aml_dma_operator op, void *op_arg)

The linux dma create_request() operator implementation. Creates a pointer struct aml_dma_linux_request stored in req.

int aml_dma_linux_request_wait(struct aml_dma_data *dma, struct aml_dma_request **req)

The linux dma wait_request() operator implementation.

Parameters:
  • dma[in] The dma engine where request has been posted.

  • req[in] A pointer to a struct aml_dma_linux_request.

int aml_dma_linux_barrier(struct aml_dma_data *dma)

The linux dma barrier() operator implementation.

Returns:

The first failing request error code on error. Remaining requests are not waited.

Returns:

AML_SUCCESS on success.

int aml_dma_linux_request_destroy(struct aml_dma_data *dma, struct aml_dma_request **req)

The linux dma destroy_request() operator implementation.

Parameters:
  • dma[in] unused.

  • req[in] A pointer to a struct aml_dma_linux_request. The pointer is set to NULL.

int aml_dma_linux_copy_1D(struct aml_layout *dst, const struct aml_layout *src, void *arg)

Linux DMA operator implementation: Use only with aml_dma_linux_request_create() or higher level aml_dma_async_copy_custom(). This copy operator is compatible only with:

  • This dma linux implementation,

  • Dense source and destination layouts of one dimension. Make a flat copy of contiguous bytes in between two layout raw pointers. The size of the byte stream is computed as the product of dimensions and element size.

See also

aml_layout_dense

Parameters:
  • dst[out] The destination dense layout.

  • src[in] The source dense layout.

  • arg[in] Unused.

int aml_dma_linux_memcpy_op(struct aml_layout *dst, const struct aml_layout *src, void *arg)

Linux DMA operator implementation: Use only with aml_dma_linux_request_create() or higher level aml_dma_async_copy_custom(). Make a flat copy of contiguous bytes between two raw pointers. This dma operator casts input layout pointers into void* and assumes these are contiguous set of bytes to copy from src to dst in the linux memcpy() fashion.

Parameters:
  • dst[out] The destination (void*) of the copy casted into a struct aml_layout *.

  • src[in] The source (void*) of the copy casted into a struct aml_layout *.

  • arg[in] The size (size_t) of the copy casted into a void*.

Returns:

AML_SUCCESS

int aml_dma_linux_copy_generic(struct aml_layout *dst, const struct aml_layout *src, void *arg)

Linux DMA operator implementation: Generic helper to copy from one layout to another.

Parameters:
  • dst[out] The destination layout.

  • src[in] The source layout.

  • arg[in] Ignored.

Returns:

AML_SUCCESS

Variables

struct aml_dma *aml_dma_linux

Pre instantiated linux dma engine. The user may use this directly after a successful call to aml_init(). This pointer is not valid anymore after aml_finalize() is called.

struct aml_dma_ops aml_dma_linux_ops

The methods table of linux dma.

struct aml_dma_linux_data
#include <linux.h>

The dma data is simply a task scheduler.

struct aml_dma_linux_task_in
#include <linux.h>

The task input structure sent to the scheduler workers to perform the dma operator work.

struct aml_dma_linux_request
#include <linux.h>

The dma request implementation