Fixup OS_HAS_AGP/OS_HAS_MTRR along lines of patches going to kernel, as

suggested by Arjan..
Signed-off-by: Dave Airlie <airlied@linux.ie>
main
Dave Airlie 2004-09-04 23:21:40 +00:00
parent 3d9e16aa6e
commit 4499ea42ea
12 changed files with 238 additions and 162 deletions

View File

@ -83,6 +83,9 @@
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
#include "drm.h" #include "drm.h"
#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
#include "drm_os_linux.h" #include "drm_os_linux.h"
/* If you want the memory alloc debug functionality, change define below */ /* If you want the memory alloc debug functionality, change define below */
@ -104,11 +107,8 @@
#define DRIVER_IRQ_VBL 0x200 #define DRIVER_IRQ_VBL 0x200
#define DRIVER_DMA_QUEUE 0x800 #define DRIVER_DMA_QUEUE 0x800
#define __OS_HAS_AGP (defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE))
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
/*@}*/ /*@}*/
/***********************************************************************/ /***********************************************************************/
/** \name Begin the DRM... */ /** \name Begin the DRM... */
/*@{*/ /*@{*/
@ -431,7 +431,6 @@ typedef struct drm_device_dma {
/*@}*/ /*@}*/
} drm_device_dma_t; } drm_device_dma_t;
#if __OS_HAS_AGP
/** /**
* AGP memory entry. Stored as a doubly linked list. * AGP memory entry. Stored as a doubly linked list.
*/ */
@ -460,7 +459,6 @@ typedef struct drm_agp_head {
int cant_use_aperture; int cant_use_aperture;
unsigned long page_mask; unsigned long page_mask;
} drm_agp_head_t; } drm_agp_head_t;
#endif
/** /**
* Scatter-gather memory. * Scatter-gather memory.
@ -654,9 +652,7 @@ typedef struct drm_device {
wait_queue_head_t buf_readers; /**< Processes waiting to read */ wait_queue_head_t buf_readers; /**< Processes waiting to read */
wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */ wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
#if __OS_HAS_AGP
drm_agp_head_t *agp; /**< AGP data */ drm_agp_head_t *agp; /**< AGP data */
#endif
struct pci_dev *pdev; /**< PCI device structure */ struct pci_dev *pdev; /**< PCI device structure */
int pci_domain; /**< PCI bus domain number */ int pci_domain; /**< PCI bus domain number */
@ -688,6 +684,24 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature
return ((dev->driver_features & feature) ? 1 : 0); return ((dev->driver_features & feature) ? 1 : 0);
} }
#if __OS_HAS_AGP
static inline int drm_core_has_AGP(struct drm_device *dev)
{
return drm_core_check_feature(dev, DRIVER_USE_AGP);
}
#else
#define drm_core_has_AGP(dev) (0)
#endif
#if __OS_HAS_MTRR
static inline int drm_core_has_MTRR(struct drm_device *dev)
{
return drm_core_check_feature(dev, DRIVER_USE_MTRR);
}
#else
#define drm_core_has_MTRR(dev) (0)
#endif
extern void DRM(driver_register_fns)(struct drm_device *dev); extern void DRM(driver_register_fns)(struct drm_device *dev);
/******************************************************************/ /******************************************************************/
@ -744,12 +758,10 @@ extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size,
drm_device_t *dev); drm_device_t *dev);
extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev); extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev);
#if __OS_HAS_AGP
extern DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type); extern DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type);
extern int DRM(free_agp)(DRM_AGP_MEM *handle, int pages); extern int DRM(free_agp)(DRM_AGP_MEM *handle, int pages);
extern int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start); extern int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start);
extern int DRM(unbind_agp)(DRM_AGP_MEM *handle); extern int DRM(unbind_agp)(DRM_AGP_MEM *handle);
#endif
/* Misc. IOCTL support (drm_ioctl.h) */ /* Misc. IOCTL support (drm_ioctl.h) */
extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp, extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
@ -866,7 +878,6 @@ extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
extern void DRM(vbl_send_signals)( drm_device_t *dev ); extern void DRM(vbl_send_signals)( drm_device_t *dev );
#if __OS_HAS_AGP
/* AGP/GART support (drm_agpsupport.h) */ /* AGP/GART support (drm_agpsupport.h) */
extern drm_agp_head_t *DRM(agp_init)(void); extern drm_agp_head_t *DRM(agp_init)(void);
extern void DRM(agp_uninit)(void); extern void DRM(agp_uninit)(void);
@ -891,7 +902,6 @@ extern DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type);
extern int DRM(agp_free_memory)(DRM_AGP_MEM *handle); extern int DRM(agp_free_memory)(DRM_AGP_MEM *handle);
extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start); extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start);
extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle); extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle);
#endif
/* Stub support (drm_stub.h) */ /* Stub support (drm_stub.h) */
int DRM(stub_register)(const char *name, int DRM(stub_register)(const char *name,

View File

@ -102,15 +102,14 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int
#ifdef __alpha__ #ifdef __alpha__
map->offset += dev->hose->mem_space->start; map->offset += dev->hose->mem_space->start;
#endif #endif
#if __OS_HAS_MTRR if (drm_core_has_MTRR(dev)) {
if ( drm_core_check_feature(dev, DRIVER_USE_MTRR) ) {
if ( map->type == _DRM_FRAME_BUFFER || if ( map->type == _DRM_FRAME_BUFFER ||
(map->flags & _DRM_WRITE_COMBINING) ) { (map->flags & _DRM_WRITE_COMBINING) ) {
map->mtrr = mtrr_add( map->offset, map->size, map->mtrr = mtrr_add( map->offset, map->size,
MTRR_TYPE_WRCOMB, 1 ); MTRR_TYPE_WRCOMB, 1 );
} }
} }
#endif
if (map->type == _DRM_REGISTERS) if (map->type == _DRM_REGISTERS)
map->handle = DRM(ioremap)( map->offset, map->size, dev ); map->handle = DRM(ioremap)( map->offset, map->size, dev );
@ -200,15 +199,13 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
#ifdef __alpha__ #ifdef __alpha__
map->offset += dev->hose->mem_space->start; map->offset += dev->hose->mem_space->start;
#endif #endif
#if __OS_HAS_MTRR if (drm_core_has_MTRR(dev)) {
if (drm_core_check_feature(dev, DRIVER_USE_MTRR)) {
if ( map->type == _DRM_FRAME_BUFFER || if ( map->type == _DRM_FRAME_BUFFER ||
(map->flags & _DRM_WRITE_COMBINING) ) { (map->flags & _DRM_WRITE_COMBINING) ) {
map->mtrr = mtrr_add( map->offset, map->size, map->mtrr = mtrr_add( map->offset, map->size,
MTRR_TYPE_WRCOMB, 1 ); MTRR_TYPE_WRCOMB, 1 );
} }
} }
#endif
if (map->type == _DRM_REGISTERS) if (map->type == _DRM_REGISTERS)
map->handle = DRM(ioremap)( map->offset, map->size, map->handle = DRM(ioremap)( map->offset, map->size,
dev ); dev );
@ -234,9 +231,8 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
dev->lock.hw_lock = map->handle; /* Pointer to lock */ dev->lock.hw_lock = map->handle; /* Pointer to lock */
} }
break; break;
#if __OS_HAS_AGP
case _DRM_AGP: case _DRM_AGP:
if (drm_core_check_feature(dev, DRIVER_USE_AGP)) { if (drm_core_has_AGP(dev)) {
#ifdef __alpha__ #ifdef __alpha__
map->offset += dev->hose->mem_space->start; map->offset += dev->hose->mem_space->start;
#endif #endif
@ -244,7 +240,6 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
map->mtrr = dev->agp->agp_mtrr; /* for getmap */ map->mtrr = dev->agp->agp_mtrr; /* for getmap */
} }
break; break;
#endif
case _DRM_SCATTER_GATHER: case _DRM_SCATTER_GATHER:
if (!dev->sg) { if (!dev->sg) {
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
@ -1264,8 +1259,8 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
return -EFAULT; return -EFAULT;
if ( request.count >= dma->buf_count ) { if ( request.count >= dma->buf_count ) {
if (( drm_core_check_feature(dev, DRIVER_USE_AGP) && (dma->flags & _DRM_DMA_USE_AGP)) || if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) ||
( drm_core_check_feature(dev, DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG)) ) { (drm_core_check_feature(dev, DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG))) {
drm_map_t *map = dev->agp_buffer_map; drm_map_t *map = dev->agp_buffer_map;
if ( !map ) { if ( !map ) {

View File

@ -347,9 +347,8 @@ static int DRM(takedown)( drm_device_t *dev )
dev->magiclist[i].head = dev->magiclist[i].tail = NULL; dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
} }
#if __OS_HAS_AGP
/* Clear AGP information */ /* Clear AGP information */
if ( drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp ) { if ( drm_core_has_AGP(dev) && dev->agp ) {
drm_agp_mem_t *entry; drm_agp_mem_t *entry;
drm_agp_mem_t *nexte; drm_agp_mem_t *nexte;
@ -368,7 +367,6 @@ static int DRM(takedown)( drm_device_t *dev )
dev->agp->acquired = 0; dev->agp->acquired = 0;
dev->agp->enabled = 0; dev->agp->enabled = 0;
} }
#endif
/* Clear vma list (only built for debugging) */ /* Clear vma list (only built for debugging) */
if ( dev->vmalist ) { if ( dev->vmalist ) {
@ -509,8 +507,7 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if ((retcode = dev->fn_tbl.preinit(dev, ent->driver_data))) if ((retcode = dev->fn_tbl.preinit(dev, ent->driver_data)))
goto error_out_unreg; goto error_out_unreg;
#if __OS_HAS_AGP if (drm_core_has_AGP(dev)) {
if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
dev->agp = DRM(agp_init)(); dev->agp = DRM(agp_init)();
if ( drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && dev->agp == NULL ) { if ( drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && dev->agp == NULL ) {
DRM_ERROR( "Cannot initialize the agpgart module.\n" ); DRM_ERROR( "Cannot initialize the agpgart module.\n" );
@ -518,8 +515,8 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto error_out_unreg; goto error_out_unreg;
} }
#if __OS_HAS_MTRR
if (drm_core_check_feature(dev, DRIVER_USE_MTRR)) { if (drm_core_has_MTRR(dev)) {
if (dev->agp) if (dev->agp)
dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base, dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size*1024*1024, dev->agp->agp_info.aper_size*1024*1024,
@ -527,8 +524,7 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1 ); 1 );
} }
} }
#endif
#endif
retcode = DRM(ctxbitmap_init)( dev ); retcode = DRM(ctxbitmap_init)( dev );
if( retcode ) { if( retcode ) {
DRM_ERROR( "Cannot allocate memory for context bitmap.\n" ); DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
@ -680,8 +676,7 @@ static void __exit drm_cleanup( drm_device_t *dev )
break; break;
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
#if __OS_HAS_MTRR if ( drm_core_has_MTRR(dev)) {
if ( drm_core_check_feature(dev, DRIVER_USE_MTRR)) {
if ( map->mtrr >= 0 ) { if ( map->mtrr >= 0 ) {
int retcode; int retcode;
retcode = mtrr_del( map->mtrr, retcode = mtrr_del( map->mtrr,
@ -690,7 +685,6 @@ static void __exit drm_cleanup( drm_device_t *dev )
DRM_DEBUG( "mtrr_del=%d\n", retcode ); DRM_DEBUG( "mtrr_del=%d\n", retcode );
} }
} }
#endif
break; break;
case _DRM_SHM: case _DRM_SHM:
@ -719,22 +713,19 @@ static void __exit drm_cleanup( drm_device_t *dev )
DRM(ctxbitmap_cleanup)( dev ); DRM(ctxbitmap_cleanup)( dev );
#if __OS_HAS_AGP if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && dev->agp && dev->agp->agp_mtrr >= 0) {
#if __OS_HAS_MTRR
if ( drm_core_check_feature(dev, DRIVER_USE_MTRR) && dev->agp && dev->agp->agp_mtrr >= 0 ) {
int retval; int retval;
retval = mtrr_del( dev->agp->agp_mtrr, retval = mtrr_del( dev->agp->agp_mtrr,
dev->agp->agp_info.aper_base, dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size*1024*1024 ); dev->agp->agp_info.aper_size*1024*1024 );
DRM_DEBUG( "mtrr_del=%d\n", retval ); DRM_DEBUG( "mtrr_del=%d\n", retval );
} }
#endif
if ( drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp ) { if (drm_core_has_AGP(dev) && dev->agp ) {
DRM(agp_uninit)(); DRM(agp_uninit)();
DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS ); DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
dev->agp = NULL; dev->agp = NULL;
} }
#endif
if (dev->fn_tbl.postcleanup) if (dev->fn_tbl.postcleanup)
dev->fn_tbl.postcleanup(dev); dev->fn_tbl.postcleanup(dev);
} }
@ -1129,7 +1120,6 @@ int DRM(lock)( struct inode *inode, struct file *filp,
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue( &dev->lock.lock_queue, &entry ); remove_wait_queue( &dev->lock.lock_queue, &entry );
if ( !ret ) {
sigemptyset( &dev->sigmask ); sigemptyset( &dev->sigmask );
sigaddset( &dev->sigmask, SIGSTOP ); sigaddset( &dev->sigmask, SIGSTOP );
sigaddset( &dev->sigmask, SIGTSTP ); sigaddset( &dev->sigmask, SIGTSTP );
@ -1151,7 +1141,7 @@ int DRM(lock)( struct inode *inode, struct file *filp,
dev->fn_tbl.kernel_context_switch(dev, dev->last_context, dev->fn_tbl.kernel_context_switch(dev, dev->last_context,
lock.context); lock.context);
} }
}
DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" ); DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );

View File

@ -139,12 +139,29 @@ drm_follow_page (void *vaddr)
return pte_pfn(*ptep) << PAGE_SHIFT; return pte_pfn(*ptep) << PAGE_SHIFT;
} }
#endif /* __OS_HAS_AGP && defined(VMAP_4_ARGS) */ #else /* __OS_HAS_AGP */
static inline drm_map_t *drm_lookup_map(unsigned long offset, unsigned long size, drm_device_t *dev)
{
return NULL;
}
static inline void *agp_remap(unsigned long offset, unsigned long size, drm_device_t *dev)
{
return NULL;
}
static inline unsigned long drm_follow_page (void *vaddr)
{
return 0;
}
#endif
static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev) static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev)
{ {
#if __OS_HAS_AGP && defined(VMAP_4_ARGS) #if defined(VMAP_4_ARGS)
if ( drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture) { if ( drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev); drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP) if (map && map->type == _DRM_AGP)
@ -158,8 +175,8 @@ static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_de
static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size, static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size,
drm_device_t *dev) drm_device_t *dev)
{ {
#if __OS_HAS_AGP&& defined(VMAP_4_ARGS) #if defined(VMAP_4_ARGS)
if ( drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture) { if ( drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev); drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP) if (map && map->type == _DRM_AGP)
@ -172,13 +189,13 @@ static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size
static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev) static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev)
{ {
#if __OS_HAS_AGP && defined(VMAP_4_ARGS) #if defined(VMAP_4_ARGS)
/* /*
* This is a bit ugly. It would be much cleaner if the DRM API would use separate * This is a bit ugly. It would be much cleaner if the DRM API would use separate
* routines for handling mappings in the AGP space. Hopefully this can be done in * routines for handling mappings in the AGP space. Hopefully this can be done in
* a future revision of the interface... * a future revision of the interface...
*/ */
if (drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture
&& ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END)) && ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END))
{ {
unsigned long offset; unsigned long offset;

View File

@ -47,6 +47,7 @@ typedef void irqreturn_t;
#endif #endif
/** AGP types */ /** AGP types */
#if __OS_HAS_AGP
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,70) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,70)
#define DRM_AGP_MEM agp_memory #define DRM_AGP_MEM agp_memory
#define DRM_AGP_KERN agp_kern_info #define DRM_AGP_KERN agp_kern_info
@ -54,6 +55,30 @@ typedef void irqreturn_t;
#define DRM_AGP_MEM struct agp_memory #define DRM_AGP_MEM struct agp_memory
#define DRM_AGP_KERN struct agp_kern_info #define DRM_AGP_KERN struct agp_kern_info
#endif #endif
#else
/* define some dummy types for non AGP supporting kernels */
struct no_agp_kern {
unsigned long aper_base;
unsigned long aper_size;
};
#define DRM_AGP_MEM int
#define DRM_AGP_KERN struct no_agp_kern
#endif
#if !(__OS_HAS_MTRR)
static __inline__ int mtrr_add (unsigned long base, unsigned long size,
unsigned int type, char increment)
{
return -ENODEV;
}
static __inline__ int mtrr_del (int reg, unsigned long base,
unsigned long size)
{
return -ENODEV;
}
#define MTRR_TYPE_WRCOMB 1
#endif
/** Task queue handler arguments */ /** Task queue handler arguments */
#define DRM_TASKQUEUE_ARGS void *arg #define DRM_TASKQUEUE_ARGS void *arg

