summaryrefslogtreecommitdiff
path: root/bsd-core/ati_pcigart.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2003-02-21 23:23:09 +0000
committerEric Anholt <anholt@freebsd.org>2003-02-21 23:23:09 +0000
commitcfa778af9c70faea8c13e5cb7f80029eee0d074e (patch)
tree15483e64b6c2b56d3bb0f247df9df2c2602e0404 /bsd-core/ati_pcigart.c
parenta64472d18493de575a7636704b45babe7b4b4572 (diff)
Merge from bsd-4-0-0-branch.
Diffstat (limited to 'bsd-core/ati_pcigart.c')
-rw-r--r--bsd-core/ati_pcigart.c51
1 files changed, 6 insertions, 45 deletions
diff --git a/bsd-core/ati_pcigart.c b/bsd-core/ati_pcigart.c
index 28723f56..ba0b81a7 100644
--- a/bsd-core/ati_pcigart.c
+++ b/bsd-core/ati_pcigart.c
@@ -42,25 +42,6 @@
# define ATI_MAX_PCIGART_PAGES 8192 /* 32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE 4096 /* PCI GART page size */
-static unsigned long DRM(ati_alloc_pcigart_table)( void )
-{
- unsigned long address;
-
- DRM_DEBUG( "\n" );
-
- address = (unsigned long) malloc( (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE, DRM(M_DRM), M_WAITOK );
-
- DRM_DEBUG( "returning 0x%08lx\n", address );
- return address;
-}
-
-static void DRM(ati_free_pcigart_table)( unsigned long address )
-{
- DRM_DEBUG( "\n" );
-
- free( (void *)address, DRM(M_DRM));
-}
-
int DRM(ati_pcigart_init)( drm_device_t *dev,
unsigned long *addr,
dma_addr_t *bus_addr)
@@ -76,23 +57,15 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
goto done;
}
- address = DRM(ati_alloc_pcigart_table)();
+ address = (long)contigmalloc((1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE,
+ DRM(M_DRM), M_WAITOK, 0ul, 0xfffffffful, PAGE_SIZE, 0);
if ( !address ) {
DRM_ERROR( "cannot allocate PCI GART page!\n" );
goto done;
}
- /* FIXME non-vtophys==bustophys-arches */
+ /* XXX: we need to busdma this */
bus_address = vtophys( address );
- /*pci_map_single(dev->pdev, (void *)address,
- ATI_PCIGART_TABLE_PAGES * PAGE_SIZE,
- PCI_DMA_TODEVICE);*/
-/* if (bus_address == 0) {
- DRM_ERROR( "unable to map PCIGART pages!\n" );
- DRM(ati_free_pcigart_table)( (unsigned long)address );
- address = 0;
- goto done;
- }*/
pci_gart = (u32 *)address;
@@ -102,16 +75,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
bzero( pci_gart, ATI_MAX_PCIGART_PAGES * sizeof(u32) );
for ( i = 0 ; i < pages ; i++ ) {
- /* we need to support large memory configurations */
- /* FIXME non-vtophys==vtobus-arches */
entry->busaddr[i] = vtophys( entry->handle + (i*PAGE_SIZE) );
-/* if (entry->busaddr[i] == 0) {
- DRM_ERROR( "unable to map PCIGART pages!\n" );
- DRM(ati_pcigart_cleanup)( dev, (unsigned long)address, bus_address );
- address = 0;
- bus_address = 0;
- goto done;
- }*/
page_base = (u32) entry->busaddr[i];
for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
@@ -122,8 +86,6 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
ret = 1;
- DRM_READMEMORYBARRIER();
-
done:
*addr = address;
*bus_addr = bus_address;
@@ -142,9 +104,8 @@ int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
return 0;
}
- if ( addr ) {
- DRM(ati_free_pcigart_table)( addr );
- }
-
+#if __FreeBSD_version > 500000
+ contigfree( (void *)addr, (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE, DRM(M_DRM)); /* Not available on 4.x */
+#endif
return 1;
}