Sync with Linus 2.4.9-pre2 + make all nopage routines more alike

main
Jeff Hartmann 2001-08-13 23:23:47 +00:00
parent 2d4b2cf6f6
commit aa09e36114
12 changed files with 98 additions and 76 deletions

View File

@ -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 );

View File

@ -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

View File

@ -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;

View File

@ -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++) {

View File

@ -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))));
DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\n", address, page, physical);
get_page(page);
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

View File

@ -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 );

View File

@ -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

View File

@ -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;

View File

@ -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++) {

View File

@ -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))));
DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\n", address, page, physical);
get_page(page);
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

View File

@ -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
}

View File

@ -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
}