summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorJeff Hartmann <jhartmann@valinux.com>2001-08-13 23:23:47 +0000
committerJeff Hartmann <jhartmann@valinux.com>2001-08-13 23:23:47 +0000
commitaa09e3611490d6a2f12f211c3c834f1237126313 (patch)
tree0938669d60d1697e119ed218f276aaa38830e29e /linux
parent2d4b2cf6f69de2ceaf0c2b00ccbb24aad412b202 (diff)
Sync with Linus 2.4.9-pre2 + make all nopage routines more alike
Diffstat (limited to 'linux')
-rw-r--r--linux/ati_pcigart.h8
-rw-r--r--linux/drmP.h5
-rw-r--r--linux/drm_context.h26
-rw-r--r--linux/drm_scatter.h4
-rw-r--r--linux/drm_vm.h40
-rw-r--r--linux/r128_cce.c4
-rw-r--r--linux/radeon_cp.c4
7 files changed, 51 insertions, 40 deletions
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/drmP.h b/linux/drmP.h
index 8e2ecd16..f0a7ebf4 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -76,6 +76,11 @@
#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) (virt_to_bus(page_address(page)))
+#endif
+
/* DRM template customization defaults
*/
#ifndef __HAVE_AGP
diff --git a/linux/drm_context.h b/linux/drm_context.h
index 5e54d81a..eb4d61c8 100644
--- a/linux/drm_context.h
+++ b/linux/drm_context.h
@@ -160,7 +160,7 @@ int DRM(getsareactx)(struct inode *inode, struct file *filp,
return -EFAULT;
down(&dev->struct_sem);
- if ((int)request.ctx_id >= dev->max_context) {
+ if (dev->max_context < 0 || request.ctx_id >= (unsigned) dev->max_context) {
up(&dev->struct_sem);
return -EINVAL;
}
@@ -193,22 +193,20 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp,
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)) {
- up(&dev->struct_sem);
- return -EINVAL;
- }
- map = r_list->map;
+bad:
up(&dev->struct_sem);
+ return -EINVAL;
- if (!map) return -EINVAL;
-
- down(&dev->struct_sem);
- if ((int)request.ctx_id >= dev->max_context) {
- up(&dev->struct_sem);
- return -EINVAL;
- }
+found:
+ map = r_list->map;
+ 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;
up(&dev->struct_sem);
return 0;
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 2a5ee146..8119a21b 100644
--- a/linux/drm_vm.h
+++ b/linux/drm_vm.h
@@ -122,7 +122,11 @@ 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
}
#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%08lx\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))));
+
+ get_page(page);
- DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\n", address, page, physical);
+ DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\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/r128_cce.c b/linux/r128_cce.c
index 24b6de8d..fb19010c 100644
--- a/linux/r128_cce.c
+++ b/linux/r128_cce.c
@@ -358,10 +358,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,
- 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),
+ 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 51596c7b..d95df0da 100644
--- a/linux/radeon_cp.c
+++ b/linux/radeon_cp.c
@@ -630,10 +630,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),
+ page_to_bus(entry->pagelist[page_ofs]),
entry->handle + tmp_ofs );
#endif
}