diff options
Diffstat (limited to 'linux-core')
-rw-r--r-- | linux-core/drmP.h | 8 | ||||
-rw-r--r-- | linux-core/drm_bufs.c | 57 | ||||
-rw-r--r-- | linux-core/drm_dma.c | 23 |
3 files changed, 45 insertions, 43 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 95a79c8e..d50bb2d9 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -105,9 +105,6 @@ #ifndef __HAVE_IRQ #define __HAVE_IRQ 0 #endif -#ifndef __HAVE_DMA_FREELIST -#define __HAVE_DMA_FREELIST 0 -#endif #define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \ defined(CONFIG_AGP_MODULE))) @@ -590,7 +587,10 @@ struct drm_driver_fn { int (*kernel_context_switch)(struct drm_device *dev, int old, int new); int (*kernel_context_switch_unlock)(struct drm_device *dev); int (*dma_schedule)(struct drm_device *dev, int locked); - int (*waitlist_destroy)(drm_waitlist_t *bl); + int (*waitlist_destroy)(drm_waitlist_t *bl); + int (*freelist_create)(drm_freelist_t *bl, int count); + int (*freelist_put)(struct drm_device *dev, drm_freelist_t *bl, drm_buf_t *buf); + int (*freelist_destroy)(drm_freelist_t *bl); }; /** * DRM device structure. diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index 3c0d5717..d3d0b83c 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -304,7 +304,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, * * Frees any pages and buffers associated with the given entry. */ -static void DRM(cleanup_buf_error)(drm_buf_entry_t *entry) +static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry) { int i; @@ -337,9 +337,8 @@ static void DRM(cleanup_buf_error)(drm_buf_entry_t *entry) sizeof(*entry->buflist), DRM_MEM_BUFS); -#if __HAVE_DMA_FREELIST - DRM(freelist_destroy)(&entry->freelist); -#endif + if (dev->fn_tbl.freelist_destroy) + dev->fn_tbl.freelist_destroy(&entry->freelist); entry->buf_count = 0; } @@ -468,7 +467,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, if(!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; - DRM(cleanup_buf_error)(entry); + DRM(cleanup_buf_error)(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -492,7 +491,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, DRM_MEM_BUFS ); if(!temp_buflist) { /* Free the entry because it isn't valid */ - DRM(cleanup_buf_error)(entry); + DRM(cleanup_buf_error)(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -509,12 +508,14 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, DRM_DEBUG( "dma->buf_count : %d\n", dma->buf_count ); DRM_DEBUG( "entry->buf_count : %d\n", entry->buf_count ); -#if __HAVE_DMA_FREELIST - DRM(freelist_create)( &entry->freelist, entry->buf_count ); - for ( i = 0 ; i < entry->buf_count ; i++ ) { - DRM(freelist_put)( dev, &entry->freelist, &entry->buflist[i] ); + if (dev->fn_tbl.freelist_create) + { + dev->fn_tbl.freelist_create( &entry->freelist, entry->buf_count); + for ( i = 0 ; i < entry->buf_count ; i++ ) { + dev->fn_tbl.freelist_put( dev, &entry->freelist, &entry->buflist[i] ); + } } -#endif + up( &dev->struct_sem ); request.count = entry->buf_count; @@ -653,7 +654,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, /* Set count correctly so we free the proper amount. */ entry->buf_count = count; entry->seg_count = count; - DRM(cleanup_buf_error)(entry); + DRM(cleanup_buf_error)(dev,entry); DRM(free)( temp_pagelist, (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), @@ -694,7 +695,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, /* Set count correctly so we free the proper amount. */ entry->buf_count = count; entry->seg_count = count; - DRM(cleanup_buf_error)(entry); + DRM(cleanup_buf_error)(dev,entry); DRM(free)( temp_pagelist, (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), @@ -718,7 +719,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, DRM_MEM_BUFS ); if (!temp_buflist) { /* Free the entry because it isn't valid */ - DRM(cleanup_buf_error)(entry); + DRM(cleanup_buf_error)(dev,entry); DRM(free)( temp_pagelist, (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), @@ -748,12 +749,14 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, dma->page_count += entry->seg_count << page_order; dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order); -#if __HAVE_DMA_FREELIST - DRM(freelist_create)( &entry->freelist, entry->buf_count ); - for ( i = 0 ; i < entry->buf_count ; i++ ) { - DRM(freelist_put)( dev, &entry->freelist, &entry->buflist[i] ); + if (dev->fn_tbl.freelist_create) + { + dev->fn_tbl.freelist_create( &entry->freelist, entry->buf_count); + for ( i = 0 ; i < entry->buf_count ; i++ ) { + dev->fn_tbl.freelist_put( dev, &entry->freelist, &entry->buflist[i] ); + } } -#endif + up( &dev->struct_sem ); request.count = entry->buf_count; @@ -877,7 +880,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, if(!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; - DRM(cleanup_buf_error)(entry); + DRM(cleanup_buf_error)(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -902,7 +905,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, DRM_MEM_BUFS ); if(!temp_buflist) { /* Free the entry because it isn't valid */ - DRM(cleanup_buf_error)(entry); + DRM(cleanup_buf_error)(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -919,12 +922,14 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, DRM_DEBUG( "dma->buf_count : %d\n", dma->buf_count ); DRM_DEBUG( "entry->buf_count : %d\n", entry->buf_count ); -#if __HAVE_DMA_FREELIST - DRM(freelist_create)( &entry->freelist, entry->buf_count ); - for ( i = 0 ; i < entry->buf_count ; i++ ) { - DRM(freelist_put)( dev, &entry->freelist, &entry->buflist[i] ); + if (dev->fn_tbl.freelist_create) + { + dev->fn_tbl.freelist_create( &entry->freelist, entry->buf_count); + for ( i = 0 ; i < entry->buf_count ; i++ ) { + dev->fn_tbl.freelist_put( dev, &entry->freelist, &entry->buflist[i] ); + } } -#endif + up( &dev->struct_sem ); request.count = entry->buf_count; diff --git a/linux-core/drm_dma.c b/linux-core/drm_dma.c index 04467342..811d768d 100644 --- a/linux-core/drm_dma.c +++ b/linux-core/drm_dma.c @@ -117,9 +117,9 @@ void DRM(dma_takedown)(drm_device_t *dev) dma->bufs[i].buf_count * sizeof(*dma->bufs[0].buflist), DRM_MEM_BUFS); -#if __HAVE_DMA_FREELIST - DRM(freelist_destroy)(&dma->bufs[i].freelist); -#endif + + if (dev->fn_tbl.freelist_destroy) + dev->fn_tbl.freelist_destroy(&dma->bufs[i].freelist); } } @@ -159,16 +159,13 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf) if ( __HAVE_DMA_WAITQUEUE && waitqueue_active(&buf->dma_wait)) { wake_up_interruptible(&buf->dma_wait); } -#if __HAVE_DMA_FREELIST - else { - drm_device_dma_t *dma = dev->dma; - /* If processes are waiting, the last one - to wake will put the buffer on the free - list. If no processes are waiting, we - put the buffer on the freelist here. */ - DRM(freelist_put)(dev, &dma->bufs[buf->order].freelist, buf); - } -#endif + /* If processes are waiting, the last one + to wake will put the buffer on the free + list. If no processes are waiting, we + put the buffer on the freelist here. */ + else if (dev->fn_tbl.freelist_put) + dev->fn_tbl.freelist_put(dev, &dev->dma->bufs[buf->order].freelist, buf); + } #if !__HAVE_DMA_RECLAIM |