View File

@ -46,10 +46,10 @@
* Find the right map and if it's AGP memory find the real physical page to * Find the right map and if it's AGP memory find the real physical page to
* map, get the page, increment the use count and return it. * map, get the page, increment the use count and return it.
*/ */
#if __OS_HAS_AGP
static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma, static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
unsigned long address) unsigned long address)
{ {
#if __OS_HAS_AGP
drm_file_t *priv = vma->vm_file->private_data; drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_map_t *map = NULL; drm_map_t *map = NULL;
@ -59,7 +59,7 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
/* /*
* Find the right map * Find the right map
*/ */
if (!drm_core_check_feature(dev, DRIVER_USE_AGP)) if (!drm_core_has_AGP(dev))
goto vm_nopage_error; goto vm_nopage_error;
if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error; if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error;
@ -112,10 +112,15 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
return page; return page;
} }
vm_nopage_error: vm_nopage_error:
#endif /* __OS_HAS_AGP */
return NOPAGE_SIGBUS; /* Disallow mremap */ return NOPAGE_SIGBUS; /* Disallow mremap */
} }
#else /* __OS_HAS_AGP */
static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
unsigned long address)
{
return NOPAGE_SIGBUS;
}
#endif /* __OS_HAS_AGP */
/** /**
* \c nopage method for shared virtual memory. * \c nopage method for shared virtual memory.
@ -206,15 +211,13 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
switch (map->type) { switch (map->type) {
case _DRM_REGISTERS: case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
#if __OS_HAS_MTRR if (drm_core_has_MTRR(dev) && map->mtrr >= 0) {
if (drm_core_check_feature(dev, DRIVER_USE_MTRR) && map->mtrr >= 0) {
int retcode; int retcode;
retcode = mtrr_del(map->mtrr, retcode = mtrr_del(map->mtrr,
map->offset, map->offset,
map->size); map->size);
DRM_DEBUG("mtrr_del = %d\n", retcode); DRM_DEBUG("mtrr_del = %d\n", retcode);
} }
#endif
DRM(ioremapfree)(map->handle, map->size, dev); DRM(ioremapfree)(map->handle, map->size, dev);
break; break;
case _DRM_SHM: case _DRM_SHM:
@ -583,8 +586,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
switch (map->type) { switch (map->type) {
case _DRM_AGP: case _DRM_AGP:
#if __OS_HAS_AGP if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
if (drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp->cant_use_aperture) {
/* /*
* On some platforms we can't talk to bus dma address from the CPU, so for * On some platforms we can't talk to bus dma address from the CPU, so for
* memory of type DRM_AGP, we'll deal with sorting out the real physical * memory of type DRM_AGP, we'll deal with sorting out the real physical
@ -596,7 +598,6 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
vma->vm_ops = &DRM(vm_ops); vma->vm_ops = &DRM(vm_ops);
break; break;
} }
#endif
/* fall through to _DRM_FRAME_BUFFER... */ /* fall through to _DRM_FRAME_BUFFER... */
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
case _DRM_REGISTERS: case _DRM_REGISTERS:

