#include <rdma/uverbs_ioctl.h>
#include "mmap.h"
+/* number of reserved mmaps for the driver */
+#define MMAP_RESERVED 256
+/* start point for dynamic offsets */
+#define MMAP_OFFSET_START (MMAP_RESERVED * PAGE_SIZE)
+
/**
* rvt_mmap_init - init link list and lock for mem map
* @rdi: rvt dev struct
{
INIT_LIST_HEAD(&rdi->pending_mmaps);
spin_lock_init(&rdi->pending_lock);
- rdi->mmap_offset = PAGE_SIZE;
+ rdi->mmap_offset = MMAP_OFFSET_START;
spin_lock_init(&rdi->mmap_offset_lock);
}
struct rvt_mmap_info *ip, *pp;
int ret = -EINVAL;
+ /* call driver if in reserved range */
+ if (offset < MMAP_OFFSET_START) {
+ if (rdi->driver_f.mmap)
+ return rdi->driver_f.mmap(context, vma);
+ return -EINVAL;
+ }
+
/*
* Search the device's list of objects waiting for a mmap call.
* Normally, this list is very short since a call to create a
spin_lock_irq(&rdi->mmap_offset_lock);
if (rdi->mmap_offset == 0)
- rdi->mmap_offset = ALIGN(PAGE_SIZE, SHMLBA);
+ rdi->mmap_offset = MMAP_OFFSET_START;
ip->offset = rdi->mmap_offset;
- rdi->mmap_offset += ALIGN(size, SHMLBA);
+ rdi->mmap_offset += PAGE_SIZE;
spin_unlock_irq(&rdi->mmap_offset_lock);
INIT_LIST_HEAD(&ip->pending_mmaps);
spin_lock_irq(&rdi->mmap_offset_lock);
if (rdi->mmap_offset == 0)
- rdi->mmap_offset = PAGE_SIZE;
+ rdi->mmap_offset = MMAP_OFFSET_START;
ip->offset = rdi->mmap_offset;
- rdi->mmap_offset += size;
+ rdi->mmap_offset += PAGE_SIZE;
spin_unlock_irq(&rdi->mmap_offset_lock);
ip->size = size;