DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

udi_dma_buf_unmap(3udi)


Release a buffer's DMA mapping

SYNOPSIS

#include <udi.h>

udi_buf_t *udi_dma_buf_unmap (

	udi_dma_handle_t dma_handle,

	udi_size_t new_buf_size );
 

ARGUMENTS dma_handle is a DMA handle previously mapped via udi_dma_buf_map.

new_buf_size is the number of bytes of data to preserve from the mapped buffer. This becomes the new value of buf->buf_size for the buffer.

DESCRIPTION udi_dma_buf_unmap frees any resources associated with a DMA handle by a previous udi_dma_buf_map request. It should be used when a DMA transfer completes and its DMA handle is not going to be reused with the associated buffer.

If the flags passed to udi_dma_buf_map for this handle included UDI_DMA_IN, udi_dma_buf_unmap performs an implicit inbound udi_dma_sync for the entire mapped range and ensures that any data modified by the device is now visible to the driver.

If dma_handle is equal to UDI_NULL_DMA_HANDLE, explicitly or implicitly (zeroed by initial value or by using udi_memset), this function acts as a no-op. Otherwise, dma_handle must have been allocated by udi_dma_prepare.

Even if the buffer's buf_size value was changed while the buffer was mapped, the entire buffer will be unmapped. Any buffer data beyond new_buf_size at the time of the udi_dma_buf_unmap will be discarded (though the memory might not be).

WARNINGS The driver must make sure that its device is no longer accessing the buffer or control structure memory before it calls udi_dma_buf_unmap.

RETURN VALUES The udi_dma_buf_unmap function returns a buffer pointer that the driver must now use in place of the original buf. This is logically the same buffer that was passed to udi_dma_buf_map, but the environment may have reallocated it in the process of handling the DMA operation.

REFERENCES udi_dma_buf_map, udi_dma_prepare


UDI Physical I/O Specification Contents