Skip to content

Commit

Permalink
dma_map_single() being depreciated in future and switching to dma_all…
Browse files Browse the repository at this point in the history
…oc_coherent()

offers simplified management, potentially better performance, reduced fragmentation, and safer memory access for your DMA operations
  • Loading branch information
ruck314 committed Feb 27, 2024
1 parent 31d35ca commit 5a73302
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions common/driver/dma_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,13 @@ size_t dmaAllocBuffers ( struct DmaDevice *dev, struct DmaBufferList *list,

// Streaming buffer type, standard kernel memory
else if ( list->dev->cfgMode & BUFF_STREAM ) {
buff->buffAddr = kzalloc(list->dev->cfgSize, GFP_KERNEL);
dev_info(dev->device,"dmaAllocBuffers: BUFF_STREAM\n");
// Allocate consistent memory directly using dma_alloc_coherent
buff->buffAddr = dma_alloc_coherent(list->dev->device, list->dev->cfgSize, &buff->buffHandle, GFP_KERNEL);

if (buff->buffAddr != NULL) {
buff->buffHandle = dma_map_single(list->dev->device,buff->buffAddr,
list->dev->cfgSize,direction);

// Map error
if ( dma_mapping_error(list->dev->device,buff->buffHandle) ) {
buff->buffHandle = 0;
}
// Check for mapping error
if (buff->buffAddr == NULL) {
dev_err(dev->device,"dmaAllocBuffers: dma_alloc_coherent failed\n");
}
}

Expand Down

0 comments on commit 5a73302

Please sign in to comment.