experimental PCI DMA fixes use proper Linux interfaces
parent
4c1c05ad96
commit
0a211db23c
|
@ -361,6 +361,12 @@ typedef struct drm_freelist {
|
|||
spinlock_t lock;
|
||||
} drm_freelist_t;
|
||||
|
||||
typedef struct drm_dma_handle {
|
||||
dma_addr_t busaddr;
|
||||
void *vaddr;
|
||||
size_t size;
|
||||
} drm_dma_handle_t;
|
||||
|
||||
/**
|
||||
* Buffer entry. There is one of this for each buffer size order.
|
||||
*/
|
||||
|
@ -370,8 +376,7 @@ typedef struct drm_buf_entry {
|
|||
drm_buf_t *buflist; /**< buffer list */
|
||||
int seg_count;
|
||||
int page_order;
|
||||
unsigned long *seglist;
|
||||
|
||||
drm_dma_handle_t **seglist;
|
||||
drm_freelist_t freelist;
|
||||
} drm_buf_entry_t;
|
||||
|
||||
|
@ -489,12 +494,6 @@ typedef struct drm_sigdata {
|
|||
drm_hw_lock_t *lock;
|
||||
} drm_sigdata_t;
|
||||
|
||||
typedef struct drm_dma_handle {
|
||||
dma_addr_t busaddr;
|
||||
void *vaddr;
|
||||
size_t size;
|
||||
} drm_dma_handle_t;
|
||||
|
||||
/**
|
||||
* Mappings list
|
||||
*/
|
||||
|
|
|
@ -515,8 +515,7 @@ static void drm_cleanup_buf_error(drm_device_t * dev, drm_buf_entry_t * entry)
|
|||
if (entry->seg_count) {
|
||||
for (i = 0; i < entry->seg_count; i++) {
|
||||
if (entry->seglist[i]) {
|
||||
drm_free_pages(entry->seglist[i],
|
||||
entry->page_order, DRM_MEM_DMA);
|
||||
drm_pci_free(dev, entry->seglist[i]);
|
||||
}
|
||||
}
|
||||
drm_free(entry->seglist,
|
||||
|
@ -733,7 +732,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
|
|||
int total;
|
||||
int page_order;
|
||||
drm_buf_entry_t *entry;
|
||||
unsigned long page;
|
||||
drm_dma_handle_t *dmah;
|
||||
drm_buf_t *buf;
|
||||
int alignment;
|
||||
unsigned long offset;
|
||||
|
@ -836,8 +835,10 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
|
|||
page_count = 0;
|
||||
|
||||
while (entry->buf_count < count) {
|
||||
page = drm_alloc_pages(page_order, DRM_MEM_DMA);
|
||||
if (!page) {
|
||||
|
||||
dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000, 0xfffffffful);
|
||||
|
||||
if (!dmah) {
|
||||
/* Set count correctly so we free the proper amount. */
|
||||
entry->buf_count = count;
|
||||
entry->seg_count = count;
|
||||
|
@ -849,13 +850,13 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
|
|||
atomic_dec(&dev->buf_alloc);
|
||||
return -ENOMEM;
|
||||
}
|
||||
entry->seglist[entry->seg_count++] = page;
|
||||
entry->seglist[entry->seg_count++] = dmah;
|
||||
for (i = 0; i < (1 << page_order); i++) {
|
||||
DRM_DEBUG("page %d @ 0x%08lx\n",
|
||||
dma->page_count + page_count,
|
||||
page + PAGE_SIZE * i);
|
||||
(unsigned long)dmah->vaddr + PAGE_SIZE * i);
|
||||
temp_pagelist[dma->page_count + page_count++]
|
||||
= page + PAGE_SIZE * i;
|
||||
= (unsigned long)dmah->vaddr + PAGE_SIZE * i;
|
||||
}
|
||||
for (offset = 0;
|
||||
offset + size <= total && entry->buf_count < count;
|
||||
|
@ -866,7 +867,8 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
|
|||
buf->order = order;
|
||||
buf->used = 0;
|
||||
buf->offset = (dma->byte_count + byte_count + offset);
|
||||
buf->address = (void *)(page + offset);
|
||||
buf->address = (void *)(dmah->vaddr + offset);
|
||||
buf->bus_address = dmah->busaddr + offset;
|
||||
buf->next = NULL;
|
||||
buf->waiting = 0;
|
||||
buf->pending = 0;
|
||||
|
|
|
@ -85,9 +85,7 @@ void drm_dma_takedown(drm_device_t * dev)
|
|||
dma->bufs[i].seg_count);
|
||||
for (j = 0; j < dma->bufs[i].seg_count; j++) {
|
||||
if (dma->bufs[i].seglist[j]) {
|
||||
drm_free_pages(dma->bufs[i].seglist[j],
|
||||
dma->bufs[i].page_order,
|
||||
DRM_MEM_DMA);
|
||||
drm_pci_free(dev, dma->bufs[i].seglist[j]);
|
||||
}
|
||||
}
|
||||
drm_free(dma->bufs[i].seglist,
|
||||
|
|
Loading…
Reference in New Issue