Skip to content

Commit

Permalink
casing on kernel version to determine if dma_alloc_pages existed yet
Browse files Browse the repository at this point in the history
  • Loading branch information
ruck314 committed Jul 3, 2024
1 parent 7da8ea0 commit 0c78987
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions common/driver/dma_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
* ----------------------------------------------------------------------------
**/

#include <dma_buffer.h>
#include <asm/io.h>
#include <linux/dma-mapping.h>
#include <linux/sort.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/version.h>

#include <dma_buffer.h>
#include <dma_common.h>

/**
Expand Down Expand Up @@ -106,12 +108,22 @@ size_t dmaAllocBuffers ( struct DmaDevice *dev, struct DmaBufferList *list,

// Streaming buffer type, standard kernel memory
else if ( list->dev->cfgMode & BUFF_STREAM ) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
buff->buffAddr = kmalloc(list->dev->cfgSize, GFP_KERNEL);
if (buff->buffAddr != NULL) {
buff->buffHandle = dma_map_single(list->dev->device, buff->buffAddr, list->dev->cfgSize, direction);
// Check for mapping error
if ( dma_mapping_error(list->dev->device,buff->buffHandle) ) {
buff->buffHandle = 0;
}
}
#else
buff->buffAddr = dma_alloc_pages(list->dev->device, list->dev->cfgSize, &buff->buffHandle, direction, GFP_KERNEL);

// Check for mapping error
if (buff->buffAddr == NULL) {
dev_err(dev->device, "dmaAllocBuffers: dma_alloc_pages failed\n");
}
#endif
}

// ACP type with permanent handle mapping, dma capable kernel memory
Expand Down

0 comments on commit 0c78987

Please sign in to comment.