unsigned long new_size)
{
comedi_async *async = s->async;
- unsigned long adr;
/* if no change is required, do nothing */
if(async->prealloc_buf && async->prealloc_bufsz == new_size){
return 0;
}
- // cleanup old buffer
- if(async->prealloc_bufsz)
- {
- int i;
- unsigned n_pages = async->prealloc_bufsz >> PAGE_SHIFT;
-
- adr = (unsigned long) async->prealloc_buf;
- for(i = 0; i < n_pages; i++){
- mem_map_unreserve(virt_to_page(adr));
- adr += PAGE_SIZE;
- }
- async->prealloc_bufsz = 0;
- }
if(async->prealloc_buf)
{
if(s->async_dma_dir != DMA_NONE)
vfree(async->prealloc_buf);
}
async->prealloc_buf = NULL;
+ async->prealloc_bufsz = 0;
}
if(async->buf_page_list)
{
for(i = 0; i < async->n_buf_pages; ++i)
{
if(async->buf_page_list[i].virt_addr)
+ mem_map_unreserve(virt_to_page(async->buf_page_list[i].virt_addr));
+ if(async->buf_page_list[i].dma_addr)
{
dma_free_coherent(dev->hw_dev, PAGE_SIZE,
async->buf_page_list[i].virt_addr, async->buf_page_list[i].dma_addr);
// size is rounded up to nearest multiple of PAGE_SIZE
new_size = n_pages << PAGE_SHIFT;
+ async->buf_page_list = vmalloc(sizeof(struct comedi_buf_page) * n_pages);
+ if(async->buf_page_list == NULL)
+ {
+ return -ENOMEM;
+ }
+ memset(async->buf_page_list, 0, sizeof(struct comedi_buf_page) * n_pages);
+ async->n_buf_pages = n_pages;
+
if(s->async_dma_dir != DMA_NONE)
{
struct page** pages = NULL;
- async->buf_page_list = vmalloc(sizeof(struct comedi_buf_page) * n_pages);
- if(async->buf_page_list == NULL)
- {
- return -ENOMEM;
- }
- memset(async->buf_page_list, 0, sizeof(struct comedi_buf_page) * n_pages);
- async->n_buf_pages = n_pages;
-
pages = vmalloc(sizeof(struct page*) * n_pages);
if(pages == NULL)
{
vfree(pages);
return -ENOMEM;
}
+ mem_map_reserve(virt_to_page(async->buf_page_list[i].virt_addr));
pages[i] = virt_to_page(async->buf_page_list[i].virt_addr);
}
async->prealloc_buf = vmap(pages, n_pages, VM_MAP, PAGE_KERNEL_NOCACHE);
{
return -ENOMEM;
}
- }
-
- adr = (unsigned long)async->prealloc_buf;
- for(i = 0; i < n_pages; i++)
- {
- mem_map_reserve(virt_to_page(adr));
- adr += PAGE_SIZE;
+ for(i = 0; i < n_pages; i++)
+ {
+ async->buf_page_list[i].virt_addr = async->prealloc_buf + PAGE_SIZE * i;
+ mem_map_reserve(virt_to_page(async->buf_page_list[i].virt_addr));
+ }
}
}
async->prealloc_bufsz = new_size;