drm: update PCIGART support from CVS

In order to work on FreeBSD the gart needed to use a local mapping
This patch moves the mainline to the new code and aligns some comment
changes

From: Eric Anholt <anholt@freebsd.org>
Signed-off-by: Dave Airlie <airlied@linux.ie>

authored by Dave Airlie and committed by Dave Airlie f26c473c 0a406877

+43 -38
+11 -12
drivers/char/drm/ati_pcigart.c
··· 52 52 # define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */ 53 53 # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ 54 54 55 - static unsigned long drm_ati_alloc_pcigart_table(void) 55 + static void *drm_ati_alloc_pcigart_table(void) 56 56 { 57 57 unsigned long address; 58 58 struct page *page; ··· 72 72 } 73 73 74 74 DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address); 75 - return address; 75 + return (void *)address; 76 76 } 77 77 78 - static void drm_ati_free_pcigart_table(unsigned long address) 78 + static void drm_ati_free_pcigart_table(void *address) 79 79 { 80 80 struct page *page; 81 81 int i; 82 82 DRM_DEBUG("%s\n", __FUNCTION__); 83 83 84 - page = virt_to_page(address); 84 + page = virt_to_page((unsigned long)address); 85 85 86 86 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { 87 87 __put_page(page); 88 88 ClearPageReserved(page); 89 89 } 90 90 91 - free_pages(address, ATI_PCIGART_TABLE_ORDER); 91 + free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER); 92 92 } 93 93 94 - int drm_ati_pcigart_cleanup(drm_device_t * dev, 95 - drm_ati_pcigart_info * gart_info) 94 + int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info) 96 95 { 97 96 drm_sg_mem_t *entry = dev->sg; 98 97 unsigned long pages; ··· 135 136 136 137 EXPORT_SYMBOL(drm_ati_pcigart_cleanup); 137 138 138 - int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info) 139 + int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) 139 140 { 140 141 drm_sg_mem_t *entry = dev->sg; 141 - unsigned long address = 0; 142 + void *address = NULL; 142 143 unsigned long pages; 143 144 u32 *pci_gart, page_base, bus_address = 0; 144 145 int i, j, ret = 0; ··· 162 163 goto done; 163 164 } 164 165 165 - bus_address = pci_map_single(dev->pdev, (void *)address, 166 + bus_address = pci_map_single(dev->pdev, address, 166 167 ATI_PCIGART_TABLE_PAGES * 167 168 PAGE_SIZE, PCI_DMA_TODEVICE); 168 169 if (bus_address == 0) { ··· 175 176 address = gart_info->addr; 176 177 bus_address = gart_info->bus_addr; 177 178 DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", 178 - bus_address, address); 179 + bus_address, (unsigned long)address); 179 180 } 180 181 181 182 pci_gart = (u32 *) address; ··· 194 195 if (entry->busaddr[i] == 0) { 195 196 DRM_ERROR("unable to map PCIGART pages!\n"); 196 197 drm_ati_pcigart_cleanup(dev, gart_info); 197 - address = 0; 198 + address = NULL; 198 199 bus_address = 0; 199 200 goto done; 200 201 }
+2 -1
drivers/char/drm/drmP.h
··· 522 522 typedef struct ati_pcigart_info { 523 523 int gart_table_location; 524 524 int is_pcie; 525 - unsigned long addr; 525 + void *addr; 526 526 dma_addr_t bus_addr; 527 + drm_local_map_t mapping; 527 528 } drm_ati_pcigart_info; 528 529 529 530 /**
+9 -6
drivers/char/drm/r128_cce.c
··· 1 - /* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*- 1 + /* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*- 2 2 * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com 3 - * 3 + */ 4 + /* 4 5 * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. 5 6 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 6 7 * All Rights Reserved. ··· 560 559 if (dev_priv->is_pci) { 561 560 #endif 562 561 dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN; 563 - dev_priv->gart_info.addr = dev_priv->gart_info.bus_addr = 0; 562 + dev_priv->gart_info.addr = NULL; 563 + dev_priv->gart_info.bus_addr = 0; 564 564 dev_priv->gart_info.is_pcie = 0; 565 565 if (!drm_ati_pcigart_init(dev, &dev_priv->gart_info)) { 566 566 DRM_ERROR("failed to init PCI GART!\n"); ··· 603 601 drm_core_ioremapfree(dev_priv->cce_ring, dev); 604 602 if (dev_priv->ring_rptr != NULL) 605 603 drm_core_ioremapfree(dev_priv->ring_rptr, dev); 606 - if (dev->agp_buffer_map != NULL) 604 + if (dev->agp_buffer_map != NULL) { 607 605 drm_core_ioremapfree(dev->agp_buffer_map, dev); 606 + dev->agp_buffer_map = NULL; 607 + } 608 608 } else 609 609 #endif 610 610 { 611 611 if (dev_priv->gart_info.bus_addr) 612 612 if (!drm_ati_pcigart_cleanup(dev, 613 - &dev_priv-> 614 - gart_info)) 613 + &dev_priv->gart_info)) 615 614 DRM_ERROR 616 615 ("failed to cleanup PCI GART!\n"); 617 616 }
+2 -2
drivers/char/drm/r128_drm.h
··· 1 1 /* r128_drm.h -- Public header for the r128 driver -*- linux-c -*- 2 2 * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com 3 - * 4 - * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. 3 + */ 4 + /* Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. 5 5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 6 6 * All rights reserved. 7 7 *
+2 -2
drivers/char/drm/r128_drv.h
··· 1 1 /* r128_drv.h -- Private header for r128 driver -*- linux-c -*- 2 2 * Created: Mon Dec 13 09:51:11 1999 by faith@precisioninsight.com 3 - * 4 - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 3 + */ 4 + /* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 5 5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 6 6 * All rights reserved. 7 7 *
+2 -2
drivers/char/drm/r128_irq.c
··· 1 - /* r128_irq.c -- IRQ handling for radeon -*- linux-c -*- 2 - * 1 + /* r128_irq.c -- IRQ handling for radeon -*- linux-c -*- */ 2 + /* 3 3 * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. 4 4 * 5 5 * The Weather Channel (TM) funded Tungsten Graphics to develop the
+2 -2
drivers/char/drm/r128_state.c
··· 1 1 /* r128_state.c -- State support for r128 -*- linux-c -*- 2 2 * Created: Thu Jan 27 02:53:43 2000 by gareth@valinux.com 3 - * 4 - * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 3 + */ 4 + /* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 5 5 * All Rights Reserved. 6 6 * 7 7 * Permission is hereby granted, free of charge, to any person obtaining a
+13 -11
drivers/char/drm/radeon_cp.c
··· 1 - /* radeon_cp.c -- CP support for Radeon -*- linux-c -*- 2 - * 1 + /* radeon_cp.c -- CP support for Radeon -*- linux-c -*- */ 2 + /* 3 3 * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. 4 4 * Copyright 2000 VA Linux Systems, Inc., Fremont, California. 5 5 * All Rights Reserved. ··· 1561 1561 if (dev_priv->pcigart_offset) { 1562 1562 dev_priv->gart_info.bus_addr = 1563 1563 dev_priv->pcigart_offset + dev_priv->fb_location; 1564 + dev_priv->gart_info.mapping.offset = 1565 + dev_priv->gart_info.bus_addr; 1566 + dev_priv->gart_info.mapping.size = 1567 + RADEON_PCIGART_TABLE_SIZE; 1568 + 1569 + drm_core_ioremap(&dev_priv->gart_info.mapping, dev); 1564 1570 dev_priv->gart_info.addr = 1565 - (unsigned long)drm_ioremap(dev_priv->gart_info. 1566 - bus_addr, 1567 - RADEON_PCIGART_TABLE_SIZE, 1568 - dev); 1571 + dev_priv->gart_info.mapping.handle; 1569 1572 1570 1573 dev_priv->gart_info.is_pcie = 1571 1574 !!(dev_priv->flags & CHIP_IS_PCIE); 1572 1575 dev_priv->gart_info.gart_table_location = 1573 1576 DRM_ATI_GART_FB; 1574 1577 1575 - DRM_DEBUG("Setting phys_pci_gart to %08lX %08lX\n", 1578 + DRM_DEBUG("Setting phys_pci_gart to %p %08lX\n", 1576 1579 dev_priv->gart_info.addr, 1577 1580 dev_priv->pcigart_offset); 1578 1581 } else { 1579 1582 dev_priv->gart_info.gart_table_location = 1580 1583 DRM_ATI_GART_MAIN; 1581 - dev_priv->gart_info.addr = 1582 - dev_priv->gart_info.bus_addr = 0; 1584 + dev_priv->gart_info.addr = NULL; 1585 + dev_priv->gart_info.bus_addr = 0; 1583 1586 if (dev_priv->flags & CHIP_IS_PCIE) { 1584 1587 DRM_ERROR 1585 1588 ("Cannot use PCI Express without GART in FB memory\n"); ··· 1644 1641 DRM_ERROR("failed to cleanup PCI GART!\n"); 1645 1642 1646 1643 if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB) { 1647 - drm_ioremapfree((void *)dev_priv->gart_info.addr, 1648 - RADEON_PCIGART_TABLE_SIZE, dev); 1644 + drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev); 1649 1645 dev_priv->gart_info.addr = 0; 1650 1646 } 1651 1647 }