View File

@ -83,6 +83,9 @@
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
#include "drm.h" #include "drm.h"
#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
#include "drm_os_linux.h" #include "drm_os_linux.h"
/* If you want the memory alloc debug functionality, change define below */ /* If you want the memory alloc debug functionality, change define below */
@ -104,11 +107,8 @@
#define DRIVER_IRQ_VBL 0x200 #define DRIVER_IRQ_VBL 0x200
#define DRIVER_DMA_QUEUE 0x800 #define DRIVER_DMA_QUEUE 0x800
#define __OS_HAS_AGP (defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE))
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
/*@}*/ /*@}*/
/***********************************************************************/ /***********************************************************************/
/** \name Begin the DRM... */ /** \name Begin the DRM... */
/*@{*/ /*@{*/
@ -431,7 +431,6 @@ typedef struct drm_device_dma {
/*@}*/ /*@}*/
} drm_device_dma_t; } drm_device_dma_t;
#if __OS_HAS_AGP
/** /**
* AGP memory entry. Stored as a doubly linked list. * AGP memory entry. Stored as a doubly linked list.
*/ */
@ -460,7 +459,6 @@ typedef struct drm_agp_head {
int cant_use_aperture; int cant_use_aperture;
unsigned long page_mask; unsigned long page_mask;
} drm_agp_head_t; } drm_agp_head_t;
#endif
/** /**
* Scatter-gather memory. * Scatter-gather memory.
@ -654,9 +652,7 @@ typedef struct drm_device {
wait_queue_head_t buf_readers; /**< Processes waiting to read */ wait_queue_head_t buf_readers; /**< Processes waiting to read */
wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */ wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
#if __OS_HAS_AGP
drm_agp_head_t *agp; /**< AGP data */ drm_agp_head_t *agp; /**< AGP data */
#endif
struct pci_dev *pdev; /**< PCI device structure */ struct pci_dev *pdev; /**< PCI device structure */
int pci_domain; /**< PCI bus domain number */ int pci_domain; /**< PCI bus domain number */
@ -688,6 +684,24 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature
return ((dev->driver_features & feature) ? 1 : 0); return ((dev->driver_features & feature) ? 1 : 0);
} }
#if __OS_HAS_AGP
static inline int drm_core_has_AGP(struct drm_device *dev)
{
return drm_core_check_feature(dev, DRIVER_USE_AGP);
}
#else
#define drm_core_has_AGP(dev) (0)
#endif
#if __OS_HAS_MTRR
static inline int drm_core_has_MTRR(struct drm_device *dev)
{
return drm_core_check_feature(dev, DRIVER_USE_MTRR);
}
#else
#define drm_core_has_MTRR(dev) (0)
#endif
extern void DRM(driver_register_fns)(struct drm_device *dev); extern void DRM(driver_register_fns)(struct drm_device *dev);
/******************************************************************/ /******************************************************************/
@ -744,12 +758,10 @@ extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size,
drm_device_t *dev); drm_device_t *dev);
extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev); extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev);
#if __OS_HAS_AGP
extern DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type); extern DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type);
extern int DRM(free_agp)(DRM_AGP_MEM *handle, int pages); extern int DRM(free_agp)(DRM_AGP_MEM *handle, int pages);
extern int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start); extern int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start);
extern int DRM(unbind_agp)(DRM_AGP_MEM *handle); extern int DRM(unbind_agp)(DRM_AGP_MEM *handle);
#endif
/* Misc. IOCTL support (drm_ioctl.h) */ /* Misc. IOCTL support (drm_ioctl.h) */
extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp, extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
@ -866,7 +878,6 @@ extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
extern void DRM(vbl_send_signals)( drm_device_t *dev ); extern void DRM(vbl_send_signals)( drm_device_t *dev );
#if __OS_HAS_AGP
/* AGP/GART support (drm_agpsupport.h) */ /* AGP/GART support (drm_agpsupport.h) */
extern drm_agp_head_t *DRM(agp_init)(void); extern drm_agp_head_t *DRM(agp_init)(void);
extern void DRM(agp_uninit)(void); extern void DRM(agp_uninit)(void);
@ -891,7 +902,6 @@ extern DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type);
extern int DRM(agp_free_memory)(DRM_AGP_MEM *handle); extern int DRM(agp_free_memory)(DRM_AGP_MEM *handle);
extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start); extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start);
extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle); extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle);
#endif
/* Stub support (drm_stub.h) */ /* Stub support (drm_stub.h) */
int DRM(stub_register)(const char *name, int DRM(stub_register)(const char *name,

View File

@ -102,15 +102,14 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int
#ifdef __alpha__ #ifdef __alpha__
map->offset += dev->hose->mem_space->start; map->offset += dev->hose->mem_space->start;
#endif #endif
#if __OS_HAS_MTRR if (drm_core_has_MTRR(dev)) {
if ( drm_core_check_feature(dev, DRIVER_USE_MTRR) ) {
if ( map->type == _DRM_FRAME_BUFFER || if ( map->type == _DRM_FRAME_BUFFER ||
(map->flags & _DRM_WRITE_COMBINING) ) { (map->flags & _DRM_WRITE_COMBINING) ) {
map->mtrr = mtrr_add( map->offset, map->size, map->mtrr = mtrr_add( map->offset, map->size,
MTRR_TYPE_WRCOMB, 1 ); MTRR_TYPE_WRCOMB, 1 );
} }
} }
#endif
if (map->type == _DRM_REGISTERS) if (map->type == _DRM_REGISTERS)
map->handle = DRM(ioremap)( map->offset, map->size, dev ); map->handle = DRM(ioremap)( map->offset, map->size, dev );
@ -200,15 +199,13 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
#ifdef __alpha__ #ifdef __alpha__
map->offset += dev->hose->mem_space->start; map->offset += dev->hose->mem_space->start;
#endif #endif
#if __OS_HAS_MTRR if (drm_core_has_MTRR(dev)) {
if (drm_core_check_feature(dev, DRIVER_USE_MTRR)) {
if ( map->type == _DRM_FRAME_BUFFER || if ( map->type == _DRM_FRAME_BUFFER ||
(map->flags & _DRM_WRITE_COMBINING) ) { (map->flags & _DRM_WRITE_COMBINING) ) {
map->mtrr = mtrr_add( map->offset, map->size, map->mtrr = mtrr_add( map->offset, map->size,
MTRR_TYPE_WRCOMB, 1 ); MTRR_TYPE_WRCOMB, 1 );
} }
} }
#endif
if (map->type == _DRM_REGISTERS) if (map->type == _DRM_REGISTERS)
map->handle = DRM(ioremap)( map->offset, map->size, map->handle = DRM(ioremap)( map->offset, map->size,
dev ); dev );
@ -234,9 +231,8 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
dev->lock.hw_lock = map->handle; /* Pointer to lock */ dev->lock.hw_lock = map->handle; /* Pointer to lock */
} }
break; break;
#if __OS_HAS_AGP
case _DRM_AGP: case _DRM_AGP:
if (drm_core_check_feature(dev, DRIVER_USE_AGP)) { if (drm_core_has_AGP(dev)) {
#ifdef __alpha__ #ifdef __alpha__
map->offset += dev->hose->mem_space->start; map->offset += dev->hose->mem_space->start;
#endif #endif
@ -244,7 +240,6 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
map->mtrr = dev->agp->agp_mtrr; /* for getmap */ map->mtrr = dev->agp->agp_mtrr; /* for getmap */
} }
break; break;
#endif
case _DRM_SCATTER_GATHER: case _DRM_SCATTER_GATHER:
if (!dev->sg) { if (!dev->sg) {
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
@ -1264,8 +1259,8 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
return -EFAULT; return -EFAULT;
if ( request.count >= dma->buf_count ) { if ( request.count >= dma->buf_count ) {
if (( drm_core_check_feature(dev, DRIVER_USE_AGP) && (dma->flags & _DRM_DMA_USE_AGP)) || if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) ||
( drm_core_check_feature(dev, DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG)) ) { (drm_core_check_feature(dev, DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG))) {
drm_map_t *map = dev->agp_buffer_map; drm_map_t *map = dev->agp_buffer_map;
if ( !map ) { if ( !map ) {

View File

@ -347,9 +347,8 @@ static int DRM(takedown)( drm_device_t *dev )
dev->magiclist[i].head = dev->magiclist[i].tail = NULL; dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
} }
#if __OS_HAS_AGP
/* Clear AGP information */ /* Clear AGP information */
if ( drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp ) { if ( drm_core_has_AGP(dev) && dev->agp ) {
drm_agp_mem_t *entry; drm_agp_mem_t *entry;
drm_agp_mem_t *nexte; drm_agp_mem_t *nexte;
@ -368,7 +367,6 @@ static int DRM(takedown)( drm_device_t *dev )
dev->agp->acquired = 0; dev->agp->acquired = 0;
dev->agp->enabled = 0; dev->agp->enabled = 0;
} }
#endif
/* Clear vma list (only built for debugging) */ /* Clear vma list (only built for debugging) */
if ( dev->vmalist ) { if ( dev->vmalist ) {
@ -509,8 +507,7 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if ((retcode = dev->fn_tbl.preinit(dev, ent->driver_data))) if ((retcode = dev->fn_tbl.preinit(dev, ent->driver_data)))
goto error_out_unreg; goto error_out_unreg;
#if __OS_HAS_AGP if (drm_core_has_AGP(dev)) {
if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
dev->agp = DRM(agp_init)(); dev->agp = DRM(agp_init)();
if ( drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && dev->agp == NULL ) { if ( drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && dev->agp == NULL ) {
DRM_ERROR( "Cannot initialize the agpgart module.\n" ); DRM_ERROR( "Cannot initialize the agpgart module.\n" );
@ -518,8 +515,8 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto error_out_unreg; goto error_out_unreg;
} }
#if __OS_HAS_MTRR
if (drm_core_check_feature(dev, DRIVER_USE_MTRR)) { if (drm_core_has_MTRR(dev)) {
if (dev->agp) if (dev->agp)
dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base, dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size*1024*1024, dev->agp->agp_info.aper_size*1024*1024,
@ -527,8 +524,7 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1 ); 1 );
} }
} }
#endif
#endif
retcode = DRM(ctxbitmap_init)( dev ); retcode = DRM(ctxbitmap_init)( dev );
if( retcode ) { if( retcode ) {
DRM_ERROR( "Cannot allocate memory for context bitmap.\n" ); DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
@ -680,8 +676,7 @@ static void __exit drm_cleanup( drm_device_t *dev )
break; break;
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
#if __OS_HAS_MTRR if ( drm_core_has_MTRR(dev)) {
if ( drm_core_check_feature(dev, DRIVER_USE_MTRR)) {
if ( map->mtrr >= 0 ) { if ( map->mtrr >= 0 ) {
int retcode; int retcode;
retcode = mtrr_del( map->mtrr, retcode = mtrr_del( map->mtrr,
@ -690,7 +685,6 @@ static void __exit drm_cleanup( drm_device_t *dev )
DRM_DEBUG( "mtrr_del=%d\n", retcode ); DRM_DEBUG( "mtrr_del=%d\n", retcode );
} }
} }
#endif
break; break;
case _DRM_SHM: case _DRM_SHM:
@ -719,22 +713,19 @@ static void __exit drm_cleanup( drm_device_t *dev )
DRM(ctxbitmap_cleanup)( dev ); DRM(ctxbitmap_cleanup)( dev );
#if __OS_HAS_AGP if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && dev->agp && dev->agp->agp_mtrr >= 0) {
#if __OS_HAS_MTRR
if ( drm_core_check_feature(dev, DRIVER_USE_MTRR) && dev->agp && dev->agp->agp_mtrr >= 0 ) {
int retval; int retval;
retval = mtrr_del( dev->agp->agp_mtrr, retval = mtrr_del( dev->agp->agp_mtrr,
dev->agp->agp_info.aper_base, dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size*1024*1024 ); dev->agp->agp_info.aper_size*1024*1024 );
DRM_DEBUG( "mtrr_del=%d\n", retval ); DRM_DEBUG( "mtrr_del=%d\n", retval );
} }
#endif
if ( drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp ) { if (drm_core_has_AGP(dev) && dev->agp ) {
DRM(agp_uninit)(); DRM(agp_uninit)();
DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS ); DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
dev->agp = NULL; dev->agp = NULL;
} }
#endif
if (dev->fn_tbl.postcleanup) if (dev->fn_tbl.postcleanup)
dev->fn_tbl.postcleanup(dev); dev->fn_tbl.postcleanup(dev);
} }
@ -1129,7 +1120,6 @@ int DRM(lock)( struct inode *inode, struct file *filp,
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue( &dev->lock.lock_queue, &entry ); remove_wait_queue( &dev->lock.lock_queue, &entry );
if ( !ret ) {
sigemptyset( &dev->sigmask ); sigemptyset( &dev->sigmask );
sigaddset( &dev->sigmask, SIGSTOP ); sigaddset( &dev->sigmask, SIGSTOP );
sigaddset( &dev->sigmask, SIGTSTP ); sigaddset( &dev->sigmask, SIGTSTP );
@ -1151,7 +1141,7 @@ int DRM(lock)( struct inode *inode, struct file *filp,
dev->fn_tbl.kernel_context_switch(dev, dev->last_context, dev->fn_tbl.kernel_context_switch(dev, dev->last_context,
lock.context); lock.context);
} }
}
DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" ); DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );

View File

@ -139,12 +139,29 @@ drm_follow_page (void *vaddr)
return pte_pfn(*ptep) << PAGE_SHIFT; return pte_pfn(*ptep) << PAGE_SHIFT;
} }
#endif /* __OS_HAS_AGP && defined(VMAP_4_ARGS) */ #else /* __OS_HAS_AGP */
static inline drm_map_t *drm_lookup_map(unsigned long offset, unsigned long size, drm_device_t *dev)
{
return NULL;
}
static inline void *agp_remap(unsigned long offset, unsigned long size, drm_device_t *dev)
{
return NULL;
}
static inline unsigned long drm_follow_page (void *vaddr)
{
return 0;
}
#endif
static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev) static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev)
{ {
#if __OS_HAS_AGP && defined(VMAP_4_ARGS) #if defined(VMAP_4_ARGS)
if ( drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture) { if ( drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev); drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP) if (map && map->type == _DRM_AGP)
@ -158,8 +175,8 @@ static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_de
static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size, static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size,
drm_device_t *dev) drm_device_t *dev)
{ {
#if __OS_HAS_AGP&& defined(VMAP_4_ARGS) #if defined(VMAP_4_ARGS)
if ( drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture) { if ( drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev); drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP) if (map && map->type == _DRM_AGP)
@ -172,13 +189,13 @@ static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size
static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev) static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev)
{ {
#if __OS_HAS_AGP && defined(VMAP_4_ARGS) #if defined(VMAP_4_ARGS)
/* /*
* This is a bit ugly. It would be much cleaner if the DRM API would use separate * This is a bit ugly. It would be much cleaner if the DRM API would use separate
* routines for handling mappings in the AGP space. Hopefully this can be done in * routines for handling mappings in the AGP space. Hopefully this can be done in
* a future revision of the interface... * a future revision of the interface...
*/ */
if (drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture
&& ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END)) && ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END))
{ {
unsigned long offset; unsigned long offset;

View File

@ -47,6 +47,7 @@ typedef void irqreturn_t;
#endif #endif
/** AGP types */ /** AGP types */
#if __OS_HAS_AGP
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,70) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,70)
#define DRM_AGP_MEM agp_memory #define DRM_AGP_MEM agp_memory
#define DRM_AGP_KERN agp_kern_info #define DRM_AGP_KERN agp_kern_info
@ -54,6 +55,30 @@ typedef void irqreturn_t;
#define DRM_AGP_MEM struct agp_memory #define DRM_AGP_MEM struct agp_memory
#define DRM_AGP_KERN struct agp_kern_info #define DRM_AGP_KERN struct agp_kern_info
#endif #endif
#else
/* define some dummy types for non AGP supporting kernels */
struct no_agp_kern {
unsigned long aper_base;
unsigned long aper_size;
};
#define DRM_AGP_MEM int
#define DRM_AGP_KERN struct no_agp_kern
#endif
#if !(__OS_HAS_MTRR)
static __inline__ int mtrr_add (unsigned long base, unsigned long size,
unsigned int type, char increment)
{
return -ENODEV;
}
static __inline__ int mtrr_del (int reg, unsigned long base,
unsigned long size)
{
return -ENODEV;
}
#define MTRR_TYPE_WRCOMB 1
#endif
/** Task queue handler arguments */ /** Task queue handler arguments */
#define DRM_TASKQUEUE_ARGS void *arg #define DRM_TASKQUEUE_ARGS void *arg

