summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@fairlite.demon.co.uk>2001-08-19 12:29:57 +0000
committerAlan Hourihane <alanh@fairlite.demon.co.uk>2001-08-19 12:29:57 +0000
commited1730707d7530600870c94af2d5010f26ec154f (patch)
tree051c74e01771e320624c8d68d59354efdd4193d7
parent002b0ae22e789a1ce7f6c7320c8dd74bfc80b309 (diff)
merge kernel modules from trunk (again).
-rw-r--r--linux-core/ati_pcigart.c8
-rw-r--r--linux-core/drm_context.c41
-rw-r--r--linux-core/drm_drv.c4
-rw-r--r--linux-core/drm_ioctl.c2
-rw-r--r--linux-core/drm_os_linux.h6
-rw-r--r--linux-core/drm_scatter.c4
-rw-r--r--linux-core/drm_vm.c110
-rw-r--r--linux-core/i810_dma.c1
-rw-r--r--linux/ati_pcigart.h8
-rw-r--r--linux/drm_context.h41
-rw-r--r--linux/drm_drv.h4
-rw-r--r--linux/drm_ioctl.h2
-rw-r--r--linux/drm_os_linux.h6
-rw-r--r--linux/drm_scatter.h4
-rw-r--r--linux/drm_vm.h110
-rw-r--r--linux/i810_dma.c1
-rw-r--r--linux/mga_dma.c1
-rw-r--r--linux/r128_cce.c6
-rw-r--r--linux/radeon_cp.c6
19 files changed, 200 insertions, 165 deletions
diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c
index 99d17ee7..a794b3e0 100644
--- a/linux-core/ati_pcigart.c
+++ b/linux-core/ati_pcigart.c
@@ -133,9 +133,9 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
#if defined(__alpha__) && (LINUX_VERSION_CODE >= 0x020400)
/* we need to support large memory configurations */
entry->busaddr[i] = pci_map_single(dev->pdev,
- entry->pagelist[i]->virtual,
- PAGE_SIZE,
- PCI_DMA_TODEVICE);
+ page_address( entry->pagelist[i] ),
+ PAGE_SIZE,
+ PCI_DMA_TODEVICE);
if (entry->busaddr[i] == 0) {
DRM_ERROR( "unable to map PCIGART pages!\n" );
DRM(ati_pcigart_cleanup)( dev, address, bus_address );
@@ -145,7 +145,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
}
page_base = (u32) entry->busaddr[i];
#else
- page_base = virt_to_bus( entry->pagelist[i]->virtual );
+ page_base = page_to_bus( entry->pagelist[i] );
#endif
for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
*pci_gart++ = cpu_to_le32( page_base );
diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c
index 0ab0c256..3a75afd0 100644
--- a/linux-core/drm_context.c
+++ b/linux-core/drm_context.c
@@ -93,7 +93,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
DRM_MEM_MAPS);
if(!dev->context_sareas) {
clear_bit(bit, dev->ctx_bitmap);
- DRM_OS_UNLOCK;
+ up(&dev->struct_sem);
return -1;
}
dev->context_sareas[bit] = NULL;
@@ -156,7 +156,7 @@ int DRM(getsareactx)( DRM_OS_IOCTL )
sizeof(request) );
DRM_OS_LOCK;
- if ((int)request.ctx_id >= dev->max_context) {
+ if (dev->max_context < 0 || request.ctx_id >= (unsigned) dev->max_context) {
DRM_OS_UNLOCK;
DRM_OS_RETURN(EINVAL);
}
@@ -192,33 +192,34 @@ int DRM(setsareactx)( DRM_OS_IOCTL )
list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *)list;
if(r_list->map &&
- r_list->map->handle == request.handle) break;
+ r_list->map->handle == request.handle)
+ goto found;
}
- if (list == &(dev->maplist->head)) {
- DRM_OS_UNLOCK;
- DRM_OS_RETURN(EINVAL);
- }
- map = r_list->map;
#endif
#ifdef __FreeBSD__
TAILQ_FOREACH(list, dev->maplist, link) {
map=list->map;
- if(map->handle == request.handle) break;
- }
- if (!list) {
- lockmgr( &dev->dev_lock, LK_RELEASE, 0, curproc );
- return EINVAL;
+ if(map->handle == request.handle)
+ goto found;
}
#endif
- DRM_OS_UNLOCK;
- if (!map) DRM_OS_RETURN(EINVAL);
+bad:
+ DRM_OS_UNLOCK;
+ return -EINVAL;
- DRM_OS_LOCK;
- if ((int)request.ctx_id >= dev->max_context) {
- DRM_OS_UNLOCK;
- DRM_OS_RETURN(EINVAL);
- }
+found:
+#ifdef __linux__
+ map = r_list->map;
+#endif
+#ifdef __FreeBSD__
+ map = list->map;
+#endif
+ if (!map) goto bad;
+ if (dev->max_context < 0)
+ goto bad;
+ if (request.ctx_id >= (unsigned) dev->max_context)
+ goto bad;
dev->context_sareas[request.ctx_id] = map;
DRM_OS_UNLOCK;
return 0;
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 20bd6682..66aa05a2 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -155,6 +155,7 @@ static struct file_operations DRM(fops) = { \
#endif /* __FreeBSD__ */
#endif
+
/*
* The default number of instances (minor numbers) to initialize.
*/
@@ -723,6 +724,7 @@ static int __init drm_init( void )
static int DRM(init)( device_t nbdev )
#endif
{
+
drm_device_t *dev;
int i;
#if __HAVE_CTX_BITMAP
@@ -854,6 +856,8 @@ static void DRM(cleanup)(device_t nbdev)
drm_device_t *dev;
int i;
+ DRM_DEBUG( "\n" );
+
for (i = DRM(numdevs) - 1; i >= 0; i--) {
#ifdef __linux__
dev = &(DRM(device)[i]);
diff --git a/linux-core/drm_ioctl.c b/linux-core/drm_ioctl.c
index adcd36d6..97f3b33a 100644
--- a/linux-core/drm_ioctl.c
+++ b/linux-core/drm_ioctl.c
@@ -158,7 +158,7 @@ int DRM(setunique)( DRM_OS_IOCTL )
pci_dev = pci_find_slot(b, PCI_DEVFN(d,f));
if (pci_dev) {
dev->pdev = pci_dev;
- dev->hose = pci_dev->sysdata;
+ dev->hose = pci_dev->sysdata;
}
} while(0);
#endif
diff --git a/linux-core/drm_os_linux.h b/linux-core/drm_os_linux.h
index fee24cc1..55a7a3cd 100644
--- a/linux-core/drm_os_linux.h
+++ b/linux-core/drm_os_linux.h
@@ -39,6 +39,12 @@
#include "compat-pre24.h"
#endif
#include <asm/pgalloc.h>
+#include "drm.h"
+
+/* page_to_bus for earlier kernels, not optimal in all cases */
+#ifndef page_to_bus
+#define page_to_bus(page) ((unsigned int)(virt_to_bus(page_address(page))))
+#endif
#define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
diff --git a/linux-core/drm_scatter.c b/linux-core/drm_scatter.c
index 5654c8cb..66d34968 100644
--- a/linux-core/drm_scatter.c
+++ b/linux-core/drm_scatter.c
@@ -179,7 +179,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
for ( i = 0 ; i < pages ; i++ ) {
unsigned long *tmp;
- tmp = (unsigned long *)entry->pagelist[i]->virtual;
+ tmp = page_address( entry->pagelist[i] );
for ( j = 0 ;
j < PAGE_SIZE / sizeof(unsigned long) ;
j++, tmp++ ) {
@@ -197,7 +197,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
"virtual mapping\n" );
}
}
- tmp = (unsigned long *)entry->pagelist[i]->virtual;
+ tmp = page_address( entry->pagelist[i] );
for(j = 0 ;
j < PAGE_SIZE / sizeof(unsigned long) ;
j++, tmp++) {
diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c
index 40f6c7f7..b5a5deb6 100644
--- a/linux-core/drm_vm.c
+++ b/linux-core/drm_vm.c
@@ -68,61 +68,65 @@ struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
#endif
{
#if defined(__alpha__) && __REALLY_HAVE_AGP
- drm_file_t *priv = vma->vm_file->private_data;
- drm_device_t *dev = priv->dev;
- drm_map_t *map = NULL;
- drm_map_list_t *r_list;
- struct list_head *list;
+ drm_file_t *priv = vma->vm_file->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_map_t *map = NULL;
+ drm_map_list_t *r_list;
+ struct list_head *list;
- /*
+ /*
* Find the right map
*/
- list_for_each(list, &dev->maplist->head) {
- r_list = (drm_map_list_t *)list;
- map = r_list->map;
- if (!map) continue;
- if (map->offset == VM_OFFSET(vma)) break;
- }
+ list_for_each(list, &dev->maplist->head) {
+ r_list = (drm_map_list_t *)list;
+ map = r_list->map;
+ if (!map) continue;
+ if (map->offset == VM_OFFSET(vma)) break;
+ }
- if (map && map->type == _DRM_AGP) {
- unsigned long offset = address - vma->vm_start;
- unsigned long baddr = VM_OFFSET(vma) + offset;
- struct drm_agp_mem *agpmem;
- struct page *page;
+ if (map && map->type == _DRM_AGP) {
+ unsigned long offset = address - vma->vm_start;
+ unsigned long baddr = VM_OFFSET(vma) + offset;
+ struct drm_agp_mem *agpmem;
+ struct page *page;
- /*
+ /*
* Make it a bus-relative address
*/
- baddr -= dev->hose->mem_space->start;
+ baddr -= dev->hose->mem_space->start;
- /*
+ /*
* It's AGP memory - find the real physical page to map
*/
- for(agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) {
- if (agpmem->bound <= baddr &&
- agpmem->bound + agpmem->pages * PAGE_SIZE > baddr)
- break;
- }
+ for(agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) {
+ if (agpmem->bound <= baddr &&
+ agpmem->bound + agpmem->pages * PAGE_SIZE > baddr)
+ break;
+ }
- if (!agpmem) {
- /*
+ if (!agpmem) {
+ /*
* Oops - no memory found
*/
- return NOPAGE_SIGBUS; /* couldn't find it */
+ return NOPAGE_SIGBUS; /* couldn't find it */
}
- /*
+ /*
* Get the page, inc the use count, and return it
*/
- offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
+ offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
agpmem->memory->memory[offset] &= ~1UL; /* HACK */
- page = virt_to_page(__va(agpmem->memory->memory[offset]));
+ page = virt_to_page(__va(agpmem->memory->memory[offset]));
#if 0
-DRM_ERROR("baddr = 0x%lx page = 0x%lx, offset = 0x%lx\n",
- baddr, __va(agpmem->memory->memory[offset]), offset);
+ DRM_ERROR("baddr = 0x%lx page = 0x%lx, offset = 0x%lx\n",
+ baddr, __va(agpmem->memory->memory[offset]), offset);
+#endif
+ get_page(page);
+#if LINUX_VERSION_CODE < 0x020317
+ return page_address(page);
+#else
+ return page;
#endif
- get_page(page);
- return page;
}
#endif
return NOPAGE_SIGBUS; /* Disallow mremap */
@@ -144,12 +148,12 @@ struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
#else
drm_map_t *map = (drm_map_t *)vma->vm_pte;
#endif
- unsigned long physical;
unsigned long offset;
unsigned long i;
pgd_t *pgd;
pmd_t *pmd;
pte_t *pte;
+ struct page *page;
if (address > vma->vm_end) return NOPAGE_SIGBUS; /* Disallow mremap */
if (!map) return NOPAGE_OOM; /* Nothing allocated */
@@ -165,14 +169,15 @@ struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
if( !pmd_present( *pmd ) ) return NOPAGE_OOM;
pte = pte_offset( pmd, i );
if( !pte_present( *pte ) ) return NOPAGE_OOM;
- physical = (unsigned long)pte_page( *pte )->virtual;
- atomic_inc(&virt_to_page(physical)->count); /* Dec. by kernel */
- DRM_DEBUG("0x%08lx => 0x%08lx\n", address, physical);
+ page = pte_page(*pte);
+ get_page(page);
+
+ DRM_DEBUG("0x%08lx => 0x%08x\n", address, page_to_bus(page));
#if LINUX_VERSION_CODE < 0x020317
- return physical;
+ return page_address(page);
#else
- return virt_to_page(physical);
+ return page;
#endif
}
@@ -277,24 +282,27 @@ struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev;
drm_device_dma_t *dma = dev->dma;
- unsigned long physical;
unsigned long offset;
- unsigned long page;
+ unsigned long page_nr;
+ struct page *page;
if (!dma) return NOPAGE_SIGBUS; /* Error */
if (address > vma->vm_end) return NOPAGE_SIGBUS; /* Disallow mremap */
if (!dma->pagelist) return NOPAGE_OOM ; /* Nothing allocated */
offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
- page = offset >> PAGE_SHIFT;
- physical = dma->pagelist[page] + (offset & (~PAGE_MASK));
- atomic_inc(&virt_to_page(physical)->count); /* Dec. by kernel */
+ page_nr = offset >> PAGE_SHIFT;
+ page = virt_to_page((dma->pagelist[page_nr] +
+ (offset & (~PAGE_MASK))));
- DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\n", address, page, physical);
+ get_page(page);
+
+ DRM_DEBUG("0x%08lx (page %lu) => 0x%08x\n", address, page_nr,
+ page_to_bus(page));
#if LINUX_VERSION_CODE < 0x020317
- return physical;
+ return page_address(page);
#else
- return virt_to_page(physical);
+ return page;
#endif
}
@@ -331,10 +339,10 @@ struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
map_offset = map->offset - dev->sg->handle;
page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT);
page = entry->pagelist[page_offset];
- atomic_inc(&page->count); /* Dec. by kernel */
+ get_page(page);
#if LINUX_VERSION_CODE < 0x020317
- return (unsigned long)virt_to_phys(page->virtual);
+ return page_address(page);
#else
return page;
#endif
diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c
index 819aacb4..1ab8b930 100644
--- a/linux-core/i810_dma.c
+++ b/linux-core/i810_dma.c
@@ -452,7 +452,6 @@ static int i810_dma_initialize(drm_device_t *dev,
DRM_ERROR("can not find sarea!\n");
DRM_OS_RETURN(EINVAL);
}
-
DRM_FIND_MAP( dev_priv->mmio_map, init->mmio_offset );
if(!dev_priv->mmio_map) {
dev->dev_private = (void *)dev_priv;
diff --git a/linux/ati_pcigart.h b/linux/ati_pcigart.h
index 99d17ee7..a794b3e0 100644
--- a/linux/ati_pcigart.h
+++ b/linux/ati_pcigart.h
@@ -133,9 +133,9 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
#if defined(__alpha__) && (LINUX_VERSION_CODE >= 0x020400)
/* we need to support large memory configurations */
entry->busaddr[i] = pci_map_single(dev->pdev,
- entry->pagelist[i]->virtual,
- PAGE_SIZE,
- PCI_DMA_TODEVICE);
+ page_address( entry->pagelist[i] ),
+ PAGE_SIZE,
+ PCI_DMA_TODEVICE);
if (entry->busaddr[i] == 0) {
DRM_ERROR( "unable to map PCIGART pages!\n" );
DRM(ati_pcigart_cleanup)( dev, address, bus_address );
@@ -145,7 +145,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
}
page_base = (u32) entry->busaddr[i];
#else
- page_base = virt_to_bus( entry->pagelist[i]->virtual );
+ page_base = page_to_bus( entry->pagelist[i] );
#endif
for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
*pci_gart++ = cpu_to_le32( page_base );
diff --git a/linux/drm_context.h b/linux/drm_context.h
index 0ab0c256..3a75afd0 100644
--- a/linux/drm_context.h
+++ b/linux/drm_context.h
@@ -93,7 +93,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
DRM_MEM_MAPS);
if(!dev->context_sareas) {
clear_bit(bit, dev->ctx_bitmap);
- DRM_OS_UNLOCK;
+ up(&dev->struct_sem);
return -1;
}
dev->context_sareas[bit] = NULL;
@@ -156,7 +156,7 @@ int DRM(getsareactx)( DRM_OS_IOCTL )
sizeof(request) );
DRM_OS_LOCK;
- if ((int)request.ctx_id >= dev->max_context) {
+ if (dev->max_context < 0 || request.ctx_id >= (unsigned) dev->max_context) {
DRM_OS_UNLOCK;
DRM_OS_RETURN(EINVAL);
}
@@ -192,33 +192,34 @@ int DRM(setsareactx)( DRM_OS_IOCTL )
list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *)list;
if(r_list->map &&
- r_list->map->handle == request.handle) break;
+ r_list->map->handle == request.handle)
+ goto found;
}
- if (list == &(dev->maplist->head)) {
- DRM_OS_UNLOCK;
- DRM_OS_RETURN(EINVAL);
- }
- map = r_list->map;
#endif
#ifdef __FreeBSD__
TAILQ_FOREACH(list, dev->maplist, link) {
map=list->map;
- if(map->handle == request.handle) break;
- }
- if (!list) {
- lockmgr( &dev->dev_lock, LK_RELEASE, 0, curproc );
- return EINVAL;
+ if(map->handle == request.handle)
+ goto found;
}
#endif
- DRM_OS_UNLOCK;
- if (!map) DRM_OS_RETURN(EINVAL);
+bad:
+ DRM_OS_UNLOCK;
+ return -EINVAL;
- DRM_OS_LOCK;
- if ((int)request.ctx_id >= dev->max_context) {
- DRM_OS_UNLOCK;
- DRM_OS_RETURN(EINVAL);
- }
+found:
+#ifdef __linux__
+ map = r_list->map;
+#endif
+#ifdef __FreeBSD__
+ map = list->map;
+#endif
+ if (!map) goto bad;
+ if (dev->max_context < 0)
+ goto bad;
+ if (request.ctx_id >= (unsigned) dev->max_context)
+ goto bad;
dev->context_sareas[request.ctx_id] = map;
DRM_OS_UNLOCK;
return 0;
diff --git a/linux/drm_drv.h b/linux/drm_drv.h
index 20bd6682..66aa05a2 100644
--- a/linux/drm_drv.h
+++ b/linux/drm_drv.h
@@ -155,6 +155,7 @@ static struct file_operations DRM(fops) = { \
#endif /* __FreeBSD__ */
#endif
+
/*
* The default number of instances (minor numbers) to initialize.
*/
@@ -723,6 +724,7 @@ static int __init drm_init( void )
static int DRM(init)( device_t nbdev )
#endif
{
+
drm_device_t *dev;
int i;
#if __HAVE_CTX_BITMAP
@@ -854,6 +856,8 @@ static void DRM(cleanup)(device_t nbdev)
drm_device_t *dev;
int i;
+ DRM_DEBUG( "\n" );
+
for (i = DRM(numdevs) - 1; i >= 0; i--) {
#ifdef __linux__
dev = &(DRM(device)[i]);
diff --git a/linux/drm_ioctl.h b/linux/drm_ioctl.h
index adcd36d6..97f3b33a 100644
--- a/linux/drm_ioctl.h
+++ b/linux/drm_ioctl.h
@@ -158,7 +158,7 @@ int DRM(setunique)( DRM_OS_IOCTL )
pci_dev = pci_find_slot(b, PCI_DEVFN(d,f));
if (pci_dev) {
dev->pdev = pci_dev;
- dev->hose = pci_dev->sysdata;
+ dev->hose = pci_dev->sysdata;
}
} while(0);
#endif
diff --git a/linux/drm_os_linux.h b/linux/drm_os_linux.h
index fee24cc1..55a7a3cd 100644
--- a/linux/drm_os_linux.h
+++ b/linux/drm_os_linux.h
@@ -39,6 +39,12 @@
#include "compat-pre24.h"
#endif
#include <asm/pgalloc.h>
+#include "drm.h"
+
+/* page_to_bus for earlier kernels, not optimal in all cases */
+#ifndef page_to_bus
+#define page_to_bus(page) ((unsigned int)(virt_to_bus(page_address(page))))
+#endif
#define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
diff --git a/linux/drm_scatter.h b/linux/drm_scatter.h
index 5654c8cb..66d34968 100644
--- a/linux/drm_scatter.h
+++ b/linux/drm_scatter.h
@@ -179,7 +179,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
for ( i = 0 ; i < pages ; i++ ) {
unsigned long *tmp;
- tmp = (unsigned long *)entry->pagelist[i]->virtual;
+ tmp = page_address( entry->pagelist[i] );
for ( j = 0 ;
j < PAGE_SIZE / sizeof(unsigned long) ;
j++, tmp++ ) {
@@ -197,7 +197,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
"virtual mapping\n" );
}
}
- tmp = (unsigned long *)entry->pagelist[i]->virtual;
+ tmp = page_address( entry->pagelist[i] );
for(j = 0 ;
j < PAGE_SIZE / sizeof(unsigned long) ;
j++, tmp++) {
diff --git a/linux/drm_vm.h b/linux/drm_vm.h
index 40f6c7f7..b5a5deb6 100644
--- a/linux/drm_vm.h
+++ b/linux/drm_vm.h
@@ -68,61 +68,65 @@ struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
#endif
{
#if defined(__alpha__) && __REALLY_HAVE_AGP
- drm_file_t *priv = vma->vm_file->private_data;
- drm_device_t *dev = priv->dev;
- drm_map_t *map = NULL;
- drm_map_list_t *r_list;
- struct list_head *list;
+ drm_file_t *priv = vma->vm_file->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_map_t *map = NULL;
+ drm_map_list_t *r_list;
+ struct list_head *list;
- /*
+ /*
* Find the right map
*/
- list_for_each(list, &dev->maplist->head) {
- r_list = (drm_map_list_t *)list;
- map = r_list->map;
- if (!map) continue;
- if (map->offset == VM_OFFSET(vma)) break;
- }
+ list_for_each(list, &dev->maplist->head) {
+ r_list = (drm_map_list_t *)list;
+ map = r_list->map;
+ if (!map) continue;
+ if (map->offset == VM_OFFSET(vma)) break;
+ }
- if (map && map->type == _DRM_AGP) {
- unsigned long offset = address - vma->vm_start;
- unsigned long baddr = VM_OFFSET(vma) + offset;
- struct drm_agp_mem *agpmem;
- struct page *page;
+ if (map && map->type == _DRM_AGP) {
+ unsigned long offset = address - vma->vm_start;
+ unsigned long baddr = VM_OFFSET(vma) + offset;
+ struct drm_agp_mem *agpmem;
+ struct page *page;
- /*
+ /*
* Make it a bus-relative address
*/
- baddr -= dev->hose->mem_space->start;
+ baddr -= dev->hose->mem_space->start;
- /*
+ /*
* It's AGP memory - find the real physical page to map
*/
- for(agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) {
- if (agpmem->bound <= baddr &&
- agpmem->bound + agpmem->pages * PAGE_SIZE > baddr)
- break;
- }
+ for(agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) {
+ if (agpmem->bound <= baddr &&
+ agpmem->bound + agpmem->pages * PAGE_SIZE > baddr)
+ break;
+ }
- if (!agpmem) {
- /*
+ if (!agpmem) {
+ /*
* Oops - no memory found
*/
- return NOPAGE_SIGBUS; /* couldn't find it */
+ return NOPAGE_SIGBUS; /* couldn't find it */
}
- /*
+ /*
* Get the page, inc the use count, and return it
*/
- offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
+ offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
agpmem->memory->memory[offset] &= ~1UL; /* HACK */
- page = virt_to_page(__va(agpmem->memory->memory[offset]));
+ page = virt_to_page(__va(agpmem->memory->memory[offset]));
#if 0
-DRM_ERROR("baddr = 0x%lx page = 0x%lx, offset = 0x%lx\n",
- baddr, __va(agpmem->memory->memory[offset]), offset);
+ DRM_ERROR("baddr = 0x%lx page = 0x%lx, offset = 0x%lx\n",
+ baddr, __va(agpmem->memory->memory[offset]), offset);
+#endif
+ get_page(page);
+#if LINUX_VERSION_CODE < 0x020317
+ return page_address(page);
+#else
+ return page;
#endif
- get_page(page);
- return page;
}
#endif
return NOPAGE_SIGBUS; /* Disallow mremap */
@@ -144,12 +148,12 @@ struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
#else
drm_map_t *map = (drm_map_t *)vma->vm_pte;
#endif
- unsigned long physical;
unsigned long offset;
unsigned long i;
pgd_t *pgd;
pmd_t *pmd;
pte_t *pte;
+ struct page *page;
if (address > vma->vm_end) return NOPAGE_SIGBUS; /* Disallow mremap */
if (!map) return NOPAGE_OOM; /* Nothing allocated */
@@ -165,14 +169,15 @@ struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
if( !pmd_present( *pmd ) ) return NOPAGE_OOM;
pte = pte_offset( pmd, i );
if( !pte_present( *pte ) ) return NOPAGE_OOM;
- physical = (unsigned long)pte_page( *pte )->virtual;
- atomic_inc(&virt_to_page(physical)->count); /* Dec. by kernel */
- DRM_DEBUG("0x%08lx => 0x%08lx\n", address, physical);
+ page = pte_page(*pte);
+ get_page(page);
+
+ DRM_DEBUG("0x%08lx => 0x%08x\n", address, page_to_bus(page));
#if LINUX_VERSION_CODE < 0x020317
- return physical;
+ return page_address(page);
#else
- return virt_to_page(physical);
+ return page;
#endif
}
@@ -277,24 +282,27 @@ struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev;
drm_device_dma_t *dma = dev->dma;
- unsigned long physical;
unsigned long offset;
- unsigned long page;
+ unsigned long page_nr;
+ struct page *page;
if (!dma) return NOPAGE_SIGBUS; /* Error */
if (address > vma->vm_end) return NOPAGE_SIGBUS; /* Disallow mremap */
if (!dma->pagelist) return NOPAGE_OOM ; /* Nothing allocated */
offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
- page = offset >> PAGE_SHIFT;
- physical = dma->pagelist[page] + (offset & (~PAGE_MASK));
- atomic_inc(&virt_to_page(physical)->count); /* Dec. by kernel */
+ page_nr = offset >> PAGE_SHIFT;
+ page = virt_to_page((dma->pagelist[page_nr] +
+ (offset & (~PAGE_MASK))));
- DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\n", address, page, physical);
+ get_page(page);
+
+ DRM_DEBUG("0x%08lx (page %lu) => 0x%08x\n", address, page_nr,
+ page_to_bus(page));
#if LINUX_VERSION_CODE < 0x020317
- return physical;
+ return page_address(page);
#else
- return virt_to_page(physical);
+ return page;
#endif
}
@@ -331,10 +339,10 @@ struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
map_offset = map->offset - dev->sg->handle;
page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT);
page = entry->pagelist[page_offset];
- atomic_inc(&page->count); /* Dec. by kernel */
+ get_page(page);
#if LINUX_VERSION_CODE < 0x020317
- return (unsigned long)virt_to_phys(page->virtual);
+ return page_address(page);
#else
return page;
#endif
diff --git a/linux/i810_dma.c b/linux/i810_dma.c
index 819aacb4..1ab8b930 100644
--- a/linux/i810_dma.c
+++ b/linux/i810_dma.c
@@ -452,7 +452,6 @@ static int i810_dma_initialize(drm_device_t *dev,
DRM_ERROR("can not find sarea!\n");
DRM_OS_RETURN(EINVAL);
}
-
DRM_FIND_MAP( dev_priv->mmio_map, init->mmio_offset );
if(!dev_priv->mmio_map) {
dev->dev_private = (void *)dev_priv;
diff --git a/linux/mga_dma.c b/linux/mga_dma.c
index 29ecb59d..9d9df2e3 100644
--- a/linux/mga_dma.c
+++ b/linux/mga_dma.c
@@ -548,7 +548,6 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
mga_do_cleanup_dma( dev );
DRM_OS_RETURN(EINVAL);
}
-
DRM_FIND_MAP( dev_priv->warp, init->warp_offset );
if(!dev_priv->warp) {
DRM_ERROR( "failed to find warp microcode region!\n" );
diff --git a/linux/r128_cce.c b/linux/r128_cce.c
index f0477139..ed3c221d 100644
--- a/linux/r128_cce.c
+++ b/linux/r128_cce.c
@@ -364,10 +364,10 @@ static void r128_cce_init_ring_buffer( drm_device_t *dev,
entry->handle + tmp_ofs );
#else
R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR,
- DRM_OS_VTOPHYS( entry->pagelist[page_ofs]->virtual ) );
+ page_to_bus(entry->pagelist[page_ofs]));
- DRM_DEBUG( "ring rptr: offset=0x%08lx handle=0x%08lx\n",
- virt_to_bus(entry->pagelist[page_ofs]->virtual),
+ DRM_DEBUG( "ring rptr: offset=0x%08x handle=0x%08lx\n",
+ page_to_bus(entry->pagelist[page_ofs]),
entry->handle + tmp_ofs );
#endif
}
diff --git a/linux/radeon_cp.c b/linux/radeon_cp.c
index afd56f9f..5907df75 100644
--- a/linux/radeon_cp.c
+++ b/linux/radeon_cp.c
@@ -638,10 +638,10 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev,
entry->handle + tmp_ofs );
#else
RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR,
- virt_to_bus(entry->pagelist[page_ofs]->virtual));
+ page_to_bus(entry->pagelist[page_ofs]));
- DRM_DEBUG( "ring rptr: offset=0x%08lx handle=0x%08lx\n",
- virt_to_bus(entry->pagelist[page_ofs]->virtual),
+ DRM_DEBUG( "ring rptr: offset=0x%08x handle=0x%08lx\n",
+ page_to_bus(entry->pagelist[page_ofs]),
entry->handle + tmp_ofs );
#endif
}