/alps/pcitool

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to driver/kmem.c

  • Committer: Vasilii Chernov
  • Date: 2016-03-02 07:48:24 UTC
  • mfrom: (359 pcitool)
  • mto: This revision was merged to the branch mainline in revision 367.
  • Revision ID: vchernov@inr.ru-20160302074824-gcpwar3f33n5353q
1. Merge with http://ufo.kit.edu/ufo/log/csa/pcitool 359 revision
2. Move api_server to html server

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
         */
138
138
        switch (kmem_entry->type&PCILIB_KMEM_TYPE_MASK) {
139
139
         case PCILIB_KMEM_TYPE_CONSISTENT:
 
140
#ifdef PCIDRIVER_DUMMY_DEVICE
 
141
            retptr = kmalloc( kmem_handle->size, GFP_KERNEL);
 
142
#else /* PCIDRIVER_DUMMY_DEVICE */
140
143
            retptr = pci_alloc_consistent( privdata->pdev, kmem_handle->size, &(kmem_entry->dma_handle) );
 
144
#endif /* PCIDRIVER_DUMMY_DEVICE */
141
145
            break;
142
146
         case PCILIB_KMEM_TYPE_REGION:
143
147
            retptr = ioremap(kmem_handle->pa,  kmem_handle->size);
162
166
            kmem_entry->dma_handle = 0;
163
167
 
164
168
            if (retptr) {
 
169
#ifndef PCIDRIVER_DUMMY_DEVICE
165
170
                if (kmem_entry->type == PCILIB_KMEM_TYPE_DMA_S2C_PAGE) {
166
171
                    kmem_entry->direction = PCI_DMA_TODEVICE;
167
172
                    kmem_entry->dma_handle = pci_map_single(privdata->pdev, retptr, kmem_handle->size, PCI_DMA_TODEVICE);
178
183
                    
179
184
                    }
180
185
                }
 
186
#endif /* ! PCIDRIVER_DUMMY_DEVICE */
181
187
            }
182
188
            
183
189
            break;
361
367
        if (kmem_entry->direction == PCI_DMA_NONE)
362
368
                return -EINVAL;
363
369
 
 
370
#ifndef PCIDRIVER_DUMMY_DEVICE
364
371
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
365
372
        switch (direction) {
366
373
                case PCILIB_KMEM_SYNC_TODEVICE:
391
398
                        return -EINVAL;                         /* wrong direction parameter */
392
399
        }
393
400
#endif
 
401
#endif /* ! PCIDRIVER_DUMMY_DEVICE */
394
402
 
395
403
        return 0;       /* success */
396
404
}
480
488
        /* Release DMA memory */
481
489
        switch (kmem_entry->type&PCILIB_KMEM_TYPE_MASK) {
482
490
         case PCILIB_KMEM_TYPE_CONSISTENT:
 
491
#ifdef PCIDRIVER_DUMMY_DEVICE
 
492
            kfree((void*)(kmem_entry->cpua));
 
493
#else /* PCIDRIVER_DUMMY_DEVICE */
483
494
            pci_free_consistent( privdata->pdev, kmem_entry->size, (void *)(kmem_entry->cpua), kmem_entry->dma_handle );
 
495
#endif /* PCIDRIVER_DUMMY_DEVICE */
484
496
            break;
485
497
         case PCILIB_KMEM_TYPE_REGION:
486
498
            iounmap((void *)(kmem_entry->cpua));
487
499
            break;
488
500
         case PCILIB_KMEM_TYPE_PAGE:
 
501
#ifndef PCIDRIVER_DUMMY_DEVICE
489
502
            if (kmem_entry->dma_handle) {
490
503
                if (kmem_entry->type == PCILIB_KMEM_TYPE_DMA_S2C_PAGE) {
491
504
                    pci_unmap_single(privdata->pdev, kmem_entry->dma_handle, kmem_entry->size, PCI_DMA_TODEVICE);
493
506
                    pci_unmap_single(privdata->pdev, kmem_entry->dma_handle, kmem_entry->size, PCI_DMA_FROMDEVICE);
494
507
                }
495
508
            }
 
509
#endif /* ! PCIDRIVER_DUMMY_DEVICE */
496
510
            free_pages((unsigned long)kmem_entry->cpua, get_order(kmem_entry->size));
497
511
            break;
498
512
        }