View File

@ -46,10 +46,10 @@
* Find the right map and if it's AGP memory find the real physical page to * Find the right map and if it's AGP memory find the real physical page to
* map, get the page, increment the use count and return it. * map, get the page, increment the use count and return it.
*/ */
#if __OS_HAS_AGP
static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma, static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
unsigned long address) unsigned long address)
{ {
#if __OS_HAS_AGP
drm_file_t *priv = vma->vm_file->private_data; drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_map_t *map = NULL; drm_map_t *map = NULL;
@ -59,7 +59,7 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
/* /*
* Find the right map * Find the right map
*/ */
if (!drm_core_check_feature(dev, DRIVER_USE_AGP)) if (!drm_core_has_AGP(dev))
goto vm_nopage_error; goto vm_nopage_error;
if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error; if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error;
@ -112,10 +112,15 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
return page; return page;
} }
vm_nopage_error: vm_nopage_error:
#endif /* __OS_HAS_AGP */
return NOPAGE_SIGBUS; /* Disallow mremap */ return NOPAGE_SIGBUS; /* Disallow mremap */
} }
#else /* __OS_HAS_AGP */
static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
unsigned long address)
{
return NOPAGE_SIGBUS;
}
#endif /* __OS_HAS_AGP */
/** /**
* \c nopage method for shared virtual memory. * \c nopage method for shared virtual memory.
@ -206,15 +211,13 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
switch (map->type) { switch (map->type) {
case _DRM_REGISTERS: case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
#if __OS_HAS_MTRR if (drm_core_has_MTRR(dev) && map->mtrr >= 0) {
if (drm_core_check_feature(dev, DRIVER_USE_MTRR) && map->mtrr >= 0) {
int retcode; int retcode;
retcode = mtrr_del(map->mtrr, retcode = mtrr_del(map->mtrr,
map->offset, map->offset,
map->size); map->size);
DRM_DEBUG("mtrr_del = %d\n", retcode); DRM_DEBUG("mtrr_del = %d\n", retcode);
} }
#endif
DRM(ioremapfree)(map->handle, map->size, dev); DRM(ioremapfree)(map->handle, map->size, dev);
break; break;
case _DRM_SHM: case _DRM_SHM:
@ -583,8 +586,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
switch (map->type) { switch (map->type) {
case _DRM_AGP: case _DRM_AGP:
#if __OS_HAS_AGP if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
if (drm_core_check_feature(dev, DRIVER_USE_AGP) && dev->agp->cant_use_aperture) {
/* /*
* On some platforms we can't talk to bus dma address from the CPU, so for * On some platforms we can't talk to bus dma address from the CPU, so for
* memory of type DRM_AGP, we'll deal with sorting out the real physical * memory of type DRM_AGP, we'll deal with sorting out the real physical
@ -596,7 +598,6 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
vma->vm_ops = &DRM(vm_ops); vma->vm_ops = &DRM(vm_ops);
break; break;
} }
#endif
/* fall through to _DRM_FRAME_BUFFER... */ /* fall through to _DRM_FRAME_BUFFER... */
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
case _DRM_REGISTERS: case _DRM_REGISTERS: